diff --git a/oversampling/HIIR/FPUDownsampler2x.h b/oversampling/HIIR/FPUDownsampler2x.h deleted file mode 100644 index b4fbe01..0000000 --- a/oversampling/HIIR/FPUDownsampler2x.h +++ /dev/null @@ -1,257 +0,0 @@ -/* - -FPUDownsampler2x.h -Copyright(c) 2005 Laurent de Soras - -Downsamples the input signal by a factor 2, using FPU. - -Template parameters: - - NC: number of coefficients, > 0 - - --- Legal stuff --- - -This program is free software. It comes without any warranty, to -the extent permitted by applicable law. You can redistribute it -and/or modify it under the terms of the Do What The Fuck You Want -To Public License, Version 2, as published by Sam Hocevar. See -http://sam.zoy.org/wtfpl/COPYING for more details. - -*/ - -#include -#include "FPUStageProc.h" - -namespace hiir -{ -template -class Downsampler2xFPU -{ -public: - enum { NBR_COEFS = NC }; - Downsampler2xFPU(); - - /* - Name: set_coefs - Description: - Sets filter coefficients. Generate them with the PolyphaseIir2Designer - class. - Call this function before doing any processing. - Input parameters: - - coef_arr: Array of coefficients. There should be as many coefficients as - mentioned in the class template parameter. - */ - void set_coefs(const double coef_arr[]); - - /* - Name: process_sample - Description: - Downsamples (x2) one pair of samples, to generate one output sample. - Input parameters: - - in_ptr: pointer on the two samples to decimate - Returns: Samplerate-reduced sample. - */ - inline T process_sample(const T in_ptr [2]); - - /* - Name: process_block - Description: - Downsamples (x2) a block of samples. - Input and output blocks may overlap, see assert() for details. - Input parameters: - - in_ptr: Input array, containing nbr_spl * 2 samples. - - nbr_spl: Number of samples to output, > 0 - Output parameters: - - out_ptr: Array for the output samples, capacity: nbr_spl samples. - */ - void process_block(T out_ptr[], const T in_ptr[], long nbr_spl); - - /* - Name: process_sample_split - Description: - Split (spectrum-wise) in half a pair of samples. The lower part of the - spectrum is a classic downsampling, equivalent to the output of - process_sample(). - The higher part is the complementary signal: original filter response - is flipped from left to right, becoming a high-pass filter with the same - cutoff frequency. This signal is then critically sampled (decimation by 2), - flipping the spectrum: Fs/4...Fs/2 becomes Fs/4...0. - Input parameters: - - in_ptr: pointer on the pair of input samples - Output parameters: - - low: output sample, lower part of the spectrum (downsampling) - - high: output sample, higher part of the spectrum. - */ - inline void process_sample_split(T &low, T &high, const T in_ptr[2]); - - /* - Name: process_block_split - Description: - Split (spectrum-wise) in half a block of samples. The lower part of the - spectrum is a classic downsampling, equivalent to the output of - process_block(). - The higher part is the complementary signal: original filter response - is flipped from left to right, becoming a high-pass filter with the same - cutoff frequency. This signal is then critically sampled (decimation by 2), - flipping the spectrum: Fs/4...Fs/2 becomes Fs/4...0. - Input and output blocks may overlap, see assert() for details. - Input parameters: - - in_ptr: Input array, containing nbr_spl * 2 samples. - - nbr_spl: Number of samples for each output, > 0 - Output parameters: - - out_l_ptr: Array for the output samples, lower part of the spectrum - (downsampling). Capacity: nbr_spl samples. - - out_h_ptr: Array for the output samples, higher part of the spectrum. - Capacity: nbr_spl samples. - */ - void process_block_split(T out_l_ptr[], T out_h_ptr[], const T in_ptr[], long nbr_spl); - - /* - Name: clear_buffers - Description: - Clears filter memory, as if it processed silence since an infinite amount - of time. - */ - void clear_buffers(); - -private: - std::array _coef; - std::array _x; - std::array _y; - -private: - bool operator == (const Downsampler2xFPU &other); - bool operator != (const Downsampler2xFPU &other); - -}; // class Downsampler2xFPU - - -template -Downsampler2xFPU ::Downsampler2xFPU () -: _coef () -, _x () -, _y () -{ - for (int i = 0; i < NBR_COEFS; ++i) - { - _coef [i] = 0; - } - clear_buffers (); -} - -template -void Downsampler2xFPU ::set_coefs (const double coef_arr[]) -{ - assert (coef_arr != 0); - - for (int i = 0; i < NBR_COEFS; ++i) - { - _coef [i] = static_cast (coef_arr [i]); - } -} - -template -T Downsampler2xFPU ::process_sample (const T in_ptr [2]) -{ - assert (in_ptr != 0); - - T spl_0 (in_ptr [1]); - T spl_1 (in_ptr [0]); - - #if defined (_MSC_VER) - #pragma inline_depth (255) - #endif // _MSC_VER - - StageProcFPU ::process_sample_pos ( - NBR_COEFS, - spl_0, - spl_1, - &_coef [0], - &_x [0], - &_y [0] - ); - - return (0.5f * (spl_0 + spl_1)); -} - - -template -void Downsampler2xFPU ::process_block (T out_ptr[], const T in_ptr[], long nbr_spl) -{ - assert (in_ptr != 0); - assert (out_ptr != 0); - assert (out_ptr <= in_ptr || out_ptr >= in_ptr + nbr_spl * 2); - assert (nbr_spl > 0); - - long pos = 0; - do - { - out_ptr [pos] = process_sample (&in_ptr [pos * 2]); - ++pos; - } - while (pos < nbr_spl); -} - -template -void Downsampler2xFPU ::process_sample_split (T &low, T &high, const T in_ptr [2]) -{ - assert (&low != 0); - assert (&high != 0); - assert (in_ptr != 0); - - T spl_0 = in_ptr [1]; - T spl_1 = in_ptr [0]; - - #if defined (_MSC_VER) - #pragma inline_depth (255) - #endif // _MSC_VER - - StageProcFPU ::process_sample_pos ( - NBR_COEFS, - spl_0, - spl_1, - &_coef [0], - &_x [0], - &_y [0] - ); - - low = (spl_0 + spl_1) * 0.5f; - high = spl_0 - low; // (spl_0 - spl_1) * 0.5f; -} - -template -void Downsampler2xFPU ::process_block_split (T out_l_ptr[], T out_h_ptr[], const T in_ptr[], long nbr_spl) -{ - assert (in_ptr != 0); - assert (out_l_ptr != 0); - assert (out_l_ptr <= in_ptr || out_l_ptr >= in_ptr + nbr_spl * 2); - assert (out_h_ptr != 0); - assert (out_h_ptr <= in_ptr || out_h_ptr >= in_ptr + nbr_spl * 2); - assert (out_h_ptr != out_l_ptr); - assert (nbr_spl > 0); - - long pos = 0; - do - { - process_sample_split - ( - out_l_ptr [pos], - out_h_ptr [pos], - &in_ptr [pos * 2] - ); - ++pos; - } - while (pos < nbr_spl); -} - -template -void Downsampler2xFPU ::clear_buffers () -{ - for (int i = 0; i < NBR_COEFS; ++i) - { - _x [i] = 0; - _y [i] = 0; - } -} - -} // namespace hiir - diff --git a/oversampling/HIIR/FPUStageProc.h b/oversampling/HIIR/FPUStageProc.h deleted file mode 100644 index 5f0b2e0..0000000 --- a/oversampling/HIIR/FPUStageProc.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - StageProcFPU.h - Copyright (c) 2005 Laurent de Soras - -Template parameters: - - REMAINING: Number of remaining coefficients to process, >= 0 - - --- Legal stuff --- - -This program is free software. It comes without any warranty, to -the extent permitted by applicable law. You can redistribute it -and/or modify it under the terms of the Do What The Fuck You Want -To Public License, Version 2, as published by Sam Hocevar. See -http://sam.zoy.org/wtfpl/COPYING for more details. - -*/ - -#pragma once - -namespace hiir -{ - -template -class StageProcFPU -{ -public: - static inline void process_sample_pos (const int nbr_coefs, T &spl_0, T &spl_1, const T coef [], T x [], T y []); - static inline void process_sample_neg (const int nbr_coefs, T &spl_0, T &spl_1, const T coef [], T x [], T y []); - -private: - StageProcFPU(); - StageProcFPU(const StageProcFPU &other); - StageProcFPU& operator = (const StageProcFPU &other); - bool operator == (const StageProcFPU &other); - bool operator != (const StageProcFPU &other); - -}; // class StageProcFPU - -template <> -inline void StageProcFPU <1, double>::process_sample_pos (const int nbr_coefs, double &spl_0, double &/*spl_1*/, const double coef [], double x [], double y []) -{ - const int last = nbr_coefs - 1; - const double temp = (spl_0 - y [last]) * coef [last] + x [last]; - x [last] = spl_0; - y [last] = temp; - spl_0 = temp; -} - -template <> -inline void StageProcFPU <0, double>::process_sample_pos (const int /*nbr_coefs*/, double &/*spl_0*/, double &/*spl_1*/, const double /*coef*/ [], double /*x*/ [], double /*y*/ []) -{ - // Nothing (stops recursion) -} - -template <> -inline void StageProcFPU <1, float>::process_sample_pos (const int nbr_coefs, float &spl_0, float &/*spl_1*/, const float coef [], float x [], float y []) -{ - const int last = nbr_coefs - 1; - const float temp = (spl_0 - y [last]) * coef [last] + x [last]; - x [last] = spl_0; - y [last] = temp; - spl_0 = temp; -} - -template <> -inline void StageProcFPU <0, float>::process_sample_pos (const int /*nbr_coefs*/, float &/*spl_0*/, float &/*spl_1*/, const float /*coef*/ [], float /*x*/ [], float /*y*/ []) -{ - // Nothing (stops recursion) -} - -template -void StageProcFPU ::process_sample_pos (const int nbr_coefs, T &spl_0, T &spl_1, const T coef [], T x [], T y []) -{ - const int cnt = nbr_coefs - REMAINING; - - const T temp_0 = - (spl_0 - y [cnt + 0]) * coef [cnt + 0] + x [cnt + 0]; - const T temp_1 = - (spl_1 - y [cnt + 1]) * coef [cnt + 1] + x [cnt + 1]; - - x [cnt + 0] = spl_0; - x [cnt + 1] = spl_1; - - y [cnt + 0] = temp_0; - y [cnt + 1] = temp_1; - - spl_0 = temp_0; - spl_1 = temp_1; - - StageProcFPU ::process_sample_pos ( - nbr_coefs, - spl_0, - spl_1, - &coef [0], - &x [0], - &y [0] - ); -} - -template <> -inline void StageProcFPU <1, double>::process_sample_neg (const int nbr_coefs, double &spl_0, double &/*spl_1*/, const double coef [], double x [], double y []) -{ - const int last = nbr_coefs - 1; - const double temp = (spl_0 + y [last]) * coef [last] - x [last]; - x [last] = spl_0; - y [last] = temp; - spl_0 = temp; -} - -template <> -inline void StageProcFPU <0, double>::process_sample_neg (const int /*nbr_coefs*/, double &/*spl_0*/, double &/*spl_1*/, const double /*coef*/ [], double /*x*/ [], double /*y*/ []) -{ - // Nothing (stops recursion) -} - -template <> -inline void StageProcFPU <1, float>::process_sample_neg (const int nbr_coefs, float &spl_0, float &/*spl_1*/, const float coef [], float x [], float y []) -{ - const int last = nbr_coefs - 1; - const float temp = (spl_0 + y [last]) * coef [last] - x [last]; - x [last] = spl_0; - y [last] = temp; - spl_0 = temp; -} - -template <> -inline void StageProcFPU <0, float>::process_sample_neg (const int /*nbr_coefs*/, float &/*spl_0*/, float &/*spl_1*/, const float /*coef*/ [], float /*x*/ [], float /*y*/ []) -{ - // Nothing (stops recursion) -} - -template -void StageProcFPU ::process_sample_neg (const int nbr_coefs, T &spl_0, T &spl_1, const T coef [], T x [], T y []) -{ - const int cnt = nbr_coefs - REMAINING; - - const T temp_0 = - (spl_0 + y [cnt + 0]) * coef [cnt + 0] - x [cnt + 0]; - const T temp_1 = - (spl_1 + y [cnt + 1]) * coef [cnt + 1] - x [cnt + 1]; - - x [cnt + 0] = spl_0; - x [cnt + 1] = spl_1; - - y [cnt + 0] = temp_0; - y [cnt + 1] = temp_1; - - spl_0 = temp_0; - spl_1 = temp_1; - - StageProcFPU ::process_sample_neg ( - nbr_coefs, - spl_0, - spl_1, - &coef [0], - &x [0], - &y [0] - ); -} - - -} // namespace hiir diff --git a/oversampling/HIIR/FPUUpsampler2x.h b/oversampling/HIIR/FPUUpsampler2x.h deleted file mode 100755 index 95bfed3..0000000 --- a/oversampling/HIIR/FPUUpsampler2x.h +++ /dev/null @@ -1,168 +0,0 @@ -/* -FPUUpsampler2x.h -Copyright (c) 2005 Laurent de Soras - -Upsamples by a factor 2 the input signal, using FPU. - -Template parameters: -- NC: number of coefficients, > 0 - ---- Legal stuff --- - -This program is free software. It comes without any warranty, to -the extent permitted by applicable law. You can redistribute it -and/or modify it under the terms of the Do What The Fuck You Want -To Public License, Version 2, as published by Sam Hocevar. See -http://sam.zoy.org/wtfpl/COPYING for more details. - -*/ - -#pragma once - -#include -#include "FPUStageProc.h" - -namespace hiir -{ - -template -class Upsampler2xFPU -{ -public: - - enum { NBR_COEFS = NC }; - - Upsampler2xFPU (); - - /* - Name: set_coefs - Description: - Sets filter coefficients. Generate them with the PolyphaseIir2Designer - class. - Call this function before doing any processing. - Input parameters: - - coef_arr: Array of coefficients. There should be as many coefficients as - mentioned in the class template parameter. - */ - void set_coefs (const double coef_arr [NBR_COEFS]); - - /* - Name: process_sample - Description: - Upsamples (x2) the input sample, generating two output samples. - Input parameters: - - input: The input sample. - Output parameters: - - out_0: First output sample. - - out_1: Second output sample. - */ - inline void process_sample (T &out_0, T &out_1, T input); - - /* - Name: process_block - Description: - Upsamples (x2) the input sample block. - Input and output blocks may overlap, see assert() for details. - Input parameters: - - in_ptr: Input array, containing nbr_spl samples. - - nbr_spl: Number of input samples to process, > 0 - Output parameters: - - out_0_ptr: Output sample array, capacity: nbr_spl * 2 samples. - */ - void process_block (T out_ptr [], const T in_ptr [], long nbr_spl); - - /* - Name: clear_buffers - Description: - Clears filter memory, as if it processed silence since an infinite amount - of time. - */ - void clear_buffers (); - -private: - std::array _coef; - std::array _x; - std::array _y; - -private: - bool operator == (const Upsampler2xFPU &other); - bool operator != (const Upsampler2xFPU &other); - -}; // class Upsampler2xFPU - -template -Upsampler2xFPU ::Upsampler2xFPU () -: _coef () -, _x () -, _y () -{ - for (int i = 0; i < NBR_COEFS; ++i) - { - _coef [i] = 0; - } - clear_buffers (); -} - -template -void Upsampler2xFPU ::set_coefs (const double coef_arr [NBR_COEFS]) -{ - assert (coef_arr != 0); - - for (int i = 0; i < NBR_COEFS; ++i) - { - _coef [i] = static_cast (coef_arr [i]); - } -} - -template -void Upsampler2xFPU ::process_sample (T &out_0, T &out_1, T input) -{ -// assert (&out_0 != 0); -// assert (&out_1 != 0); - - T even = input; - T odd = input; - StageProcFPU ::process_sample_pos ( - NBR_COEFS, - even, - odd, - &_coef [0], - &_x [0], - &_y [0] - ); - out_0 = even; - out_1 = odd; -} - -template -void Upsampler2xFPU ::process_block (T out_ptr [], const T in_ptr [], long nbr_spl) -{ -// assert (out_ptr != 0); -// assert (in_ptr != 0); -// assert (out_ptr >= in_ptr + nbr_spl || in_ptr >= out_ptr + nbr_spl); -// assert (nbr_spl > 0); - - long pos = 0; - do - { - process_sample ( - out_ptr [pos * 2], - out_ptr [pos * 2 + 1], - in_ptr [pos] - ); - ++ pos; - } - while (pos < nbr_spl); -} - -template -void Upsampler2xFPU ::clear_buffers () -{ - for (int i = 0; i < NBR_COEFS; ++i) - { - _x [i] = 0; - _y [i] = 0; - } -} - -} // namespace hiir diff --git a/oversampling/HIIR/PolyphaseIIR2Designer.cpp b/oversampling/HIIR/PolyphaseIIR2Designer.cpp deleted file mode 100644 index ed069d8..0000000 --- a/oversampling/HIIR/PolyphaseIIR2Designer.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/* - PolyphaseIIR2Designer.cpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This program is free software. It comes without any warranty, to -the extent permitted by applicable law. You can redistribute it -and/or modify it under the terms of the Do What The Fuck You Want -To Public License, Version 2, as published by Sam Hocevar. See -http://sam.zoy.org/wtfpl/COPYING for more details. - -*/ - -#if defined (_MSC_VER) - #pragma warning (1 : 4130) // "'operator' : logical operation on address of string constant" - #pragma warning (1 : 4223) // "nonstandard extension used : non-lvalue array converted to pointer" - #pragma warning (1 : 4705) // "statement has no effect" - #pragma warning (1 : 4706) // "assignment within conditional expression" - #pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information" - #pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)" - #pragma warning (4 : 4355) // "'this' : used in base member initializer list" -#endif - -#include "PolyphaseIIR2Designer.h" - -#include -#include - -namespace hiir -{ - static const double PI = 3.141592653589793238; - - int round_int (double x) - { - return (static_cast (std::floor (x + 0.5))); - } - - int ceil_int (double x) - { - return (static_cast (std::ceil (x))); - } - - template - T ipowp (T x, long n) - { - assert (n >= 0); - - T z (1); - while (n != 0) - { - if ((n & 1) != 0) - { - z *= x; - } - n >>= 1; - x *= x; - } - - return (z); - } - - -int PolyphaseIIR2Designer::compute_nbr_coefs_from_proto (double attenuation, double transition) -{ - assert (attenuation > 0); - assert (transition > 0); - assert (transition < 0.5); - - double k; - double q; - compute_transition_param (k, q, transition); - const int order = compute_order (attenuation, q); - const int nbr_coefs = (order - 1) / 2; - - return (nbr_coefs); -} - -double PolyphaseIIR2Designer::compute_atten_from_order_tbw (int nbr_coefs, double transition) -{ - assert (nbr_coefs > 0); - assert (transition > 0); - assert (transition < 0.5); - - double k; - double q; - compute_transition_param (k, q, transition); - const int order = nbr_coefs * 2 + 1; - const double attenuation = compute_atten (q, order); - - return (attenuation); -} - -int PolyphaseIIR2Designer::compute_coefs (double coef_arr[], double attenuation, double transition) -{ - assert (&coef_arr != 0); - assert (attenuation > 0); - assert (transition > 0); - assert (transition < 0.5); - - double k; - double q; - compute_transition_param (k, q, transition); - - // Computes number of required coefficients - const int order = compute_order (attenuation, q); - const int nbr_coefs = (order - 1) / 2; - - // Coefficient calculation - for (int index = 0; index < nbr_coefs; ++index) - { - coef_arr [index] = compute_coef (index, k, q, order); - } - - return (nbr_coefs); -} - -void PolyphaseIIR2Designer::compute_coefs_spec_order_tbw (double coef_arr[], int nbr_coefs, double transition) -{ - assert (&coef_arr != 0); - assert (nbr_coefs > 0); - assert (transition > 0); - assert (transition < 0.5); - - double k; - double q; - compute_transition_param (k, q, transition); - const int order = nbr_coefs * 2 + 1; - - // Coefficient calculation - for (int index = 0; index < nbr_coefs; ++index) - { - coef_arr [index] = compute_coef (index, k, q, order); - } -} - -void PolyphaseIIR2Designer::compute_transition_param (double &k, double &q, double transition) -{ - assert (&k != 0); - assert (&q != 0); - assert (transition > 0); - assert (transition < 0.5); - - using namespace std; - - k = tan ((1 - transition * 2) * hiir::PI / 4); - k *= k; - assert (k < 1); - assert (k > 0); - double kksqrt = pow (1 - k * k, 0.25); - const double e = 0.5 * (1 - kksqrt) / (1 + kksqrt); - const double e2 = e * e; - const double e4 = e2 * e2; - q = e * (1 + e4 * (2 + e4 * (15 + 150 * e4))); - assert (q > 0); -} - -int PolyphaseIIR2Designer::compute_order (double attenuation, double q) -{ - assert (attenuation > 0); - assert (q > 0); - - using namespace std; - - const double attn_p2 = pow (10.0, -attenuation / 10); - const double a = attn_p2 / (1 - attn_p2); - int order = hiir::ceil_int (log (a * a / 16) / log (q)); - if ((order & 1) == 0) - { - ++ order; - } - if (order == 1) - { - order = 3; - } - - return (order); -} - -double PolyphaseIIR2Designer::compute_atten (double q, int order) -{ - assert (q > 0); - assert (order > 0); - assert ((order & 1) == 1); - - using namespace std; - - const double a = 4 * exp (order * 0.5 * log (q)); - assert (a != -1.0); - const double attn_p2 = a / (1 + a); - const double attenuation = -10 * log10 (attn_p2); - assert (attenuation > 0); - - return (attenuation); -} - -double PolyphaseIIR2Designer::compute_coef (int index, double k, double q, int order) -{ - assert (index >= 0); - assert (index * 2 < order); - - using namespace std; - - const int c = index + 1; - const double num = compute_acc_num (q, order, c) * pow (q, 0.25); - const double den = compute_acc_den (q, order, c) + 0.5; - const double ww = num / den; - const double wwsq = ww * ww; - - const double x = sqrt ((1 - wwsq * k) * (1 - wwsq / k)) / (1 + wwsq); - const double coef = (1 - x) / (1 + x); - - return (coef); -} - -double PolyphaseIIR2Designer::compute_acc_num (double q, int order, int c) -{ - assert (c >= 1); - assert (c < order * 2); - - using namespace std; - - int i = 0; - int j = 1; - double acc = 0; - double q_ii1; - do - { - q_ii1 = hiir::ipowp (q, i * (i + 1)); - q_ii1 *= sin ((i * 2 + 1) * c * hiir::PI / order) * j; - acc += q_ii1; - - j = -j; - ++i; - } - while (fabs (q_ii1) > 1e-100); - - return (acc); -} - -double PolyphaseIIR2Designer::compute_acc_den (double q, int order, int c) -{ - assert (c >= 1); - assert (c < order * 2); - - using namespace std; - - int i = 1; - int j = -1; - double acc = 0; - double q_i2; - do - { - q_i2 = hiir::ipowp (q, i * i); - q_i2 *= cos (i * 2 * c * hiir::PI / order) * j; - acc += q_i2; - - j = -j; - ++i; - } - while (fabs (q_i2) > 1e-100); - - return (acc); -} - -} // namespace hiir - diff --git a/oversampling/HIIR/PolyphaseIIR2Designer.h b/oversampling/HIIR/PolyphaseIIR2Designer.h deleted file mode 100644 index 44a593a..0000000 --- a/oversampling/HIIR/PolyphaseIIR2Designer.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - - PolyphaseIIR2Designer.h - Copyright (c) 2005 Laurent de Soras - -Compute coefficients for 2-path polyphase IIR filter, half-band filter or -Pi/2 phaser. - - -2 - a + z - N/2-1 2k+1 -A0 (z) = Prod ------------ - k = 0 -2 - 1 + a z - 2k+1 - - -2 - a + z - -1 (N-1)/2 2k -A1 (z) = z . Prod ---------- - k = 0 -2 - 1 + a z - 2k - - 1 -H (z) = - (A0 (z) + A1 (z)) - 2 - -Sum of A0 and A1 gives a low-pass filter. -Difference of A0 and A1 gives the complementary high-pass filter. - -For the Pi/2 phaser, product form is (a - z^-2) / (1 - az^-2) -Sum and difference of A0 and A1 have a Pi/2 phase difference. - -References: - -* Polyphase Two-Path Filter Designer in Java - Artur Krukowski - http://www.cmsa.wmin.ac.uk/~artur/Poly.html - -* Digital Signal Processing Schemes for Efficient Interpolation and Decimation - Valenzuela and Constantinides - IEE Proceedings, Dec 1983 - -* A Hilbert-Transformer Frequency Shifter for Audio - Scott Wardle - http://www.iua.upf.es/dafx98/papers/WAR19.PS - - --- Legal stuff --- - -This program is free software. It comes without any warranty, to -the extent permitted by applicable law. You can redistribute it -and/or modify it under the terms of the Do What The Fuck You Want -To Public License, Version 2, as published by Sam Hocevar. See -http://sam.zoy.org/wtfpl/COPYING for more details. - -*/ - -#pragma once - -namespace hiir -{ - -class PolyphaseIIR2Designer -{ -public: - - /* - Name: compute_nbr_coefs_from_proto - Description: - Finds the minimum number of coefficients for a given filter specification - Input parameters: - - attenuation: stop-band attenuation, dB. > 0. - - transition: normalized transition bandwidth. Range ]0 ; 1/2[ - Returns: Number of coefficients, > 0 - */ - static int compute_nbr_coefs_from_proto (double attenuation, double transition); - - /* - Name: compute_atten_from_order_tbw - Description: - Compute the attenuation corresponding to a given number of coefficients - and the transition bandwidth. - Input parameters: - - nbr_coefs: Number of desired coefficients. > 0. - - transition: normalized transition bandwidth. Range ]0 ; 1/2[ - Returns: stop-band attenuation, dB. > 0. - */ - static double compute_atten_from_order_tbw (int nbr_coefs, double transition); - - /* - Name: compute_coefs - Description: - Computes coefficients for a half-band polyphase IIR filter, function of a - given stop-band gain / transition bandwidth specification. - Order is automatically calculated. - Input parameters: - - attenuation: stop-band attenuation, dB. > 0. - - transition: normalized transition bandwidth. Range ]0 ; 1/2[ - Output parameters: - - coef_arr: Coefficient list, must be large enough to store all the - coefficients. Filter order = nbr_coefs * 2 + 1 - Returns: number of coefficients - */ - static int compute_coefs (double coef_arr[], double attenuation, double transition); - - /* - Name: compute_coefs_spec_order_tbw - Description: - Computes coefficients for a half-band polyphase IIR filter, function of a - given transition bandwidth and desired filter order. Bandstop attenuation - is set to the maximum value for these constraints. - Input parameters: - - nbr_coefs: Number of desired coefficients. > 0. - - transition: normalized transition bandwidth. Range ]0 ; 1/2[ - Output parameters: - - coef_arr: Coefficient list, must be large enough to store all the - coefficients. - */ - static void compute_coefs_spec_order_tbw (double coef_arr[], int nbr_coefs, double transition); - -private: - static void compute_transition_param (double &k, double &q, double transition); - static int compute_order (double attenuation, double q); - static double compute_atten (double q, int order); - static double compute_coef (int index, double k, double q, int order); - static double compute_acc_num (double q, int order, int c); - static double compute_acc_den (double q, int order, int c); - -private: - PolyphaseIIR2Designer(); - ~PolyphaseIIR2Designer(); - PolyphaseIIR2Designer(const PolyphaseIIR2Designer &other); - PolyphaseIIR2Designer& - operator = (const PolyphaseIIR2Designer &other); - bool operator == (const PolyphaseIIR2Designer &other); - bool operator != (const PolyphaseIIR2Designer &other); - -}; // class PolyphaseIIR2Designer - -} // namespace hiir diff --git a/oversampling/HIIR/license.txt b/oversampling/HIIR/license.txt deleted file mode 100755 index 1c93089..0000000 --- a/oversampling/HIIR/license.txt +++ /dev/null @@ -1,13 +0,0 @@ - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - Version 2, December 2004 - - Copyright (C) 2004 Sam Hocevar - - Everyone is permitted to copy and distribute verbatim or modified - copies of this license document, and changing it is allowed as long - as the name is changed. - - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/oversampling/HIIR/readme.txt b/oversampling/HIIR/readme.txt deleted file mode 100755 index 34f8f4c..0000000 --- a/oversampling/HIIR/readme.txt +++ /dev/null @@ -1,248 +0,0 @@ -============================================================================== - - hiir - Version 1.11 - - An oversampling and Hilbert transform library in C++ - - By Laurent de Soras, 2005-2013 - -============================================================================== - - - -Contents: - -1. Legal -2. What is hiir ? -3. Using hiir -4. Compilation -5. Oversampling to higher ratios -6. History -7. Contact - - - -1. Legal --------- - -Check the file license.txt to get full information about the license. - - - -2. What is hiir ? ------------------ - -hiir is a DSP (digital signal processing) library in C++, with two purposes: - - - Changing the sampling rate of a signal by a factor two, in both -directions (upsampling and downsampling). - - Obtaining two signals with a pi/2 phase difference (Hilbert transform) - -These distinct operations are actually sharing the same filter design method -and processing kernel, that is why they are included in the same package. The -filter (a two-path polyphase IIR) is very efficient and can be used to achieve -high-quality oversampling or phase shift at a low CPU cost. It is made of a -symetric half-band elliptic low-pass filter, hence having an extremely flat -frequency response in the passband. - -Various implementations are supplied with the library, using special CPU -instructions to optimise the calculation speed. Currently SSE and 3DNow! -instruction sets are supported, as well as the classic and portable FPU -implementation. - -Source code may be downloaded from this webpage: -http://ldesoras.free.fr/prod.html - - - -3. Using hiir -------------- - -To avoid any collision, names have been encapsulated in the namespace "hiir". -So you have to prefix every name of this library with hiir:: or put a line -"using namespace hiir;" into your code. - -The filter design class is PolyphaseIir2Designer. It generates coefficients -for the filters from a specification: stopband attenuation, transition -bandwidth and/or number of coefficients. - -The main processing classes are Downsampler2x*, Upsampler2x* and PhaseHalfPi*. -The suffix indicates the implementation. Choose "Fpu" if you are not sure -about the right one to use. All implementations of a class category have the -same function syntax, so you can use them with C++ templates. - -The implementations should have a consistent behaviour, based on the FPU one. -Some of them have specific requirement, like object alignment in memory or -delay in processing. See the header file (.h) of the class for details about -the constraints and inconsistencies, and the code file (.cpp/.hpp) for details -about function calls. - -As you can see, almost all classes are templates based on number of -coefficients. This means it is not possible to change this number at run-time. -This is the most important constraint of this library. However the reward is -the high speed of the execution. Anyway, you could build a wrapper to support -variable number of coefficients, althought it means that you will have -probably to compile a large number of variations on the same code. - -The library processes only 32-bit floating point data. - -hiir is intended to be portable, but has little architecture-dependant pieces -of code. So far, it has been built and tested on: - - - MS Windows / MS Visual C++ 6.0 (FPU/SSE/3DNow) - - MS Windows / MS Visual C++ 2005 (FPU/SSE/3DNow) - - MS Windows / MS Visual C++ 2010 (FPU/SSE/3DNow) - - MS Windows / GCC 4.5.3 (FPU/SSE only) - - MS Windows / Clang 3.1 (FPU/SSE only) - - MacOS 10.5 / GCC 4 (FPU/SSE only) - -If you happen to have another system and tweak it to make it run successfully, -pleeeeease send me your modification so I can include it to the main -distribution. Run main.cpp in Debug mode before, then in Release mode, in -order to be sure that everything is fine. I would also be glad to include -implementations for other processors/compilers. - -References for filter use and design: - -- Scott Wardle, "A Hilbert-Transformer Frequency Shifter for Audio" -http://www.iua.upf.es/dafx98/papers/ - -- Valenzuela and Constantinides, "Digital Signal Processing Schemes for -Efficient Interpolation and Decimation", IEEE Proceedings, Dec 1983 - -- Artur Krukowski, Izzet Kale, "The design of arbitrary-band multi-path -polyphase IIR filters", ISCAS 2, page 741-744. IEEE, 2001 - - - -4. Compilation and testing --------------------------- - -Drop the following files into your project or makefile : - -hiir/Array.* -hiir/def.h -hiir/Downsampler2x*.* -hiir/fnc.* -hiir/PhaseHalfPi*.* -hiir/PolyphaseIir2Designer.* -hiir/Stage*.* -hiir/Upsampler2x*.* - -Other files (in the hiir/test directory) are for testing purpose only, do not -include them if you just need to use the library; they are not needed to use -hiir in your own programs. - -hiir may be compiled in two versions: release and debug. Debug version -has checks that could slow down the code. Define NDEBUG to set the Release -mode. For example, the command line to compile the test bench on GCC or -Clang would look like: - -Debug mode: -g++ -msse -I. -o ./hiir_debug.exe hiir/*.cpp hiir/test/*.cpp -clang++ -D_X86_ -msse -I. -o ./hiir_debug.exe hiir/*.cpp hiir/test/*.cpp - -Release mode: -g++ -msse -I. -o ./hiir_release.exe -DNDEBUG -O3 hiir/*.cpp hiir/test/*.cpp -clang++ -D_X86_ -msse -I. -o ./hiir_release.exe -DNDEBUG -O3 hiir/*.cpp hiir/test/*.cpp - -The "-msse" option enables the compilation of the SSE intrinsics. - -Notes for MS VC++ 6.0 users: - -- You'll need the Processor Pack in order to be able to compile 3DNow! and -SSE code. - -- The intensive use of recursive templates may slow down a bit the compilation, -especially if you use many different filter sizes (number of coefficients). -On MS Visual C++, you will probably have to use the /Zm option to increase -the memory reserved to the compiler. /Zm500 should be enough to compile the -test bench. - -- Also, MS Visual C++ issues a lot of warning related to the use of the EBX -register or lack of FEMMS instruction at the end of a function. This is normal -and you can safely disable these warning while using hiir classes. - -The included test bench checks roughly the accuracy of the filters. It also -tests the speed of every available function. Therefore, implementing new -instruction set should be facilitated. - -If you want to compile and run the test bench, please first edit the -test/conf.h file, in order to select the instruction sets available for your -CPU (there is currently no automatic detection). If you are not sure, disable -all of them. - -In the same file, you have also testing options. You can save on the disk all -the samples generated during tests in order to check them in a sample editor. -However the files may take a lot of space on the disk, so it is recommended to -disable this option if it is not required. The "long tests" options are -intended to provide extensive checks on various filter sizes (it takes longer -to compile, but is safer if you want to change anything in the lib). - - - -5. Oversampling to higher ratios --------------------------------- - -It is possible to oversample a signal at a higher ratio than 2. You just have -to cascade up/downsamplers to achieve a power-of-2 ratio. Depending on your -requirements, you can reduce the filter order as the sampling rate is getting -bigger by reducing the transition bandwidth (TBW). - -For example, let's suppose one wants 16x downsampling, with 96 dB of stopband -attenuation and a 0.49*Fs passband. You'll need the following specifications -for each stage: - - 2x -> 1x: TBW = 0.01 - 4x -> 2x: TBW = 0.01/2 + 1/4 = 0.255 - 8x -> 4x: TBW = 0.01/4 + 1/8 + 1/4 = 0.3775 -16x -> 8x: TBW = 0.01/8 + 1/16 + 1/8 + 1/4 = 0.43865 - -The reason is that you do not need to preserve spectrum parts that will be -wiped out by subsequent stages. Only the spectrum part present after the -final stage has to be perserved. - -More generally: - -TBW[stage] = (TBW[stage-1] + 0.5) / 2 -or -TBW[stage] = TBW[0] * (0.5^stage) + 0.5 * (1 - 0.5^stage) - -So transition bandwidth requirement is significatively low until the last -stage (0). Thus, the optimal performance would be reached by using hiir -downsampler for the last stage because the requirement on the transition -bandwidth is important, and by using a classic FIR filtering for other -stages. Of course, it's possible to use hiir at every stage, but a well- -optimised polyphase FIR routine is probably more efficient than a 1- or 2- -coefficent IIR downsampler. Indeed, these IIR SIMD implementations have -little or no benefit for low-order filters, whereas small FIR filters can -benefit from SIMD. Check the speed test results to make your mind. - - - -6. History ----------- - -v1.11 (2012.06.26) - - Changed the license to the WTFPL - - Fixed some compilation warnings - -v1.10 (2008.05.28) - - Changed directory structure - - Test code is now in its own namespace (hiir::test) - - Uses intrinsics for SSE code, making the code compilable on GCC. - -v1.00 (2005.03.29) - - Initial release - - - -7. Contact ----------- - -Please address any comment, bug report or flame to: - -Laurent de Soras -http://ldesoras.free.fr - diff --git a/oversampling/LICENSE.txt b/oversampling/LICENSE.txt deleted file mode 100644 index 66fe31f..0000000 --- a/oversampling/LICENSE.txt +++ /dev/null @@ -1,24 +0,0 @@ -iPlug 2 C++ Plug-in Framework. - -Copyright (C) the iPlug 2 Developers. Portions copyright other contributors, see each source file for more information. - -Based on WDL-OL/iPlug by Oli Larkin (2011-2018), and the original iPlug v1 (2008) by John Schwartz / Cockos - -LICENSE: - -This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. - -Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -1. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -1. This notice may not be removed or altered from any source distribution. - -iPlug 2 includes the following 3rd party libraries (see each license info): - -* Cockos WDL https://www.cockos.com/wdl -* NanoVG https://github.com/memononen/nanovg -* NanoSVG https://github.com/memononen/nanosvg -* MetalNanoVG https://github.com/ollix/MetalNanoVG -* RTAudio https://www.music.mcgill.ca/~gary/rtaudio -* RTMidi https://www.music.mcgill.ca/~gary/rtmidi diff --git a/oversampling/Oversampler.h b/oversampling/Oversampler.h deleted file mode 100644 index 973063b..0000000 --- a/oversampling/Oversampler.h +++ /dev/null @@ -1,459 +0,0 @@ -/* - ============================================================================== - - This file is part of the iPlug 2 library. Copyright (C) the iPlug 2 developers. - - Modified by Christopher Herb for standalone use. - - See LICENSE.txt for more info. - - ============================================================================== -*/ - -#pragma once - -#define OVERSAMPLING_FACTORS_VA_LIST "None", "2x", "4x", "8x", "16x" - -#include -#include -#include - -#include "HIIR/FPUDownsampler2x.h" -#include "HIIR/FPUUpsampler2x.h" - -#include "WDL/heapbuf.h" -#include "WDL/ptrlist.h" - -// #include "IPlugPlatform.h" - -using namespace hiir; - -enum EFactor { - kNone = 0, - k2x, - k4x, - k8x, - k16x, - kNumFactors -}; - -template -class OverSampler { -public: - using BlockProcessFunc = std::function; - - OverSampler(EFactor factor = kNone, bool blockProcessing = true, int nInChannels = 1, int nOutChannels = 1) - : mBlockProcessing(blockProcessing) - , mNInChannels(nInChannels) - , mNOutChannels(nOutChannels) - { - - static constexpr double coeffs2x[12] = {0.036681502163648017, 0.13654762463195794, 0.27463175937945444, - 0.42313861743656711, 0.56109869787919531, 0.67754004997416184, - 0.76974183386322703, 0.83988962484963892, 0.89226081800387902, - 0.9315419599631839, 0.96209454837808417, 0.98781637073289585}; - static constexpr double coeffs4x[4] = {0.041893991997656171, 0.16890348243995201, 0.39056077292116603, - 0.74389574826847926}; - static constexpr double coeffs8x[3] = {0.055748680811302048, 0.24305119574153072, 0.64669913119268196}; - static constexpr double coeffs16x[2] = {0.10717745346023573, 0.53091435354504557}; - - for (auto c = 0; c < mNInChannels; c++) { - mUpsampler2x.Add(new Upsampler2xFPU<12, T>()); - mUpsampler4x.Add(new Upsampler2xFPU<4, T>()); - mUpsampler8x.Add(new Upsampler2xFPU<3, T>()); - mUpsampler16x.Add(new Upsampler2xFPU<2, T>()); - - mUpsampler2x.Get(c)->set_coefs(coeffs2x); - mUpsampler4x.Get(c)->set_coefs(coeffs4x); - mUpsampler8x.Get(c)->set_coefs(coeffs8x); - mUpsampler16x.Get(c)->set_coefs(coeffs16x); - - // ptr location doesn't matter at this stage - mNextInputPtrs.Add(mUp2x.Get()); - } - - for (auto c = 0; c < mNOutChannels; c++) { - mDownsampler2x.Add(new Downsampler2xFPU<12, T>()); - mDownsampler4x.Add(new Downsampler2xFPU<4, T>()); - mDownsampler8x.Add(new Downsampler2xFPU<3, T>()); - mDownsampler16x.Add(new Downsampler2xFPU<2, T>()); - - mDownsampler2x.Get(c)->set_coefs(coeffs2x); - mDownsampler4x.Get(c)->set_coefs(coeffs4x); - mDownsampler8x.Get(c)->set_coefs(coeffs8x); - mDownsampler16x.Get(c)->set_coefs(coeffs16x); - - // ptr location doesn't matter at this stage - mNextOutputPtrs.Add(mDown2x.Get()); - } - - SetOverSampling(factor); - - Reset(); - } - - ~OverSampler() - { - mUpsampler2x.Empty(true); - mDownsampler2x.Empty(true); - mUpsampler4x.Empty(true); - mDownsampler4x.Empty(true); - mUpsampler8x.Empty(true); - mDownsampler8x.Empty(true); - mUpsampler16x.Empty(true); - mDownsampler16x.Empty(true); - } - - OverSampler(const OverSampler&) = delete; - OverSampler& operator=(const OverSampler&) = delete; - - void Reset(int blockSize = 16) - { - int numBufSamples = 1; - - if (mBlockProcessing) numBufSamples = blockSize; - else { - numBufSamples = 1; - blockSize = 1; - } - - numBufSamples *= mNInChannels; - - mUp2x.Resize(2 * numBufSamples); - mUp4x.Resize(4 * numBufSamples); - mUp8x.Resize(8 * numBufSamples); - mUp16x.Resize(16 * numBufSamples); - - mDown2x.Resize(2 * numBufSamples); - mDown4x.Resize(4 * numBufSamples); - mDown8x.Resize(8 * numBufSamples); - mDown16x.Resize(16 * numBufSamples); - - mUp16BufferPtrs.Empty(); - mUp8BufferPtrs.Empty(); - mUp4BufferPtrs.Empty(); - mUp2BufferPtrs.Empty(); - - mDown16BufferPtrs.Empty(); - mDown8BufferPtrs.Empty(); - mDown4BufferPtrs.Empty(); - mDown2BufferPtrs.Empty(); - - for (auto c = 0; c < mNInChannels; c++) { - mUpsampler2x.Get(c)->clear_buffers(); - mUpsampler4x.Get(c)->clear_buffers(); - mUpsampler8x.Get(c)->clear_buffers(); - mUpsampler16x.Get(c)->clear_buffers(); - - mUp2BufferPtrs.Add(mUp2x.Get() + c * 2 * blockSize); - mUp4BufferPtrs.Add(mUp4x.Get() + (c * 4 * blockSize)); - mUp8BufferPtrs.Add(mUp8x.Get() + (c * 8 * blockSize)); - mUp16BufferPtrs.Add(mUp16x.Get() + (c * 16 * blockSize)); - } - - for (auto c = 0; c < mNOutChannels; c++) { - mDownsampler2x.Get(c)->clear_buffers(); - mDownsampler4x.Get(c)->clear_buffers(); - mDownsampler8x.Get(c)->clear_buffers(); - mDownsampler16x.Get(c)->clear_buffers(); - - mDown2BufferPtrs.Add(mDown2x.Get() + c * 2 * blockSize); - mDown4BufferPtrs.Add(mDown4x.Get() + (c * 4 * blockSize)); - mDown8BufferPtrs.Add(mDown8x.Get() + (c * 8 * blockSize)); - mDown16BufferPtrs.Add(mDown16x.Get() + (c * 16 * blockSize)); - } - } - - /** Over sample an input block with a per-block function (up sample input -> process with function -> down sample) - * @param inputs Two-dimensional array containing the non-interleaved input buffers of audio samples for all - * channels - * @param outputs Two-dimensional array for audio output (non-interleaved). - * @param nFrames The block size for this block: number of samples per channel. - * @param nInChans The number of input channels to process. Must be less or equal to the number of channels passed - * to the constructor - * @param nOutChans The number of output channels to process. Must be less or equal to the number of channels passed - * to the constructor - * @param func The function that processes the audio sample at the higher sampling rate. NOTE: std::function can - * call malloc if you pass in captures */ - void ProcessBlock(T** inputs, T** outputs, int nFrames, int nInChans, int nOutChans, BlockProcessFunc func) - { - assert(nInChans <= mNInChannels); - assert(nOutChans <= mNOutChannels); - - if (mRate != mPrevRate) { - switch (mRate) { - case 2: - mInPtrLoopSrc = &mUp2BufferPtrs; - mOutPtrLoopSrc = &mDown2BufferPtrs; - break; - case 4: - mInPtrLoopSrc = &mUp4BufferPtrs; - mOutPtrLoopSrc = &mDown4BufferPtrs; - break; - case 8: - mInPtrLoopSrc = &mUp8BufferPtrs; - mOutPtrLoopSrc = &mDown8BufferPtrs; - break; - case 16: - mInPtrLoopSrc = &mUp16BufferPtrs; - mOutPtrLoopSrc = &mDown16BufferPtrs; - break; - default: - break; - } - - mPrevRate = mRate; - } - - for (auto c = 0; c < nInChans; c++) { - if (mRate >= 2) { mUpsampler2x.Get(c)->process_block(mUp2BufferPtrs.Get(c), inputs[c], nFrames); } - if (mRate >= 4) { - mUpsampler4x.Get(c)->process_block(mUp4BufferPtrs.Get(c), mUp2BufferPtrs.Get(c), nFrames * 2); - } - if (mRate >= 8) { - mUpsampler8x.Get(c)->process_block(mUp8BufferPtrs.Get(c), mUp4BufferPtrs.Get(c), nFrames * 4); - } - if (mRate == 16) { - mUpsampler16x.Get(c)->process_block(mUp16BufferPtrs.Get(c), mUp8BufferPtrs.Get(c), nFrames * 8); - } - } - - if (mRate == 1) { - func(inputs, outputs, nFrames); - } else { - for (auto i = 0; i < mRate; i++) { - for (auto c = 0; c < nInChans; c++) { - mNextInputPtrs.Set(c, mInPtrLoopSrc->Get(c) + (i * nFrames)); - mNextOutputPtrs.Set(c, mOutPtrLoopSrc->Get(c) + (i * nFrames)); - } - func(mNextInputPtrs.GetList(), mNextOutputPtrs.GetList(), nFrames); - } - } - - for (auto c = 0; c < nOutChans; c++) { - if (mRate == 16) { - mDownsampler16x.Get(c)->process_block(mDown8BufferPtrs.Get(c), mDown16BufferPtrs.Get(c), nFrames * 8); - } - if (mRate >= 8) { - mDownsampler8x.Get(c)->process_block(mDown4BufferPtrs.Get(c), mDown8BufferPtrs.Get(c), nFrames * 4); - } - if (mRate >= 4) { - mDownsampler4x.Get(c)->process_block(mDown2BufferPtrs.Get(c), mDown4BufferPtrs.Get(c), nFrames * 2); - } - if (mRate >= 2) { mDownsampler2x.Get(c)->process_block(outputs[c], mDown2BufferPtrs.Get(c), nFrames); } - } - } - - /** Over sample an input sample with a per-sample function (up-sample input -> process with function -> down-sample) - * @param input The audio sample to input - * @param std::function The function that processes the audio sample at the higher sampling rate. - * NOTE: std::function can call malloc if you pass in captures - * @return The audio sample output */ - T Process(T input, std::function func) - { - T output; - - if (mRate == 16) { - mUpsampler2x.Get(0)->process_sample(mUp2x.Get()[0], mUp2x.Get()[1], input); - mUpsampler4x.Get(0)->process_block(mUp4x.Get(), mUp2x.Get(), 2); - mUpsampler8x.Get(0)->process_block(mUp8x.Get(), mUp4x.Get(), 4); - mUpsampler16x.Get(0)->process_block(mUp16x.Get(), mUp8x.Get(), 8); - - for (auto i = 0; i < 16; i++) { mDown16x.Get()[i] = func(mUp16x.Get()[i]); } - - mDownsampler16x.Get(0)->process_block(mDown8x.Get(), mDown16x.Get(), 8); - mDownsampler8x.Get(0)->process_block(mDown4x.Get(), mDown8x.Get(), 4); - mDownsampler4x.Get(0)->process_block(mDown2x.Get(), mDown4x.Get(), 2); - output = mDownsampler2x.Get(0)->process_sample(mDown2x.Get()); - } else if (mRate == 8) { - mUpsampler2x.Get(0)->process_sample(mUp2x.Get()[0], mUp2x.Get()[1], input); - mUpsampler4x.Get(0)->process_block(mUp4x.Get(), mUp2x.Get(), 2); - mUpsampler8x.Get(0)->process_block(mUp8x.Get(), mUp4x.Get(), 4); - - for (auto i = 0; i < 8; i++) { mDown8x.Get()[i] = func(mUp8x.Get()[i]); } - - mDownsampler8x.Get(0)->process_block(mDown4x.Get(), mDown8x.Get(), 4); - mDownsampler4x.Get(0)->process_block(mDown2x.Get(), mDown4x.Get(), 2); - output = mDownsampler2x.Get(0)->process_sample(mDown2x.Get()); - } else if (mRate == 4) { - mUpsampler2x.Get(0)->process_sample(mUp2x.Get()[0], mUp2x.Get()[1], input); - mUpsampler4x.Get(0)->process_block(mUp4x.Get(), mUp2x.Get(), 2); - - for (auto i = 0; i < 4; i++) { mDown4x.Get()[i] = func(mUp4x.Get()[i]); } - - mDownsampler4x.Get(0)->process_block(mDown2x.Get(), mDown4x.Get(), 2); - output = mDownsampler2x.Get(0)->process_sample(mDown2x.Get()); - } else if (mRate == 2) { - mUpsampler2x.Get(0)->process_sample(mUp2x.Get()[0], mUp2x.Get()[1], input); - - mDown2x.Get()[0] = func(mUp2x.Get()[0]); - mDown2x.Get()[1] = func(mUp2x.Get()[1]); - output = mDownsampler2x.Get(0)->process_sample(mDown2x.Get()); - } else { - output = func(input); - } - - return output; - } - - /** Over-sample an per-sample synthesis function - * @param genFunc The function that generates the audio sample - * @return The audio sample output */ - T ProcessGen(std::function genFunc) - { - auto ProcessDown16x = [&](T input) { - mDown16x.Get()[mWritePos] = (T)input; - - mWritePos++; - mWritePos &= 15; - - if (mWritePos == 0) { - mDownsampler16x.Get(0)->process_block(mDown8x.Get(), mDown16x.Get(), 8); - mDownsampler8x.Get(0)->process_block(mDown4x.Get(), mDown8x.Get(), 4); - mDownsampler4x.Get(0)->process_block(mDown2x.Get(), mDown4x.Get(), 2); - mDownSamplerOutput = mDownsampler2x.Get(0)->process_sample(mDown2x.Get()); - } - }; - - auto ProcessDown8x = [&](T input) { - mDown8x.Get()[mWritePos] = (T)input; - - mWritePos++; - mWritePos &= 7; - - if (mWritePos == 0) { - mDownsampler8x.Get(0)->process_block(mDown4x.Get(), mDown8x.Get(), 4); - mDownsampler4x.Get(0)->process_block(mDown2x.Get(), mDown4x.Get(), 2); - mDownSamplerOutput = mDownsampler2x.Get(0)->process_sample(mDown2x.Get()); - } - }; - - auto ProcessDown4x = [&](T input) { - mDown4x.Get()[mWritePos] = (T)input; - - mWritePos++; - mWritePos &= 3; - - if (mWritePos == 0) { - mDownsampler4x.Get(0)->process_block(mDown2x.Get(), mDown4x.Get(), 2); - mDownSamplerOutput = mDownsampler2x.Get(0)->process_sample(mDown2x.Get()); - } - }; - - auto ProcessDown2x = [&](T input) { - mDown2x.Get()[mWritePos] = (T)input; - - mWritePos = !mWritePos; - - if (mWritePos == 0) { mDownSamplerOutput = mDownsampler2x.Get(0)->process_sample(mDown2x.Get()); } - }; - - T output; - - for (int j = 0; j < mRate; j++) { - output = genFunc(); - - switch (mRate) { - case 2: - ProcessDown2x(output); - break; - case 4: - ProcessDown4x(output); - break; - case 8: - ProcessDown8x(output); - break; - case 16: - ProcessDown16x(output); - break; - default: - break; - } - } - - if (mRate > 1) output = mDownSamplerOutput; - - return output; - } - - void SetOverSampling(EFactor factor) - { - if (factor != mFactor) { - mFactor = factor; - mRate = std::pow(2, (int)factor); - - Reset(); - } - } - - static EFactor RateToFactor(int rate) - { - switch (rate) { - case 1: - return EFactor::kNone; - case 2: - return EFactor::k2x; - case 4: - return EFactor::k4x; - case 8: - return EFactor::k8x; - case 16: - return EFactor::k16x; - default: - assert(0); - return EFactor::kNone; - } - } - - int GetRate() const { return mRate; } - -private: - EFactor mFactor = kNone; - int mPrevRate = 0; - int mRate = 1; - int mWritePos = 0; - T mDownSamplerOutput = 0.; - bool mBlockProcessing; // false - int mNInChannels; // 1 - int mNOutChannels; - - // the actual data - WDL_TypedBuf mUp16x; - WDL_TypedBuf mUp8x; - WDL_TypedBuf mUp4x; - WDL_TypedBuf mUp2x; - - WDL_TypedBuf mDown16x; - WDL_TypedBuf mDown8x; - WDL_TypedBuf mDown4x; - WDL_TypedBuf mDown2x; - - // Ptrs into buffer data - WDL_PtrList mUp16BufferPtrs; - WDL_PtrList mUp8BufferPtrs; - WDL_PtrList mUp4BufferPtrs; - WDL_PtrList mUp2BufferPtrs; - - WDL_PtrList mDown16BufferPtrs; - WDL_PtrList mDown8BufferPtrs; - WDL_PtrList mDown4BufferPtrs; - WDL_PtrList mDown2BufferPtrs; - - WDL_PtrList mNextInputPtrs; - WDL_PtrList mNextOutputPtrs; - - // Ptrs to the buffer data ptrs, changed depending on rate (block processing only) - WDL_PtrList* mInPtrLoopSrc = nullptr; - WDL_PtrList* mOutPtrLoopSrc = nullptr; - - // Ptrs to oversamplers for each channel - WDL_PtrList> mUpsampler2x; // for 1x to 2x SR - WDL_PtrList> mUpsampler4x; // for 2x to 4x SR - WDL_PtrList> mUpsampler8x; // for 4x to 8x SR - WDL_PtrList> mUpsampler16x; // for 8x to 16x SR - - WDL_PtrList> mDownsampler2x; // decimator for 2x to 1x SR - WDL_PtrList> mDownsampler4x; // decimator for 4x to 2x SR - WDL_PtrList> mDownsampler8x; // decimator for 8x to 4x SR - WDL_PtrList> mDownsampler16x; // decimator for 16x to 8x SR -}; diff --git a/oversampling/WDL/.gitattributes b/oversampling/WDL/.gitattributes deleted file mode 100644 index d21ee29..0000000 --- a/oversampling/WDL/.gitattributes +++ /dev/null @@ -1,26 +0,0 @@ -* -text -*.c text=auto -*.cpp text=auto -*.cc text=auto -*.h text=auto -*.hpp text=auto -*.m text=auto -*.mm text=auto - -*.eel text=auto -*.php text=auto -*.txt text=auto - -*.bat text eol=crlf -*.cmd text eol=crlf - -*.rc text eol=crlf -*.dsp text eol=crlf -*.dsw text eol=crlf -*.sln text eol=crlf -*.vcxproj text eol=crlf -*.vcxproj.filters text eol=crlf - -*.sh text eol=lf -*.pbxproj text eol=lf -Makefile text eol=lf diff --git a/oversampling/WDL/MersenneTwister.h b/oversampling/WDL/MersenneTwister.h deleted file mode 100644 index 3af5ab5..0000000 --- a/oversampling/WDL/MersenneTwister.h +++ /dev/null @@ -1,413 +0,0 @@ -// Taken from http://www-personal.engin.umich.edu/~wagnerr/MersenneTwister.html - - -// MersenneTwister.h -// Mersenne Twister random number generator -- a C++ class MTRand -// Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus -// Richard J. Wagner v1.0 15 May 2003 rjwagner@writeme.com - -// The Mersenne Twister is an algorithm for generating random numbers. It -// was designed with consideration of the flaws in various other generators. -// The period, 2^19937-1, and the order of equidistribution, 623 dimensions, -// are far greater. The generator is also fast; it avoids multiplication and -// division, and it benefits from caches and pipelines. For more information -// see the inventors' web page at http://www.math.keio.ac.jp/~matumoto/emt.html - -// Reference -// M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-Dimensionally -// Equidistributed Uniform Pseudo-Random Number Generator", ACM Transactions on -// Modeling and Computer Simulation, Vol. 8, No. 1, January 1998, pp 3-30. - -// Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, -// Copyright (C) 2000 - 2003, Richard J. Wagner -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. The names of its contributors may not be used to endorse or promote -// products derived from this software without specific prior written -// permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// The original code included the following notice: -// -// When you use this, send an email to: matumoto@math.keio.ac.jp -// with an appropriate reference to your work. -// -// It would be nice to CC: rjwagner@writeme.com and Cokus@math.washington.edu -// when you write. - -#ifndef _MERSENNETWISTER_H_ -#define _MERSENNETWISTER_H_ - -// Not thread safe (unless auto-initialization is avoided and each thread has -// its own MTRand object) - -#include -#include -#include -#include - -class MTRand { -// Data -public: - typedef unsigned int uint32; // unsigned integer type, at least 32 bits - - enum { N = 624 }; // length of state vector - enum { SAVE = N + 1 }; // length of array for save() - -protected: - enum { M = 397 }; // period parameter - - uint32 state[N]; // internal state - uint32 *pNext; // next value to get from state - int left; // number of values left before reload needed - - -//Methods -public: - MTRand( const uint32& oneSeed ); // initialize with a simple uint32 - MTRand( uint32 *const bigSeed, uint32 const seedLength = N ); // or an array - MTRand(); // auto-initialize with /dev/urandom or time() and clock() - - // Do NOT use for CRYPTOGRAPHY without securely hashing several returned - // values together, otherwise the generator state can be learned after - // reading 624 consecutive values. - - // Access to 32-bit random numbers - double rand(); // real number in [0,1] - double rand( const double& n ); // real number in [0,n] - double randExc(); // real number in [0,1) - double randExc( const double& n ); // real number in [0,n) - double randDblExc(); // real number in (0,1) - double randDblExc( const double& n ); // real number in (0,n) - uint32 randInt(); // integer in [0,2^32-1] - uint32 randInt( const uint32& n ); // integer in [0,n] for n < 2^32 - double operator()() { return rand(); } // same as rand() - - // Access to 53-bit random numbers (capacity of IEEE double precision) - double rand53(); // real number in [0,1) - - // Access to nonuniform random number distributions - double randNorm( const double& mean = 0.0, const double& variance = 0.0 ); - - // Re-seeding functions with same behavior as initializers - void seed( const uint32 oneSeed ); - void seed( uint32 *const bigSeed, const uint32 seedLength = N ); - void seed(); - - // Saving and loading generator state - void save( uint32* saveArray ) const; // to array of size SAVE - void load( uint32 *const loadArray ); // from such array - -protected: - void initialize( const uint32 oneSeed ); - void reload(); - uint32 hiBit( const uint32& u ) const { return u & 0x80000000UL; } - uint32 loBit( const uint32& u ) const { return u & 0x00000001UL; } - uint32 loBits( const uint32& u ) const { return u & 0x7fffffffUL; } - uint32 mixBits( const uint32& u, const uint32& v ) const - { return hiBit(u) | loBits(v); } - uint32 twist( const uint32& m, const uint32& s0, const uint32& s1 ) const - { return m ^ (mixBits(s0,s1)>>1) ^ (-((int)loBit(s1)) & 0x9908b0dfUL); } - -public: - // This was protected, but we need it exposed so FIRan1.h can use it for seeding - static uint32 hash( time_t t, clock_t c ); -}; - - -inline MTRand::MTRand( const uint32& oneSeed ) - { seed(oneSeed); } - -inline MTRand::MTRand( uint32 *const bigSeed, const uint32 seedLength ) - { seed(bigSeed,seedLength); } - -inline MTRand::MTRand() - { seed(); } - -inline double MTRand::rand() - { return double(randInt()) * (1.0/4294967295.0); } - -inline double MTRand::rand( const double& n ) - { return rand() * n; } - -inline double MTRand::randExc() - { return double(randInt()) * (1.0/4294967296.0); } - -inline double MTRand::randExc( const double& n ) - { return randExc() * n; } - -inline double MTRand::randDblExc() - { return ( double(randInt()) + 0.5 ) * (1.0/4294967296.0); } - -inline double MTRand::randDblExc( const double& n ) - { return randDblExc() * n; } - -inline double MTRand::rand53() -{ - uint32 a = randInt() >> 5, b = randInt() >> 6; - return ( a * 67108864.0 + b ) * (1.0/9007199254740992.0); // by Isaku Wada -} - -inline double MTRand::randNorm( const double& mean, const double& variance ) -{ - // Return a real number from a normal (Gaussian) distribution with given - // mean and variance by Box-Muller method - double r = sqrt( -2.0 * log( 1.0-randDblExc()) ) * variance; - double phi = 2.0 * 3.14159265358979323846264338328 * randExc(); - return mean + r * cos(phi); -} - -inline MTRand::uint32 MTRand::randInt() -{ - // Pull a 32-bit integer from the generator state - // Every other access function simply transforms the numbers extracted here - - if( left == 0 ) reload(); - --left; - - uint32 s1; - s1 = *pNext++; - s1 ^= (s1 >> 11); - s1 ^= (s1 << 7) & 0x9d2c5680UL; - s1 ^= (s1 << 15) & 0xefc60000UL; - return ( s1 ^ (s1 >> 18) ); -} - -inline MTRand::uint32 MTRand::randInt( const uint32& n ) -{ - // Find which bits are used in n - // Optimized by Magnus Jonsson (magnus@smartelectronix.com) - uint32 used = n; - used |= used >> 1; - used |= used >> 2; - used |= used >> 4; - used |= used >> 8; - used |= used >> 16; - - // Draw numbers until one is found in [0,n] - uint32 i; - do - i = randInt() & used; // toss unused bits to shorten search - while( i > n ); - return i; -} - - -inline void MTRand::seed( const uint32 oneSeed ) -{ - // Seed the generator with a simple uint32 - initialize(oneSeed); - reload(); -} - - -inline void MTRand::seed( uint32 *const bigSeed, const uint32 seedLength ) -{ - // Seed the generator with an array of uint32's - // There are 2^19937-1 possible initial states. This function allows - // all of those to be accessed by providing at least 19937 bits (with a - // default seed length of N = 624 uint32's). Any bits above the lower 32 - // in each element are discarded. - // Just call seed() if you want to get array from /dev/urandom - initialize(19650218UL); - int i = 1; - uint32 j = 0; - int k = ( N > seedLength ? N : seedLength ); - for( ; k; --k ) - { - state[i] = - state[i] ^ ( (state[i-1] ^ (state[i-1] >> 30)) * 1664525UL ); - state[i] += ( bigSeed[j] & 0xffffffffUL ) + j; - state[i] &= 0xffffffffUL; - ++i; ++j; - if( i >= N ) { state[0] = state[N-1]; i = 1; } - if( j >= seedLength ) j = 0; - } - for( k = N - 1; k; --k ) - { - state[i] = - state[i] ^ ( (state[i-1] ^ (state[i-1] >> 30)) * 1566083941UL ); - state[i] -= i; - state[i] &= 0xffffffffUL; - ++i; - if( i >= N ) { state[0] = state[N-1]; i = 1; } - } - state[0] = 0x80000000UL; // MSB is 1, assuring non-zero initial array - reload(); -} - - -inline void MTRand::seed() -{ - // Seed the generator with an array from /dev/urandom if available - // Otherwise use a hash of time() and clock() values - - // No point in trying this on Windows machines - won't work, so it just slows things down -#ifndef WIN32 -#ifndef WDL_MTRAND_FASTSEED - // First try getting an array from /dev/urandom - FILE* urandom = fopen( "/dev/urandom", "rb" ); - if( urandom ) - { - uint32 bigSeed[N]; - uint32 *s = bigSeed; - int i = N; - bool success = true; - while( success && i-- ) - success = fread( s++, sizeof(uint32), 1, urandom ); - fclose(urandom); - if( success ) { seed( bigSeed, N ); return; } - } -#endif -#endif - - // Was not successful, so use time() and clock() instead - seed( hash( time(NULL), clock() ) ); -} - - -inline void MTRand::initialize( const uint32 seedv ) -{ - // Initialize generator state with seed - // See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier. - // In previous versions, most significant bits (MSBs) of the seed affect - // only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto. - uint32 *s = state; - uint32 *r = state; - int i = 1; - *s++ = seedv & 0xffffffffUL; - for( ; i < N; ++i ) - { - *s++ = ( 1812433253UL * ( *r ^ (*r >> 30) ) + i ) & 0xffffffffUL; - r++; - } -} - - -inline void MTRand::reload() -{ - // Generate N new values in state - // Made clearer and faster by Matthew Bellew (matthew.bellew@home.com) - uint32 *p = state; - int i; - for( i = int(N) - int(M); i--; ++p ) - *p = twist( p[M], p[0], p[1] ); - for( i = M; --i; ++p ) - *p = twist( p[int(M)-int(N)], p[0], p[1] ); - *p = twist( p[int(M)-int(N)], p[0], state[0] ); - - left = N, pNext = state; -} - - -inline MTRand::uint32 MTRand::hash( time_t t, clock_t c ) -{ - // Get a uint32 from t and c - // Better than uint32(x) in case x is floating point in [0,1] - // Based on code by Lawrence Kirby (fred@genesis.demon.co.uk) - - static uint32 differ = 0; // guarantee time-based seeds will change - - uint32 h1 = 0; - unsigned char *p = (unsigned char *) &t; - for( size_t i = 0; i < sizeof(t); ++i ) - { - h1 *= UCHAR_MAX + 2U; - h1 += p[i]; - } - uint32 h2 = 0; - p = (unsigned char *) &c; - for( size_t j = 0; j < sizeof(c); ++j ) - { - h2 *= UCHAR_MAX + 2U; - h2 += p[j]; - } - return ( h1 + differ++ ) ^ h2; -} - - -inline void MTRand::save( uint32* saveArray ) const -{ - uint32 *sa = saveArray; - const uint32 *s = state; - int i = N; - for( ; i--; *sa++ = *s++ ) {} - *sa = left; -} - - -inline void MTRand::load( uint32 *const loadArray ) -{ - uint32 *s = state; - uint32 *la = loadArray; - int i = N; - for( ; i--; *s++ = *la++ ) {} - left = *la; - pNext = &state[N-left]; -} - - - -#endif // MERSENNETWISTER_H - -// Change log: -// -// v0.1 - First release on 15 May 2000 -// - Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus -// - Translated from C to C++ -// - Made completely ANSI compliant -// - Designed convenient interface for initialization, seeding, and -// obtaining numbers in default or user-defined ranges -// - Added automatic seeding from /dev/urandom or time() and clock() -// - Provided functions for saving and loading generator state -// -// v0.2 - Fixed bug which reloaded generator one step too late -// -// v0.3 - Switched to clearer, faster reload() code from Matthew Bellew -// -// v0.4 - Removed trailing newline in saved generator format to be consistent -// with output format of built-in types -// -// v0.5 - Improved portability by replacing static const int's with enum's and -// clarifying return values in seed(); suggested by Eric Heimburg -// - Removed MAXINT constant; use 0xffffffffUL instead -// -// v0.6 - Eliminated seed overflow when uint32 is larger than 32 bits -// - Changed integer [0,n] generator to give better uniformity -// -// v0.7 - Fixed operator precedence ambiguity in reload() -// - Added access for real numbers in (0,1) and (0,n) -// -// v0.8 - Included time.h header to properly support time_t and clock_t -// -// v1.0 - Revised seeding to match 26 Jan 2002 update of Nishimura and Matsumoto -// - Allowed for seeding with arrays of any length -// - Added access for real numbers in [0,1) with 53-bit resolution -// - Added access for real numbers from normal (Gaussian) distributions -// - Increased overall speed by optimizing twist() -// - Doubled speed of integer [0,n] generation -// - Fixed out-of-range number generation on 64-bit machines -// - Improved portability by substituting literal constants for long enum's -// - Changed license from GNU LGPL to BSD diff --git a/oversampling/WDL/adpcm_decode.h b/oversampling/WDL/adpcm_decode.h deleted file mode 100644 index f97195c..0000000 --- a/oversampling/WDL/adpcm_decode.h +++ /dev/null @@ -1,319 +0,0 @@ -#ifndef _WDL_ADPCM_DECODE_H_ -#define _WDL_ADPCM_DECODE_H_ - -#include "queue.h" - -#define MSADPCM_TYPE 2 -#define IMAADPCM_TYPE 0x11 -#define CADPCM2_TYPE 0xac0c - -class WDL_adpcm_decoder -{ - typedef struct - { - int cf1,cf2,deltas,spl1,spl2; - } WDL_adpcm_decode_chanctx; - -public: - enum { MSADPCM_PREAMBLELEN=7, IMA_PREAMBLELEN=4 }; - static INT64 sampleLengthFromBytes(INT64 nbytes, int blockalign, int nch, int type, int bps) - { - if (!bps||type!=CADPCM2_TYPE) bps=4; - // remove overhead of headers - INT64 nblocks=((nbytes+blockalign-1)/blockalign); - - // remove preambles - if (type==IMAADPCM_TYPE||type==CADPCM2_TYPE) nbytes -= nblocks*IMA_PREAMBLELEN*nch; - else nbytes -= nblocks*MSADPCM_PREAMBLELEN*nch; - - // scale from bytes to samples - nbytes = (nbytes*8)/(nch*bps); - - if (type==IMAADPCM_TYPE||type==CADPCM2_TYPE) nbytes++; // IMA has just one initial sample - else nbytes+=2; // msadpcm has 2 initial sample values - - return nbytes; - } - - WDL_adpcm_decoder(int blockalign,int nch, int type, int bps) - { - m_bps=0; - m_type=0; - m_nch=0; - m_blockalign=0; - m_srcbuf=0; - m_chans=0; - setParameters(blockalign,nch,type,bps); - } - ~WDL_adpcm_decoder() - { - free(m_srcbuf); - free(m_chans); - } - - - void resetState() - { - if (m_chans) memset(m_chans,0,m_nch*sizeof(WDL_adpcm_decode_chanctx)); - m_srcbuf_valid=0; - samplesOut.Clear(); - samplesOut.Compact(); - } - - void setParameters(int ba, int nch, int type, int bps) - { - if (m_blockalign != ba||nch != m_nch||type!=m_type||bps != m_bps) - { - free(m_srcbuf); - free(m_chans); - m_bps=bps; - m_blockalign=ba; - m_nch=nch; - m_srcbuf_valid=0; - m_srcbuf=(unsigned char*)malloc(ba); - m_chans=(WDL_adpcm_decode_chanctx*)malloc(sizeof(WDL_adpcm_decode_chanctx)*nch); - m_type=type; - resetState(); - } - } - - int blockAlign() { return m_blockalign; } - - int samplesPerBlock() - { - if (m_type==IMAADPCM_TYPE||m_type==CADPCM2_TYPE) - { - if (m_bps == 2) return (m_blockalign/m_nch - IMA_PREAMBLELEN)*4 + 1; - return (m_blockalign/m_nch - IMA_PREAMBLELEN)*2 + 1; //4 bit - } - return (m_blockalign/m_nch - MSADPCM_PREAMBLELEN)*2 + 2; // 4 bit - } - - INT64 samplesToSourceBytes(INT64 outlen_samples) // length in samplepairs - { - outlen_samples -= samplesOut.Available()/m_nch; - if (outlen_samples<1) return 0; // no data required - - int spls_block = samplesPerBlock(); - if (spls_block<1) return 0; - INT64 nblocks = (outlen_samples+spls_block-1)/spls_block; - INT64 v=nblocks * m_blockalign; - - v -= m_srcbuf_valid; - - return wdl_max(v,0); - } - - void AddInput(void *buf, int len, short *parm_cotab=NULL) - { - unsigned char *rdbuf = (unsigned char *)buf; - if (m_srcbuf_valid) - { - int v=m_blockalign-m_srcbuf_valid; - if (v>len) v=len; - - memcpy(m_srcbuf+m_srcbuf_valid,rdbuf,v); - len-=v; - rdbuf+=v; - if ((m_srcbuf_valid+=v)>=m_blockalign) - { - DecodeBlock(m_srcbuf,parm_cotab); - m_srcbuf_valid=0; - } - } - - while (len >= m_blockalign) - { - DecodeBlock(rdbuf,parm_cotab); - rdbuf+=m_blockalign; - len-=m_blockalign; - } - if (len>0) memcpy(m_srcbuf,rdbuf,m_srcbuf_valid=len); - } - - - int sourceBytesQueued() { return m_srcbuf_valid; } - WDL_TypedQueue samplesOut; - -private: - static int getwordsigned(unsigned char **rdptr) - { - int s = (*rdptr)[0] + ((*rdptr)[1]<<8); - (*rdptr)+=2; - if (s & 0x8000) s -= 0x10000; - return s; - } - - bool DecodeBlockIMA(unsigned char *buf) - { - int samples_block = samplesPerBlock(); - - int nch=m_nch; - int ch; - short *outptr = samplesOut.Add(NULL,samples_block * nch); - - for (ch=0;ch>2; break; - default: nib=lastbyte>>4; bstate=0; break; - } - nib &= 8|4; - } - else - { - if ((bstate^=1)) nib=(lastbyte=*buf++)&0xf; - else nib=lastbyte>>4; - } - - int step_index=m_chans[ch].cf1; - if (step_index<0)step_index=0; - else if (step_index>88)step_index=88; - - int step=step_table[step_index]; - - int diff = ((nib&7)*step)/4 + step/8; - - int v=m_chans[ch].spl1 + ((nib&8) ? -diff : diff); - - if (v<-32768)v=-32768; - else if (v>32767)v=32767; - - outptr[wrpos]=(short)v; - wrpos+=nch; - - m_chans[ch].spl1=v; - - m_chans[ch].cf1=step_index + index_table[nib&7]; - - - // advance channelcounts - if (++cnt==chunksize) - { - if (++ch>=nch) - { - ch=0; - outptr += chunksize*nch; - } - wrpos = ch; - cnt=0; - } - } - - return true; - } - - bool DecodeBlock(unsigned char *buf, short *parm_cotab=NULL) - { - if (m_type==IMAADPCM_TYPE||m_type==CADPCM2_TYPE) return DecodeBlockIMA(buf); - static short cotab[14] = { 256,0, 512,-256, 0,0, 192,64, 240, 0,460, -208, 392, -232 }; - static short adtab[16] = { 230, 230, 230, 230, 307, 409, 512, 614, 768, 614, 512, 409, 307, 230, 230, 230 }; - - short *use_cotab = parm_cotab ? parm_cotab : cotab; - int nch = m_nch; - int ch; - for(ch=0;ch 6) return false; - c*=2; - m_chans[ch].cf1 = use_cotab[c]; - m_chans[ch].cf2 = use_cotab[c+1]; - } - for(ch=0;ch>4; - else nib=lastbyte&0xf; - - int sn=nib; - if (sn & 8) sn -= 16; - - int pred = ( ((m_chans[ch].spl1 * m_chans[ch].cf1) + - (m_chans[ch].spl2 * m_chans[ch].cf2)) / 256) + - (sn * m_chans[ch].deltas); - - m_chans[ch].spl2 = m_chans[ch].spl1; - - if (pred < -32768) pred=-32768; - else if (pred > 32767) pred=32767; - - *outptr++ = m_chans[ch].spl1 = pred; - - int i= (adtab[nib] * m_chans[ch].deltas) / 256; - if (i <= 16) m_chans[ch].deltas=16; - else m_chans[ch].deltas = i; - } - } - return true; - } - - WDL_adpcm_decode_chanctx *m_chans; - unsigned char *m_srcbuf; - int m_srcbuf_valid; - - int m_blockalign,m_nch,m_type,m_bps; - - -}; - - -#endif diff --git a/oversampling/WDL/adpcm_encode.h b/oversampling/WDL/adpcm_encode.h deleted file mode 100644 index 77ff749..0000000 --- a/oversampling/WDL/adpcm_encode.h +++ /dev/null @@ -1,137 +0,0 @@ -#ifndef _WDL_ADPCM_ENCODE_H_ -#define _WDL_ADPCM_ENCODE_H_ - - -#include "pcmfmtcvt.h" - -void WDL_adpcm_encode_IMA(PCMFMTCVT_DBL_TYPE *samples, int numsamples, int nch, int bps, - unsigned char *bufout, int *bufout_used, short **predState); - -#define WDL_adpcm_encode_IMA_samplesneededbytes(bytes,bps) ((((bytes)-4)*8)/(bps)+1) - - -// untested. also probably slow. -#ifdef WDL_ADPCM_ENCODE_IMPL - - -static signed char ima_adpcm_index_table[8] = { -1, -1, -1, -1, 2, 4, 6, 8, }; -static short ima_adpcm_step_table[89] = { - 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, - 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, - 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, - 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, - 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, - 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, - 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, - 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, - 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 -}; - -static char calcBestNibble(int *initial_step_index, int lastSpl, int thisSpl, short *lastsplout, int bps) -{ - - int step=ima_adpcm_step_table[*initial_step_index]; - - char sign=0; - int adiff = thisSpl - lastSpl; - if (adiff<0) { adiff=-adiff; sign=8; } - - // adiff == (nib*step)/4 + step/8 - // adiff - step/8 = nib*step/4 - // nib = 4*(adiff-step/8)/step = 4*adiff/step - 0.5 - int nib = step ? ((4 * adiff - step/2) / step) : 0; - if (nib<0) nib=0; - else if(nib>7) nib=7; - - if (bps==2) nib&=4; - - int diff = (nib*step)/4 + step/8; - *lastsplout = lastSpl + (sign?-diff:diff); - - - *initial_step_index += ima_adpcm_index_table[nib]; - - if (*initial_step_index<0)*initial_step_index=0; - else if (*initial_step_index>88)*initial_step_index=88; - - return (char)nib|sign; -} - - - -void WDL_adpcm_encode_IMA(PCMFMTCVT_DBL_TYPE *samples, int numsamples, int nch, int bps, - unsigned char *bufout, int *bufout_used, short **predState) -{ - int x; - if (!*predState) *predState=(short *)calloc(nch,sizeof(short)); - - short *pstate = *predState; - for(x=0;x>8; - spl+=nch; - - *wrptr++ = step_index&0xff; *wrptr++ = step_index>>8; - - wrptr += (nch-1)*4; - - - int outpos=0; - const int outblocklen = bps == 2 ? 16 : 8; - unsigned char buildchar=0; - - while (left-->0) - { - short this_spl; - double_TO_INT16(this_spl,*spl); - char nib = calcBestNibble(&step_index,last_out,this_spl,&last_out,bps); - - spl+=nch; - - // update output - if (bps == 2) - { - nib>>=2; - switch (outpos&3) - { - case 0: buildchar = nib; break; - case 1: buildchar |= nib<<2; break; - case 2: buildchar |= nib<<4; break; - case 3: *wrptr++ = buildchar | (nib<<6); break; - } - } - else - { - if (!(outpos&1)) buildchar = nib; - else *wrptr++ = buildchar | (nib<<4); - } - - // skip other channels - if (++outpos == outblocklen) - { - wrptr += ((nch-1)*outblocklen*bps)/8; - outpos=0; - } - } - pstate[x] = step_index; - - } - *bufout_used = (((numsamples-1)*bps)/8 + 4)*nch; - - -} - -#endif - - -#endif//_WDL_ADPCM_ENCODE_H_ \ No newline at end of file diff --git a/oversampling/WDL/assocarray.h b/oversampling/WDL/assocarray.h deleted file mode 100644 index e1a4df0..0000000 --- a/oversampling/WDL/assocarray.h +++ /dev/null @@ -1,491 +0,0 @@ -#ifndef _WDL_ASSOCARRAY_H_ -#define _WDL_ASSOCARRAY_H_ - -#include "heapbuf.h" -#include "mergesort.h" -#include "wdlcstring.h" - -// on all of these, if valdispose is set, the array will dispose of values as needed. -// if keydup/keydispose are set, copies of (any) key data will be made/destroyed as necessary - - -// WDL_AssocArrayImpl can be used on its own, and can contain structs for keys or values -template class WDL_AssocArrayImpl -{ - WDL_AssocArrayImpl(const WDL_AssocArrayImpl &cp) { CopyContents(cp); } - - WDL_AssocArrayImpl &operator=(const WDL_AssocArrayImpl &cp) { CopyContents(cp); return *this; } - -public: - - explicit WDL_AssocArrayImpl(int (*keycmp)(KEY *k1, KEY *k2), - KEY (*keydup)(KEY)=NULL, - void (*keydispose)(KEY)=NULL, - void (*valdispose)(VAL)=NULL) - { - m_keycmp = keycmp; - m_keydup = keydup; - m_keydispose = keydispose; - m_valdispose = valdispose; - } - - ~WDL_AssocArrayImpl() - { - DeleteAll(); - } - - VAL* GetPtr(KEY key, KEY *keyPtrOut=NULL) const - { - bool ismatch = false; - int i = LowerBound(key, &ismatch); - if (ismatch) - { - KeyVal* kv = m_data.Get()+i; - if (keyPtrOut) *keyPtrOut = kv->key; - return &(kv->val); - } - return 0; - } - - bool Exists(KEY key) const - { - bool ismatch = false; - LowerBound(key, &ismatch); - return ismatch; - } - - int Insert(KEY key, VAL val) - { - bool ismatch = false; - int i = LowerBound(key, &ismatch); - if (ismatch) - { - KeyVal* kv = m_data.Get()+i; - if (m_valdispose) m_valdispose(kv->val); - kv->val = val; - } - else - { - KeyVal* kv = m_data.Resize(m_data.GetSize()+1)+i; - memmove(kv+1, kv, (m_data.GetSize()-i-1)*(unsigned int)sizeof(KeyVal)); - if (m_keydup) key = m_keydup(key); - kv->key = key; - kv->val = val; - } - return i; - } - - void Delete(KEY key) - { - bool ismatch = false; - int i = LowerBound(key, &ismatch); - if (ismatch) - { - KeyVal* kv = m_data.Get()+i; - if (m_keydispose) m_keydispose(kv->key); - if (m_valdispose) m_valdispose(kv->val); - m_data.Delete(i); - } - } - - void DeleteByIndex(int idx) - { - if (idx >= 0 && idx < m_data.GetSize()) - { - KeyVal* kv = m_data.Get()+idx; - if (m_keydispose) m_keydispose(kv->key); - if (m_valdispose) m_valdispose(kv->val); - m_data.Delete(idx); - } - } - - void DeleteAll(bool resizedown=false) - { - if (m_keydispose || m_valdispose) - { - int i; - for (i = 0; i < m_data.GetSize(); ++i) - { - KeyVal* kv = m_data.Get()+i; - if (m_keydispose) m_keydispose(kv->key); - if (m_valdispose) m_valdispose(kv->val); - } - } - m_data.Resize(0, resizedown); - } - - int GetSize() const - { - return m_data.GetSize(); - } - - VAL* EnumeratePtr(int i, KEY* key=NULL) const - { - if (i >= 0 && i < m_data.GetSize()) - { - KeyVal* kv = m_data.Get()+i; - if (key) *key = kv->key; - return &(kv->val); - } - return 0; - } - - KEY* ReverseLookupPtr(VAL val) const - { - int i; - for (i = 0; i < m_data.GetSize(); ++i) - { - KeyVal* kv = m_data.Get()+i; - if (kv->val == val) return &kv->key; - } - return 0; - } - - void ChangeKey(KEY oldkey, KEY newkey) - { - bool ismatch=false; - int i=LowerBound(oldkey, &ismatch); - if (ismatch) ChangeKeyByIndex(i, newkey, true); - } - - void ChangeKeyByIndex(int idx, KEY newkey, bool needsort) - { - if (idx >= 0 && idx < m_data.GetSize()) - { - KeyVal* kv=m_data.Get()+idx; - if (!needsort) - { - if (m_keydispose) m_keydispose(kv->key); - if (m_keydup) newkey=m_keydup(newkey); - kv->key=newkey; - } - else - { - VAL val=kv->val; - m_data.Delete(idx); - Insert(newkey, val); - } - } - } - - // fast add-block mode - void AddUnsorted(KEY key, VAL val) - { - int i=m_data.GetSize(); - KeyVal* kv = m_data.Resize(i+1)+i; - if (m_keydup) key = m_keydup(key); - kv->key = key; - kv->val = val; - } - - void Resort(int (*new_keycmp)(KEY *k1, KEY *k2)=NULL) - { - if (new_keycmp) m_keycmp = new_keycmp; - if (m_data.GetSize() > 1 && m_keycmp) - { - qsort(m_data.Get(), m_data.GetSize(), sizeof(KeyVal), - (int(*)(const void*, const void*))m_keycmp); - if (!new_keycmp) - RemoveDuplicateKeys(); - } - } - - void ResortStable() - { - if (m_data.GetSize() > 1 && m_keycmp) - { - char *tmp=(char*)malloc(m_data.GetSize()*sizeof(KeyVal)); - if (WDL_NORMALLY(tmp)) - { - WDL_mergesort(m_data.Get(), m_data.GetSize(), sizeof(KeyVal), - (int(*)(const void*, const void*))m_keycmp, tmp); - free(tmp); - } - else - { - qsort(m_data.Get(), m_data.GetSize(), sizeof(KeyVal), - (int(*)(const void*, const void*))m_keycmp); - } - - RemoveDuplicateKeys(); - } - } - - int LowerBound(KEY key, bool* ismatch) const - { - int a = 0; - int c = m_data.GetSize(); - while (a != c) - { - int b = (a+c)/2; - KeyVal* kv=m_data.Get()+b; - int cmp = m_keycmp(&key, &kv->key); - if (cmp > 0) a = b+1; - else if (cmp < 0) c = b; - else - { - *ismatch = true; - return b; - } - } - *ismatch = false; - return a; - } - - int GetIdx(KEY key) const - { - bool ismatch=false; - int i = LowerBound(key, &ismatch); - if (ismatch) return i; - return -1; - } - - void SetGranul(int gran) - { - m_data.SetGranul(gran); - } - - void CopyContents(const WDL_AssocArrayImpl &cp) - { - m_data=cp.m_data; - m_keycmp = cp.m_keycmp; - m_keydup = cp.m_keydup; - m_keydispose = m_keydup ? cp.m_keydispose : NULL; - m_valdispose = NULL; // avoid disposing of values twice, since we don't have a valdup, we can't have a fully valid copy - if (m_keydup) - { - const int n=m_data.GetSize(); - for (int x=0;xkey = m_keydup(kv->key); - } - } - } - - void CopyContentsAsReference(const WDL_AssocArrayImpl &cp) - { - DeleteAll(true); - m_keycmp = cp.m_keycmp; - m_keydup = NULL; // this no longer can own any data - m_keydispose = NULL; - m_valdispose = NULL; - - m_data=cp.m_data; - } - - -// private data, but exposed in case the caller wants to manipulate at its own risk - struct KeyVal - { - KEY key; - VAL val; - }; - WDL_TypedBuf m_data; - - static int keycmp_ptr(KEY *a, KEY *b) { return (INT_PTR)*a > (INT_PTR)*b ? 1 : (INT_PTR)*a < (INT_PTR)*b ? -1 : 0; } - -protected: - - int (*m_keycmp)(KEY *k1, KEY *k2); - KEY (*m_keydup)(KEY); - void (*m_keydispose)(KEY); - void (*m_valdispose)(VAL); - -private: - - void RemoveDuplicateKeys() // after resorting - { - const int sz = m_data.GetSize(); - - int cnt = 1; - KeyVal *rd = m_data.Get() + 1, *wr = rd; - for (int x = 1; x < sz; x ++) - { - if (m_keycmp(&rd->key, &wr[-1].key)) - { - if (rd != wr) *wr=*rd; - wr++; - cnt++; - } - else - { - if (m_keydispose) m_keydispose(rd->key); - if (m_valdispose) m_valdispose(rd->val); - } - rd++; - } - if (cnt < sz) m_data.Resize(cnt,false); - } -}; - - -// WDL_AssocArray adds useful functions but cannot contain structs for keys or values -template class WDL_AssocArray : public WDL_AssocArrayImpl -{ -public: - - explicit WDL_AssocArray(int (*keycmp)(KEY *k1, KEY *k2), - KEY (*keydup)(KEY)=NULL, - void (*keydispose)(KEY)=NULL, void (*valdispose)(VAL)=NULL) - : WDL_AssocArrayImpl(keycmp, keydup, keydispose, valdispose) - { - } - - VAL Get(KEY key, VAL notfound=0) const - { - VAL* p = this->GetPtr(key); - if (p) return *p; - return notfound; - } - - VAL Enumerate(int i, KEY* key=NULL, VAL notfound=0) const - { - VAL* p = this->EnumeratePtr(i, key); - if (p) return *p; - return notfound; - } - - KEY ReverseLookup(VAL val, KEY notfound=0) const - { - KEY* p=this->ReverseLookupPtr(val); - if (p) return *p; - return notfound; - } -}; - - -template class WDL_IntKeyedArray : public WDL_AssocArray -{ -public: - - explicit WDL_IntKeyedArray(void (*valdispose)(VAL)=NULL) - : WDL_AssocArray(cmpint, NULL, NULL, valdispose) {} - - static int cmpint(int *a, int *b) { return *a > *b ? 1 : *a < *b ? -1 : 0; } -}; - -template class WDL_IntKeyedArray2 : public WDL_AssocArrayImpl -{ -public: - - explicit WDL_IntKeyedArray2(void (*valdispose)(VAL)=NULL) - : WDL_AssocArrayImpl(cmpint, NULL, NULL, valdispose) {} - - static int cmpint(int *a, int *b) { return *a > *b ? 1 : *a < *b ? -1 : 0; } -}; - -template class WDL_StringKeyedArray : public WDL_AssocArray -{ -public: - - explicit WDL_StringKeyedArray(bool caseSensitive=true, void (*valdispose)(VAL)=NULL) - : WDL_AssocArray(caseSensitive?cmpstr:cmpistr, dupstr, freestr, valdispose) {} - - static const char *dupstr(const char *s) { return strdup(s); } // these might not be necessary but depending on the libc maybe... - static int cmpstr(const char **s1, const char **s2) { return strcmp(*s1, *s2); } - static int cmpistr(const char **a, const char **b) { return stricmp(*a,*b); } - static void freestr(const char* s) { free((void*)s); } - static void freecharptr(char *p) { free(p); } -}; - - -template class WDL_StringKeyedArray2 : public WDL_AssocArrayImpl -{ -public: - - explicit WDL_StringKeyedArray2(bool caseSensitive=true, void (*valdispose)(VAL)=NULL) - : WDL_AssocArrayImpl(caseSensitive?cmpstr:cmpistr, dupstr, freestr, valdispose) {} - - ~WDL_StringKeyedArray2() { } - - static const char *dupstr(const char *s) { return strdup(s); } // these might not be necessary but depending on the libc maybe... - static int cmpstr(const char **s1, const char **s2) { return strcmp(*s1, *s2); } - static int cmpistr(const char **a, const char **b) { return stricmp(*a,*b); } - static void freestr(const char* s) { free((void*)s); } - static void freecharptr(char *p) { free(p); } -}; - -// sorts text as text, sorts anything that looks like a number as a number -template class WDL_LogicalSortStringKeyedArray : public WDL_StringKeyedArray -{ -public: - - explicit WDL_LogicalSortStringKeyedArray(bool caseSensitive=true, void (*valdispose)(VAL)=NULL) - : WDL_StringKeyedArray(caseSensitive, valdispose) - { - WDL_StringKeyedArray::m_keycmp = caseSensitive?cmpstr:cmpistr; // override - } - - ~WDL_LogicalSortStringKeyedArray() { } - - static int cmpstr(const char **a, const char **b) - { - int r=WDL_strcmp_logical_ex(*a, *b, 1, WDL_STRCMP_LOGICAL_EX_FLAG_UTF8CONVERT); - return r?r:strcmp(*a,*b); - } - static int cmpistr(const char **a, const char **b) - { - int r=WDL_strcmp_logical_ex(*a, *b, 0, WDL_STRCMP_LOGICAL_EX_FLAG_UTF8CONVERT); - return r?r:stricmp(*a,*b); - } -}; - - -template class WDL_PtrKeyedArray : public WDL_AssocArray -{ -public: - explicit WDL_PtrKeyedArray(void (*valdispose)(VAL)=NULL) - : WDL_AssocArray(WDL_AssocArray::keycmp_ptr, NULL, NULL, valdispose) {} -}; - -template class WDL_PointerKeyedArray : public WDL_AssocArray -{ -public: - explicit WDL_PointerKeyedArray(void (*valdispose)(VAL)=NULL) - : WDL_AssocArray(WDL_AssocArray::keycmp_ptr, NULL, NULL, valdispose) {} -}; - -struct WDL_Set_DummyRec { }; -template class WDL_Set : public WDL_AssocArrayImpl -{ - public: - explicit WDL_Set(int (*keycmp)(KEY *k1, KEY *k2), - KEY (*keydup)(KEY)=NULL, - void (*keydispose)(KEY)=NULL - ) - : WDL_AssocArrayImpl(keycmp,keydup,keydispose) - { - } - - int Insert(KEY key) - { - WDL_Set_DummyRec r; - return WDL_AssocArrayImpl::Insert(key,r); - } - void AddUnsorted(KEY key) - { - WDL_Set_DummyRec r; - WDL_AssocArrayImpl::AddUnsorted(key,r); - } - - bool Get(KEY key) const - { - return WDL_AssocArrayImpl::Exists(key); - } - bool Enumerate(int i, KEY *key=NULL) - { - return WDL_AssocArrayImpl::EnumeratePtr(i,key) != NULL; - } -}; - -template class WDL_PtrSet : public WDL_Set -{ -public: - explicit WDL_PtrSet() : WDL_Set( WDL_AssocArray::keycmp_ptr ) { } -}; - - - -#endif - diff --git a/oversampling/WDL/audiobuffercontainer.cpp b/oversampling/WDL/audiobuffercontainer.cpp deleted file mode 100644 index d68d837..0000000 --- a/oversampling/WDL/audiobuffercontainer.cpp +++ /dev/null @@ -1,243 +0,0 @@ -#include "audiobuffercontainer.h" -#include "queue.h" -#include - -void ChannelPinMapper::Reset() -{ - for (int i=0; i < CHANNELPINMAPPER_MAXPINS; ++i) - m_mapping[i].set_excl(i); -} - -void ChannelPinMapper::SetNPins(int nPins) -{ - if (nPins<0) nPins=0; - else if (nPins>CHANNELPINMAPPER_MAXPINS) nPins=CHANNELPINMAPPER_MAXPINS; - int i; - for (i = m_nPins; i < nPins; ++i) - { - ClearPin(i); - if (i < m_nCh) - { - SetPin(i, i, true); - } - } - m_nPins = nPins; -} - -void ChannelPinMapper::SetNChannels(int nCh, bool auto_passthru) -{ - if (auto_passthru) for (int i = m_nCh; i < nCh && i < m_nPins; ++i) { - SetPin(i, i, true); - } - m_nCh = nCh; -} - -void ChannelPinMapper::Init(const PinMapPin * pMapping, int nPins) -{ - if (nPins<0) nPins=0; - else if (nPins>CHANNELPINMAPPER_MAXPINS) nPins=CHANNELPINMAPPER_MAXPINS; - memcpy(m_mapping, pMapping, nPins*sizeof(PinMapPin)); - memset(m_mapping+nPins, 0, (CHANNELPINMAPPER_MAXPINS-nPins)*sizeof(PinMapPin)); - m_nPins = m_nCh = nPins; -} - -#define BITMASK64(bitIdx) (((WDL_UINT64)1)<<(bitIdx)) - -void ChannelPinMapper::ClearPin(int pinIdx) -{ - if (pinIdx >=0 && pinIdx < CHANNELPINMAPPER_MAXPINS) m_mapping[pinIdx].clear(); -} - -void ChannelPinMapper::SetPin(int pinIdx, int chIdx, bool on) -{ - if (pinIdx >=0 && pinIdx < CHANNELPINMAPPER_MAXPINS) - { - if (on) - { - m_mapping[pinIdx].set_chan(chIdx); - } - else - { - m_mapping[pinIdx].clear_chan(chIdx); - } - } -} - -bool ChannelPinMapper::TogglePin(int pinIdx, int chIdx) -{ - bool on = GetPin(pinIdx, chIdx); - on = !on; - SetPin(pinIdx, chIdx, on); - return on; -} - -bool ChannelPinMapper::GetPin(int pinIdx, int chIdx) const -{ - if (pinIdx >= 0 && pinIdx < CHANNELPINMAPPER_MAXPINS) - { - return m_mapping[pinIdx].has_chan(chIdx); - } - return false; -} - -bool ChannelPinMapper::IsStraightPassthrough() const -{ - if (m_nCh != m_nPins) return false; - PinMapPin tmp; - tmp.clear(); - for (int i = 0; i < m_nPins; ++i) - { - tmp.set_chan(i); - if (!tmp.equal_to(m_mapping[i])) return false; - tmp.clear_chan(i); - } - return true; -} - -#define PINMAPPER_MAGIC 1000 - -const char *ChannelPinMapper::SaveStateNew(int* pLen) -{ - m_cfgret.Clear(); - int magic = PINMAPPER_MAGIC; - WDL_Queue__AddToLE(&m_cfgret, &magic); - WDL_Queue__AddToLE(&m_cfgret, &m_nCh); - WDL_Queue__AddToLE(&m_cfgret, &m_nPins); - const int num64 = wdl_max(1,(wdl_min(m_nCh,CHANNELPINMAPPER_MAXPINS) + 63)/64); - for (int y = 0; y < num64; y ++) - { - for (int x = 0; x < m_nPins; x ++) - { - const WDL_UINT64 v = m_mapping[x].get_64(y); - WDL_Queue__AddToLE(&m_cfgret, &v); - } - } - *pLen = m_cfgret.GetSize(); - return (const char*)m_cfgret.Get(); -} - -bool ChannelPinMapper::LoadState(const char* buf, int len) -{ - WDL_Queue chunk; - chunk.Add(buf, len); - int* pMagic = WDL_Queue__GetTFromLE(&chunk, (int*)0); - if (!pMagic || *pMagic != PINMAPPER_MAGIC) return false; - int* pNCh = WDL_Queue__GetTFromLE(&chunk, (int*) 0); - int* pNPins = WDL_Queue__GetTFromLE(&chunk, (int*) 0); - if (!pNCh || !pNPins) return false; - const int src_pins = *pNPins; - SetNPins(src_pins); - SetNChannels(*pNCh); - const int num64 = wdl_max(1,(wdl_min(m_nCh,CHANNELPINMAPPER_MAXPINS)+63)/64); - const int maplen = src_pins * sizeof(WDL_UINT64); - for (int y = 0; y < num64; y ++) - { - if (chunk.Available() < maplen) return y>0; - const WDL_UINT64 *pMap = (const WDL_UINT64 *)WDL_Queue__GetDataFromLE(&chunk, maplen, sizeof(WDL_UINT64)); - const int sz = wdl_min(m_nPins,src_pins); - for (int x = 0; x < sz; x ++) - { - m_mapping[x].set_64(pMap[x], y); - } - } - - return true; -} - - -AudioBufferContainer::AudioBufferContainer() -{ - m_nCh = 0; - m_nFrames = 0; - m_fmt = FMT_32FP; - m_interleaved = true; - m_hasData = false; -} - -// converts interleaved buffer to interleaved buffer, using min(len_in,len_out) and zeroing any extra samples -// isInput means it reads from track channels and writes to plugin pins -// wantZeroExcessOutput=false means that untouched channels will be preserved in buf_out -void PinMapperConvertBuffers(const double *buf, int len_in, int nch_in, - double *buf_out, int len_out, int nch_out, - const ChannelPinMapper *pinmap, bool isInput, bool wantZeroExcessOutput) -{ - - if (pinmap->IsStraightPassthrough() || !pinmap->GetNPins()) - { - int x; - char *op = (char *)buf_out; - const char *ip = (const char *)buf; - - const int ip_adv = nch_in * sizeof(double); - - const int clen = wdl_min(nch_in, nch_out) * sizeof(double); - const int zlen = nch_out > nch_in ? (nch_out - nch_in) * sizeof(double) : 0; - - const int cplen = wdl_min(len_in,len_out); - - for (x=0;xGetNPins(),isInput ? nch_out : nch_in); - const int nchan = isInput ? nch_in : nch_out; - - int p; - PinMapPin clearmask; - clearmask.clear(); - for (p = 0; p < npins; p ++) - { - const PinMapPin &map = pinmap->m_mapping[p]; - for (unsigned int x = 0; map.enum_chans(&x,nchan); x ++) - { - int i=len_in; - const double *ip = buf + (isInput ? x : p); - const int out_idx = (isInput ? p : x); - - bool want_zero=false; - if (!wantZeroExcessOutput) - { - if (!clearmask.has_chan(out_idx)) - { - clearmask.set_chan(out_idx); - want_zero=true; - } - } - - double *op = buf_out + out_idx; - - if (want_zero) - { - while (i-- > 0) - { - *op = *ip; - op += nch_out; - ip += nch_in; - } - } - else - { - while (i-- > 0) - { - *op += *ip; - op += nch_out; - ip += nch_in; - } - } - } - } - } -} diff --git a/oversampling/WDL/audiobuffercontainer.h b/oversampling/WDL/audiobuffercontainer.h deleted file mode 100644 index b11a63c..0000000 --- a/oversampling/WDL/audiobuffercontainer.h +++ /dev/null @@ -1,228 +0,0 @@ -#ifndef _AUDIOBUFFERCONTAINER_ -#define _AUDIOBUFFERCONTAINER_ - -#include "wdltypes.h" -#include -#include -#include "ptrlist.h" -#include "queue.h" - - -#define CHANNELPINMAPPER_MAXPINS 128 - - -struct PinMapPin -{ - enum { PINMAP_PIN_MAX_CHANNELS = CHANNELPINMAPPER_MAXPINS }; - - enum { STATE_ENT_BITS=64, STATE_SIZE=(PINMAP_PIN_MAX_CHANNELS + STATE_ENT_BITS - 1) / STATE_ENT_BITS }; - WDL_UINT64 state[STATE_SIZE]; - static WDL_UINT64 make_mask(unsigned int idx) { return WDL_UINT64_CONST(1) << (idx & (STATE_ENT_BITS-1)); } - static WDL_UINT64 full_mask() { return ~WDL_UINT64_CONST(0); } - - WDL_UINT64 get_64(unsigned int offs=0) const { - return WDL_NORMALLY(offs < STATE_SIZE) ? state[offs] : 0; - } - void set_64(WDL_UINT64 s, unsigned int offs=0) { - if (WDL_NORMALLY(offs < STATE_SIZE)) state[offs]=s; - } - unsigned int get_64_max() const { return STATE_SIZE; } - unsigned int get_64_top(unsigned int minv=0) const { - unsigned int x = STATE_SIZE; - while (x > minv && !state[x-1]) x--; - return x; - } - - void clear() { memset(state,0,sizeof(state)); } - void clear_chan(unsigned int ch) { if (WDL_NORMALLY(ch < PINMAP_PIN_MAX_CHANNELS)) state[ch/STATE_ENT_BITS] &= ~make_mask(ch); } - void set_chan(unsigned int ch) { if (WDL_NORMALLY(ch < PINMAP_PIN_MAX_CHANNELS)) state[ch/STATE_ENT_BITS] |= make_mask(ch); } - void tog_chan(unsigned int ch) { if (WDL_NORMALLY(ch < PINMAP_PIN_MAX_CHANNELS)) state[ch/STATE_ENT_BITS] ^= make_mask(ch); } - void set_chan_lt(unsigned int cnt) - { - if (WDL_NOT_NORMALLY(cnt > PINMAP_PIN_MAX_CHANNELS)) cnt = PINMAP_PIN_MAX_CHANNELS; - for (int x = 0; cnt && x < STATE_SIZE; x ++) - { - if (cnt < STATE_ENT_BITS) { state[x] |= make_mask(cnt)-1; cnt=0; } - else { state[x] = full_mask(); cnt -= STATE_ENT_BITS; } - } - } - void set_excl(unsigned int ch) { clear(); set_chan(ch); } - - bool has_chan(unsigned int ch) const { return WDL_NORMALLY(ch < PINMAP_PIN_MAX_CHANNELS) && (state[ch/STATE_ENT_BITS] & make_mask(ch)); } - bool has_chan_lt(unsigned int cnt) const - { - if (WDL_NOT_NORMALLY(cnt > PINMAP_PIN_MAX_CHANNELS)) cnt = PINMAP_PIN_MAX_CHANNELS; - for (int x = 0; cnt && x < STATE_SIZE; x ++) - { - if (cnt < STATE_ENT_BITS) return (state[x] & (make_mask(cnt)-1)); - if (state[x]) return true; - cnt -= STATE_ENT_BITS; - } - return false; - } - - // call with 0, then increment after each call (returns false when done) - bool enum_chans(unsigned int *ch, unsigned int maxch=PINMAP_PIN_MAX_CHANNELS) const - { - if (WDL_NOT_NORMALLY(maxch > PINMAP_PIN_MAX_CHANNELS)) - maxch = PINMAP_PIN_MAX_CHANNELS; - - unsigned int x = *ch; - if (x >= maxch) return false; - - WDL_UINT64 s = state[x / STATE_ENT_BITS] >> (x & (STATE_ENT_BITS-1)); - for (;;) - { - if (s) - { - do - { - if (s&1) { *ch = x; return true; } - s>>=1; - x++; - WDL_ASSERT(x & (STATE_ENT_BITS-1)); // we should never run out of bits! - } - while (x < maxch); - break; - } - x = (x & ~(STATE_ENT_BITS-1)) + STATE_ENT_BITS; - if (x >= maxch) break; - s = state[x / STATE_ENT_BITS]; - } - - *ch = x; - return false; - } - - PinMapPin & operator |= (const PinMapPin &v) - { - for (int x = 0; x < STATE_SIZE; x ++) state[x]|=v.state[x]; - return *this; - } - - PinMapPin & operator &= (const PinMapPin &v) - { - for (int x = 0; x < STATE_SIZE; x ++) state[x]&=v.state[x]; - return *this; - } - - void invert() - { - for (int x = 0; x < STATE_SIZE; x ++) state[x]^=full_mask(); - } - - bool equal_to(const PinMapPin &v, unsigned int nch_top = PINMAP_PIN_MAX_CHANNELS) const - { - if (WDL_NOT_NORMALLY(nch_top > PINMAP_PIN_MAX_CHANNELS)) nch_top = PINMAP_PIN_MAX_CHANNELS; - for (unsigned int x = 0; x < nch_top; x += STATE_ENT_BITS) - { - if ((v.state[x/STATE_ENT_BITS]^state[x/STATE_ENT_BITS]) & - (((nch_top-x) < STATE_ENT_BITS) ? (make_mask(nch_top-x)-1) : full_mask())) - return false; - } - return true; - } -}; - - -class ChannelPinMapper -{ -public: - - ChannelPinMapper() : m_nCh(0), m_nPins(0) { Reset(); } - ~ChannelPinMapper() {} - - void SetNPins(int nPins); - void SetNChannels(int nCh, bool auto_passthru=true); - // or ... - void Init(const PinMapPin * pMapping, int nPins); - // or ... - void Reset(); // set to full passthrough - - int GetNPins() const { return m_nPins; } - int GetNChannels() const { return m_nCh; } - - void ClearPin(int pinIdx); - void SetPin(int pinIdx, int chIdx, bool on); - bool TogglePin(int pinIdx, int chIdx); - - // true if this pin is mapped to this channel - bool GetPin(int pinIdx, int chIdx) const; - - // true if this mapper is a straight 1:1 passthrough - bool IsStraightPassthrough() const; - - const char *SaveStateNew(int* pLen); // owned - bool LoadState(const char* buf, int len); - - PinMapPin m_mapping[CHANNELPINMAPPER_MAXPINS]; - int m_nCh, m_nPins; - -private: - - WDL_Queue m_cfgret; -}; - -// converts interleaved buffer to interleaved buffer, using min(len_in,len_out) and zeroing any extra samples -// isInput means it reads from track channels and writes to plugin pins -// wantZeroExcessOutput=false means that untouched channels will be preserved in buf_out -void PinMapperConvertBuffers(const double *buf, int len_in, int nch_in, - double *buf_out, int len_out, int nch_out, - const ChannelPinMapper *pinmap, bool isInput, bool wantZeroExcessOutput); - -// use for float and double only ... ints will break it -class AudioBufferContainer -{ -public: - - AudioBufferContainer(); - ~AudioBufferContainer() {} - - enum - { - FMT_32FP=4, - FMT_64FP=8 - }; - - static bool BufConvert(void* dest, const void* src, int destFmt, int srcFmt, int nFrames, int destStride, int srcStride); - - int GetNChannels() const { return m_nCh; } - int GetNFrames() const { return m_nFrames; } - int GetFormat() const { return m_fmt; } - - void Resize(int nCh, int nFrames, bool preserveData); - // call Reformat(GetFormat(), false) to discard current data (for efficient repopulating) - void Reformat(int fmt, bool preserveData); - - // src=NULL to memset(0) - void* SetAllChannels(int fmt, const void* src, int nCh, int nFrames); - - // src=NULL to memset(0) - void* SetChannel(int fmt, const void* src, int chIdx, int nFrames); - - void* MixChannel(int fmt, const void* src, int chIdx, int nFrames, bool addToDest, double wt_start, double wt_end); - - void* GetAllChannels(int fmt, bool preserveData); - void* GetChannel(int fmt, int chIdx, bool preserveData); - - void CopyFrom(const AudioBufferContainer* rhs); - -private: - - void ReLeave(bool interleave, bool preserveData); - - WDL_HeapBuf m_data; - int m_nCh; - int m_nFrames; - - int m_fmt; - bool m_interleaved; - bool m_hasData; -} WDL_FIXALIGN; - - -void SetPinsFromChannels(AudioBufferContainer* dest, AudioBufferContainer* src, const ChannelPinMapper* mapper, int forceMinChanCnt=0); -void SetChannelsFromPins(AudioBufferContainer* dest, AudioBufferContainer* src, const ChannelPinMapper* mapper, double wt_start=1.0, double wt_end=1.0); - - -#endif diff --git a/oversampling/WDL/besselfilter.cpp b/oversampling/WDL/besselfilter.cpp deleted file mode 100644 index fbf1a20..0000000 --- a/oversampling/WDL/besselfilter.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "besselfilter.h" - -// table produced by mkfilter's bessel -- N.B. only one member of each C.Conj. pair is listed -const WDL_BesselFilterCoeffs::complex WDL_BesselFilterCoeffs::mPoles[10 * 3] = -{ - complex(-9.9999999999999978e-001, 0.0000000000000000e+000), complex(-1.1016013305921748e+000, 6.3600982475704204e-001), - complex(-1.3226757999104561e+000, 0.0000000000000000e+000), complex(-1.0474091610089453e+000, 9.9926443628064676e-001), - complex(-1.3700678305514509e+000, 4.1024971749375211e-001), complex(-9.9520876435027783e-001, 1.2571057394546732e+000), - complex(-1.5023162714474929e+000, 0.0000000000000000e+000), complex(-1.3808773258604621e+000, 7.1790958762678447e-001), - complex(-9.5767654856269568e-001, 1.4711243207304141e+000), complex(-1.5714904036160653e+000, 3.2089637422258727e-001), - complex(-1.3818580975965893e+000, 9.7147189071159734e-001), complex(-9.3065652294686840e-001, 1.6618632689426145e+000), - complex(-1.6843681792730136e+000, 0.0000000000000000e+000), complex(-1.6120387662260254e+000, 5.8924450693124097e-001), - complex(-1.3789032167953983e+000, 1.1915667778006367e+000), complex(-9.0986778062340656e-001, 1.8364513530362705e+000), - complex(-1.7574084004017807e+000, 2.7286757510254800e-001), complex(-1.6369394181268191e+000, 8.2279562513962257e-001), - complex(-1.3738412176373478e+000, 1.3883565758775174e+000), complex(-8.9286971884713073e-001, 1.9983258436412903e+000), - complex(-1.8566005012059337e+000, 0.0000000000000000e+000), complex(-1.8071705349890272e+000, 5.1238373057326947e-001), - complex(-1.6523964845794235e+000, 1.0313895669915880e+000), complex(-1.3675883097976385e+000, 1.5677337122426156e+000), - complex(-8.7839927616393221e-001, 2.1498005243204834e+000), complex(-1.9276196913244821e+000, 2.4162347094517739e-001), - complex(-1.8421962445659017e+000, 7.2725759775348364e-001), complex(-1.6618102413500957e+000, 1.2211002185915161e+000), - complex(-1.3606922783857325e+000, 1.7335057426584299e+000), complex(-8.6575690170894881e-001, 2.2926048309837426e+000) -}; diff --git a/oversampling/WDL/besselfilter.h b/oversampling/WDL/besselfilter.h deleted file mode 100644 index b1b077d..0000000 --- a/oversampling/WDL/besselfilter.h +++ /dev/null @@ -1,412 +0,0 @@ -/* - WDL - besselfilter.h - (c) Theo Niessink 2011 - - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - - This file provides classes for a low-pass Bessel filter design using the - matched Z-transform method. - - This Bessel filter implementation was originally extracted from from the - source code of mkfilter, written by A.J. Fisher. - - - - Example #1: - - // 8th order anti-alias filter - #define WDL_BESSEL_FILTER_ORDER 8 - #include "besselfilter.h" - - int oversampling = 8; - - WDL_BesselFilterCoeffs bessel; - WDL_BesselFilterStage filter; - - bessel.Calc(0.5 / (double)oversampling); - filter.Reset(); - - for (int i = 0; i < nFrames; ++i) - { - filter.Process(inputs[0][i], bessel.Coeffs()); - outputs[0][i] = filter.Output(); - } - - Example #2: - - #include "besselfilter.h" - - int order = 4; - int oversampling = 8; - - // 2 cascaded filters - WDL_BesselFilterStage filter[2]; - filter[0].Reset(); - filter[1].Reset(); - - WDL_BesselFilterCoeffs coeffs; - coeffs.Calc(0.5 / (double)oversampling, order); - - for (int i = 0; i < nFrames; ++i) - { - filter[0].Process(inputs[0][i], &coeffs); - filter[1].Process(filter[0].Output(), &coeffs); - outputs[0][i] = filter[1].Output(); - } - - Example #3: - - #define WDL_BESSEL_DENORMAL_AGGRESSIVE - #include "besselfilter.h" - - int order = 8; - int oversampling = 8; - - WDL_BesselFilter bessel; - bessel.Calc(0.5 / (double)oversampling, order); - bessel.Reset(); - - for (int i = 0; i < nFrames; ++i) - { - bessel.Process(inputs[0][i]); - outputs[0][i] = bessel.Output(); - } - -*/ - - -#ifndef _BESSELFILTER_H_ -#define _BESSELFILTER_H_ - - -#include -#ifdef _MSC_VER -#pragma warning(disable:4996) // hypot -#endif - -#include -#include - -#include "wdltypes.h" - -// By default denormals are zeroed to prevent exessive CPU use. Defining -// WDL_BESSEL_DENORMAL_IGNORE will disable denormal filtering. Defining -// WDL_BESSEL_DENORMAL_AGGRESSIVE will filter out denormals more -// aggressively by zeroing anything below 5.6e-017. -#ifndef WDL_BESSEL_DENORMAL_IGNORE - #include "denormal.h" - #if defined(WDL_BESSEL_DENORMAL_AGGRESSIVE) - #define WDL_BESSEL_FIX_DENORMAL(a) (denormal_fix_double_aggressive(a)) - #else - #define WDL_BESSEL_FIX_DENORMAL(a) (denormal_fix_double(a)) - #endif -#else - #define WDL_BESSEL_FIX_DENORMAL(a) ((void)0) -#endif - - -// Defining WDL_BESSEL_FILTER_ORDER will make the Bessel filter order fixed, -// which increases efficiency. -#ifdef WDL_BESSEL_FILTER_ORDER - #if !(WDL_BESSEL_FILTER_ORDER >= 1 && WDL_BESSEL_FILTER_ORDER <= 10) - #error WDL_BESSEL_FILTER_ORDER should be in 1..10 range - #endif - #define WDL_BESSEL_FILTER_MAX WDL_BESSEL_FILTER_ORDER - -// Defining WDL_BESSEL_FILTER_MAX limits the maximum Bessel filter order, -// which reduces buffer sizes. -#else - #if defined(WDL_BESSEL_FILTER_MAX) && WDL_BESSEL_FILTER_MAX < 1 - #define WDL_BESSEL_FILTER_MAX 1 - #elif !defined(WDL_BESSEL_FILTER_MAX) || WDL_BESSEL_FILTER_MAX > 10 - #define WDL_BESSEL_FILTER_MAX 10 - #endif -#endif - - -class WDL_BesselFilterCoeffs -{ - friend class WDL_BesselFilterStage; - -public: - inline WDL_BesselFilterCoeffs() {} - -#ifdef WDL_BESSEL_FILTER_ORDER - // alpha = cornerFreq / (oversampling * sampleRate) - inline WDL_BesselFilterCoeffs(const double alpha) { Calc(alpha); } - - void Calc(double alpha) - { - const int order = WDL_BESSEL_FILTER_ORDER; - -#else - inline WDL_BesselFilterCoeffs(const double alpha, const int order) { Calc(alpha, order); } - - void Calc(double alpha, const int order) - { - assert(order >= 1 && order <= WDL_BESSEL_FILTER_MAX); - mOrder = order; -#endif - - assert(alpha >= 1e-37 && alpha < 0.5); - alpha *= 6.283185307179586476; // 2.*M_PI - - // compute S-plane poles for prototype LP filter - // transform prototype into appropriate filter type (lp) - // given S-plane poles & zeros, compute Z-plane poles & zeros, by matched z-transform - complex zplane[WDL_BESSEL_FILTER_MAX]; - int p = (order*order) / 4; - int n = 0; - if (order & 1) zplane[n++] = exp(multiply(alpha, mPoles[p++])); - for (int i = 0; i < order / 2; ++i) - { - zplane[n++] = exp(multiply(alpha, mPoles[p])); - zplane[n++] = exp(multiply(alpha, conjugate(mPoles[p++]))); - } - - // compute product of poles or zeros as a polynomial of z - complex coeffs[WDL_BESSEL_FILTER_MAX + 1]; - coeffs[0] = 1.; - for (int i = 1; i <= order; ++i) coeffs[i] = 0.; - - for (int i = 0; i < order; ++i) - { - // multiply factor (z-w) into coeffs - complex w = minus(zplane[i]); - for (int i = order; i >= 1; --i) coeffs[i] = add(multiply(w, coeffs[i]), coeffs[i - 1]); - coeffs[0] = multiply(w, coeffs[0]); - } - #ifndef NDEBUG - // check computed coeffs of z^k are all real - for (int n = 0; n <= order; ++n) - { - // mkfilter: coeff of z^n is not real; poles/zeros are not complex conjugates - assert(fabs(coeffs[n].im) <= 1e-10); - } - #endif - - // given Z-plane poles [& zeros], compute [top &] bot polynomials in Z, and then recurrence relation - complex gain = 0.; - for (int i = order; i >= 0; --i) gain = add(gain, coeffs[i]); - gain = inverse(gain); - mCoeffs[0] = 1./hypot(gain.im, gain.re); - for (int i = 1, j = order - 1; i <= order; ++i, --j) mCoeffs[i] = -(coeffs[j].re / coeffs[order].re); - } - - inline int Order() const - { - #ifdef WDL_BESSEL_FILTER_ORDER - return WDL_BESSEL_FILTER_ORDER; - #else - return mOrder; - #endif - } - - inline const double* Coeffs() const { return mCoeffs; } - inline double Gain() const { return mCoeffs[0]; } - -protected: - double mCoeffs[WDL_BESSEL_FILTER_MAX + 1]; - - #ifndef WDL_BESSEL_FILTER_ORDER - int mOrder; - #endif - - // Minimalistic complex number implementation - - struct complex - { - double re, im; - complex() {} - complex(const double r, const double j = 0.): re(r), im(j) {} - }; - - // z = z1 + z2 - inline complex add(const complex z1, const complex z2) const - { - return complex(z1.re + z2.re, z1.im + z2.im); - } - - // z = r * z - inline complex multiply(const double r, const complex z) const - { - return complex(r * z.re, r * z.im); - } - - // z = z1 * z2 - inline complex multiply(const complex z1, const complex z2) const - { - return complex(z1.re * z2.re - z1.im * z2.im, z1.re * z2.im + z1.im * z2.re); - } - - // z = -z - inline complex minus(const complex z) const - { - return complex(-z.re, -z.im); - } - - // z = conjugate(z) - inline complex conjugate(const complex z) const - { - return complex(z.re, -z.im); - } - - // z = 1/z - inline complex inverse(const complex z) const - { - const double r = z.re*z.re + z.im*z.im; - return complex(z.re / r, -z.im / r); - } - - // z = exp(z) - inline complex exp(const complex z) const - { - const double r = ::exp(z.re); - return complex(r * cos(z.im), r * sin(z.im)); - } - - // Precalculated Bessel poles - static const complex mPoles[10 * 3]; -} WDL_FIXALIGN; - -#ifdef WDL_BESSEL_FILTER_ORDER - #define WDL_BESSEL_FILTER_OUTPUT(n) (coeffs[WDL_BESSEL_FILTER_ORDER - n + 1] * mOutput[WDL_BESSEL_FILTER_ORDER - n + 1]) -#endif - -class WDL_BesselFilterStage -{ -public: - inline WDL_BesselFilterStage() {} - inline WDL_BesselFilterStage(const double value) { Reset(value); } - - inline void Reset() { memset(mOutput, 0, sizeof(mOutput)); } - - inline void Reset(const double value) - { - for (int i = 0; i < WDL_BESSEL_FILTER_MAX; ++i) mOutput[i] = value; - } - -#ifdef WDL_BESSEL_FILTER_ORDER - - inline void Process(const double input, const double* const coeffs) - { - #if WDL_BESSEL_FILTER_ORDER >= 10 - mOutput[10] = mOutput[9]; - #endif - #if WDL_BESSEL_FILTER_ORDER >= 9 - mOutput[9] = mOutput[8]; - #endif - #if WDL_BESSEL_FILTER_ORDER >= 8 - mOutput[8] = mOutput[7]; - #endif - #if WDL_BESSEL_FILTER_ORDER >= 7 - mOutput[7] = mOutput[6]; - #endif - #if WDL_BESSEL_FILTER_ORDER >= 6 - mOutput[6] = mOutput[5]; - #endif - #if WDL_BESSEL_FILTER_ORDER >= 5 - mOutput[5] = mOutput[4]; - #endif - #if WDL_BESSEL_FILTER_ORDER >= 4 - mOutput[4] = mOutput[3]; - #endif - #if WDL_BESSEL_FILTER_ORDER >= 3 - mOutput[3] = mOutput[2]; - #endif - #if WDL_BESSEL_FILTER_ORDER >= 2 - mOutput[2] = mOutput[1]; - #endif - mOutput[1] = mOutput[0]; - - mOutput[0] = coeffs[0] * input - #if WDL_BESSEL_FILTER_ORDER >= 10 - + WDL_BESSEL_FILTER_OUTPUT(10) - #endif - #if WDL_BESSEL_FILTER_ORDER >= 9 - + WDL_BESSEL_FILTER_OUTPUT(9) - #endif - #if WDL_BESSEL_FILTER_ORDER >= 8 - + WDL_BESSEL_FILTER_OUTPUT(8) - #endif - #if WDL_BESSEL_FILTER_ORDER >= 7 - + WDL_BESSEL_FILTER_OUTPUT(7) - #endif - #if WDL_BESSEL_FILTER_ORDER >= 6 - + WDL_BESSEL_FILTER_OUTPUT(6) - #endif - #if WDL_BESSEL_FILTER_ORDER >= 5 - + WDL_BESSEL_FILTER_OUTPUT(5) - #endif - #if WDL_BESSEL_FILTER_ORDER >= 4 - + WDL_BESSEL_FILTER_OUTPUT(4) - #endif - #if WDL_BESSEL_FILTER_ORDER >= 3 - + WDL_BESSEL_FILTER_OUTPUT(3) - #endif - #if WDL_BESSEL_FILTER_ORDER >= 2 - + WDL_BESSEL_FILTER_OUTPUT(2) - #endif - + WDL_BESSEL_FILTER_OUTPUT(1); - WDL_BESSEL_FIX_DENORMAL(&mOutput[0]); - } - - inline void Process(const double input, const WDL_BesselFilterCoeffs* const bessel) { Process(input, bessel->mCoeffs); } - -#else // #elif !defined(WDL_BESSEL_FILTER_ORDER) - - inline void Process(const double input, const double* const coeffs, const int order) - { - double output = coeffs[0] * input; - for (int i = order; i > 0; --i) - { - mOutput[i] = mOutput[i - 1]; - output += coeffs[i] * mOutput[i]; - WDL_BESSEL_FIX_DENORMAL(&output); - } - mOutput[0] = output; - } - - inline void Process(const double input, const WDL_BesselFilterCoeffs* const bessel) { Process(input, bessel->mCoeffs, bessel->mOrder); } - -#endif - - inline double Output() const { return mOutput[0]; } - -protected: - double mOutput[WDL_BESSEL_FILTER_MAX + 1]; -} WDL_FIXALIGN; - - -class WDL_BesselFilter: public WDL_BesselFilterCoeffs, public WDL_BesselFilterStage -{ -public: - inline WDL_BesselFilter() {} - - #ifdef WDL_BESSEL_FILTER_ORDER - inline WDL_BesselFilter(const double alpha) { Calc(alpha); } - inline void Process(const double input) { WDL_BesselFilterStage::Process(input, mCoeffs); } - #else - inline WDL_BesselFilter(const double alpha, const int order) { Calc(alpha, order); } - inline void Process(const double input) { WDL_BesselFilterStage::Process(input, mCoeffs, mOrder); } - #endif -} WDL_FIXALIGN; - - -#endif // _BESSELFILTER_H_ diff --git a/oversampling/WDL/bitfield.h b/oversampling/WDL/bitfield.h deleted file mode 100644 index bd08514..0000000 --- a/oversampling/WDL/bitfield.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _WDL_BITFIELD_H_ -#define _WDL_BITFIELD_H_ - -#include "heapbuf.h" - -class WDL_BitField // ultra simple bit field -{ -public: - bool SetSize(int sz) // clears state - { - void *b=m_hb.ResizeOK((sz+7)/8); - if (b) memset(b,0,m_hb.GetSize()); - return !!b; - } - int GetApproxSize() const { return m_hb.GetSize()*8; } // may return slightly greater than the size set - - bool IsSet(unsigned int idx) const - { - const unsigned char mask = 1<<(idx&7); - idx>>=3; - return idx < (unsigned int)m_hb.GetSize() && (((unsigned char *)m_hb.Get())[idx]&mask); - } - void Set(unsigned int idx) - { - const unsigned char mask = 1<<(idx&7); - idx>>=3; - if (idx < (unsigned int)m_hb.GetSize()) ((unsigned char *)m_hb.Get())[idx] |= mask; - } - -private: - WDL_HeapBuf m_hb; -}; - -#endif //_WDL_BITFIELD_H_ \ No newline at end of file diff --git a/oversampling/WDL/chunkalloc.h b/oversampling/WDL/chunkalloc.h deleted file mode 100644 index a4aa5b5..0000000 --- a/oversampling/WDL/chunkalloc.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef _WDL_CHUNKALLOC_H_ -#define _WDL_CHUNKALLOC_H_ - -#include "wdltypes.h" - -class WDL_ChunkAlloc -{ - struct _hdr - { - struct _hdr *_next; - char data[16]; - }; - - _hdr *m_chunks; - int m_chunksize, m_chunkused; - - public: - - WDL_ChunkAlloc(int chunksize=65500) { m_chunks=NULL; m_chunkused=0; m_chunksize=chunksize>16?chunksize:16; } - ~WDL_ChunkAlloc() { Free(); } - - void Free() - { - _hdr *a = m_chunks; - m_chunks=0; - m_chunkused=0; - while (a) { _hdr *f=a; a=a->_next; free(f); } - } - - void *Alloc(int sz, int align=0) - { - if (sz<1) return NULL; - - if (align < 1 || (align & (align-1))) align=1; - - if (m_chunks) - { - int use_sz=sz; - char *p = m_chunks->data + m_chunkused; - int a = ((int) (INT_PTR)p) & (align-1); - if (a) - { - use_sz += align-a; - p += align-a; - } - if (use_sz <= m_chunksize - m_chunkused) - { - m_chunkused += use_sz; - return p; - } - } - - // we assume that malloc always gives at least 8 byte alignment, and our _next ptr may offset that by 4, - // so no need to allocate extra if less than 4 bytes of alignment requested - int use_align = (align>=4 ? align : 0); - int alloc_sz=sz+use_align; - if (alloc_sz < m_chunksize) - { - // if existing chunk has less free space in it than we would at chunksize, allocate chunksize - if (!m_chunks || m_chunkused > alloc_sz) alloc_sz=m_chunksize; - } - _hdr *nc = (_hdr *)malloc(sizeof(_hdr) + alloc_sz - 16); - if (!nc) return NULL; - - int use_sz=sz; - char *ret = nc->data; - int a = ((int) (INT_PTR)ret) & (align-1); - if (a) - { - use_sz += align-a; - ret += align-a; - } - - if (m_chunks && (m_chunksize-m_chunkused) >= (alloc_sz - use_sz)) - { - // current chunk has as much or more free space than our chunk, put our chunk on the list second - nc->_next = m_chunks->_next; - m_chunks->_next=nc; - } - else - { - // push our chunk to the top of the list - nc->_next = m_chunks; - m_chunks=nc; - m_chunkused = alloc_sz >= m_chunksize ? use_sz : m_chunksize; - } - - return ret; - } - - char *StrDup(const char *s) - { - if (!s) return NULL; - const int l = (int) strlen(s)+1; - char *ret = (char*)Alloc(l); - if (!ret) return NULL; - memcpy(ret,s,l); - return ret; - } - -}; - -#endif diff --git a/oversampling/WDL/circbuf.h b/oversampling/WDL/circbuf.h deleted file mode 100644 index 25f8165..0000000 --- a/oversampling/WDL/circbuf.h +++ /dev/null @@ -1,275 +0,0 @@ -/* - WDL - circbuf.h - Copyright (C) 2005 Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - -*/ - -/* - - This file provides a simple class for a circular FIFO queue of bytes. - -*/ - -#ifndef _WDL_CIRCBUF_H_ -#define _WDL_CIRCBUF_H_ - -#include "heapbuf.h" - -class WDL_CircBuf -{ -public: - WDL_CircBuf() - { - m_inbuf = m_wrptr = 0; - m_buf = NULL; - m_alloc = 0; - } - ~WDL_CircBuf() - { - free(m_buf); - } - void SetSize(int size) - { - if (size<0) size=0; - m_inbuf = m_wrptr = 0; - if (size != m_alloc || !m_buf) - { - m_alloc = size; - free(m_buf); - m_buf = size ? (char*)malloc(size) : NULL; - } - } - - void SetSizePreserveContents(int newsz) - { - if (newsz < NbInBuf()) newsz = NbInBuf(); // do not allow destructive resize down - const int oldsz = m_alloc, dsize = newsz - oldsz; - if (!dsize) return; - if (!m_inbuf||!m_buf) { SetSize(newsz); return; } - - const int div1 = m_inbuf - m_wrptr; // div1>0 is size of end block, div1<0 is offset of start block - char *buf=NULL; - if (dsize > 0) - { - buf = (char *)realloc(m_buf, newsz); - if (WDL_NORMALLY(buf) && div1 > 0) // block crossing loop, need to shuffle some data - { - if (div1 > m_wrptr) // m_wrptr is size of start block, div1 is size of end block - { - // end block is larger than start, move some of start block to end of end block and shuffle forward start - if (dsize >= m_wrptr) - { - if (m_wrptr>0) memmove(buf+oldsz,buf,m_wrptr); - m_wrptr += oldsz; - } - else - { - memmove(buf + oldsz, buf, dsize); - m_wrptr -= dsize; - memmove(buf, buf+dsize, m_wrptr); - } - } - else // end block is smaller, move it to the new end of buffer - { - memmove(buf + newsz - div1, buf + oldsz - div1, div1); - } - } - } - else if (div1 < 0) // shrinking, and not a wrapped buffer - { - if (m_wrptr > newsz) - { - memmove(m_buf,m_buf-div1, m_inbuf); - m_wrptr = m_inbuf; - } - buf = (char *)realloc(m_buf, newsz); - } - - if (!buf) // failed realloc(), or sizing down with block crossing loop boundary - { - buf = (char *)malloc(newsz); - if (WDL_NOT_NORMALLY(!buf)) return; - const int peeked = Peek(buf,0,m_inbuf); - if (peeked != m_inbuf) { WDL_ASSERT(peeked == m_inbuf); } - free(m_buf); - m_wrptr = m_inbuf = peeked; - } - if (m_wrptr > newsz) { WDL_ASSERT(m_wrptr <= newsz); } - if (m_wrptr >= newsz) m_wrptr=0; - m_alloc = newsz; - m_buf = buf; - } - void Reset() { m_inbuf = m_wrptr = 0; } - int Add(const void *buf, int l) - { - if (!m_buf) return 0; - const int bf = m_alloc - m_inbuf; - if (l>bf) l = bf; - if (l > 0) - { - m_wrptr = __write_bytes(m_wrptr,l,buf); - m_inbuf += l; - } - return l; - } - void UnAdd(int amt) - { - if (amt > 0) - { - if (amt > m_inbuf) amt=m_inbuf; - m_wrptr -= amt; - if (m_wrptr < 0) m_wrptr += m_alloc; - m_inbuf -= amt; - } - } - - void Skip(int l) // can be used to rewind read pointer - { - m_inbuf -= l; - if (m_inbuf<0) m_inbuf=0; - else if (m_inbuf>m_alloc) m_inbuf=m_alloc; - } - - int Peek(void *buf, int offs, int len) const - { - if (offs<0||!m_buf) return 0; - const int ibo = m_inbuf-offs; - if (len > ibo) len = ibo; - if (len > 0) - { - int rp = m_wrptr - ibo; - if (rp < 0) rp += m_alloc; - const int wr1 = m_alloc - rp; - char * const rd = m_buf; - if (wr1 < len) - { - memcpy(buf,rd+rp,wr1); - memcpy((char*)buf+wr1,rd,len-wr1); - } - else - { - memcpy(buf,rd+rp,len); - } - } - return len; - } - - void WriteAtReadPointer(const void *buf, int len, int offs=0) - { - if (WDL_NOT_NORMALLY(offs<0) || WDL_NOT_NORMALLY(offs>=m_inbuf)) return; - if (!m_buf || len<1) return; - if (offs+len > m_inbuf) len = m_inbuf-offs; - - int write_offs = m_wrptr - m_inbuf + offs; - if (write_offs < 0) write_offs += m_alloc; - __write_bytes(write_offs, len, buf); - } - - int Get(void *buf, int l) - { - const int amt = Peek(buf,0,l); - m_inbuf -= amt; - return amt; - } - int NbFree() const { return m_alloc - m_inbuf; } // formerly Available() - int NbInBuf() const { return m_inbuf; } - int GetTotalSize() const { return m_alloc; } - -private: - int __write_bytes(int wrptr, int l, const void *buf) // no bounds checking, return end offset - { - const int wr1 = m_alloc-wrptr; - char * const p = m_buf, * const pw = p + wrptr; - if (wr1 < l) - { - if (buf) - { - memcpy(pw, buf, wr1); - memcpy(p, (char*)buf + wr1, l-wr1); - } - else - { - memset(pw, 0, wr1); - memset(p, 0, l-wr1); - } - return l-wr1; - } - - if (buf) memcpy(pw, buf, l); - else memset(pw, 0, l); - return wr1 == l ? 0 : wrptr+l; - } - - char *m_buf; - int m_inbuf, m_wrptr,m_alloc; -} WDL_FIXALIGN; - - -template -class WDL_TypedCircBuf -{ -public: - - WDL_TypedCircBuf() {} - ~WDL_TypedCircBuf() {} - - void SetSize(int size) - { - mBuf.SetSize(size * sizeof(T)); - } - void SetSizePreserveContents(int size) - { - mBuf.SetSizePreserveContents(size*sizeof(T)); - } - - void Reset() - { - mBuf.Reset(); - } - - void UnAdd(int l) { mBuf.UnAdd(l*sizeof(T)); } - - int Add(const T* buf, int l) - { - return mBuf.Add(buf, l * sizeof(T)) / sizeof(T); - } - - int Get(T* buf, int l) - { - return mBuf.Get(buf, l * sizeof(T)) / sizeof(T); - } - - int Peek(T* buf, int offs, int l) - { - return mBuf.Peek(buf, offs*sizeof(T), l * sizeof(T)) / sizeof(T); - } - void Skip(int l) { mBuf.Skip(l*sizeof(T)); } - - void WriteAtReadPointer(const void *buf, int len, int offs=0) { mBuf.WriteAtReadPointer(buf,len*sizeof(T),offs*sizeof(T)); } - - int NbFree() const { return mBuf.NbFree() / sizeof(T); } // formerly Available() - int ItemsInQueue() const { return mBuf.NbInBuf() / sizeof(T); } - int NbInBuf() const { return mBuf.NbInBuf() / sizeof(T); } - int GetTotalSize() const { return mBuf.GetTotalSize() / sizeof(T); } - -private: - WDL_CircBuf mBuf; -} WDL_FIXALIGN; - -#endif diff --git a/oversampling/WDL/cmath/bessel_polynomial.h b/oversampling/WDL/cmath/bessel_polynomial.h deleted file mode 100644 index 030d32b..0000000 --- a/oversampling/WDL/cmath/bessel_polynomial.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - bessel_polynomial.h - Copyright (C) 2011 and later Lubomir I. Ivanov (neolit123 [at] gmail) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* - algorithm to calculate coefficients for a bessel polynomial from krall & fink - series. -*/ - -#ifndef _BESSEL_POLYNOMIAL_H_ -#define _BESSEL_POLYNOMIAL_H_ - -#include "custom_math.h" -#include "factorial.h" - -#ifdef _BESSEL_USE_INLINE_ - #define _BESSEL_INLINE _CMATH_INLINE -#else - #define _BESSEL_INLINE -#endif - -#ifndef _CMATH_ANSI - #define _BESSEL_MAX_ORDER 10 -#else - #define _BESSEL_MAX_ORDER 3 -#endif - -/* return a coefficient */ -_BESSEL_INLINE cmath_std_int_t -bessel_coefficient(const cmath_uint16_t k, const cmath_uint16_t n) -{ - register cmath_std_int_t c; - const cmath_uint16_t nmk = (cmath_uint16_t)(n - k); - c = factorial(2*n - k); - c /= (factorial(nmk)*factorial(k)) * (1 << nmk); - return c; -} - -/* calculate all coefficients for n-th order polynomial */ -_BESSEL_INLINE -void bessel_polynomial( cmath_std_int_t *coeff, - const cmath_uint16_t order, - const cmath_uint16_t reverse ) -{ - register cmath_uint16_t i = (cmath_uint16_t)(order + 1); - if (reverse) - { - while (i--) - coeff[order-i] = bessel_coefficient(i, order); - } - else - { - while (i--) - coeff[i] = bessel_coefficient(i, order); - } -} - -#endif /* _BESSEL_POLYNOMIAL_H */ diff --git a/oversampling/WDL/cmath/complex_number.h b/oversampling/WDL/cmath/complex_number.h deleted file mode 100644 index c5be193..0000000 --- a/oversampling/WDL/cmath/complex_number.h +++ /dev/null @@ -1,368 +0,0 @@ -/* - complex_number.h - Copyright (C) 2011 and later Lubomir I. Ivanov (neolit123 [at] gmail) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* - portable complex number operations -*/ - -#ifndef _COMPLEX_NUMBER_H_ -#define _COMPLEX_NUMBER_H_ - -#include "custom_math.h" - -/* settings */ -#ifndef _CNUM_NO_INLINE - #define _CNUM_INLINE _CMATH_INLINE -#else - #define _CNUM_INLINE -#endif - -#ifndef _CNUM_NO_ALIAS - #define _CNUM_ALIAS _CMATH_MAY_ALIAS -#else - #define _CNUM_ALIAS -#endif - -/* types & constants */ -#ifndef cnum_t - #define cnum_t cmath_t -#endif - -typedef struct -{ - cnum_t r _CMATH_ALIGN(8); - cnum_t i _CMATH_ALIGN(8); -} _CNUM_ALIAS cnum_s; - -const cnum_s cnum_zero = {0, 0}; -const cnum_s cnum_i1 = {0, 1}; -const cnum_s cnum_r1 = {1, 0}; -const cnum_s cnum_r2 = {2, 0}; - -/* methods */ -#define _CNUM(r, i) cnum_new(r, i) -#define _CNUMD(x, r, i) cnum_s x = {r, i} - -_CNUM_INLINE -cnum_s cnum_set(cnum_s *x, const cnum_t r, const cnum_t i) -{ - x->r = r; - x->i = i; - return *x; -} - -_CNUM_INLINE -cnum_s cnum_from(cnum_s *x, const cnum_s y) -{ - x->r = y.r; - x->i = y.i; - return *x; -} - -_CNUM_INLINE -cnum_s cnum_new(const cnum_t r, const cnum_t i) -{ - cnum_s x; - x.r = r; - x.i = i; - return x; -} - -_CNUM_INLINE -cnum_s cnum_cartesian(const cnum_s x) -{ - return cnum_new(x.r * cmath_cos(x.i), x.r * cmath_sin(x.i)); -} - -_CNUM_INLINE -cnum_s cnum_polar(const cnum_s x) -{ - return cnum_new(cmath_cabs(x.r, x.i), cmath_carg(x.r, x.i)); -} - -_CNUM_INLINE -cnum_s cnum_conjugate(const cnum_s x) -{ - return cnum_new(x.r, -x.i); -} - -_CNUM_INLINE -cnum_s cnum_negative(const cnum_s x) -{ - return cnum_new(-x.r, -x.i); -} - -_CNUM_INLINE -cnum_s cnum_swap(const cnum_s x) -{ - return cnum_new(x.i, x.r); -} - -_CNUM_INLINE -cnum_s cnum_add(const cnum_s x, const cnum_s y) -{ - return cnum_new(x.r + y.r, x.i + y.i); -} - -_CNUM_INLINE -cnum_s cnum_add_r(const cnum_s x, const cnum_t y) -{ - return cnum_new(x.r + y, x.i + y); -} - -_CNUM_INLINE -cnum_s cnum_sub(const cnum_s x, const cnum_s y) -{ - return cnum_new(x.r - y.r, x.i - y.i); -} - -_CNUM_INLINE -cnum_s cnum_sub_r(register cnum_s x, const cnum_t y) -{ - return cnum_new(x.r - y, x.i - y); -} - -_CNUM_INLINE -cnum_s cnum_r_sub(const cnum_t x, register cnum_s y) -{ - return cnum_new(x - y.r, x - y.i); -} - -_CNUM_INLINE -cnum_s cnum_mul(const cnum_s x, const cnum_s y) -{ - return cnum_new(x.r*y.r - x.i*y.i, x.r*y.i + x.i*y.r); -} - -_CNUM_INLINE -cnum_s cnum_mul_r(const cnum_s x, const cnum_t y) -{ - return cnum_new(x.r*y, x.i*y); -} - -#define cnum_sqr(x) \ - cnum_mul(x, x) - -_CNUM_INLINE -cnum_s cnum_div_r(const cnum_s x, const cnum_t y) -{ - return cnum_new(x.r/y, x.i/y); -} - -_CNUM_INLINE -cnum_s cnum_r_div(const cnum_t x, const cnum_s y) -{ - return cnum_new(x/y.r, x/y.i); -} - -_CNUM_INLINE -cnum_s cnum_div(const cnum_s x, const cnum_s y) -{ - return cnum_div_r(cnum_mul(x, cnum_conjugate(y)), - (y.r*y.r + cmath_abs(y.i*y.i))); -} - -#define cnum_inv(x) \ - cnum_div(cnum_r1, x) - -#define _CNUM_CHECK_EXP_D_ \ - cmath_abs(deg - cmath_round(deg)) == 0 - -_CNUM_INLINE -cnum_s cnum_exp(const cnum_s x) -{ - cnum_t sin_i = cmath_sin(x.i); - cnum_t cos_i = cmath_cos(x.i); - const cnum_t exp_r = cmath_exp(x.r); - - #ifndef _CNUM_NO_CHECK_EXP_ - register cnum_t deg; - - if (x.r == 0) - return cnum_zero; - deg = x.i / cmath_pi; - if (_CNUM_CHECK_EXP_D_) - sin_i = 0; - deg += 0.5; - if (_CNUM_CHECK_EXP_D_) - cos_i = 0; - deg = x.i / cmath_pi2; - if (_CNUM_CHECK_EXP_D_) - cos_i = 1; - #endif - - return cnum_new(exp_r*cos_i, exp_r*sin_i); -} - -_CNUM_INLINE -cnum_s cnum_log_k(const cnum_s x, const cmath_int32_t k) -{ - return cnum_new(cmath_log(cmath_cabs(x.r, x.i)), - (cmath_carg(x.r, x.i) + (cmath_pi2*k))); -} - -#define cnum_log(x) \ - cnum_log_k(x, 0) - -#define cnum_log_b_k(x, b, k) \ - cnum_div(cnum_log_k(x, k), cnum_log_k(b, k)) - -#define cnum_log_b(b, x) \ - cnum_div(cnum_log(x), cnum_log(b)) - -#define cnum_log2(x) \ - cnum_log_b(x, 2) - -#define cnum_log2_k(x, k) \ - cnum_log_b_k(x, 2, k) - -#define cnum_log10(x) \ - cnum_log_b(x, 2) - -#define cnum_log10_k(x, k) \ - cnum_log_b_k(x, 10, k) - -#define _CNUM_CHECK_POW_C_ \ - if (x.r == 0 && x.i == 0) \ - return cnum_zero; \ - if (y.r == 0 && y.i == 0) \ - return cnum_r1 \ - -_CNUM_INLINE -cnum_s cnum_pow_c_k(const cnum_s x, const cnum_s y, const cmath_int32_t k) -{ - _CNUM_CHECK_POW_C_; - return cnum_exp(cnum_mul(cnum_log_k(x, k), y)); -} - -_CNUM_INLINE -cnum_s cnum_pow_c(const cnum_s x, const cnum_s y) -{ - _CNUM_CHECK_POW_C_; - return cnum_exp(cnum_mul(cnum_log(x), y)); -} - -_CNUM_INLINE -cnum_s cnum_pow(const cnum_s x, const cnum_t n) -{ - const cnum_t r_pow_n = cmath_pow(cmath_cabs(x.r, x.i), n); - const cnum_t theta_n = cmath_carg(x.r, x.i) * n; - if (n == 0) - return cnum_new(1, 0); - if (n == 1) - return x; - return cnum_new(r_pow_n * cmath_cos(theta_n), r_pow_n * cmath_sin(theta_n)); -} - -#define cnum_root_c_k(x, y, k) \ - cnum_exp(cnum_div(cnum_log_k(x, k), y)) - -#define cnum_root_c(x, y) \ - cnum_exp(cnum_div(cnum_log(x), y)) - -#define cnum_root(x, n) \ - cnum_pow(x, 1/n) - -#define cnum_sqrt(x) \ - cnum_pow(x, 0.5) - -#define cnum_sin(x) \ - cnum_new(cmath_sin((x).r)*cmath_cosh((x).i), \ - cmath_cos((x).r)*cmath_sinh((x).i)) - -#define cnum_sinh(x) \ - cnum_new(cmath_sinh(x.r)*cmath_cos(x.i), cmath_cosh(x.r)*sin(x.i)) - -#define cnum_cos(x) \ - cnum_new(cmath_cos(x.r)*cmath_cosh(x.i), -cmath_sin(x.r)*cmath_sinh(x.i)) - -#define cnum_cosh(x) \ - cnum_new(cmath_cosh(x.r)*cmath_cos(x.i), cmath_sinh(x.r)*cmath_sin(x.i)) - -#define cnum_tan(x) \ - cnum_div(cnum_sin(x), cnum_cos(x)) - -#define cnum_tanh(x) \ - cnum_div(cnum_sinh(x), cnum_cosh(x)) - -#define cnum_csc(x) \ - cnum_inv(cnum_sin(x)) - -#define cnum_sec(x) \ - cnum_inv(cnum_cos(x)) - -#define cnum_cotan(x) \ - cnum_inv(cnum_tan(x)) - -#define cnum_asin(x) \ - cnum_negative(cnum_mul(cnum_i1, cnum_log(cnum_add(cnum_mul(cnum_i1, x), \ - cnum_sqrt(cnum_sub(cnum_r1, cnum_sqr(x))))))) - -#define cnum_acos(x) \ - cnum_negative(cnum_mul(cnum_i1, cnum_log(cnum_add(x, cnum_mul(cnum_i1, \ - cnum_sqrt(cnum_sub(cnum_r1, cnum_sqr(x)))))))) - -#define cnum_atan(x) \ - cnum_div(cnum_mul(cnum_i1, cnum_log(cnum_div(cnum_sub(cnum_r1, \ - cnum_mul(cnum_i1, x)), cnum_add(cnum_r1, cnum_mul(cnum_i1, x))))), cnum_r2) - -#define cnum_acsc(x) \ - cnum_asin(cnum_inv(x)) - -#define cnum_asec(x) \ - cnum_acos(cnum_inv(x)) - -#define cnum_acot(x) \ - cnum_atan(cnum_inv(x)) - -#define cnum_csch(x) \ - cnum_inv(cnum_sinh(x)) - -#define cnum_sech(x) \ - cnum_inv(cnum_cosh(x)) - -#define cnum_coth(x) \ - cnum_inv(cnum_tanh(x)) - -#define cnum_asinh(x) \ - cnum_log(cnum_add(x, cnum_sqrt(cnum_add(cnum_r1, cnum_sqr(x))))) - -#define cnum_acosh(x) \ - cnum_log(cnum_add(x, cnum_mul(cnum_sqrt(cnum_add(x, cnum_r1)), \ - cnum_sqrt(cnum_sub(x, cnum_r1))))) - -#define cnum_atanh(x) \ - cnum_div(cnum_sub(cnum_log(cnum_add(cnum_r1, x)), \ - cnum_log(cnum_sub(cnum_r1, x))), cnum_r2) - -#define cnum_acsch(x) \ - cnum_asinh(cnum_inv(x)) - -#define cnum_asech(x) \ - cnum_acosh(cnum_inv(x)) - -#define cnum_asech(x) \ - cnum_acosh(cnum_inv(x)) - -#define cnum_acoth(x) \ - cnum_atanh(cnum_inv(x)) - -#endif /* _COMPLEX_NUMBER_H_ */ diff --git a/oversampling/WDL/cmath/custom_math.h b/oversampling/WDL/cmath/custom_math.h deleted file mode 100644 index a624b3a..0000000 --- a/oversampling/WDL/cmath/custom_math.h +++ /dev/null @@ -1,209 +0,0 @@ -/* - custom_math.h - Copyright (C) 2011 and later Lubomir I. Ivanov (neolit123 [at] gmail) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* - portable definitions for ansi c and cross compiler compatibility. - contains: numeric constants, custom math functions, macros & other. -*/ - -#ifndef _CUSTOM_MATH_H_ -#define _CUSTOM_MATH_H_ - -#include "math.h" - -/* check for "c89" mode */ -#if (defined _MSC_VER && defined __STDC__) || \ - (defined __GNUC__ && defined __STRICT_ANSI__) - #define _CMATH_ANSI -#endif - -/* enable inline */ -#if defined __cplusplus || (!defined _CMATH_ANSI && defined _CMATH_USE_INLINE) - #ifdef _MSC_VER - #define _CMATH_INLINE __inline - #else - #define _CMATH_INLINE inline - #endif -#else - #define _CMATH_INLINE -#endif - -/* align type to size of type */ -#if defined __GNUC__ || defined __TINYC__ - #define _CMATH_ALIGN(x) __attribute__ ((aligned(x))) - #define _CMATH_ALIGN_T(x) __attribute__ ((aligned(sizeof(x)))) -#else - #define _CMATH_ALIGN(x) - #define _CMATH_ALIGN_T(x) -#endif - -/* printf max integer */ -#ifndef _CMATH_ANSI - #ifdef _WIN32 - #define _CMATH_PR_STD_UINT "I64u" - #define _CMATH_PR_STD_INT "I64i" - #define _CMATH_PR_STD_HEX "I64x" - #else - #define _CMATH_PR_STD_UINT "llu" - #define _CMATH_PR_STD_INT "lli" - #define _CMATH_PR_STD_HEX "llx" - #endif -#else - #define _CMATH_PR_STD_UINT "u" - #define _CMATH_PR_STD_INT "d" - #define _CMATH_PR_STD_HEX "x" -#endif - -/* msvc specifics */ -#ifdef _MSC_VER - #pragma warning(disable : 4514) - - #define MK_L(x) (x) - #define MK_UL(x) (x) - #define MK_LL(x) (x) - #define MK_ULL(x) (x) -#else - #define MK_L(x) (x##L) - #define MK_UL(x) (x##UL) - #ifdef _CMATH_ANSI - #define MK_LL(x) (x##L) - #define MK_ULL(x) (x##UL) - #else - #define MK_LL(x) (x##LL) - #define MK_ULL(x) (x##ULL) - #endif -#endif - -/* definitions depending on c standard */ -#ifdef _CMATH_ANSI - #define cmath_std_signbit MK_UL(0x7fffffff) - #define cmath_std_float_t float - #define cmath_std_int_t int -#else - #define cmath_std_signbit MK_ULL(0x7fffffffffffffff) - #define cmath_std_float_t double - #ifdef _MSC_VER - #define cmath_std_int_t __int64 - #else - #define cmath_std_int_t long long - #endif -#endif - -/* types and constants */ -#ifndef cmath_t - #define cmath_t double -#endif - -#define cmath_std_uint_t unsigned cmath_std_int_t - -#define cmath_pi 3.1415926535897932384626433832795 -#define cmath_pi2 6.2831853071795864769252867665590 -#define cmath_pi_2 1.5707963267948966192313216916398 -#define cmath_e 2.7182818284590452353602874713526 -#define cmath_sqrt2 1.4142135623730950488016887242097 -#define cmath_pi_180 0.0174532925199432957692369076848 -#define cmath_180_pi 57.295779513082320876798154814105 - -#define cmath_int8_t char -#define cmath_uint8_t unsigned char -#define cmath_int16_t short -#define cmath_uint16_t unsigned short -#define cmath_int32_t int -#define cmath_uint32_t unsigned int - -/* aliased types */ -#ifdef __GNUC__ - #define _CMATH_MAY_ALIAS __attribute__((__may_alias__)) -#else - #define _CMATH_MAY_ALIAS -#endif - -typedef cmath_t _CMATH_MAY_ALIAS cmath_t_a; - -/* possible approximations */ -#define cmath_sin sin -#define cmath_cos cos -#define cmath_tan tan -#define cmath_asin asin -#define cmath_acos acos -#define cmath_atan atan -#define cmath_atan2 atan2 -#define cmath_sinh sinh -#define cmath_cosh cosh -#define cmath_tanh tanh -#define cmath_exp exp -#define cmath_pow pow -#define cmath_sqrt sqrt -#define cmath_log log -#define cmath_log2 log2 -#define cmath_log10 log10 - -/* methods */ -#define cmath_array_size(x) \ - (sizeof(x) / sizeof(*(x))) - -#define poly_order(x) \ - (sizeof(x) / sizeof(*(x)) - 1) - -#define cmath_cabs(a, b) \ - cmath_sqrt((a)*(a) + (b)*(b)) - -#define cmath_carg(a, b) \ - cmath_atan2((b), (a)) - -#define cmath_radians(x) \ - ((x)*cmath_pi_180) - -#define cmath_degrees(x) \ - ((x)*cmath_180_pi) - -_CMATH_INLINE -cmath_t cmath_powi(const cmath_t x, register cmath_uint16_t n) -{ - register cmath_t result = 1; - while (n--) - result *= x; - return result; -} - -_CMATH_INLINE -cmath_t cmath_abs(const cmath_t x) -{ - register union - { - cmath_std_int_t i; - cmath_std_float_t j; - } u; - u.j = (cmath_std_float_t)x; - u.i &= cmath_std_signbit; - return u.j; -} - -_CMATH_INLINE -cmath_t cmath_round(const cmath_t x) -{ - if (x < 0.0) - return (cmath_t)(cmath_std_int_t)(x - 0.5); - else - return (cmath_t)(cmath_std_int_t)(x + 0.5); -} - -#endif /* _CUSTOM_MATH_H_ */ diff --git a/oversampling/WDL/cmath/durand_kerner.h b/oversampling/WDL/cmath/durand_kerner.h deleted file mode 100644 index 36572fc..0000000 --- a/oversampling/WDL/cmath/durand_kerner.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - durand_kerner.h - Copyright (C) 2011 and later Lubomir I. Ivanov (neolit123 [at] gmail) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* - durand-kerner (weierstrass) algorithm for finding complex roots - of polynomials. - accuracy depends a lot on data type precision. -*/ - -#ifndef _DURAND_KERNER_H_ -#define _DURAND_KERNER_H_ - -#include "horner.h" -#include "custom_math.h" -#include "complex_number.h" - -/* settings */ -#ifdef _DURAND_KERNER_USE_INLINE_ - #define _DURAND_KERNER_INLINE _CMATH_INLINE -#else - #define _DURAND_KERNER_INLINE -#endif - -#define DK_EPSILON 1E-16 -#define DK_MAX_ITR 1E+3 -#define DK_MAX_N 256 - -const cnum_s dk_demoivre_c = {0.4, 0.9}; - -/* accepts an array of complex numbers */ -_DURAND_KERNER_INLINE -void durand_kerner_c -(const cnum_s *coeff, cnum_s *roots, const cmath_uint16_t order) -{ - register cmath_uint16_t i, j; - register cmath_uint32_t itr; - cnum_s coeff_sc[DK_MAX_N]; - cnum_s x; - cnum_s hor; /* needs an address or breaks g++ 4.x */ - - i = 0; - while(i < order) - { - cnum_from(&roots[i], cnum_pow(dk_demoivre_c, i)); - i++; - } - - cnum_from(&coeff_sc[0], cnum_r1); - i = 1; - while(i < order+1) - { - cnum_from(&coeff_sc[i], cnum_div(coeff[i], coeff[0])); - i++; - } - - itr = 0; - while(itr < DK_MAX_ITR) - { - i = 0; - while(i < order) - { - j = 0; - x = cnum_r1; - while (j < order) - { - if (i != j) - x = cnum_mul(cnum_sub(roots[i], roots[j]), x); - j++; - } - hor = horner_eval_c(coeff_sc, roots[i], order); - x = cnum_div(hor, x); - x = cnum_sub(roots[i], x); - if (cmath_abs(cmath_abs(x.r) - cmath_abs(roots[i].r)) < DK_EPSILON && - cmath_abs(cmath_abs(x.i) - cmath_abs(roots[i].i)) < DK_EPSILON) - return; - cnum_from(&roots[i], x); - i++; - } - itr++; - } -} - -/* accepts an array of real numbers */ -_DURAND_KERNER_INLINE -void durand_kerner -(const cmath_t *coeff, cnum_s *roots, const cmath_uint16_t order) -{ - register cmath_uint16_t i; - cnum_s coeff_c[DK_MAX_N]; - i = 0; - while(i < (order+1)) - { - cnum_set(&coeff_c[i], coeff[i], 0); - i++; - } - durand_kerner_c(coeff_c, roots, order); -} - -#endif /* _DURAND_KERNER_H_ */ diff --git a/oversampling/WDL/cmath/factorial.h b/oversampling/WDL/cmath/factorial.h deleted file mode 100644 index f19803d..0000000 --- a/oversampling/WDL/cmath/factorial.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - factorial.h - Copyright (C) 2011 and later Lubomir I. Ivanov (neolit123 [at] gmail) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* - methods to return low-order factorials depending on allowed data types. - - 20! = 2432902008176640000 is the maximum factorial to be held - in a unsigned 64bit integer. - 13! = 479001600 is the maximum factorial to be held in a unsigned - 32bit integer. -*/ - -#ifndef _FACTORIAL_H_ -#define _FACTORIAL_H_ - -#include "custom_math.h" - -#define FACTORIAL_LOWER \ - MK_ULL(1), \ - MK_ULL(1), \ - MK_ULL(2), \ - MK_ULL(6), \ - MK_ULL(24), \ - MK_ULL(120), \ - MK_ULL(720), \ - MK_ULL(5040), \ - MK_ULL(40320), \ - MK_ULL(362880), \ - MK_ULL(3628800), \ - MK_ULL(39916800), \ - MK_ULL(479001600) - -#define FACTORIAL_HIGHER \ - MK_ULL(6227020800), \ - MK_ULL(87178291200), \ - MK_ULL(1307674368000), \ - MK_ULL(20922789888000), \ - MK_ULL(355687428096000), \ - MK_ULL(6402373705728000), \ - MK_ULL(121645100408832000), \ - MK_ULL(2432902008176640000) - -static const cmath_std_uint_t _factorials[] = -{ - #ifdef _CMATH_ANSI - FACTORIAL_LOWER - #else - FACTORIAL_LOWER, - FACTORIAL_HIGHER - #endif -}; - -static const cmath_t _inv_factorials[] = -{ - 1.00000000000000000000000000000000, - 1.00000000000000000000000000000000, - 0.50000000000000000000000000000000, - 0.16666666666666666666666666666667, - 0.04166666666666666666666666666666, - 0.00833333333333333333333333333333, - 0.00138888888888888888888888888888, - 0.00019841269841269841269841269841, - 0.00002480158730158730158730158730, - 0.00000275573192239858906525573192, - 0.00000027557319223985890652557319, - 0.00000002505210838544171877505210, - 0.00000000208767569878680989792100, - 0.00000000016059043836821614599390, - 0.00000000001147074559772972471385, - 0.00000000000076471637318198164750, - 0.00000000000004779477332387385297, - 0.00000000000000281145725434552076, - 0.00000000000000015619206968586225, - 0.00000000000000000822063524662433, - 0.00000000000000000041103176233122 -}; - -_CMATH_INLINE -cmath_std_uint_t factorial(const cmath_uint32_t x) -{ - if(x >= cmath_array_size(_factorials)) - return 0; - else - return _factorials[x]; -} - -_CMATH_INLINE -cmath_t inv_factorial(const cmath_uint32_t x) -{ - if(x >= cmath_array_size(_inv_factorials)) - return 0; - else - return _inv_factorials[x]; -} - -#endif /* _FACTORIAL_H_ */ diff --git a/oversampling/WDL/cmath/horner.h b/oversampling/WDL/cmath/horner.h deleted file mode 100644 index d943457..0000000 --- a/oversampling/WDL/cmath/horner.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - horner.h - Copyright (C) 2011 and later Lubomir I. Ivanov (neolit123 [at] gmail) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* - algorithm to evaluate integer order polynomials using horner's scheme. -*/ - -#ifndef _HORNER_H_ -#define _HORNER_H_ - -#include "custom_math.h" -#include "complex_number.h" - -/* settings */ -#ifndef _HORNER_INLINE - #define _HORNER_INLINE _CMATH_INLINE -#else - #define _HORNER_INLINE -#endif - -/* real */ -_HORNER_INLINE -cmath_t horner_eval -(const cmath_t *coeff, const cmath_t x, cmath_uint16_t order) -{ - register cmath_t y = coeff[0]; - register cmath_uint16_t n = 1; - order += 1; - while(n < order) - { - y = y*x + coeff[n]; - n++; - } - return y; -} - -/* complex */ -_HORNER_INLINE -cnum_s horner_eval_c -(const cnum_s *coeff, const cnum_s x, cmath_uint16_t order) -{ - register cmath_uint16_t n = 1; - cnum_s y = coeff[0]; - order += 1; - while(n < order) - { - y = cnum_add(cnum_mul(y, x), coeff[n]); - n++; - } - return y; -} - -#endif /* _HORNER_H_ */ diff --git a/oversampling/WDL/cmath/test_bessel.c b/oversampling/WDL/cmath/test_bessel.c deleted file mode 100644 index 83915a6..0000000 --- a/oversampling/WDL/cmath/test_bessel.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - test_bessel.h - Copyright (C) 2011 and later Lubomir I. Ivanov (neolit123 [at] gmail) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* - test bessel_polynomial.h and other related headers - - gcc -W -Wall -Wextra -ansi pedantic - cl /W4 /Za - - reduced precisions for ansi c -*/ - -#include "stdio.h" -#include "custom_math.h" -#include "bessel_polynomial.h" -#include "durand_kerner.h" - -int main(void) -{ - register cmath_uint16_t i = 0; - register cmath_int16_t diff = 0; - - cmath_uint32_t in_order = _BESSEL_MAX_ORDER + 1; - cmath_uint16_t order; - const cmath_uint16_t reverse = 1; - - cmath_std_int_t coeff[_BESSEL_MAX_ORDER + 1]; - - cnum_t dk_coeff[_BESSEL_MAX_ORDER + 1]; - cnum_s dk_roots[_BESSEL_MAX_ORDER]; - - /* */ - #ifdef _CMATH_ANSI - puts("\n\nansi c is: on"); - #else - puts("\n\nansi c is: off"); - #endif - - /* */ - while (in_order > _BESSEL_MAX_ORDER) - { - printf("\nenter order of bessel polynomial (0 - %d): ", _BESSEL_MAX_ORDER); - scanf("%u", &in_order); - } - - order = (cmath_uint16_t)in_order; - bessel_polynomial(coeff, order, reverse); - - printf("\norder [N]: %d", order); - printf("\nreversed bessel: %d\n\n", reverse); - printf("list of coefficients:\n"); - while (i <= order) - { - printf("order[%2d]: ", (order - i)); - printf("%"_CMATH_PR_STD_INT"\n", coeff[i]); - i++; - } - puts("\npolynomial:"); - printf("y(x) = "); - - i = 0; - while (i <= order) - { - diff = (cmath_int16_t)(order - i); - if (diff > 0) - if (coeff[i] > 1) - { - printf("%"_CMATH_PR_STD_INT, coeff[i]); - if (diff > 1) - printf("*x^%d + ", diff); - else - printf("*x + "); - } - else - printf("x^%d + ", diff); - else - printf("%"_CMATH_PR_STD_INT"", coeff[i]); - i++; - } - - /* */ - puts("\n\nlist roots:"); - i = 0; - while (i < order+1) - { - dk_coeff[i] = (cnum_t)coeff[i]; - i++; - } - - durand_kerner(dk_coeff, dk_roots, order); - - i = 0; - while (i < order) - { - printf("root[%2d]: %.15f \t % .15f*i\n", - i+1, (double)dk_roots[i].r, (double)dk_roots[i].i); - i++; - } - - return 0; -} diff --git a/oversampling/WDL/cmath/test_eval.c b/oversampling/WDL/cmath/test_eval.c deleted file mode 100644 index fabf9ff..0000000 --- a/oversampling/WDL/cmath/test_eval.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - test_eval.h - Copyright (C) 2011 and later Lubomir I. Ivanov (neolit123 [at] gmail) - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* - test horner.h for complex numbers and other related headers - - gcc -W -Wall -Wextra -ansi pedantic - cl /W4 /Za - - reduced precisions for ansi c -*/ - -#include "stdio.h" -#include "complex_number.h" -#include "horner.h" -#include "durand_kerner.h" - -int main(void) -{ - cmath_uint16_t i = 0; - - cnum_t y[] = {2, -6, 2, -1}; - cnum_s cy[] = {{2, 0}, {-6, 0}, {2, 0}, {-1, 0}}; - - cnum_t fx = horner_eval(y, 5, poly_order(y)); - cnum_s fcx = horner_eval_c(cy, _CNUM(5, 0), poly_order(y)); - - cnum_t dk_coeff[] = {12, -7, 0.001, 0, 3, -5}; - cnum_s dk_roots[5]; - - cnum_s dk_coeff_c[] = {{12, 0}, {-7, 0}, {0.001, 0}, {0, 0}, {3, 0}, {-5, 0}}; - cnum_s dk_roots_c[5]; - - durand_kerner(dk_coeff, dk_roots, poly_order(dk_coeff)); - durand_kerner_c(dk_coeff_c, dk_roots_c, poly_order(dk_coeff_c)); - - /* */ - #ifdef _CMATH_ANSI - puts("\n\nansi c is: on"); - #else - puts("\n\nansi c is: off"); - #endif - - /* */ - puts("\n\nevaluate polynomials:\n"); - printf("* y[]: %.15f\n", (double)fx); - printf("* cy[]: %.15f \t %.15f*i\n", (double)fcx.r, (double)fcx.i); - - /* */ - puts("\nfind roots:"); - puts("\n* dk_coeff[]:"); - i = 0; - while (i < poly_order(dk_coeff)) - { - printf("root[%2d]: %.15f \t % .15f*i\n", - i+1, (double)dk_roots[i].r, (double)dk_roots[i].i); - i++; - } - i = 0; - puts("\n* dk_coeff_c[]:"); - while (i < poly_order(dk_coeff_c)) - { - printf("root[%2d]: %.15f \t % .15f*i\n", - i+1, (double)dk_roots_c[i].r, (double)dk_roots_c[i].i); - i++; - } - - return 0; -} diff --git a/oversampling/WDL/convoengine.cpp b/oversampling/WDL/convoengine.cpp deleted file mode 100644 index cbab7f6..0000000 --- a/oversampling/WDL/convoengine.cpp +++ /dev/null @@ -1,1065 +0,0 @@ -/* - WDL - convoengine.cpp - Copyright (C) 2006 and later Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - -*/ - -#ifdef _WIN32 -#include -#endif -#include -#include -#include -#include -#include "convoengine.h" - -#include "denormal.h" - -//#define TIMING -#include "timing.c" - -#define CONVOENGINE_SILENCE_THRESH 1.0e-12 // -240dB -#define CONVOENGINE_IMPULSE_SILENCE_THRESH 1.0e-15 // -300dB - -static void WDL_CONVO_CplxMul2(WDL_FFT_COMPLEX *c, WDL_FFT_COMPLEX *a, WDL_CONVO_IMPULSEBUFCPLXf *b, int n) -{ - WDL_FFT_REAL t1, t2, t3, t4, t5, t6, t7, t8; - if (n<2 || (n&1)) return; - - do { - t1 = a[0].re * b[0].re; - t2 = a[0].im * b[0].im; - t3 = a[0].im * b[0].re; - t4 = a[0].re * b[0].im; - t5 = a[1].re * b[1].re; - t6 = a[1].im * b[1].im; - t7 = a[1].im * b[1].re; - t8 = a[1].re * b[1].im; - t1 -= t2; - t3 += t4; - t5 -= t6; - t7 += t8; - c[0].re = t1; - c[1].re = t5; - c[0].im = t3; - c[1].im = t7; - a += 2; - b += 2; - c += 2; - } while (n -= 2); -} -static void WDL_CONVO_CplxMul3(WDL_FFT_COMPLEX *c, WDL_FFT_COMPLEX *a, WDL_CONVO_IMPULSEBUFCPLXf *b, int n) -{ - WDL_FFT_REAL t1, t2, t3, t4, t5, t6, t7, t8; - if (n<2 || (n&1)) return; - - do { - t1 = a[0].re * b[0].re; - t2 = a[0].im * b[0].im; - t3 = a[0].im * b[0].re; - t4 = a[0].re * b[0].im; - t5 = a[1].re * b[1].re; - t6 = a[1].im * b[1].im; - t7 = a[1].im * b[1].re; - t8 = a[1].re * b[1].im; - t1 -= t2; - t3 += t4; - t5 -= t6; - t7 += t8; - c[0].re += t1; - c[1].re += t5; - c[0].im += t3; - c[1].im += t7; - a += 2; - b += 2; - c += 2; - } while (n -= 2); -} - -static bool CompareQueueToBuf(WDL_FastQueue *q, const void *data, int len) -{ - int offs=0; - while (len>0) - { - void *td=NULL; - int sz=q->GetPtr(offs,&td); - if (sz<1) return true; // not enough data = not equal! - if (sz>len) sz=len; - - int i=sz/sizeof(WDL_FFT_REAL); - WDL_FFT_REAL *a1=(WDL_FFT_REAL*)td; - WDL_FFT_REAL *b1=(WDL_FFT_REAL*)data; - while (i--) - { - if (fabs(*a1-*b1)>CONVOENGINE_SILENCE_THRESH) return true; - a1++; - b1++; - } - - data = ((char *)data)+sz; - offs+=sz; - len-=sz; - } - return false; -} - - -WDL_ConvolutionEngine::WDL_ConvolutionEngine() -{ - WDL_fft_init(); - m_fft_size=0; - m_impdata.Add(new ImpChannelInfo); - m_impulse_len=0; - m_proc_nch=0; -} - -WDL_ConvolutionEngine::~WDL_ConvolutionEngine() -{ - m_impdata.Empty(true); - m_proc.Empty(true); -} - -int WDL_ConvolutionEngine::SetImpulse(WDL_ImpulseBuffer *impulse, int fft_size, int impulse_sample_offset, int max_imp_size, bool forceBrute) -{ - int impulse_len=0; - int x; - int nch=impulse->GetNumChannels(); - for (x = 0; x < nch; x ++) - { - int l=impulse->impulses[x].GetSize()-impulse_sample_offset; - if (max_imp_size && l>max_imp_size) l=max_imp_size; - if (impulse_len < l) impulse_len=l; - } - - if (nch>1) // detect mono signals pretending to be multichannel - { - for (x = 1; x < nch; x ++) - { - if (impulse->impulses[x].GetSize()!=impulse->impulses[0].GetSize()|| - memcmp(impulse->impulses[x].Get(),impulse->impulses[0].Get(), - impulse->impulses[0].GetSize()*sizeof(WDL_FFT_REAL))) - break; - } - if (x >= nch) nch=1; - } - - m_impulse_len=impulse_len; - m_proc_nch=-1; - - while (m_impdata.GetSize() > nch) - m_impdata.Delete(m_impdata.GetSize()-1,true); - while (m_impdata.GetSize() < nch) - m_impdata.Add(new ImpChannelInfo); - - if (forceBrute) - { - m_fft_size=0; - - // save impulse - for (x = 0; x < m_impdata.GetSize(); x ++) - { - WDL_FFT_REAL *imp=impulse->impulses[x].Get()+impulse_sample_offset; - int lenout=impulse->impulses[x].GetSize()-impulse_sample_offset; - if (max_imp_size && lenout>max_imp_size) lenout=max_imp_size; - - WDL_CONVO_IMPULSEBUFf *impout=m_impdata.Get(x)->imp.Resize(lenout)+lenout; - while (lenout-->0) *--impout = (WDL_CONVO_IMPULSEBUFf) *imp++; - } - - for (x = 0; x < m_proc.GetSize(); x ++) - { - ProcChannelInfo *inf = m_proc.Get(x); - inf->samplesin.Clear(); - inf->samplesin2.Clear(); - inf->samplesout.Clear(); - } - - return 0; - } - - - if (fft_size<=0) - { - int msz=fft_size<=-16? -fft_size*2 : 32768; - - fft_size=32; - while (fft_size < impulse_len*2 && fft_size < msz) fft_size*=2; - } - - m_fft_size=fft_size; - - int impchunksize=fft_size/2; - int nblocks=(impulse_len+impchunksize-1)/impchunksize; - //wdl_log("il=%d, ffts=%d, cs=%d, nb=%d\n",impulse_len,fft_size,impchunksize,nblocks); - - const bool smallerSizeMode=sizeof(WDL_CONVO_IMPULSEBUFf)!=sizeof(WDL_FFT_REAL); - - WDL_FFT_REAL scale=(WDL_FFT_REAL) (1.0/fft_size); - for (x = 0; x < m_impdata.GetSize(); x ++) - { - WDL_FFT_REAL *imp=impulse->impulses[x].Get()+impulse_sample_offset; - - WDL_FFT_REAL *imp2=x < m_impdata.GetSize()-1 ? impulse->impulses[x+1].Get()+impulse_sample_offset : NULL; - - WDL_CONVO_IMPULSEBUFf *impout=m_impdata.Get(x)->imp.Resize((nblocks+!!smallerSizeMode)*fft_size*2); - char *zbuf=m_impdata.Get(x)->zflag.Resize(nblocks); - int lenout=impulse->impulses[x].GetSize()-impulse_sample_offset; - if (max_imp_size && lenout>max_imp_size) lenout=max_imp_size; - - int bl; - for (bl = 0; bl < nblocks; bl ++) - { - - int thissz=lenout; - if (thissz > impchunksize) thissz=impchunksize; - - lenout -= thissz; - int i=0; - WDL_FFT_REAL mv=0.0; - WDL_FFT_REAL mv2=0.0; - WDL_FFT_REAL *imptmp = (WDL_FFT_REAL *)impout; //-V615 - - for (; i < thissz; i ++) - { - WDL_FFT_REAL v=*imp++; - WDL_FFT_REAL v2=(WDL_FFT_REAL)fabs(v); - if (v2 > mv) mv=v2; - - imptmp[i*2]=denormal_filter_aggressive(v * scale); - - if (imp2) - { - v=*imp2++; - v2=(WDL_FFT_REAL)fabs(v); - if (v2>mv2) mv2=v2; - imptmp[i*2+1]=denormal_filter_aggressive(v*scale); - } - else imptmp[i*2+1]=0.0; - } - for (; i < fft_size; i ++) - { - imptmp[i*2]=0.0; - imptmp[i*2+1]=0.0; - } - if (mv>CONVOENGINE_IMPULSE_SILENCE_THRESH||mv2>CONVOENGINE_IMPULSE_SILENCE_THRESH) - { - *zbuf++=mv>CONVOENGINE_IMPULSE_SILENCE_THRESH ? 2 : 1; // 1 means only second channel has content - WDL_fft((WDL_FFT_COMPLEX*)impout,fft_size,0); - - if (smallerSizeMode) - { - int x,n=fft_size*2; - for(x=0;xsamplesin.Clear(); - inf->samplesin2.Clear(); - inf->samplesout.Clear(); - inf->hist_pos = 0; - memset(inf->samplehist_zflag.Get(),0,inf->samplehist_zflag.GetSize()); - memset(inf->samplehist.Get(),0,inf->samplehist.GetSize()*sizeof(WDL_FFT_REAL)); - memset(inf->overlaphist.Get(),0,inf->overlaphist.GetSize()*sizeof(WDL_FFT_REAL)); - } -} - -void WDL_ConvolutionEngine::Add(WDL_FFT_REAL **bufs, int len, int nch) -{ - while (m_proc.GetSize() < nch) m_proc.Add(new ProcChannelInfo); - while (m_proc.GetSize() > nch) m_proc.Delete(m_proc.GetSize()-1,true); - - if (m_fft_size<1) - { - m_proc_nch=nch; - - for (int ch = 0; ch < nch; ch ++) - { - int wch = ch % m_impdata.GetSize(); - WDL_CONVO_IMPULSEBUFf *imp=m_impdata.Get(wch)->imp.Get(); - int imp_len = m_impdata.Get(wch)->imp.GetSize(); - ProcChannelInfo *pinf = m_proc.Get(ch); - - if (imp_len>0) - { - if (pinf->samplesin2.Available()samplesin2.Available(); - memset(pinf->samplesin2.Add(NULL,sza),0,sza); - } - WDL_FFT_REAL *psrc; - - if (bufs && bufs[ch]) - psrc=(WDL_FFT_REAL*)pinf->samplesin2.Add(bufs[ch],len*sizeof(WDL_FFT_REAL)); - else - { - psrc=(WDL_FFT_REAL*)pinf->samplesin2.Add(NULL,len*sizeof(WDL_FFT_REAL)); - memset(psrc,0,len*sizeof(WDL_FFT_REAL)); - } - - WDL_FFT_REAL *pout=(WDL_FFT_REAL*)pinf->samplesout.Add(NULL,len*sizeof(WDL_FFT_REAL)); - int x; - int len1 = len&~1; - for (x=0; x < len1 ; x += 2) - { - int i=imp_len; - double sum=0.0,sum2=0.0; - WDL_FFT_REAL *sp=psrc+x-imp_len + 1; - WDL_CONVO_IMPULSEBUFf *ip=imp; - int j=i/4; i&=3; - while (j--) // produce 2 samples, 4 impulse samples at a time - { - double a = ip[0],b=ip[1],aa=ip[2],bb=ip[3]; - double c = sp[1],d=sp[2],cc=sp[3]; - sum+=a * sp[0] + b * c + aa * d + bb * cc; - sum2+=a * c + b * d + aa * cc + bb * sp[4]; - ip+=4; - sp+=4; - } - - while (i--) - { - double a = *ip++; - sum+=a * sp[0]; - sum2+=a * sp[1]; - sp++; - } - pout[x]=(WDL_FFT_REAL) sum; - pout[x+1]=(WDL_FFT_REAL) sum2; - } - for(;xsamplesin2.Advance(len*sizeof(WDL_FFT_REAL)); - pinf->samplesin2.Compact(); - } - else - { - if (bufs && bufs[ch]) pinf->samplesout.Add(bufs[ch],len*sizeof(WDL_FFT_REAL)); - else - { - memset(pinf->samplesout.Add(NULL,len*sizeof(WDL_FFT_REAL)),0,len*sizeof(WDL_FFT_REAL)); - } - } - - } - return; - } - - - int impchunksize=m_fft_size/2; - int nblocks=(m_impulse_len+impchunksize-1)/impchunksize; - - if (m_proc_nch != nch) - { - m_proc_nch=nch; - - int mso=0; - for (int ch = 0; ch < nch; ch ++) - { - ProcChannelInfo *pinf = m_proc.Get(ch); - pinf->hist_pos = 0; - int so=pinf->samplesin.Available() + pinf->samplesout.Available(); - if (so>mso) mso=so; - - if (m_impulse_len<1||!nblocks) - { - if (pinf->samplesin.Available()) - { - int s=pinf->samplesin.Available(); - void *buf=pinf->samplesout.Add(NULL,s); - pinf->samplesin.GetToBuf(0,buf,s); - pinf->samplesin.Clear(); - } - } - - if (so < mso) - { - memset(pinf->samplesout.Add(NULL,mso-so),0,mso-so); - } - - const int sz=nblocks*m_fft_size; - - memset(pinf->samplehist_zflag.Resize(nblocks),0,nblocks); - pinf->samplehist.Resize(sz*2); - pinf->overlaphist.Resize(m_fft_size/2); - memset(pinf->samplehist.Get(),0,pinf->samplehist.GetSize()*sizeof(WDL_FFT_REAL)); - memset(pinf->overlaphist.Get(),0,pinf->overlaphist.GetSize()*sizeof(WDL_FFT_REAL)); - } - } - - if (m_impulse_len<1||!nblocks) - { - for (int ch = 0; ch < nch; ch ++) - { - ProcChannelInfo *pinf = m_proc.Get(ch); - if (bufs && bufs[ch]) - pinf->samplesout.Add(bufs[ch],len*sizeof(WDL_FFT_REAL)); - else - memset(pinf->samplesout.Add(NULL,len*sizeof(WDL_FFT_REAL)),0,len*sizeof(WDL_FFT_REAL)); - } - // pass through - return; - } - - for (int ch = 0; ch < nch; ch ++) - { - ProcChannelInfo *pinf = m_proc.Get(ch); - if (!pinf->samplehist.GetSize()||!pinf->overlaphist.GetSize()) continue; - pinf->samplesin.Add(bufs ? bufs[ch] : NULL,len*sizeof(WDL_FFT_REAL)); - } -} - -void WDL_ConvolutionEngine::AddSilenceToOutput(int len) -{ - for (int ch = 0; ch < m_proc_nch; ch++) - { - ProcChannelInfo *pinf = m_proc.Get(ch); - memset(pinf->samplesout.Add(NULL,len*sizeof(WDL_FFT_REAL)),0,len*sizeof(WDL_FFT_REAL)); - } -} - -int WDL_ConvolutionEngine::Avail(int want) -{ - if (m_fft_size<1) - { - ProcChannelInfo *pinf = m_proc.Get(0); - return pinf ? pinf->samplesout.Available()/sizeof(WDL_FFT_REAL) : 0; - } - - const int sz=m_fft_size/2; - const int chunksize=m_fft_size/2; - const int nblocks=(m_impulse_len+chunksize-1)/chunksize; - // clear combining buffer - WDL_FFT_REAL *workbuf2 = m_combinebuf.Resize(m_fft_size*4); // temp space - - int ch; - - for (ch = 0; ch < m_proc_nch; ch ++) - { - ProcChannelInfo *pinf = m_proc.Get(ch); - ProcChannelInfo *pinf2 = ch+1 < m_proc_nch ? m_proc.Get(ch+1) : NULL; - - if (!pinf->samplehist.GetSize()||!pinf->overlaphist.GetSize()) continue; - int srcc=ch % m_impdata.GetSize(); - - bool allow_mono_input_mode=true; - bool mono_impulse_mode=false; - - if (m_impdata.GetSize()==1 && pinf2 && - pinf2->samplehist.GetSize()&&pinf2->overlaphist.GetSize() && - pinf->samplesin.Available()==pinf2->samplesin.Available() && - pinf->samplesout.Available()==pinf2->samplesout.Available() - ) - { // 2x processing mode - mono_impulse_mode=true; - allow_mono_input_mode=false; - } - - - const int in_needed=sz; - - // useSilentList[x] = 1 for mono signal, 2 for stereo, 0 for silent - char *useSilentList=pinf->samplehist_zflag.GetSize()==nblocks ? pinf->samplehist_zflag.Get() : NULL; - while (pinf->samplesin.Available()/(int)sizeof(WDL_FFT_REAL) >= sz && - pinf->samplesout.Available() < want*(int)sizeof(WDL_FFT_REAL)) - { - int histpos; - if ((histpos=++pinf->hist_pos) >= nblocks) histpos=pinf->hist_pos=0; - - // get samples from input, to history - WDL_FFT_REAL *optr = pinf->samplehist.Get()+histpos*m_fft_size*2; - - pinf->samplesin.GetToBuf(0,optr+sz,in_needed*sizeof(WDL_FFT_REAL)); - pinf->samplesin.Advance(in_needed*sizeof(WDL_FFT_REAL)); - - - bool mono_input_mode=false; - - bool nonzflag=false; - if (mono_impulse_mode) - { - if (++pinf2->hist_pos >= nblocks) pinf2->hist_pos=0; - pinf2->samplesin.GetToBuf(0,workbuf2,sz*sizeof(WDL_FFT_REAL)); - pinf2->samplesin.Advance(sz*sizeof(WDL_FFT_REAL)); - int i; - for (i = 0; i < sz; i ++) // unpack samples - { - WDL_FFT_REAL f = optr[i*2]=denormal_filter_aggressive(optr[sz+i]); - if (!nonzflag && (f<-CONVOENGINE_SILENCE_THRESH || f>CONVOENGINE_SILENCE_THRESH)) nonzflag=true; - f=optr[i*2+1]=denormal_filter_aggressive(workbuf2[i]); - if (!nonzflag && (f<-CONVOENGINE_SILENCE_THRESH || f>CONVOENGINE_SILENCE_THRESH)) nonzflag=true; - } - } - else - { - if (allow_mono_input_mode && - pinf2 && - srccsamplesin,optr+sz,sz*sizeof(WDL_FFT_REAL)) - ) - { - mono_input_mode=true; - } - else - { - allow_mono_input_mode=false; - } - - int i; - for (i = 0; i < sz; i ++) // unpack samples - { - WDL_FFT_REAL f=optr[i*2]=denormal_filter_aggressive(optr[sz+i]); - optr[i*2+1]=0.0; - if (!nonzflag && (f<-CONVOENGINE_SILENCE_THRESH || f>CONVOENGINE_SILENCE_THRESH)) nonzflag=true; - } - } - - int i; - for (i = 1; mono_input_mode && i < nblocks; i ++) // start @ 1, since hist[histpos] is no longer used for here - { - int srchistpos = histpos-i; - if (srchistpos < 0) srchistpos += nblocks; - if (!useSilentList || useSilentList[srchistpos]==2) mono_input_mode=false; - } - - if (nonzflag||!useSilentList) memset(optr+sz*2,0,sz*2*sizeof(WDL_FFT_REAL)); - - -#ifdef WDLCONVO_ZL_ACCOUNTING - m_zl_fftcnt++; -#endif - - if (nonzflag) WDL_fft((WDL_FFT_COMPLEX*)optr,m_fft_size,0); - - if (useSilentList) useSilentList[histpos]=nonzflag ? (mono_input_mode ? 1 : 2) : 0; - - int mzfl=2; - if (mono_input_mode) - { - mzfl=1; - - pinf2->samplesin.Advance(sz*sizeof(WDL_FFT_REAL)); - - // save a valid copy in sample hist incase we switch from mono to stereo - if (++pinf2->hist_pos >= nblocks) pinf2->hist_pos=0; - if (pinf2->samplehist_zflag.GetSize()==nblocks) - pinf2->samplehist_zflag.Get()[pinf2->hist_pos] = nonzflag ? 1 : 0; - - WDL_FFT_REAL *optr2 = pinf2->samplehist.Get()+pinf2->hist_pos*m_fft_size*2; - memcpy(optr2,optr,m_fft_size*2*sizeof(WDL_FFT_REAL)); - } - - int applycnt=0; - char *useImpSilentList=m_impdata.Get(srcc)->zflag.GetSize() == nblocks ? m_impdata.Get(srcc)->zflag.Get() : NULL; - - WDL_CONVO_IMPULSEBUFf *impulseptr=m_impdata.Get(srcc)->imp.Get(); - for (i = 0; i < nblocks; i ++, impulseptr+=m_fft_size*2) - { - int srchistpos = histpos-i; - if (srchistpos < 0) srchistpos += nblocks; - - if (useImpSilentList && useImpSilentList[i]samplehist.Get() + m_fft_size*srchistpos*2; - - if (applycnt++) // add to output - WDL_CONVO_CplxMul3((WDL_FFT_COMPLEX*)workbuf2,(WDL_FFT_COMPLEX*)samplehist,(WDL_CONVO_IMPULSEBUFCPLXf*)impulseptr,m_fft_size); - else // replace output - WDL_CONVO_CplxMul2((WDL_FFT_COMPLEX*)workbuf2,(WDL_FFT_COMPLEX*)samplehist,(WDL_CONVO_IMPULSEBUFCPLXf*)impulseptr,m_fft_size); - - } - if (!applycnt) - memset(workbuf2,0,m_fft_size*2*sizeof(WDL_FFT_REAL)); - else - WDL_fft((WDL_FFT_COMPLEX*)workbuf2,m_fft_size,1); - - WDL_FFT_REAL *olhist=pinf->overlaphist.Get(); // errors from last time - WDL_FFT_REAL *p1=workbuf2,*p3=workbuf2+m_fft_size,*p1o=workbuf2; - - if (mono_impulse_mode||mono_input_mode) - { - WDL_FFT_REAL *p2o=workbuf2+m_fft_size*2; - WDL_FFT_REAL *olhist2=pinf2->overlaphist.Get(); // errors from last time - int s=sz/2; - while (s--) - { - p2o[0] = p1[1]+olhist2[0]; - p2o[1] = p1[3]+olhist2[1]; - p1o[0] = p1[0]+olhist[0]; - p1o[1] = p1[2]+olhist[1]; - p1o+=2; - p2o+=2; - p1+=4; - - olhist[0]=p3[0]; - olhist[1]=p3[2]; - olhist2[0]=p3[1]; - olhist2[1]=p3[3]; - p3+=4; - - olhist+=2; - olhist2+=2; - } - // add samples to output - pinf->samplesout.Add(workbuf2,sz*sizeof(WDL_FFT_REAL)); - pinf2->samplesout.Add(workbuf2+m_fft_size*2,sz*sizeof(WDL_FFT_REAL)); - } - else - { - int s=sz/2; - while (s--) - { - p1o[0] = p1[0]+olhist[0]; - p1o[1] = p1[2]+olhist[1]; - p1o+=2; - p1+=4; - - olhist[0]=p3[0]; - olhist[1]=p3[2]; - p3+=4; - - olhist+=2; - } - // add samples to output - pinf->samplesout.Add(workbuf2,sz*sizeof(WDL_FFT_REAL)); - } - } // while available - - if (mono_impulse_mode) ch++; - } - - int mv = want; - for (ch=0;chsamplesout.Available()/sizeof(WDL_FFT_REAL) : 0; - if (!ch || vsamplesout.Get(); - return ret; -} - -void WDL_ConvolutionEngine::Advance(int len) -{ - for (int ch = 0; ch < m_proc_nch; ch ++) - { - ProcChannelInfo *pinf = m_proc.Get(ch); - pinf->samplesout.Advance(len*sizeof(WDL_FFT_REAL)); - pinf->samplesout.Compact(); - } -} - - - -/**************************************************************** -** low latency version -*/ - -WDL_ConvolutionEngine_Div::WDL_ConvolutionEngine_Div() -{ - timingInit(); - for (int x = 0; x < 2; x ++) m_sout.Add(new WDL_Queue); - m_need_feedsilence=true; -} - -int WDL_ConvolutionEngine_Div::SetImpulse(WDL_ImpulseBuffer *impulse, int maxfft_size, int known_blocksize, int max_imp_size, int impulse_offset, int latency_allowed) -{ - m_need_feedsilence=true; - - m_engines.Empty(true); - if (maxfft_size<0)maxfft_size=-maxfft_size; - maxfft_size*=2; - if (!maxfft_size || maxfft_size>32768) maxfft_size=32768; - - - const int MAX_SIZE_FOR_BRUTE=64; - - int fftsize = MAX_SIZE_FOR_BRUTE; - int impulsechunksize = MAX_SIZE_FOR_BRUTE; - - if (known_blocksize && !(known_blocksize&(known_blocksize-1)) && known_blocksize>MAX_SIZE_FOR_BRUTE*2) - { - fftsize=known_blocksize/2; - impulsechunksize=known_blocksize/2; - } - if (latency_allowed*2 > fftsize) - { - int x = 16; - while (x <= latency_allowed) x*=2; - if (x>32768) x=32768; - fftsize=impulsechunksize=x; - } - - int offs=0; - int samplesleft=impulse->impulses[0].GetSize()-impulse_offset; - if (max_imp_size>0 && samplesleft>max_imp_size) samplesleft=max_imp_size; - - do - { - WDL_ConvolutionEngine *eng=new WDL_ConvolutionEngine; - - bool wantBrute = !latency_allowed && !offs; - if (impulsechunksize*(wantBrute ? 2 : 3) >= samplesleft) impulsechunksize=samplesleft; // early-out, no point going to a larger FFT (since if we did this, we wouldnt have enough samples for a complete next pass) - if (fftsize>=maxfft_size) { impulsechunksize=samplesleft; fftsize=maxfft_size; } // if FFTs are as large as possible, finish up - - eng->SetImpulse(impulse,fftsize,offs+impulse_offset,impulsechunksize, wantBrute); - eng->m_zl_delaypos = offs; - eng->m_zl_dumpage=0; - m_engines.Add(eng); - -#ifdef WDLCONVO_ZL_ACCOUNTING - wdl_log("ce%d: offs=%d, len=%d, fftsize=%d\n",m_engines.GetSize(),offs,impulsechunksize,fftsize); -#endif - - samplesleft -= impulsechunksize; - offs+=impulsechunksize; - -#if 1 // this seems about 10% faster (maybe due to better cache use from less sized ffts used?) - impulsechunksize=offs*3; - fftsize=offs*2; -#else - impulsechunksize=fftsize; - - fftsize*=2; -#endif - } - while (samplesleft > 0); - - return GetLatency(); -} - -int WDL_ConvolutionEngine_Div::GetLatency() -{ - return m_engines.GetSize() ? m_engines.Get(0)->GetLatency() : 0; -} - - -void WDL_ConvolutionEngine_Div::Reset() -{ - int x; - for (x = 0; x < m_engines.GetSize(); x ++) - { - WDL_ConvolutionEngine *eng=m_engines.Get(x); - eng->Reset(); - } - for (x = 0; x < m_sout.GetSize(); x ++) - { - m_sout.Get(x)->Clear(); - } - - m_need_feedsilence=true; -} - -WDL_ConvolutionEngine_Div::~WDL_ConvolutionEngine_Div() -{ - timingPrint(); - m_engines.Empty(true); - m_sout.Empty(true); -} - -void WDL_ConvolutionEngine_Div::Add(WDL_FFT_REAL **bufs, int len, int nch) -{ - while (m_sout.GetSize() < nch) - m_sout.Add(new WDL_Queue); - while (m_sout.GetSize() > nch) - m_sout.Delete(m_sout.GetSize()-1,true); - - bool ns=m_need_feedsilence; - m_need_feedsilence=false; - - int x; - for (x = 0; x < m_engines.GetSize(); x ++) - { - WDL_ConvolutionEngine *eng=m_engines.Get(x); - if (ns) - { - eng->m_zl_dumpage = (x>0 && x < m_engines.GetSize()-1) ? (eng->GetLatency()/4) : 0; // reduce max number of ffts per block by staggering them - - if (eng->m_zl_dumpage>0) - eng->Add(NULL,eng->m_zl_dumpage,nch); // added silence to input (to control when fft happens) - } - - eng->Add(bufs,len,nch); - - if (ns) eng->AddSilenceToOutput(eng->m_zl_delaypos); // add silence to output (to delay output to its correct time) - - } -} -WDL_FFT_REAL **WDL_ConvolutionEngine_Div::Get() -{ - WDL_FFT_REAL **ret = m_get_tmpptrs.ResizeOK(m_sout.GetSize(),false); - if (WDL_NORMALLY(ret)) - for (int x = 0; x < m_sout.GetSize(); x ++) ret[x]=(WDL_FFT_REAL *)m_sout.Get(x)->Get(); - return ret; -} - -void WDL_ConvolutionEngine_Div::Advance(int len) -{ - int x; - for (x = 0; x < m_sout.GetSize(); x ++) - { - WDL_Queue *q = m_sout.Get(x); - q->Advance(len*sizeof(WDL_FFT_REAL)); - q->Compact(); - } -} - -int WDL_ConvolutionEngine_Div::Avail(int wantSamples) -{ - timingEnter(1); - int wso=wantSamples; - int x; -#ifdef WDLCONVO_ZL_ACCOUNTING - int cnt=0; - static int maxcnt=-1; - int h=0; -#endif - for (x = 0; x < m_engines.GetSize(); x ++) - { - WDL_ConvolutionEngine *eng=m_engines.Get(x); -#ifdef WDLCONVO_ZL_ACCOUNTING - eng->m_zl_fftcnt=0; -#endif - int a=eng->Avail(wso+eng->m_zl_dumpage) - eng->m_zl_dumpage; -#ifdef WDLCONVO_ZL_ACCOUNTING - cnt += !!eng->m_zl_fftcnt; - -#if 0 - if (eng->m_zl_fftcnt) - h|=1<m_zl_fftcnt && x==m_engines.GetSize()-1 && cnt>1) - { - wdl_log("fft flags=%08x (%08x=max)\n",h,1<maxcnt)maxcnt=cnt; - if (GetTickCount()>lastt+1000) - { - lastt=GetTickCount(); - wdl_log("maxcnt=%d\n",maxcnt); - maxcnt=-1; - } -#endif - if (wantSamples>0) - { - const int add_sz = wantSamples*sizeof(WDL_FFT_REAL); - for (x =0; x < m_sout.GetSize(); x ++) - { - void *add = m_sout.Get(x)->Add(NULL,add_sz); - if (WDL_NORMALLY(add != NULL)) memset(add,0,add_sz); - } - - for (x = 0; x < m_engines.GetSize(); x ++) - { - WDL_ConvolutionEngine *eng=m_engines.Get(x); - if (eng->m_zl_dumpage>0) { eng->Advance(eng->m_zl_dumpage); eng->m_zl_dumpage=0; } - - WDL_FFT_REAL **p=eng->Get(); - if (p) - { - int i; - for (i =0; i < m_sout.GetSize(); i ++) - { - WDL_Queue *q = m_sout.Get(i); - const int qsz = q->Available(); - if (WDL_NORMALLY(qsz >= add_sz)) - { - WDL_FFT_REAL *o=(WDL_FFT_REAL *)((char *)q->Get() + qsz - add_sz); - const WDL_FFT_REAL *in=p[i]; - int j=wantSamples; - while (j-->0) *o++ += *in++; - } - } - } - eng->Advance(wantSamples); - } - } - timingLeave(1); - - WDL_Queue *q0 = m_sout.Get(0); - int av=WDL_NORMALLY(q0 != NULL) ? (int) (q0->Available()/sizeof(WDL_FFT_REAL)) : 0; - return av>wso ? wso : av; -} - - -#ifdef WDL_TEST_CONVO - -#include - -int main(int argc, char **argv) -{ - if (argc!=5) - { - printf("usage: convoengine fftsize implen oneoffs pingoffs\n"); - return -1; - } - - int fftsize=atoi(argv[1]); - int implen = atoi(argv[2]); - int oneoffs = atoi(argv[3]); - int pingoffs=atoi(argv[4]); - - if (implen < 1 || oneoffs < 0 || oneoffs >= implen || pingoffs < 0) - { - printf("invalid parameters\n"); - return -1; - } - - WDL_ImpulseBuffer imp; - imp.nch=1; - memset(imp.impulses[0].Resize(implen),0,implen*sizeof(WDL_FFT_REAL)); - imp.impulses[0].Get()[oneoffs]=1.0; - - -#if WDL_TEST_CONVO==2 - WDL_ConvolutionEngine_Div engine; -#else - WDL_ConvolutionEngine engine; -#endif - engine.SetImpulse(&imp,fftsize); - WDL_TypedBuf m_tmpbuf; - memset(m_tmpbuf.Resize(pingoffs+1),0,pingoffs*sizeof(WDL_FFT_REAL)); - m_tmpbuf.Get()[pingoffs]=1.0; - WDL_FFT_REAL *p=m_tmpbuf.Get(); - engine.Add(&p,pingoffs+1,1); - - p=m_tmpbuf.Resize(4096); - memset(p,0,m_tmpbuf.GetSize()*sizeof(WDL_FFT_REAL)); - - int avail; - while ((avail=engine.Avail(pingoffs+oneoffs + 8192)) < pingoffs+oneoffs + 8192) - { - engine.Add(&p,4096,1); - } - WDL_FFT_REAL **output = engine.Get(); - if (!output || !*output) - { - printf("cant get output\n"); - return -1; - } - int x; - for (x = 0; x < avail; x ++) - { - WDL_FFT_REAL val=output[0][x]; - WDL_FFT_REAL expval = (x==pingoffs+oneoffs) ? 1.0:0.0; - if (fabs(val-expval)>0.000000001) - { - printf("%d: %.4fdB - %f %f\n",x,log10(max(val,0.000000000001))*20.0 - log10(max(expval,0.000000000001))*20.0,val,expval); - } - } - - return 0; -} - -#endif - - -int WDL_ImpulseBuffer::SetLength(int samples) -{ - const int nch = impulses.list.GetSize(); - if (!nch) return 0; - for (int x=0;x old_nch) - { - while (impulses.list.GetSize() < usench) - impulses.list.Add(new WDL_TypedBuf); - - const int len = SetLength(GetLength()); - - int x,ax=0; - if (duplicateExisting && len>0 && old_nch>0) for(x=old_nch;x=old_nch) ax=0; - } - } - else while (usench); - } - ~WDL_ImpulseBuffer() - { - impulses.list.Empty(true); - } - - int GetLength() { return impulses.list.GetSize() ? impulses[0].GetSize() : 0; } - int SetLength(int samples); // resizes/clears all channels accordingly, returns actual size set (can be 0 if error) - void SetNumChannels(int usench, bool duplicateExisting=true); // handles allocating/converting/etc - int GetNumChannels() { return impulses.list.GetSize(); } - - double samplerate; - struct { - WDL_PtrList > list; - - WDL_TypedBuf &operator[](size_t i) const - { - WDL_TypedBuf *p = list.Get(i); - if (WDL_NORMALLY(p != NULL)) return *p; - return *list.Get(0); // if for some reason an out of range index was passed, return first item rather than crash - } - } impulses; - -}; - -class WDL_ConvolutionEngine -{ -public: - WDL_ConvolutionEngine(); - ~WDL_ConvolutionEngine(); - - int SetImpulse(WDL_ImpulseBuffer *impulse, int fft_size=-1, int impulse_sample_offset=0, int max_imp_size=0, bool forceBrute=false); - - int GetFFTSize() { return m_fft_size; } - int GetLatency() { return m_fft_size/2; } - - void Reset(); // clears out any latent samples - - void Add(WDL_FFT_REAL **bufs, int len, int nch); - - int Avail(int wantSamples); - WDL_FFT_REAL **Get(); // returns length valid - void Advance(int len); - -private: - - struct ImpChannelInfo { - WDL_TypedBuf imp; - WDL_TypedBuf zflag; - }; - - struct ProcChannelInfo { - WDL_Queue samplesout; - WDL_Queue samplesin2; - WDL_FastQueue samplesin; - - WDL_TypedBuf samplehist; // FFT'd sample blocks per channel - WDL_TypedBuf samplehist_zflag; - WDL_TypedBuf overlaphist; - - int hist_pos; - }; - - - WDL_PtrList m_impdata; - - int m_impulse_len; - int m_fft_size; - - int m_proc_nch; - WDL_PtrList m_proc; - - - WDL_TypedBuf m_combinebuf; - WDL_TypedBuf m_get_tmpptrs; - -public: - - // _div stuff - int m_zl_delaypos; - int m_zl_dumpage; - -//#define WDLCONVO_ZL_ACCOUNTING -#ifdef WDLCONVO_ZL_ACCOUNTING - int m_zl_fftcnt;//removeme (testing of benchmarks) -#endif - void AddSilenceToOutput(int len); - -} WDL_FIXALIGN; - -// low latency version -class WDL_ConvolutionEngine_Div -{ -public: - WDL_ConvolutionEngine_Div(); - ~WDL_ConvolutionEngine_Div(); - - int SetImpulse(WDL_ImpulseBuffer *impulse, int maxfft_size=0, int known_blocksize=0, int max_imp_size=0, int impulse_offset=0, int latency_allowed=0); - - int GetLatency(); - void Reset(); - - void Add(WDL_FFT_REAL **bufs, int len, int nch); - - int Avail(int wantSamples); - WDL_FFT_REAL **Get(); // returns length valid - void Advance(int len); - -private: - WDL_PtrList m_engines; - - WDL_PtrList m_sout; - WDL_TypedBuf m_get_tmpptrs; - - bool m_need_feedsilence; - -} WDL_FIXALIGN; - - -#endif diff --git a/oversampling/WDL/coreaudio_channel_formats.h b/oversampling/WDL/coreaudio_channel_formats.h deleted file mode 100644 index 2606ca9..0000000 --- a/oversampling/WDL/coreaudio_channel_formats.h +++ /dev/null @@ -1,384 +0,0 @@ -#ifndef _CAFCHANNELFORMATS_H_ -#define _CAFCHANNELFORMATS_H_ - -// from CoreAudioBaseTypes.h in the ios sdk, good luck finding it online - -enum -{ - // these are identical to the WAVEFORMATEXTENSIBLE bitmask - kAudioChannelBit_Left = (1U<<0), // WAVEXT: SPEAKER_FRONT_LEFT - kAudioChannelBit_Right = (1U<<1), // WAVEXT: SPEAKER_FRONT_RIGHT - kAudioChannelBit_Center = (1U<<2), // WAVEXT: SPEAKER_FRONT_CENTER - kAudioChannelBit_LFEScreen = (1U<<3), // WAVEXT: SPEAKER_LOW_FREQUENCY - kAudioChannelBit_LeftSurround = (1U<<4), // WAVEXT: SPEAKER_BACK_LEFT - kAudioChannelBit_RightSurround = (1U<<5), // WAVEXT: SPEAKER_BACK_RIGHT - kAudioChannelBit_LeftCenter = (1U<<6), // WAVEXT: SPEAKER_FRONT_LEFT_OF_CENTER - kAudioChannelBit_RightCenter = (1U<<7), // WAVEXT: SPEAKER_FROM_RIGHT_OF_CENTER - kAudioChannelBit_CenterSurround = (1U<<8), // WAVEXT: SPEAKER_BACK_CENTER - kAudioChannelBit_LeftSurroundDirect = (1U<<9), // WAVEXT: SPEAKER_SIDE_LEFT - kAudioChannelBit_RightSurroundDirect = (1U<<10), // WAVEXT: SPEAKER_SIDE_RIGHT - kAudioChannelBit_TopCenterSurround = (1U<<11), // WAVEXT: SPEAKER_TOP_CENTER - kAudioChannelBit_VerticalHeightLeft = (1U<<12), // WAVEXT: SPEAKER_TOP_FRONT_LEFT - kAudioChannelBit_VerticalHeightCenter = (1U<<13), // WAVEXT: SPEAKER_TOP_FRONT_CENTER - kAudioChannelBit_VerticalHeightRight = (1U<<14), // WAVEXT: SPEAKER_TOP_FRONT_RIGHT - kAudioChannelBit_TopBackLeft = (1U<<15), // WAVEXT: SPEAKER_TOP_BACK_LEFT - kAudioChannelBit_TopBackCenter = (1U<<16), // WAVEXT: SPEAKER_TOP_BACK_CENTER - kAudioChannelBit_TopBackRight = (1U<<17), // WAVEXT: SPEAKER_TOP_BACK_RIGHT - kAudioChannelBit_LeftTopFront = (1U<<18), - kAudioChannelBit_CenterTopFront = (1U<<19), - kAudioChannelBit_RightTopFront = (1U<<20), - kAudioChannelBit_LeftTopMiddle = (1U<<21), - kAudioChannelBit_CenterTopMiddle = (1U<<22), - kAudioChannelBit_RightTopMiddle = (1U<<23), - kAudioChannelBit_LeftTopRear = (1U<<24), - kAudioChannelBit_CenterTopRear = (1U<<25), - kAudioChannelBit_RightTopRear = (1U<<26), -}; - -enum -{ - // Some channel abbreviations used below: - // L - left - // R - right - // C - center - // Ls - left surround - // Rs - right surround - // Cs - center surround - // Rls - rear left surround - // Rrs - rear right surround - // Lw - left wide - // Rw - right wide - // Lsd - left surround direct - // Rsd - right surround direct - // Lc - left center - // Rc - right center - // Ts - top surround - // Vhl - vertical height left - // Vhc - vertical height center - // Vhr - vertical height right - // Ltf - left top front - // Ctf - center top front - // Rtf - right top front - // Ltm - left top middle - // Ctm - center top middle - // Rtm - right top middle - // Ltr - left top rear - // Ctr - center top rear - // Rtr - right top rear - // Lt - left matrix total. for matrix encoded stereo. - // Rt - right matrix total. for matrix encoded stereo. - - // General layouts - kAudioChannelLayoutTag_UseChannelDescriptions = (0U<<16) | 0, // use the array of AudioChannelDescriptions to define the mapping. - kAudioChannelLayoutTag_UseChannelBitmap = (1U<<16) | 0, // use the bitmap to define the mapping. - - kAudioChannelLayoutTag_Mono = (100U<<16) | 1, // a standard mono stream - kAudioChannelLayoutTag_Stereo = (101U<<16) | 2, // a standard stereo stream (L R) - implied playback - kAudioChannelLayoutTag_StereoHeadphones = (102U<<16) | 2, // a standard stereo stream (L R) - implied headphone playback - kAudioChannelLayoutTag_MatrixStereo = (103U<<16) | 2, // a matrix encoded stereo stream (Lt, Rt) - kAudioChannelLayoutTag_MidSide = (104U<<16) | 2, // mid/side recording - kAudioChannelLayoutTag_XY = (105U<<16) | 2, // coincident mic pair (often 2 figure 8's) - kAudioChannelLayoutTag_Binaural = (106U<<16) | 2, // binaural stereo (left, right) - kAudioChannelLayoutTag_Ambisonic_B_Format = (107U<<16) | 4, // W, X, Y, Z - - kAudioChannelLayoutTag_Quadraphonic = (108U<<16) | 4, // L R Ls Rs -- 90 degree speaker separation - kAudioChannelLayoutTag_Pentagonal = (109U<<16) | 5, // L R Ls Rs C -- 72 degree speaker separation - kAudioChannelLayoutTag_Hexagonal = (110U<<16) | 6, // L R Ls Rs C Cs -- 60 degree speaker separation - kAudioChannelLayoutTag_Octagonal = (111U<<16) | 8, // L R Ls Rs C Cs Lw Rw -- 45 degree speaker separation - kAudioChannelLayoutTag_Cube = (112U<<16) | 8, // left, right, rear left, rear right - // top left, top right, top rear left, top rear right - - // MPEG defined layouts - kAudioChannelLayoutTag_MPEG_1_0 = kAudioChannelLayoutTag_Mono, // C - kAudioChannelLayoutTag_MPEG_2_0 = kAudioChannelLayoutTag_Stereo, // L R - kAudioChannelLayoutTag_MPEG_3_0_A = (113U<<16) | 3, // L R C - kAudioChannelLayoutTag_MPEG_3_0_B = (114U<<16) | 3, // C L R - kAudioChannelLayoutTag_MPEG_4_0_A = (115U<<16) | 4, // L R C Cs - kAudioChannelLayoutTag_MPEG_4_0_B = (116U<<16) | 4, // C L R Cs - kAudioChannelLayoutTag_MPEG_5_0_A = (117U<<16) | 5, // L R C Ls Rs - kAudioChannelLayoutTag_MPEG_5_0_B = (118U<<16) | 5, // L R Ls Rs C - kAudioChannelLayoutTag_MPEG_5_0_C = (119U<<16) | 5, // L C R Ls Rs - kAudioChannelLayoutTag_MPEG_5_0_D = (120U<<16) | 5, // C L R Ls Rs - kAudioChannelLayoutTag_MPEG_5_1_A = (121U<<16) | 6, // L R C LFE Ls Rs - kAudioChannelLayoutTag_MPEG_5_1_B = (122U<<16) | 6, // L R Ls Rs C LFE - kAudioChannelLayoutTag_MPEG_5_1_C = (123U<<16) | 6, // L C R Ls Rs LFE - kAudioChannelLayoutTag_MPEG_5_1_D = (124U<<16) | 6, // C L R Ls Rs LFE - kAudioChannelLayoutTag_MPEG_6_1_A = (125U<<16) | 7, // L R C LFE Ls Rs Cs - kAudioChannelLayoutTag_MPEG_7_1_A = (126U<<16) | 8, // L R C LFE Ls Rs Lc Rc - kAudioChannelLayoutTag_MPEG_7_1_B = (127U<<16) | 8, // C Lc Rc L R Ls Rs LFE (doc: IS-13818-7 MPEG2-AAC Table 3.1) - kAudioChannelLayoutTag_MPEG_7_1_C = (128U<<16) | 8, // L R C LFE Ls Rs Rls Rrs - kAudioChannelLayoutTag_Emagic_Default_7_1 = (129U<<16) | 8, // L R Ls Rs C LFE Lc Rc - kAudioChannelLayoutTag_SMPTE_DTV = (130U<<16) | 8, // L R C LFE Ls Rs Lt Rt - // (kAudioChannelLayoutTag_ITU_5_1 plus a matrix encoded stereo mix) - // ITU defined layouts - kAudioChannelLayoutTag_ITU_1_0 = kAudioChannelLayoutTag_Mono, // C - kAudioChannelLayoutTag_ITU_2_0 = kAudioChannelLayoutTag_Stereo, // L R - - kAudioChannelLayoutTag_ITU_2_1 = (131U<<16) | 3, // L R Cs - kAudioChannelLayoutTag_ITU_2_2 = (132U<<16) | 4, // L R Ls Rs - kAudioChannelLayoutTag_ITU_3_0 = kAudioChannelLayoutTag_MPEG_3_0_A, // L R C - kAudioChannelLayoutTag_ITU_3_1 = kAudioChannelLayoutTag_MPEG_4_0_A, // L R C Cs - - kAudioChannelLayoutTag_ITU_3_2 = kAudioChannelLayoutTag_MPEG_5_0_A, // L R C Ls Rs - kAudioChannelLayoutTag_ITU_3_2_1 = kAudioChannelLayoutTag_MPEG_5_1_A, // L R C LFE Ls Rs - kAudioChannelLayoutTag_ITU_3_4_1 = kAudioChannelLayoutTag_MPEG_7_1_C, // L R C LFE Ls Rs Rls Rrs - - // DVD defined layouts - kAudioChannelLayoutTag_DVD_0 = kAudioChannelLayoutTag_Mono, // C (mono) - kAudioChannelLayoutTag_DVD_1 = kAudioChannelLayoutTag_Stereo, // L R - kAudioChannelLayoutTag_DVD_2 = kAudioChannelLayoutTag_ITU_2_1, // L R Cs - kAudioChannelLayoutTag_DVD_3 = kAudioChannelLayoutTag_ITU_2_2, // L R Ls Rs - kAudioChannelLayoutTag_DVD_4 = (133U<<16) | 3, // L R LFE - kAudioChannelLayoutTag_DVD_5 = (134U<<16) | 4, // L R LFE Cs - kAudioChannelLayoutTag_DVD_6 = (135U<<16) | 5, // L R LFE Ls Rs - kAudioChannelLayoutTag_DVD_7 = kAudioChannelLayoutTag_MPEG_3_0_A, // L R C - kAudioChannelLayoutTag_DVD_8 = kAudioChannelLayoutTag_MPEG_4_0_A, // L R C Cs - kAudioChannelLayoutTag_DVD_9 = kAudioChannelLayoutTag_MPEG_5_0_A, // L R C Ls Rs - kAudioChannelLayoutTag_DVD_10 = (136U<<16) | 4, // L R C LFE - kAudioChannelLayoutTag_DVD_11 = (137U<<16) | 5, // L R C LFE Cs - kAudioChannelLayoutTag_DVD_12 = kAudioChannelLayoutTag_MPEG_5_1_A, // L R C LFE Ls Rs - // 13 through 17 are duplicates of 8 through 12. - kAudioChannelLayoutTag_DVD_13 = kAudioChannelLayoutTag_DVD_8, // L R C Cs - kAudioChannelLayoutTag_DVD_14 = kAudioChannelLayoutTag_DVD_9, // L R C Ls Rs - kAudioChannelLayoutTag_DVD_15 = kAudioChannelLayoutTag_DVD_10, // L R C LFE - kAudioChannelLayoutTag_DVD_16 = kAudioChannelLayoutTag_DVD_11, // L R C LFE Cs - kAudioChannelLayoutTag_DVD_17 = kAudioChannelLayoutTag_DVD_12, // L R C LFE Ls Rs - kAudioChannelLayoutTag_DVD_18 = (138U<<16) | 5, // L R Ls Rs LFE - kAudioChannelLayoutTag_DVD_19 = kAudioChannelLayoutTag_MPEG_5_0_B, // L R Ls Rs C - kAudioChannelLayoutTag_DVD_20 = kAudioChannelLayoutTag_MPEG_5_1_B, // L R Ls Rs C LFE - - // These layouts are recommended for AudioUnit usage - // These are the symmetrical layouts - kAudioChannelLayoutTag_AudioUnit_4 = kAudioChannelLayoutTag_Quadraphonic, - kAudioChannelLayoutTag_AudioUnit_5 = kAudioChannelLayoutTag_Pentagonal, - kAudioChannelLayoutTag_AudioUnit_6 = kAudioChannelLayoutTag_Hexagonal, - kAudioChannelLayoutTag_AudioUnit_8 = kAudioChannelLayoutTag_Octagonal, - // These are the surround-based layouts - kAudioChannelLayoutTag_AudioUnit_5_0 = kAudioChannelLayoutTag_MPEG_5_0_B, // L R Ls Rs C - kAudioChannelLayoutTag_AudioUnit_6_0 = (139U<<16) | 6, // L R Ls Rs C Cs - kAudioChannelLayoutTag_AudioUnit_7_0 = (140U<<16) | 7, // L R Ls Rs C Rls Rrs - kAudioChannelLayoutTag_AudioUnit_7_0_Front = (148U<<16) | 7, // L R Ls Rs C Lc Rc - kAudioChannelLayoutTag_AudioUnit_5_1 = kAudioChannelLayoutTag_MPEG_5_1_A, // L R C LFE Ls Rs - kAudioChannelLayoutTag_AudioUnit_6_1 = kAudioChannelLayoutTag_MPEG_6_1_A, // L R C LFE Ls Rs Cs - kAudioChannelLayoutTag_AudioUnit_7_1 = kAudioChannelLayoutTag_MPEG_7_1_C, // L R C LFE Ls Rs Rls Rrs - kAudioChannelLayoutTag_AudioUnit_7_1_Front = kAudioChannelLayoutTag_MPEG_7_1_A, // L R C LFE Ls Rs Lc Rc - - kAudioChannelLayoutTag_AAC_3_0 = kAudioChannelLayoutTag_MPEG_3_0_B, // C L R - kAudioChannelLayoutTag_AAC_Quadraphonic = kAudioChannelLayoutTag_Quadraphonic, // L R Ls Rs - kAudioChannelLayoutTag_AAC_4_0 = kAudioChannelLayoutTag_MPEG_4_0_B, // C L R Cs - kAudioChannelLayoutTag_AAC_5_0 = kAudioChannelLayoutTag_MPEG_5_0_D, // C L R Ls Rs - kAudioChannelLayoutTag_AAC_5_1 = kAudioChannelLayoutTag_MPEG_5_1_D, // C L R Ls Rs Lfe - kAudioChannelLayoutTag_AAC_6_0 = (141U<<16) | 6, // C L R Ls Rs Cs - kAudioChannelLayoutTag_AAC_6_1 = (142U<<16) | 7, // C L R Ls Rs Cs Lfe - kAudioChannelLayoutTag_AAC_7_0 = (143U<<16) | 7, // C L R Ls Rs Rls Rrs - kAudioChannelLayoutTag_AAC_7_1 = kAudioChannelLayoutTag_MPEG_7_1_B, // C Lc Rc L R Ls Rs Lfe - kAudioChannelLayoutTag_AAC_7_1_B = (183U<<16) | 8, // C L R Ls Rs Rls Rrs LFE - kAudioChannelLayoutTag_AAC_7_1_C = (184U<<16) | 8, // C L R Ls Rs LFE Vhl Vhr - kAudioChannelLayoutTag_AAC_Octagonal = (144U<<16) | 8, // C L R Ls Rs Rls Rrs Cs - - kAudioChannelLayoutTag_TMH_10_2_std = (145U<<16) | 16, // L R C Vhc Lsd Rsd Ls Rs Vhl Vhr Lw Rw Csd Cs LFE1 LFE2 - kAudioChannelLayoutTag_TMH_10_2_full = (146U<<16) | 21, // TMH_10_2_std plus: Lc Rc HI VI Haptic - - kAudioChannelLayoutTag_AC3_1_0_1 = (149U<<16) | 2, // C LFE - kAudioChannelLayoutTag_AC3_3_0 = (150U<<16) | 3, // L C R - kAudioChannelLayoutTag_AC3_3_1 = (151U<<16) | 4, // L C R Cs - kAudioChannelLayoutTag_AC3_3_0_1 = (152U<<16) | 4, // L C R LFE - kAudioChannelLayoutTag_AC3_2_1_1 = (153U<<16) | 4, // L R Cs LFE - kAudioChannelLayoutTag_AC3_3_1_1 = (154U<<16) | 5, // L C R Cs LFE - - kAudioChannelLayoutTag_EAC_6_0_A = (155U<<16) | 6, // L C R Ls Rs Cs - kAudioChannelLayoutTag_EAC_7_0_A = (156U<<16) | 7, // L C R Ls Rs Rls Rrs - - kAudioChannelLayoutTag_EAC3_6_1_A = (157U<<16) | 7, // L C R Ls Rs LFE Cs - kAudioChannelLayoutTag_EAC3_6_1_B = (158U<<16) | 7, // L C R Ls Rs LFE Ts - kAudioChannelLayoutTag_EAC3_6_1_C = (159U<<16) | 7, // L C R Ls Rs LFE Vhc - kAudioChannelLayoutTag_EAC3_7_1_A = (160U<<16) | 8, // L C R Ls Rs LFE Rls Rrs - kAudioChannelLayoutTag_EAC3_7_1_B = (161U<<16) | 8, // L C R Ls Rs LFE Lc Rc - kAudioChannelLayoutTag_EAC3_7_1_C = (162U<<16) | 8, // L C R Ls Rs LFE Lsd Rsd - kAudioChannelLayoutTag_EAC3_7_1_D = (163U<<16) | 8, // L C R Ls Rs LFE Lw Rw - kAudioChannelLayoutTag_EAC3_7_1_E = (164U<<16) | 8, // L C R Ls Rs LFE Vhl Vhr - - kAudioChannelLayoutTag_EAC3_7_1_F = (165U<<16) | 8, // L C R Ls Rs LFE Cs Ts - kAudioChannelLayoutTag_EAC3_7_1_G = (166U<<16) | 8, // L C R Ls Rs LFE Cs Vhc - kAudioChannelLayoutTag_EAC3_7_1_H = (167U<<16) | 8, // L C R Ls Rs LFE Ts Vhc - - kAudioChannelLayoutTag_DTS_3_1 = (168U<<16) | 4, // C L R LFE - kAudioChannelLayoutTag_DTS_4_1 = (169U<<16) | 5, // C L R Cs LFE - kAudioChannelLayoutTag_DTS_6_0_A = (170U<<16) | 6, // Lc Rc L R Ls Rs - kAudioChannelLayoutTag_DTS_6_0_B = (171U<<16) | 6, // C L R Rls Rrs Ts - kAudioChannelLayoutTag_DTS_6_0_C = (172U<<16) | 6, // C Cs L R Rls Rrs - kAudioChannelLayoutTag_DTS_6_1_A = (173U<<16) | 7, // Lc Rc L R Ls Rs LFE - kAudioChannelLayoutTag_DTS_6_1_B = (174U<<16) | 7, // C L R Rls Rrs Ts LFE - kAudioChannelLayoutTag_DTS_6_1_C = (175U<<16) | 7, // C Cs L R Rls Rrs LFE - kAudioChannelLayoutTag_DTS_7_0 = (176U<<16) | 7, // Lc C Rc L R Ls Rs - kAudioChannelLayoutTag_DTS_7_1 = (177U<<16) | 8, // Lc C Rc L R Ls Rs LFE - kAudioChannelLayoutTag_DTS_8_0_A = (178U<<16) | 8, // Lc Rc L R Ls Rs Rls Rrs - kAudioChannelLayoutTag_DTS_8_0_B = (179U<<16) | 8, // Lc C Rc L R Ls Cs Rs - kAudioChannelLayoutTag_DTS_8_1_A = (180U<<16) | 9, // Lc Rc L R Ls Rs Rls Rrs LFE - kAudioChannelLayoutTag_DTS_8_1_B = (181U<<16) | 9, // Lc C Rc L R Ls Cs Rs LFE - kAudioChannelLayoutTag_DTS_6_1_D = (182U<<16) | 7, // C L R Ls Rs LFE Cs - - kAudioChannelLayoutTag_WAVE_2_1 = kAudioChannelLayoutTag_DVD_4, // 3 channels, L R LFE - kAudioChannelLayoutTag_WAVE_3_0 = kAudioChannelLayoutTag_MPEG_3_0_A, // 3 channels, L R C - kAudioChannelLayoutTag_WAVE_4_0_A = kAudioChannelLayoutTag_ITU_2_2, // 4 channels, L R Ls Rs - kAudioChannelLayoutTag_WAVE_4_0_B = (185U<<16) | 4, // 4 channels, L R Rls Rrs - kAudioChannelLayoutTag_WAVE_5_0_A = kAudioChannelLayoutTag_MPEG_5_0_A, // 5 channels, L R C Ls Rs - kAudioChannelLayoutTag_WAVE_5_0_B = (186U<<16) | 5, // 5 channels, L R C Rls Rrs - kAudioChannelLayoutTag_WAVE_5_1_A = kAudioChannelLayoutTag_MPEG_5_1_A, // 6 channels, L R C LFE Ls Rs - kAudioChannelLayoutTag_WAVE_5_1_B = (187U<<16) | 6, // 6 channels, L R C LFE Rls Rrs - kAudioChannelLayoutTag_WAVE_6_1 = (188U<<16) | 7, // 7 channels, L R C LFE Cs Ls Rs - kAudioChannelLayoutTag_WAVE_7_1 = (189U<<16) | 8, // 8 channels, L R C LFE Rls Rrs Ls Rs - - kAudioChannelLayoutTag_HOA_ACN_SN3D = (190U<<16) | 0, // Higher Order Ambisonics, Ambisonics Channel Number, SN3D normalization - // needs to be ORed with the actual number of channels (not the HOA order) - kAudioChannelLayoutTag_HOA_ACN_N3D = (191U<<16) | 0, // Higher Order Ambisonics, Ambisonics Channel Number, N3D normalization - // needs to be ORed with the actual number of channels (not the HOA order) - - kAudioChannelLayoutTag_Atmos_5_1_2 = (194U<<16) | 8, ///< L R C LFE Ls Rs Ltm Rtm - kAudioChannelLayoutTag_Atmos_5_1_4 = (195U<<16) | 10, ///< L R C LFE Ls Rs Vhl Vhr Ltr Rtr - kAudioChannelLayoutTag_Atmos_7_1_2 = (196U<<16) | 10, ///< L R C LFE Ls Rs Rls Rrs Ltm Rtm - kAudioChannelLayoutTag_Atmos_7_1_4 = (192U<<16) | 12, ///< L R C LFE Ls Rs Rls Rrs Vhl Vhr Ltr Rtr - kAudioChannelLayoutTag_Atmos_9_1_6 = (193U<<16) | 16, ///< L R C LFE Ls Rs Rls Rrs Lw Rw Vhl Vhr Ltm Rtm Ltr Rtr // L R C LFE Ls Rs Ltm Rtm - - kAudioChannelLayoutTag_DiscreteInOrder = (147U<<16) | 0, ///< needs to be ORed with the actual number of channels // needs to be ORed with the actual number of channels - - kAudioChannelLayoutTag_BeginReserved = 0xF0000000, // Channel layout tag values in this range are reserved for internal use - kAudioChannelLayoutTag_EndReserved = 0xFFFEFFFF, - - kAudioChannelLayoutTag_Unknown = 0xFFFF0000 // needs to be ORed with the actual number of channels -}; - -enum -{ - kAudioChannelLabel_Unknown = 0xFFFFFFFF, // unknown or unspecified other use - kAudioChannelLabel_Unused = 0, // channel is present, but has no intended use or destination - kAudioChannelLabel_UseCoordinates = 100, // channel is described by the mCoordinates fields. - - kAudioChannelLabel_Left = 1, - kAudioChannelLabel_Right = 2, - kAudioChannelLabel_Center = 3, - kAudioChannelLabel_LFEScreen = 4, - kAudioChannelLabel_LeftSurround = 5, - kAudioChannelLabel_RightSurround = 6, - kAudioChannelLabel_LeftCenter = 7, - kAudioChannelLabel_RightCenter = 8, - kAudioChannelLabel_CenterSurround = 9, // WAVE: "Back Center" or plain "Rear Surround" - kAudioChannelLabel_LeftSurroundDirect = 10, - kAudioChannelLabel_RightSurroundDirect = 11, - kAudioChannelLabel_TopCenterSurround = 12, - kAudioChannelLabel_VerticalHeightLeft = 13, // WAVE: "Top Front Left" - kAudioChannelLabel_VerticalHeightCenter = 14, // WAVE: "Top Front Center" - kAudioChannelLabel_VerticalHeightRight = 15, // WAVE: "Top Front Right" - - kAudioChannelLabel_TopBackLeft = 16, - kAudioChannelLabel_TopBackCenter = 17, - kAudioChannelLabel_TopBackRight = 18, - - kAudioChannelLabel_RearSurroundLeft = 33, - kAudioChannelLabel_RearSurroundRight = 34, - kAudioChannelLabel_LeftWide = 35, - kAudioChannelLabel_RightWide = 36, - kAudioChannelLabel_LFE2 = 37, - kAudioChannelLabel_LeftTotal = 38, // matrix encoded 4 channels - kAudioChannelLabel_RightTotal = 39, // matrix encoded 4 channels - kAudioChannelLabel_HearingImpaired = 40, - kAudioChannelLabel_Narration = 41, - kAudioChannelLabel_Mono = 42, - kAudioChannelLabel_DialogCentricMix = 43, - - kAudioChannelLabel_CenterSurroundDirect = 44, // back center, non diffuse - - kAudioChannelLabel_Haptic = 45, - - kAudioChannelLabel_LeftTopFront = 46, - kAudioChannelLabel_CenterTopFront = 47, - kAudioChannelLabel_RightTopFront = 48, - kAudioChannelLabel_LeftTopMiddle = 49, - kAudioChannelLabel_CenterTopMiddle = 50, - kAudioChannelLabel_RightTopMiddle = 51, - kAudioChannelLabel_LeftTopRear = 52, - kAudioChannelLabel_CenterTopRear = 53, - kAudioChannelLabel_RightTopRear = 54, - - // first order ambisonic channels - kAudioChannelLabel_Ambisonic_W = 200, - kAudioChannelLabel_Ambisonic_X = 201, - kAudioChannelLabel_Ambisonic_Y = 202, - kAudioChannelLabel_Ambisonic_Z = 203, - - // Mid/Side Recording - kAudioChannelLabel_MS_Mid = 204, - kAudioChannelLabel_MS_Side = 205, - - // X-Y Recording - kAudioChannelLabel_XY_X = 206, - kAudioChannelLabel_XY_Y = 207, - - // Binaural Recording - kAudioChannelLabel_BinauralLeft = 208, - kAudioChannelLabel_BinauralRight = 209, - - // other - kAudioChannelLabel_HeadphonesLeft = 301, - kAudioChannelLabel_HeadphonesRight = 302, - kAudioChannelLabel_ClickTrack = 304, - kAudioChannelLabel_ForeignLanguage = 305, - - // generic discrete channel - kAudioChannelLabel_Discrete = 400, - - // numbered discrete channel - kAudioChannelLabel_Discrete_0 = (1U<<16) | 0, - kAudioChannelLabel_Discrete_1 = (1U<<16) | 1, - kAudioChannelLabel_Discrete_2 = (1U<<16) | 2, - kAudioChannelLabel_Discrete_3 = (1U<<16) | 3, - kAudioChannelLabel_Discrete_4 = (1U<<16) | 4, - kAudioChannelLabel_Discrete_5 = (1U<<16) | 5, - kAudioChannelLabel_Discrete_6 = (1U<<16) | 6, - kAudioChannelLabel_Discrete_7 = (1U<<16) | 7, - kAudioChannelLabel_Discrete_8 = (1U<<16) | 8, - kAudioChannelLabel_Discrete_9 = (1U<<16) | 9, - kAudioChannelLabel_Discrete_10 = (1U<<16) | 10, - kAudioChannelLabel_Discrete_11 = (1U<<16) | 11, - kAudioChannelLabel_Discrete_12 = (1U<<16) | 12, - kAudioChannelLabel_Discrete_13 = (1U<<16) | 13, - kAudioChannelLabel_Discrete_14 = (1U<<16) | 14, - kAudioChannelLabel_Discrete_15 = (1U<<16) | 15, - kAudioChannelLabel_Discrete_65535 = (1U<<16) | 65535, - - // generic HOA ACN channel - kAudioChannelLabel_HOA_ACN = 500, - - // numbered HOA ACN channels - kAudioChannelLabel_HOA_ACN_0 = (2U << 16) | 0, - kAudioChannelLabel_HOA_ACN_1 = (2U << 16) | 1, - kAudioChannelLabel_HOA_ACN_2 = (2U << 16) | 2, - kAudioChannelLabel_HOA_ACN_3 = (2U << 16) | 3, - kAudioChannelLabel_HOA_ACN_4 = (2U << 16) | 4, - kAudioChannelLabel_HOA_ACN_5 = (2U << 16) | 5, - kAudioChannelLabel_HOA_ACN_6 = (2U << 16) | 6, - kAudioChannelLabel_HOA_ACN_7 = (2U << 16) | 7, - kAudioChannelLabel_HOA_ACN_8 = (2U << 16) | 8, - kAudioChannelLabel_HOA_ACN_9 = (2U << 16) | 9, - kAudioChannelLabel_HOA_ACN_10 = (2U << 16) | 10, - kAudioChannelLabel_HOA_ACN_11 = (2U << 16) | 11, - kAudioChannelLabel_HOA_ACN_12 = (2U << 16) | 12, - kAudioChannelLabel_HOA_ACN_13 = (2U << 16) | 13, - kAudioChannelLabel_HOA_ACN_14 = (2U << 16) | 14, - kAudioChannelLabel_HOA_ACN_15 = (2U << 16) | 15, - kAudioChannelLabel_HOA_ACN_65024 = (2U << 16) | 65024, // 254th order uses 65025 channels - - kAudioChannelLabel_BeginReserved = 0xF0000000, // Channel label values in this range are reserved for internal use - kAudioChannelLabel_EndReserved = 0xFFFFFFFE -}; - -enum -{ - kAudioChannelFlags_AllOff = 0, - kAudioChannelFlags_RectangularCoordinates = (1U<<0), - kAudioChannelFlags_SphericalCoordinates = (1U<<1), - kAudioChannelFlags_Meters = (1U<<2) -}; - - -#endif // _CAFCHANNELFORMATS_H_ \ No newline at end of file diff --git a/oversampling/WDL/db2val.h b/oversampling/WDL/db2val.h deleted file mode 100644 index a0a0df1..0000000 --- a/oversampling/WDL/db2val.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef _WDL_DB2VAL_H_ -#define _WDL_DB2VAL_H_ - -#include - -#define TWENTY_OVER_LN10 8.6858896380650365530225783783321 -#define LN10_OVER_TWENTY 0.11512925464970228420089957273422 -#define DB2VAL(x) exp((x)*LN10_OVER_TWENTY) - -static inline double VAL2DB(double x) -{ - if (x < 0.0000000298023223876953125) return -150.0; - double v=log(x)*TWENTY_OVER_LN10; - return v<-150.0?-150.0:v; -} - -static inline double VAL2DB_EX(double x, double mindb) -{ - return x <= DB2VAL(mindb) ? mindb : (log(x)*TWENTY_OVER_LN10); -} - -#endif \ No newline at end of file diff --git a/oversampling/WDL/delay_line.h b/oversampling/WDL/delay_line.h deleted file mode 100644 index f44adcd..0000000 --- a/oversampling/WDL/delay_line.h +++ /dev/null @@ -1,180 +0,0 @@ -#ifndef _WDL_DELAY_LINE_H_ -#define _WDL_DELAY_LINE_H_ - -#include "circbuf.h" - -template class WDL_DelayLine { -public: - WDL_DelayLine() : m_nch(1) { } - ~WDL_DelayLine() { } - - // call before accessing anything. - // total_size is maximum delay line length required (preserves contents on resize) - // if valid_size >=0, ensures delay line has exactly valid_size pairs set (must be <= total_size!) - void set_nch_length(int nch, int total_size, int valid_size=-1) - { - if (WDL_NOT_NORMALLY(valid_size > total_size)) valid_size=total_size; - - int avail = get_avail_pairs(); - const int minsz = valid_size >= 0 ? valid_size : total_size; - if (avail > minsz) - { - skip_pairs(avail-minsz); - avail = minsz; - } - - if (m_nch != nch && WDL_NORMALLY(nch>0)) - { - if (nch > m_nch) m_q.SetSizePreserveContents(total_size*nch); - - SampleType work[2048]; - const int chunk = 2048 / wdl_max(nch,m_nch); - int nleft = avail; - while (nleft > 0) - { - const int a = wdl_min(chunk,nleft); - nleft-=a; - - m_q.Get(work,a*m_nch); - VALIDATE_BUFFER(work,a*m_nch); - reinterleave_buffer(work,m_nch,nch,a); - m_q.Add(work,a*nch); - } - - if (nch < m_nch) m_q.SetSizePreserveContents(total_size*nch); - - m_nch=nch; - } - else - { - const int newsz = total_size*nch, cursz = m_q.GetTotalSize(); - if (newsz > cursz || newsz < cursz/2) m_q.SetSizePreserveContents(newsz); - } - - if (valid_size > 0) - { - const int need_extra = valid_size - get_avail_pairs(); - if (need_extra > 0) - { - // insert zero data at read pointer in delay line - m_q.Skip(-need_extra*nch); - m_q.WriteAtReadPointer(NULL,need_extra*nch); - } - } - } - - void add_pairs(const SampleType *buf, int pairs) // pushes data off old end of queue - { - WDL_ASSERT(pairs>=0); - if (pairs <= 0) return; - - VALIDATE_BUFFER(buf,pairs*m_nch); - - int add_sz = pairs*m_nch; - if (add_sz > m_q.NbFree()) - { - if (add_sz > m_q.GetTotalSize()) - { - if (buf) buf += add_sz - m_q.GetTotalSize(); - add_sz = m_q.GetTotalSize(); - } - m_q.Skip(add_sz - m_q.NbFree()); - } - - const int added = m_q.Add(buf,add_sz); - if (added != add_sz) { WDL_ASSERT(added == add_sz); } - } - - void unadd_pairs(int pairs) - { - WDL_ASSERT(pairs>=0); - if (pairs>0) m_q.UnAdd(pairs*m_nch); - } - - int peek_pairs(SampleType *buf, int pairs, int offs=0) // allow to request more than available, returns amt returned - { - WDL_ASSERT(offs >= 0); - const int avail = get_avail_pairs(); - const int rdsize = wdl_min(avail - offs, pairs); - if (rdsize <= 0) return 0; - - int ret = m_q.Peek(buf,offs*m_nch,rdsize*m_nch); - WDL_ASSERT(ret == rdsize*m_nch); - VALIDATE_BUFFER(buf,rdsize); - return ret/m_nch; - } - - void get_pairs(SampleType *buf, int pairs) // asserts if pairs > available - { - int amt; - WDL_ASSERT(pairs <= get_avail_pairs()); - if (buf) - { - amt = peek_pairs(buf,pairs,0); - WDL_ASSERT(amt == pairs); - VALIDATE_BUFFER(buf,amt); - } - else - { - amt = pairs; - } - skip_pairs(amt); - } - - void skip_pairs(int samt) { if (samt > 0) m_q.Skip(samt*m_nch); } - int get_avail_pairs() const { return m_q.NbInBuf()/m_nch; } - - void free_memory() { m_q.SetSize(0); } // frees memory - void clear() { m_q.Reset(); } // keeps max buffer size intact but clears contents - - static void reinterleave_buffer(SampleType *rdptr, int in_nch, int out_nch, int len) - { - if (len < 1 || !rdptr) return; - - int x=len-1; - SampleType *wrptr = rdptr; - if (out_nch < in_nch) - { - const int sz1=out_nch*sizeof(SampleType); - while (x--) - { - rdptr += in_nch; - wrptr += out_nch; - memmove(wrptr,rdptr,sz1); - } - } - else if (out_nch > in_nch) - { - const int sz1=in_nch*sizeof(SampleType); - const int sz2=(out_nch-in_nch)*sizeof(SampleType); - rdptr += in_nch*x; - wrptr += out_nch*x; - while(x--) - { - memmove(wrptr,rdptr,sz1); - memset(wrptr+in_nch,0,sz2); - - rdptr-=in_nch; - wrptr-=out_nch; - } - memset(wrptr+in_nch,0,sz2); // last iteration doesnt need memcpy (but does need clear) - } - } - -private: - WDL_TypedCircBuf m_q; - int m_nch; - - static void VALIDATE_BUFFER(const SampleType *buf, int cnt) - { -#ifdef _DEBUG - if (buf) for (int x = 0; x < cnt; x ++) - { - double v = buf[x]; - WDL_ASSERT(v >= -40000.0 && v < 40000.0); - } -#endif - } -}; - -#endif diff --git a/oversampling/WDL/denormal.h b/oversampling/WDL/denormal.h deleted file mode 100644 index e9dfb04..0000000 --- a/oversampling/WDL/denormal.h +++ /dev/null @@ -1,248 +0,0 @@ -#ifndef _WDL_DENORMAL_H_ -#define _WDL_DENORMAL_H_ - -#include -#include "wdltypes.h" -// note: the _aggressive versions filter out anything less than around 1.0e-16 or so (approximately) to 0.0, including -0.0 (becomes 0.0) -// note: new! the _aggressive versions also filter inf and NaN to 0.0 - -#ifdef __cplusplus -#define WDL_DENORMAL_INLINE inline -#elif defined(_MSC_VER) -#define WDL_DENORMAL_INLINE __inline -#else - #ifdef WDL_STATICFUNC_UNUSED - #define WDL_DENORMAL_INLINE WDL_STATICFUNC_UNUSED - #else - #define WDL_DENORMAL_INLINE - #endif -#endif - -static WDL_DENORMAL_INLINE unsigned int WDL_DENORMAL_FLOAT_W(const float *a) { unsigned int v; memcpy(&v,a,sizeof(v)); return v; } -static WDL_DENORMAL_INLINE unsigned int WDL_DENORMAL_DOUBLE_HW(const double *a) { WDL_UINT64 v; memcpy(&v,(char*)a,sizeof(v)); return (unsigned int) (v>>32); } - -#define WDL_DENORMAL_DOUBLE_AGGRESSIVE_CUTOFF 0x3cA00000 // 0x3B8000000 maybe instead? that's 10^-5 smaller or so -#define WDL_DENORMAL_FLOAT_AGGRESSIVE_CUTOFF 0x25000000 - - -// define WDL_DENORMAL_WANTS_SCOPED_FTZ, and then use a WDL_denormal_ftz_scope in addition to denormal_*(), then -// if FTZ is available it will be used instead... -// -#ifdef WDL_DENORMAL_WANTS_SCOPED_FTZ - -#if defined(__SSE2__) || _M_IX86_FP >= 2 || defined(_M_X64) - #define WDL_DENORMAL_FTZMODE - #define WDL_DENORMAL_FTZSTATE_TYPE unsigned int - #ifdef _MSC_VER - #include - #else - #include - #endif - #define wdl_denorm_mm_getcsr() _mm_getcsr() - #define wdl_denorm_mm_setcsr(x) _mm_setcsr(x) - #if defined(__SSE3__) - #define wdl_denorm_mm_csr_mask ((1<<15)|(1<<11) | (1<<8) | (1<<6)) // FTZ, underflow, denormal mask, DAZ - #else - #define wdl_denorm_mm_csr_mask ((1<<15)|(1<<11)) // FTZ and underflow only (target SSE2) - #endif -#elif defined(__arm__) || defined(__aarch64__) - #define WDL_DENORMAL_FTZMODE - #define WDL_DENORMAL_FTZSTATE_TYPE unsigned long - static unsigned long __attribute__((unused)) wdl_denorm_mm_getcsr() - { - unsigned long rv; -#ifdef __aarch64__ - asm volatile ( "mrs %0, fpcr" : "=r" (rv)); -#else - asm volatile ( "fmrx %0, fpscr" : "=r" (rv)); -#endif - return rv; - } - static void __attribute__((unused)) wdl_denorm_mm_setcsr(unsigned long v) - { -#ifdef __aarch64__ - asm volatile ( "msr fpcr, %0" :: "r"(v)); -#else - asm volatile ( "fmxr fpscr, %0" :: "r"(v)); -#endif - } - #define wdl_denorm_mm_csr_mask (1<<24) -#endif - -class WDL_denormal_ftz_scope -{ - public: - WDL_denormal_ftz_scope() - { -#ifdef WDL_DENORMAL_FTZMODE - const WDL_DENORMAL_FTZSTATE_TYPE b = wdl_denorm_mm_csr_mask; - old_state = wdl_denorm_mm_getcsr(); - if ((need_restore = (old_state & b) != b)) - wdl_denorm_mm_setcsr(old_state|b); -#endif - } - ~WDL_denormal_ftz_scope() - { -#ifdef WDL_DENORMAL_FTZMODE - if (need_restore) wdl_denorm_mm_setcsr(old_state); -#endif - } - -#ifdef WDL_DENORMAL_FTZMODE - WDL_DENORMAL_FTZSTATE_TYPE old_state; - bool need_restore; -#endif - -}; - - -#endif - - -#if !defined(WDL_DENORMAL_FTZMODE) && !defined(WDL_DENORMAL_DO_NOT_FILTER) - -static double WDL_DENORMAL_INLINE denormal_filter_double(double a) -{ - return (WDL_DENORMAL_DOUBLE_HW(&a)&0x7ff00000) ? a : 0.0; -} - -static double WDL_DENORMAL_INLINE denormal_filter_double2(double a) -{ - return ((WDL_DENORMAL_DOUBLE_HW(&a)+0x100000)&0x7ff00000) > 0x100000 ? a : 0.0; -} - -static double WDL_DENORMAL_INLINE denormal_filter_double_aggressive(double a) -{ - return ((WDL_DENORMAL_DOUBLE_HW(&a)+0x100000)&0x7ff00000) >= WDL_DENORMAL_DOUBLE_AGGRESSIVE_CUTOFF ? a : 0.0; -} - -static float WDL_DENORMAL_INLINE denormal_filter_float(float a) -{ - return (WDL_DENORMAL_FLOAT_W(&a)&0x7f800000) ? a : 0.0f; -} - -static float WDL_DENORMAL_INLINE denormal_filter_float2(float a) -{ - return ((WDL_DENORMAL_FLOAT_W(&a)+0x800000)&0x7f800000) > 0x800000 ? a : 0.0f; -} - - -static float WDL_DENORMAL_INLINE denormal_filter_float_aggressive(float a) -{ - return ((WDL_DENORMAL_FLOAT_W(&a)+0x800000)&0x7f800000) >= WDL_DENORMAL_FLOAT_AGGRESSIVE_CUTOFF ? a : 0.0f; -} -static void WDL_DENORMAL_INLINE denormal_fix_double(double *a) -{ - if (!(WDL_DENORMAL_DOUBLE_HW(a)&0x7ff00000)) *a=0.0; -} - -static void WDL_DENORMAL_INLINE denormal_fix_double_aggressive(double *a) -{ - if (((WDL_DENORMAL_DOUBLE_HW(a)+0x100000)&0x7ff00000) < WDL_DENORMAL_DOUBLE_AGGRESSIVE_CUTOFF) *a=0.0; -} - -static void WDL_DENORMAL_INLINE denormal_fix_float(float *a) -{ - if (!(WDL_DENORMAL_FLOAT_W(a)&0x7f800000)) *a=0.0f; -} -static void WDL_DENORMAL_INLINE denormal_fix_float_aggressive(float *a) -{ - if (((WDL_DENORMAL_FLOAT_W(a)+0x800000)&0x7f800000) < WDL_DENORMAL_FLOAT_AGGRESSIVE_CUTOFF) *a=0.0f; -} - - - -#ifdef __cplusplus // automatic typed versions (though one should probably use the explicit versions... - - -static double WDL_DENORMAL_INLINE denormal_filter(double a) -{ - return (WDL_DENORMAL_DOUBLE_HW(&a)&0x7ff00000) ? a : 0.0; -} -static double WDL_DENORMAL_INLINE denormal_filter_aggressive(double a) -{ - return ((WDL_DENORMAL_DOUBLE_HW(&a)+0x100000)&0x7ff00000) >= WDL_DENORMAL_DOUBLE_AGGRESSIVE_CUTOFF ? a : 0.0; -} - -static float WDL_DENORMAL_INLINE denormal_filter(float a) -{ - return (WDL_DENORMAL_FLOAT_W(&a)&0x7f800000) ? a : 0.0f; -} - -static float WDL_DENORMAL_INLINE denormal_filter_aggressive(float a) -{ - return ((WDL_DENORMAL_FLOAT_W(&a)+0x800000)&0x7f800000) >= WDL_DENORMAL_FLOAT_AGGRESSIVE_CUTOFF ? a : 0.0f; -} - -static void WDL_DENORMAL_INLINE denormal_fix(double *a) -{ - if (!(WDL_DENORMAL_DOUBLE_HW(a)&0x7ff00000)) *a=0.0; -} -static void WDL_DENORMAL_INLINE denormal_fix_aggressive(double *a) -{ - if (((WDL_DENORMAL_DOUBLE_HW(a)+0x100000)&0x7ff00000) < WDL_DENORMAL_DOUBLE_AGGRESSIVE_CUTOFF) *a=0.0; -} -static void WDL_DENORMAL_INLINE denormal_fix(float *a) -{ - if (!(WDL_DENORMAL_FLOAT_W(a)&0x7f800000)) *a=0.0f; -} -static void WDL_DENORMAL_INLINE denormal_fix_aggressive(float *a) -{ - if (((WDL_DENORMAL_FLOAT_W(a)+0x800000)&0x7f800000) < WDL_DENORMAL_FLOAT_AGGRESSIVE_CUTOFF) *a=0.0f; -} - - - -#endif // cplusplus versions - -#else // end of !WDL_DENORMAL_DO_NOT_FILTER (and other platform-specific checks) - -#define denormal_filter(x) (x) -#define denormal_filter2(x) (x) -#define denormal_filter_double(x) (x) -#define denormal_filter_double2(x) (x) -#define denormal_filter_double_aggressive(x) (x) -#define denormal_filter_float(x) (x) -#define denormal_filter_float2(x) (x) -#define denormal_filter_float_aggressive(x) (x) -#define denormal_filter_aggressive(x) (x) -#define denormal_fix(x) do { } while(0) -#define denormal_fix_aggressive(x) do { } while(0) -#define denormal_fix_double(x) do { } while(0) -#define denormal_fix_double_aggressive(x) do { } while(0) -#define denormal_fix_float(x) do { } while(0) -#define denormal_fix_float_aggressive(x) do { } while(0) - -#endif - - -//////////////////// -// this isnt a denormal function but it is similar, so we'll put it here as a bonus - -static void WDL_DENORMAL_INLINE GetDoubleMaxAbsValue(double *out, const double *in) // note: the value pointed to by "out" must be >=0.0, __NOT__ <= -0.0 -{ - WDL_UINT64 i, o; - memcpy(&i,in,sizeof(i)); - memcpy(&o,out,sizeof(o)); - i &= WDL_UINT64_CONST(0x7fffffffffffffff); - if (i > o) memcpy(out,&i,sizeof(i)); -} - -static void WDL_DENORMAL_INLINE GetFloatMaxAbsValue(float *out, const float *in) // note: the value pointed to by "out" must be >=0.0, __NOT__ <= -0.0 -{ - unsigned int i, o; - memcpy(&i, in, sizeof(i)); - memcpy(&o, out, sizeof(o)); - i &= 0x7fffffff; - if (i > o) memcpy(out, &i, sizeof(i)); -} - - -#ifdef __cplusplus -static void WDL_DENORMAL_INLINE GetFloatMaxAbsValue(double *out, const double *in) // note: the value pointed to by "out" must be >=0.0, __NOT__ <= -0.0 -{ - GetDoubleMaxAbsValue(out,in); -} -#endif - -#endif diff --git a/oversampling/WDL/destroycheck.h b/oversampling/WDL/destroycheck.h deleted file mode 100644 index 2fa1247..0000000 --- a/oversampling/WDL/destroycheck.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef _WDL_DESTROYCHECK_H_ -#define _WDL_DESTROYCHECK_H_ - -// this is a useful class for verifying that an object (usually "this") hasn't been destroyed: -// to use it you add a WDL_DestroyState as a member of your class, then use the WDL_DestroyCheck -// helper class (creating it when the pointer is known valid, and checking it later to see if it -// is still valid). -// -// example: -// class myClass { -// WDL_DestroyState dest; -// ... -// }; -// -// calling code (on myClass *classInstnace): -// WDL_DestroyCheck chk(&classInstance->dest); -// somefunction(); -// if (!chk.isOK()) printf("classInstance got deleted!\n"); -// -// NOTE: only use this when these objects will be accessed from the same thread -- it will fail miserably -// in a multithreaded environment - - - - -class WDL_DestroyCheck -{ - public: - class WDL_DestroyStateNextRec { public: WDL_DestroyCheck *next; }; - - WDL_DestroyStateNextRec n, *prev; - WDL_DestroyCheck(WDL_DestroyStateNextRec *state) - { - n.next=NULL; - if ((prev=state)) - { - if ((n.next=prev->next)) n.next->prev = &n; - prev->next=this; - } - } - ~WDL_DestroyCheck() - { - if (prev) - { - prev->next = n.next; - if (n.next) n.next->prev = prev; - } - } - - bool isOK() { return !!prev; } -}; - -class WDL_DestroyState : public WDL_DestroyCheck::WDL_DestroyStateNextRec -{ - public: - WDL_DestroyState() { next=NULL; } - - ~WDL_DestroyState() - { - WDL_DestroyCheck *p = next; - while (p) { WDL_DestroyCheck *np = p->n.next; p->prev=NULL; p->n.next=NULL; p=np; } - } -}; - -#endif diff --git a/oversampling/WDL/diffcalc.h b/oversampling/WDL/diffcalc.h deleted file mode 100644 index bb69561..0000000 --- a/oversampling/WDL/diffcalc.h +++ /dev/null @@ -1,163 +0,0 @@ -#ifndef _WDL_DIFFCALC_H_ -#define _WDL_DIFFCALC_H_ - -#include "assocarray.h" - - - -// Based on "An O(ND) Difference Algorithm and Its Variations", Myers -// http://xmailserver.org/diff2.pdf - - -template class WDL_DiffCalc -{ -public: - WDL_DiffCalc() {} - virtual ~WDL_DiffCalc() {} - - // cmp() returns 0 if the elements are equal. - // returns the length of the merged list and populates m_rx, m_ry. - int Diff(const T* x, const T* y, int nx, int ny, int (*cmp)(const T*, const T*)) - { - m_rx.Resize(0, false); - m_ry.Resize(0, false); - ClearV(); - - if (!nx && !ny) return 0; - if (!nx || !ny) - { - int i, n=max(nx, ny); - for (i=0; i < n; ++i) - { - m_rx.Add(nx ? i : -1); - m_ry.Add(ny ? i : -1); - } - return n; - } - - if (!cmp(x, y)) // special case - { - int i, n; - for (n=1; n < min(nx, ny); ++n) - { - if (cmp(x+n, y+n)) break; - } - int len=Diff(x+n, y+n, nx-n, ny-n, cmp); - int *rx=m_rx.Get(), *ry=m_ry.Get(); - for (i=0; i < len; ++i) - { - if (rx[i] >= 0) rx[i] += n; - if (ry[i] >= 0) ry[i] += n; - } - len += n; - while (n--) - { - m_rx.Insert(n, 0); - m_ry.Insert(n, 0); - } - return len; - } - - SetV(0, 1, 0); - int d, k, xi, yi; - for (d=0; d <= nx+ny; ++d) - { - for (k=-d; k <= d ; k += 2) - { - if (k == -d || (k != d && GetV(d, k-1) < GetV(d, k+1))) - { - xi=GetV(d, k+1); - } - else - { - xi=GetV(d, k-1)+1; - } - yi=xi-k; - while (xi < nx && yi < ny && !cmp(x+xi, y+yi)) - { - ++xi; - ++yi; - } - SetV(d+1, k, xi); - if (xi >= nx && yi >= ny) break; - } - if (xi >= nx && yi >= ny) break; - } - - int len=(nx+ny+d)/2; - int *rx=m_rx.Resize(len); - int *ry=m_ry.Resize(len); - int pos=len; - - while (d) - { - while (xi > 0 && yi > 0 && !cmp(x+xi-1, y+yi-1)) - { - --pos; - rx[pos]=--xi; - ry[pos]=--yi; - } - --pos; - if (k == -d || (k != d && GetV(d, k-1) < GetV(d, k+1))) - { - ++k; - rx[pos]=-1; - ry[pos]=--yi; - } - else - { - --k; - rx[pos]=--xi; - ry[pos]=-1; - } - --d; - } - - return len; - } - - // m_rx, m_ry hold the index of each merged list element in x and y, - // or -1 if the merged list element is not an element in that source list. - // example: X="ABCABBA", Y="CBABAC" - // 0123456 012345 - // WDL_Merge() returns "ABCBABBAC" - // 012 3456 - // 0123 45 - // m_rx={ 0, 1, 2, -1, 3, 4, 5, 6, -1} - // m_ry={-1, -1, 0, 1, 2, 3, -1, 4, 5} - WDL_TypedBuf m_rx, m_ry; - -private: - - WDL_IntKeyedArray m_v; // x coord of d-contour on row k - void ClearV() - { - m_v.DeleteAll(); - } - void SetV(int d, int k, int xi) - { - m_v.Insert(_key(d, k), xi); - } - int GetV(int d, int k) - { - return m_v.Get(_key(d, k)); - } - static int _key(int d, int k) { return (d<<16)|(k+(1<<15)); } -}; - - -// this is a separate function from WDL_DiffCalc only because it requires T::operator= -template int WDL_Merge(const T* x, const T* y, int nx, int ny, - int (*cmp)(const T*, const T*), T* list) -{ - WDL_DiffCalc dc; - int i, n=dc.Diff(x, y, nx, ny, cmp); - int *rx=dc.m_rx.Get(), *ry=dc.m_ry.Get(); - for (i=0; i < n; ++i) - { - if (list) list[i]=(rx[i] >= 0 ? x[rx[i]] : y[ry[i]]); - } - return n; -} - -#endif \ No newline at end of file diff --git a/oversampling/WDL/dirscan.h b/oversampling/WDL/dirscan.h deleted file mode 100644 index 81c0556..0000000 --- a/oversampling/WDL/dirscan.h +++ /dev/null @@ -1,329 +0,0 @@ -/* - WDL - dirscan.h - Copyright (C) 2005 and later Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - -*/ - -/* - - This file provides the interface and implementation for WDL_DirScan, a simple - (and somewhat portable) directory reading class. On non-Win32 systems it wraps - opendir()/readdir()/etc. On Win32, it uses FindFirst*, and supports wildcards as - well. - - -*/ - - -#ifndef _WDL_DIRSCAN_H_ -#define _WDL_DIRSCAN_H_ - -#include "wdlstring.h" - -#ifndef _WIN32 -#include -#include -#include -extern struct stat wdl_stat_chk; -// if this fails on linux, use CFLAGS += -D_FILE_OFFSET_BITS=64 -typedef char wdl_dirscan_assert_failed_stat_not_64[sizeof(wdl_stat_chk.st_size)!=8 ? -1 : 1]; -#endif - -class WDL_DirScan -{ - public: - WDL_DirScan() : -#ifdef _WIN32 - m_h(INVALID_HANDLE_VALUE) - #ifndef WDL_NO_SUPPORT_UTF8 - , m_wcmode(false) - #endif -#else - m_h(NULL), m_ent(NULL) -#endif - { - } - - ~WDL_DirScan() - { - Close(); - } - - int First(const char *dirname -#ifdef _WIN32 - , int isExactSpec=0 -#endif - ) // returns 0 if success - { - WDL_FastString scanstr(dirname); - const int l = scanstr.GetLength(); - if (l < 1) return -1; - -#ifdef _WIN32 - if (!isExactSpec) - { - if (dirname[l-1] == '\\' || dirname[l-1] == '/') scanstr.SetLen(l-1); - m_leading_path = scanstr; - scanstr.Append("\\*"); - } - else - { - m_leading_path = scanstr; - - // remove trailing wildcards and directory separator from m_leading_path - const char *sp = m_leading_path.Get(); - int idx = m_leading_path.GetLength() - 1; - while (idx > 0 && sp[idx] != '/' && sp[idx] != '\\') idx--; - if (idx > 0) m_leading_path.SetLen(idx); - } -#else - if (dirname[l-1] == '\\' || dirname[l-1] == '/') scanstr.SetLen(l-1); - m_leading_path = scanstr; - if (!scanstr.GetLength()) scanstr.Set("/"); // fix for scanning / -#endif - - Close(); -#ifdef _WIN32 - #ifndef WDL_NO_SUPPORT_UTF8 - m_h=INVALID_HANDLE_VALUE; - #ifdef WDL_SUPPORT_WIN9X - m_wcmode = GetVersion()< 0x80000000; - #else - m_wcmode = true; - #endif - - if (m_wcmode) - { - int reqbuf = MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,scanstr.Get(),-1,NULL,0); - if (reqbuf > 1000) - { - WDL_TypedBuf tmp; - tmp.Resize(reqbuf+20); - if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,scanstr.Get(),-1,tmp.Get(),tmp.GetSize()-10)) - { - correctlongpath(tmp.Get()); - m_h=FindFirstFileW(tmp.Get(),&m_fd); - } - } - else - { - WCHAR wfilename[1024]; - if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,scanstr.Get(),-1,wfilename,1024-10)) - { - correctlongpath(wfilename); - m_h=FindFirstFileW(wfilename,&m_fd); - } - } - } - - if (m_h==INVALID_HANDLE_VALUE) m_wcmode=false; - - if (m_h==INVALID_HANDLE_VALUE) - #endif - m_h=FindFirstFileA(scanstr.Get(),(WIN32_FIND_DATAA*)&m_fd); - return (m_h == INVALID_HANDLE_VALUE); -#else - m_ent=0; - m_h=opendir(scanstr.Get()); - return !m_h || Next(); -#endif - } - int Next() // returns 0 on success - { -#ifdef _WIN32 - if (m_h == INVALID_HANDLE_VALUE) return -1; - #ifndef WDL_NO_SUPPORT_UTF8 - if (m_wcmode) return !FindNextFileW(m_h,&m_fd); - #endif - return !FindNextFileA(m_h,(WIN32_FIND_DATAA*)&m_fd); -#else - if (!m_h) return -1; - return !(m_ent=readdir(m_h)); -#endif - } - void Close() - { -#ifdef _WIN32 - if (m_h != INVALID_HANDLE_VALUE) FindClose(m_h); - m_h=INVALID_HANDLE_VALUE; -#else - if (m_h) closedir(m_h); - m_h=0; m_ent=0; -#endif - } - -#ifdef _WIN32 - const char *GetCurrentFN() - { -#ifndef WDL_NO_SUPPORT_UTF8 - if (m_wcmode) - { - if (!WideCharToMultiByte(CP_UTF8,0,m_fd.cFileName,-1,m_tmpbuf,sizeof(m_tmpbuf),NULL,NULL)) - m_tmpbuf[0]=0; - return m_tmpbuf; - } -#endif - return ((WIN32_FIND_DATAA *)&m_fd)->cFileName; - } -#else - const char *GetCurrentFN() const { return m_ent?m_ent->d_name : ""; } -#endif - template void GetCurrentFullFN(T *str) - { - str->Set(m_leading_path.Get()); -#ifdef _WIN32 - str->Append("\\"); -#else - str->Append("/"); -#endif - str->Append(GetCurrentFN()); - } - int GetCurrentIsDirectory() const // returns 1 if dir, 2 if symlink to dir, 4 if possibly-recursive symlink to dir - { -#ifdef _WIN32 - return !!(m_fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); -#else - char tmp[2048]; - if (m_ent) switch (m_ent->d_type) - { - case DT_DIR: return 1; - case DT_LNK: - { - snprintf(tmp,sizeof(tmp),"%s/%s",m_leading_path.Get(),m_ent->d_name); - char *rp = realpath(tmp,NULL); - if (!rp) return 0; - - struct stat sb; - int ret = (!stat(rp,&sb) && (sb.st_mode & S_IFMT) == S_IFDIR) ? 2 : 0; - if (ret) - { - // treat symlinks of /path/to/foo -> /path from being resolved (avoiding obvious feedback loops) - const int rpl = (int) strlen(rp); - if ( -#ifdef __APPLE__ - !strnicmp(rp,m_leading_path.Get(),rpl) -#else - !strncmp(rp,m_leading_path.Get(),rpl) -#endif - && (m_leading_path.Get()[rpl] == '/' || m_leading_path.Get()[rpl] == 0) - ) ret = 4; - } - free(rp); - return ret; - } - case DT_UNKNOWN: - { - snprintf(tmp,sizeof(tmp),"%s/%s",m_leading_path.Get(),m_ent->d_name); - DIR *d = opendir(tmp); - if (d) { closedir(d); return 1; } - return 0; - } - } - return 0; -#endif - } - - // these are somewhat windows specific calls, eh -#ifdef _WIN32 - DWORD GetCurrentFileSize(DWORD *HighWord=NULL) const { if (HighWord) *HighWord = m_fd.nFileSizeHigh; return m_fd.nFileSizeLow; } - void GetCurrentLastWriteTime(FILETIME *ft) const { *ft = m_fd.ftLastWriteTime; } - void GetCurrentLastAccessTime(FILETIME *ft) const { *ft = m_fd.ftLastAccessTime; } - void GetCurrentCreationTime(FILETIME *ft) const { *ft = m_fd.ftCreationTime; } - DWORD GetFileAttributes() const { return m_fd.dwFileAttributes; } -#elif defined(_WDL_SWELL_H_) - - void GetCurrentCreationTime(FILETIME *ft) - { - char tmp[2048]; - snprintf(tmp,sizeof(tmp),"%s/%s",m_leading_path.Get(),GetCurrentFN()); - struct stat st={0,}; - stat(tmp,&st); - unsigned long long a=(unsigned long long)st.st_ctime; // seconds since january 1st, 1970 - a+=11644473600ull; // 1601->1970 - a*=10000000; // seconds to 1/10th microseconds (100 nanoseconds) - ft->dwLowDateTime=a & 0xffffffff; - ft->dwHighDateTime=a>>32; - } - - void GetCurrentLastWriteTime(FILETIME *ft) - { - char tmp[2048]; - snprintf(tmp,sizeof(tmp),"%s/%s",m_leading_path.Get(),GetCurrentFN()); - struct stat st={0,}; - stat(tmp,&st); - unsigned long long a=(unsigned long long)st.st_mtime; // seconds since january 1st, 1970 - a+=11644473600ull; // 1601->1970 - a*=10000000; // seconds to 1/10th microseconds (100 nanoseconds) - ft->dwLowDateTime=a & 0xffffffff; - ft->dwHighDateTime=a>>32; - } - DWORD GetCurrentFileSize(DWORD *HighWord=NULL) - { - char tmp[2048]; - snprintf(tmp,sizeof(tmp),"%s/%s",m_leading_path.Get(),GetCurrentFN()); - struct stat st={0,}; - stat(tmp,&st); - - if (HighWord) *HighWord = (DWORD)(st.st_size>>32); - return (DWORD)(st.st_size&0xffffffff); - } - -#endif - - private: -#ifdef _WIN32 - -#ifndef WDL_NO_SUPPORT_UTF8 - bool m_wcmode; - WIN32_FIND_DATAW m_fd; - char m_tmpbuf[MAX_PATH*5]; // even if each byte gets encoded as 4 utf-8 bytes this should be plenty ;) -#else - WIN32_FIND_DATAA m_fd; -#endif - HANDLE m_h; -#else - DIR *m_h; - struct dirent *m_ent; -#endif - WDL_FastString m_leading_path; - -#ifdef _WIN32 - static void correctlongpath(WCHAR *buf) // this also exists as wdl_utf8_correctlongpath - { - const WCHAR *insert; - WCHAR *wr; - int skip = 0; - if (!buf || !buf[0] || wcslen(buf) < 256) return; - if (buf[1] == ':') insert=L"\\\\?\\"; - else if (buf[0] == '\\' && buf[1] == '\\') { insert = L"\\\\?\\UNC\\"; skip=2; } - else return; - - wr = buf + wcslen(insert); - memmove(wr, buf + skip, (wcslen(buf+skip)+1)*2); - memmove(buf,insert,wcslen(insert)*2); - while (*wr) - { - if (*wr == '/') *wr = '\\'; - wr++; - } - } -#endif -} WDL_FIXALIGN; - -#endif diff --git a/oversampling/WDL/eel2/.gitignore b/oversampling/WDL/eel2/.gitignore deleted file mode 100644 index fd2f028..0000000 --- a/oversampling/WDL/eel2/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -/*.obj -/asm-nseel-x64-macho.asm -/asm-nseel-x64.asm -/loose_eel.exe - -!/asm-nseel-x64-macho.o -!/asm-nseel-x64.obj -!/asm-nseel-arm64ec.obj diff --git a/oversampling/WDL/eel2/Makefile b/oversampling/WDL/eel2/Makefile deleted file mode 100644 index 694ab4f..0000000 --- a/oversampling/WDL/eel2/Makefile +++ /dev/null @@ -1,167 +0,0 @@ -CC=gcc -CFLAGS=-g -DWDL_FFT_REALSIZE=8 -Wall -Wno-unused-function -Wno-multichar -Wno-unused-result -Wshadow -Wtype-limits -LFLAGS= -CXX=g++ - -ifdef DEBUG -CFLAGS += -D_DEBUG -O0 -DWDL_CHECK_FOR_NON_UTF8_FOPEN -else -CFLAGS += -DNDEBUG -O -endif - -CFLAGS += -D_FILE_OFFSET_BITS=64 - -OBJS=nseel-caltab.o nseel-compiler.o nseel-eval.o nseel-lextab.o nseel-ram.o nseel-yylex.o nseel-cfunc.o fft.o - -SWELL_OBJS= -LICE_OBJS= - -OBJS2= - -UNAME_S := $(shell uname -s) -ARCH := $(shell uname -m) - -ifeq ($(ARCH), aarch64) - ifeq ($(shell $(CC) -dumpmachine | cut -f 1 -d -), arm) - # helper for armv7l userspace on aarch64 cpu - ARCH := armv7l - endif -endif - -ifeq ($(UNAME_S),Darwin) - CC=clang - CXX=clang++ - CFLAGS += -arch $(ARCH) -endif - -ifeq ($(ARCH),arm64) - CFLAGS += -fsigned-char -else - ifneq ($(filter arm%,$(ARCH)),) - CFLAGS += -fsigned-char -mfpu=vfp -march=armv6t2 -marm - endif - ifeq ($(ARCH),aarch64) - CFLAGS += -fsigned-char - endif -endif - -ifndef ALLOW_WARNINGS - ifneq ($(UNAME_S),Darwin) - CFLAGS += -Werror - endif -endif -ifndef DEPRECATED_WARNINGS - CFLAGS += -Wno-deprecated-declarations -endif - - -default: loose_eel eel_pp - -nseel-compiler.o: glue*.h ns-eel*.h -nseel-cfunc.o: asm*.c ns-eel*.h -loose_eel.o: eel*.h ns-eel*.h -nseel-*.o: ns-eel*.h - -vpath %.cpp ../lice ../swell -vpath %.mm ../swell -vpath %.c ../ - -ifdef MAXLOOP - CFLAGS += -DNSEEL_LOOPFUNC_SUPPORT_MAXLEN=$(MAXLOOP) -else - CFLAGS += -DNSEEL_LOOPFUNC_SUPPORT_MAXLEN=0 -endif - -ifdef DISASSEMBLE - CFLAGS += -DEELSCRIPT_DO_DISASSEMBLE -endif - -ifndef NO_GFX - LICE_OBJS += lice.o lice_image.o lice_line.o lice_ico.o lice_bmp.o lice_textnew.o lice_text.o lice_arc.o - CFLAGS += -DEEL_LICE_WANT_STANDALONE - - ifeq ($(UNAME_S),Darwin) - CLANG_VER := $(shell clang --version|head -n 1| sed 's/.*version \([0-9][0-9]*\).*/\1/' ) - CLANG_GT_9 := $(shell [ $(CLANG_VER) -gt 9 ] && echo true ) - ifeq ($(CLANG_GT_9),true) - CFLAGS += -mmacosx-version-min=10.7 -stdlib=libc++ - else - CFLAGS += -mmacosx-version-min=10.5 - endif - SWELL_OBJS += swell-wnd.o swell-gdi.o swell.o swell-misc.o swell-dlg.o swell-menu.o swell-kb.o - LFLAGS += -lobjc -framework Cocoa -framework Carbon - else - - CFLAGS += -DSWELL_LICE_GDI -DSWELL_EXTRA_MINIMAL - ifdef GDK2 - CFLAGS += -DSWELL_TARGET_GDK=2 $(shell pkg-config --cflags gdk-2.0) - LFLAGS += $(shell pkg-config --libs gdk-2.0) -lX11 -lXi - else - CFLAGS += -DSWELL_TARGET_GDK=3 $(shell pkg-config --cflags gdk-3.0) - LFLAGS += $(shell pkg-config --libs gdk-3.0) -lX11 -lXi - endif - ifndef NOFREETYPE - CFLAGS += -DSWELL_FREETYPE $(shell pkg-config --cflags freetype2) - LFLAGS += $(shell pkg-config --libs freetype2) - endif - - SWELL_OBJS += swell-wnd-generic.o swell-gdi-lice.o swell.o swell-misc-generic.o \ - swell-dlg-generic.o swell-menu-generic.o swell-kb-generic.o \ - swell-gdi-generic.o swell-ini.o swell-generic-gdk.o - - LFLAGS += -ldl -lGL - endif - -endif - -ifdef PORTABLE - CFLAGS += -DEEL_TARGET_PORTABLE -else - ifeq ($(UNAME_S),Darwin) - ifeq ($(ARCH),x86_64) - ASM_FMT = macho64 - NASM_OPTS = --prefix _ - OBJS2 += asm-nseel-x64-sse.o - endif - endif - ifeq ($(UNAME_S),Linux) - ifeq ($(ARCH),x86_64) - ASM_FMT = elf64 - NASM_OPTS = - OBJS2 += asm-nseel-x64-sse.o - endif - endif - -asm-nseel-x64-sse.o: asm-nseel-x64-sse.asm - nasm -D AMD64ABI -f $(ASM_FMT) $(NASM_OPTS) asm-nseel-x64-sse.asm - -endif -CXXFLAGS=$(CFLAGS) - -ifeq ($(CXX),g++) - GCC_VER := $(shell $(CXX) --version|head -n 1| sed 's/.* \([0-9][0-9]*\)[.][0-9.]*/\1/' ) - GCC_GT_10 := $(shell [ "$(GCC_VER)" -gt 10 ] && echo true ) - ifeq ($(GCC_GT_10),true) - CXXFLAGS += -std=c++03 - endif -endif - -gen-yacc: - yacc -v -d eel2.y - -gen-lex: # the output of this, lex.nseel.c, is unused because we have a handwritten parser instead - flex eel2.l - -%.o : %.mm - $(CXX) $(CXXFLAGS) -c -o $@ $^ - -loose_eel: loose_eel.o $(OBJS) $(OBJS2) $(SWELL_OBJS) $(LICE_OBJS) - g++ -o $@ $^ $(CXXFLAGS) $(LFLAGS) - -eel_pp: eel_pp.o $(OBJS) $(OBJS2) - g++ -o $@ $^ $(CXXFLAGS) $(LFLAGS) - -clean: - -rm -f -- loose_eel loose_eel.o eel_pp.o eel_pp $(OBJS) $(SWELL_OBJS) $(LICE_OBJS) - -.PHONY: clean gen-lex gen-yacc diff --git a/oversampling/WDL/eel2/a2i.php b/oversampling/WDL/eel2/a2i.php deleted file mode 100644 index 1c94150..0000000 --- a/oversampling/WDL/eel2/a2i.php +++ /dev/null @@ -1,222 +0,0 @@ -1) - $end_restore = substr($line,1-strlen($lastchunk)); - else $end_restore=""; - - $sline = substr($sline,1,strlen($sline)-1-strlen($lastchunk)); - - // get rid of chars we can ignore - $sline=preg_replace("/%\d+/","__TEMP_REPLACE__", $sline); - - $sline=str_replace("\\n","", $sline); - $sline=str_replace("\"","", $sline); - $sline=str_replace("$","", $sline); - $sline=str_replace("%","", $sline); - - - // get rid of excess whitespace, especially around commas - $sline=str_replace(" "," ", $sline); - $sline=str_replace(" "," ", $sline); - $sline=str_replace(" "," ", $sline); - $sline=str_replace(", ",",", $sline); - $sline=str_replace(" ,",",", $sline); - - $sline=preg_replace("/st\\(([0-9]+)\\)/","FPREG_$1",$sline); - - - if (preg_match("/^([0-9]+):/",trim($sline))) - { - $d = (int) $sline; - $a = strstr($sline,":"); - if ($a) $sline = substr($a,1); - - if (isset($btfut[$d]) && $btfut[$d] != "") $thislbl = $btfut[$d]; - else $thislbl = "label_" . $labelcnt++; - - $btfut[$d]=""; - $bthist[$d] = $thislbl; - - fputs($out,$thislbl . ":\n"); - } - - $sploded = explode(" ",trim($sline)); - if ($sline != "" && count($sploded)>0) - { - $inst = trim($sploded[0]); - $suffix = ""; - - $instline = strstr($sline,$inst); - $beg_restore .= substr($sline,0,-strlen($instline)); - - $parms = trim(substr($instline,strlen($inst))); - - if ($inst=="j") $inst="jmp"; - - //if ($inst == "fdiv" && $parms == "") $inst="fdivr"; - - if ($inst != "call" && substr($inst,-2) == "ll") $suffix = "ll"; - else if ($inst != "call" && $inst != "fmul" && substr($inst,-1) == "l") $suffix = "l"; - else if (substr($inst,0,1)=="f" && $inst != "fcos" && $inst != "fsincos" && $inst != "fabs" && $inst != "fchs" && substr($inst,-1) == "s") $suffix = "s"; - - - if ($suffix != "" && $inst != "jl") $inst = substr($inst,0,-strlen($suffix)); - - $parms = preg_replace("/\\((.{2,3}),(.{2,3})\\)/","($1+$2)",$parms); - - $parms=preg_replace("/EEL_F_SUFFIX (-?[0-9]+)\\((.*)\\)/","qword ptr [$2+$1]",$parms); - $parms=preg_replace("/EEL_F_SUFFIX \\((.*)\\)/","qword ptr [$1]",$parms); - - if ($inst == "sh" && $suffix == "ll") { $suffix="l"; $inst="shl"; } - - if ($suffix == "ll" || ($suffix == "l" && substr($inst,0,1) == "f" && substr($inst,0,2) != "fi")) $suffixstr = "qword ptr "; - else if ($suffix == "l") $suffixstr = "dword ptr "; - else if ($suffix == "s") $suffixstr = "dword ptr "; - else $suffixstr = ""; - $parms=preg_replace("/(-?[0-9]+)\\((.*)\\)/",$suffixstr . "[$2+$1]",$parms); - $parms=preg_replace("/\\((.*)\\)/",$suffixstr . "[$1]",$parms); - - - $parms=str_replace("EEL_F_SUFFIX","qword ptr", $parms); - - $plist = explode(",",$parms); - if (count($plist) > 2) echo "Warning: too many parameters $parms!\n"; - else if (count($plist)==2) - { - $parms = trim($plist[1]) . ", " . trim($plist[0]); - } - else - { - } - - if ($inst=="fsts") $inst="fstsw"; - if ($inst=="call" && substr($parms,0,1) == "*") $parms=substr($parms,1); - if (substr($inst,0,1) == "j") - { - if (substr($parms,-1) == "f") - { - $d = (int) substr($parms,0,-1); - if (isset($btfut[$d]) && $btfut[$d] != "") $thislbl = $btfut[$d]; - else $btfut[$d] = $thislbl = "label_" . $labelcnt++; - $parms = $thislbl; - } - else if (substr($parms,-1) == "b") - { - $d = (int) substr($parms,0,-1); - if ($bthist[$d]=="") echo "Error resolving label $parms\n"; - $parms = $bthist[$d]; - } - } - if (stristr($parms,"[0xfefefefe]")) - { - if ($inst == "fmul" || $inst=="fadd" || $inst == "fcomp") - { - if ($inst=="fmul") $hdr="0x0D"; - if ($inst=="fadd") $hdr="0x05"; - if ($inst=="fcomp") $hdr="0x1D"; - - fputs($out,"_emit 0xDC; // $inst qword ptr [0xfefefefe]\n"); - fputs($out,"_emit $hdr;\n"); - fputs($out,"_emit 0xFE;\n"); - fputs($out,"_emit 0xFE;\n"); - fputs($out,"_emit 0xFE;\n"); - fputs($out,"_emit 0xFE;\n"); - $nowrite=1; - } - } - - - $sline = $inst; - if ($parms !="") $sline .= " " . $parms; - $sline .= ";"; - - } - - $sline=preg_replace("/FPREG_([0-9]+)/","st($1)",$sline); - $line = $beg_restore . $sline . $end_restore; - - } - - - } - } - - if (!$nowrite) - { - if (strstr($line,"__TEMP_REPLACE__")) - { - $a = strstr($line,"//REPLACE="); - if ($a === false) die ("__TEMP_REPLACE__ found, no REPLACE=\n"); - $line=str_replace("__TEMP_REPLACE__",substr($a,10),$line); - } - fputs($out,$line . "\n"); - } -} - -if ($inblock) echo "Error (ended in __asm__ block???)\n"; - - -fclose($in); -fclose($out); - -}; - -process_file("asm-nseel-x86-gcc.c" , "asm-nseel-x86-msvc.c"); -// process_file("asm-miscfunc-x86-gcc.c" , "asm-miscfunc-x86-msvc.c"); -//process_file("asm-megabuf-x86-gcc.c" , "asm-megabuf-x86-msvc.c"); - -?> diff --git a/oversampling/WDL/eel2/asm-nseel-aarch64-gcc.c b/oversampling/WDL/eel2/asm-nseel-aarch64-gcc.c deleted file mode 100644 index c822107..0000000 --- a/oversampling/WDL/eel2/asm-nseel-aarch64-gcc.c +++ /dev/null @@ -1,1270 +0,0 @@ -#define FUNCTION_MARKER "mov x0, x0\n" \ - "mov x1, x1\n" \ - "mov x2, x2\n" - -#if EEL_F_SIZE == 8 - -void nseel_asm_1pdd(void) -{ - - __asm__ __volatile__( - FUNCTION_MARKER - "mov x3, 0xdead\n" - "movk x3, 0xbeef, lsl 16\n" - "movk x3, 0xbeef, lsl 32\n" - "str x30, [sp, #-16]!\n" - "blr x3\n" - "ldr x30, [sp], #16\n" - FUNCTION_MARKER - :: ); -} - -void nseel_asm_2pdd(void) -{ - - __asm__ __volatile__( - FUNCTION_MARKER - "mov x3, 0xdead\n" - "movk x3, 0xbeef, lsl 16\n" - "movk x3, 0xbeef, lsl 32\n" - "fmov d2, d0\n" - "fmov d0, d1\n" - "fmov d1, d2\n" - "str x30, [sp, #-16]!\n" - "blr x3\n" - "ldr x30, [sp], #16\n" - FUNCTION_MARKER - :: ); -}; - -void nseel_asm_2pdds(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "mov x3, 0xdead\n" - "movk x3, 0xbeef, lsl 16\n" - "movk x3, 0xbeef, lsl 32\n" - "stp x1, x30, [sp, #-16]!\n" - "fmov d1, d0\n" - "ldr d0, [x1]\n" - "blr x3\n" - "ldp x0, x30, [sp], 16\n" - "str d0, [x0]\n" - FUNCTION_MARKER - :: ); -} - -#else // 32 bit floating point calls - -#error no 32 bit float support - -#endif - -//--------------------------------------------------------------------------------------------------------------- - - -void nseel_asm_invsqrt(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "mov x0, 0x59df\n" - "movk x0, 0x5f37, lsl 16\n" - "fcvt s2, d0\n" - "ldr d3, [x21, #32]\n" - "fmov w1, s2\n" - "fmul d0, d0, d3\n" - "asr w1, w1, #1\n" - - "sub w0, w0, w1\n" - - "fmov s4, w0\n" - "fcvt d1, s4\n" - - "ldr d2, [x21, #40]\n" - "fmul d0, d0, d1\n" - "fmul d0, d0, d1\n" - "fadd d0, d0, d2\n" - "fmul d0, d0, d1\n" - - FUNCTION_MARKER - ); -} - -void nseel_asm_dbg_getstackptr(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "mov x0, sp\n" - "ucvtf d0, x0\n" - FUNCTION_MARKER - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_sqr(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fmul d0, d0, d0\n" - FUNCTION_MARKER - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_abs(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fabs d0, d0\n" - FUNCTION_MARKER - ); -} - - -#define FLUSH_TO_ZERO \ - "ldr x1, [x1]\n" \ - "mov x3, #0x10000000000000\n" \ - "mov x2, #0x20000000000000\n" \ - "add x1, x1, x3\n" \ - "and x1, x1, #0x7ff0000000000000\n" \ - "cmp x1, x2\n" \ - "bgt 0f\n" \ - "str xzr, [x0]\n" \ - "0:\n" - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_assign(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d0, [x0]\n" - "mov x0, x1\n" - "str d0, [x1]\n" - FLUSH_TO_ZERO - FUNCTION_MARKER - ); -} -// -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_assign_fromfp(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "mov x0, x1\n" - "str d0, [x1]\n" - FLUSH_TO_ZERO - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_assign_fast(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d0, [x0]\n" - "mov x0, x1\n" - "str d0, [x1]\n" - FUNCTION_MARKER - ); -} -// -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_assign_fast_fromfp(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "mov x0, x1\n" - "str d0, [x1]\n" - FUNCTION_MARKER - ); -} - - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_add(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fadd d0, d1, d0\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_add_op(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d1, [x1]\n" - "fadd d0, d1, d0\n" - "mov x0, x1\n" - "str d0, [x1]\n" - FLUSH_TO_ZERO - FUNCTION_MARKER - ); -} - -void nseel_asm_add_op_fast(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d1, [x1]\n" - "fadd d0, d1, d0\n" - "mov x0, x1\n" - "str d0, [x1]\n" - FUNCTION_MARKER - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_sub(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fsub d0, d1, d0\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_sub_op(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d1, [x1]\n" - "fsub d0, d1, d0\n" - "mov x0, x1\n" - "str d0, [x1]\n" - FLUSH_TO_ZERO - FUNCTION_MARKER - ); -} - -void nseel_asm_sub_op_fast(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d1, [x1]\n" - "fsub d0, d1, d0\n" - "mov x0, x1\n" - "str d0, [x1]\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_mul(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fmul d0, d1, d0\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_mul_op(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d1, [x1]\n" - "fmul d0, d0, d1\n" - "mov x0, x1\n" - "str d0, [x1]\n" - FLUSH_TO_ZERO - FUNCTION_MARKER - ); -} - -void nseel_asm_mul_op_fast(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d1, [x1]\n" - "fmul d0, d0, d1\n" - "mov x0, x1\n" - "str d0, [x1]\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_div(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fdiv d0, d1, d0\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_div_op(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d1, [x1]\n" - "fdiv d0, d1, d0\n" - "mov x0, x1\n" - "str d0, [x1]\n" - FLUSH_TO_ZERO - FUNCTION_MARKER - ); -} - -void nseel_asm_div_op_fast(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d1, [x1]\n" - "fdiv d0, d1, d0\n" - "mov x0, x1\n" - "str d0, [x1]\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_mod(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fabs d0, d0\n" - "fabs d1, d1\n" - "fcvtzu x1, d0\n" - "fcvtzu x0, d1\n" - "udiv x2, x0, x1\n" - "msub x0, x2, x1, x0\n" - "ucvtf d0, x0\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_shl(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcvtzs w0, d1\n" - "fcvtzs w1, d0\n" - "lsl w0, w0, w1\n" - "scvtf d0, w0\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_shr(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcvtzs w0, d1\n" - "fcvtzs w1, d0\n" - "asr w0, w0, w1\n" - "scvtf d0, w0\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_mod_op(void) -{ - - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d1, [x1]\n" - "fabs d0, d0\n" - "fabs d1, d1\n" - "fcvtzu x3, d0\n" - "fcvtzu x0, d1\n" - "udiv x2, x0, x3\n" - "msub x0, x2, x3, x0\n" - "ucvtf d0, x0\n" - - "str d0, [x1]\n" - "mov x0, x1\n" - FUNCTION_MARKER - ); - -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_or(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcvtzs x0, d0\n" - "fcvtzs x1, d1\n" - "orr x0, x0, x1\n" - "scvtf d0, x0\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_or0(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcvtzs x0, d0\n" - "scvtf d0, x0\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_or_op(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d1, [x1]\n" - "fcvtzs x0, d0\n" - "fcvtzs x3, d1\n" - "orr x0, x0, x3\n" - "scvtf d0, x0\n" - "mov x0, x1\n" - "str d0, [x1]\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_xor(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcvtzs x0, d0\n" - "fcvtzs x1, d1\n" - "eor x0, x0, x1\n" - "scvtf d0, x0\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_xor_op(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d1, [x1]\n" - "fcvtzs x0, d0\n" - "fcvtzs x3, d1\n" - "eor x0, x0, x3\n" - "scvtf d0, x0\n" - "mov x0, x1\n" - "str d0, [x1]\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_and(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcvtzs x0, d0\n" - "fcvtzs x1, d1\n" - "and x0, x0, x1\n" - "scvtf d0, x0\n" - FUNCTION_MARKER - );} - -void nseel_asm_and_op(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d1, [x1]\n" - "fcvtzs x0, d0\n" - "fcvtzs x3, d1\n" - "and x0, x0, x3\n" - "scvtf d0, x0\n" - "mov x0, x1\n" - "str d0, [x1]\n" - FUNCTION_MARKER - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_uminus(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fneg d0, d0\n" - FUNCTION_MARKER - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_sign(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fmov d1, #-1.0\n" - "fmov d2, #1.0\n" - "fcmpe d0, #0.0\n" - "fcsel d0, d0, d1, gt\n" - "fcsel d0, d0, d2, lt\n" - FUNCTION_MARKER - :: - ); -} - - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_bnot(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "cmp w0, #0\n" - "cset w0, eq\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_if(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "str x30, [sp, #-16]!\n" - "mov x1, 0xdead\n" - "movk x1, 0xbeef, lsl 16\n" - "movk x1, 0xbeef, lsl 32\n" - "mov x2, 0xdead\n" - "movk x2, 0xbeef, lsl 16\n" - "movk x2, 0xbeef, lsl 32\n" - "cmp w0, #0\n" - "csel x1, x1, x2, ne\n" - "blr x1\n" - "ldr x30, [sp], #16\n" - FUNCTION_MARKER - :: ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_repeat(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcvtzs w3, d0\n" - "cmp w3, #0\n" - "ble 0f\n" -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - "mov x2, %0\n" - "movk x2, %1, lsl 16\n" - "cmp w3, w2\n" - "csel w3, w2, w3, gt\n" -#endif - "stp x24, x30, [sp, #-16]!\n" - - "mov x24, 0xdead\n" - "movk x24, 0xbeef, lsl 16\n" - "movk x24, 0xbeef, lsl 32\n" - "1:\n" - "stp x3, x22, [sp, #-16]!\n" - "blr x24\n" - "ldp x3, x22, [sp], 16\n" - "sub x3, x3, #1\n" - "cmp x3, #0\n" - "bgt 1b\n" - "ldp x24, x30, [sp], 16\n" - "0:\n" - FUNCTION_MARKER -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - ::"g" (NSEEL_LOOPFUNC_SUPPORT_MAXLEN&65535), - "g" (NSEEL_LOOPFUNC_SUPPORT_MAXLEN>>16) -#endif - ); -} - -void nseel_asm_repeatwhile(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - "mov x3, %0\n" - "movk x3, %1, lsl 16\n" -#endif - "stp x24, x30, [sp, #-16]!\n" - - "mov x24, 0xdead\n" - "movk x24, 0xbeef, lsl 16\n" - "movk x24, 0xbeef, lsl 32\n" - "0:\n" - "stp x3, x22, [sp, #-16]!\n" - "blr x24\n" - "ldp x3, x22, [sp], 16\n" - "cmp w0, #0\n" -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - "beq 0f\n" - "sub x3, x3, #1\n" - "cmp x3, #0\n" - "bne 0b\n" - "0:\n" -#else - "bne 0b\n" -#endif - "ldp x24, x30, [sp], 16\n" - - FUNCTION_MARKER -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - ::"g" (NSEEL_LOOPFUNC_SUPPORT_MAXLEN&65535), - "g" (NSEEL_LOOPFUNC_SUPPORT_MAXLEN>>16) -#endif - ); -} - - -void nseel_asm_band(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "cmp w0, #0\n" - "beq 0f\n" - "mov x3, 0xdead\n" - "movk x3, 0xbeef, lsl 16\n" - "movk x3, 0xbeef, lsl 32\n" - "str x30, [sp, #-16]!\n" - "blr x3\n" - "ldr x30, [sp], #16\n" - "0:\n" - FUNCTION_MARKER - :: ); -} - -void nseel_asm_bor(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "cmp w0, #0\n" - "bne 0f\n" - "mov x3, 0xdead\n" - "movk x3, 0xbeef, lsl 16\n" - "movk x3, 0xbeef, lsl 32\n" - "str x30, [sp, #-16]!\n" - "blr x3\n" - "ldr x30, [sp], #16\n" - "0:\n" - FUNCTION_MARKER - :: ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_equal(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d2, [x21]\n" - "fsub d0, d0, d1\n" - "fabs d0, d0\n" - "fcmp d0, d2\n" - "cset w0, lt\n" - FUNCTION_MARKER - :: - ); -} -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_equal_exact(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmp d1, d0\n" - "cset w0, eq\n" - FUNCTION_MARKER - :: - ); -} -// -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_notequal_exact(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmp d1, d0\n" - "cset w0, ne\n" - FUNCTION_MARKER - :: - ); -} -// -// -// -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_notequal(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d2, [x21]\n" - "fsub d0, d0, d1\n" - "fabs d0, d0\n" - "fcmp d0, d2\n" - "cset w0, ge\n" - FUNCTION_MARKER - :: - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_below(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmp d1, d0\n" - "cset w0, lt\n" - FUNCTION_MARKER - :: - ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_beloweq(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmp d1, d0\n" - "cset w0, le\n" - FUNCTION_MARKER - :: - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_above(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmp d1, d0\n" - "cset w0, gt\n" - FUNCTION_MARKER - :: - ); -} - -void nseel_asm_aboveeq(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmp d1, d0\n" - "cset w0, ge\n" - FUNCTION_MARKER - :: - ); -} - - - -void nseel_asm_min(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d0, [x0]\n" - "ldr d1, [x1]\n" - "fcmp d1, d0\n" - "csel x0, x1, x0, lt\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_max(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d0, [x0]\n" - "ldr d1, [x1]\n" - "fcmp d1, d0\n" - "csel x0, x1, x0, gt\n" - FUNCTION_MARKER - ); -} - - - -void nseel_asm_min_fp(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmp d1, d0\n" - "fcsel d0, d1, d0, lt\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_max_fp(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmp d1, d0\n" - "fcsel d0, d1, d0, gt\n" - FUNCTION_MARKER - ); -} - - - - - - - -void _asm_generic3parm(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "str x30, [sp, #-16]!\n" // input: r0 last, r1=second to last, r2=third to last - // output: r0=context, r1=r2, r2=r1, r3=r0 - "mov x3, x0\n" // r0 (last parameter) -> r3 - - "mov x0, 0xdead\n" // r0 is first parm (context) - "movk x0, 0xbeef, lsl 16\n" - "movk x0, 0xbeef, lsl 32\n" - - "mov x4, 0xdead\n" - "movk x4, 0xbeef, lsl 16\n" - "movk x4, 0xbeef, lsl 32\n" - - "mov x5, x1\n" // swap x1/x2 - "mov x1, x2\n" - "mov x2, x5\n" - - "blr x4\n" - "ldr x30, [sp], #16\n" - FUNCTION_MARKER - :: - ); -} - -void _asm_generic3parm_retd(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "str x30, [sp, #-16]!\n" // input: r0 last, r1=second to last, r2=third to last - "mov x3, x0\n" // r0 (last parameter) -> r3 - - "mov x0, 0xdead\n" // r0 is first parm (context) - "movk x0, 0xbeef, lsl 16\n" - "movk x0, 0xbeef, lsl 32\n" - - "mov x4, 0xdead\n" - "movk x4, 0xbeef, lsl 16\n" - "movk x4, 0xbeef, lsl 32\n" - - "mov x5, x1\n" // swap x1/x2 - "mov x1, x2\n" - "mov x2, x5\n" - - "blr x4\n" - "ldr x30, [sp], #16\n" - FUNCTION_MARKER - :: - ); -} - - -void _asm_generic2parm(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "str x30, [sp, #-16]!\n" // input: r0 last, r1=second to last - "mov x2, x0\n" - - "mov x0, 0xdead\n" // r0 is first parm (context) - "movk x0, 0xbeef, lsl 16\n" - "movk x0, 0xbeef, lsl 32\n" - - "mov x4, 0xdead\n" - "movk x4, 0xbeef, lsl 16\n" - "movk x4, 0xbeef, lsl 32\n" - - "blr x4\n" - "ldr x30, [sp], #16\n" - FUNCTION_MARKER - :: - ); -} - - -void _asm_generic2parm_retd(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "str x30, [sp, #-16]!\n" // input: r0 last, r1=second to last - "mov x2, x0\n" - - "mov x0, 0xdead\n" // r0 is first parm (context) - "movk x0, 0xbeef, lsl 16\n" - "movk x0, 0xbeef, lsl 32\n" - - "mov x4, 0xdead\n" - "movk x4, 0xbeef, lsl 16\n" - "movk x4, 0xbeef, lsl 32\n" - - "blr x4\n" - "ldr x30, [sp], #16\n" - FUNCTION_MARKER - :: - ); -} - -void _asm_generic2xparm_retd(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "str x30, [sp, #-16]!\n" // input: r0 last, r1=second to last - "mov x2, x1\n" - "mov x3, x0\n" - - "mov x0, 0xdead\n" // r0 is first parm (context) - "movk x0, 0xbeef, lsl 16\n" - "movk x0, 0xbeef, lsl 32\n" - - "mov x1, 0xdead\n" // second parm - "movk x1, 0xbeef, lsl 16\n" - "movk x1, 0xbeef, lsl 32\n" - - "mov x4, 0xdead\n" - "movk x4, 0xbeef, lsl 16\n" - "movk x4, 0xbeef, lsl 32\n" - - "blr x4\n" - "ldr x30, [sp], #16\n" - FUNCTION_MARKER - :: - ); -} - - -void _asm_generic1parm(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "str x30, [sp, #-16]!\n" - "mov x1, x0\n" - - "mov x0, 0xdead\n" // r0 is first parm (context) - "movk x0, 0xbeef, lsl 16\n" - "movk x0, 0xbeef, lsl 32\n" - - "mov x4, 0xdead\n" - "movk x4, 0xbeef, lsl 16\n" - "movk x4, 0xbeef, lsl 32\n" - - "blr x4\n" - "ldr x30, [sp], #16\n" - FUNCTION_MARKER - :: - ); -} - - - -void _asm_generic1parm_retd(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "str x30, [sp, #-16]!\n" - "mov x1, x0\n" - - "mov x0, 0xdead\n" // r0 is first parm (context) - "movk x0, 0xbeef, lsl 16\n" - "movk x0, 0xbeef, lsl 32\n" - - "mov x4, 0xdead\n" - "movk x4, 0xbeef, lsl 16\n" - "movk x4, 0xbeef, lsl 32\n" - - "blr x4\n" - "ldr x30, [sp], #16\n" - - FUNCTION_MARKER - :: - ); -} - - - - -void _asm_megabuf(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d1, [x20, #-8]\n" - "fadd d0, d0, d1\n" - "fcvtzu w3, d0\n" - "asr w2, w3, %0\n" - "bic w2, w2, #7\n" // r2 is page index*8 - "cmp w2, %1\n" - "bhs 0f\n" - - "add x2, x2, x20\n" - "ldr x2, [x2]\n" - "cmp x2, #0\n" - "beq 0f\n" - - "mov x0, %2\n" - "and x3, x3, x0\n" // r3 mask item in slot - "add x0, x2, x3, lsl #3\n" // set result - "b 1f\n" - "0:\n" - - // failed, call stub function - "mov x2, 0xdead\n" - "movk x2, 0xbeef, lsl 16\n" - "movk x2, 0xbeef, lsl 32\n" - "str x30, [sp, #-16]!\n" - "mov x0, x20\n" // first parameter: blocks - "mov x1, x3\n" // second parameter: slot index - "blr x2\n" - "ldr x30, [sp], #16\n" - "1:\n" - - FUNCTION_MARKER - :: - "i" (NSEEL_RAM_ITEMSPERBLOCK_LOG2 - 3/*log2(sizeof(void*))*/), - "i" (NSEEL_RAM_BLOCKS*sizeof(void*)), - "i" (NSEEL_RAM_ITEMSPERBLOCK-1) - ); -} - - -void _asm_gmegabuf(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "mov x0, 0xdead\n" - "movk x0, 0xbeef, lsl 16\n" - "movk x0, 0xbeef, lsl 32\n" - - "mov x2, 0xdead\n" - "movk x2, 0xbeef, lsl 16\n" - "movk x2, 0xbeef, lsl 32\n" - - "ldr d1, [x20, #-8]\n" - "fadd d0, d0, d1\n" - - "fcvtzu w1, d0\n" - - "str x30, [sp, #-16]!\n" - - "blr x2\n" - - "ldr x30, [sp], #16\n" - - FUNCTION_MARKER - :: - ); -} - - -void nseel_asm_fcall(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "mov x0, 0xdead\n" - "movk x0, 0xbeef, lsl 16\n" - "movk x0, 0xbeef, lsl 32\n" - "str x30, [sp, #-16]!\n" - "blr x0\n" - "ldr x30, [sp], #16\n" - FUNCTION_MARKER - ); -} - - - -void nseel_asm_stack_push(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d0, [x0]\n" - - "mov x3, 0xdead\n" // r3 is stack - "movk x3, 0xbeef, lsl 16\n" - "movk x3, 0xbeef, lsl 32\n" - "ldr x0, [x3]\n" - - "add x0, x0, #8\n" - - "mov x2, 0xdead\n" - "movk x2, 0xbeef, lsl 16\n" - "movk x2, 0xbeef, lsl 32\n" - "and x0, x0, x2\n" - "mov x2, 0xdead\n" - "movk x2, 0xbeef, lsl 16\n" - "movk x2, 0xbeef, lsl 32\n" - "orr x0, x0, x2\n" - - "str x0, [x3]\n" - "str d0, [x0]\n" - - FUNCTION_MARKER - ); -} - -void nseel_asm_stack_pop(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "mov x3, 0xdead\n" // r3 is stack - "movk x3, 0xbeef, lsl 16\n" - "movk x3, 0xbeef, lsl 32\n" - "ldr x1, [x3]\n" - "ldr d0, [x1]\n" - "sub x1, x1, #8\n" - "mov x2, 0xdead\n" - "movk x2, 0xbeef, lsl 16\n" - "movk x2, 0xbeef, lsl 32\n" - "str d0, [x0]\n" - "and x1, x1, x2\n" - "mov x2, 0xdead\n" - "movk x2, 0xbeef, lsl 16\n" - "movk x2, 0xbeef, lsl 32\n" - "orr x1, x1, x2\n" - - "str x1, [x3]\n" - FUNCTION_MARKER - ); -} - - - -void nseel_asm_stack_pop_fast(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "mov x3, 0xdead\n" // r3 is stack - "movk x3, 0xbeef, lsl 16\n" - "movk x3, 0xbeef, lsl 32\n" - "ldr x1, [x3]\n" - "mov x0, x1\n" - "sub x1, x1, #8\n" - "mov x2, 0xdead\n" - "movk x2, 0xbeef, lsl 16\n" - "movk x2, 0xbeef, lsl 32\n" - "and x1, x1, x2\n" - "mov x2, 0xdead\n" - "movk x2, 0xbeef, lsl 16\n" - "movk x2, 0xbeef, lsl 32\n" - "orr x1, x1, x2\n" - "str x1, [x3]\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_stack_peek(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "mov x3, 0xdead\n" // r3 is stack - "movk x3, 0xbeef, lsl 16\n" - "movk x3, 0xbeef, lsl 32\n" - - "fcvtzs w2, d0\n" - - "ldr x1, [x3]\n" - "sub x1, x1, x2, lsl #3\n" - "mov x2, 0xdead\n" - "movk x2, 0xbeef, lsl 16\n" - "movk x2, 0xbeef, lsl 32\n" - "and x1, x1, x2\n" - "mov x2, 0xdead\n" - "movk x2, 0xbeef, lsl 16\n" - "movk x2, 0xbeef, lsl 32\n" - "orr x0, x1, x2\n" - FUNCTION_MARKER - ); -} - - -void nseel_asm_stack_peek_top(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "mov x3, 0xdead\n" // r3 is stack - "movk x3, 0xbeef, lsl 16\n" - "movk x3, 0xbeef, lsl 32\n" - "ldr x0, [x3]\n" - FUNCTION_MARKER - ); -} - - -void nseel_asm_stack_peek_int(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "mov x3, 0xdead\n" // r3 is stack - "movk x3, 0xbeef, lsl 16\n" - "movk x3, 0xbeef, lsl 32\n" - - "mov x2, 0xdead\n" - "movk x2, 0xbeef, lsl 16\n" - "movk x2, 0xbeef, lsl 32\n" - - "ldr x1, [x3]\n" - "sub x1, x1, x2\n" - "mov x2, 0xdead\n" - "movk x2, 0xbeef, lsl 16\n" - "movk x2, 0xbeef, lsl 32\n" - "and x1, x1, x2\n" - "mov x2, 0xdead\n" - "movk x2, 0xbeef, lsl 16\n" - "movk x2, 0xbeef, lsl 32\n" - "orr x0, x1, x2\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_stack_exch(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "mov x3, 0xdead\n" // r3 is stack - "movk x3, 0xbeef, lsl 16\n" - "movk x3, 0xbeef, lsl 32\n" - "ldr x1, [x3]\n" - "ldr d0, [x0]\n" - "ldr d1, [x1]\n" - "str d0, [x1]\n" - "str d1, [x0]\n" - FUNCTION_MARKER - ); -} - - -void nseel_asm_booltofp(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "cmp w0, #0\n" - "fmov d0, #1.0\n" - "movi d1, #0\n" - "fcsel d0, d0, d1, ne\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_fptobool(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d1, [x21]\n" - "fabs d0, d0\n" - "fcmp d0, d1\n" - "cset w0, ge\n" - FUNCTION_MARKER - :: - ); -} - -void nseel_asm_fptobool_rev(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ldr d1, [x21]\n" - "fabs d0, d0\n" - "fcmp d0, d1\n" - "cset w0, lt\n" - FUNCTION_MARKER - :: - ); -} - diff --git a/oversampling/WDL/eel2/asm-nseel-aarch64-msvc.asm b/oversampling/WDL/eel2/asm-nseel-aarch64-msvc.asm deleted file mode 100644 index a585912..0000000 --- a/oversampling/WDL/eel2/asm-nseel-aarch64-msvc.asm +++ /dev/null @@ -1,1418 +0,0 @@ -NSEEL_RAM_ITEMSPERBLOCK_LOG2 equ 16 -NSEEL_RAM_BLOCKS_LOG2 equ 9 -NSEEL_LOOPFUNC_SUPPORT_MAXLEN equ 1048576 - -NSEEL_RAM_BLOCKS equ (1 << NSEEL_RAM_BLOCKS_LOG2) -NSEEL_RAM_ITEMSPERBLOCK equ (1< 0 - mov x2, (NSEEL_LOOPFUNC_SUPPORT_MAXLEN & 65535) - movk x2, (NSEEL_LOOPFUNC_SUPPORT_MAXLEN>>16), lsl 16 - cmp w3, w2 - csel w3, w2, w3, gt - ] - stp fp, lr, [sp, #-48]! - mov fp, sp - str x24, [sp, #16] - - mov x24, 0xdead - movk x24, 0xbeef, lsl 16 - movk x24, 0xbeef, lsl 32 -|rep_lz| - stp x3, x22, [sp, #32] - blr x24 - ldp x3, x22, [sp, #32] - sub x3, x3, #1 - cmp x3, #0 - bgt |rep_lz| - ldr x24, [sp, #16] - ldp fp, lr, [sp], #48 -|rep_lz2| - mov x1, x1 - - ENDP - -|nseel_asm_repeatwhile| PROC - - - mov x1, x1 - [ NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - mov x3, (NSEEL_LOOPFUNC_SUPPORT_MAXLEN & 65535) - movk x3, (NSEEL_LOOPFUNC_SUPPORT_MAXLEN>>16), lsl 16 - ] - stp fp, lr, [sp, #-48]! - str x24, [sp, #16] - - mov x24, 0xdead - movk x24, 0xbeef, lsl 16 - movk x24, 0xbeef, lsl 32 -|repw_lz| - stp x3, x22, [sp, #32] - blr x24 - ldp x3, x22, [sp, #32] - cmp w0, #0 - [ NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - beq |repw_lz2| - sub x3, x3, #1 - cmp x3, #0 - bne |repw_lz| -|repw_lz2| - ] - [ NSEEL_LOOPFUNC_SUPPORT_MAXLEN == 0 - bne |repw_lz| - ] - ldr x24, [sp, #16] - ldp fp, lr, [sp], #48 - - mov x1, x1 - - ENDP - - -|nseel_asm_band| PROC - - - mov x1, x1 - cmp w0, #0 - beq |band_chk| - mov x3, 0xdead - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - stp fp, lr, [sp, #-16]! - mov fp, sp - blr x3 - ldp fp, lr, [sp], #16 -|band_chk| - mov x1, x1 - ENDP - -|nseel_asm_bor| PROC - - - mov x1, x1 - cmp w0, #0 - bne |bor_chk| - mov x3, 0xdead - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - stp fp, lr, [sp, #-16]! - mov fp, sp - blr x3 - ldp fp, lr, [sp], #16 -|bor_chk| - mov x1, x1 - ENDP - - -|nseel_asm_equal| PROC - - - mov x1, x1 - ldr d2, [x21] - fsub d0, d0, d1 - fabs d0, d0 - fcmp d0, d2 - cset w0, lt - mov x1, x1 - - ENDP - -|nseel_asm_equal_exact| PROC - - - mov x1, x1 - fcmp d1, d0 - cset w0, eq - mov x1, x1 - - ENDP - - -|nseel_asm_notequal_exact| PROC - - - mov x1, x1 - fcmp d1, d0 - cset w0, ne - mov x1, x1 - - ENDP - - - - -|nseel_asm_notequal| PROC - - - mov x1, x1 - ldr d2, [x21] - fsub d0, d0, d1 - fabs d0, d0 - fcmp d0, d2 - cset w0, ge - mov x1, x1 - - ENDP - - - -|nseel_asm_below| PROC - - - mov x1, x1 - fcmp d1, d0 - cset w0, lt - mov x1, x1 - - ENDP - - -|nseel_asm_beloweq| PROC - - - mov x1, x1 - fcmp d1, d0 - cset w0, le - mov x1, x1 - - ENDP - - - -|nseel_asm_above| PROC - - - mov x1, x1 - fcmp d1, d0 - cset w0, gt - mov x1, x1 - - ENDP - -|nseel_asm_aboveeq| PROC - - - mov x1, x1 - fcmp d1, d0 - cset w0, ge - mov x1, x1 - - ENDP - - - -|nseel_asm_min| PROC - - - mov x1, x1 - ldr d0, [x0] - ldr d1, [x1] - fcmp d1, d0 - csel x0, x1, x0, lt - mov x1, x1 - - ENDP - -|nseel_asm_max| PROC - - - mov x1, x1 - ldr d0, [x0] - ldr d1, [x1] - fcmp d1, d0 - csel x0, x1, x0, gt - mov x1, x1 - - ENDP - - - -|nseel_asm_min_fp| PROC - - - mov x1, x1 - fcmp d1, d0 - fcsel d0, d1, d0, lt - mov x1, x1 - - ENDP - -|nseel_asm_max_fp| PROC - - - mov x1, x1 - fcmp d1, d0 - fcsel d0, d1, d0, gt - mov x1, x1 - - ENDP - - - - - - - -|_asm_generic3parm| PROC - - - mov x1, x1 - stp fp, lr, [sp, #-16]! ; input: r0 last, r1=second to last, r2=third to last - mov fp, sp - - mov x3, x0 ; r0 (last parameter) -> r3 - - mov x0, 0xdead ; r0 is first parm (context) - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - - mov x4, 0xdead - movk x4, 0xbeef, lsl 16 - movk x4, 0xbeef, lsl 32 - - mov x5, x1 ; swap x1/x2 - mov x1, x2 - mov x2, x5 - - blr x4 - ldp fp, lr, [sp], #16 - mov x1, x1 - - ENDP - -|_asm_generic3parm_retd| PROC - - - mov x1, x1 - stp fp, lr, [sp, #-16]! ; input: r0 last, r1=second to last, r2=third to last - mov fp, sp - mov x3, x0 ; r0 (last parameter) -> r3 - - mov x0, 0xdead ; r0 is first parm (context) - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - - mov x4, 0xdead - movk x4, 0xbeef, lsl 16 - movk x4, 0xbeef, lsl 32 - - mov x5, x1 ; // swap x1/x2 - mov x1, x2 - mov x2, x5 - - blr x4 - ldp fp, lr, [sp], #16 - mov x1, x1 - - ENDP - - -|_asm_generic2parm| PROC - - - mov x1, x1 - stp fp, lr, [sp, #-16]! ; input: r0 last, r1=second to last - mov fp, sp - mov x2, x0 - - mov x0, 0xdead ; r0 is first parm (context) - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - - mov x4, 0xdead - movk x4, 0xbeef, lsl 16 - movk x4, 0xbeef, lsl 32 - - blr x4 - ldp fp, lr, [sp], #16 - mov x1, x1 - - ENDP - - -|_asm_generic2parm_retd| PROC - - - mov x1, x1 - stp fp, lr, [sp, #-16]! ; input: r0 last, r1=second to last - mov fp, sp - mov x2, x0 - - mov x0, 0xdead ; r0 is first parm (context) - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - - mov x4, 0xdead - movk x4, 0xbeef, lsl 16 - movk x4, 0xbeef, lsl 32 - - blr x4 - ldp fp, lr, [sp], #16 - mov x1, x1 - - ENDP - -|_asm_generic2xparm_retd| PROC - - - mov x1, x1 - stp fp, lr, [sp, #-16]! ; input: r0 last, r1=second to last - mov fp, sp - mov x2, x1 - mov x3, x0 - - mov x0, 0xdead ; r0 is first parm (context) - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - - mov x1, 0xdead ; second parm - movk x1, 0xbeef, lsl 16 - movk x1, 0xbeef, lsl 32 - - mov x4, 0xdead - movk x4, 0xbeef, lsl 16 - movk x4, 0xbeef, lsl 32 - - blr x4 - ldp fp, lr, [sp], #16 - mov x1, x1 - - ENDP - - -|_asm_generic1parm| PROC - - - mov x1, x1 - stp fp, lr, [sp, #-16]! - mov fp, sp - mov x1, x0 - - mov x0, 0xdead ; r0 is first parm (context) - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - - mov x4, 0xdead - movk x4, 0xbeef, lsl 16 - movk x4, 0xbeef, lsl 32 - - blr x4 - ldp fp, lr, [sp], #16 - mov x1, x1 - - ENDP - - - -|_asm_generic1parm_retd| PROC - - - mov x1, x1 - stp fp, lr, [sp, #-16]! - mov fp, sp - mov x1, x0 - - mov x0, 0xdead ; // r0 is first parm (context) - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - - mov x4, 0xdead - movk x4, 0xbeef, lsl 16 - movk x4, 0xbeef, lsl 32 - - blr x4 - ldp fp, lr, [sp], #16 - - mov x1, x1 - - ENDP - - - - -|_asm_megabuf| PROC - - - mov x1, x1 - add x0, x20, #-8 - ldr d1, [x0] - fadd d0, d0, d1 - fcvtzu w3, d0 - asr w2, w3, (NSEEL_RAM_ITEMSPERBLOCK_LOG2 - 3) - bic w2, w2, #7 ; r2 is page index*8 - mov w0, (NSEEL_RAM_BLOCKS * 8) - cmp w2, w0 - bhs |mbchk1| - - add x2, x2, x20 - ldr x2, [x2] - cmp x2, #0 - beq |mbchk1| - - mov x0, (NSEEL_RAM_ITEMSPERBLOCK - 1) - and x3, x3, x0 ; r3 mask item in slot - add x0, x2, x3, lsl #3 ; set result - b |mbchk2| -|mbchk1| - - - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - stp fp, lr, [sp, #-16]! - mov fp, sp - mov x0, x20 ; first parameter: blocks - mov x1, x3 ; second parameter: slot index - blr x2 - ldp fp, lr, [sp], #16 -|mbchk2| - - mov x1, x1 - - ENDP - - -|_asm_gmegabuf| PROC - - - mov x1, x1 - add x2, x20, #-8 - ldr d1, [x2] - - mov x0, 0xdead - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - - fadd d0, d0, d1 - - fcvtzu w1, d0 - - stp fp, lr, [sp, #-16]! - mov fp, sp - - blr x2 - - ldp fp, lr, [sp], #16 - - mov x1, x1 - - ENDP - - -|nseel_asm_fcall| PROC - - - mov x1, x1 - mov x0, 0xdead - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - stp fp, lr, [sp, #-16]! - mov fp, sp - blr x0 - ldp fp, lr, [sp], #16 - mov x1, x1 - - ENDP - - - -|nseel_asm_stack_push| PROC - - - mov x1, x1 - ldr d0, [x0] - - mov x3, 0xdead ; r3 is stack - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - ldr x0, [x3] - - add x0, x0, #8 - - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - and x0, x0, x2 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - orr x0, x0, x2 - - str x0, [x3] - str d0, [x0] - - mov x1, x1 - - ENDP - -|nseel_asm_stack_pop| PROC - - - mov x1, x1 - mov x3, 0xdead ; r3 is stack - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - ldr x1, [x3] - ldr d0, [x1] - sub x1, x1, #8 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - str d0, [x0] - and x1, x1, x2 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - orr x1, x1, x2 - - str x1, [x3] - mov x1, x1 - - ENDP - - - -|nseel_asm_stack_pop_fast| PROC - - - mov x1, x1 - mov x3, 0xdead ; r3 is stack - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - ldr x1, [x3] - mov x0, x1 - sub x1, x1, #8 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - and x1, x1, x2 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - orr x1, x1, x2 - str x1, [x3] - mov x1, x1 - - ENDP - -|nseel_asm_stack_peek| PROC - - - mov x1, x1 - mov x3, 0xdead ; r3 is stack - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - - fcvtzs w2, d0 - - ldr x1, [x3] - sub x1, x1, x2, lsl #3 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - and x1, x1, x2 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - orr x0, x1, x2 - mov x1, x1 - - ENDP - - -|nseel_asm_stack_peek_top| PROC - - - mov x1, x1 - mov x3, 0xdead ; r3 is stack - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - ldr x0, [x3] - mov x1, x1 - - ENDP - - -|nseel_asm_stack_peek_int| PROC - - - mov x1, x1 - mov x3, 0xdead ; r3 is stack - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - - ldr x1, [x3] - sub x1, x1, x2 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - and x1, x1, x2 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - orr x0, x1, x2 - mov x1, x1 - - ENDP - -|nseel_asm_stack_exch| PROC - - - mov x1, x1 - mov x3, 0xdead ; r3 is stack - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - ldr x1, [x3] - ldr d0, [x0] - ldr d1, [x1] - str d0, [x1] - str d1, [x0] - mov x1, x1 - - ENDP - - -|nseel_asm_booltofp| PROC - - - mov x1, x1 - cmp w0, #0 - fmov d0, #1.0 - movi d1, #0 - fcsel d0, d0, d1, ne - mov x1, x1 - - ENDP - -|nseel_asm_fptobool| PROC - - - mov x1, x1 - ldr d1, [x21] - fabs d0, d0 - fcmp d0, d1 - cset w0, ge - mov x1, x1 - - ENDP - -|nseel_asm_fptobool_rev| PROC - - - mov x1, x1 - ldr d1, [x21] - fabs d0, d0 - fcmp d0, d1 - cset w0, lt - mov x1, x1 - - ENDP - -|eel_callcode64| PROC - stp fp, lr, [sp, #-128]! - mov fp, sp - - stp d13, d12, [sp, #16] - stp d11, d10, [sp, #32] - stp d9, d8, [sp, #48] - stp d15, d14, [sp, #64] - stp x20, x19, [sp, #80] - stp x18, x21, [sp, #96] - stp x22, x23, [sp, #112] - - mov x19, x0 - mov x20, x2 - mov x21, x3 - blr x1 - - ldp d13, d12, [sp, #16] - ldp d11, d10, [sp, #32] - ldp d9, d8, [sp, #48] - ldp d15, d14, [sp, #64] - ldp x20, x19, [sp, #80] - ldp x18, x21, [sp, #96] - ldp x22, x23, [sp, #112] - ldp fp, lr, [sp], #128 - ret - - ENDP - -|glue_getscr| PROC - mrs x0, FPCR - ret - ENDP - -|glue_setscr| PROC - msr FPCR, x0 - ret - ENDP - - END diff --git a/oversampling/WDL/eel2/asm-nseel-arm-gcc.c b/oversampling/WDL/eel2/asm-nseel-arm-gcc.c deleted file mode 100644 index 8893796..0000000 --- a/oversampling/WDL/eel2/asm-nseel-arm-gcc.c +++ /dev/null @@ -1,1308 +0,0 @@ -#define FUNCTION_MARKER "mov r0, r0\n" \ - "mov r1, r1\n" \ - "mov r2, r2\n" - -#if EEL_F_SIZE == 8 - -__attribute__((naked)) void nseel_asm_1pdd(void) -{ - - __asm__ __volatile__( - FUNCTION_MARKER - "movw r3, 0xdead\n" - "movt r3, 0xbeef\n" - "str lr, [sp, #-8]!\n" - "blx r3\n" - "ldr lr, [sp], #8\n" - FUNCTION_MARKER - :: ); -} - -__attribute__((naked)) void nseel_asm_2pdd(void) -{ - - __asm__ __volatile__( - FUNCTION_MARKER - "movw r3, 0xdead\n" - "movt r3, 0xbeef\n" - "fcpyd d2, d0\n" - "fcpyd d0, d1\n" - "fcpyd d1, d2\n" - "str lr, [sp, #-8]!\n" - "blx r3\n" - "ldr lr, [sp], #8\n" - FUNCTION_MARKER - :: ); -}; - -__attribute__((naked)) void nseel_asm_2pdds(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "movw r3, 0xdead\n" - "movt r3, 0xbeef\n" - "push {r1, lr}\n" - "fcpyd d1, d0\n" - "fldd d0, [r1]\n" - "blx r3\n" - "pop {r0, lr}\n" - "fstd d0, [r0]\n" - FUNCTION_MARKER - :: ); -} - -#else // 32 bit floating point calls - -#error no 32 bit float support - -#endif - -//--------------------------------------------------------------------------------------------------------------- - - -__attribute__((naked)) void nseel_asm_invsqrt(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "movw r0, 0x59df\n" - "movt r0, 0x5f37\n" - "fcvtsd s2, d0\n" - "fldd d3, [r6, #32]\n" - "fmrs r1, s2\n" - "fmuld d0, d0, d3\n" - "mov r1, r1, asr #1\n" - - "sub r0, r0, r1\n" - - "fmsr s4, r0\n" - "fcvtds d1, s4\n" - - "fldd d2, [r6, #40]\n" - "fmuld d0, d0, d1\n" - "fmuld d0, d0, d1\n" - "faddd d0, d0, d2\n" - "fmuld d0, d0, d1\n" - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_dbg_getstackptr(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fmsr s0, sp\n" - "fsitod d0, s0\n" - FUNCTION_MARKER - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_sqr(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fmuld d0, d0, d0\n" - FUNCTION_MARKER - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_abs(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fabsd d0, d0\n" - FUNCTION_MARKER - ); -} - -#define FLUSH_TO_ZERO \ - "ldr r1, [r0, #4]\n" \ - "movs r2, #0\n" \ - "movt r2, #0x7ff0\n" \ - "add r1, r1, #0x00100000\n" \ - "ands r1, r1, r2\n" \ - "cmp r1, #0x00200000\n" \ - "bgt 0f\n" \ - "movs r2, #0\n" \ - "movs r3, #0\n" \ - "strd r2, [r0]\n" \ - "0:\n" - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_assign(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d0, [r0]\n" - "mov r0, r1\n" - "fstd d0, [r1]\n" - - FLUSH_TO_ZERO - FUNCTION_MARKER - ); -} -// -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_assign_fromfp(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "mov r0, r1\n" - "fstd d0, [r1]\n" - FLUSH_TO_ZERO - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_assign_fast(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d0, [r0]\n" - "mov r0, r1\n" - "fstd d0, [r1]\n" - FUNCTION_MARKER - ); -} -// -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_assign_fast_fromfp(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "mov r0, r1\n" - "fstd d0, [r1]\n" - FUNCTION_MARKER - ); -} - - - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_add(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "faddd d0, d1, d0\n" - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_add_op(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d1, [r1]\n" - "faddd d0, d1, d0\n" - "mov r0, r1\n" - "fstd d0, [r1]\n" - FLUSH_TO_ZERO - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_add_op_fast(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d1, [r1]\n" - "faddd d0, d1, d0\n" - "mov r0, r1\n" - "fstd d0, [r1]\n" - FUNCTION_MARKER - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_sub(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fsubd d0, d1, d0\n" - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_sub_op(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d1, [r1]\n" - "fsubd d0, d1, d0\n" - "mov r0, r1\n" - "fstd d0, [r1]\n" - FLUSH_TO_ZERO - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_sub_op_fast(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d1, [r1]\n" - "fsubd d0, d1, d0\n" - "mov r0, r1\n" - "fstd d0, [r1]\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_mul(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fmuld d0, d0, d1\n" - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_mul_op(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d1, [r1]\n" - "fmuld d0, d0, d1\n" - "mov r0, r1\n" - "fstd d0, [r1]\n" - FLUSH_TO_ZERO - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_mul_op_fast(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d1, [r1]\n" - "fmuld d0, d0, d1\n" - "mov r0, r1\n" - "fstd d0, [r1]\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_div(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fdivd d0, d1, d0\n" - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_div_op(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d1, [r1]\n" - "fdivd d0, d1, d0\n" - "mov r0, r1\n" - "fstd d0, [r1]\n" - FLUSH_TO_ZERO - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_div_op_fast(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d1, [r1]\n" - "fdivd d0, d1, d0\n" - "mov r0, r1\n" - "fstd d0, [r1]\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_mod(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ftouizd s0, d0\n" // round to unsigned integers - "fmrs r3, s0\n" - "fuitod d0, s0\n" // divisor - "ftouizd s2, d1\n" - - "cmp r3, #0\n" - "beq 0f\n" - - "fuitod d1, s2\n" // value - "fdivd d2, d1, d0\n" - "ftouizd s4, d2\n" - "fuitod d2, s4\n" - "fmuld d2, d2, d0\n" - "fsubd d0, d1, d2\n" - "0:\n" - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_shl(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ftosizd s0, d0\n" - "ftosizd s1, d1\n" - "fmrs r3, s0\n" - "fmrs r2, s1\n" - "mov r3, r2, asl r3\n" - "fmsr s0, r3\n" - "fsitod d0, s0\n" - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_shr(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ftosizd s0, d0\n" - "ftosizd s1, d1\n" - "fmrs r3, s0\n" - "fmrs r2, s1\n" - "mov r3, r2, asr r3\n" - "fmsr s0, r3\n" - "fsitod d0, s0\n" - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_mod_op(void) -{ - - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d1, [r1]\n" - "ftouizd s0, d0\n" // round to unsigned integers - "fmrs r3, s0\n" - "fuitod d0, s0\n" // divisor - "ftouizd s2, d1\n" - - "cmp r3, #0\n" - "beq 0f\n" - - "fuitod d1, s2\n" // value - "fdivd d2, d1, d0\n" - "ftouizd s4, d2\n" - "fuitod d2, s4\n" - "fmuld d2, d2, d0\n" - "fsubd d0, d1, d2\n" - "0:\n" - "mov r0, r1\n" - "fstd d0, [r1]\n" - FLUSH_TO_ZERO - FUNCTION_MARKER - ); - -} - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_or(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ftosizd s0, d0\n" - "ftosizd s1, d1\n" - "fmrs r3, s0\n" - "fmrs r2, s1\n" - "orr r3, r3, r2\n" - "fmsr s0, r3\n" - "fsitod d0, s0\n" - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_or0(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ftosizd s0, d0\n" - "fsitod d0, s0\n" - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_or_op(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d1, [r1]\n" - "ftosizd s0, d0\n" - "ftosizd s1, d1\n" - "fmrs r3, s0\n" - "fmrs r2, s1\n" - "orr r3, r3, r2\n" - "fmsr s0, r3\n" - "fsitod d0, s0\n" - "mov r0, r1\n" - "fstd d0, [r1]\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_xor(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ftosizd s0, d0\n" - "ftosizd s1, d1\n" - "fmrs r3, s0\n" - "fmrs r2, s1\n" - "eor r3, r3, r2\n" - "fmsr s0, r3\n" - "fsitod d0, s0\n" - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_xor_op(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d1, [r1]\n" - "ftosizd s0, d0\n" - "ftosizd s1, d1\n" - "fmrs r3, s0\n" - "fmrs r2, s1\n" - "eor r3, r3, r2\n" - "fmsr s0, r3\n" - "fsitod d0, s0\n" - "mov r0, r1\n" - "fstd d0, [r1]\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_and(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "ftosizd s0, d0\n" - "ftosizd s1, d1\n" - "fmrs r3, s0\n" - "fmrs r2, s1\n" - "and r3, r3, r2\n" - "fmsr s0, r3\n" - "fsitod d0, s0\n" - FUNCTION_MARKER - );} - -__attribute__((naked)) void nseel_asm_and_op(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d1, [r1]\n" - "ftosizd s0, d0\n" - "ftosizd s1, d1\n" - "fmrs r3, s0\n" - "fmrs r2, s1\n" - "and r3, r3, r2\n" - "fmsr s0, r3\n" - "fsitod d0, s0\n" - "mov r0, r1\n" - "fstd d0, [r1]\n" - FUNCTION_MARKER - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_uminus(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fnegd d0, d0\n" - FUNCTION_MARKER - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_sign(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmpzd d0\n" - "fmstat\n" - "flddgt d0, [r6, #16]\n" - "flddlt d0, [r6, #24]\n" - FUNCTION_MARKER - :: - ); -} - - - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_bnot(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "cmp r0, #0\n" - "movne r0, #0\n" - "moveq r0, #1\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_if(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "str lr, [sp, #-8]!\n" - "movw r1, 0xdead\n" - "movt r1, 0xbeef\n" - "movw r2, 0xdead\n" - "movt r2, 0xbeef\n" - "cmp r0, #0\n" - "moveq r1, r2\n" - "blx r1\n" - "ldr lr, [sp], #8\n" - FUNCTION_MARKER - :: ); -} - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_repeat(void) -{ -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - __asm__ __volatile__( - FUNCTION_MARKER - "ftosizd s0, d0\n" - "fmrs r3, s0\n" - "cmp r3, #0\n" - "ble 0f\n" - "movw r2, %0\n" - "movt r2, %1\n" - "cmp r3, r2\n" - "movgt r3, r2\n" - "push {r10,lr}\n" - - "movw r10, 0xdead\n" - "movt r10, 0xbeef\n" - "1:\n" - "push {r3,r5}\n" // save counter + worktable - "blx r10\n" - "pop {r3,r5}\n" - "sub r3, r3, #1\n" - "cmp r3, #0\n" - "bgt 1b\n" - "pop {r10,lr}\n" - - "0:\n" - FUNCTION_MARKER - ::"g" (NSEEL_LOOPFUNC_SUPPORT_MAXLEN&65535), - "g" (NSEEL_LOOPFUNC_SUPPORT_MAXLEN>>16) - ); -#else - __asm__ __volatile__( - FUNCTION_MARKER - "ftosizd s0, d0\n" - "fmrs r3, s0\n" - "cmp r3, #0\n" - "ble 0f\n" - "push {r10,lr}\n" - - "movw r10, 0xdead\n" - "movt r10, 0xbeef\n" - "1:\n" - "push {r3,r5}\n" // save counter + worktable - "blx r10\n" - "pop {r3,r5}\n" - "sub r3, r3, #1\n" - "cmp r3, #0\n" - "bgt 1b\n" - "pop {r10,lr}\n" - - "0:\n" - FUNCTION_MARKER - ); -#endif -} - -__attribute__((naked)) void nseel_asm_repeatwhile(void) -{ -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - __asm__ __volatile__( - FUNCTION_MARKER - "movw r3, %0\n" - "movt r3, %1\n" - "push {r10,lr}\n" - - "movw r10, 0xdead\n" - "movt r10, 0xbeef\n" - "0:\n" - "push {r3,r5}\n" // save counter + worktable - "blx r10\n" - "pop {r3,r5}\n" - "sub r3, r3, #1\n" - "cmp r0, #0\n" - "cmpne r3, #0\n" - "bne 0b\n" - "pop {r10,lr}\n" - - FUNCTION_MARKER - ::"g" (NSEEL_LOOPFUNC_SUPPORT_MAXLEN&65535), - "g" (NSEEL_LOOPFUNC_SUPPORT_MAXLEN>>16) - ); -#else - __asm__ __volatile__( - FUNCTION_MARKER - "push {r10,lr}\n" - - "movw r10, 0xdead\n" - "movt r10, 0xbeef\n" - "0:\n" - "push {r3,r5}\n" // save worktable (r3 just for alignment) - "blx r10\n" - "pop {r3,r5}\n" - "cmp r0, #0\n" - "bne 0b\n" - "pop {r10,lr}\n" - - "0:\n" - FUNCTION_MARKER - ); -#endif -} - - -__attribute__((naked)) void nseel_asm_band(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "cmp r0, #0\n" - "beq 0f\n" - "movw r3, 0xdead\n" - "movt r3, 0xbeef\n" - "push {r3, lr}\n" - "blx r3\n" - "pop {r3, lr}\n" - "0:\n" - FUNCTION_MARKER - :: ); -} - -__attribute__((naked)) void nseel_asm_bor(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "cmp r0, #0\n" - "bne 0f\n" - "movw r3, 0xdead\n" - "movt r3, 0xbeef\n" - "push {r3, lr}\n" - "blx r3\n" - "pop {r3, lr}\n" - "0:\n" - FUNCTION_MARKER - :: ); -} - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_equal(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d2, [r6]\n" - "fsubd d0, d0, d1\n" - "fabsd d0, d0\n" - "fcmpd d2, d0\n" - "fmstat\n" - "movlt r0, #0\n" - "movge r0, #1\n" - FUNCTION_MARKER - :: - ); -} -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_equal_exact(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmpd d0, d1\n" - "fmstat\n" - "movne r0, #0\n" - "moveq r0, #1\n" - FUNCTION_MARKER - :: - ); -} -// -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_notequal_exact(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmpd d0, d1\n" - "fmstat\n" - "moveq r0, #0\n" - "movne r0, #1\n" - FUNCTION_MARKER - :: - ); -} -// -// -// -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_notequal(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d2, [r6]\n" - "fsubd d0, d0, d1\n" - "fabsd d0, d0\n" - "fcmpd d2, d0\n" - "fmstat\n" - "movlt r0, #1\n" - "movge r0, #0\n" - FUNCTION_MARKER - :: - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_below(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmpd d1, d0\n" - "fmstat\n" - "movlt r0, #1\n" - "movge r0, #0\n" - FUNCTION_MARKER - :: - ); -} - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_beloweq(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmpd d1, d0\n" - "fmstat\n" - "movle r0, #1\n" - "movgt r0, #0\n" - FUNCTION_MARKER - :: - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -__attribute__((naked)) void nseel_asm_above(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmpd d1, d0\n" - "fmstat\n" - "movgt r0, #1\n" - "movle r0, #0\n" - FUNCTION_MARKER - :: - ); -} - -__attribute__((naked)) void nseel_asm_aboveeq(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmpd d1, d0\n" - "fmstat\n" - "movge r0, #1\n" - "movlt r0, #0\n" - FUNCTION_MARKER - :: - ); -} - - - -__attribute__((naked)) void nseel_asm_min(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d0, [r0]\n" - "fldd d1, [r1]\n" - "fcmpd d1, d0\n" - "fmstat\n" - "movlt r0, r1\n" - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_max(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d0, [r0]\n" - "fldd d1, [r1]\n" - "fcmpd d1, d0\n" - "fmstat\n" - "movge r0, r1\n" - FUNCTION_MARKER - ); -} - - - -__attribute__((naked)) void nseel_asm_min_fp(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmpd d1, d0\n" - "fmstat\n" - "fcpydlt d0, d1\n" - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_max_fp(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fcmpd d1, d0\n" - "fmstat\n" - "fcpydge d0, d1\n" - FUNCTION_MARKER - ); -} - - - - - - - -__attribute__((naked)) void _asm_generic3parm(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "push {r4, lr}\n" // input: r0 last, r1=second to last, r2=third to last - // output: r0=context, r1=r2, r2=r1, r3=r0 - "mov r3, r0\n" // r0 (last parameter) -> r3 - "mov r4, r1\n" // r1 (second to last parameter) r1->r4->r2 - - "movw r0, 0xdead\n" // r0 is first parm (context) - "movt r0, 0xbeef\n" - - "mov r1, r2\n" // r2->r1 - "mov r2, r4\n" // r1->r2 - - "movw r4, 0xdead\n" - "movt r4, 0xbeef\n" - - "blx r4\n" - "pop {r4, lr}\n" - FUNCTION_MARKER - :: - ); -} - -__attribute__((naked)) void _asm_generic3parm_retd(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "push {r4, lr}\n" // input: r0 last, r1=second to last, r2=third to last - // output: r0=context, r1=r2, r2=r1, r3=r0 - "mov r3, r0\n" // r0 (last parameter) -> r3 - "mov r4, r1\n" // r1 (second to last parameter) r1->r4->r2 - - "movw r0, 0xdead\n" // r0 is first parm (context) - "movt r0, 0xbeef\n" - - "mov r1, r2\n" // r2->r1 - "mov r2, r4\n" // r1->r2 - - "movw r4, 0xdead\n" - "movt r4, 0xbeef\n" - - "blx r4\n" - "pop {r4, lr}\n" - FUNCTION_MARKER - :: - ); -} - - -__attribute__((naked)) void _asm_generic2parm(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "str lr, [sp, #-8]!\n" - "mov r2, r0\n" // r0 -> r2, r1-r1, - "movw r0, 0xdead\n" // r0 is first parm - "movt r0, 0xbeef\n" - "movw r3, 0xdead\n" - "movt r3, 0xbeef\n" - "blx r3\n" - "ldr lr, [sp], #8\n" - FUNCTION_MARKER - :: - ); -} - - -__attribute__((naked)) void _asm_generic2parm_retd(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "str lr, [sp, #-8]!\n" - "mov r2, r0\n" // r0 -> r2, r1-r1, - "movw r0, 0xdead\n" // r0 is first parm - "movt r0, 0xbeef\n" - "movw r3, 0xdead\n" - "movt r3, 0xbeef\n" - "blx r3\n" - "ldr lr, [sp], #8\n" - FUNCTION_MARKER - :: - ); -} - - -__attribute__((naked)) void _asm_generic2xparm_retd(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "push {r4, lr}\n" - "mov r3, r0\n" // r0 is last parameter - "mov r2, r1\n" // - "movw r0, 0xdead\n" // r0 is ctx - "movt r0, 0xbeef\n" - "movw r1, 0xdead\n" // r1 is second ctx - "movt r1, 0xbeef\n" - "movw r4, 0xdead\n" - "movt r4, 0xbeef\n" - "blx r4\n" - "pop {r4, lr}\n" - FUNCTION_MARKER - :: - ); -} - -__attribute__((naked)) void _asm_generic1parm(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "str lr, [sp, #-8]!\n" - "mov r1, r0\n" // r0 -> r1 - "movw r0, 0xdead\n" // r0 is first parm - "movt r0, 0xbeef\n" - "movw r3, 0xdead\n" - "movt r3, 0xbeef\n" - "blx r3\n" - "ldr lr, [sp], #8\n" - FUNCTION_MARKER - :: - ); -} - - - -__attribute__((naked)) void _asm_generic1parm_retd(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "str lr, [sp, #-8]!\n" - "mov r1, r0\n" // r0 -> r1 - "movw r0, 0xdead\n" // r0 is first parm - "movt r0, 0xbeef\n" - "movw r3, 0xdead\n" - "movt r3, 0xbeef\n" - "blx r3\n" - "ldr lr, [sp], #8\n" - FUNCTION_MARKER - :: - ); -} - - - - -__attribute__((naked)) void _asm_megabuf(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d1, [r7, #-8]\n" - "faddd d0, d0, d1\n" - "ftouizd s0, d0\n" - "fmrs r3, s0\n" // r3 is slot index - "mov r2, r3, asr %0\n" - "bic r2, r2, #3\n" // r2 is page index*4 - "cmp r2, %1\n" - "bhs 0f\n" - - "add r2, r2, r7\n" - "ldr r2, [r2]\n" - "cmp r2, #0\n" - "beq 0f\n" - - "movw r0, %2\n" - "and r3, r3, r0\n" // r3 mask item in slot - "add r0, r2, r3, asl #3\n" // set result - "b 1f\n" - "0:\n" - - // failed, call stub function - "movw r2, 0xdead\n" - "movt r2, 0xbeef\n" - "str lr, [sp, #-8]!\n" - "mov r0, r7\n" // first parameter: blocks - "mov r1, r3\n" // second parameter: slot index - "blx r2\n" - "ldr lr, [sp], #8\n" - - "1:\n" - - FUNCTION_MARKER - :: - "i" (NSEEL_RAM_ITEMSPERBLOCK_LOG2 - 2/*log2(sizeof(void*))*/), - "i" (NSEEL_RAM_BLOCKS*4 /*(sizeof(void*))*/), - "i" (NSEEL_RAM_ITEMSPERBLOCK-1) - ); -} - - -__attribute__((naked)) void _asm_gmegabuf(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "movw r0, 0xdead\n" - "movt r0, 0xbeef\n" - - "movw r2, 0xdead\n" - "movt r2, 0xbeef\n" - - "fldd d1, [r7, #-8]\n" - "faddd d0, d0, d1\n" - "ftouizd s0, d0\n" - "fmrs r1, s0\n" // r1 is slot index - - "push {r4, lr}\n" - - "blx r2\n" - - "pop {r4, lr}\n" - - FUNCTION_MARKER - :: - ); -} - - -__attribute__((naked)) void nseel_asm_fcall(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "movw r0, 0xdead\n" - "movt r0, 0xbeef\n" - "push {r4, lr}\n" - "blx r0\n" - "pop {r4, lr}\n" - FUNCTION_MARKER - ); -} - - - -__attribute__((naked)) void nseel_asm_stack_push(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d0, [r0]\n" - - "movw r3, 0xdead\n" // r3 is stack - "movt r3, 0xbeef\n" - "ldr r0, [r3]\n" - - "add r0, r0, #8\n" - - "movw r2, 0xdead\n" - "movt r2, 0xbeef\n" - "and r0, r0, r2\n" - "movw r2, 0xdead\n" - "movt r2, 0xbeef\n" - "orr r0, r0, r2\n" - - "str r0, [r3]\n" - "fstd d0, [r0]\n" - - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_stack_pop(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "movw r3, 0xdead\n" // r3 is stack - "movt r3, 0xbeef\n" - "ldr r1, [r3]\n" - "fldd d0, [r1]\n" - "sub r1, r1, #8\n" - "movw r2, 0xdead\n" - "movt r2, 0xbeef\n" - "fstd d0, [r0]\n" - "and r1, r1, r2\n" - "movw r2, 0xdead\n" - "movt r2, 0xbeef\n" - "orr r1, r1, r2\n" - - "str r1, [r3]\n" - FUNCTION_MARKER - ); -} - - - -__attribute__((naked)) void nseel_asm_stack_pop_fast(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "movw r3, 0xdead\n" // r3 is stack - "movt r3, 0xbeef\n" - "ldr r1, [r3]\n" - "mov r0, r1\n" - "sub r1, r1, #8\n" - "movw r2, 0xdead\n" - "movt r2, 0xbeef\n" - "and r1, r1, r2\n" - "movw r2, 0xdead\n" - "movt r2, 0xbeef\n" - "orr r1, r1, r2\n" - "str r1, [r3]\n" - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_stack_peek(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "movw r3, 0xdead\n" // r3 is stack - "movt r3, 0xbeef\n" - - "ftosizd s0, d0\n" - "fmrs r2, s0\n" // r2 is index in stack - - "ldr r1, [r3]\n" - "sub r1, r1, r2, asl #3\n" - "movw r2, 0xdead\n" - "movt r2, 0xbeef\n" - "and r1, r1, r2\n" - "movw r2, 0xdead\n" - "movt r2, 0xbeef\n" - "orr r0, r1, r2\n" - FUNCTION_MARKER - ); -} - - -__attribute__((naked)) void nseel_asm_stack_peek_top(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "movw r3, 0xdead\n" // r3 is stack - "movt r3, 0xbeef\n" - "ldr r0, [r3]\n" - FUNCTION_MARKER - ); -} - - -__attribute__((naked)) void nseel_asm_stack_peek_int(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "movw r3, 0xdead\n" // r3 is stack - "movt r3, 0xbeef\n" - - "movw r2, 0xdead\n" // r3 is stack - "movt r2, 0xbeef\n" - - "ldr r1, [r3]\n" - "sub r1, r1, r2\n" - "movw r2, 0xdead\n" - "movt r2, 0xbeef\n" - "and r1, r1, r2\n" - "movw r2, 0xdead\n" - "movt r2, 0xbeef\n" - "orr r0, r1, r2\n" - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_stack_exch(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "movw r3, 0xdead\n" // r3 is stack - "movt r3, 0xbeef\n" - "ldr r1, [r3]\n" - "fldd d0, [r0]\n" - "fldd d1, [r1]\n" - "fstd d0, [r1]\n" - "fstd d1, [r0]\n" - FUNCTION_MARKER - ); -} - - -__attribute__((naked)) void nseel_asm_booltofp(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "cmp r0, #0\n" - "flddne d0, [r6, #16]\n" - "flddeq d0, [r6, #8]\n" - FUNCTION_MARKER - ); -} - -__attribute__((naked)) void nseel_asm_fptobool(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d1, [r6]\n" - "fabsd d0, d0\n" - "fcmpd d0, d1\n" - "fmstat\n" - "movgt r0, #1\n" - "movlt r0, #0\n" - FUNCTION_MARKER - :: - ); -} - -__attribute__((naked)) void nseel_asm_fptobool_rev(void) -{ - __asm__ __volatile__( - FUNCTION_MARKER - "fldd d1, [r6]\n" - "fabsd d0, d0\n" - "fcmpd d0, d1\n" - "fmstat\n" - "movgt r0, #0\n" - "movlt r0, #1\n" - FUNCTION_MARKER - :: - ); -} - diff --git a/oversampling/WDL/eel2/asm-nseel-arm64ec.asm b/oversampling/WDL/eel2/asm-nseel-arm64ec.asm deleted file mode 100644 index cfee5cb..0000000 --- a/oversampling/WDL/eel2/asm-nseel-arm64ec.asm +++ /dev/null @@ -1,1416 +0,0 @@ -NSEEL_RAM_ITEMSPERBLOCK_LOG2 equ 16 -NSEEL_RAM_BLOCKS_LOG2 equ 9 -NSEEL_LOOPFUNC_SUPPORT_MAXLEN equ 1048576 - -NSEEL_RAM_BLOCKS equ (1 << NSEEL_RAM_BLOCKS_LOG2) -NSEEL_RAM_ITEMSPERBLOCK equ (1< 0 - mov x2, (NSEEL_LOOPFUNC_SUPPORT_MAXLEN & 65535) - movk x2, (NSEEL_LOOPFUNC_SUPPORT_MAXLEN>>16), lsl 16 - cmp w3, w2 - csel w3, w2, w3, gt - ] - stp fp, lr, [sp, #-48]! - mov fp, sp - str x25, [sp, #16] - - mov x25, 0xdead - movk x25, 0xbeef, lsl 16 - movk x25, 0xbeef, lsl 32 -|rep_lz| - stp x3, x22, [sp, #32] - blr x25 - ldp x3, x22, [sp, #32] - sub x3, x3, #1 - cmp x3, #0 - bgt |rep_lz| - ldr x25, [sp, #16] - ldp fp, lr, [sp], #48 -|rep_lz2| - mov x1, x1 - - ENDP - -|#nseel_asm_repeatwhile| PROC - - - mov x1, x1 - [ NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - mov x3, (NSEEL_LOOPFUNC_SUPPORT_MAXLEN & 65535) - movk x3, (NSEEL_LOOPFUNC_SUPPORT_MAXLEN>>16), lsl 16 - ] - stp fp, lr, [sp, #-48]! - str x25, [sp, #16] - - mov x25, 0xdead - movk x25, 0xbeef, lsl 16 - movk x25, 0xbeef, lsl 32 -|repw_lz| - stp x3, x22, [sp, #32] - blr x25 - ldp x3, x22, [sp, #32] - cmp w0, #0 - [ NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - beq |repw_lz2| - sub x3, x3, #1 - cmp x3, #0 - bne |repw_lz| -|repw_lz2| - ] - [ NSEEL_LOOPFUNC_SUPPORT_MAXLEN == 0 - bne |repw_lz| - ] - ldr x25, [sp, #16] - ldp fp, lr, [sp], #48 - - mov x1, x1 - - ENDP - - -|#nseel_asm_band| PROC - - - mov x1, x1 - cmp w0, #0 - beq |band_chk| - mov x3, 0xdead - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - stp fp, lr, [sp, #-16]! - mov fp, sp - blr x3 - ldp fp, lr, [sp], #16 -|band_chk| - mov x1, x1 - ENDP - -|#nseel_asm_bor| PROC - - - mov x1, x1 - cmp w0, #0 - bne |bor_chk| - mov x3, 0xdead - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - stp fp, lr, [sp, #-16]! - mov fp, sp - blr x3 - ldp fp, lr, [sp], #16 -|bor_chk| - mov x1, x1 - ENDP - - -|#nseel_asm_equal| PROC - - - mov x1, x1 - ldr d2, [x21] - fsub d0, d0, d1 - fabs d0, d0 - fcmp d0, d2 - cset w0, lt - mov x1, x1 - - ENDP - -|#nseel_asm_equal_exact| PROC - - - mov x1, x1 - fcmp d1, d0 - cset w0, eq - mov x1, x1 - - ENDP - - -|#nseel_asm_notequal_exact| PROC - - - mov x1, x1 - fcmp d1, d0 - cset w0, ne - mov x1, x1 - - ENDP - - - - -|#nseel_asm_notequal| PROC - - - mov x1, x1 - ldr d2, [x21] - fsub d0, d0, d1 - fabs d0, d0 - fcmp d0, d2 - cset w0, ge - mov x1, x1 - - ENDP - - - -|#nseel_asm_below| PROC - - - mov x1, x1 - fcmp d1, d0 - cset w0, lt - mov x1, x1 - - ENDP - - -|#nseel_asm_beloweq| PROC - - - mov x1, x1 - fcmp d1, d0 - cset w0, le - mov x1, x1 - - ENDP - - - -|#nseel_asm_above| PROC - - - mov x1, x1 - fcmp d1, d0 - cset w0, gt - mov x1, x1 - - ENDP - -|#nseel_asm_aboveeq| PROC - - - mov x1, x1 - fcmp d1, d0 - cset w0, ge - mov x1, x1 - - ENDP - - - -|#nseel_asm_min| PROC - - - mov x1, x1 - ldr d0, [x0] - ldr d1, [x1] - fcmp d1, d0 - csel x0, x1, x0, lt - mov x1, x1 - - ENDP - -|#nseel_asm_max| PROC - - - mov x1, x1 - ldr d0, [x0] - ldr d1, [x1] - fcmp d1, d0 - csel x0, x1, x0, gt - mov x1, x1 - - ENDP - - - -|#nseel_asm_min_fp| PROC - - - mov x1, x1 - fcmp d1, d0 - fcsel d0, d1, d0, lt - mov x1, x1 - - ENDP - -|#nseel_asm_max_fp| PROC - - - mov x1, x1 - fcmp d1, d0 - fcsel d0, d1, d0, gt - mov x1, x1 - - ENDP - - - - - - - -|#_asm_generic3parm| PROC - - - mov x1, x1 - stp fp, lr, [sp, #-16]! ; input: r0 last, r1=second to last, r2=third to last - mov fp, sp - - mov x3, x0 ; r0 (last parameter) -> r3 - - mov x0, 0xdead ; r0 is first parm (context) - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - - mov x4, 0xdead - movk x4, 0xbeef, lsl 16 - movk x4, 0xbeef, lsl 32 - - mov x5, x1 ; swap x1/x2 - mov x1, x2 - mov x2, x5 - - blr x4 - ldp fp, lr, [sp], #16 - mov x1, x1 - - ENDP - -|#_asm_generic3parm_retd| PROC - - - mov x1, x1 - stp fp, lr, [sp, #-16]! ; input: r0 last, r1=second to last, r2=third to last - mov fp, sp - mov x3, x0 ; r0 (last parameter) -> r3 - - mov x0, 0xdead ; r0 is first parm (context) - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - - mov x4, 0xdead - movk x4, 0xbeef, lsl 16 - movk x4, 0xbeef, lsl 32 - - mov x5, x1 ; // swap x1/x2 - mov x1, x2 - mov x2, x5 - - blr x4 - ldp fp, lr, [sp], #16 - mov x1, x1 - - ENDP - - -|#_asm_generic2parm| PROC - - - mov x1, x1 - stp fp, lr, [sp, #-16]! ; input: r0 last, r1=second to last - mov fp, sp - mov x2, x0 - - mov x0, 0xdead ; r0 is first parm (context) - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - - mov x4, 0xdead - movk x4, 0xbeef, lsl 16 - movk x4, 0xbeef, lsl 32 - - blr x4 - ldp fp, lr, [sp], #16 - mov x1, x1 - - ENDP - - -|#_asm_generic2parm_retd| PROC - - - mov x1, x1 - stp fp, lr, [sp, #-16]! ; input: r0 last, r1=second to last - mov fp, sp - mov x2, x0 - - mov x0, 0xdead ; r0 is first parm (context) - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - - mov x4, 0xdead - movk x4, 0xbeef, lsl 16 - movk x4, 0xbeef, lsl 32 - - blr x4 - ldp fp, lr, [sp], #16 - mov x1, x1 - - ENDP - -|#_asm_generic2xparm_retd| PROC - - - mov x1, x1 - stp fp, lr, [sp, #-16]! ; input: r0 last, r1=second to last - mov fp, sp - mov x2, x1 - mov x3, x0 - - mov x0, 0xdead ; r0 is first parm (context) - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - - mov x1, 0xdead ; second parm - movk x1, 0xbeef, lsl 16 - movk x1, 0xbeef, lsl 32 - - mov x4, 0xdead - movk x4, 0xbeef, lsl 16 - movk x4, 0xbeef, lsl 32 - - blr x4 - ldp fp, lr, [sp], #16 - mov x1, x1 - - ENDP - - -|#_asm_generic1parm| PROC - - - mov x1, x1 - stp fp, lr, [sp, #-16]! - mov fp, sp - mov x1, x0 - - mov x0, 0xdead ; r0 is first parm (context) - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - - mov x4, 0xdead - movk x4, 0xbeef, lsl 16 - movk x4, 0xbeef, lsl 32 - - blr x4 - ldp fp, lr, [sp], #16 - mov x1, x1 - - ENDP - - - -|#_asm_generic1parm_retd| PROC - - - mov x1, x1 - stp fp, lr, [sp, #-16]! - mov fp, sp - mov x1, x0 - - mov x0, 0xdead ; // r0 is first parm (context) - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - - mov x4, 0xdead - movk x4, 0xbeef, lsl 16 - movk x4, 0xbeef, lsl 32 - - blr x4 - ldp fp, lr, [sp], #16 - - mov x1, x1 - - ENDP - - - - -|#_asm_megabuf| PROC - - - mov x1, x1 - add x0, x20, #-8 - ldr d1, [x0] - fadd d0, d0, d1 - fcvtzu w3, d0 - asr w2, w3, (NSEEL_RAM_ITEMSPERBLOCK_LOG2 - 3) - bic w2, w2, #7 ; r2 is page index*8 - mov w0, (NSEEL_RAM_BLOCKS * 8) - cmp w2, w0 - bhs |mbchk1| - - add x2, x2, x20 - ldr x2, [x2] - cmp x2, #0 - beq |mbchk1| - - mov x0, (NSEEL_RAM_ITEMSPERBLOCK - 1) - and x3, x3, x0 ; r3 mask item in slot - add x0, x2, x3, lsl #3 ; set result - b |mbchk2| -|mbchk1| - - - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - stp fp, lr, [sp, #-16]! - mov fp, sp - mov x0, x20 ; first parameter: blocks - mov x1, x3 ; second parameter: slot index - blr x2 - ldp fp, lr, [sp], #16 -|mbchk2| - - mov x1, x1 - - ENDP - - -|#_asm_gmegabuf| PROC - - - mov x1, x1 - add x2, x20, #-8 - ldr d1, [x2] - - mov x0, 0xdead - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - - fadd d0, d0, d1 - - fcvtzu w1, d0 - - stp fp, lr, [sp, #-16]! - mov fp, sp - - blr x2 - - ldp fp, lr, [sp], #16 - - mov x1, x1 - - ENDP - - -|#nseel_asm_fcall| PROC - - - mov x1, x1 - mov x0, 0xdead - movk x0, 0xbeef, lsl 16 - movk x0, 0xbeef, lsl 32 - stp fp, lr, [sp, #-16]! - mov fp, sp - blr x0 - ldp fp, lr, [sp], #16 - mov x1, x1 - - ENDP - - - -|#nseel_asm_stack_push| PROC - - - mov x1, x1 - ldr d0, [x0] - - mov x3, 0xdead ; r3 is stack - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - ldr x0, [x3] - - add x0, x0, #8 - - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - and x0, x0, x2 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - orr x0, x0, x2 - - str x0, [x3] - str d0, [x0] - - mov x1, x1 - - ENDP - -|#nseel_asm_stack_pop| PROC - - - mov x1, x1 - mov x3, 0xdead ; r3 is stack - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - ldr x1, [x3] - ldr d0, [x1] - sub x1, x1, #8 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - str d0, [x0] - and x1, x1, x2 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - orr x1, x1, x2 - - str x1, [x3] - mov x1, x1 - - ENDP - - - -|#nseel_asm_stack_pop_fast| PROC - - - mov x1, x1 - mov x3, 0xdead ; r3 is stack - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - ldr x1, [x3] - mov x0, x1 - sub x1, x1, #8 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - and x1, x1, x2 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - orr x1, x1, x2 - str x1, [x3] - mov x1, x1 - - ENDP - -|#nseel_asm_stack_peek| PROC - - - mov x1, x1 - mov x3, 0xdead ; r3 is stack - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - - fcvtzs w2, d0 - - ldr x1, [x3] - sub x1, x1, x2, lsl #3 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - and x1, x1, x2 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - orr x0, x1, x2 - mov x1, x1 - - ENDP - - -|#nseel_asm_stack_peek_top| PROC - - - mov x1, x1 - mov x3, 0xdead ; r3 is stack - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - ldr x0, [x3] - mov x1, x1 - - ENDP - - -|#nseel_asm_stack_peek_int| PROC - - - mov x1, x1 - mov x3, 0xdead ; r3 is stack - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - - ldr x1, [x3] - sub x1, x1, x2 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - and x1, x1, x2 - mov x2, 0xdead - movk x2, 0xbeef, lsl 16 - movk x2, 0xbeef, lsl 32 - orr x0, x1, x2 - mov x1, x1 - - ENDP - -|#nseel_asm_stack_exch| PROC - - - mov x1, x1 - mov x3, 0xdead ; r3 is stack - movk x3, 0xbeef, lsl 16 - movk x3, 0xbeef, lsl 32 - ldr x1, [x3] - ldr d0, [x0] - ldr d1, [x1] - str d0, [x1] - str d1, [x0] - mov x1, x1 - - ENDP - - -|#nseel_asm_booltofp| PROC - - - mov x1, x1 - cmp w0, #0 - fmov d0, #1.0 - movi d1, #0 - fcsel d0, d0, d1, ne - mov x1, x1 - - ENDP - -|#nseel_asm_fptobool| PROC - - - mov x1, x1 - ldr d1, [x21] - fabs d0, d0 - fcmp d0, d1 - cset w0, ge - mov x1, x1 - - ENDP - -|#nseel_asm_fptobool_rev| PROC - - - mov x1, x1 - ldr d1, [x21] - fabs d0, d0 - fcmp d0, d1 - cset w0, lt - mov x1, x1 - - ENDP - -|#eel_callcode64| PROC - stp fp, lr, [sp, #-128]! - mov fp, sp - - stp d13, d12, [sp, #16] - stp d11, d10, [sp, #32] - stp d9, d8, [sp, #48] - stp d15, d14, [sp, #64] - stp x20, x19, [sp, #80] - stp x22, x21, [sp, #96] - - mov x19, x0 - mov x20, x2 - mov x21, x3 - blr x1 - - ldp d13, d12, [sp, #16] - ldp d11, d10, [sp, #32] - ldp d9, d8, [sp, #48] - ldp d15, d14, [sp, #64] - ldp x20, x19, [sp, #80] - ldp x22, x21, [sp, #96] - ldp fp, lr, [sp], #128 - ret - - ENDP - -|#glue_getscr| PROC - mrs x0, FPCR - ret - ENDP - -|#glue_setscr| PROC - msr FPCR, x0 - ret - ENDP - - END diff --git a/oversampling/WDL/eel2/asm-nseel-arm64ec.obj b/oversampling/WDL/eel2/asm-nseel-arm64ec.obj deleted file mode 100644 index f0f0843..0000000 Binary files a/oversampling/WDL/eel2/asm-nseel-arm64ec.obj and /dev/null differ diff --git a/oversampling/WDL/eel2/asm-nseel-multi-macho.o b/oversampling/WDL/eel2/asm-nseel-multi-macho.o deleted file mode 100644 index c689364..0000000 Binary files a/oversampling/WDL/eel2/asm-nseel-multi-macho.o and /dev/null differ diff --git a/oversampling/WDL/eel2/asm-nseel-ppc-gcc.c b/oversampling/WDL/eel2/asm-nseel-ppc-gcc.c deleted file mode 100644 index 11aa25e..0000000 --- a/oversampling/WDL/eel2/asm-nseel-ppc-gcc.c +++ /dev/null @@ -1,1436 +0,0 @@ -#define FUNCTION_MARKER "mr r0, r0\n" \ - "mr r1, r1\n" \ - "mr r2, r2\n" - -#if EEL_F_SIZE == 8 - -void nseel_asm_1pdd(void) -{ - - __asm__( - FUNCTION_MARKER - "addis r5, 0, 0xdead\n" - "ori r5, r5, 0xbeef\n" - "mtctr r5\n" - "subi r1, r1, 64\n" - "bctrl\n" - "addi r1, r1, 64\n" - FUNCTION_MARKER - :: ); -} - -void nseel_asm_2pdd(void) -{ - - __asm__( - FUNCTION_MARKER - "addis r7, 0, 0xdead\n" - "ori r7, r7, 0xbeef\n" - "fmr f2, f1\n" - "lfd f1, 0(r14)\n" - "mtctr r7\n" - "subi r1, r1, 64\n" - "bctrl\n" - "addi r1, r1, 64\n" - FUNCTION_MARKER - :: ); -}; - -void nseel_asm_2pdds(void) -{ - __asm__( - FUNCTION_MARKER - "addis r5, 0, 0xdead\n" - "ori r5, r5, 0xbeef\n" - "fmr f2, f1\n" - "lfd f1, 0(r14)\n" - "mtctr r5\n" - "subi r1, r1, 64\n" - "bctrl\n" - "addi r1, r1, 64\n" - "stfd f1, 0(r14)\n" - "mr r3, r14\n" - FUNCTION_MARKER - :: ); -} - -#else // 32 bit floating point calls - -#error no 32 bit float support - -#endif - -//--------------------------------------------------------------------------------------------------------------- - - -void nseel_asm_invsqrt(void) -{ - __asm__( - FUNCTION_MARKER - "frsqrte f1, f1\n" // less accurate than our x86 equivilent, but invsqrt() is inherently inaccurate anyway - FUNCTION_MARKER - ); -} - -void nseel_asm_dbg_getstackptr(void) -{ - __asm__( - FUNCTION_MARKER - "addis r11, 0, 0x4330\n" - "xoris r10, r1, 0x8000\n" - "stw r11, -8(r1)\n" // 0x43300000 - "stw r10, -4(r1)\n" // our integer sign flipped - "lfd f1, -8(r1)\n" - "fsub f1, f1, f30\n" - FUNCTION_MARKER - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_sqr(void) -{ - __asm__( - FUNCTION_MARKER - "fmul f1, f1, f1\n" - FUNCTION_MARKER - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_abs(void) -{ - __asm__( - FUNCTION_MARKER - "fabs f1, f1\n" - FUNCTION_MARKER - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_assign(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f1, 0(r3)\n" - "mr r3, r14\n" - "stfd f1, 0(r14)\n" - FUNCTION_MARKER - ); -} -// -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_assign_fromfp(void) -{ - __asm__( - FUNCTION_MARKER - "mr r3, r14\n" - "stfd f1, 0(r14)\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_assign_fast(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f1, 0(r3)\n" - "mr r3, r14\n" - "stfd f1, 0(r14)\n" - FUNCTION_MARKER - ); -} -// -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_assign_fast_fromfp(void) -{ - __asm__( - FUNCTION_MARKER - "mr r3, r14\n" - "stfd f1, 0(r14)\n" - FUNCTION_MARKER - ); -} - - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_add(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fadd f1, f1, f2\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_add_op(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fadd f1, f1, f2\n" - "mr r3, r14\n" - "stfd f1, 0(r14)\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_add_op_fast(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fadd f1, f1, f2\n" - "mr r3, r14\n" - "stfd f1, 0(r14)\n" - FUNCTION_MARKER - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_sub(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fsub f1, f2, f1\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_sub_op(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fsub f1, f2, f1\n" - "mr r3, r14\n" - "stfd f1, 0(r14)\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_sub_op_fast(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fsub f1, f2, f1\n" - "mr r3, r14\n" - "stfd f1, 0(r14)\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_mul(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fmul f1, f2, f1\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_mul_op(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fmul f1, f2, f1\n" - "mr r3, r14\n" - "stfd f1, 0(r14)\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_mul_op_fast(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fmul f1, f2, f1\n" - "mr r3, r14\n" - "stfd f1, 0(r14)\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_div(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fdiv f1, f2, f1\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_div_op(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fdiv f1, f2, f1\n" - "mr r3, r14\n" - "stfd f1, 0(r14)\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_div_op_fast(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fdiv f1, f2, f1\n" - "mr r3, r14\n" - "stfd f1, 0(r14)\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_mod(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fabs f1, f1\n" - "fabs f2, f2\n" - "fctiwz f1, f1\n" - "fctiwz f2, f2\n" - "stfd f1, -8(r1)\n" - "stfd f2, -16(r1)\n" - "lwz r10, -4(r1)\n" - "lwz r11, -12(r1)\n" //r11 and r12 have the integers - - "divw r12, r11, r10\n" - "mullw r12, r12, r10\n" - "subf r10, r12, r11\n" - - "addis r11, 0, 0x4330\n" - "xoris r10, r10, 0x8000\n" - "stw r11, -8(r1)\n" // 0x43300000 - "stw r10, -4(r1)\n" // our integer sign flipped - "lfd f1, -8(r1)\n" - "fsub f1, f1, f30\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_shl(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fctiwz f1, f1\n" - "fctiwz f2, f2\n" - "stfd f1, -8(r1)\n" - "stfd f2, -16(r1)\n" - "lwz r10, -4(r1)\n" - "lwz r11, -12(r1)\n" //r11 and r12 have the integers - "slw r10, r11, r10\n" // r10 has the result - "addis r11, 0, 0x4330\n" - "xoris r10, r10, 0x8000\n" - "stw r11, -8(r1)\n" // 0x43300000 - "stw r10, -4(r1)\n" // our integer sign flipped - "lfd f1, -8(r1)\n" - "fsub f1, f1, f30\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_shr(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fctiwz f1, f1\n" - "fctiwz f2, f2\n" - "stfd f1, -8(r1)\n" - "stfd f2, -16(r1)\n" - "lwz r10, -4(r1)\n" - "lwz r11, -12(r1)\n" //r11 and r12 have the integers - "sraw r10, r11, r10\n" // r10 has the result - "addis r11, 0, 0x4330\n" - "xoris r10, r10, 0x8000\n" - "stw r11, -8(r1)\n" // 0x43300000 - "stw r10, -4(r1)\n" // our integer sign flipped - "lfd f1, -8(r1)\n" - "fsub f1, f1, f30\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_mod_op(void) -{ - - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fabs f1, f1\n" - "fabs f2, f2\n" - "fctiwz f1, f1\n" - "fctiwz f2, f2\n" - "stfd f1, -8(r1)\n" - "stfd f2, -16(r1)\n" - "lwz r10, -4(r1)\n" - "lwz r11, -12(r1)\n" //r11 and r12 have the integers - - "divw r12, r11, r10\n" - "mullw r12, r12, r10\n" - "subf r10, r12, r11\n" - - "addis r11, 0, 0x4330\n" - "xoris r10, r10, 0x8000\n" - "stw r11, -8(r1)\n" // 0x43300000 - "stw r10, -4(r1)\n" // our integer sign flipped - "lfd f1, -8(r1)\n" - "fsub f1, f1, f30\n" - "mr r3, r14\n" - "stfd f1, 0(r14)\n" - FUNCTION_MARKER - ); - -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_or(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fctiwz f1, f1\n" - "fctiwz f2, f2\n" - "stfd f1, -8(r1)\n" - "stfd f2, -16(r1)\n" - "lwz r10, -4(r1)\n" - "lwz r11, -12(r1)\n" //r11 and r12 have the integers - "or r10, r10, r11\n" // r10 has the result - "addis r11, 0, 0x4330\n" - "xoris r10, r10, 0x8000\n" - "stw r11, -8(r1)\n" // 0x43300000 - "stw r10, -4(r1)\n" // our integer sign flipped - "lfd f1, -8(r1)\n" - "fsub f1, f1, f30\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_or0(void) -{ - __asm__( - FUNCTION_MARKER - "fctiwz f1, f1\n" - "addis r11, 0, 0x4330\n" - "stfd f1, -8(r1)\n" - "lwz r10, -4(r1)\n" - "xoris r10, r10, 0x8000\n" - "stw r11, -8(r1)\n" // 0x43300000 - "stw r10, -4(r1)\n" // our integer sign flipped - "lfd f1, -8(r1)\n" - "fsub f1, f1, f30\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_or_op(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fctiwz f1, f1\n" - "fctiwz f2, f2\n" - "stfd f1, -8(r1)\n" - "stfd f2, -16(r1)\n" - "lwz r10, -4(r1)\n" - "lwz r11, -12(r1)\n" //r11 and r12 have the integers - "or r10, r10, r11\n" // r10 has the result - "addis r11, 0, 0x4330\n" - "xoris r10, r10, 0x8000\n" - "stw r11, -8(r1)\n" // 0x43300000 - "stw r10, -4(r1)\n" // our integer sign flipped - "lfd f1, -8(r1)\n" - "fsub f1, f1, f30\n" - "mr r3, r14\n" - "stfd f1, 0(r14)\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_xor(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fctiwz f1, f1\n" - "fctiwz f2, f2\n" - "stfd f1, -8(r1)\n" - "stfd f2, -16(r1)\n" - "lwz r10, -4(r1)\n" - "lwz r11, -12(r1)\n" //r11 and r12 have the integers - "xor r10, r10, r11\n" // r10 has the result - "addis r11, 0, 0x4330\n" - "xoris r10, r10, 0x8000\n" - "stw r11, -8(r1)\n" // 0x43300000 - "stw r10, -4(r1)\n" // our integer sign flipped - "lfd f1, -8(r1)\n" - "fsub f1, f1, f30\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_xor_op(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fctiwz f1, f1\n" - "fctiwz f2, f2\n" - "stfd f1, -8(r1)\n" - "stfd f2, -16(r1)\n" - "lwz r10, -4(r1)\n" - "lwz r11, -12(r1)\n" //r11 and r12 have the integers - "xor r10, r10, r11\n" // r10 has the result - "addis r11, 0, 0x4330\n" - "xoris r10, r10, 0x8000\n" - "stw r11, -8(r1)\n" // 0x43300000 - "stw r10, -4(r1)\n" // our integer sign flipped - "lfd f1, -8(r1)\n" - "fsub f1, f1, f30\n" - "mr r3, r14\n" - "stfd f1, 0(r14)\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_and(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fctiwz f1, f1\n" - "fctiwz f2, f2\n" - "stfd f1, -8(r1)\n" - "stfd f2, -16(r1)\n" - "lwz r10, -4(r1)\n" - "lwz r11, -12(r1)\n" //r11 and r12 have the integers - "and r10, r10, r11\n" // r10 has the result - "addis r11, 0, 0x4330\n" - "xoris r10, r10, 0x8000\n" - "stw r11, -8(r1)\n" // 0x43300000 - "stw r10, -4(r1)\n" // our integer sign flipped - "lfd f1, -8(r1)\n" - "fsub f1, f1, f30\n" - FUNCTION_MARKER - );} - -void nseel_asm_and_op(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fctiwz f1, f1\n" - "fctiwz f2, f2\n" - "stfd f1, -8(r1)\n" - "stfd f2, -16(r1)\n" - "lwz r10, -4(r1)\n" - "lwz r11, -12(r1)\n" //r11 and r12 have the integers - "and r10, r10, r11\n" // r10 has the result - "addis r11, 0, 0x4330\n" - "xoris r10, r10, 0x8000\n" - "stw r11, -8(r1)\n" // 0x43300000 - "stw r10, -4(r1)\n" // our integer sign flipped - "lfd f1, -8(r1)\n" - "fsub f1, f1, f30\n" - "mr r3, r14\n" - "stfd f1, 0(r14)\n" - FUNCTION_MARKER - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_uminus(void) -{ - __asm__( - FUNCTION_MARKER - "fneg f1, f1\n" - FUNCTION_MARKER - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_sign(void) -{ - __asm__( - FUNCTION_MARKER - "li r9, 0\n" - "stw r9, -4(r1)\n" - "lis r9, 0xbf80\n" // -1 in float - "lfs f2, -4(r1)\n" - - "fcmpu cr7, f1, f2\n" - "blt- cr7, 0f\n" - "ble- cr7, 1f\n" - " lis r9, 0x3f80\n" // 1 in float - "0:\n" - " stw r9, -4(r1)\n" - " lfs f1, -4(r1)\n" - "1:\n" - FUNCTION_MARKER - :: - ); -} - - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_bnot(void) -{ - __asm__( - FUNCTION_MARKER - "cmpwi cr0, r3, 0\n" - "addis r3, 0, 0\n" - "bne cr0, 0f\n" - "addis r3, 0, 1\n" - "0:\n" - FUNCTION_MARKER - ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_if(void) -{ - __asm__( - FUNCTION_MARKER - "cmpwi cr0, r3, 0\n" - "beq cr0, 0f\n" - " addis r6, 0, 0xdead\n" - " ori r6, r6, 0xbeef\n" - " mtctr r6\n" - " bctrl\n" - "b 1f\n" - "0:\n" - " addis r6, 0, 0xdead\n" - " ori r6, r6, 0xbeef\n" - " mtctr r6\n" - " bctrl\n" - "1:\n" - FUNCTION_MARKER - :: ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_repeat(void) -{ -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - __asm__( - FUNCTION_MARKER - "fctiwz f1, f1\n" - "stfd f1, -8(r1)\n" - "lwz r5, -4(r1)\n" // r5 has count now - "cmpwi cr0, r5, 0\n" - "ble cr0, 1f\n" // skip the loop - - "addis r7, 0, ha16(%0)\n" - "addi r7, r7, lo16(%0)\n" - - "stwu r16, -16(r1)\n" // set up the stack for the loop, save r16 - - "cmpw cr0, r7, r5\n" - "bge cr0, 0f\n" - "mr r5, r7\n" // set r5 to max if we have to -"0:\n" - "addis r6, 0, 0xdead\n" - "ori r6, r6, 0xbeef\n" - - "addi r5, r5, -1\n" - "stw r5, 4(r1)\n" - - "mtctr r6\n" - "bctrl\n" - - "lwz r16, 0(r1)\n" - "lwz r5, 4(r1)\n" - - "cmpwi cr0, r5, 0\n" - "bgt cr0, 0b\n" - - "addi r1, r1, 16\n" // restore old stack - - "1:\n" - FUNCTION_MARKER - ::"g" (NSEEL_LOOPFUNC_SUPPORT_MAXLEN) - ); -#else - __asm__( - FUNCTION_MARKER - "fctiwz f1, f1\n" - "stfd f1, -8(r1)\n" - "lwz r5, -4(r1)\n" // r5 has count now - "cmpwi cr0, r5, 0\n" - "ble cr0, 1f\n" // skip the loop - - "stwu r16, -16(r1)\n" // set up the stack for the loop, save r16 - -"0:\n" - "addis r6, 0, 0xdead\n" - "ori r6, r6, 0xbeef\n" - - "addi r5, r5, -1\n" - "stw r5, 4(r1)\n" - - "mtctr r6\n" - "bctrl\n" - - "lwz r16, 0(r1)\n" - "lwz r5, 4(r1)\n" - - "cmpwi cr0, r5, 0\n" - "bgt cr0, 0b\n" - - "addi r1, r1, 16\n" // restore old stack - - "1:\n" - FUNCTION_MARKER - :: - ); -#endif -} - -void nseel_asm_repeatwhile(void) -{ -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - __asm__( - FUNCTION_MARKER - "stwu r16, -16(r1)\n" // save r16 to stack, update stack - "addis r5, 0, ha16(%0)\n" - "addi r5, r5, lo16(%0)\n" -"0:\n" - - "addis r6, 0, 0xdead\n" - "ori r6, r6, 0xbeef\n" - "stw r5, 4(r1)\n" // save maxcnt - - "mtctr r6\n" - "bctrl\n" - - "lwz r16, 0(r1)\n" // restore r16 - "lwz r5, 4(r1)\n" // restore, check maxcnt - - "cmpwi cr7, r3, 0\n" // check return value - "addi r5, r5, -1\n" - - "beq cr7, 1f\n" - - "cmpwi cr0, r5, 0\n" - "bgt cr0, 0b\n" - "1:\n" - "addi r1, r1, 16\n" // restore stack - FUNCTION_MARKER - ::"g" (NSEEL_LOOPFUNC_SUPPORT_MAXLEN) - ); -#else - __asm__( - FUNCTION_MARKER - "stwu r16, -16(r1)\n" // save r16 to stack, update stack -"0:\n" - "addis r6, 0, 0xdead\n" - "ori r6, r6, 0xbeef\n" - - "mtctr r6\n" - "bctrl\n" - - "lwz r16, 0(r1)\n" // restore r16 - - "cmpwi cr7, r3, 0\n" // check return value - "bne cr7, 0b\n" - "addi r1, r1, 16\n" // restore stack - FUNCTION_MARKER - :: - ); - -#endif -} - - -void nseel_asm_band(void) -{ - __asm__( - FUNCTION_MARKER - "cmpwi cr7, r3, 0\n" - "beq cr7, 0f\n" - " addis r6, 0, 0xdead\n" - " ori r6, r6, 0xbeef\n" - " mtctr r6\n" - " bctrl\n" - "0:\n" - FUNCTION_MARKER - :: ); -} - -void nseel_asm_bor(void) -{ - __asm__( - FUNCTION_MARKER - "cmpwi cr7, r3, 0\n" - "bne cr7, 0f\n" - " addis r6, 0, 0xdead\n" - " ori r6, r6, 0xbeef\n" - " mtctr r6\n" - " bctrl\n" - "0:\n" - FUNCTION_MARKER - :: ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_equal(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fsub f1, f1, f2\n" - "fabs f1, f1\n" - "fcmpu cr7, f1, f31\n" - "addis r3, 0, 0\n" - "bge cr7, 0f\n" - "addis r3, 0, 1\n" - "0:\n" - FUNCTION_MARKER - :: - ); -} -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_equal_exact(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fcmpu cr7, f1, f2\n" - "addis r3, 0, 0\n" - "bne cr7, 0f\n" - "addis r3, 0, 1\n" - "0:\n" - FUNCTION_MARKER - :: - ); -} -// -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_notequal_exact(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fcmpu cr7, f1, f2\n" - "addis r3, 0, 0\n" - "beq cr7, 0f\n" - "addis r3, 0, 1\n" - "0:\n" - FUNCTION_MARKER - :: - ); -} -// -// -// -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_notequal(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fsub f1, f1, f2\n" - "fabs f1, f1\n" - "fcmpu cr7, f1, f31\n" - "addis r3, 0, 0\n" - "blt cr7, 0f\n" - " addis r3, 0, 1\n" - "0:\n" - FUNCTION_MARKER - :: - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_below(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fcmpu cr7, f1, f2\n" - "addis r3, 0, 0\n" - "ble cr7, 0f\n" - "addis r3, 0, 1\n" - "0:\n" - FUNCTION_MARKER - :: - ); -} - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_beloweq(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fcmpu cr7, f1, f2\n" - "addis r3, 0, 0\n" - "blt cr7, 0f\n" - " addis r3, 0, 1\n" - "0:\n" - FUNCTION_MARKER - :: - ); -} - - -//--------------------------------------------------------------------------------------------------------------- -void nseel_asm_above(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fcmpu cr7, f1, f2\n" - "addis r3, 0, 0\n" - "bge cr7, 0f\n" - "addis r3, 0, 1\n" - "0:\n" - FUNCTION_MARKER - :: - ); -} - -void nseel_asm_aboveeq(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fcmpu cr7, f1, f2\n" - "addis r3, 0, 0\n" - "bgt cr7, 0f\n" - "addis r3, 0, 1\n" - "0:\n" - FUNCTION_MARKER - :: - ); -} - - - -void nseel_asm_min(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f1, 0(r3)\n" - "lfd f2, 0(r14)\n" - "fcmpu cr7, f2, f1\n" - "bgt cr7, 0f\n" - "mr r3, r14\n" - "0:\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_max(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f1, 0(r3)\n" - "lfd f2, 0(r14)\n" - "fcmpu cr7, f2, f1\n" - "blt cr7, 0f\n" - "mr r3, r14\n" - "0:\n" - FUNCTION_MARKER - ); -} - - - -void nseel_asm_min_fp(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fcmpu cr7, f2, f1\n" - "bgt cr7, 0f\n" - "fmr f1, f2\n" - "0:\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_max_fp(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, 0(r14)\n" - "fcmpu cr7, f2, f1\n" - "blt cr7, 0f\n" - "fmr f1, f2\n" - "0:\n" - FUNCTION_MARKER - ); -} - - - - - - - -void _asm_generic3parm(void) -{ - __asm__( - FUNCTION_MARKER - "mr r6, r3\n" - "addis r3, 0, 0xdead\n" - "ori r3, r3, 0xbeef\n" - "addis r7, 0, 0xdead\n" - "ori r7, r7, 0xbeef\n" - "mr r4, r15\n" - "mr r5, r14\n" - "mtctr r7\n" - "subi r1, r1, 64\n" - "bctrl\n" - "addi r1, r1, 64\n" - FUNCTION_MARKER - :: - ); -} - -void _asm_generic3parm_retd(void) -{ - __asm__( - FUNCTION_MARKER - "mr r6, r3\n" - "addis r3, 0, 0xdead\n" - "ori r3, r3, 0xbeef\n" - "addis r7, 0, 0xdead\n" - "ori r7, r7, 0xbeef\n" - "mr r4, r15\n" - "mr r5, r14\n" - "mtctr r7\n" - "subi r1, r1, 64\n" - "bctrl\n" - "addi r1, r1, 64\n" - FUNCTION_MARKER - :: - ); -} - - -void _asm_generic2parm(void) // this prob neds to be fixed for ppc -{ - __asm__( - FUNCTION_MARKER - "mr r5, r3\n" - "addis r3, 0, 0xdead\n" - "ori r3, r3, 0xbeef\n" - "addis r7, 0, 0xdead\n" - "ori r7, r7, 0xbeef\n" - "mr r4, r14\n" - "mtctr r7\n" - "subi r1, r1, 64\n" - "bctrl\n" - "addi r1, r1, 64\n" - FUNCTION_MARKER - :: - ); -} - - -void _asm_generic2parm_retd(void) -{ - __asm__( - FUNCTION_MARKER - "mr r5, r3\n" - "addis r3, 0, 0xdead\n" - "ori r3, r3, 0xbeef\n" - "addis r7, 0, 0xdead\n" - "ori r7, r7, 0xbeef\n" - "mr r4, r14\n" - "mtctr r7\n" - "subi r1, r1, 64\n" - "bctrl\n" - "addi r1, r1, 64\n" - FUNCTION_MARKER - :: - ); -} - -void _asm_generic2xparm_retd(void) -{ - __asm__( - FUNCTION_MARKER - "mr r6, r3\n" - "addis r3, 0, 0xdead\n" - "ori r3, r3, 0xbeef\n" - "addis r4, 0, 0xdead\n" - "ori r4, r4, 0xbeef\n" - "addis r7, 0, 0xdead\n" - "ori r7, r7, 0xbeef\n" - "mr r5, r14\n" - "mtctr r7\n" - "subi r1, r1, 64\n" - "bctrl\n" - "addi r1, r1, 64\n" - FUNCTION_MARKER - :: - ); -} - -void _asm_generic1parm(void) // this prob neds to be fixed for ppc -{ - __asm__( - FUNCTION_MARKER - "mr r4, r3\n" - "addis r3, 0, 0xdead\n" - "ori r3, r3, 0xbeef\n" - "addis r7, 0, 0xdead\n" - "ori r7, r7, 0xbeef\n" - "mtctr r7\n" - "subi r1, r1, 64\n" - "bctrl\n" - "addi r1, r1, 64\n" - FUNCTION_MARKER - :: - ); -} - - - -void _asm_generic1parm_retd(void) -{ - __asm__( - FUNCTION_MARKER - "mr r4, r3\n" - "addis r3, 0, 0xdead\n" - "ori r3, r3, 0xbeef\n" - "addis r7, 0, 0xdead\n" - "ori r7, r7, 0xbeef\n" - "mtctr r7\n" - "subi r1, r1, 64\n" - "bctrl\n" - "addi r1, r1, 64\n" - FUNCTION_MARKER - :: - ); -} - - - - -void _asm_megabuf(void) -{ - __asm__( - FUNCTION_MARKER - "lfd f2, -8(r13)\n" - "mr r3, r13\n" - - "fadd f1, f2, f1\n" - - // f1 has (float) index of array, r3 has EEL_F ** - "fctiwz f1, f1\n" - "stfd f1, -8(r1)\n" - "lwz r4, -4(r1)\n" // r4 is index of array - - "andis. r15, r4, %0\n" // check to see if it has any bits in 0xFF800000, which is 0xFFFFFFFF - (NSEEL_RAM_BLOCKS*NSEEL_RAM_ITEMSPERBLOCK - 1) - "bne cr0, 0f\n" // out of range, jump to error - - // shr 14 (16 for NSEEL_RAM_ITEMSPERBLOCK, minus two for pointer size), which is rotate 18 - // mask 7 bits (NSEEL_RAM_BLOCKS), but leave two empty bits (pointer size) - "rlwinm r15, r4, %1, %2, 29\n" - "lwzx r15, r3, r15\n" // r15 = (r3+r15) - "cmpi cr0, r15, 0\n" - "bne cr0, 1f\n" // if nonzero, jump to final calculation - - "0:\n" - // set up function call - "addis r7, 0, 0xdead\n" - "ori r7, r7, 0xbeef\n" - "mtctr r7\n" - "subi r1, r1, 64\n" - "bctrl\n" - "addi r1, r1, 64\n" - "b 2f\n" - "1:\n" - // good news: we can do a direct addr return - // bad news: more rlwinm ugliness! - // shift left by 3 (sizeof(EEL_F)), mask off lower 3 bits, only allow 16 bits (NSEEL_RAM_ITEMSPERBLOCK) through - "rlwinm r3, r4, 3, %3, 28\n" - - // add offset of loaded block - "add r3, r3, r15\n" - - "2:\n" - FUNCTION_MARKER - :: - "i" ((0xFFFFFFFF - (NSEEL_RAM_BLOCKS*NSEEL_RAM_ITEMSPERBLOCK - 1))>>16), - "i" (32 - NSEEL_RAM_ITEMSPERBLOCK_LOG2 + 2), - "i" (30 - NSEEL_RAM_BLOCKS_LOG2), - "i" (28 - NSEEL_RAM_ITEMSPERBLOCK_LOG2 + 1) - ); -} - - -void _asm_gmegabuf(void) -{ - __asm__( - FUNCTION_MARKER - "fadd f1, f31, f1\n" - "addis r3, 0, 0xdead\n" // set up context pointer - "ori r3, r3, 0xbeef\n" - - "fctiwz f1, f1\n" - "subi r1, r1, 64\n" - - "addis r7, 0, 0xdead\n" - "ori r7, r7, 0xbeef\n" - - "stfd f1, 8(r1)\n" - "mtctr r7\n" - - "lwz r4, 12(r1)\n" - - "bctrl\n" - "addi r1, r1, 64\n" - FUNCTION_MARKER - :: - ); -} - - -void nseel_asm_fcall(void) -{ - __asm__( - FUNCTION_MARKER - "addis r6, 0, 0xdead\n" - "ori r6, r6, 0xbeef\n" - "mtctr r6\n" - "bctrl\n" - FUNCTION_MARKER - ); -} - - - -void nseel_asm_stack_push(void) -{ - __asm__( - FUNCTION_MARKER - - "addis r6, 0, 0xdead\n" - "ori r6, r6, 0xbeef\n" // r6 is stack - - "lfd f1, 0(r3)\n" // f1 is value to copy to stack - "lwz r3, 0(r6)\n" - - "addis r14, 0, 0xdead\n" - "ori r14, r14, 0xbeef\n" - "addi r3, r3, 0x8\n" - - "and r3, r3, r14\n" - - "addis r14, 0, 0xdead\n" - "ori r14, r14, 0xbeef\n" - "or r3, r3, r14\n" - - "stfd f1, 0(r3)\n" // copy parameter to stack - - "stw r3, 0(r6)\n" // update stack state - FUNCTION_MARKER - ); -} - -void nseel_asm_stack_pop(void) -{ - __asm__( - FUNCTION_MARKER - "addis r6, 0, 0xdead\n" - "ori r6, r6, 0xbeef\n" // r6 is stack - "lwz r15, 0(r6)\n" // return the old stack pointer - - "lfd f1, 0(r15)\n" - "subi r15, r15, 0x8\n" - - "addis r14, 0, 0xdead\n" - "ori r14, r14, 0xbeef\n" - "and r15, r15, r14\n" - - "addis r14, 0, 0xdead\n" - "ori r14, r14, 0xbeef\n" - "or r15, r15, r14\n" - "stw r15, 0(r6)\n" - - "stfd f1, 0(r3)\n" - FUNCTION_MARKER - ); -} - - - -void nseel_asm_stack_pop_fast(void) -{ - __asm__( - FUNCTION_MARKER - "addis r6, 0, 0xdead\n" - "ori r6, r6, 0xbeef\n" // r6 is stack - "lwz r3, 0(r6)\n" // return the old stack pointer - - "mr r15, r3\n" // update stack pointer - "subi r15, r15, 0x8\n" - - "addis r14, 0, 0xdead\n" - "ori r14, r14, 0xbeef\n" - "and r15, r15, r14\n" - - "addis r14, 0, 0xdead\n" - "ori r14, r14, 0xbeef\n" - "or r15, r15, r14\n" - "stw r15, 0(r6)\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_stack_peek(void) -{ - __asm__( - FUNCTION_MARKER - "fctiwz f1, f1\n" - "stfd f1, -8(r1)\n" - - "addis r6, 0, 0xdead\n" - "ori r6, r6, 0xbeef\n" // r6 is stack - - "lwz r14, -4(r1)\n" - "rlwinm r14, r14, 3, 0, 28\n" // slwi r14, r14, 3 -- 3 is log2(sizeof(EEL_F)) -- 28 represents 31-3 - "lwz r3, 0(r6)\n" // return the old stack pointer - - "sub r3, r3, r14\n" - - "addis r14, 0, 0xdead\n" - "ori r14, r14, 0xbeef\n" - "and r3, r3, r14\n" - - "addis r14, 0, 0xdead\n" - "ori r14, r14, 0xbeef\n" - "or r3, r3, r14\n" - FUNCTION_MARKER - ); -} - - -void nseel_asm_stack_peek_top(void) -{ - __asm__( - FUNCTION_MARKER - "addis r6, 0, 0xdead\n" - "ori r6, r6, 0xbeef\n" // r6 is stack - "lwz r3, 0(r6)\n" // return the old stack pointer - FUNCTION_MARKER - ); -} - - -void nseel_asm_stack_peek_int(void) -{ - __asm__( - FUNCTION_MARKER - "addis r6, 0, 0xdead\n" - "ori r6, r6, 0xbeef\n" // r6 is stack - "lwz r3, 0(r6)\n" // return the old stack pointer - - "addis r14, 0, 0xdead\n" // add manual offset - "ori r14, r14, 0xbeef\n" - "sub r3, r3, r14\n" - - "addis r14, 0, 0xdead\n" - "ori r14, r14, 0xbeef\n" - "and r3, r3, r14\n" - - "addis r14, 0, 0xdead\n" - "ori r14, r14, 0xbeef\n" - "or r3, r3, r14\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_stack_exch(void) -{ - __asm__( - FUNCTION_MARKER - "addis r6, 0, 0xdead\n" - "ori r6, r6, 0xbeef\n" // r6 is stack - "lfd f1, 0(r3)\n" - "lwz r14, 0(r6)\n" - "lfd f2, 0(r14)\n" - - "stfd f1, 0(r14)\n" - "stfd f2, 0(r3)\n" - FUNCTION_MARKER - ); -} - - -void nseel_asm_booltofp(void) -{ - __asm__( - FUNCTION_MARKER - "cmpwi cr7, r3, 0\n" - "li r14, 0\n" - "beq cr7, 0f\n" - "addis r14, 0, 0x3f80\n" - "0:\n" - "stw r14, -8(r1)\n" - "lfs f1, -8(r1)\n" - FUNCTION_MARKER - ); -} - -void nseel_asm_fptobool(void) -{ - __asm__( - FUNCTION_MARKER - "fabs f1, f1\n" - "fcmpu cr7, f1, f31\n" - "addis r3, 0, 1\n" - "bge cr7, 0f\n" - " addis r3, 0, 0\n" - "0:\n" - FUNCTION_MARKER - :: - ); -} - -void nseel_asm_fptobool_rev(void) -{ - __asm__( - FUNCTION_MARKER - "fabs f1, f1\n" - "fcmpu cr7, f1, f31\n" - "addis r3, 0, 0\n" - "bge cr7, 0f\n" - " addis r3, 0, 1\n" - "0:\n" - FUNCTION_MARKER - :: - ); -} - diff --git a/oversampling/WDL/eel2/asm-nseel-x64-macho.o b/oversampling/WDL/eel2/asm-nseel-x64-macho.o deleted file mode 100644 index b019fc2..0000000 Binary files a/oversampling/WDL/eel2/asm-nseel-x64-macho.o and /dev/null differ diff --git a/oversampling/WDL/eel2/asm-nseel-x64-sse.asm b/oversampling/WDL/eel2/asm-nseel-x64-sse.asm deleted file mode 100644 index 2a71c1c..0000000 --- a/oversampling/WDL/eel2/asm-nseel-x64-sse.asm +++ /dev/null @@ -1,1357 +0,0 @@ -; these must be synced with any changes in ns-eel-int.h -%define NSEEL_RAM_BLOCKS_DEFAULTMAX 128 -%define NSEEL_RAM_BLOCKS_LOG2 9 -%define NSEEL_RAM_ITEMSPERBLOCK_LOG2 16 -%define NSEEL_RAM_BLOCKS (1 << NSEEL_RAM_BLOCKS_LOG2) -%define NSEEL_RAM_ITEMSPERBLOCK (1< -#include - -#define YY_USER_ACTION yylloc->first_line = yylineno; - -#define YY_FATAL_ERROR(msg) { ((struct yyguts_t*)yyscanner)->yyextra_r->errVar=1; } -#define YY_INPUT(buf,result,max_size) { (result) = nseel_gets(yyextra,(buf),max_size); } - -#define YY_EXTRA_TYPE compileContext * - -#undef YY_BUF_SIZE -#define YY_BUF_SIZE (NSEEL_MAX_VARIABLE_NAMELEN*2) - -#undef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE (NSEEL_MAX_VARIABLE_NAMELEN) - -#include "y.tab.h" - -#ifdef _WIN32 -#define YY_NO_UNISTD_H -#endif - -#include "ns-eel-int.h" - -int nseel_gets(compileContext *ctx, char *buf, size_t sz); - -#define PARSENUM *yylval = nseel_translate(yyextra,yytext, 0); return VALUE; -#define EEL_ACTION(x) return x; - -#ifdef stdin -#undef stdin -#endif -#define stdin (0) - -#ifdef stdout -#undef stdout -#endif -#define stdout (0) - -static int g_fake_errno; -#ifdef errno -#undef errno -#endif - -#define errno g_fake_errno - -static void comment(yyscan_t yyscanner); - -%} - -%% - -[0-9]+\.?[0-9]* PARSENUM; -\.[0-9]+ PARSENUM; -0[xX][0-9a-fA-F]* PARSENUM; -\$[xX][0-9a-fA-F]* PARSENUM; -\$\~[0-9]* PARSENUM; -\$[Ee] PARSENUM; -\$[Pp][Ii] PARSENUM; -\$[Pp][Hh][Ii] PARSENUM; -\$\'.\' PARSENUM; -\#[a-zA-Z0-9\._]* *yylval = nseel_translate(yyextra,yytext, 0); return STRING_IDENTIFIER; -\<\< return TOKEN_SHL; -\>\> return TOKEN_SHR; -\<= return TOKEN_LTE; -\>= return TOKEN_GTE; -== return TOKEN_EQ; -=== return TOKEN_EQ_EXACT; -\!= return TOKEN_NE; -\!== return TOKEN_NE_EXACT; -\&\& return TOKEN_LOGICAL_AND; -\|\| return TOKEN_LOGICAL_OR; -\+= return TOKEN_ADD_OP; --= return TOKEN_SUB_OP; -%= return TOKEN_MOD_OP; -\|= return TOKEN_OR_OP; -\&= return TOKEN_AND_OP; -\~= return TOKEN_XOR_OP; -\/= return TOKEN_DIV_OP; -\*= return TOKEN_MUL_OP; -\^= return TOKEN_POW_OP; - -[a-zA-Z_][a-zA-Z0-9\._]* &yylval = nseel_createCompiledValuePtr((compileContext *)yyextra, NULL, yytext); return IDENTIFIER; - -[ \t\r\n]+ /* whitespace */ -\/\/.*$ /* comment */ -"/*" { comment(yyscanner); } - -. return (int)yytext[0]; - -%% - -static void comment(yyscan_t yyscanner) -{ - int c,lc=0; - - while (0 != (c = input(yyscanner))) - { - if (c == '/' && lc == '*') return; - lc = c; - } - // end of file, ignore for now -} diff --git a/oversampling/WDL/eel2/eel2.vim b/oversampling/WDL/eel2/eel2.vim deleted file mode 100644 index bd77e45..0000000 --- a/oversampling/WDL/eel2/eel2.vim +++ /dev/null @@ -1,370 +0,0 @@ -" Vim syntax file -" This needs a lot of C-specific stuff removed, please help if you care =) -" Language: EEL2, based on: -" -" -" Language: C - Maintainer: Bram Moolenaar - Last Change: 2009 Nov 17 - -" Quit when a (custom) syntax file was already loaded -if exists("b:current_syntax") - finish -endif - -" A bunch of useful C keywords -syn keyword cStatement function globals global local instance -syn keyword cRepeat while loop -syn keyword cRepeat sin cos tan sqrt log log10 asin acos atan atan2 exp abs sqr min max sign rand floor ceil invsqrt freembuf memcpy memset stack_psuh stack_pop stack_peek stack_exch -syn keyword cRepeat atomic_setifequal atomic_exch atomic_add atomic_set atomic_get convolve_c fft ifft fft_permute fft_ipermute fopen fread fgets fgetc fwrite fprintf fseek ftell feof fflush fclose -syn keyword cRepeat gfx_lineto gfx_lineto gfx_rectto gfx_rect gfx_line gfx_gradrect gfx_muladdrect gfx_deltablit gfx_transformblit gfx_blurto gfx_drawnumber gfx_drawchar gfx_drawstr gfx_measurestr gfx_printf gfx_setpixel gfx_getpixel gfx_getimgdim gfx_setimgdim gfx_loadimg gfx_blit gfx_blitext gfx_blit gfx_setfont gfx_getfont gfx_init gfx_quit gfx_getchar -syn keyword cRepeat mdct imdct sleep time time_precise tcp_listen tcp_listen_end tcp_connect tcp_send tcp_recv tcp_set_block tcp_close strlen -syn keyword cRepeat strcat strcpy strcmp stricmp strncat strncpy strncmp strnicmp str_setlen strcpy_from strcpy_substr strcpy_substr str_getchar str_setchar str_getchar str_setchar str_insert str_delsub sprintf printf match matchi - -syn keyword cTodo contained TODO FIXME XXX - -" It's easy to accidentally add a space after a backslash that was intended -" for line continuation. Some compilers allow it, which makes it -" unpredicatable and should be avoided. -syn match cBadContinuation contained "\\\s\+$" - -" cCommentGroup allows adding matches for special things in comments -syn cluster cCommentGroup contains=cTodo,cBadContinuation - -" String and Character constants -" Highlight special characters (those which have a backslash) differently -syn match cSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)" -if !exists("c_no_utf") - syn match cSpecial display contained "\\\(u\x\{4}\|U\x\{8}\)" -endif -if exists("c_no_cformat") - syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,@Spell - " cCppString: same as cString, but ends at end of line - syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,@Spell -else - if !exists("c_no_c99") " ISO C99 - syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlLjzt]\|ll\|hh\)\=\([aAbdiuoxXDOUfFeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained - else - syn match cFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([bdiuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained - endif - syn match cFormat display "%%" contained - syn region cString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=cSpecial,cFormat,@Spell - " cCppString: same as cString, but ends at end of line - syn region cCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial,cFormat,@Spell -endif - -syn match cCharacter "L\='[^\\]'" -syn match cCharacter "L'[^']*'" contains=cSpecial -syn match cCharacter "'[^']*'" contains=cSpecial -if exists("c_gnu") - syn match cSpecialError "L\='\\[^'\"?\\abefnrtv]'" - syn match cSpecialCharacter "L\='\\['\"?\\abefnrtv]'" -else - syn match cSpecialError "L\='\\[^'\"?\\abfnrtv]'" - syn match cSpecialCharacter "L\='\\['\"?\\abfnrtv]'" -endif -syn match cSpecialCharacter display "L\='\\\o\{1,3}'" -syn match cSpecialCharacter display "'\\x\x\{1,2}'" -syn match cSpecialCharacter display "L'\\x\x\+'" - -"when wanted, highlight trailing white space -if exists("c_space_errors") - if !exists("c_no_trail_space_error") - syn match cSpaceError display excludenl "\s\+$" - endif - if !exists("c_no_tab_space_error") - syn match cSpaceError display " \+\t"me=e-1 - endif -endif - -" This should be before cErrInParen to avoid problems with #define ({ xxx }) -if exists("c_curly_error") - syntax match cCurlyError "}" - syntax region cBlock start="{" end="}" contains=ALLBUT,cCurlyError,@cParenGroup,cErrInParen,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell fold -else - syntax region cBlock start="{" end="}" transparent fold -endif - -"catch errors caused by wrong parenthesis and brackets -" also accept <% for {, %> for }, <: for [ and :> for ] (C99) -" But avoid matching <::. -syn cluster cParenGroup contains=cParenError,cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom -if exists("c_no_curly_error") - syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell - " cCppParen: same as cParen but ends at end-of-line; used in cDefine - syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell - syn match cParenError display ")" - syn match cErrInParen display contained "^[{}]\|^<%\|^%>" -elseif exists("c_no_bracket_error") - syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cCppString,@Spell - " cCppParen: same as cParen but ends at end-of-line; used in cDefine - syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cParen,cString,@Spell - syn match cParenError display ")" - syn match cErrInParen display contained "[{}]\|<%\|%>" -else - syn region cParen transparent start='(' end=')' contains=ALLBUT,@cParenGroup,cCppParen,cErrInBracket,cCppBracket,cCppString,@Spell - " cCppParen: same as cParen but ends at end-of-line; used in cDefine - syn region cCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@cParenGroup,cErrInBracket,cParen,cBracket,cString,@Spell - syn match cParenError display "[\])]" - syn match cErrInParen display contained "[\]{}]\|<%\|%>" - syn region cBracket transparent start='\[\|<::\@!' end=']\|:>' contains=ALLBUT,@cParenGroup,cErrInParen,cCppParen,cCppBracket,cCppString,@Spell - " cCppBracket: same as cParen but ends at end-of-line; used in cDefine - syn region cCppBracket transparent start='\[\|<::\@!' skip='\\$' excludenl end=']\|:>' end='$' contained contains=ALLBUT,@cParenGroup,cErrInParen,cParen,cBracket,cString,@Spell - syn match cErrInBracket display contained "[){}]\|<%\|%>" -endif - -"integer number, or floating point number without a dot and with "f". -syn case ignore -syn match cNumbers display transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctalError,cOctal -" Same, but without octal error (for comments) -syn match cNumbersCom display contained transparent "\<\d\|\.\d" contains=cNumber,cFloat,cOctal -syn match cNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>" -"hex number -syn match cNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>" -" Flag the first zero of an octal number as something special -syn match cOctal display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=cOctalZero -syn match cOctalZero display contained "\<0" -syn match cFloat display contained "\d\+f" -"floating point number, with dot, optional exponent -syn match cFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=" -"floating point number, starting with a dot, optional exponent -syn match cFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>" -"floating point number, without dot, with exponent -syn match cFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>" -if !exists("c_no_c99") - "hexadecimal floating point number, optional leading digits, with dot, with exponent - syn match cFloat display contained "0x\x*\.\x\+p[-+]\=\d\+[fl]\=\>" - "hexadecimal floating point number, with leading digits, optional dot, with exponent - syn match cFloat display contained "0x\x\+\.\=p[-+]\=\d\+[fl]\=\>" -endif - -" flag an octal number with wrong digits -syn match cOctalError display contained "0\o*[89]\d*" -syn case match - -if exists("c_comment_strings") - " A comment can contain cString, cCharacter and cNumber. - " But a "*/" inside a cString in a cComment DOES end the comment! So we - " need to use a special type of cString: cCommentString, which also ends on - " "*/", and sees a "*" at the start of the line as comment again. - " Unfortunately this doesn't very well work for // type of comments :-( - syntax match cCommentSkip contained "^\s*\*\($\|\s\+\)" - syntax region cCommentString contained start=+L\=\\\@" skip="\\$" end="$" keepend contains=cComment,cCommentL,cCppString,cCharacter,cCppParen,cParenError,cNumbers,cCommentError,cSpaceError -syn match cPreCondit display "^\s*\(%:\|#\)\s*\(else\|endif\)\>" -if !exists("c_no_if0") - if !exists("c_no_if0_fold") - syn region cCppOut start="^\s*\(%:\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=cCppOut2 fold - else - syn region cCppOut start="^\s*\(%:\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=cCppOut2 - endif - syn region cCppOut2 contained start="0" end="^\s*\(%:\|#\)\s*\(endif\>\|else\>\|elif\>\)" contains=cSpaceError,cCppSkip - syn region cCppSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cSpaceError,cCppSkip -endif -syn region cIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ -syn match cIncluded display contained "<[^>]*>" -syn match cInclude display "^\s*\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded -"syn match cLineSkip "\\$" -syn cluster cPreProcGroup contains=cPreCondit,cIncluded,cInclude,cDefine,cErrInParen,cErrInBracket,cUserLabel,cSpecial,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cString,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cParen,cBracket,cMulti -syn region cDefine start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell -syn region cPreProc start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@cPreProcGroup,@Spell - -" Highlight User Labels -syn cluster cMultiGroup contains=cIncluded,cSpecial,cCommentSkip,cCommentString,cComment2String,@cCommentGroup,cCommentStartError,cUserCont,cUserLabel,cOctalZero,cCppOut,cCppOut2,cCppSkip,cFormat,cNumber,cFloat,cOctal,cOctalError,cNumbersCom,cCppParen,cCppBracket,cCppString -syn region cMulti transparent start='?' skip='::' end=':' end=')' end=';' contains=ALLBUT,@cMultiGroup,@Spell -" Avoid matching foo::bar() in C++ by requiring that the next char is not ':' - -syn match cUserLabel display "\I\i*" contained - - -if exists("c_minlines") - let b:c_minlines = c_minlines -else - if !exists("c_no_if0") - let b:c_minlines = 50 " #if 0 constructs can be long - else - let b:c_minlines = 15 " mostly for () constructs - endif -endif -if exists("c_curly_error") - syn sync fromstart -else - exec "syn sync ccomment cComment minlines=" . b:c_minlines -endif - -" Define the default highlighting. -" Only used when an item doesn't have highlighting yet -hi def link cFormat cSpecial -hi def link cCppString cString -hi def link cCommentL cComment -hi def link cCommentStart cComment -hi def link cUserLabel Label -hi def link cRepeat Repeat -hi def link cCharacter Character -hi def link cSpecialCharacter cSpecial -hi def link cNumber Number -hi def link cOctal Number -hi def link cOctalZero PreProc " link this to Error if you want -hi def link cFloat Float -hi def link cOctalError cError -hi def link cParenError cError -hi def link cErrInParen cError -hi def link cErrInBracket cError -hi def link cCommentError cError -hi def link cCommentStartError cError -hi def link cSpaceError cError -hi def link cSpecialError cError -hi def link cCurlyError cError -hi def link cOperator Operator -hi def link cStructure Structure -hi def link cStorageClass StorageClass -hi def link cInclude Include -hi def link cPreProc PreProc -hi def link cDefine Macro -hi def link cIncluded cString -hi def link cError Error -hi def link cStatement Statement -hi def link cPreCondit PreCondit -hi def link cType Type -hi def link cConstant Constant -hi def link cCommentString cString -hi def link cComment2String cString -hi def link cCommentSkip cComment -hi def link cString String -hi def link cComment Comment -hi def link cSpecial SpecialChar -hi def link cTodo Todo -hi def link cBadContinuation Error -hi def link cCppSkip cCppOut -hi def link cCppOut2 cCppOut -hi def link cCppOut Comment - -let b:current_syntax = "eel2" - -" vim: ts=8 diff --git a/oversampling/WDL/eel2/eel2.y b/oversampling/WDL/eel2/eel2.y deleted file mode 100644 index c7bf561..0000000 --- a/oversampling/WDL/eel2/eel2.y +++ /dev/null @@ -1,376 +0,0 @@ -%pure-parser -%name-prefix="nseel" -%parse-param { compileContext* context } -%lex-param { void* scanner } - - -/* this will prevent y.tab.c from ever calling yydestruct(), since we do not use it and it is a waste */ -%destructor { - #define yydestruct(a,b,c,d,e) -} VALUE - - -%{ -#ifdef _WIN32 -#include -#endif -#include -#include -#include -#include - -#include "y.tab.h" -#include "ns-eel-int.h" - -#define scanner context->scanner -#define YY_(x) ("") - -%} - -%token VALUE IDENTIFIER TOKEN_SHL TOKEN_SHR -%token TOKEN_LTE TOKEN_GTE TOKEN_EQ TOKEN_EQ_EXACT TOKEN_NE TOKEN_NE_EXACT TOKEN_LOGICAL_AND TOKEN_LOGICAL_OR -%token TOKEN_ADD_OP TOKEN_SUB_OP TOKEN_MOD_OP TOKEN_OR_OP TOKEN_AND_OP TOKEN_XOR_OP TOKEN_DIV_OP TOKEN_MUL_OP TOKEN_POW_OP -%token STRING_LITERAL STRING_IDENTIFIER -%expect 75 -%start program - -%% - -more_params: - expression - | expression ',' more_params - { - $$ = nseel_createMoreParametersOpcode(context,$1,$3); - } - ; - -string: - STRING_LITERAL - | STRING_LITERAL string - { - ((struct eelStringSegmentRec *)$1)->_next = (struct eelStringSegmentRec *)$2; - $$ = $1; - } - ; - -assignable_value: - IDENTIFIER - { - if (!($$ = nseel_resolve_named_symbol(context, $1, -1, NULL))) /* convert from purely named to namespace-relative, etc */ - { - yyerror(&yyloc, context, ""); - YYERROR; - } - } - /* we used to have VALUE in here rather than rvalue, to allow 1=1 1+=2 etc, but silly to, - though this breaks Vmorph, which does 1=1 for a nop, and Jonas DrumReaplacer, which does x = 0 = y = 0 */ - | '(' expression ')' - { - $$ = $2; - } - | IDENTIFIER '(' expression ')' '(' expression ')' - { - int err; - if (!($$ = nseel_setCompiledFunctionCallParameters(context,$1, $3, 0, 0, $6, &err))) - { - if (err == -1) yyerror(&yylsp[-2], context, ""); - else if (err == 0) yyerror(&yylsp[-6], context, ""); - else yyerror(&yylsp[-3], context, ""); // parameter count wrong - - YYERROR; - } - } - | IDENTIFIER '(' expression ')' - { - int err; - if (!($$ = nseel_setCompiledFunctionCallParameters(context,$1, $3, 0, 0, 0, &err))) - { - if (err == 0) yyerror(&yylsp[-3], context, ""); - else yyerror(&yylsp[0], context, ""); // parameter count wrong - YYERROR; - } - } - | IDENTIFIER '(' ')' - { - int err; - if (!($$ = nseel_setCompiledFunctionCallParameters(context,$1, nseel_createCompiledValue(context,0.0), 0, 0, 0,&err))) - { - if (err == 0) yyerror(&yylsp[-2], context, ""); // function not found - else yyerror(&yylsp[0], context, ""); // parameter count wrong - YYERROR; - } - } - | IDENTIFIER '(' expression ',' expression ')' - { - int err; - if (!($$ = nseel_setCompiledFunctionCallParameters(context,$1, $3, $5, 0, 0,&err))) - { - if (err == 0) yyerror(&yylsp[-5], context, ""); - else if (err == 2) yyerror(&yylsp[0], context, ""); // needs more than 2 parameters - else yyerror(&yylsp[-2], context, ""); // less than 2 - YYERROR; - } - } - | IDENTIFIER '(' expression ',' expression ',' more_params ')' - { - int err; - if (!($$ = nseel_setCompiledFunctionCallParameters(context,$1, $3, $5, $7, 0, &err))) - { - if (err == 0) yyerror(&yylsp[-7], context, ""); - else if (err==2) yyerror(&yylsp[0], context, ""); // needs more parameters - else if (err==4) yyerror(&yylsp[-4], context, ""); // needs single parameter - else yyerror(&yylsp[-2], context, ""); // less parm - YYERROR; - } - } - | rvalue '[' ']' - { - $$ = nseel_createMemoryAccess(context,$1,0); - } - | rvalue '[' expression ']' - { - $$ = nseel_createMemoryAccess(context,$1,$3); - } - ; - -rvalue: - VALUE - | STRING_IDENTIFIER - | string - { - $$ = nseel_eelMakeOpcodeFromStringSegments(context,(struct eelStringSegmentRec *)$1); - } - | assignable_value - ; - - -assignment: - rvalue - | assignable_value '=' if_else_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_ASSIGN,2,$1,$3); - } - | assignable_value TOKEN_ADD_OP if_else_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_ADD_OP,2,$1,$3); - } - | assignable_value TOKEN_SUB_OP if_else_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_SUB_OP,2,$1,$3); - } - | assignable_value TOKEN_MOD_OP if_else_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_MOD_OP,2,$1,$3); - } - | assignable_value TOKEN_OR_OP if_else_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_OR_OP,2,$1,$3); - } - | assignable_value TOKEN_AND_OP if_else_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_AND_OP,2,$1,$3); - } - | assignable_value TOKEN_XOR_OP if_else_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_XOR_OP,2,$1,$3); - } - | assignable_value TOKEN_DIV_OP if_else_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_DIV_OP,2,$1,$3); - } - | assignable_value TOKEN_MUL_OP if_else_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_MUL_OP,2,$1,$3); - } - | assignable_value TOKEN_POW_OP if_else_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_POW_OP,2,$1,$3); - } - | STRING_IDENTIFIER '=' if_else_expr - { - $$ = nseel_createFunctionByName(context,"strcpy",2,$1,$3,NULL); - } - | STRING_IDENTIFIER TOKEN_ADD_OP if_else_expr - { - $$ = nseel_createFunctionByName(context,"strcat",2,$1,$3,NULL); - } - ; - -unary_expr: - assignment - | '+' unary_expr - { - $$ = $2; - } - | '-' unary_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_UMINUS,1,$2,0); - } - | '!' unary_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_NOT,1,$2,0); - } - ; - -pow_expr: - unary_expr - | pow_expr '^' unary_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_POW,2,$1,$3); - } - ; - -mod_expr: - pow_expr - | mod_expr '%' pow_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_MOD,2,$1,$3); - } - | mod_expr TOKEN_SHL pow_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_SHL,2,$1,$3); - } - | mod_expr TOKEN_SHR pow_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_SHR,2,$1,$3); - } - ; - -div_expr: - mod_expr - | div_expr '/' mod_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_DIVIDE,2,$1,$3); - } - ; - - -mul_expr: - div_expr - | mul_expr '*' div_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_MULTIPLY,2,$1,$3); - } - ; - - -sub_expr: - mul_expr - | sub_expr '-' mul_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_SUB,2,$1,$3); - } - ; - -add_expr: - sub_expr - | add_expr '+' sub_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_ADD,2,$1,$3); - } - ; - -andor_expr: - add_expr - | andor_expr '&' add_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_AND,2,$1,$3); - } - | andor_expr '|' add_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_OR,2,$1,$3); - } - | andor_expr '~' add_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_XOR,2,$1,$3); - } - ; - -cmp_expr: - andor_expr - | cmp_expr '<' andor_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_LT,2,$1,$3); - } - | cmp_expr '>' andor_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_GT,2,$1,$3); - } - | cmp_expr TOKEN_LTE andor_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_LTE,2,$1,$3); - } - | cmp_expr TOKEN_GTE andor_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_GTE,2,$1,$3); - } - | cmp_expr TOKEN_EQ andor_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_EQ,2,$1,$3); - } - | cmp_expr TOKEN_EQ_EXACT andor_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_EQ_EXACT,2,$1,$3); - } - | cmp_expr TOKEN_NE andor_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_NE,2,$1,$3); - } - | cmp_expr TOKEN_NE_EXACT andor_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_NE_EXACT,2,$1,$3); - } - ; - -logical_and_or_expr: - cmp_expr - | logical_and_or_expr TOKEN_LOGICAL_AND cmp_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_LOGICAL_AND,2,$1,$3); - } - | logical_and_or_expr TOKEN_LOGICAL_OR cmp_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_LOGICAL_OR,2,$1,$3); - } - ; - -if_else_expr: - logical_and_or_expr - | logical_and_or_expr '?' if_else_expr ':' if_else_expr - { - $$ = nseel_createIfElse(context, $1, $3, $5); - } - | logical_and_or_expr '?' ':' if_else_expr - { - $$ = nseel_createIfElse(context, $1, 0, $4); - } - | logical_and_or_expr '?' if_else_expr - { - $$ = nseel_createIfElse(context, $1, $3, 0); - } - ; - - -expression: - if_else_expr - | expression ';' if_else_expr - { - $$ = nseel_createSimpleCompiledFunction(context,FN_JOIN_STATEMENTS,2,$1,$3); - } - | expression ';' - { - $$ = $1; - } - ; - - -program: - expression - { - if (@1.first_line) { } - context->result = $1; - } - ; - - -%% diff --git a/oversampling/WDL/eel2/eel_atomic.h b/oversampling/WDL/eel2/eel_atomic.h deleted file mode 100644 index f71d1c2..0000000 --- a/oversampling/WDL/eel2/eel_atomic.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef __EEL_ATOMIC_H__ -#define __EEL_ATOMIC_H__ - -// requires these to be defined -//#define EEL_ATOMIC_SET_SCOPE(opaque) WDL_Mutex *mutex = (opaque?&((effectProcessor *)opaque)->m_atomic_mutex:&atomic_mutex); -//#define EEL_ATOMIC_ENTER mutex->Enter() -//#define EEL_ATOMIC_LEAVE mutex->Leave() - -static EEL_F NSEEL_CGEN_CALL atomic_setifeq(void *opaque, EEL_F *a, EEL_F *cmp, EEL_F *nd) -{ - EEL_F ret; - EEL_ATOMIC_SET_SCOPE(opaque) - EEL_ATOMIC_ENTER; - ret = *a; - if (fabs(ret - *cmp) < NSEEL_CLOSEFACTOR) *a = *nd; - EEL_ATOMIC_LEAVE; - return ret; -} - -static EEL_F NSEEL_CGEN_CALL atomic_exch(void *opaque, EEL_F *a, EEL_F *b) -{ - EEL_F tmp; - EEL_ATOMIC_SET_SCOPE(opaque) - EEL_ATOMIC_ENTER; - tmp = *b; - *b = *a; - *a = tmp; - EEL_ATOMIC_LEAVE; - return tmp; -} - -static EEL_F NSEEL_CGEN_CALL atomic_add(void *opaque, EEL_F *a, EEL_F *b) -{ - EEL_F tmp; - EEL_ATOMIC_SET_SCOPE(opaque) - EEL_ATOMIC_ENTER; - tmp = (*a += *b); - EEL_ATOMIC_LEAVE; - return tmp; -} - -static EEL_F NSEEL_CGEN_CALL atomic_set(void *opaque, EEL_F *a, EEL_F *b) -{ - EEL_F tmp; - EEL_ATOMIC_SET_SCOPE(opaque) - EEL_ATOMIC_ENTER; - tmp = *a = *b; - EEL_ATOMIC_LEAVE; - return tmp; -} - -static EEL_F NSEEL_CGEN_CALL atomic_get(void *opaque, EEL_F *a) -{ - EEL_F tmp; - EEL_ATOMIC_SET_SCOPE(opaque) - EEL_ATOMIC_ENTER; - tmp = *a; - EEL_ATOMIC_LEAVE; - return tmp; -} - -static void EEL_atomic_register() -{ - NSEEL_addfunc_retval("atomic_setifequal",3, NSEEL_PProc_THIS, &atomic_setifeq); - NSEEL_addfunc_retval("atomic_exch",2, NSEEL_PProc_THIS, &atomic_exch); - NSEEL_addfunc_retval("atomic_add",2, NSEEL_PProc_THIS, &atomic_add); - NSEEL_addfunc_retval("atomic_set",2, NSEEL_PProc_THIS, &atomic_set); - NSEEL_addfunc_retval("atomic_get",1, NSEEL_PProc_THIS, &atomic_get); -} - -#endif diff --git a/oversampling/WDL/eel2/eel_eval.h b/oversampling/WDL/eel2/eel_eval.h deleted file mode 100644 index 8c04e96..0000000 --- a/oversampling/WDL/eel2/eel_eval.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef _EEL_EVAL_H_ -#define _EEL_EVAL_H_ - -#ifndef EEL_EVAL_GET_CACHED -#define EEL_EVAL_GET_CACHED(str, ch) (NULL) -#endif - -#ifndef EEL_EVAL_SET_CACHED -#define EEL_EVAL_SET_CACHED(sv, ch) { NSEEL_code_free(ch); free(sv); } -#endif - -#ifndef EEL_EVAL_SCOPE_ENTER -#define EEL_EVAL_SCOPE_ENTER 1 -#define EEL_EVAL_SCOPE_LEAVE -#endif - -static EEL_F NSEEL_CGEN_CALL _eel_eval(void *opaque, EEL_F *s) -{ - NSEEL_VMCTX r = EEL_EVAL_GET_VMCTX(opaque); - NSEEL_CODEHANDLE ch = NULL; - char *sv=NULL; - if (r) - { - EEL_STRING_MUTEXLOCK_SCOPE - const char *str=EEL_STRING_GET_FOR_INDEX(*s,NULL); -#ifdef EEL_STRING_DEBUGOUT - if (!str) - { - EEL_STRING_DEBUGOUT("eval() passed invalid string handle %f",*s); - } -#endif - if (str && *str) - { - sv=EEL_EVAL_GET_CACHED(str,ch); - if (!sv) sv=strdup(str); - } - } - if (sv) - { - if (!ch) ch = NSEEL_code_compile(r,sv,0); - if (ch) - { - if (EEL_EVAL_SCOPE_ENTER) - { - NSEEL_code_execute(ch); - EEL_EVAL_SCOPE_LEAVE - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("eval() reentrancy limit reached"); -#endif - } - - EEL_EVAL_SET_CACHED(sv,ch); - return 1.0; - } - else - { -#ifdef EEL_STRING_DEBUGOUT - const char *err=NSEEL_code_getcodeerror(r); - if (err) EEL_STRING_DEBUGOUT("eval() error: %s",err); -#endif - } - free(sv); - } - return 0.0; -} - -void EEL_eval_register() -{ - NSEEL_addfunc_retval("eval",1,NSEEL_PProc_THIS,&_eel_eval); -} - -#ifdef EEL_WANT_DOCUMENTATION -static const char *eel_eval_function_reference = - "eval\t\"code\"\tExecutes code passed in. Code can use functions, but functions created in code can't be used elsewhere.\0" -; -#endif - -#endif diff --git a/oversampling/WDL/eel2/eel_fft.h b/oversampling/WDL/eel2/eel_fft.h deleted file mode 100644 index 6b64d03..0000000 --- a/oversampling/WDL/eel2/eel_fft.h +++ /dev/null @@ -1,396 +0,0 @@ -#ifndef __EEL_FFT_H_ -#define __EEL_FFT_H_ - -#include "../fft.h" -#if WDL_FFT_REALSIZE != EEL_F_SIZE -#error WDL_FFT_REALSIZE -- EEL_F_SIZE size mismatch -#endif - -#ifndef EEL_FFT_MINBITLEN -#define EEL_FFT_MINBITLEN 4 -#endif - -#ifndef EEL_FFT_MAXBITLEN -#define EEL_FFT_MAXBITLEN 15 -#endif - -#ifndef EEL_FFT_MINBITLEN_REORDER -#define EEL_FFT_MINBITLEN_REORDER (EEL_FFT_MINBITLEN-1) -#endif - -//#define EEL_SUPER_FAST_FFT_REORDERING // quite a bit faster (50-100%) than "normal", but uses a 256kb lookup -//#define EEL_SLOW_FFT_REORDERING // 20%-80% slower than normal, alloca() use, no reason to ever use this - -#ifdef EEL_SUPER_FAST_FFT_REORDERING -static int *fft_reorder_table_for_bitsize(int bitsz) -{ - static int s_tab[ (2 << EEL_FFT_MAXBITLEN) + 24*(EEL_FFT_MAXBITLEN-EEL_FFT_MINBITLEN_REORDER+1) ]; // big 256kb table, ugh - if (bitsz<=EEL_FFT_MINBITLEN_REORDER) return s_tab; - return s_tab + (1<= 4 && dir < 8) - { - if (dir == 4 || dir == 5) - { - //timingEnter(0); -#if defined(EEL_SUPER_FAST_FFT_REORDERING) || !defined(EEL_SLOW_FFT_REORDERING) - fft_reorder_buffer(sizebits,(WDL_FFT_COMPLEX*)data,dir==4); -#else - // old blech - const int flen=1<= 0 && dir < 2) - { - WDL_fft((WDL_FFT_COMPLEX*)data,1<= 2 && dir < 4) - { - WDL_real_fft((WDL_FFT_REAL*)data,1<1 && bitl < EEL_FFT_MAXBITLEN) - { - bitl++; - l>>=1; - } - if (bitl < ((dir&4) ? EEL_FFT_MINBITLEN_REORDER : EEL_FFT_MINBITLEN)) // smallest FFT is 16 item, smallest reorder is 8 item - { - return start; - } - ilen=1< NSEEL_RAM_ITEMSPERBLOCK || dest_offs < 0 || src_offs < 0 || - dest_offs >= NSEEL_RAM_BLOCKS*NSEEL_RAM_ITEMSPERBLOCK || src_offs >= NSEEL_RAM_BLOCKS*NSEEL_RAM_ITEMSPERBLOCK) return dest; - if ((dest_offs&(NSEEL_RAM_ITEMSPERBLOCK-1)) + len > NSEEL_RAM_ITEMSPERBLOCK) return dest; - if ((src_offs&(NSEEL_RAM_ITEMSPERBLOCK-1)) + len > NSEEL_RAM_ITEMSPERBLOCK) return dest; - - srcptr = __NSEEL_RAMAlloc(blocks,src_offs); - if (!srcptr || srcptr==&nseel_ramalloc_onfail) return dest; - destptr = __NSEEL_RAMAlloc(blocks,dest_offs); - if (!destptr || destptr==&nseel_ramalloc_onfail) return dest; - - - WDL_fft_complexmul((WDL_FFT_COMPLEX*)destptr,(WDL_FFT_COMPLEX*)srcptr,(len/2)&~1); - - return dest; -} - -void EEL_fft_register() -{ - WDL_fft_init(); -#if defined(EEL_SUPER_FAST_FFT_REORDERING) - if (!fft_reorder_table_for_bitsize(EEL_FFT_MINBITLEN_REORDER)[0]) - { - int x; - for (x=EEL_FFT_MINBITLEN_REORDER;x<=EEL_FFT_MAXBITLEN;x++) fft_make_reorder_table(x,fft_reorder_table_for_bitsize(x)); - } -#endif - NSEEL_addfunc_retptr("convolve_c",3,NSEEL_PProc_RAM,&eel_convolve_c); - NSEEL_addfunc_retptr("fft",2,NSEEL_PProc_RAM,&eel_fft); - NSEEL_addfunc_retptr("ifft",2,NSEEL_PProc_RAM,&eel_ifft); - NSEEL_addfunc_retptr("fft_real",2,NSEEL_PProc_RAM,&eel_fft_real); - NSEEL_addfunc_retptr("ifft_real",2,NSEEL_PProc_RAM,&eel_ifft_real); - NSEEL_addfunc_retptr("fft_permute",2,NSEEL_PProc_RAM,&eel_fft_permute); - NSEEL_addfunc_retptr("fft_ipermute",2,NSEEL_PProc_RAM,&eel_ifft_permute); -} - -#ifdef EEL_WANT_DOCUMENTATION -static const char *eel_fft_function_reference = -"convolve_c\tdest,src,size\tMultiplies each of size complex pairs in dest by the complex pairs in src. Often used for convolution.\0" -"fft\tbuffer,size\tPerforms a FFT on the data in the local memory buffer at the offset specified by the first parameter. The size of the FFT is specified " - "by the second parameter, which must be 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, or 32768. The outputs are permuted, so if " - "you plan to use them in-order, call fft_permute(buffer, size) before and fft_ipermute(buffer,size) after your in-order use. Your inputs or " - "outputs will need to be scaled down by 1/size, if used.\n" - "Note that fft()/ifft() require real / imaginary input pairs, so a 256 point FFT actually works with 512 items.\n" - "Note that fft()/ifft() must NOT cross a 65,536 item boundary, so be sure to specify the offset accordingly.\0" -"ifft\tbuffer,size\tPerform an inverse FFT. For more information see fft().\0" -"fft_real\tbuffer,size\tPerforms an FFT, but takes size input samples and produces size/2 complex output pairs. Usually used along with fft_permute(size/2). Inputs/outputs will need to be scaled by 0.5/size.\0" -"ifft_real\tbuffer,size\tPerforms an inverse FFT, but takes size/2 complex input pairs and produces size real output values. Usually used along with fft_ipermute(size/2).\0" -"fft_permute\tbuffer,size\tPermute the output of fft() to have bands in-order. See fft() for more information.\0" -"fft_ipermute\tbuffer,size\tPermute the input for ifft(), taking bands from in-order to the order ifft() requires. See fft() for more information.\0" -; -#endif - - -#endif diff --git a/oversampling/WDL/eel2/eel_files.h b/oversampling/WDL/eel2/eel_files.h deleted file mode 100644 index 7b5dac2..0000000 --- a/oversampling/WDL/eel2/eel_files.h +++ /dev/null @@ -1,262 +0,0 @@ -#ifndef __EEL_FILES_H__ -#define __EEL_FILES_H__ - -// should include eel_strings.h before this, probably -//#define EEL_FILE_OPEN(fn,mode) ((instance)opaque)->OpenFile(fn,mode) -//#define EEL_FILE_GETFP(fp) ((instance)opaque)->GetFileFP(fp) -//#define EEL_FILE_CLOSE(fpindex) ((instance)opaque)->CloseFile(fpindex) - -static EEL_F NSEEL_CGEN_CALL _eel_fopen(void *opaque, EEL_F *fn_index, EEL_F *mode_index) -{ - EEL_STRING_MUTEXLOCK_SCOPE - const char *fn = EEL_STRING_GET_FOR_INDEX(*fn_index,NULL); - const char *mode = EEL_STRING_GET_FOR_INDEX(*mode_index,NULL); - if (!fn || !mode) return 0; - return (EEL_F) EEL_FILE_OPEN(fn,mode); -} -static EEL_F NSEEL_CGEN_CALL _eel_fclose(void *opaque, EEL_F *fpp) -{ - EEL_F ret=EEL_FILE_CLOSE((int)*fpp); -#ifdef EEL_STRING_DEBUGOUT - if (ret < 0) EEL_STRING_DEBUGOUT("fclose(): file handle %f not valid",*fpp); -#endif - return ret; -} -static EEL_F NSEEL_CGEN_CALL _eel_fgetc(void *opaque, EEL_F *fpp) -{ - EEL_STRING_MUTEXLOCK_SCOPE - FILE *fp = EEL_FILE_GETFP((int)*fpp); - if (fp) return (EEL_F)fgetc(fp); -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("fgetc(): file handle %f not valid",*fpp); -#endif - return -1.0; -} - -static EEL_F NSEEL_CGEN_CALL _eel_ftell(void *opaque, EEL_F *fpp) -{ - EEL_STRING_MUTEXLOCK_SCOPE - FILE *fp = EEL_FILE_GETFP((int)*fpp); - if (fp) return (EEL_F)ftell(fp); -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("ftell(): file handle %f not valid",*fpp); -#endif - return -1.0; -} -static EEL_F NSEEL_CGEN_CALL _eel_fflush(void *opaque, EEL_F *fpp) -{ - EEL_STRING_MUTEXLOCK_SCOPE - FILE *fp = EEL_FILE_GETFP((int)*fpp); - if (fp) { fflush(fp); return 0.0; } -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("fflush(): file handle %f not valid",*fpp); -#endif - return -1.0; -} - -static EEL_F NSEEL_CGEN_CALL _eel_feof(void *opaque, EEL_F *fpp) -{ - EEL_STRING_MUTEXLOCK_SCOPE - FILE *fp = EEL_FILE_GETFP((int)*fpp); - if (fp) return feof(fp) ? 1.0 : 0.0; -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("feof(): file handle %f not valid",*fpp); -#endif - return -1.0; -} -static EEL_F NSEEL_CGEN_CALL _eel_fseek(void *opaque, EEL_F *fpp, EEL_F *offset, EEL_F *wh) -{ - EEL_STRING_MUTEXLOCK_SCOPE - FILE *fp = EEL_FILE_GETFP((int)*fpp); - if (fp) return fseek(fp, (int) *offset, *wh<0 ? SEEK_SET : *wh > 0 ? SEEK_END : SEEK_CUR); -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("fseek(): file handle %f not valid",*fpp); -#endif - return -1.0; -} -static EEL_F NSEEL_CGEN_CALL _eel_fgets(void *opaque, EEL_F *fpp, EEL_F *strOut) -{ - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr=NULL; - EEL_STRING_GET_FOR_WRITE(*strOut, &wr); - - FILE *fp = EEL_FILE_GETFP((int)*fpp); - if (!fp) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("fgets(): file handle %f not valid",*fpp); -#endif - if (wr) wr->Set(""); - return 0.0; - } - char buf[16384]; - buf[0]=0; - fgets(buf,sizeof(buf),fp); - if (wr) - { - wr->Set(buf); - return (EEL_F)wr->GetLength(); - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("fgets: bad destination specifier passed %f, throwing away %d bytes",*strOut, (int)strlen(buf)); -#endif - return (int)strlen(buf); - } -} -static EEL_F NSEEL_CGEN_CALL _eel_fread(void *opaque, EEL_F *fpp, EEL_F *strOut, EEL_F *flen) -{ - int use_len = (int) *flen; - if (use_len < 1) return 0.0; - - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr=NULL; - EEL_STRING_GET_FOR_WRITE(*strOut, &wr); - if (!wr) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("fread: bad destination specifier passed %f, not reading %d bytes",*strOut, use_len); -#endif - return -1; - } - - FILE *fp = EEL_FILE_GETFP((int)*fpp); - if (!fp) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("fread(): file handle %f not valid",*fpp); -#endif - if (wr) wr->Set(""); - return 0.0; - } - - wr->SetLen(use_len); - if (wr->GetLength() != use_len) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("fread: error allocating storage for read of %d bytes", use_len); -#endif - return -1.0; - } - use_len = (int)fread((char *)wr->Get(),1,use_len,fp); - wr->SetLen(use_len > 0 ? use_len : 0, true); - return (EEL_F) use_len; -} - -static EEL_F NSEEL_CGEN_CALL _eel_fwrite(void *opaque, EEL_F *fpp, EEL_F *strOut, EEL_F *flen) -{ - EEL_STRING_MUTEXLOCK_SCOPE - int use_len = (int) *flen; - - EEL_STRING_STORAGECLASS *wr=NULL; - const char *str=EEL_STRING_GET_FOR_INDEX(*strOut, &wr); - if (!wr && !str) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("fwrite: bad source specifier passed %f, not writing %d bytes",*strOut, use_len); -#endif - return -1.0; - } - if (!wr) - { - const int ssl = (int)strlen(str); - if (use_len < 1 || use_len > ssl) use_len = ssl; - } - else - { - if (use_len < 1 || use_len > wr->GetLength()) use_len = wr->GetLength(); - } - - if (use_len < 1) return 0.0; - - FILE *fp = EEL_FILE_GETFP((int)*fpp); - if (!fp) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("fwrite(): file handle %f not valid",*fpp); -#endif - return 0.0; - } - - return (EEL_F) fwrite(str,1,use_len,fp); -} - -static EEL_F NSEEL_CGEN_CALL _eel_fprintf(void *opaque, INT_PTR nparam, EEL_F **parm) -{ - if (opaque && nparam > 1) - { - EEL_STRING_MUTEXLOCK_SCOPE - FILE *fp = EEL_FILE_GETFP((int)*(parm[0])); - if (!fp) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("fprintf(): file handle %f not valid",parm[0][0]); -#endif - return 0.0; - } - - EEL_STRING_STORAGECLASS *wr_src=NULL; - const char *fmt = EEL_STRING_GET_FOR_INDEX(*(parm[1]),&wr_src); - if (fmt) - { - char buf[16384]; - const int len = eel_format_strings(opaque,fmt,wr_src?(fmt+wr_src->GetLength()) : NULL, buf,(int)sizeof(buf),(int)nparam-2,parm+2); - - if (len >= 0) - { - return (EEL_F) fwrite(buf,1,len,fp); - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("fprintf: bad format string %s",fmt); -#endif - } - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("fprintf: bad format specifier passed %f",*(parm[1])); -#endif - } - } - return 0.0; -} - -void EEL_file_register() -{ - NSEEL_addfunc_retval("fopen",2,NSEEL_PProc_THIS,&_eel_fopen); - - NSEEL_addfunc_retval("fread",3,NSEEL_PProc_THIS,&_eel_fread); - NSEEL_addfunc_retval("fgets",2,NSEEL_PProc_THIS,&_eel_fgets); - NSEEL_addfunc_retval("fgetc",1,NSEEL_PProc_THIS,&_eel_fgetc); - - NSEEL_addfunc_retval("fwrite",3,NSEEL_PProc_THIS,&_eel_fwrite); - NSEEL_addfunc_varparm("fprintf",2,NSEEL_PProc_THIS,&_eel_fprintf); - - NSEEL_addfunc_retval("fseek",3,NSEEL_PProc_THIS,&_eel_fseek); - NSEEL_addfunc_retval("ftell",1,NSEEL_PProc_THIS,&_eel_ftell); - NSEEL_addfunc_retval("feof",1,NSEEL_PProc_THIS,&_eel_feof); - NSEEL_addfunc_retval("fflush",1,NSEEL_PProc_THIS,&_eel_fflush); - NSEEL_addfunc_retval("fclose",1,NSEEL_PProc_THIS,&_eel_fclose); -} - -#ifdef EEL_WANT_DOCUMENTATION -static const char *eel_file_function_reference = -"fopen\t\"fn\",\"mode\"\tOpens a file \"fn\" with mode \"mode\". For read, use \"r\" or \"rb\", write \"w\" or \"wb\". Returns a positive integer on success.\0" -"fclose\tfp\tCloses a file previously opened with fopen().\0" -"fread\tfp,#str,length\tReads from file fp into #str, up to length bytes. Returns actual length read, or negative if error.\0" -"fgets\tfp,#str\tReads a line from file fp into #str. Returns length of #str read.\0" -"fgetc\tfp\tReads a character from file fp, returns -1 if EOF.\0" -"fwrite\tfp,#str,len\tWrites up to len characters of #str to file fp. If len is less than 1, the full contents of #str will be written. Returns the number of bytes written to file.\0" -"fprintf\tfp,\"format\"[,...]\tFormats a string and writes it to file fp. For more information on format specifiers, see sprintf(). Returns bytes written to file.\0" -"fseek\tfp,offset,whence\tSeeks file fp, offset bytes from whence reference. Whence negative specifies start of file, positive whence specifies end of file, and zero whence specifies current file position.\0" -"ftell\tfp\tRetunrs the current file position.\0" -"feof\tfp\tReturns nonzero if the file fp is at the end of file.\0" -"fflush\tfp\tIf file fp is open for writing, flushes out any buffered data to disk.\0" -; -#endif - - -#endif diff --git a/oversampling/WDL/eel2/eel_import.h b/oversampling/WDL/eel2/eel_import.h deleted file mode 100644 index 46e2176..0000000 --- a/oversampling/WDL/eel2/eel_import.h +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************************* - * imported EEL - ******************************************************************************************/ - -void (*NSEEL_addfunc_ret_type)(const char *name, int np, int ret_type, NSEEL_PPPROC pproc, void *fptr, eel_function_table *destination); // ret_type=-1 for bool, 1 for value, 0 for ptr -void (*NSEEL_addfunc_varparm_ex)(const char *name, int min_np, int want_exact, NSEEL_PPPROC pproc, EEL_F (NSEEL_CGEN_CALL *fptr)(void *, INT_PTR, EEL_F **), eel_function_table *destination); - - -NSEEL_VMCTX (*NSEEL_VM_alloc)(); // return a handle -void (*NSEEL_VM_SetGRAM)(NSEEL_VMCTX, void **); -void (*NSEEL_VM_free)(NSEEL_VMCTX ctx); // free when done with a VM and ALL of its code have been freed, as well -void (*NSEEL_VM_SetFunctionTable)(NSEEL_VMCTX, eel_function_table *tab); // use NULL to use default (global) table -EEL_F *(*NSEEL_VM_regvar)(NSEEL_VMCTX ctx, const char *name); // register a variable (before compilation) - -void (*NSEEL_VM_SetCustomFuncThis)(NSEEL_VMCTX ctx, void *thisptr); -NSEEL_CODEHANDLE (*NSEEL_code_compile_ex)(NSEEL_VMCTX ctx, const char *code, int lineoffs, int flags); -void (*NSEEL_VM_set_var_resolver)(NSEEL_VMCTX ctx, EEL_F *(*res)(void *userctx, const char *name), void *userctx); -char *(*NSEEL_code_getcodeerror)(NSEEL_VMCTX ctx); -void (*NSEEL_code_execute)(NSEEL_CODEHANDLE code); -void (*NSEEL_code_free)(NSEEL_CODEHANDLE code); -EEL_F *(*nseel_int_register_var)(compileContext *ctx, const char *name, int isReg, const char **namePtrOut); -void (*NSEEL_VM_enumallvars)(NSEEL_VMCTX ctx, int (*func)(const char *name, EEL_F *val, void *ctx), void *userctx); -EEL_F *(*NSEEL_VM_getramptr)(NSEEL_VMCTX ctx, unsigned int offs, int *validAmt); -void ** (*eel_gmem_attach)(const char *nm, bool is_alloc); -void (*eel_fft_register)(eel_function_table*); - -struct eelStringSegmentRec { - struct eelStringSegmentRec *_next; - const char *str_start; // escaped characters, including opening/trailing characters - int str_len; -}; -void (*NSEEL_VM_SetStringFunc)(NSEEL_VMCTX ctx, - EEL_F (*onString)(void *caller_this, struct eelStringSegmentRec *list), - EEL_F (*onNamedString)(void *caller_this, const char *name)); - -// call with NULL to calculate size, or non-null to generate to buffer (returning size used -- will not null terminate, caller responsibility) -int (*nseel_stringsegments_tobuf)(char *bufOut, int bufout_sz, struct eelStringSegmentRec *list); - -void *(*NSEEL_PProc_RAM)(void *data, int data_size, struct _compileContext *ctx); -void *(*NSEEL_PProc_THIS)(void *data, int data_size, struct _compileContext *ctx); - -void (*eel_enterfp)(int s[2]); -void (*eel_leavefp)(int s[2]); - - -eel_function_table g_eel_function_table; -#define NSEEL_ADDFUNC_DESTINATION (&g_eel_function_table) - -// -// adds a function that returns a value (EEL_F) -#define NSEEL_addfunc_retval(name,np,pproc,fptr) \ - NSEEL_addfunc_ret_type(name,np,1,pproc,(void *)(fptr),NSEEL_ADDFUNC_DESTINATION) - -// adds a function that returns a pointer (EEL_F*) -#define NSEEL_addfunc_retptr(name,np,pproc,fptr) \ - NSEEL_addfunc_ret_type(name,np,0,pproc,(void *)(fptr),NSEEL_ADDFUNC_DESTINATION) - -// adds a void or bool function -#define NSEEL_addfunc_retbool(name,np,pproc,fptr) \ - NSEEL_addfunc_ret_type(name,np,-1,pproc,(void *)(fptr),NSEEL_ADDFUNC_DESTINATION) - -// adds a function that takes min_np or more parameters (func sig needs to be EEL_F func(void *ctx, INT_PTR np, EEL_F **parms) -#define NSEEL_addfunc_varparm(name, min_np, pproc, fptr) \ - NSEEL_addfunc_varparm_ex(name,min_np,0,pproc,fptr,NSEEL_ADDFUNC_DESTINATION) - -// adds a function that takes np parameters via func: sig needs to be EEL_F func(void *ctx, INT_PTR np, EEL_F **parms) -#define NSEEL_addfunc_exparms(name, np, pproc, fptr) \ - NSEEL_addfunc_varparm_ex(name,np,1,pproc,fptr,NSEEL_ADDFUNC_DESTINATION) - -class eel_string_context_state; - -#define __NS_EELINT_H__ - -#define EEL_IMPORT_ALL(IMPORT_FUNC) \ - IMPORT_FUNC(NSEEL_addfunc_ret_type) \ - IMPORT_FUNC(NSEEL_addfunc_varparm_ex) \ - IMPORT_FUNC(NSEEL_VM_free) \ - IMPORT_FUNC(NSEEL_VM_SetFunctionTable) \ - IMPORT_FUNC(NSEEL_VM_regvar) \ - IMPORT_FUNC(NSEEL_VM_SetCustomFuncThis) \ - IMPORT_FUNC(NSEEL_code_compile_ex) \ - IMPORT_FUNC(NSEEL_code_getcodeerror) \ - IMPORT_FUNC(NSEEL_code_execute) \ - IMPORT_FUNC(NSEEL_code_free) \ - IMPORT_FUNC(NSEEL_PProc_THIS) \ - IMPORT_FUNC(NSEEL_PProc_RAM) \ - IMPORT_FUNC(NSEEL_VM_SetStringFunc) \ - IMPORT_FUNC(NSEEL_VM_enumallvars) \ - IMPORT_FUNC(NSEEL_VM_getramptr) \ - IMPORT_FUNC(NSEEL_VM_SetGRAM) \ - IMPORT_FUNC(eel_gmem_attach) \ - IMPORT_FUNC(eel_fft_register) \ - IMPORT_FUNC(nseel_stringsegments_tobuf) \ - IMPORT_FUNC(nseel_int_register_var) \ - IMPORT_FUNC(eel_leavefp) \ - IMPORT_FUNC(eel_enterfp) \ - IMPORT_FUNC(NSEEL_VM_set_var_resolver) \ - IMPORT_FUNC(NSEEL_VM_alloc) /* keep NSEEL_VM_alloc last */ - - - -/******************************************************************************************* - * END of imported EEL - ******************************************************************************************/ diff --git a/oversampling/WDL/eel2/eel_lice.h b/oversampling/WDL/eel2/eel_lice.h deleted file mode 100644 index 02500a0..0000000 --- a/oversampling/WDL/eel2/eel_lice.h +++ /dev/null @@ -1,3223 +0,0 @@ -#ifndef _EEL_LICE_H_ -#define _EEL_LICE_H_ - -// #define EEL_LICE_GET_FILENAME_FOR_STRING(idx, fs, p) (((sInst*)opaque)->GetFilenameForParameter(idx,fs,p)) -// #define EEL_LICE_GET_CONTEXT(opaque) (((opaque) ? (((sInst *)opaque)->m_gfx_state) : NULL) - - -void eel_lice_register(); - -#ifdef DYNAMIC_LICE - #define LICE_IBitmap LICE_IBitmap_disabledAPI - #include "../lice/lice.h" - - #undef LICE_IBitmap - typedef void LICE_IBitmap; // prevent us from using LICE api directly, in case it ever changes - -class LICE_IFont; - -#ifdef EEL_LICE_API_ONLY -#define EEL_LICE_FUNCDEF extern -#else -#define EEL_LICE_FUNCDEF -#endif - -#define LICE_FUNCTION_VALID(x) (x) - -EEL_LICE_FUNCDEF LICE_IBitmap *(*__LICE_CreateBitmap)(int, int, int); -EEL_LICE_FUNCDEF void (*__LICE_Clear)(LICE_IBitmap *dest, LICE_pixel color); -EEL_LICE_FUNCDEF void (*__LICE_Line)(LICE_IBitmap *dest, int x1, int y1, int x2, int y2, LICE_pixel color, float alpha, int mode, bool aa); -EEL_LICE_FUNCDEF bool (*__LICE_ClipLine)(int* pX1, int* pY1, int* pX2, int* pY2, int xLo, int yLo, int xHi, int yHi); -EEL_LICE_FUNCDEF void (*__LICE_DrawText)(LICE_IBitmap *bm, int x, int y, const char *string, - LICE_pixel color, float alpha, int mode); -EEL_LICE_FUNCDEF void (*__LICE_DrawChar)(LICE_IBitmap *bm, int x, int y, char c, - LICE_pixel color, float alpha, int mode); -EEL_LICE_FUNCDEF void (*__LICE_MeasureText)(const char *string, int *w, int *h); -EEL_LICE_FUNCDEF void (*__LICE_PutPixel)(LICE_IBitmap *bm, int x, int y, LICE_pixel color, float alpha, int mode); -EEL_LICE_FUNCDEF LICE_pixel (*__LICE_GetPixel)(LICE_IBitmap *bm, int x, int y); -EEL_LICE_FUNCDEF void (*__LICE_FillRect)(LICE_IBitmap *dest, int x, int y, int w, int h, LICE_pixel color, float alpha, int mode); -EEL_LICE_FUNCDEF void (*__LICE_DrawRect)(LICE_IBitmap *dest, int x, int y, int w, int h, LICE_pixel color, float alpha, int mode); -EEL_LICE_FUNCDEF LICE_IBitmap *(*__LICE_LoadImage)(const char* filename, LICE_IBitmap* bmp, bool tryIgnoreExtension); -EEL_LICE_FUNCDEF void (*__LICE_Blur)(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, int srcx, int srcy, int srcw, int srch); // src and dest can overlap, however it may look fudgy if they do -EEL_LICE_FUNCDEF void (*__LICE_ScaledBlit)(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, int dstw, int dsth, - float srcx, float srcy, float srcw, float srch, float alpha, int mode); -EEL_LICE_FUNCDEF void (*__LICE_Circle)(LICE_IBitmap* dest, float cx, float cy, float r, LICE_pixel color, float alpha, int mode, bool aa); -EEL_LICE_FUNCDEF void (*__LICE_FillCircle)(LICE_IBitmap* dest, float cx, float cy, float r, LICE_pixel color, float alpha, int mode, bool aa); -EEL_LICE_FUNCDEF void (*__LICE_FillTriangle)(LICE_IBitmap* dest, int x1, int y1, int x2, int y2, int x3, int y3, LICE_pixel color, float alpha, int mode); -EEL_LICE_FUNCDEF void (*__LICE_FillConvexPolygon)(LICE_IBitmap* dest, const int* x, const int* y, int npoints, LICE_pixel color, float alpha, int mode); -EEL_LICE_FUNCDEF void (*__LICE_RoundRect)(LICE_IBitmap *drawbm, float xpos, float ypos, float w, float h, int cornerradius, LICE_pixel col, float alpha, int mode, bool aa); -EEL_LICE_FUNCDEF void (*__LICE_Arc)(LICE_IBitmap* dest, float cx, float cy, float r, float minAngle, float maxAngle, LICE_pixel color, float alpha, int mode, bool aa); - -// if cliptosourcerect is false, then areas outside the source rect can get in (otherwise they are not drawn) -EEL_LICE_FUNCDEF void (*__LICE_RotatedBlit)(LICE_IBitmap *dest, LICE_IBitmap *src, - int dstx, int dsty, int dstw, int dsth, - float srcx, float srcy, float srcw, float srch, - float angle, - bool cliptosourcerect, float alpha, int mode, - float rotxcent, float rotycent); // these coordinates are offset from the center of the image, in source pixel coordinates - - -EEL_LICE_FUNCDEF void (*__LICE_MultiplyAddRect)(LICE_IBitmap *dest, int x, int y, int w, int h, - float rsc, float gsc, float bsc, float asc, // 0-1, or -100 .. +100 if you really are insane - float radd, float gadd, float badd, float aadd); // 0-255 is the normal range on these.. of course its clamped - -EEL_LICE_FUNCDEF void (*__LICE_GradRect)(LICE_IBitmap *dest, int dstx, int dsty, int dstw, int dsth, - float ir, float ig, float ib, float ia, - float drdx, float dgdx, float dbdx, float dadx, - float drdy, float dgdy, float dbdy, float dady, - int mode); - -EEL_LICE_FUNCDEF void (*__LICE_TransformBlit2)(LICE_IBitmap *dest, LICE_IBitmap *src, - int dstx, int dsty, int dstw, int dsth, - double *srcpoints, int div_w, int div_h, // srcpoints coords should be div_w*div_h*2 long, and be in source image coordinates - float alpha, int mode); - -EEL_LICE_FUNCDEF void (*__LICE_DeltaBlit)(LICE_IBitmap *dest, LICE_IBitmap *src, - int dstx, int dsty, int dstw, int dsth, - float srcx, float srcy, float srcw, float srch, - double dsdx, double dtdx, double dsdy, double dtdy, - double dsdxdy, double dtdxdy, - bool cliptosourcerect, float alpha, int mode); - - -#define LICE_Blur __LICE_Blur -#define LICE_Clear __LICE_Clear -#define LICE_Line __LICE_Line -#define LICE_ClipLine __LICE_ClipLine -#define LICE_FillRect __LICE_FillRect -#define LICE_DrawRect __LICE_DrawRect -#define LICE_PutPixel __LICE_PutPixel -#define LICE_GetPixel __LICE_GetPixel -#define LICE_DrawText __LICE_DrawText -#define LICE_DrawChar __LICE_DrawChar -#define LICE_MeasureText __LICE_MeasureText -#define LICE_LoadImage __LICE_LoadImage -#define LICE_RotatedBlit __LICE_RotatedBlit -#define LICE_ScaledBlit __LICE_ScaledBlit -#define LICE_MultiplyAddRect __LICE_MultiplyAddRect -#define LICE_GradRect __LICE_GradRect -#define LICE_TransformBlit2 __LICE_TransformBlit2 -#define LICE_DeltaBlit __LICE_DeltaBlit -#define LICE_Circle __LICE_Circle -#define LICE_FillCircle __LICE_FillCircle -#define LICE_FillTriangle __LICE_FillTriangle -#define LICE_FillConvexPolygon __LICE_FillConvexPolygon -#define LICE_RoundRect __LICE_RoundRect -#define LICE_Arc __LICE_Arc - -EEL_LICE_FUNCDEF HDC (*LICE__GetDC)(LICE_IBitmap *bm); -EEL_LICE_FUNCDEF int (*LICE__GetWidth)(LICE_IBitmap *bm); -EEL_LICE_FUNCDEF int (*LICE__GetHeight)(LICE_IBitmap *bm); -EEL_LICE_FUNCDEF void (*LICE__Destroy)(LICE_IBitmap *bm); -EEL_LICE_FUNCDEF bool (*LICE__resize)(LICE_IBitmap *bm, int w, int h); - -EEL_LICE_FUNCDEF void (*LICE__DestroyFont)(LICE_IFont* font); -EEL_LICE_FUNCDEF LICE_IFont *(*LICE_CreateFont)(); -EEL_LICE_FUNCDEF void (*LICE__SetFromHFont)(LICE_IFont* ifont, HFONT font, int flags); -EEL_LICE_FUNCDEF LICE_pixel (*LICE__SetTextColor)(LICE_IFont* ifont, LICE_pixel color); -EEL_LICE_FUNCDEF void (*LICE__SetTextCombineMode)(LICE_IFont* ifont, int mode, float alpha); -EEL_LICE_FUNCDEF int (*LICE__DrawText)(LICE_IFont* ifont, LICE_IBitmap *bm, const char *str, int strcnt, RECT *rect, UINT dtFlags); - -#else - -#include "../lice/lice.h" -#include "../lice/lice_text.h" - -#define LICE_FUNCTION_VALID(x) (sizeof(int) > 0) - -static HDC LICE__GetDC(LICE_IBitmap *bm) -{ - return bm->getDC(); -} -static int LICE__GetWidth(LICE_IBitmap *bm) -{ - return bm->getWidth(); -} -static int LICE__GetHeight(LICE_IBitmap *bm) -{ - return bm->getHeight(); -} -static void LICE__Destroy(LICE_IBitmap *bm) -{ - delete bm; -} -static void LICE__SetFromHFont(LICE_IFont * ifont, HFONT font, int flags) -{ - if (ifont) ifont->SetFromHFont(font,flags); -} -static LICE_pixel LICE__SetTextColor(LICE_IFont* ifont, LICE_pixel color) -{ - if (ifont) return ifont->SetTextColor(color); - return 0; -} -static void LICE__SetTextCombineMode(LICE_IFont* ifont, int mode, float alpha) -{ - if (ifont) ifont->SetCombineMode(mode, alpha); -} -static int LICE__DrawText(LICE_IFont* ifont, LICE_IBitmap *bm, const char *str, int strcnt, RECT *rect, UINT dtFlags) -{ - if (ifont) return ifont->DrawText(bm, str, strcnt, rect, dtFlags); - return 0; -} - - -static LICE_IFont *LICE_CreateFont() -{ - return new LICE_CachedFont(); -} -static void LICE__DestroyFont(LICE_IFont *bm) -{ - delete bm; -} -static bool LICE__resize(LICE_IBitmap *bm, int w, int h) -{ - return bm->resize(w,h); -} - -static LICE_IBitmap *__LICE_CreateBitmap(int mode, int w, int h) -{ - if (mode==1) return new LICE_SysBitmap(w,h); - return new LICE_MemBitmap(w,h); -} - - -#endif - -#include "../wdlutf8.h" - - -class eel_lice_state -{ -public: - - eel_lice_state(NSEEL_VMCTX vm, void *ctx, int image_slots, int font_slots); - ~eel_lice_state(); - - void resetVarsToStock() - { - if (m_gfx_a&&m_gfx_r&&m_gfx_g&&m_gfx_b) *m_gfx_r=*m_gfx_g=*m_gfx_b=*m_gfx_a=1.0; - if (m_gfx_a2) *m_gfx_a2=1.0; - if (m_gfx_dest) *m_gfx_dest=-1.0; - if (m_mouse_wheel) *m_mouse_wheel=0.0; - if (m_mouse_hwheel) *m_mouse_hwheel=0.0; - // todo: reset others? - } - - LICE_IBitmap *m_framebuffer, *m_framebuffer_extra; - int m_framebuffer_dirty; - - struct img_shared_state - { - LICE_IBitmap *bm; - int refcnt; - - img_shared_state(LICE_IBitmap *b) : bm(b), refcnt(1) { } - - void release() - { - if (wdl_atomic_decr(&refcnt)==0) delete this; - } - - private: - - ~img_shared_state() - { - s_img_cache_mutex.Enter(); - for (int x = 0; x < s_img_cache.GetSize(); x ++) - { - if (s_img_cache.Enumerate(x) == this) - { - s_img_cache.DeleteByIndex(x); - break; - } - } - s_img_cache_mutex.Leave(); - if (LICE_FUNCTION_VALID(LICE__Destroy)) - LICE__Destroy(bm); - } - }; - - static WDL_StringKeyedArray s_img_cache; - static WDL_Mutex s_img_cache_mutex; - - struct img_state - { - LICE_IBitmap *bm; - img_shared_state *shared; - - void clear(LICE_IBitmap *bmnew=NULL, img_shared_state *sharednew=NULL) - { - if (shared) shared->release(); - if (bm && LICE_FUNCTION_VALID(LICE__Destroy)) - LICE__Destroy(bm); - bm = bmnew; - shared = sharednew; - } - void on_write() - { - if (shared && WDL_NORMALLY(shared->bm)) - { - const int bmw = LICE__GetWidth(shared->bm), bmh = LICE__GetHeight(shared->bm); - bm = __LICE_CreateBitmap(1,bmw,bmh); - LICE_ScaledBlit(bm,shared->bm, // copy the entire image - 0,0,bmw,bmh, - 0.0f,0.0f,(float)bmw,(float)bmh, - 1.0f,LICE_BLIT_MODE_COPY); - shared->release(); - shared = NULL; - } - } - }; - - bool do_load_image(int img, const char *str); - - WDL_TypedBuf m_gfx_images; - struct gfxFontStruct { - LICE_IFont *font; - char last_fontname[128]; - char actual_fontname[128]; - int last_fontsize; - int last_fontflag; - - int use_fonth; - }; - WDL_TypedBuf m_gfx_fonts; - enum { - EELFONT_FLAG_BOLD = (1<<24), - EELFONT_FLAG_ITALIC = (2<<24), - EELFONT_FLAG_UNDERLINE = (4<<24), - EELFONT_FLAG_MASK = EELFONT_FLAG_BOLD|EELFONT_FLAG_ITALIC|EELFONT_FLAG_UNDERLINE - }; - - int m_gfx_font_active; // -1 for default, otherwise index into gfx_fonts (NOTE: this differs from the exposed API, which defines 0 as default, 1-n) - LICE_IFont *GetActiveFont() { return m_gfx_font_active>=0&&m_gfx_font_active-2.0) - { - if (idx < 0.0) return m_framebuffer; - - const int a = (int)idx; - if (a >= 0 && a < m_gfx_images.GetSize()) - { - img_state *rec = m_gfx_images.Get() + a; - if (is_wr) rec->on_write(); - return rec->shared ? rec->shared->bm : rec->bm; - } - } - return NULL; - }; - - void SetImageDirty(LICE_IBitmap *bm) - { - if (bm == m_framebuffer && !m_framebuffer_dirty) - { - if (m_gfx_clear && *m_gfx_clear > -1.0) - { - const int a=(int)*m_gfx_clear; - if (LICE_FUNCTION_VALID(LICE_Clear)) LICE_Clear(m_framebuffer,LICE_RGBA((a&0xff),((a>>8)&0xff),((a>>16)&0xff),0)); - } - m_framebuffer_dirty=1; - } - } - - // R, G, B, A, w, h, x, y, mode(1=add,0=copy) - EEL_F *m_gfx_r, *m_gfx_g, *m_gfx_b, *m_gfx_w, *m_gfx_h, *m_gfx_a, *m_gfx_x, *m_gfx_y, *m_gfx_mode, *m_gfx_clear, *m_gfx_texth,*m_gfx_dest, *m_gfx_a2; - EEL_F *m_mouse_x, *m_mouse_y, *m_mouse_cap, *m_mouse_wheel, *m_mouse_hwheel; - EEL_F *m_gfx_ext_retina; - - NSEEL_VMCTX m_vmref; - void *m_user_ctx; - - int setup_frame(HWND hwnd, RECT r, int _mouse_x=0, int _mouse_y=0, int has_dpi=0); // mouse_x/y used only if hwnd is NULL - void finish_draw(); - - void gfx_lineto(EEL_F xpos, EEL_F ypos, EEL_F aaflag); - void gfx_rectto(EEL_F xpos, EEL_F ypos); - void gfx_line(int np, EEL_F **parms); - void gfx_rect(int np, EEL_F **parms); - void gfx_roundrect(int np, EEL_F **parms); - void gfx_arc(int np, EEL_F **parms); - void gfx_set(int np, EEL_F **parms); - void gfx_grad_or_muladd_rect(int mode, int np, EEL_F **parms); - void gfx_setpixel(EEL_F r, EEL_F g, EEL_F b); - void gfx_getpixel(EEL_F *r, EEL_F *g, EEL_F *b); - void gfx_drawnumber(EEL_F n, EEL_F ndigits); - void gfx_drawchar(EEL_F ch); - void gfx_getimgdim(EEL_F img, EEL_F *w, EEL_F *h); - EEL_F gfx_setimgdim(int img, EEL_F *w, EEL_F *h); - void gfx_blurto(EEL_F x, EEL_F y); - void gfx_blitext(EEL_F img, EEL_F *coords, EEL_F angle); - void gfx_blitext2(int np, EEL_F **parms, int mode); // 0=blit, 1=deltablit - void gfx_transformblit(EEL_F **parms, int div_w, int div_h, EEL_F *tab); // parms[0]=src, 1-4=x,y,w,h - void gfx_circle(float x, float y, float r, bool fill, bool aaflag); - void gfx_triangle(EEL_F** parms, int nparms); - void gfx_drawstr(void *opaque, EEL_F **parms, int nparms, int formatmode); // formatmode=1 for format, 2 for purely measure no format, 3 for measure char - EEL_F gfx_loadimg(void *opaque, int img, EEL_F loadFrom); - EEL_F gfx_setfont(void *opaque, int np, EEL_F **parms); - EEL_F gfx_getfont(void *opaque, int np, EEL_F **parms); - EEL_F gfx_getdropfile(void *opaque, int np, EEL_F **parms); - - LICE_pixel getCurColor(); - int getCurMode(); - int getCurModeForBlit(bool isFBsrc); - -#ifdef EEL_LICE_WANT_STANDALONE - HWND create_wnd(HWND par, int isChild); - HWND hwnd_standalone; - int hwnd_standalone_kb_state[32]; // pressed keys, if any - - // these have to be **parms because of the hack for getting string from parm index - EEL_F gfx_showmenu(void* opaque, EEL_F** parms, int nparms); - EEL_F gfx_setcursor(void* opaque, EEL_F** parms, int nparms); - - int m_kb_queue[64]; - unsigned char m_kb_queue_valid; - unsigned char m_kb_queue_pos; - HCURSOR m_cursor; - int m_cursor_resid; -#ifdef EEL_LICE_LOADTHEMECURSOR - char m_cursor_name[128]; -#endif - -#ifndef EEL_LICE_STANDALONE_NOINITQUIT - RECT m_last_undocked_r; -#endif - -#endif - - DWORD m_last_menu_time; - int m_last_menu_cnt; - - int m_has_cap; // high 16 bits are current capture state, low 16 bits are temporary flags from mousedown - bool m_has_had_getch; // set on first gfx_getchar(), makes mouse_cap updated with modifiers even when no mouse click is down - - WDL_PtrList m_ddrop_files; -}; - - -#ifndef EEL_LICE_API_ONLY - -WDL_StringKeyedArray eel_lice_state::s_img_cache(true); -WDL_Mutex eel_lice_state::s_img_cache_mutex; - -eel_lice_state::eel_lice_state(NSEEL_VMCTX vm, void *ctx, int image_slots, int font_slots) -{ -#ifdef EEL_LICE_WANT_STANDALONE - hwnd_standalone=NULL; - memset(hwnd_standalone_kb_state,0,sizeof(hwnd_standalone_kb_state)); - m_kb_queue_valid=0; - m_cursor_resid=0; - m_cursor = NULL; -#ifndef EEL_LICE_STANDALONE_NOINITQUIT - memset(&m_last_undocked_r,0,sizeof(m_last_undocked_r)); -#endif - -#ifdef EEL_LICE_LOADTHEMECURSOR - m_cursor_name[0]=0; -#endif -#endif - m_user_ctx=ctx; - m_vmref= vm; - m_gfx_font_active=-1; - m_gfx_fonts.Resize(font_slots); - memset(m_gfx_fonts.Get(),0,m_gfx_fonts.GetSize()*sizeof(m_gfx_fonts.Get()[0])); - - m_gfx_images.Resize(image_slots); - memset(m_gfx_images.Get(),0,m_gfx_images.GetSize()*sizeof(m_gfx_images.Get()[0])); - m_framebuffer=m_framebuffer_extra=0; - m_framebuffer_dirty=0; - - m_gfx_r = NSEEL_VM_regvar(vm,"gfx_r"); - m_gfx_g = NSEEL_VM_regvar(vm,"gfx_g"); - m_gfx_b = NSEEL_VM_regvar(vm,"gfx_b"); - m_gfx_a = NSEEL_VM_regvar(vm,"gfx_a"); - m_gfx_a2 = NSEEL_VM_regvar(vm,"gfx_a2"); - - m_gfx_w = NSEEL_VM_regvar(vm,"gfx_w"); - m_gfx_h = NSEEL_VM_regvar(vm,"gfx_h"); - m_gfx_x = NSEEL_VM_regvar(vm,"gfx_x"); - m_gfx_y = NSEEL_VM_regvar(vm,"gfx_y"); - m_gfx_mode = NSEEL_VM_regvar(vm,"gfx_mode"); - m_gfx_clear = NSEEL_VM_regvar(vm,"gfx_clear"); - m_gfx_texth = NSEEL_VM_regvar(vm,"gfx_texth"); - m_gfx_dest = NSEEL_VM_regvar(vm,"gfx_dest"); - m_gfx_ext_retina = NSEEL_VM_regvar(vm,"gfx_ext_retina"); - - m_mouse_x = NSEEL_VM_regvar(vm,"mouse_x"); - m_mouse_y = NSEEL_VM_regvar(vm,"mouse_y"); - m_mouse_cap = NSEEL_VM_regvar(vm,"mouse_cap"); - m_mouse_wheel=NSEEL_VM_regvar(vm,"mouse_wheel"); - m_mouse_hwheel=NSEEL_VM_regvar(vm,"mouse_hwheel"); - - if (m_gfx_texth) *m_gfx_texth=8; - - m_has_cap=0; - m_has_had_getch=false; - m_last_menu_time = GetTickCount() - 100000; - m_last_menu_cnt = 0; -} -eel_lice_state::~eel_lice_state() -{ -#ifdef EEL_LICE_WANT_STANDALONE - if (hwnd_standalone) DestroyWindow(hwnd_standalone); -#endif - if (LICE_FUNCTION_VALID(LICE__Destroy)) - { - LICE__Destroy(m_framebuffer_extra); - LICE__Destroy(m_framebuffer); - } - for (int x=0;x>4)&0xf; - if (sm > LICE_BLIT_MODE_COPY && sm <= LICE_BLIT_MODE_HSVADJ) return sm; - - return (gmode&1) ? LICE_BLIT_MODE_ADD : LICE_BLIT_MODE_COPY; -} -int eel_lice_state::getCurModeForBlit(bool isFBsrc) -{ - const int gmode = (int) (*m_gfx_mode); - - const int sm=(gmode>>4)&0xf; - - int mode; - if (sm > LICE_BLIT_MODE_COPY && sm <= LICE_BLIT_MODE_HSVADJ) mode=sm; - else mode=((gmode&1) ? LICE_BLIT_MODE_ADD : LICE_BLIT_MODE_COPY); - - - if (!isFBsrc && !(gmode&2)) mode|=LICE_BLIT_USE_ALPHA; - if (!(gmode&4)) mode|=LICE_BLIT_FILTER_BILINEAR; - - return mode; -} -LICE_pixel eel_lice_state::getCurColor() -{ - int red=(int) (*m_gfx_r*255.0); - int green=(int) (*m_gfx_g*255.0); - int blue=(int) (*m_gfx_b*255.0); - int a2=(int) (*m_gfx_a2*255.0); - if (red<0) red=0;else if (red>255)red=255; - if (green<0) green=0;else if (green>255)green=255; - if (blue<0) blue=0; else if (blue>255) blue=255; - if (a2<0) a2=0; else if (a2>255) a2=255; - return LICE_RGBA(red,green,blue,a2); -} - - -static EEL_F * NSEEL_CGEN_CALL _gfx_lineto(void *opaque, EEL_F *xpos, EEL_F *ypos, EEL_F *useaa) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_lineto(*xpos, *ypos, *useaa); - return xpos; -} -static EEL_F * NSEEL_CGEN_CALL _gfx_lineto2(void *opaque, EEL_F *xpos, EEL_F *ypos) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_lineto(*xpos, *ypos, 1.0f); - return xpos; -} - -static EEL_F * NSEEL_CGEN_CALL _gfx_rectto(void *opaque, EEL_F *xpos, EEL_F *ypos) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_rectto(*xpos, *ypos); - return xpos; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_line(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_line((int)np,parms); - return 0.0; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_rect(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_rect((int)np,parms); - return 0.0; -} -static EEL_F NSEEL_CGEN_CALL _gfx_roundrect(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_roundrect((int)np,parms); - return 0.0; -} -static EEL_F NSEEL_CGEN_CALL _gfx_arc(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_arc((int)np,parms); - return 0.0; -} -static EEL_F NSEEL_CGEN_CALL _gfx_set(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_set((int)np,parms); - return 0.0; -} -static EEL_F NSEEL_CGEN_CALL _gfx_gradrect(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_grad_or_muladd_rect(0,(int)np,parms); - return 0.0; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_muladdrect(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_grad_or_muladd_rect(1,(int)np,parms); - return 0.0; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_deltablit(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_blitext2((int)np,parms,1); - return 0.0; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_transformblit(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) - { -#ifndef EEL_LICE_NO_RAM - const int divw = (int) (parms[5][0]+0.5); - const int divh = (int) (parms[6][0]+0.5); - if (divw < 1 || divh < 1) return 0.0; - const int sz = divw*divh*2; - -#ifdef EEL_LICE_RAMFUNC - EEL_F *d = EEL_LICE_RAMFUNC(opaque,7,sz); - if (!d) return 0.0; -#else - EEL_F **blocks = ctx->m_vmref ? ((compileContext*)ctx->m_vmref)->ram_state->blocks : 0; - if (!blocks || np < 8) return 0.0; - - const int addr1= (int) (parms[7][0]+0.5); - EEL_F *d=__NSEEL_RAMAlloc(blocks,addr1); - if (sz>NSEEL_RAM_ITEMSPERBLOCK) - { - int x; - for(x=NSEEL_RAM_ITEMSPERBLOCK;xgfx_transformblit(parms,divw,divh,d); -#endif - } - return 0.0; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_circle(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - bool aa = true, fill = false; - if (np>3) fill = parms[3][0] > 0.5; - if (np>4) aa = parms[4][0] > 0.5; - if (ctx) ctx->gfx_circle((float)parms[0][0], (float)parms[1][0], (float)parms[2][0], fill, aa); - return 0.0; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_triangle(void* opaque, INT_PTR np, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_triangle(parms, (int)np); - return 0.0; -} - -static EEL_F * NSEEL_CGEN_CALL _gfx_drawnumber(void *opaque, EEL_F *n, EEL_F *nd) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_drawnumber(*n, *nd); - return n; -} - -static EEL_F * NSEEL_CGEN_CALL _gfx_drawchar(void *opaque, EEL_F *n) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_drawchar(*n); - return n; -} - -static EEL_F * NSEEL_CGEN_CALL _gfx_measurestr(void *opaque, EEL_F *str, EEL_F *xOut, EEL_F *yOut) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) - { - EEL_F *p[3]={str,xOut,yOut}; - ctx->gfx_drawstr(opaque,p,3,2); - } - return str; -} -static EEL_F * NSEEL_CGEN_CALL _gfx_measurechar(void *opaque, EEL_F *str, EEL_F *xOut, EEL_F *yOut) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) - { - EEL_F *p[3]={str,xOut,yOut}; - ctx->gfx_drawstr(opaque,p,3,3); - } - return str; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_drawstr(void *opaque, INT_PTR nparms, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_drawstr(opaque,parms,(int)nparms,0); - return parms[0][0]; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_printf(void *opaque, INT_PTR nparms, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx && nparms>0) - { - EEL_F v= **parms; - ctx->gfx_drawstr(opaque,parms,(int)nparms,1); - return v; - } - return 0.0; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_showmenu(void* opaque, INT_PTR nparms, EEL_F **parms) -{ - eel_lice_state* ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) return ctx->gfx_showmenu(opaque, parms, (int)nparms); - return 0.0; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_setcursor(void* opaque, INT_PTR nparms, EEL_F **parms) -{ - eel_lice_state* ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) return ctx->gfx_setcursor(opaque, parms, (int)nparms); - return 0.0; -} - -static EEL_F * NSEEL_CGEN_CALL _gfx_setpixel(void *opaque, EEL_F *r, EEL_F *g, EEL_F *b) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_setpixel(*r, *g, *b); - return r; -} - -static EEL_F * NSEEL_CGEN_CALL _gfx_getpixel(void *opaque, EEL_F *r, EEL_F *g, EEL_F *b) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_getpixel(r, g, b); - return r; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_setfont(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) return ctx->gfx_setfont(opaque,(int)np,parms); - return 0.0; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_getfont(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) - { - const int idx=ctx->m_gfx_font_active; - if (idx>=0 && idx < ctx->m_gfx_fonts.GetSize()) - { - eel_lice_state::gfxFontStruct* f=ctx->m_gfx_fonts.Get()+idx; - - EEL_STRING_MUTEXLOCK_SCOPE - -#ifdef NOT_EEL_STRING_UPDATE_STRING - NOT_EEL_STRING_UPDATE_STRING(parms[0][0],f->actual_fontname); -#else - WDL_FastString *fs=NULL; - EEL_STRING_GET_FOR_WRITE(parms[0][0],&fs); - if (fs) fs->Set(f->actual_fontname); -#endif - } - return idx; - } - return 0.0; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_blit2(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx && np>=3) - { - ctx->gfx_blitext2((int)np,parms,0); - return *(parms[0]); - } - return 0.0; -} - -static EEL_F * NSEEL_CGEN_CALL _gfx_blitext(void *opaque, EEL_F *img, EEL_F *coordidx, EEL_F *rotate) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) - { -#ifndef EEL_LICE_NO_RAM -#ifdef EEL_LICE_RAMFUNC - EEL_F *buf = EEL_LICE_RAMFUNC(opaque,1,10); - if (!buf) return img; -#else - EEL_F fc = *coordidx; - if (fc < -0.5 || fc >= NSEEL_RAM_BLOCKS*NSEEL_RAM_ITEMSPERBLOCK) return img; - int a=(int)fc; - if (a<0) return img; - - EEL_F buf[10]; - int x; - EEL_F **blocks = ctx->m_vmref ? ((compileContext*)ctx->m_vmref)->ram_state->blocks : 0; - if (!blocks) return img; - for (x = 0;x < 10; x ++) - { - EEL_F *d=__NSEEL_RAMAlloc(blocks,a++); - if (!d || d==&nseel_ramalloc_onfail) return img; - buf[x]=*d; - } -#endif - // read megabuf - ctx->gfx_blitext(*img,buf,*rotate); -#endif - } - return img; -} - - -static EEL_F * NSEEL_CGEN_CALL _gfx_blurto(void *opaque, EEL_F *x, EEL_F *y) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_blurto(*x,*y); - return x; -} - -static EEL_F * NSEEL_CGEN_CALL _gfx_getimgdim(void *opaque, EEL_F *img, EEL_F *w, EEL_F *h) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) ctx->gfx_getimgdim(*img,w,h); - return img; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_loadimg(void *opaque, EEL_F *img, EEL_F *fr) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) return ctx->gfx_loadimg(opaque,(int)*img,*fr); - return 0.0; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_getdropfile(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) return ctx->gfx_getdropfile(opaque,(int) np, parms); - return 0.0; -} -static EEL_F NSEEL_CGEN_CALL _gfx_setimgdim(void *opaque, EEL_F *img, EEL_F *w, EEL_F *h) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) return ctx->gfx_setimgdim((int)*img,w,h); - return 0.0; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_getsyscol(void* ctxe, INT_PTR np, EEL_F **parms) -{ - return (EEL_F)LICE_RGBA_FROMNATIVE(GetSysColor(COLOR_3DFACE)); -} - -void eel_lice_state::gfx_lineto(EEL_F xpos, EEL_F ypos, EEL_F aaflag) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_lineto"); - if (!dest) return; - - int x1=(int)floor(xpos),y1=(int)floor(ypos),x2=(int)floor(*m_gfx_x), y2=(int)floor(*m_gfx_y); - if (LICE_FUNCTION_VALID(LICE__GetWidth) && LICE_FUNCTION_VALID(LICE__GetHeight) && LICE_FUNCTION_VALID(LICE_Line) && - LICE_FUNCTION_VALID(LICE_ClipLine) && - LICE_ClipLine(&x1,&y1,&x2,&y2,0,0,LICE__GetWidth(dest),LICE__GetHeight(dest))) - { - SetImageDirty(dest); - LICE_Line(dest,x1,y1,x2,y2,getCurColor(),(float) *m_gfx_a,getCurMode(),aaflag > 0.5); - } - *m_gfx_x = xpos; - *m_gfx_y = ypos; - -} - -void eel_lice_state::gfx_circle(float x, float y, float r, bool fill, bool aaflag) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_circle"); - if (!dest) return; - - if (LICE_FUNCTION_VALID(LICE_Circle) && LICE_FUNCTION_VALID(LICE_FillCircle)) - { - SetImageDirty(dest); - if(fill) - LICE_FillCircle(dest, x, y, r, getCurColor(), (float) *m_gfx_a, getCurMode(), aaflag); - else - LICE_Circle(dest, x, y, r, getCurColor(), (float) *m_gfx_a, getCurMode(), aaflag); - } -} - -void eel_lice_state::gfx_triangle(EEL_F** parms, int np) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest, "gfx_triangle"); - if (np >= 6) - { - np &= ~1; - SetImageDirty(dest); - if (np == 6) - { - if (!LICE_FUNCTION_VALID(LICE_FillTriangle)) return; - - LICE_FillTriangle(dest, (int)parms[0][0], (int)parms[1][0], (int)parms[2][0], (int)parms[3][0], - (int)parms[4][0], (int)parms[5][0], getCurColor(), (float)*m_gfx_a, getCurMode()); - } - else - { - if (!LICE_FUNCTION_VALID(LICE_FillConvexPolygon)) return; - - const int maxpt = 512; - const int n = wdl_min(np/2, maxpt); - int i, rdi=0; - int x[maxpt], y[maxpt]; - for (i=0; i < n; i++) - { - x[i]=(int)parms[rdi++][0]; - y[i]=(int)parms[rdi++][0]; - } - - LICE_FillConvexPolygon(dest, x, y, n, getCurColor(), (float)*m_gfx_a, getCurMode()); - } - } -} - -void eel_lice_state::gfx_rectto(EEL_F xpos, EEL_F ypos) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_rectto"); - if (!dest) return; - - EEL_F x1=xpos,y1=ypos,x2=*m_gfx_x, y2=*m_gfx_y; - if (x2 0.5 && y2-y1 > 0.5) - { - SetImageDirty(dest); - LICE_FillRect(dest,(int)x1,(int)y1,(int)(x2-x1),(int)(y2-y1),getCurColor(),(float)*m_gfx_a,getCurMode()); - } - *m_gfx_x = xpos; - *m_gfx_y = ypos; -} - - -void eel_lice_state::gfx_line(int np, EEL_F **parms) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_line"); - if (!dest) return; - - int x1=(int)floor(parms[0][0]),y1=(int)floor(parms[1][0]),x2=(int)floor(parms[2][0]), y2=(int)floor(parms[3][0]); - if (LICE_FUNCTION_VALID(LICE__GetWidth) && - LICE_FUNCTION_VALID(LICE__GetHeight) && - LICE_FUNCTION_VALID(LICE_Line) && - LICE_FUNCTION_VALID(LICE_ClipLine) && LICE_ClipLine(&x1,&y1,&x2,&y2,0,0,LICE__GetWidth(dest),LICE__GetHeight(dest))) - { - SetImageDirty(dest); - LICE_Line(dest,x1,y1,x2,y2,getCurColor(),(float)*m_gfx_a,getCurMode(),np< 5 || parms[4][0] > 0.5); - } -} - -void eel_lice_state::gfx_rect(int np, EEL_F **parms) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_rect"); - if (!dest) return; - - int x1=(int)floor(parms[0][0]),y1=(int)floor(parms[1][0]),w=(int)floor(parms[2][0]),h=(int)floor(parms[3][0]); - int filled=(np < 5 || parms[4][0] > 0.5); - - if (LICE_FUNCTION_VALID(LICE_FillRect) && LICE_FUNCTION_VALID(LICE_DrawRect) && w>0 && h>0) - { - SetImageDirty(dest); - if (filled) LICE_FillRect(dest,x1,y1,w,h,getCurColor(),(float)*m_gfx_a,getCurMode()); - else LICE_DrawRect(dest, x1, y1, w-1, h-1, getCurColor(), (float)*m_gfx_a, getCurMode()); - } -} - -void eel_lice_state::gfx_roundrect(int np, EEL_F **parms) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_roundrect"); - if (!dest) return; - - const bool aa = np <= 5 || parms[5][0]>0.5; - - if (LICE_FUNCTION_VALID(LICE_RoundRect) && parms[2][0]>0 && parms[3][0]>0) - { - SetImageDirty(dest); - LICE_RoundRect(dest, (float)parms[0][0], (float)parms[1][0], (float)parms[2][0], (float)parms[3][0], (int)parms[4][0], getCurColor(), (float)*m_gfx_a, getCurMode(), aa); - } -} - -void eel_lice_state::gfx_arc(int np, EEL_F **parms) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_arc"); - if (!dest) return; - - const bool aa = np <= 5 || parms[5][0]>0.5; - - if (LICE_FUNCTION_VALID(LICE_Arc)) - { - SetImageDirty(dest); - LICE_Arc(dest, (float)parms[0][0], (float)parms[1][0], (float)parms[2][0], (float)parms[3][0], (float)parms[4][0], getCurColor(), (float)*m_gfx_a, getCurMode(), aa); - } -} - -void eel_lice_state::gfx_grad_or_muladd_rect(int whichmode, int np, EEL_F **parms) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,whichmode==0?"gfx_gradrect":"gfx_muladdrect"); - if (!dest) return; - - const int x1=(int)floor(parms[0][0]),y1=(int)floor(parms[1][0]),w=(int)floor(parms[2][0]), h=(int)floor(parms[3][0]); - - if (w>0 && h>0) - { - SetImageDirty(dest); - if (whichmode==0 && LICE_FUNCTION_VALID(LICE_GradRect) && np > 7) - { - LICE_GradRect(dest,x1,y1,w,h,(float)parms[4][0],(float)parms[5][0],(float)parms[6][0],(float)parms[7][0], - np > 8 ? (float)parms[8][0]:0.0f, np > 9 ? (float)parms[9][0]:0.0f, np > 10 ? (float)parms[10][0]:0.0f, np > 11 ? (float)parms[11][0]:0.0f, - np > 12 ? (float)parms[12][0]:0.0f, np > 13 ? (float)parms[13][0]:0.0f, np > 14 ? (float)parms[14][0]:0.0f, np > 15 ? (float)parms[15][0]:0.0f, - getCurMode()); - } - else if (whichmode==1 && LICE_FUNCTION_VALID(LICE_MultiplyAddRect) && np > 6) - { - const double sc = 255.0; - LICE_MultiplyAddRect(dest,x1,y1,w,h,(float)parms[4][0],(float)parms[5][0],(float)parms[6][0],np>7 ? (float)parms[7][0]:1.0f, - (float)(np > 8 ? sc*parms[8][0]:0.0), (float)(np > 9 ? sc*parms[9][0]:0.0), (float)(np > 10 ? sc*parms[10][0]:0.0), (float)(np > 11 ? sc*parms[11][0]:0.0)); - } - } -} - - - -void eel_lice_state::gfx_setpixel(EEL_F r, EEL_F g, EEL_F b) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_setpixel"); - if (!dest) return; - - int red=(int) (r*255.0); - int green=(int) (g*255.0); - int blue=(int) (b*255.0); - if (red<0) red=0;else if (red>255)red=255; - if (green<0) green=0;else if (green>255)green=255; - if (blue<0) blue=0; else if (blue>255) blue=255; - - if (LICE_FUNCTION_VALID(LICE_PutPixel)) - { - SetImageDirty(dest); - LICE_PutPixel(dest,(int)*m_gfx_x, (int)*m_gfx_y,LICE_RGBA(red,green,blue,255), (float)*m_gfx_a,getCurMode()); - } -} - -void eel_lice_state::gfx_getimgdim(EEL_F img, EEL_F *w, EEL_F *h) -{ - *w=*h=0; -#ifdef DYNAMIC_LICE - if (!LICE__GetWidth || !LICE__GetHeight) return; -#endif - - LICE_IBitmap *bm=GetImageForIndex(img,"gfx_getimgdim",false); - if (bm) - { - *w=LICE__GetWidth(bm); - *h=LICE__GetHeight(bm); - } -} - -EEL_F eel_lice_state::gfx_getdropfile(void *opaque, int np, EEL_F **parms) -{ - const int idx = (int) parms[0][0]; - if (idx<0) m_ddrop_files.Empty(true,free); - if (idx < 0 || idx >= m_ddrop_files.GetSize()) return 0.0; - -#ifdef NOT_EEL_STRING_UPDATE_STRING - NOT_EEL_STRING_UPDATE_STRING(parms[1][0],m_ddrop_files.Get(idx)); -#else - if (np > 1) - { - EEL_STRING_MUTEXLOCK_SCOPE - WDL_FastString *fs=NULL; - EEL_STRING_GET_FOR_WRITE(parms[1][0], &fs); - if (fs) fs->Set(m_ddrop_files.Get(idx)); - } -#endif - return 1.0; -} - -bool eel_lice_state::do_load_image(int img, const char *str) -{ - s_img_cache_mutex.Enter(); - img_shared_state *s = s_img_cache.Get(str); - if (s) - { - wdl_atomic_incr(&s->refcnt); - } - else - { - s_img_cache_mutex.Leave(); - - LICE_IBitmap *bm = LICE_LoadImage(str,NULL,false); - if (!bm) return false; - - s = new img_shared_state(bm); - s_img_cache_mutex.Enter(); - s_img_cache.Insert(str,s); - } - s_img_cache_mutex.Leave(); - m_gfx_images.Get()[img].clear(NULL,s); - - return true; -} - -EEL_F eel_lice_state::gfx_loadimg(void *opaque, int img, EEL_F loadFrom) -{ -#ifdef DYNAMIC_LICE - if (!__LICE_LoadImage || !LICE__Destroy) return 0.0; -#endif - - if (img >= 0 && img < m_gfx_images.GetSize()) - { - WDL_FastString fs; - bool ok = EEL_LICE_GET_FILENAME_FOR_STRING(loadFrom,&fs,0); - - if (ok && fs.GetLength()) - { - if (do_load_image(img,fs.Get())) - return img; - } - } - return -1.0; - -} - -EEL_F eel_lice_state::gfx_setimgdim(int img, EEL_F *w, EEL_F *h) -{ - int rv=0; -#ifdef DYNAMIC_LICE - if (!LICE__resize ||!LICE__GetWidth || !LICE__GetHeight||!__LICE_CreateBitmap) return 0.0; -#endif - - int use_w = (int)*w; - int use_h = (int)*h; - if (use_w<1 || use_h < 1) use_w=use_h=0; - if (use_w > 8192) use_w=8192; - if (use_h > 8192) use_h=8192; - - LICE_IBitmap *bm=NULL; - if (img >= 0 && img < m_gfx_images.GetSize()) - { - m_gfx_images.Get()[img].on_write(); - bm=m_gfx_images.Get()[img].bm; - if (!bm) - { - m_gfx_images.Get()[img].bm = bm = __LICE_CreateBitmap(1,use_w,use_h); - rv=!!bm; - } - else - { - rv=LICE__resize(bm,use_w,use_h); - } - } - - return rv?1.0:0.0; -} - -void eel_lice_state::gfx_blurto(EEL_F x, EEL_F y) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_blurto"); - if (!dest -#ifdef DYNAMIC_LICE - ||!LICE_Blur -#endif - ) return; - - SetImageDirty(dest); - - int srcx = (int)x; - int srcy = (int)y; - int srcw=(int) (*m_gfx_x-x); - int srch=(int) (*m_gfx_y-y); - if (srch < 0) { srch=-srch; srcy = (int)*m_gfx_y; } - if (srcw < 0) { srcw=-srcw; srcx = (int)*m_gfx_x; } - LICE_Blur(dest,dest,srcx,srcy,srcx,srcy,srcw,srch); - *m_gfx_x = x; - *m_gfx_y = y; -} - -static bool CoordsSrcDestOverlap(EEL_F *coords) -{ - if (coords[0]+coords[2] < coords[4]) return false; - if (coords[0] > coords[4] + coords[6]) return false; - if (coords[1]+coords[3] < coords[5]) return false; - if (coords[1] > coords[5] + coords[7]) return false; - return true; -} - -void eel_lice_state::gfx_transformblit(EEL_F **parms, int div_w, int div_h, EEL_F *tab) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_transformblit"); - - if (!dest -#ifdef DYNAMIC_LICE - ||!LICE_ScaledBlit || !LICE_TransformBlit2 ||!LICE__GetWidth||!LICE__GetHeight -#endif - ) return; - - LICE_IBitmap *bm=GetImageForIndex(parms[0][0],"gfx_transformblit:src",false); - if (!bm) return; - - const int bmw=LICE__GetWidth(bm); - const int bmh=LICE__GetHeight(bm); - - const bool isFromFB = bm==m_framebuffer; - - SetImageDirty(dest); - - if (bm == dest) - { - if (!m_framebuffer_extra && LICE_FUNCTION_VALID(__LICE_CreateBitmap)) m_framebuffer_extra=__LICE_CreateBitmap(0,bmw,bmh); - if (m_framebuffer_extra) - { - - LICE__resize(bm=m_framebuffer_extra,bmw,bmh); - LICE_ScaledBlit(bm,dest, // copy the entire image - 0,0,bmw,bmh, - 0.0f,0.0f,(float)bmw,(float)bmh, - 1.0f,LICE_BLIT_MODE_COPY); - } - } - LICE_TransformBlit2(dest,bm,(int)floor(parms[1][0]),(int)floor(parms[2][0]),(int)floor(parms[3][0]),(int)floor(parms[4][0]),tab,div_w,div_h, (float)*m_gfx_a,getCurModeForBlit(isFromFB)); -} - -EEL_F eel_lice_state::gfx_setfont(void *opaque, int np, EEL_F **parms) -{ - int a = np>0 ? ((int)floor(parms[0][0]))-1 : -1; - - if (a>=0 && a < m_gfx_fonts.GetSize()) - { - gfxFontStruct *s = m_gfx_fonts.Get()+a; - if (np>1 && LICE_FUNCTION_VALID(LICE_CreateFont) && LICE_FUNCTION_VALID(LICE__SetFromHFont)) - { - const int sz=np>2 ? (int)parms[2][0] : 10; - - bool doCreate=false; - int fontflag=0; - if (!s->font) s->actual_fontname[0]=0; - - { - EEL_STRING_MUTEXLOCK_SCOPE - - const char *face=EEL_STRING_GET_FOR_INDEX(parms[1][0],NULL); - #ifdef EEL_STRING_DEBUGOUT - if (!face) EEL_STRING_DEBUGOUT("gfx_setfont: invalid string identifier %f",parms[1][0]); - #endif - if (!face || !*face) face="Arial"; - - { - unsigned int c = np > 3 ? (unsigned int) parms[3][0] : 0; - while (c) - { - switch (toupper(c&0xff)) - { - case 'B': fontflag|=EELFONT_FLAG_BOLD; break; - case 'I': fontflag|=EELFONT_FLAG_ITALIC; break; - case 'U': fontflag|=EELFONT_FLAG_UNDERLINE; break; - case 'R': fontflag|=16; break; //LICE_FONT_FLAG_FX_BLUR - case 'V': fontflag|=32; break; //LICE_FONT_FLAG_FX_INVERT - case 'M': fontflag|=64; break; //LICE_FONT_FLAG_FX_MONO - case 'S': fontflag|=128; break; //LICE_FONT_FLAG_FX_SHADOW - case 'O': fontflag|=256; break; //LICE_FONT_FLAG_FX_OUTLINE - case 'Z': fontflag|=1; break; //LICE_FONT_FLAG_VERTICAL - case 'Y': fontflag|=1|2; break; //LICE_FONT_FLAG_VERTICAL|LICE_FONT_FLAG_VERTICAL_BOTTOMUP - } - c>>=8; - } - } - - - if (fontflag != s->last_fontflag || sz!=s->last_fontsize || strncmp(s->last_fontname,face,sizeof(s->last_fontname)-1)) - { - lstrcpyn_safe(s->last_fontname,face,sizeof(s->last_fontname)); - s->last_fontsize=sz; - s->last_fontflag=fontflag; - doCreate=1; - } - } - - if (doCreate) - { - s->actual_fontname[0]=0; - if (!s->font) s->font=LICE_CreateFont(); - if (s->font) - { - const int fw = (fontflag&EELFONT_FLAG_BOLD) ? FW_BOLD : FW_NORMAL; - const bool italic = !!(fontflag&EELFONT_FLAG_ITALIC); - const bool underline = !!(fontflag&EELFONT_FLAG_UNDERLINE); - HFONT hf=NULL; -#if defined(_WIN32) && !defined(WDL_NO_SUPPORT_UTF8) - WCHAR wf[256]; - if (WDL_DetectUTF8(s->last_fontname)>0 && - GetVersion()<0x80000000 && - MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,s->last_fontname,-1,wf,256)) - { - hf = CreateFontW(sz,0,0,0,fw,italic,underline,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,wf); - } -#endif - if (!hf) hf = CreateFont(sz,0,0,0,fw,italic,underline,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,s->last_fontname); - - if (!hf) - { - s->use_fonth=0; // disable this font - } - else - { - TEXTMETRIC tm; - tm.tmHeight = sz; - - if (!m_framebuffer && LICE_FUNCTION_VALID(__LICE_CreateBitmap)) m_framebuffer=__LICE_CreateBitmap(1,64,64); - - if (m_framebuffer && LICE_FUNCTION_VALID(LICE__GetDC)) - { - HGDIOBJ oldFont = 0; - HDC hdc=LICE__GetDC(m_framebuffer); - if (hdc) - { - oldFont = SelectObject(hdc,hf); - GetTextMetrics(hdc,&tm); - -#if defined(_WIN32) && !defined(WDL_NO_SUPPORT_UTF8) - if (GetVersion()<0x80000000 && - GetTextFaceW(hdc,sizeof(wf)/sizeof(wf[0]),wf) && - WideCharToMultiByte(CP_UTF8,0,wf,-1,s->actual_fontname,sizeof(s->actual_fontname),NULL,NULL)) - { - s->actual_fontname[sizeof(s->actual_fontname)-1]=0; - } - else -#endif - GetTextFace(hdc, sizeof(s->actual_fontname), s->actual_fontname); - SelectObject(hdc,oldFont); - } - } - - s->use_fonth=wdl_max(tm.tmHeight,1); - LICE__SetFromHFont(s->font,hf, (fontflag & ~EELFONT_FLAG_MASK) | 512 /*LICE_FONT_FLAG_OWNS_HFONT*/); - } - } - } - } - - - if (s->font && s->use_fonth) - { - m_gfx_font_active=a; - if (m_gfx_texth) *m_gfx_texth=s->use_fonth; - return 1.0; - } - // try to init this font - } - #ifdef EEL_STRING_DEBUGOUT - if (a >= m_gfx_fonts.GetSize()) EEL_STRING_DEBUGOUT("gfx_setfont: invalid font %d specified",a); - #endif - - if (a<0||a>=m_gfx_fonts.GetSize()||!m_gfx_fonts.Get()[a].font) - { - m_gfx_font_active=-1; - if (m_gfx_texth) *m_gfx_texth=8; - return 1.0; - } - return 0.0; -} - -void eel_lice_state::gfx_blitext2(int np, EEL_F **parms, int blitmode) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_blitext2"); - - if (!dest -#ifdef DYNAMIC_LICE - ||!LICE_ScaledBlit || !LICE_RotatedBlit||!LICE__GetWidth||!LICE__GetHeight -#endif - ) return; - - LICE_IBitmap *bm=GetImageForIndex(parms[0][0],"gfx_blitext2:src",false); - if (!bm) return; - - const int bmw=LICE__GetWidth(bm); - const int bmh=LICE__GetHeight(bm); - - // 0=img, 1=scale, 2=rotate - double coords[8]; - const double sc = blitmode==0 && np > 1 ? parms[1][0] : 1.0, - angle = blitmode==0 && np > 2 ? parms[2][0] : 0.0; - if (blitmode==0) - { - parms+=2; - np -= 2; - } - - coords[0]=np > 1 ? parms[1][0] : 0.0f; - coords[1]=np > 2 ? parms[2][0] : 0.0f; - coords[2]=np > 3 ? parms[3][0] : bmw; - coords[3]=np > 4 ? parms[4][0] : bmh; - coords[4]=np > 5 ? parms[5][0] : *m_gfx_x; - coords[5]=np > 6 ? parms[6][0] : *m_gfx_y; - coords[6]=np > 7 ? parms[7][0] : coords[2]*sc; - coords[7]=np > 8 ? parms[8][0] : coords[3]*sc; - - const bool isFromFB = bm == m_framebuffer; - SetImageDirty(dest); - - if (bm == dest && - (blitmode != 0 || np > 1) && // legacy behavior to matech previous gfx_blit(3parm), do not use temp buffer - CoordsSrcDestOverlap(coords)) - { - if (!m_framebuffer_extra && LICE_FUNCTION_VALID(__LICE_CreateBitmap)) m_framebuffer_extra=__LICE_CreateBitmap(0,bmw,bmh); - if (m_framebuffer_extra) - { - - LICE__resize(bm=m_framebuffer_extra,bmw,bmh); - LICE_ScaledBlit(bm,dest, // copy the source portion - (int)coords[0],(int)coords[1],(int)coords[2],(int)coords[3], - (float)coords[0],(float)coords[1],(float)coords[2],(float)coords[3], - 1.0f,LICE_BLIT_MODE_COPY); - } - } - - if (blitmode==1) - { - if (LICE_FUNCTION_VALID(LICE_DeltaBlit)) - LICE_DeltaBlit(dest,bm,(int)coords[4],(int)coords[5],(int)coords[6],(int)coords[7], - (float)coords[0],(float)coords[1],(float)coords[2],(float)coords[3], - np > 9 ? (float)parms[9][0]:1.0f, // dsdx - np > 10 ? (float)parms[10][0]:0.0f, // dtdx - np > 11 ? (float)parms[11][0]:0.0f, // dsdy - np > 12 ? (float)parms[12][0]:1.0f, // dtdy - np > 13 ? (float)parms[13][0]:0.0f, // dsdxdy - np > 14 ? (float)parms[14][0]:0.0f, // dtdxdy - np <= 15 || parms[15][0] > 0.5, (float)*m_gfx_a,getCurModeForBlit(isFromFB)); - } - else if (fabs(angle)>0.000000001) - { - LICE_RotatedBlit(dest,bm,(int)coords[4],(int)coords[5],(int)coords[6],(int)coords[7], - (float)coords[0],(float)coords[1],(float)coords[2],(float)coords[3], - (float)angle,true, (float)*m_gfx_a,getCurModeForBlit(isFromFB), - np > 9 ? (float)parms[9][0] : 0.0f, - np > 10 ? (float)parms[10][0] : 0.0f); - } - else - { - LICE_ScaledBlit(dest,bm,(int)coords[4],(int)coords[5],(int)coords[6],(int)coords[7], - (float)coords[0],(float)coords[1],(float)coords[2],(float)coords[3], (float)*m_gfx_a,getCurModeForBlit(isFromFB)); - } -} - -void eel_lice_state::gfx_blitext(EEL_F img, EEL_F *coords, EEL_F angle) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_blitext"); - - if (!dest -#ifdef DYNAMIC_LICE - ||!LICE_ScaledBlit || !LICE_RotatedBlit||!LICE__GetWidth||!LICE__GetHeight -#endif - ) return; - - LICE_IBitmap *bm=GetImageForIndex(img,"gfx_blitext:src",false); - if (!bm) return; - - SetImageDirty(dest); - const bool isFromFB = bm == m_framebuffer; - - int bmw=LICE__GetWidth(bm); - int bmh=LICE__GetHeight(bm); - - if (bm == dest && CoordsSrcDestOverlap(coords)) - { - if (!m_framebuffer_extra && LICE_FUNCTION_VALID(__LICE_CreateBitmap)) m_framebuffer_extra=__LICE_CreateBitmap(0,bmw,bmh); - if ( m_framebuffer_extra) - { - - LICE__resize(bm=m_framebuffer_extra,bmw,bmh); - LICE_ScaledBlit(bm,dest, // copy the source portion - (int)coords[0],(int)coords[1],(int)coords[2],(int)coords[3], - (float)coords[0],(float)coords[1],(float)coords[2],(float)coords[3], - 1.0f,LICE_BLIT_MODE_COPY); - } - } - - if (fabs(angle)>0.000000001) - { - LICE_RotatedBlit(dest,bm,(int)coords[4],(int)coords[5],(int)coords[6],(int)coords[7], - (float)coords[0],(float)coords[1],(float)coords[2],(float)coords[3],(float)angle, - true, (float)*m_gfx_a,getCurModeForBlit(isFromFB), - (float)coords[8],(float)coords[9]); - } - else - { - LICE_ScaledBlit(dest,bm,(int)coords[4],(int)coords[5],(int)coords[6],(int)coords[7], - (float)coords[0],(float)coords[1],(float)coords[2],(float)coords[3], (float)*m_gfx_a,getCurModeForBlit(isFromFB)); - } -} - -void eel_lice_state::gfx_set(int np, EEL_F **parms) -{ - if (np < 1) return; - if (m_gfx_r) *m_gfx_r = parms[0][0]; - if (m_gfx_g) *m_gfx_g = np > 1 ? parms[1][0] : parms[0][0]; - if (m_gfx_b) *m_gfx_b = np > 2 ? parms[2][0] : parms[0][0]; - if (m_gfx_a) *m_gfx_a = np > 3 ? parms[3][0] : 1.0; - if (m_gfx_mode) *m_gfx_mode = np > 4 ? parms[4][0] : 0; - if (np > 5 && m_gfx_dest) *m_gfx_dest = parms[5][0]; - if (m_gfx_a2) *m_gfx_a2 = np > 6 ? parms[6][0] : 1.0; -} - -void eel_lice_state::gfx_getpixel(EEL_F *r, EEL_F *g, EEL_F *b) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_getpixel",false); - if (!dest) return; - - int ret=LICE_FUNCTION_VALID(LICE_GetPixel)?LICE_GetPixel(dest,(int)*m_gfx_x, (int)*m_gfx_y):0; - - *r=LICE_GETR(ret)/255.0; - *g=LICE_GETG(ret)/255.0; - *b=LICE_GETB(ret)/255.0; - -} - - -static int __drawTextWithFont(LICE_IBitmap *dest, const RECT *rect, LICE_IFont *font, const char *buf, int buflen, - int fg, int mode, float alpha, int flags, EEL_F *wantYoutput, EEL_F **measureOnly) -{ - if (font && LICE_FUNCTION_VALID(LICE__DrawText)) - { - RECT tr=*rect; - LICE__SetTextColor(font,fg); - LICE__SetTextCombineMode(font,mode,alpha); - - int maxx=0; - RECT r={0,0,tr.left,0}; - while (buflen>0) - { - int thislen = 0; - while (thislen < buflen && buf[thislen] != '\n') thislen++; - memset(&r,0,sizeof(r)); - int lineh = LICE__DrawText(font,dest,buf,thislen?thislen:1,&r,DT_SINGLELINE|DT_NOPREFIX|DT_CALCRECT); - if (!measureOnly) - { - r.right += tr.left; - lineh = LICE__DrawText(font,dest,buf,thislen?thislen:1,&tr,DT_SINGLELINE|DT_NOPREFIX|flags); - if (wantYoutput) *wantYoutput = tr.top; - } - else - { - if (r.right > maxx) maxx=r.right; - } - tr.top += lineh; - - buflen -= thislen+1; - buf += thislen+1; - } - if (measureOnly) - { - measureOnly[0][0] = maxx; - measureOnly[1][0] = tr.top; - } - return r.right; - } - else - { - int xpos=rect->left, ypos=rect->top; - int x; - int maxx=0,maxy=0; - - LICE_SubBitmap sbm( -#ifdef DYNAMIC_LICE - (LICE_IBitmap_disabledAPI*) -#endif - dest,rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top); - - if (!measureOnly) - { - if (!(flags & DT_NOCLIP)) - { - if (rect->right <= rect->left || rect->bottom <= rect->top) return 0; // invalid clip rect hm - - xpos = ypos = 0; - dest = &sbm; - } - if (flags & (DT_RIGHT|DT_BOTTOM|DT_CENTER|DT_VCENTER)) - { - EEL_F w=0.0,h=0.0; - EEL_F *mo[2] = { &w,&h}; - RECT tr={0,}; - __drawTextWithFont(dest,&tr,NULL,buf,buflen,0,0,0.0f,0,NULL,mo); - - if (flags & DT_RIGHT) xpos += (rect->right-rect->left) - (int)floor(w); - else if (flags & DT_CENTER) xpos += (rect->right-rect->left)/2 - (int)floor(w*.5); - - if (flags & DT_BOTTOM) ypos += (rect->bottom-rect->top) - (int)floor(h); - else if (flags & DT_VCENTER) ypos += (rect->bottom-rect->top)/2 - (int)floor(h*.5); - } - } - const int sxpos = xpos; - - if (LICE_FUNCTION_VALID(LICE_DrawChar)) for(x=0;x maxx) maxx=xpos; - maxy = ypos + 8; - break; - } - } - if (measureOnly) - { - measureOnly[0][0]=maxx; - measureOnly[1][0]=maxy; - } - else - { - if (wantYoutput) *wantYoutput=ypos; - } - return xpos; - } -} - -static HMENU PopulateMenuFromStr(const char** str, int* startid) -{ - HMENU hm=CreatePopupMenu(); - int pos=0; - int id=*startid; - - char buf[1024]; - const char* p=*str; - const char* sep=strchr(p, '|'); - while (sep || *p) - { - int len = (int)(sep ? sep-p : strlen(p)); - int destlen=wdl_min(len, (int)sizeof(buf)-1); - lstrcpyn(buf, p, destlen+1); - p += len; - if (sep) sep=strchr(++p, '|'); - - const char* q=buf; - HMENU subm=NULL; - bool done=false; - int flags=MF_BYPOSITION|MF_STRING; - while (strspn(q, ">#!<")) - { - if (*q == '>' && !subm) - { - subm=PopulateMenuFromStr(&p, &id); - sep=strchr(p, '|'); - } - if (*q == '#') flags |= MF_GRAYED; - if (*q == '!') flags |= MF_CHECKED; - if (*q == '<') done=true; - ++q; - } - if (subm) flags |= MF_POPUP; - if (*q) InsertMenu(hm, pos++, flags, (subm ? (INT_PTR)subm : (INT_PTR)id++), q); - else if (!done) InsertMenu(hm, pos++, MF_BYPOSITION|MF_SEPARATOR, 0, NULL); - if (done) break; - } - - *str=p; - *startid=id; - - if (!pos) - { - DestroyMenu(hm); - return NULL; - } - return hm; -} - -EEL_F eel_lice_state::gfx_showmenu(void* opaque, EEL_F** parms, int nparms) -{ - const char* p=EEL_STRING_GET_FOR_INDEX(parms[0][0], NULL); - if (!p || !p[0]) return 0.0; - - if ((GetTickCount()-m_last_menu_time) < (m_last_menu_cnt>=5 ? 3000 : 500)) - { - if (m_last_menu_cnt >= 5) return 0; - m_last_menu_cnt++; - } - else - { - m_last_menu_cnt=0; - } - - int id=1; - HMENU hm=PopulateMenuFromStr(&p, &id); - - int ret=0; - if (hm) - { - POINT pt; - HWND par = hwnd_standalone; - if (par) - { -#ifdef __APPLE__ - if (*m_gfx_ext_retina > 1.0) - { - pt.x = (short)(*m_gfx_x * .5); - pt.y = (short)(*m_gfx_y * .5); - } - else -#endif - { - pt.x = (short)*m_gfx_x; - pt.y = (short)*m_gfx_y; - } - ClientToScreen(par, &pt); - } - else - { -#ifdef EEL_LICE_STANDALONE_PARENT - par = EEL_LICE_STANDALONE_PARENT(opaque); -#endif - GetCursorPos(&pt); - } - - ret=TrackPopupMenu(hm, TPM_NONOTIFY|TPM_RETURNCMD, pt.x, pt.y, 0, par, NULL); - m_last_menu_time = GetTickCount(); - if (ret) m_last_menu_cnt = 0; - DestroyMenu(hm); - } - return (EEL_F)ret; -} - -EEL_F eel_lice_state::gfx_setcursor(void* opaque, EEL_F** parms, int nparms) -{ - if (!hwnd_standalone) return 0.0; - - bool chg = false; - const int nc = (int)parms[0][0]; - if (m_cursor_resid != nc) - { - m_cursor_resid = nc; - chg = true; - } - - const char *p = NULL; -#ifdef EEL_LICE_LOADTHEMECURSOR - if (nparms > 1) p=EEL_STRING_GET_FOR_INDEX(parms[1][0], NULL); - - if (strncmp(p?p:"",m_cursor_name,sizeof(m_cursor_name)-1)) - { - lstrcpyn(m_cursor_name, p?p:"", sizeof(m_cursor_name)); - chg = true; - } -#endif - - if (chg) - { - m_cursor = NULL; - if (!p || !*p) m_cursor = m_cursor_resid > 0 ? LoadCursor(NULL, MAKEINTRESOURCE(m_cursor_resid)) : NULL; -#ifdef EEL_LICE_LOADTHEMECURSOR - else m_cursor = EEL_LICE_LOADTHEMECURSOR(m_cursor_resid, p); -#endif - - bool do_set = GetCapture() == hwnd_standalone; - if (!do_set && GetFocus() == hwnd_standalone) - { - POINT pt; - RECT r; - GetCursorPos(&pt); - ScreenToClient(hwnd_standalone,&pt); - GetClientRect(hwnd_standalone,&r); - do_set = PtInRect(&r,pt)!=0; - } - - if (do_set) - { - SetCursor(m_cursor ? m_cursor : LoadCursor(NULL,IDC_ARROW)); - } - } - - return 1.0; -} - - -void eel_lice_state::gfx_drawstr(void *opaque, EEL_F **parms, int nparms, int formatmode)// formatmode=1 for format, 2 for purely measure no format -{ - int nfmtparms = nparms-1; - EEL_F **fmtparms = parms+1; - const char *funcname = formatmode==1?"gfx_printf": - formatmode==2?"gfx_measurestr": - formatmode==3?"gfx_measurechar" : "gfx_drawstr"; - - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,funcname); - if (!dest) return; - -#ifdef DYNAMIC_LICE - if (!LICE__GetWidth || !LICE__GetHeight) return; -#endif - - EEL_STRING_MUTEXLOCK_SCOPE - - WDL_FastString *fs=NULL; - char buf[4096]; - int s_len=0; - - const char *s; - if (formatmode==3) - { - s_len = WDL_MakeUTFChar(buf, (int)parms[0][0], sizeof(buf)); - s=buf; - } - else - { - s=EEL_STRING_GET_FOR_INDEX(parms[0][0],&fs); - #ifdef EEL_STRING_DEBUGOUT - if (!s) EEL_STRING_DEBUGOUT("gfx_%s: invalid string identifier %f",funcname,parms[0][0]); - #endif - if (!s) - { - s=""; - s_len = 12; - } - else if (formatmode==1) - { - extern int eel_format_strings(void *, const char *s, const char *ep, char *, int, int, EEL_F **); - s_len = eel_format_strings(opaque,s,fs?(s+fs->GetLength()):NULL,buf,sizeof(buf),nfmtparms,fmtparms); - if (s_len<1) return; - s=buf; - } - else - { - s_len = fs?fs->GetLength():(int)strlen(s); - } - } - - if (s_len) - { - if (formatmode>=2) - { - if (nfmtparms==2) - { - RECT r={0,0,0,0}; - __drawTextWithFont(dest,&r,GetActiveFont(),s,s_len, - getCurColor(),getCurMode(),(float)*m_gfx_a,0,NULL,fmtparms); - } - } - else - { - RECT r={(int)floor(*m_gfx_x),(int)floor(*m_gfx_y),0,0}; - int flags=DT_NOCLIP; - if (formatmode == 0 && nparms >= 4) - { - flags=(int)*parms[1]; - flags &= (DT_CENTER|DT_RIGHT|DT_VCENTER|DT_BOTTOM|DT_NOCLIP); - r.right=(int)*parms[2]; - r.bottom=(int)*parms[3]; - } - SetImageDirty(dest); - *m_gfx_x=__drawTextWithFont(dest,&r,GetActiveFont(),s,s_len, - getCurColor(),getCurMode(),(float)*m_gfx_a,flags,m_gfx_y,NULL); - } - } -} - -void eel_lice_state::gfx_drawchar(EEL_F ch) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_drawchar"); - if (!dest) return; - - SetImageDirty(dest); - - int a=(int)(ch+0.5); - if (a == '\r' || a=='\n') a=' '; - - char buf[32]; - const int buflen = WDL_MakeUTFChar(buf, a, sizeof(buf)); - - RECT r={(int)floor(*m_gfx_x),(int)floor(*m_gfx_y),0,0}; - *m_gfx_x = __drawTextWithFont(dest,&r, - GetActiveFont(),buf,buflen, - getCurColor(),getCurMode(),(float)*m_gfx_a,DT_NOCLIP,NULL,NULL); - -} - - -void eel_lice_state::gfx_drawnumber(EEL_F n, EEL_F ndigits) -{ - LICE_IBitmap *dest = GetImageForIndex(*m_gfx_dest,"gfx_drawnumber"); - if (!dest) return; - - SetImageDirty(dest); - - char buf[512]; - int a=(int)(ndigits+0.5); - if (a <0)a=0; - else if (a > 16) a=16; - snprintf(buf,sizeof(buf),"%.*f",a,n); - - RECT r={(int)floor(*m_gfx_x),(int)floor(*m_gfx_y),0,0}; - *m_gfx_x = __drawTextWithFont(dest,&r, - GetActiveFont(),buf,(int)strlen(buf), - getCurColor(),getCurMode(),(float)*m_gfx_a,DT_NOCLIP,NULL,NULL); -} - -int eel_lice_state::setup_frame(HWND hwnd, RECT r, int _mouse_x, int _mouse_y, int has_dpi) -{ - int use_w = r.right - r.left; - int use_h = r.bottom - r.top; - - POINT pt = { _mouse_x, _mouse_y }; - if (hwnd) - { - GetCursorPos(&pt); - ScreenToClient(hwnd,&pt); - } - - *m_mouse_x=pt.x-r.left; - *m_mouse_y=pt.y-r.top; - - if (has_dpi>0 && *m_gfx_ext_retina > 0.0) - { - *m_gfx_ext_retina = has_dpi/256.0; - } - else if (*m_gfx_ext_retina > 0.0) - { -#ifdef __APPLE__ - *m_gfx_ext_retina = (hwnd && SWELL_IsRetinaHWND(hwnd)) ? 2.0 : 1.0; - if (*m_gfx_ext_retina > 1.0) - { - *m_mouse_x *= 2.0; - *m_mouse_y *= 2.0; - use_w*=2; - use_h*=2; - } -#else - *m_gfx_ext_retina = 1.0; - #ifdef _WIN32 - static UINT (WINAPI *__GetDpiForWindow)(HWND); - if (!__GetDpiForWindow) - { - HINSTANCE h = LoadLibrary("user32.dll"); - if (h) *(void **)&__GetDpiForWindow = GetProcAddress(h,"GetDpiForWindow"); - if (!__GetDpiForWindow) - *(void **)&__GetDpiForWindow = (void*)(INT_PTR)1; - } - if (hwnd && (UINT_PTR)__GetDpiForWindow > (UINT_PTR)1) - { - int dpi = __GetDpiForWindow(hwnd); - if (dpi != 96) - *m_gfx_ext_retina = dpi / 96.0; - } - #else - const int rsc = SWELL_GetScaling256(); - if (rsc > 256) *m_gfx_ext_retina = rsc/256.0; - #endif -#endif - } - int dr=0; - if (!m_framebuffer && LICE_FUNCTION_VALID(__LICE_CreateBitmap)) - { - m_framebuffer=__LICE_CreateBitmap(1,use_w,use_h); - dr=1; - } - - if (!m_framebuffer || !LICE_FUNCTION_VALID(LICE__GetHeight) || !LICE_FUNCTION_VALID(LICE__GetWidth)) return -1; - - if (use_w != LICE__GetWidth(m_framebuffer) || use_h != LICE__GetHeight(m_framebuffer)) - { - LICE__resize(m_framebuffer,use_w,use_h); - dr=1; - } - *m_gfx_w = use_w; - *m_gfx_h = use_h; - - if (*m_gfx_clear > -1.0 && dr) - { - const int a=(int)*m_gfx_clear; - if (LICE_FUNCTION_VALID(LICE_Clear)) LICE_Clear(m_framebuffer,LICE_RGBA((a&0xff),((a>>8)&0xff),((a>>16)&0xff),0)); - } - m_framebuffer_dirty = dr; - - int vflags=0; - - if (m_has_cap) - { - bool swap = false; -#ifdef _WIN32 - swap = !!GetSystemMetrics(SM_SWAPBUTTON); -#endif - vflags|=m_has_cap&0xffff; - if (GetAsyncKeyState(VK_LBUTTON)&0x8000) vflags|=swap?2:1; - if (GetAsyncKeyState(VK_RBUTTON)&0x8000) vflags|=swap?1:2; - if (GetAsyncKeyState(VK_MBUTTON)&0x8000) vflags|=64; - } - if (m_has_cap || (m_has_had_getch && hwnd && GetFocus()==hwnd)) - { - if (GetAsyncKeyState(VK_CONTROL)&0x8000) vflags|=4; - if (GetAsyncKeyState(VK_SHIFT)&0x8000) vflags|=8; - if (GetAsyncKeyState(VK_MENU)&0x8000) vflags|=16; - if (GetAsyncKeyState(VK_LWIN)&0x8000) vflags|=32; - } - m_has_cap &= 0xf0000; - - *m_mouse_cap=(EEL_F)vflags; - - *m_gfx_dest = -1.0; // m_framebuffer - *m_gfx_a2 = *m_gfx_a = 1.0; // default to full alpha every call - int fh; - if (m_gfx_font_active>=0&&m_gfx_font_active0) - *m_gfx_texth=fh; - else - *m_gfx_texth = 8; - - return dr; -} - -void eel_lice_state::finish_draw() -{ - if (hwnd_standalone && m_framebuffer_dirty) - { -#ifdef __APPLE__ - void *p = SWELL_InitAutoRelease(); -#endif - - InvalidateRect(hwnd_standalone,NULL,FALSE); - UpdateWindow(hwnd_standalone); - -#ifdef __APPLE__ - SWELL_QuitAutoRelease(p); -#endif - m_framebuffer_dirty = 0; - } -} - -#ifndef EEL_LICE_NO_REGISTER -void eel_lice_register() -{ - NSEEL_addfunc_retptr("gfx_lineto",3,NSEEL_PProc_THIS,&_gfx_lineto); - NSEEL_addfunc_retptr("gfx_lineto",2,NSEEL_PProc_THIS,&_gfx_lineto2); - NSEEL_addfunc_retptr("gfx_rectto",2,NSEEL_PProc_THIS,&_gfx_rectto); - NSEEL_addfunc_varparm("gfx_rect",4,NSEEL_PProc_THIS,&_gfx_rect); - NSEEL_addfunc_varparm("gfx_line",4,NSEEL_PProc_THIS,&_gfx_line); // 5th param is optionally AA - NSEEL_addfunc_varparm("gfx_gradrect",8,NSEEL_PProc_THIS,&_gfx_gradrect); - NSEEL_addfunc_varparm("gfx_muladdrect",7,NSEEL_PProc_THIS,&_gfx_muladdrect); - NSEEL_addfunc_varparm("gfx_deltablit",9,NSEEL_PProc_THIS,&_gfx_deltablit); - NSEEL_addfunc_exparms("gfx_transformblit",8,NSEEL_PProc_THIS,&_gfx_transformblit); - NSEEL_addfunc_varparm("gfx_circle",3,NSEEL_PProc_THIS,&_gfx_circle); - NSEEL_addfunc_varparm("gfx_triangle", 6, NSEEL_PProc_THIS, &_gfx_triangle); - NSEEL_addfunc_varparm("gfx_roundrect",5,NSEEL_PProc_THIS,&_gfx_roundrect); - NSEEL_addfunc_varparm("gfx_arc",5,NSEEL_PProc_THIS,&_gfx_arc); - NSEEL_addfunc_retptr("gfx_blurto",2,NSEEL_PProc_THIS,&_gfx_blurto); - NSEEL_addfunc_exparms("gfx_showmenu",1,NSEEL_PProc_THIS,&_gfx_showmenu); - NSEEL_addfunc_varparm("gfx_setcursor",1, NSEEL_PProc_THIS, &_gfx_setcursor); - NSEEL_addfunc_retptr("gfx_drawnumber",2,NSEEL_PProc_THIS,&_gfx_drawnumber); - NSEEL_addfunc_retptr("gfx_drawchar",1,NSEEL_PProc_THIS,&_gfx_drawchar); - NSEEL_addfunc_varparm("gfx_drawstr",1,NSEEL_PProc_THIS,&_gfx_drawstr); - NSEEL_addfunc_retptr("gfx_measurestr",3,NSEEL_PProc_THIS,&_gfx_measurestr); - NSEEL_addfunc_retptr("gfx_measurechar",3,NSEEL_PProc_THIS,&_gfx_measurechar); - NSEEL_addfunc_varparm("gfx_printf",1,NSEEL_PProc_THIS,&_gfx_printf); - NSEEL_addfunc_retptr("gfx_setpixel",3,NSEEL_PProc_THIS,&_gfx_setpixel); - NSEEL_addfunc_retptr("gfx_getpixel",3,NSEEL_PProc_THIS,&_gfx_getpixel); - NSEEL_addfunc_retptr("gfx_getimgdim",3,NSEEL_PProc_THIS,&_gfx_getimgdim); - NSEEL_addfunc_retval("gfx_setimgdim",3,NSEEL_PProc_THIS,&_gfx_setimgdim); - NSEEL_addfunc_retval("gfx_loadimg",2,NSEEL_PProc_THIS,&_gfx_loadimg); - NSEEL_addfunc_retptr("gfx_blitext",3,NSEEL_PProc_THIS,&_gfx_blitext); - NSEEL_addfunc_varparm("gfx_blit",1,NSEEL_PProc_THIS,&_gfx_blit2); - NSEEL_addfunc_varparm("gfx_setfont",1,NSEEL_PProc_THIS,&_gfx_setfont); - NSEEL_addfunc_varparm("gfx_getfont",1,NSEEL_PProc_THIS,&_gfx_getfont); - NSEEL_addfunc_varparm("gfx_set",1,NSEEL_PProc_THIS,&_gfx_set); - NSEEL_addfunc_varparm("gfx_getdropfile",1,NSEEL_PProc_THIS,&_gfx_getdropfile); - NSEEL_addfunc_varparm("gfx_getsyscol",0,NSEEL_PProc_THIS,&_gfx_getsyscol); -} -#endif - -#ifdef EEL_LICE_WANT_STANDALONE - -#ifdef _WIN32 -static HINSTANCE eel_lice_hinstance; -#endif -static const char *eel_lice_standalone_classname; - -#ifdef EEL_LICE_WANT_STANDALONE_UPDATE -static EEL_F * NSEEL_CGEN_CALL _gfx_update(void *opaque, EEL_F *n) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) - { - ctx->m_ddrop_files.Empty(true,free); - if (ctx->hwnd_standalone) - { -#ifndef EEL_LICE_WANT_STANDALONE_UPDATE_NO_SETUPFRAME - ctx->finish_draw(); -#endif - - // run message pump -#ifndef EEL_LICE_WANT_STANDALONE_UPDATE_NO_MSGPUMP - -#ifdef _WIN32 - MSG msg; - while (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } -#else - void SWELL_RunEvents(); - SWELL_RunEvents(); -#endif -#endif -#ifndef EEL_LICE_WANT_STANDALONE_UPDATE_NO_SETUPFRAME - RECT r; - GetClientRect(ctx->hwnd_standalone,&r); - ctx->setup_frame(ctx->hwnd_standalone,r); -#endif - } - } - return n; -} -#endif - - - -static EEL_F NSEEL_CGEN_CALL _gfx_getchar(void *opaque, INT_PTR np, EEL_F **plist) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (np > 1) plist[1][0] = 0.0; - if (ctx) - { - EEL_F *p = plist[0]; - ctx->m_has_had_getch=true; - if (*p >= 2.0) - { - if (*p == 65536.0 || *p == 65537.0) - { - int rv = 1; - if (ctx->hwnd_standalone) - { - if (ctx->hwnd_standalone==GetFocus()) rv|=2; - if (IsWindowVisible(ctx->hwnd_standalone)) - { - rv|=4; - if (*p != 65537.0) - { - POINT pt; - GetCursorPos(&pt); - RECT r; - GetWindowRect(ctx->hwnd_standalone,&r); - if (r.top > r.bottom) - { - const int a = r.top; - r.top = r.bottom; - r.bottom = a; - } - if (PtInRect(&r,pt) && WindowFromPoint(pt) == ctx->hwnd_standalone) rv|=8; - } - } - } - return rv; - } - int x; - const int n = sizeof(ctx->hwnd_standalone_kb_state) / sizeof(ctx->hwnd_standalone_kb_state[0]); - int *st = ctx->hwnd_standalone_kb_state; - int a = (int)*p; - for (x=0;xhwnd_standalone) return -1.0; - - if (ctx->m_kb_queue_valid) - { - const int qsize = sizeof(ctx->m_kb_queue)/sizeof(ctx->m_kb_queue[0]); - int a = ctx->m_kb_queue[ctx->m_kb_queue_pos & (qsize-1)]; - ctx->m_kb_queue_pos++; - ctx->m_kb_queue_valid--; - -#ifdef _WIN32 - if (np > 1 && (a>>24) != 'u' && ctx->m_kb_queue_valid > 0) - { - int a2 = ctx->m_kb_queue[ctx->m_kb_queue_pos & (qsize-1)]; - if ((a2>>24)=='u') - { - ctx->m_kb_queue_pos++; - ctx->m_kb_queue_valid--; - plist[1][0] = (a2&0xffffff); - } - return a; - } -#else - if (a > 32 && a < 256 && np > 1) - plist[1][0] = a; -#endif - if ((a>>24) == 'u') - { - if ((a&0xffffff) < 256) - a &= 0xff; - if (np > 1) plist[1][0] = a&0xffffff; - } - - return a; - } - } - return 0.0; -} - -static int eel_lice_key_xlate(int msg, int wParam, int lParam, bool *isAltOut) -{ -#define EEL_MB_C(a) (sizeof(a)<=2 ? a[0] : \ - sizeof(a)==3 ? (((a[0])<<8)+(a[1])) : \ - sizeof(a)==4 ? (((a[0])<<16)+((a[1])<<8)+(a[2])) : \ - (((a[0])<<24)+((a[1])<<16)+((a[2])<<8)+(a[3]))) - - if (msg != WM_CHAR) - { -#ifndef _WIN32 - if (lParam & FVIRTKEY) -#endif - switch (wParam) - { - case VK_HOME: return EEL_MB_C("home"); - case VK_UP: return EEL_MB_C("up"); - case VK_PRIOR: return EEL_MB_C("pgup"); - case VK_LEFT: return EEL_MB_C("left"); - case VK_RIGHT: return EEL_MB_C("rght"); - case VK_END: return EEL_MB_C("end"); - case VK_DOWN: return EEL_MB_C("down"); - case VK_NEXT: return EEL_MB_C("pgdn"); - case VK_INSERT: return EEL_MB_C("ins"); - case VK_DELETE: return EEL_MB_C("del"); - case VK_F1: return EEL_MB_C("f1"); - case VK_F2: return EEL_MB_C("f2"); - case VK_F3: return EEL_MB_C("f3"); - case VK_F4: return EEL_MB_C("f4"); - case VK_F5: return EEL_MB_C("f5"); - case VK_F6: return EEL_MB_C("f6"); - case VK_F7: return EEL_MB_C("f7"); - case VK_F8: return EEL_MB_C("f8"); - case VK_F9: return EEL_MB_C("f9"); - case VK_F10: return EEL_MB_C("f10"); - case VK_F11: return EEL_MB_C("f11"); - case VK_F12: return EEL_MB_C("f12"); -#ifndef _WIN32 - case VK_SUBTRACT: return '-'; // numpad - - case VK_ADD: return '+'; - case VK_MULTIPLY: return '*'; - case VK_DIVIDE: return '/'; - case VK_DECIMAL: return '.'; - case VK_NUMPAD0: return '0'; - case VK_NUMPAD1: return '1'; - case VK_NUMPAD2: return '2'; - case VK_NUMPAD3: return '3'; - case VK_NUMPAD4: return '4'; - case VK_NUMPAD5: return '5'; - case VK_NUMPAD6: return '6'; - case VK_NUMPAD7: return '7'; - case VK_NUMPAD8: return '8'; - case VK_NUMPAD9: return '9'; - case (32768|VK_RETURN): return VK_RETURN; -#endif - } - - switch (wParam) - { - case VK_RETURN: - case VK_BACK: - case VK_TAB: - case VK_ESCAPE: - return wParam; - - case VK_CONTROL: break; - - default: - { - const bool isctrl = !!(GetAsyncKeyState(VK_CONTROL)&0x8000); - const bool isalt = !!(GetAsyncKeyState(VK_MENU)&0x8000); - -#ifdef __APPLE__ - // SWELL_MacKeyToWindowsKeyEx maps control(FLWIN)+A-Z to 1-26 - if (wParam > 0 && wParam <= 26 && !(lParam&FVIRTKEY)) - { - *isAltOut=isalt; - return wParam; - } -#endif - - if(isctrl || isalt) - { - - if (wParam>='a' && wParam<='z') - { - if (isctrl) wParam += 1-'a'; - if (isalt) wParam += 256; - *isAltOut=isalt; - return wParam; - } - if (wParam>='A' && wParam<='Z') - { - if (isctrl) wParam += 1-'A'; - if (isalt) wParam += 256; - *isAltOut=isalt; - return wParam; - } - } - } - break; - } - } - - if(wParam>=32) - { - #ifdef _WIN32 - if (msg == WM_CHAR) - { - return (wParam&0xffffff) | ('u'<<24); // windows encodes all wm_chars as 'u'<<24 - } - #else - if (!(GetAsyncKeyState(VK_SHIFT)&0x8000)) - { - if (wParam>='A' && wParam<='Z') - { - if ((GetAsyncKeyState(VK_LWIN)&0x8000)) wParam -= 'A'-1; - else - wParam += 'a'-'A'; - } - } - if (wParam >= 0x100) - return (wParam&0xffffff) | ('u'<<24); - return wParam; - #endif - } - return 0; -} -#undef EEL_MB_C - -static LRESULT WINAPI eel_lice_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -#ifdef __APPLE__ -extern "C" -{ - void *objc_getClass(const char *p); -#ifndef _OBJC_OBJC_H_ - void *sel_getUid(const char *p); -#endif - void objc_msgSend(void); -}; -#endif - - -HWND eel_lice_state::create_wnd(HWND par, int isChild) -{ - if (hwnd_standalone) return hwnd_standalone; -#ifdef _WIN32 - return CreateWindowEx(WS_EX_ACCEPTFILES,eel_lice_standalone_classname,"", - isChild ? (WS_CHILD|WS_TABSTOP) : (WS_POPUP|WS_CAPTION|WS_THICKFRAME|WS_SYSMENU),CW_USEDEFAULT,CW_USEDEFAULT,100,100,par,NULL,eel_lice_hinstance,this); -#else - HWND h = SWELL_CreateDialog(NULL,isChild ? NULL : ((const char *)(INT_PTR)0x400001),par,(DLGPROC)eel_lice_wndproc,(LPARAM)this); - if (h) - { - SWELL_SetClassName(h,eel_lice_standalone_classname); - SWELL_EnableMetal(h,1); - } - return h; -#endif -} - -#ifdef EEL_LICE_WANTDOCK -#ifndef ID_DOCKWINDOW -#define ID_DOCKWINDOW 40269 -#endif - -static EEL_F NSEEL_CGEN_CALL _gfx_dock(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) - { - if (np > 0 && parms[0][0] >= 0.0 && ctx->hwnd_standalone) EEL_LICE_WANTDOCK(ctx,(int)parms[0][0]); - - if (np > 1 && parms[1]) parms[1][0] = ctx->m_last_undocked_r.left; - if (np > 2 && parms[2]) parms[2][0] = ctx->m_last_undocked_r.top; - if (np > 3 && parms[3]) parms[3][0] = ctx->m_last_undocked_r.right; - if (np > 4 && parms[4]) parms[4][0] = ctx->m_last_undocked_r.bottom; - -#ifdef EEL_LICE_ISDOCKED - return EEL_LICE_ISDOCKED(ctx); -#endif - } - return 0.0; -} - -#endif //EEL_LICE_WANTDOCK - - -#ifndef EEL_LICE_STANDALONE_NOINITQUIT - -static EEL_F * NSEEL_CGEN_CALL _gfx_quit(void *opaque, EEL_F *n) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx) - { - if (ctx->hwnd_standalone) - { - DestroyWindow(ctx->hwnd_standalone); - } - ctx->hwnd_standalone=0; - } - return n; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_init(void *opaque, INT_PTR np, EEL_F **parms) -{ -#ifdef EEL_LICE_GET_CONTEXT_INIT - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT_INIT(opaque); -#else - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); -#endif - if (ctx) - { - bool wantShow=false, wantResize=true; - int sug_w = np > 1 ? (int)parms[1][0] : 640; - int sug_h = np > 2 ? (int)parms[2][0] : 480; - if (sug_w <1 && sug_h < 1 && ctx->hwnd_standalone) - { - RECT r; - GetClientRect(ctx->hwnd_standalone,&r); - sug_w = r.right; - sug_h = r.bottom; - } - #ifdef EEL_LICE_WANTDOCK - const int pos_offs = 4; - #else - const int pos_offs = 3; - #endif - - if (sug_w < 16) sug_w=16; - else if (sug_w > 8192) sug_w=8192; - if (sug_h < 16) sug_h=16; - else if (sug_h > 8192) sug_h=8192; - - if (!ctx->hwnd_standalone) - { - #ifdef __APPLE__ - void *(*send_msg)(void *, void *) = (void *(*)(void *, void *))objc_msgSend; - void (*send_msg_longparm)(void *, void *, long) = (void (*)(void *, void *, long))objc_msgSend; // long = NSInteger - - void *nsapp=send_msg( objc_getClass("NSApplication"), sel_getUid("sharedApplication")); - send_msg_longparm(nsapp,sel_getUid("setActivationPolicy:"), 0); - send_msg_longparm(nsapp,sel_getUid("activateIgnoringOtherApps:"), 1); - - #endif - - #ifdef EEL_LICE_STANDALONE_PARENT - HWND par = EEL_LICE_STANDALONE_PARENT(opaque); - #elif defined(_WIN32) - HWND par=GetDesktopWindow(); - #else - HWND par=NULL; - #endif - - ctx->create_wnd(par,0); - // resize client - - if (ctx->hwnd_standalone) - { - int px=0,py=0; - if (np >= pos_offs+2) - { - px = (int) floor(parms[pos_offs][0] + 0.5); - py = (int) floor(parms[pos_offs+1][0] + 0.5); -#ifdef EEL_LICE_VALIDATE_RECT_ON_SCREEN - RECT r = {px,py,px+sug_w,py+sug_h}; - EEL_LICE_VALIDATE_RECT_ON_SCREEN(r); - px=r.left; py=r.top; sug_w = r.right-r.left; sug_h = r.bottom-r.top; -#endif - ctx->m_last_undocked_r.left = px; - ctx->m_last_undocked_r.top = py; - ctx->m_last_undocked_r.right = sug_w; - ctx->m_last_undocked_r.bottom = sug_h; - } - - RECT r1,r2; - GetWindowRect(ctx->hwnd_standalone,&r1); - GetClientRect(ctx->hwnd_standalone,&r2); - sug_w += (r1.right-r1.left) - r2.right; - sug_h += abs(r1.bottom-r1.top) - r2.bottom; - - SetWindowPos(ctx->hwnd_standalone,NULL,px,py,sug_w,sug_h,(np >= pos_offs+2 ? 0:SWP_NOMOVE)|SWP_NOZORDER|SWP_NOACTIVATE); - - wantShow=true; - #ifdef EEL_LICE_WANTDOCK - if (np > 3) EEL_LICE_WANTDOCK(ctx,parms[3][0]); - #endif - #ifdef EEL_LICE_WANT_STANDALONE_UPDATE - { - RECT r; - GetClientRect(ctx->hwnd_standalone,&r); - ctx->setup_frame(ctx->hwnd_standalone,r); - } - #endif - } - wantResize=false; - } - if (!ctx->hwnd_standalone) return 0; - - if (np>0) - { - EEL_STRING_MUTEXLOCK_SCOPE - const char *title=EEL_STRING_GET_FOR_INDEX(parms[0][0],NULL); - #ifdef EEL_STRING_DEBUGOUT - if (!title) EEL_STRING_DEBUGOUT("gfx_init: invalid string identifier %f",parms[0][0]); - #endif - if (title&&*title) - { - SetWindowText(ctx->hwnd_standalone,title); - wantResize=false; // ignore resize if we're setting title - } - } - if (wantShow) - ShowWindow(ctx->hwnd_standalone,SW_SHOW); - if (wantResize && np>2 && !(GetWindowLong(ctx->hwnd_standalone,GWL_STYLE)&WS_CHILD)) - { - RECT r1,r2; - GetWindowRect(ctx->hwnd_standalone,&r1); - GetClientRect(ctx->hwnd_standalone,&r2); - const bool do_size = sug_w != r2.right || sug_h != r2.bottom; - - sug_w += (r1.right-r1.left) - r2.right; - sug_h += abs(r1.bottom-r1.top) - r2.bottom; - - int px=0,py=0; - const bool do_move=(np >= pos_offs+2); - if (do_move) - { - px = (int) floor(parms[pos_offs][0] + 0.5); - py = (int) floor(parms[pos_offs+1][0] + 0.5); -#ifdef EEL_LICE_VALIDATE_RECT_ON_SCREEN - RECT r = {px,py,px+sug_w,py+sug_h}; - EEL_LICE_VALIDATE_RECT_ON_SCREEN(r); - px=r.left; py=r.top; sug_w = r.right-r.left; sug_h = r.bottom-r.top; -#endif - } - if (do_size || do_move) - SetWindowPos(ctx->hwnd_standalone,NULL,px,py,sug_w,sug_h, - (do_size ? 0 : SWP_NOSIZE)|(do_move? 0:SWP_NOMOVE)|SWP_NOZORDER|SWP_NOACTIVATE); - } - return 1; - } - return 0; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_screentoclient(void *opaque, EEL_F *x, EEL_F *y) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx && ctx->hwnd_standalone) - { - POINT pt={(int) *x, (int) *y}; - ScreenToClient(ctx->hwnd_standalone,&pt); - *x = pt.x; - *y = pt.y; - return 1.0; - } - return 0.0; -} - -static EEL_F NSEEL_CGEN_CALL _gfx_clienttoscreen(void *opaque, EEL_F *x, EEL_F *y) -{ - eel_lice_state *ctx=EEL_LICE_GET_CONTEXT(opaque); - if (ctx && ctx->hwnd_standalone) - { - POINT pt={(int) *x, (int) *y}; - ClientToScreen(ctx->hwnd_standalone,&pt); - *x = pt.x; - *y = pt.y; - return 1.0; - } - return 0.0; -} - -#endif // !EEL_LICE_STANDALONE_NOINITQUIT - - -#ifndef WM_MOUSEWHEEL -#define WM_MOUSEWHEEL 0x20A -#endif -#ifndef WM_MOUSEHWHEEL -#define WM_MOUSEHWHEEL 0x20E -#endif - -LRESULT WINAPI eel_lice_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ -#ifdef WIN32 - static UINT Scroll_Message; - static bool sm_init; - if (!sm_init) - { - sm_init=true; - Scroll_Message = RegisterWindowMessage("MSWHEEL_ROLLMSG"); - } - if (Scroll_Message && uMsg == Scroll_Message) - { - uMsg=WM_MOUSEWHEEL; - wParam<<=16; - } -#endif - - switch (uMsg) - { - case WM_CREATE: - { -#ifdef _WIN32 - LPCREATESTRUCT lpcs= (LPCREATESTRUCT )lParam; - eel_lice_state *ctx=(eel_lice_state*)lpcs->lpCreateParams; - SetWindowLongPtr(hwnd,GWLP_USERDATA,(LPARAM)lpcs->lpCreateParams); -#else - eel_lice_state *ctx=(eel_lice_state*)lParam; - SetWindowLongPtr(hwnd,GWLP_USERDATA,lParam); - SetWindowLong(hwnd,GWL_EXSTYLE, GetWindowLong(hwnd,GWL_EXSTYLE) | WS_EX_ACCEPTFILES); -#endif - ctx->m_kb_queue_valid=0; - ctx->hwnd_standalone=hwnd; - } - return 0; -#ifndef _WIN32 - case WM_CLOSE: - DestroyWindow(hwnd); - return 0; -#endif - case WM_DESTROY: - { - eel_lice_state *ctx=(eel_lice_state*)GetWindowLongPtr(hwnd,GWLP_USERDATA); - if (ctx) - { -#ifdef EEL_LICE_WANTDOCK - EEL_LICE_WANTDOCK(ctx,0); -#endif - ctx->hwnd_standalone=NULL; - } - } - return 0; - case WM_ACTIVATE: - { - eel_lice_state *ctx=(eel_lice_state*)GetWindowLongPtr(hwnd,GWLP_USERDATA); - if (ctx) memset(&ctx->hwnd_standalone_kb_state,0,sizeof(ctx->hwnd_standalone_kb_state)); - } - break; - case WM_SETCURSOR: - { - eel_lice_state *ctx=(eel_lice_state*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (ctx && ctx->m_cursor) - { - POINT p; - GetCursorPos(&p); - ScreenToClient(hwnd, &p); - RECT r; - GetClientRect(hwnd, &r); - if (PtInRect(&r,p)) - { - SetCursor(ctx->m_cursor); - return TRUE; - } - } - } - break; -#ifdef EEL_LICE_WANTDOCK - case WM_CONTEXTMENU: - { - eel_lice_state *ctx=(eel_lice_state*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (ctx) - { - char title[512], buf[1024]; - GetWindowText(hwnd, title, sizeof(title)-1); - if (!title[0]) strcpy(title, "ReaScript"); - - HMENU hm=CreatePopupMenu(); - int pos=0; - - int flag=((EEL_LICE_ISDOCKED(ctx)&1) ? MF_CHECKED : 0); - snprintf(buf, sizeof(buf), "Dock %s window in Docker", title); - InsertMenu(hm, pos++, MF_BYPOSITION|MF_STRING|flag, ID_DOCKWINDOW, buf); - snprintf(buf, sizeof(buf), "Close %s window", title); - InsertMenu(hm, pos++, MF_BYPOSITION|MF_STRING, IDCANCEL, buf); - - POINT pt; - GetCursorPos(&pt); - TrackPopupMenu(hm, 0, pt.x, pt.y, 0, hwnd, NULL); - DestroyMenu(hm); - } - } - return 0; -#endif - case WM_COMMAND: - switch (LOWORD(wParam)) - { -#ifdef EEL_LICE_WANTDOCK - case ID_DOCKWINDOW: - { - eel_lice_state *ctx=(eel_lice_state*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (ctx) EEL_LICE_WANTDOCK(ctx, EEL_LICE_ISDOCKED(ctx)^1); - } - return 0; -#endif - case IDCANCEL: - DestroyWindow(hwnd); - return 0; - } - break; - case WM_USER+1001: - if (wParam == 0xdddd && lParam) - { - eel_lice_state *ctx=(eel_lice_state*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (ctx) - { - ctx->m_ddrop_files.Empty(true,free); - const char *r = (const char *)lParam; - while (*r) - { - ctx->m_ddrop_files.Add(strdup(r)); - r += strlen(r)+1; - } - } - } - return 0; - case WM_DROPFILES: - { - eel_lice_state *ctx=(eel_lice_state*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (ctx && wParam) - { - ctx->m_ddrop_files.Empty(true,free); - - HDROP hDrop = (HDROP) wParam; - const int n=DragQueryFile(hDrop,-1,NULL,0); - for (int x=0;xm_ddrop_files.Add(strdup(buf)); - } - DragFinish(hDrop); - } - } - return 0; - case WM_MOUSEHWHEEL: - case WM_MOUSEWHEEL: - { - eel_lice_state *ctx=(eel_lice_state*)GetWindowLongPtr(hwnd,GWLP_USERDATA); - if (ctx) - { - EEL_F *p= uMsg==WM_MOUSEHWHEEL ? ctx->m_mouse_hwheel : ctx->m_mouse_wheel; - if (p) *p += (EEL_F) (short)HIWORD(wParam); - } - } - return -1; -#ifdef _WIN32 - case WM_SYSKEYDOWN: - case WM_SYSKEYUP: -#endif - case WM_KEYDOWN: - case WM_KEYUP: - case WM_CHAR: - { - eel_lice_state *ctx=(eel_lice_state*)GetWindowLongPtr(hwnd,GWLP_USERDATA); -#ifdef __APPLE__ - { - int f=0; - wParam = SWELL_MacKeyToWindowsKeyEx(NULL,&f,1); - lParam=f; - } -#endif - - bool hadAltAdj=false; - int a=eel_lice_key_xlate(uMsg,(int)wParam,(int)lParam, &hadAltAdj); - if (a == -1) return 0; -#ifdef _WIN32 - if (!a && (uMsg == WM_KEYUP || uMsg == WM_SYSKEYUP)) - { - // will not end up in queue, just for state tracking - if (wParam >= 'A' && wParam <= 'Z') a=(int)wParam + 'a' - 'A'; - else a = (int)MapVirtualKey((UINT)wParam,2/*MAPVK_VK_TO_CHAR*/); - } -#endif - const int mask = hadAltAdj ? ~256 : ~0; - - if (a & mask) - { - int a_no_alt = (a&mask); - const int lowera = a_no_alt >= 1 && a_no_alt < 27 ? (a_no_alt+'a'-1) : a_no_alt >= 'A' && a_no_alt <= 'Z' ? a_no_alt+'a'-'A' : a_no_alt; - - int *st = ctx->hwnd_standalone_kb_state; - - const int n = sizeof(ctx->hwnd_standalone_kb_state) / sizeof(ctx->hwnd_standalone_kb_state[0]); - int zp=n-1,x; - - for (x=0;xm_kb_queue)/sizeof(ctx->m_kb_queue[0]); - if (ctx->m_kb_queue_valid>=qsize) // queue full, dump an old event! - { - ctx->m_kb_queue_valid--; - ctx->m_kb_queue_pos++; - } - ctx->m_kb_queue[(ctx->m_kb_queue_pos + ctx->m_kb_queue_valid++) & (qsize-1)] = a; - if (ctx->m_last_menu_cnt && (GetTickCount()-ctx->m_last_menu_time)>250) ctx->m_last_menu_cnt = 0; - } - - } - return 0; - case WM_LBUTTONDBLCLK: - case WM_RBUTTONDBLCLK: - case WM_MBUTTONDBLCLK: - case WM_RBUTTONDOWN: - case WM_MBUTTONDOWN: - case WM_LBUTTONDOWN: - { - POINT p = { (short)LOWORD(lParam), (short)HIWORD(lParam) }; - RECT r; - GetClientRect(hwnd, &r); - if (p.x >= r.left && p.x < r.right && p.y >= r.top && p.y < r.bottom) - { - if (GetCapture()!=hwnd) SetFocus(hwnd); - eel_lice_state *ctx=(eel_lice_state*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (ctx) - { - if (GetCapture()!=hwnd) SetCapture(hwnd); - int f = 0; - if (uMsg == WM_LBUTTONDBLCLK || uMsg == WM_LBUTTONDOWN) f=0x10001; - else if (uMsg == WM_RBUTTONDBLCLK || uMsg == WM_RBUTTONDOWN) f=0x20002; - else if (uMsg == WM_MBUTTONDBLCLK || uMsg == WM_MBUTTONDOWN) f=0x40040; - - if (GetAsyncKeyState(VK_CONTROL)&0x8000) f|=4; - if (GetAsyncKeyState(VK_SHIFT)&0x8000) f|=8; - if (GetAsyncKeyState(VK_MENU)&0x8000) f|=16; - if (GetAsyncKeyState(VK_LWIN)&0x8000) f|=32; - - ctx->m_has_cap|=f; - if (ctx->m_last_menu_cnt && (GetTickCount()-ctx->m_last_menu_time)>250) ctx->m_last_menu_cnt = 0; - } - } - } - return 1; - case WM_LBUTTONUP: - case WM_RBUTTONUP: - case WM_MBUTTONUP: - case WM_CAPTURECHANGED: - { - eel_lice_state *ctx=(eel_lice_state*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - if (ctx) - { - if (uMsg == WM_CAPTURECHANGED) - { - ctx->m_has_cap &= 0xffff; - } - else - { - if (ctx->m_last_menu_cnt && (GetTickCount()-ctx->m_last_menu_time)>250) ctx->m_last_menu_cnt = 0; - if (uMsg == WM_LBUTTONUP) ctx->m_has_cap &= ~0x10000; - else if (uMsg == WM_RBUTTONUP) ctx->m_has_cap &= ~0x20000; - else if (uMsg == WM_MBUTTONUP) ctx->m_has_cap &= ~0x40000; - - if (!(ctx->m_has_cap & 0xf0000)) - { - ReleaseCapture(); - } - } - } - } - return 1; -#ifdef _WIN32 - case WM_GETDLGCODE: - if (GetWindowLong(hwnd,GWL_STYLE)&WS_CHILD) return DLGC_WANTALLKEYS; - break; - case 0x02E0: //WM_DPICHANGED - if (!(GetWindowLong(hwnd,GWL_STYLE)&WS_CHILD)) - { - RECT *prcNewWindow = (RECT*)lParam; - SetWindowPos(hwnd, - NULL, - prcNewWindow ->left, - prcNewWindow ->top, - prcNewWindow->right - prcNewWindow->left, - prcNewWindow->bottom - prcNewWindow->top, - SWP_NOZORDER | SWP_NOACTIVATE); - } - break; -#endif - case WM_SIZE: - // fall through -#ifndef EEL_LICE_STANDALONE_NOINITQUIT - case WM_MOVE: - if (uMsg != WM_SIZE || wParam != SIZE_MINIMIZED) - { - eel_lice_state *ctx=(eel_lice_state*)GetWindowLongPtr(hwnd,GWLP_USERDATA); - if (ctx -#ifdef EEL_LICE_ISDOCKED - && !(GetWindowLong(hwnd,GWL_STYLE)&WS_CHILD) -#endif - ) - { - RECT r; - GetWindowRect(hwnd,&ctx->m_last_undocked_r); - GetClientRect(hwnd,&r); - if (ctx->m_last_undocked_r.bottom < ctx->m_last_undocked_r.top) ctx->m_last_undocked_r.top = ctx->m_last_undocked_r.bottom; - ctx->m_last_undocked_r.right = r.right; - ctx->m_last_undocked_r.bottom = r.bottom; - } - - } -#endif - - break; - - case WM_PAINT: - { - PAINTSTRUCT ps; - if (BeginPaint(hwnd,&ps)) - { - eel_lice_state *ctx=(eel_lice_state*)GetWindowLongPtr(hwnd,GWLP_USERDATA); - if (ctx && ctx->m_framebuffer && - LICE_FUNCTION_VALID(LICE__GetDC) && LICE_FUNCTION_VALID(LICE__GetWidth) && LICE_FUNCTION_VALID(LICE__GetHeight)) - { - int w = LICE__GetWidth(ctx->m_framebuffer); - int h = LICE__GetHeight(ctx->m_framebuffer); -#ifdef __APPLE__ - if (*ctx->m_gfx_ext_retina > 1.0) - { - StretchBlt(ps.hdc,0,0,w/2,h/2,LICE__GetDC(ctx->m_framebuffer),0,0,w,h,SRCCOPY); - } - else -#endif - BitBlt(ps.hdc,0,0,w,h,LICE__GetDC(ctx->m_framebuffer),0,0,SRCCOPY); - } - EndPaint(hwnd,&ps); - } - } - return 0; - case WM_GETMINMAXINFO: - { - LPMINMAXINFO p=(LPMINMAXINFO)lParam; - if (p->ptMinTrackSize.x > 10) p->ptMinTrackSize.x = 10; - if (p->ptMinTrackSize.y > 10) p->ptMinTrackSize.y = 10; - } - return 0; - } - -#ifdef _WIN32 - return DefWindowProcW(hwnd,uMsg,wParam,lParam); -#else - return DefWindowProc(hwnd,uMsg,wParam,lParam); -#endif -} - - - -void eel_lice_register_standalone(HINSTANCE hInstance, const char *classname, HWND hwndPar, HICON icon) -{ - eel_lice_standalone_classname=classname && *classname ? classname : "EEL_LICE_gfx_standalone"; -#ifdef _WIN32 - static bool reg; - if (!reg) - { - eel_lice_hinstance=hInstance; - WCHAR tmp[256]; - int x = 0; - while (eel_lice_standalone_classname[x]) - { - if (WDL_NOT_NORMALLY(x == 255)) break; - tmp[x] = eel_lice_standalone_classname[x]; - x++; - } - tmp[x]=0; - - WNDCLASSW wc={CS_DBLCLKS,eel_lice_wndproc,0,0,hInstance,icon,LoadCursor(NULL,IDC_ARROW), NULL, NULL,tmp}; - RegisterClassW(&wc); - reg = true; - } -#endif - -#ifndef EEL_LICE_NO_REGISTER - // gfx_init(title[, w,h, flags]) -#ifndef EEL_LICE_STANDALONE_NOINITQUIT - NSEEL_addfunc_varparm("gfx_init",1,NSEEL_PProc_THIS,&_gfx_init); - NSEEL_addfunc_retptr("gfx_quit",1,NSEEL_PProc_THIS,&_gfx_quit); - - NSEEL_addfunc_retval("gfx_screentoclient",2,NSEEL_PProc_THIS,&_gfx_screentoclient); - NSEEL_addfunc_retval("gfx_clienttoscreen",2,NSEEL_PProc_THIS,&_gfx_clienttoscreen); - -#endif -#ifdef EEL_LICE_WANTDOCK - NSEEL_addfunc_varparm("gfx_dock",1,NSEEL_PProc_THIS,&_gfx_dock); -#endif - -#ifdef EEL_LICE_WANT_STANDALONE_UPDATE - NSEEL_addfunc_retptr("gfx_update",1,NSEEL_PProc_THIS,&_gfx_update); -#endif - - NSEEL_addfunc_varparm("gfx_getchar",1,NSEEL_PProc_THIS,&_gfx_getchar); -#endif -} - - -#endif - -#endif//!EEL_LICE_API_ONLY - - - - -#ifdef DYNAMIC_LICE -static WDL_STATICFUNC_UNUSED void eel_lice_initfuncs(void *(*getFunc)(const char *name)) -{ - if (!getFunc) return; - - *(void **)&__LICE_CreateBitmap = getFunc("LICE_CreateBitmap"); - *(void **)&LICE_Clear = getFunc("LICE_Clear"); - *(void **)&LICE_Line = getFunc("LICE_LineInt"); - *(void **)&LICE_ClipLine = getFunc("LICE_ClipLine"); - *(void **)&LICE_FillRect = getFunc("LICE_FillRect"); - *(void **)&LICE_DrawRect = getFunc("LICE_DrawRect"); - *(void **)&LICE_PutPixel = getFunc("LICE_PutPixel"); - *(void **)&LICE_GetPixel = getFunc("LICE_GetPixel"); - *(void **)&LICE_DrawText = getFunc("LICE_DrawText"); - *(void **)&LICE_DrawChar = getFunc("LICE_DrawChar"); - *(void **)&LICE_MeasureText = getFunc("LICE_MeasureText"); - *(void **)&LICE_LoadImage = getFunc("LICE_LoadImage"); - *(void **)&LICE__GetDC = getFunc("LICE__GetDC"); - *(void **)&LICE__Destroy = getFunc("LICE__Destroy"); - *(void **)&LICE__GetWidth = getFunc("LICE__GetWidth"); - *(void **)&LICE__GetHeight = getFunc("LICE__GetHeight"); - *(void **)&LICE__resize = getFunc("LICE__resize"); - *(void **)&LICE_Blur = getFunc("LICE_Blur"); - *(void **)&LICE_RotatedBlit = getFunc("LICE_RotatedBlit"); - *(void **)&LICE_ScaledBlit = getFunc("LICE_ScaledBlit"); - *(void **)&LICE_Circle = getFunc("LICE_Circle"); - *(void **)&LICE_FillCircle = getFunc("LICE_FillCircle"); - *(void **)&LICE_FillTriangle=getFunc("LICE_FillTriangle"); - *(void **)&LICE_FillConvexPolygon=getFunc("LICE_FillConvexPolygon"); - *(void **)&LICE_RoundRect = getFunc("LICE_RoundRect"); - *(void **)&LICE_Arc = getFunc("LICE_Arc"); - - *(void **)&LICE_MultiplyAddRect = getFunc("LICE_MultiplyAddRect"); - *(void **)&LICE_GradRect = getFunc("LICE_GradRect"); - *(void **)&LICE_TransformBlit2 = getFunc("LICE_TransformBlit2"); - *(void **)&LICE_DeltaBlit = getFunc("LICE_DeltaBlit"); - - *(void **)&LICE__DestroyFont = getFunc("LICE__DestroyFont"); - *(void **)&LICE_CreateFont = getFunc("LICE_CreateFont"); - *(void **)&LICE__SetFromHFont = getFunc("LICE__SetFromHFont2"); - - *(void **)&LICE__SetTextColor = getFunc("LICE__SetTextColor"); - *(void **)&LICE__SetTextCombineMode = getFunc("LICE__SetTextCombineMode"); - *(void **)&LICE__DrawText = getFunc("LICE__DrawText"); -} -#endif - -#ifdef EEL_WANT_DOCUMENTATION - -#ifdef EELSCRIPT_LICE_MAX_IMAGES -#define MKSTR2(x) #x -#define MKSTR(x) MKSTR2(x) -#define EEL_LICE_DOC_MAXHANDLE MKSTR(EELSCRIPT_LICE_MAX_IMAGES-1) -#else -#define EEL_LICE_DOC_MAXHANDLE "127" -#endif - - -static const char *eel_lice_function_reference = -#ifdef EEL_LICE_WANT_STANDALONE -#ifndef EEL_LICE_STANDALONE_NOINITQUIT -#ifdef EEL_LICE_WANTDOCK - "gfx_init\t\"name\"[,width,height,dockstate,xpos,ypos]\tInitializes the graphics window with title name. Suggested width and height can be specified. If window is already open, a non-empty name will re-title window, or an empty title will resize window. \n\n" -#else - "gfx_init\t\"name\"[,width,height,xpos,ypos]\tInitializes the graphics window with title name. Suggested width and height can be specified. If window is already open, a non-empty name will re-title window, or an empty title will resize window.\n\n" -#endif - "Once the graphics window is open, gfx_update() should be called periodically. \0" - "gfx_quit\t\tCloses the graphics window.\0" -#endif -#ifdef EEL_LICE_WANT_STANDALONE_UPDATE - "gfx_update\t\tUpdates the graphics display, if opened\0" -#endif -#endif -#ifdef EEL_LICE_WANTDOCK - "gfx_dock\tv[,wx,wy,ww,wh]\tCall with v=-1 to query docked state, otherwise v>=0 to set docked state. State is &1 if docked, second byte is docker index (or last docker index if undocked). If wx-wh are specified, they will be filled with the undocked window position/size\0" -#endif - "gfx_aaaaa\t\t" - "The following global variables are special and will be used by the graphics system:\n\n\3" - // we depend on the formatting here -- following gfx_aaaaa, search for \4[gfx_*|mouse_*]- for syntax highlight etc - "\4gfx_r - current red component (0..1) used by drawing operations.\n" - "\4gfx_g - current green component (0..1) used by drawing operations.\n" - "\4gfx_b - current blue component (0..1) used by drawing operations.\n" - "\4gfx_a2 - current alpha component (0..1) used by drawing operations when writing solid colors (normally ignored but useful when creating transparent images).\n" - "\4gfx_a - alpha for drawing (1=normal).\n" - "\4gfx_mode - blend mode for drawing. Set mode to 0 for default options. Add 1.0 for additive blend mode (if you wish to do subtractive, set gfx_a to negative and use gfx_mode as additive). Add 2.0 to disable source alpha for gfx_blit(). Add 4.0 to disable filtering for gfx_blit(). \n" - "\4gfx_w - width of the UI framebuffer. \n" - "\4gfx_h - height of the UI framebuffer. \n" - "\4gfx_x - current graphics position X. Some drawing functions use as start position and update. \n" - "\4gfx_y - current graphics position Y. Some drawing functions use as start position and update. \n" - "\4gfx_clear - if greater than -1.0, framebuffer will be cleared to that color. the color for this one is packed RGB (0..255), i.e. red+green*256+blue*65536. The default is 0 (black). \n" - "\4gfx_dest - destination for drawing operations, -1 is main framebuffer, set to 0.." EEL_LICE_DOC_MAXHANDLE " to have drawing operations go to an offscreen buffer (or loaded image).\n" - "\4gfx_texth - the (READ-ONLY) height of a line of text in the current font. Do not modify this variable.\n" - "\4gfx_ext_retina - to support hidpi/retina, callers should set to 1.0 on initialization, this value will be updated to value greater than 1.0 (such as 2.0) if retina/hidpi. On macOS gfx_w/gfx_h/etc will be doubled, but on other systems gfx_w/gfx_h will remain the same and gfx_ext_retina is a scaling hint for drawing.\n" - "\4mouse_x - current X coordinate of the mouse relative to the graphics window.\n" - "\4mouse_y - current Y coordinate of the mouse relative to the graphics window.\n" - "\4mouse_wheel - wheel position, will change typically by 120 or a multiple thereof, the caller should clear the state to 0 after reading it.\n" - "\4mouse_hwheel - horizontal wheel positions, will change typically by 120 or a multiple thereof, the caller should clear the state to 0 after reading it.\n" - "\4mouse_cap - a bitfield of mouse and keyboard modifier state. Note that a script must call gfx_getchar() at least once in order to get modifier state when the mouse is not captured by the window. Bitfield bits:\3" - "\4" "1: left mouse button\n" - "\4" "2: right mouse button\n" -#ifdef __APPLE__ - "\4" "4: Command key\n" - "\4" "8: Shift key\n" - "\4" "16: Option key\n" - "\4" "32: Control key\n" -#else - "\4" "4: Control key\n" - "\4" "8: Shift key\n" - "\4" "16: Alt key\n" - "\4" "32: Windows key\n" -#endif - "\4" "64: middle mouse button\n" - "\2" - "\2\0" - -"gfx_getchar\t[char, unichar]\tIf char is 0 or omitted, returns a character from the keyboard queue, or 0 if no character is available, or -1 if the graphics window is not open. " - "If char is specified and nonzero, that character's status will be checked, and the function will return greater than 0 if it is pressed. Note that calling gfx_getchar() at least once causes mouse_cap to reflect keyboard modifiers even when the mouse is not captured.\n\n" - "Common values are standard ASCII, such as 'a', 'A', '=' and '1', but for many keys multi-byte values are used, including 'home', 'up', 'down', 'left', 'rght', 'f1'.. 'f12', 'pgup', 'pgdn', 'ins', and 'del'. \n\n" - "Modified and special keys can also be returned, including:\3\n" - "\4Ctrl/Cmd+A..Ctrl+Z as 1..26\n" - "\4Ctrl/Cmd+Alt+A..Z as 257..282\n" - "\4Alt+A..Z as 'A'+256..'Z'+256\n" - "\4" "27 for ESC\n" - "\4" "13 for Enter\n" - "\4' ' for space\n" - "\4" "65536 for query of special flags, returns: &1 (supported), &2=window has focus, &4=window is visible, &8=mouse click would hit window. 65537 queries special flags but does not do the mouse click hit testing (faster).\n" - "\4If unichar is specified, it will be set to the unicode value of the key if available (and the return value may be the unicode value or a raw key value as described above, depending). If unichar is not specified, unicode codepoints greater than 255 will be returned as 'u'<<24 + value\n" - "\2\0" - - "gfx_showmenu\t\"str\"\tShows a popup menu at gfx_x,gfx_y. str is a list of fields separated by | characters. " - "Each field represents a menu item.\nFields can start with special characters:\n\n" - "# : grayed out\n" - "! : checked\n" - "> : this menu item shows a submenu\n" - "< : last item in the current submenu\n\n" - "An empty field will appear as a separator in the menu. " - "gfx_showmenu returns 0 if the user selected nothing from the menu, 1 if the first field is selected, etc.\nExample:\n\n" - "gfx_showmenu(\"first item, followed by separator||!second item, checked|>third item which spawns a submenu|#first item in submenu, grayed out| -#endif -#include -#include -#include - -#define EEL_DCT_MINBITLEN 5 -#define EEL_DCT_MAXBITLEN 12 - - -#define PI 3.1415926535897932384626433832795 - -typedef struct { - int n; - int log2n; - EEL_F *trig; - int *bitrev; - EEL_F scale; - EEL_F *window; -} mdct_lookup; - -static void mdct(EEL_F *in, EEL_F *out, int len) -{ - int k; - EEL_F pioverlen = PI * 0.5 / (EEL_F)len; - for (k = 0; k < len / 2; k ++) - { - int i; - EEL_F d = 0.0; - for (i = 0; i < len; i ++) - { - d += in[i] * cos(pioverlen * (2.0 * i + 1.0 + len * 0.5) * (2.0 * k + 1.0)); - } - out[k] = (EEL_F)d; - } -} - -static void imdct(EEL_F *in, EEL_F *out, int len) -{ - int k; - EEL_F fourovern = 4.0 / (EEL_F)len; - EEL_F pioverlen = PI * 0.5 / (EEL_F)len; - for (k = 0; k < len; k ++) - { - int i; - EEL_F d = 0.0; - for (i = 0; i < len / 2; i ++) - { - d += in[i] * cos(pioverlen * (2.0 * k + 1.0 + len * 0.5) * (2 * i + 1.0)); - } - out[k] = (EEL_F)(d * fourovern); - } -} - - -// MDCT/iMDCT borrowed from Vorbis, thanks xiph! - - -#define cPI3_8 .38268343236508977175 -#define cPI2_8 .70710678118654752441 -#define cPI1_8 .92387953251128675613 - -#define FLOAT_CONV(x) ((EEL_F) ( x )) -#define MULT_NORM(x) (x) -#define HALVE(x) ((x)*.5f) - - - -/* 8 point butterfly (in place, 4 register) */ -static void mdct_butterfly_8(EEL_F *x) { - EEL_F r0 = x[6] + x[2]; - EEL_F r1 = x[6] - x[2]; - EEL_F r2 = x[4] + x[0]; - EEL_F r3 = x[4] - x[0]; - - x[6] = r0 + r2; - x[4] = r0 - r2; - - r0 = x[5] - x[1]; - r2 = x[7] - x[3]; - x[0] = r1 + r0; - x[2] = r1 - r0; - - r0 = x[5] + x[1]; - r1 = x[7] + x[3]; - x[3] = r2 + r3; - x[1] = r2 - r3; - x[7] = r1 + r0; - x[5] = r1 - r0; - -} - -/* 16 point butterfly (in place, 4 register) */ -static void mdct_butterfly_16(EEL_F *x) { - EEL_F r0 = x[1] - x[9]; - EEL_F r1 = x[0] - x[8]; - - x[8] += x[0]; - x[9] += x[1]; - x[0] = MULT_NORM((r0 + r1) * cPI2_8); - x[1] = MULT_NORM((r0 - r1) * cPI2_8); - - r0 = x[3] - x[11]; - r1 = x[10] - x[2]; - x[10] += x[2]; - x[11] += x[3]; - x[2] = r0; - x[3] = r1; - - r0 = x[12] - x[4]; - r1 = x[13] - x[5]; - x[12] += x[4]; - x[13] += x[5]; - x[4] = MULT_NORM((r0 - r1) * cPI2_8); - x[5] = MULT_NORM((r0 + r1) * cPI2_8); - - r0 = x[14] - x[6]; - r1 = x[15] - x[7]; - x[14] += x[6]; - x[15] += x[7]; - x[6] = r0; - x[7] = r1; - - mdct_butterfly_8(x); - mdct_butterfly_8(x + 8); -} - -/* 32 point butterfly (in place, 4 register) */ -static void mdct_butterfly_32(EEL_F *x) { - EEL_F r0 = x[30] - x[14]; - EEL_F r1 = x[31] - x[15]; - - x[30] += x[14]; - x[31] += x[15]; - x[14] = r0; - x[15] = r1; - - r0 = x[28] - x[12]; - r1 = x[29] - x[13]; - x[28] += x[12]; - x[29] += x[13]; - x[12] = MULT_NORM( r0 * cPI1_8 - r1 * cPI3_8 ); - x[13] = MULT_NORM( r0 * cPI3_8 + r1 * cPI1_8 ); - - r0 = x[26] - x[10]; - r1 = x[27] - x[11]; - x[26] += x[10]; - x[27] += x[11]; - x[10] = MULT_NORM(( r0 - r1 ) * cPI2_8); - x[11] = MULT_NORM(( r0 + r1 ) * cPI2_8); - - r0 = x[24] - x[8]; - r1 = x[25] - x[9]; - x[24] += x[8]; - x[25] += x[9]; - x[8] = MULT_NORM( r0 * cPI3_8 - r1 * cPI1_8 ); - x[9] = MULT_NORM( r1 * cPI3_8 + r0 * cPI1_8 ); - - r0 = x[22] - x[6]; - r1 = x[7] - x[23]; - x[22] += x[6]; - x[23] += x[7]; - x[6] = r1; - x[7] = r0; - - r0 = x[4] - x[20]; - r1 = x[5] - x[21]; - x[20] += x[4]; - x[21] += x[5]; - x[4] = MULT_NORM( r1 * cPI1_8 + r0 * cPI3_8 ); - x[5] = MULT_NORM( r1 * cPI3_8 - r0 * cPI1_8 ); - - r0 = x[2] - x[18]; - r1 = x[3] - x[19]; - x[18] += x[2]; - x[19] += x[3]; - x[2] = MULT_NORM(( r1 + r0 ) * cPI2_8); - x[3] = MULT_NORM(( r1 - r0 ) * cPI2_8); - - r0 = x[0] - x[16]; - r1 = x[1] - x[17]; - x[16] += x[0]; - x[17] += x[1]; - x[0] = MULT_NORM( r1 * cPI3_8 + r0 * cPI1_8 ); - x[1] = MULT_NORM( r1 * cPI1_8 - r0 * cPI3_8 ); - - mdct_butterfly_16(x); - mdct_butterfly_16(x + 16); - -} - -/* N point first stage butterfly (in place, 2 register) */ -static void mdct_butterfly_first(EEL_F *T, - EEL_F *x, - int points) { - - EEL_F *x1 = x + points - 8; - EEL_F *x2 = x + (points >> 1) - 8; - EEL_F r0; - EEL_F r1; - - do { - - r0 = x1[6] - x2[6]; - r1 = x1[7] - x2[7]; - x1[6] += x2[6]; - x1[7] += x2[7]; - x2[6] = MULT_NORM(r1 * T[1] + r0 * T[0]); - x2[7] = MULT_NORM(r1 * T[0] - r0 * T[1]); - - r0 = x1[4] - x2[4]; - r1 = x1[5] - x2[5]; - x1[4] += x2[4]; - x1[5] += x2[5]; - x2[4] = MULT_NORM(r1 * T[5] + r0 * T[4]); - x2[5] = MULT_NORM(r1 * T[4] - r0 * T[5]); - - r0 = x1[2] - x2[2]; - r1 = x1[3] - x2[3]; - x1[2] += x2[2]; - x1[3] += x2[3]; - x2[2] = MULT_NORM(r1 * T[9] + r0 * T[8]); - x2[3] = MULT_NORM(r1 * T[8] - r0 * T[9]); - - r0 = x1[0] - x2[0]; - r1 = x1[1] - x2[1]; - x1[0] += x2[0]; - x1[1] += x2[1]; - x2[0] = MULT_NORM(r1 * T[13] + r0 * T[12]); - x2[1] = MULT_NORM(r1 * T[12] - r0 * T[13]); - - x1 -= 8; - x2 -= 8; - T += 16; - - } while(x2 >= x); -} - -/* N/stage point generic N stage butterfly (in place, 2 register) */ -static void mdct_butterfly_generic(EEL_F *T, - EEL_F *x, - int points, - int trigint) { - - EEL_F *x1 = x + points - 8; - EEL_F *x2 = x + (points >> 1) - 8; - EEL_F r0; - EEL_F r1; - - do { - - r0 = x1[6] - x2[6]; - r1 = x1[7] - x2[7]; - x1[6] += x2[6]; - x1[7] += x2[7]; - x2[6] = MULT_NORM(r1 * T[1] + r0 * T[0]); - x2[7] = MULT_NORM(r1 * T[0] - r0 * T[1]); - - T += trigint; - - r0 = x1[4] - x2[4]; - r1 = x1[5] - x2[5]; - x1[4] += x2[4]; - x1[5] += x2[5]; - x2[4] = MULT_NORM(r1 * T[1] + r0 * T[0]); - x2[5] = MULT_NORM(r1 * T[0] - r0 * T[1]); - - T += trigint; - - r0 = x1[2] - x2[2]; - r1 = x1[3] - x2[3]; - x1[2] += x2[2]; - x1[3] += x2[3]; - x2[2] = MULT_NORM(r1 * T[1] + r0 * T[0]); - x2[3] = MULT_NORM(r1 * T[0] - r0 * T[1]); - - T += trigint; - - r0 = x1[0] - x2[0]; - r1 = x1[1] - x2[1]; - x1[0] += x2[0]; - x1[1] += x2[1]; - x2[0] = MULT_NORM(r1 * T[1] + r0 * T[0]); - x2[1] = MULT_NORM(r1 * T[0] - r0 * T[1]); - - T += trigint; - x1 -= 8; - x2 -= 8; - - } while(x2 >= x); -} - -static void mdct_butterflies(mdct_lookup *init, - EEL_F *x, - int points) { - - EEL_F *T = init->trig; - int stages = init->log2n - 5; - int i, j; - - if(--stages > 0) { - mdct_butterfly_first(T, x, points); - } - - for(i = 1; --stages > 0; i++) { - for(j = 0; j < (1 << i); j++) - mdct_butterfly_generic(T, x + (points >> i)*j, points >> i, 4 << i); - } - - for(j = 0; j < points; j += 32) - mdct_butterfly_32(x + j); - -} - -static void mdct_bitreverse(mdct_lookup *init, - EEL_F *x) { - int n = init->n; - int *bit = init->bitrev; - EEL_F *w0 = x; - EEL_F *w1 = x = w0 + (n >> 1); - EEL_F *T = init->trig + n; - - do { - EEL_F *x0 = x + bit[0]; - EEL_F *x1 = x + bit[1]; - - EEL_F r0 = x0[1] - x1[1]; - EEL_F r1 = x0[0] + x1[0]; - EEL_F r2 = MULT_NORM(r1 * T[0] + r0 * T[1]); - EEL_F r3 = MULT_NORM(r1 * T[1] - r0 * T[0]); - - w1 -= 4; - - r0 = HALVE(x0[1] + x1[1]); - r1 = HALVE(x0[0] - x1[0]); - - w0[0] = r0 + r2; - w1[2] = r0 - r2; - w0[1] = r1 + r3; - w1[3] = r3 - r1; - - x0 = x + bit[2]; - x1 = x + bit[3]; - - r0 = x0[1] - x1[1]; - r1 = x0[0] + x1[0]; - r2 = MULT_NORM(r1 * T[2] + r0 * T[3]); - r3 = MULT_NORM(r1 * T[3] - r0 * T[2]); - - r0 = HALVE(x0[1] + x1[1]); - r1 = HALVE(x0[0] - x1[0]); - - w0[2] = r0 + r2; - w1[0] = r0 - r2; - w0[3] = r1 + r3; - w1[1] = r3 - r1; - - T += 4; - bit += 4; - w0 += 4; - - } while(w0 < w1); -} - -static void megabuf_mdct_apply_window(void *init, EEL_F *inbuf, EEL_F *outbuf) -{ - mdct_lookup *p = (mdct_lookup *)init; - EEL_F *w; - int cnt; - if (!p) return; - - w = p->window; - if (!w) return; - - cnt = p->n / 2; - while (cnt--) *outbuf++ = *inbuf++ * *w++; - cnt = p->n / 2; - while (cnt--) *outbuf++ = *inbuf++ * *--w; -} - - - -static void *megabuf_mdct_init(int n) { - mdct_lookup *lookup = (mdct_lookup *)calloc(sizeof(mdct_lookup), 1); - int i; - EEL_F c = (PI / (EEL_F) n); - int *bitrev; - EEL_F *T; - int n2, log2n; - if (!lookup) return 0; - - lookup->n = n; - lookup->window = (EEL_F *)calloc(sizeof(EEL_F), n / 2); - if (!lookup->window) return lookup; - - for (i = 0; i < n / 2; i ++) - { - lookup->window[i] = sin(c * (i + 0.5)); - } - - if (n <= 32) return lookup; - bitrev = (int*)calloc(sizeof(int), (n / 4)); - lookup->bitrev = bitrev; - if (!bitrev) return lookup; - - T = (EEL_F*)calloc(sizeof(EEL_F), (n + n / 4)); - lookup->trig = T; - if (!T) return lookup; - - n2 = n >> 1; - log2n = lookup->log2n = (int)(log((double)n) / log(2.0) + 0.5); - - /* trig lookups... */ - - for(i = 0; i < n / 4; i++) { - T[i * 2] = FLOAT_CONV(cos((PI / n) * (4 * i))); - T[i * 2 + 1] = FLOAT_CONV(-sin((PI / n) * (4 * i))); - T[n2 + i * 2] = FLOAT_CONV(cos((PI / (2 * n)) * (2 * i + 1))); - T[n2 + i * 2 + 1] = FLOAT_CONV(sin((PI / (2 * n)) * (2 * i + 1))); - } - for(i = 0; i < n / 8; i++) { - T[n + i * 2] = FLOAT_CONV(cos((PI / n) * (4 * i + 2)) * .5); - T[n + i * 2 + 1] = FLOAT_CONV(-sin((PI / n) * (4 * i + 2)) * .5); - } - - /* bitreverse lookup... */ - - { - int mask = (1 << (log2n - 1)) - 1, j; - int msb = 1 << (log2n - 2); - for(i = 0; i < n / 8; i++) { - int acc = 0; - for(j = 0; msb >> j; j++) - if((msb >> j)&i)acc |= 1 << j; - bitrev[i * 2] = ((~acc)&mask) - 1; - bitrev[i * 2 + 1] = acc; - - } - } - lookup->scale = FLOAT_CONV(4.f / n); - return lookup; -} - -static void megabuf_mdct_backward(void *init, EEL_F *in, EEL_F *out) { - mdct_lookup *lookup = (mdct_lookup *)init; - int n, n2, n4; - EEL_F *iX, *oX, *T; - if (!lookup) return; - n = lookup->n; - if (n <= 32 || !lookup->bitrev || !lookup->trig) - { - imdct(in, out, n); - return; - } - n2 = n >> 1; - n4 = n >> 2; - - /* rotate */ - - iX = in + n2 - 7; - oX = out + n2 + n4; - T = lookup->trig + n4; - - do { - oX -= 4; - oX[0] = MULT_NORM(-iX[2] * T[3] - iX[0] * T[2]); - oX[1] = MULT_NORM (iX[0] * T[3] - iX[2] * T[2]); - oX[2] = MULT_NORM(-iX[6] * T[1] - iX[4] * T[0]); - oX[3] = MULT_NORM (iX[4] * T[1] - iX[6] * T[0]); - iX -= 8; - T += 4; - } while(iX >= in); - - iX = in + n2 - 8; - oX = out + n2 + n4; - T = lookup->trig + n4; - - do { - T -= 4; - oX[0] = MULT_NORM (iX[4] * T[3] + iX[6] * T[2]); - oX[1] = MULT_NORM (iX[4] * T[2] - iX[6] * T[3]); - oX[2] = MULT_NORM (iX[0] * T[1] + iX[2] * T[0]); - oX[3] = MULT_NORM (iX[0] * T[0] - iX[2] * T[1]); - iX -= 8; - oX += 4; - } while(iX >= in); - - mdct_butterflies(lookup, out + n2, n2); - mdct_bitreverse(lookup, out); - - /* roatate + window */ - - { - EEL_F *oX1 = out + n2 + n4; - EEL_F *oX2 = out + n2 + n4; - iX = out; - T = lookup->trig + n2; - - do { - oX1 -= 4; - - oX1[3] = MULT_NORM (iX[0] * T[1] - iX[1] * T[0]); - oX2[0] = -MULT_NORM (iX[0] * T[0] + iX[1] * T[1]); - - oX1[2] = MULT_NORM (iX[2] * T[3] - iX[3] * T[2]); - oX2[1] = -MULT_NORM (iX[2] * T[2] + iX[3] * T[3]); - - oX1[1] = MULT_NORM (iX[4] * T[5] - iX[5] * T[4]); - oX2[2] = -MULT_NORM (iX[4] * T[4] + iX[5] * T[5]); - - oX1[0] = MULT_NORM (iX[6] * T[7] - iX[7] * T[6]); - oX2[3] = -MULT_NORM (iX[6] * T[6] + iX[7] * T[7]); - - oX2 += 4; - iX += 8; - T += 8; - } while(iX < oX1); - - iX = out + n2 + n4; - oX1 = out + n4; - oX2 = oX1; - - do { - oX1 -= 4; - iX -= 4; - - oX2[0] = -(oX1[3] = iX[3]); - oX2[1] = -(oX1[2] = iX[2]); - oX2[2] = -(oX1[1] = iX[1]); - oX2[3] = -(oX1[0] = iX[0]); - - oX2 += 4; - } while(oX2 < iX); - - iX = out + n2 + n4; - oX1 = out + n2 + n4; - oX2 = out + n2; - do { - oX1 -= 4; - oX1[0] = iX[3]; - oX1[1] = iX[2]; - oX1[2] = iX[1]; - oX1[3] = iX[0]; - iX += 4; - } while(oX1 > oX2); - } -} - - -static void megabuf_mdct_forward(void *init, EEL_F *in, EEL_F *out) { - mdct_lookup *lookup = (mdct_lookup *)init; - int n, n2, n4, n8; - EEL_F *w, *w2; - if (!lookup) return; - - n = lookup->n; - if (n <= 32 || !lookup->bitrev || !lookup->trig) - { - mdct(in, out, n); - return; - } - n2 = n >> 1; - n4 = n >> 2; - n8 = n >> 3; - EEL_F oldw[1<trig + n2; - - int i = 0; - - for(i = 0; i < n8; i += 2) { - x0 -= 4; - T -= 2; - r0 = x0[2] + x1[0]; - r1 = x0[0] + x1[2]; - w2[i] = MULT_NORM(r1 * T[1] + r0 * T[0]); - w2[i + 1] = MULT_NORM(r1 * T[0] - r0 * T[1]); - x1 += 4; - } - - x1 = in + 1; - - for(; i < n2 - n8; i += 2) { - T -= 2; - x0 -= 4; - r0 = x0[2] - x1[0]; - r1 = x0[0] - x1[2]; - w2[i] = MULT_NORM(r1 * T[1] + r0 * T[0]); - w2[i + 1] = MULT_NORM(r1 * T[0] - r0 * T[1]); - x1 += 4; - } - - x0 = in + n; - - for(; i < n2; i += 2) { - T -= 2; - x0 -= 4; - r0 = -x0[2] - x1[0]; - r1 = -x0[0] - x1[2]; - w2[i] = MULT_NORM(r1 * T[1] + r0 * T[0]); - w2[i + 1] = MULT_NORM(r1 * T[0] - r0 * T[1]); - x1 += 4; - } - - - mdct_butterflies(lookup, w + n2, n2); - mdct_bitreverse(lookup, w); - - /* roatate + window */ - - T = lookup->trig + n2; - x0 = out + n2; - - for(i = 0; i < n4; i++) { - x0--; - out[i] = MULT_NORM((w[0] * T[0] + w[1] * T[1]) * lookup->scale); - x0[0] = MULT_NORM((w[0] * T[1] - w[1] * T[0]) * lookup->scale); - w += 2; - T += 2; - } - } -} - -#if 0 - -static void dct(EEL_F *in, EEL_F *out, int len) -{ - int k; - EEL_F wk = sqrt(2.0 / len); - EEL_F overtwolen = 0.5 / (EEL_F)len; - for (k = 0; k < len; k ++) - { - int n; - EEL_F d = 0.0; - for (n = 0; n < len; n ++) - { - int an = n + 1; - d += in[n] * cos(PI * (2.0 * n + 1.0) * (EEL_F)k * overtwolen); - } - if (!k) d /= sqrt(len); - else d *= wk; - out[k] = (EEL_F)d; - } -} - - -static void idct(EEL_F *in, EEL_F *out, int len) -{ - int n; - EEL_F dd0 = 1.0 / sqrt(len); - EEL_F dd1 = sqrt(2.0 / len); - EEL_F overtwolen = 0.5 / len; - for (n = 0; n < len; n ++) - { - int k; - EEL_F d = 0.0; - for (k = 0; k < len; k ++) - { - EEL_F dd; - if (!k) dd = dd0 * in[k]; - else dd = dd1 * in[k]; - d += dd * cos(PI * (2.0 * n + 1.0) * k * overtwolen); - } - out[n] = (EEL_F)d; - } -} -#endif - - -// 0 is megabuf blocks -// 1 is need_free flag - - -static EEL_F * NSEEL_CGEN_CALL mdct_func(int dir, EEL_F **blocks, EEL_F *start, EEL_F *length) -{ - int l = (int)(*length + 0.0001); - int offs = (int)(*start + 0.0001); - int bitl = 0; - int ilen; - int bidx; - EEL_F *ptr; - while (l > 1 && bitl < EEL_DCT_MAXBITLEN) - { - bitl++; - l >>= 1; - } - if (bitl < EEL_DCT_MINBITLEN) - { - return start; - } - ilen = 1 << bitl; - - bidx = bitl - EEL_DCT_MINBITLEN; - - - // check to make sure we don't cross a boundary - if (offs / NSEEL_RAM_ITEMSPERBLOCK != (offs + ilen * 2 - 1) / NSEEL_RAM_ITEMSPERBLOCK) - { - return start; - } - - ptr = __NSEEL_RAMAlloc(blocks, offs); - if (!ptr || ptr == &nseel_ramalloc_onfail) - { - return start; - } - - if (ilen > 1) - { - static void *mdct_ctxs[1 + EEL_DCT_MAXBITLEN - EEL_DCT_MINBITLEN]; - - if (!mdct_ctxs[bidx]) - { - NSEEL_HOSTSTUB_EnterMutex(); - if (!mdct_ctxs[bidx]) - mdct_ctxs[bidx] = megabuf_mdct_init(ilen); - NSEEL_HOSTSTUB_LeaveMutex(); - } - - if (mdct_ctxs[bidx]) - { - EEL_F buf[1 << EEL_DCT_MAXBITLEN]; - if (dir < 0) - { - megabuf_mdct_backward(mdct_ctxs[bidx], ptr, buf); - megabuf_mdct_apply_window(mdct_ctxs[bidx], buf, ptr); - } - else - { - megabuf_mdct_apply_window(mdct_ctxs[bidx], ptr, buf); - megabuf_mdct_forward(mdct_ctxs[bidx], buf, ptr); - } - } - } - return start; -} - - - -static EEL_F * NSEEL_CGEN_CALL megabuf_mdct(EEL_F **blocks, EEL_F *start, EEL_F *length) -{ - return mdct_func(0, blocks, start, length); -} - -static EEL_F * NSEEL_CGEN_CALL megabuf_imdct(EEL_F **blocks, EEL_F *start, EEL_F *length) -{ - return mdct_func(-1, blocks, start, length); -} - -void EEL_mdct_register() -{ - NSEEL_addfunc_retptr("mdct", 2, NSEEL_PProc_RAM, &megabuf_mdct); - NSEEL_addfunc_retptr("imdct", 2, NSEEL_PProc_RAM, &megabuf_imdct); -} - -#ifdef EEL_WANT_DOCUMENTATION -static const char *eel_mdct_function_reference = -"mdct\tbuffer,length\tPerforms a windowed modified DCT, taking length inputs and producing length/2 outputs. buffer must not cross a 65,536 item boundary, and length must be 64, 128, 256, 512, 2048 or 4096.\0" -"imdct\tbuffer,length\tPerforms a windowed inverse modified DCT, taking length/2 inputs and producing length outputs. buffer must not cross a 65,536 item boundary, and length must be 64, 128, 256, 512, 2048 or 4096.\0" -; -#endif - - -#endif diff --git a/oversampling/WDL/eel2/eel_misc.h b/oversampling/WDL/eel2/eel_misc.h deleted file mode 100644 index a819a8f..0000000 --- a/oversampling/WDL/eel2/eel_misc.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef _EEL_MISC_H_ -#define _EEL_MISC_H_ - - -#ifndef _WIN32 -#include -#endif -#include -// some generic EEL functions for things like time - -#ifndef EEL_MISC_NO_SLEEP -static EEL_F NSEEL_CGEN_CALL _eel_sleep(void *opaque, EEL_F *amt) -{ - if (*amt >= 0.0) - { - #ifdef _WIN32 - if (*amt > 30000000.0) Sleep(30000000); - else Sleep((DWORD)(*amt+0.5)); - #else - if (*amt > 30000000.0) usleep(((useconds_t)30000000)*1000); - else usleep((useconds_t)(*amt*1000.0+0.5)); - #endif - } - return 0.0; -} -#endif - -static EEL_F * NSEEL_CGEN_CALL _eel_time(void *opaque, EEL_F *v) -{ - *v = (EEL_F) time(NULL); - return v; -} - -static EEL_F * NSEEL_CGEN_CALL _eel_time_precise(void *opaque, EEL_F *v) -{ -#ifdef _WIN32 - LARGE_INTEGER freq,now; - QueryPerformanceFrequency(&freq); - QueryPerformanceCounter(&now); - *v = (double)now.QuadPart / (double)freq.QuadPart; - // *v = (EEL_F)timeGetTime() * 0.001; -#else - struct timeval tm={0,}; - gettimeofday(&tm,NULL); - *v = tm.tv_sec + tm.tv_usec*0.000001; -#endif - return v; -} - - -void EEL_misc_register() -{ -#ifndef EEL_MISC_NO_SLEEP - NSEEL_addfunc_retval("sleep",1,NSEEL_PProc_THIS,&_eel_sleep); -#endif - NSEEL_addfunc_retptr("time",1,NSEEL_PProc_THIS,&_eel_time); - NSEEL_addfunc_retptr("time_precise",1,NSEEL_PProc_THIS,&_eel_time_precise); -} - -#ifdef EEL_WANT_DOCUMENTATION -static const char *eel_misc_function_reference = -#ifndef EEL_MISC_NO_SLEEP - "sleep\tms\tYields the CPU for the millisecond count specified, calling Sleep() on Windows or usleep() on other platforms.\0" -#endif - "time\t[&val]\tSets the parameter (or a temporary buffer if omitted) to the number of seconds since January 1, 1970, and returns a reference to that value. " - "The granularity of the value returned is 1 second.\0" - "time_precise\t[&val]\tSets the parameter (or a temporary buffer if omitted) to a system-local timestamp in seconds, and returns a reference to that value. " - "The granularity of the value returned is system defined (but generally significantly smaller than one second).\0" -; -#endif - - -#endif diff --git a/oversampling/WDL/eel2/eel_net.h b/oversampling/WDL/eel2/eel_net.h deleted file mode 100644 index a796223..0000000 --- a/oversampling/WDL/eel2/eel_net.h +++ /dev/null @@ -1,564 +0,0 @@ -#ifndef _EEL_NET_H_ -#define _EEL_NET_H_ - -// x = tcp_listen(port[,interface, connected_ip_out]) poll this, returns connection id > 0, or <0 on error, or 0 if no new connect -- interface only valid on first call (or after tcp_listen_end(port)) -// tcp_listen_end(port); - -// connection = tcp_connect(host, port[, block]) // connection id > 0 on ok -// tcp_set_block(connection, block?) -// tcp_close(connection) - -// tcp_send(connection, string[, length]) // can return 0 if block, -1 if error, otherwise returns length sent -// tcp_recv(connection, string[, maxlength]) // 0 on nothing, -1 on error, otherwise returns length recv'd - - -// need: -// #define EEL_NET_GET_CONTEXT(opaque) (((sInst *)opaque)->m_net_state) - -// you must pass a JNL_AsyncDNS object to eel_net_state to support nonblocking connect with DNS resolution, otherwise DNS will block -// #define EEL_NET_NO_SYNC_DNS -- never ever call gethostbyname() synchronously, may disable DNS for blocking connect, or if a JNL_IAsyncDNS is not provided. - -#ifndef EEL_NET_MAXSEND -#define EEL_NET_MAXSEND (EEL_STRING_MAXUSERSTRING_LENGTH_HINT+4096) -#endif - - -#include "../jnetlib/netinc.h" -#define JNL_NO_IMPLEMENTATION -#include "../jnetlib/asyncdns.h" - -class eel_net_state -{ - public: - enum { STATE_FREE=0, STATE_RESOLVING, STATE_CONNECTED, STATE_ERR }; - enum { CONNECTION_ID_BASE=0x110000 }; - - eel_net_state(int max_con, JNL_IAsyncDNS *dns); - ~eel_net_state(); - - struct connection_state { - char *hostname; // set during resolve only - SOCKET sock; - int state; // STATE_RESOLVING... - int port; - bool blockmode; - }; - WDL_TypedBuf m_cons; - WDL_IntKeyedArray m_listens; - JNL_IAsyncDNS *m_dns; - - EEL_F onConnect(char *hostNameOwned, int port, int block); - EEL_F onClose(void *opaque, EEL_F handle); - EEL_F set_block(void *opaque, EEL_F handle, bool block); - EEL_F onListen(void *opaque, EEL_F handle, int mode, EEL_F *ifStr, EEL_F *ipOut); - - int __run_connect(connection_state *cs, unsigned int ip); - int __run(connection_state *cs); - int do_send(void *opaque, EEL_F h, const char *src, int len); - int do_recv(void *opaque, EEL_F h, char *buf, int maxlen); - #ifdef _WIN32 - bool m_had_socketlib_init; - #endif -}; - -eel_net_state::eel_net_state(int max_con, JNL_IAsyncDNS *dns) -{ - #ifdef _WIN32 - m_had_socketlib_init=false; - #endif - - m_cons.Resize(max_con); - int x; - for (x=0;xstate == STATE_FREE) - { - unsigned int ip=inet_addr(hostNameOwned); - if (m_dns && ip == INADDR_NONE && !block) - { - const int r=m_dns->resolve(hostNameOwned,&ip); - if (r<0) break; // error! - - if (r>0) ip = INADDR_NONE; - } -#ifndef EEL_NET_NO_SYNC_DNS - else if (ip == INADDR_NONE) - { - struct hostent *he = gethostbyname(hostNameOwned); - if (he) ip = *(int *)he->h_addr; - } -#endif - if (hostNameOwned || ip != INADDR_NONE) - { - if (ip != INADDR_NONE) - { - free(hostNameOwned); - hostNameOwned=NULL; - } - - s->state = STATE_RESOLVING; - s->hostname = hostNameOwned; - s->blockmode = !!block; - s->port = port; - if (hostNameOwned || __run_connect(s,ip)) return x + CONNECTION_ID_BASE; - - s->state=STATE_FREE; - s->hostname=NULL; - } - break; - } - } - free(hostNameOwned); - return -1; -} - -EEL_F eel_net_state::onListen(void *opaque, EEL_F handle, int mode, EEL_F *ifStr, EEL_F *ipOut) -{ - const int port = (int) handle; - if (port < 1 || port > 65535) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("tcp_listen(%d): invalid port specified, will never succeed",port); -#endif - return 0.0; - } -#ifdef _WIN32 - if (!m_had_socketlib_init) - { - m_had_socketlib_init=1; - WSADATA wsaData; - WSAStartup(MAKEWORD(1, 1), &wsaData); - } -#endif - SOCKET *sockptr = m_listens.GetPtr(port); - if (mode<0) - { - if (!sockptr) return -1.0; - - SOCKET ss=*sockptr; - m_listens.Delete(port); - if (ss != INVALID_SOCKET) - { - shutdown(ss, SHUT_RDWR); - closesocket(ss); - } - return 0.0; - } - if (!sockptr) - { - struct sockaddr_in sin; - memset((char *) &sin, 0,sizeof(sin)); - if (ifStr) - { - EEL_STRING_MUTEXLOCK_SCOPE - const char *fn = EEL_STRING_GET_FOR_INDEX(*ifStr,NULL); -#ifdef EEL_STRING_DEBUGOUT - if (!fn) EEL_STRING_DEBUGOUT("tcp_listen(%d): bad string identifier %f for second parameter (interface)",port,*ifStr); -#endif - if (fn && *fn) sin.sin_addr.s_addr=inet_addr(fn); - - } - if (!sin.sin_addr.s_addr || sin.sin_addr.s_addr==INADDR_NONE) sin.sin_addr.s_addr = INADDR_ANY; - sin.sin_family = AF_INET; - sin.sin_port = htons( (short) port ); - SOCKET sock = socket(AF_INET,SOCK_STREAM,0); - if (sock != INVALID_SOCKET) - { - SET_SOCK_DEFAULTS(sock); - SET_SOCK_BLOCK(sock,0); - if (bind(sock,(struct sockaddr *)&sin,sizeof(sin)) || listen(sock,8)==-1) - { - shutdown(sock, SHUT_RDWR); - closesocket(sock); - sock=INVALID_SOCKET; - } - } -#ifdef EEL_STRING_DEBUGOUT - //if (sock == INVALID_SOCKET) EEL_STRING_DEBUGOUT("tcp_listen(%d): failed listening on port",port); - // we report -1 to the caller, no need to error message -#endif - m_listens.Insert(port,sock); - sockptr = m_listens.GetPtr(port); - } - if (!sockptr || *sockptr == INVALID_SOCKET) return -1; - - struct sockaddr_in saddr; - socklen_t length = sizeof(struct sockaddr_in); - SOCKET newsock = accept(*sockptr, (struct sockaddr *) &saddr, &length); - if (newsock == INVALID_SOCKET) - { - return 0; // nothing to report here - } - SET_SOCK_DEFAULTS(newsock); - - int x; - for(x=0;xstate == STATE_FREE) - { - cs->state=STATE_CONNECTED; - free(cs->hostname); - cs->hostname=NULL; - cs->sock = newsock; - cs->blockmode=true; - cs->port=0; - if (ipOut) - { - EEL_STRING_MUTEXLOCK_SCOPE - WDL_FastString *ws=NULL; - EEL_STRING_GET_FOR_WRITE(*ipOut,&ws); - if (ws) - { - const unsigned int a = ntohl(saddr.sin_addr.s_addr); - ws->SetFormatted(128,"%d.%d.%d.%d",(a>>24)&0xff,(a>>16)&0xff,(a>>8)&0xff,a&0xff); - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("tcp_listen(%d): bad string identifier %f for third parameter (IP-out)",port,*ipOut); -#endif - } - } - return x + CONNECTION_ID_BASE; - } - } - shutdown(newsock, SHUT_RDWR); - closesocket(newsock); - return -1; - - -} - -int eel_net_state::__run_connect(connection_state *cs, unsigned int ip) -{ - SOCKET s=socket(AF_INET,SOCK_STREAM,0); - if (s == INVALID_SOCKET) return 0; - SET_SOCK_DEFAULTS(s); - - if (!cs->blockmode) SET_SOCK_BLOCK(s,0); - - struct sockaddr_in sa={0,}; - sa.sin_family=AF_INET; - sa.sin_addr.s_addr = ip; - sa.sin_port = htons(cs->port); - if (!connect(s,(struct sockaddr *)&sa,16) || (!cs->blockmode && JNL_ERRNO == JNL_EINPROGRESS)) - { - cs->state = STATE_CONNECTED; - cs->sock = s; - return 1; - } - shutdown(s, SHUT_RDWR); - closesocket(s); - return 0; -} - -int eel_net_state::__run(connection_state *cs) -{ - if (cs->sock != INVALID_SOCKET) return 0; - - if (!cs->hostname) return -1; - - unsigned int ip=INADDR_NONE; - const int r=m_dns ? m_dns->resolve(cs->hostname,&ip) : -1; - if (r>0) return 0; - - free(cs->hostname); - cs->hostname=NULL; - - if (r<0 || !__run_connect(cs,ip)) - { - cs->state = STATE_ERR; - return -1; - } - - return 0; -} - -int eel_net_state::do_recv(void *opaque, EEL_F h, char *buf, int maxlen) -{ - const int idx=(int)h-CONNECTION_ID_BASE; - if (idx>=0 && idxsock == INVALID_SOCKET && !s->hostname) - EEL_STRING_DEBUGOUT("tcp_recv: connection identifier %f is not open",h); -#endif - if (__run(s) || s->sock == INVALID_SOCKET) return s->state == STATE_ERR ? -1 : 0; - - if (maxlen == 0) return 0; - - const int rv=(int)recv(s->sock,buf,maxlen,0); - if (rv < 0 && !s->blockmode && (JNL_ERRNO == JNL_EWOULDBLOCK || JNL_ERRNO == JNL_ENOTCONN)) return 0; - - if (!rv) return -1; // TCP, 0=connection terminated - - return rv; - } -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("tcp_recv: connection identifier %f is out of range",h); -#endif - return -1; -} - -int eel_net_state::do_send(void *opaque, EEL_F h, const char *src, int len) -{ - const int idx=(int)h-CONNECTION_ID_BASE; - if (idx>=0 && idxsock == INVALID_SOCKET && !s->hostname) - EEL_STRING_DEBUGOUT("tcp_send: connection identifier %f is not open",h); -#endif - if (__run(s) || s->sock == INVALID_SOCKET) return s->state == STATE_ERR ? -1 : 0; - const int rv=(int)send(s->sock,src,len,0); - if (rv < 0 && !s->blockmode && (JNL_ERRNO == JNL_EWOULDBLOCK || JNL_ERRNO == JNL_ENOTCONN)) return 0; - return rv; - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("tcp_send: connection identifier %f out of range",h); -#endif - } - return -1; -} - -EEL_F eel_net_state::set_block(void *opaque, EEL_F handle, bool block) -{ - int idx=(int)handle-CONNECTION_ID_BASE; - if (idx>=0 && idxblockmode != block) - { - s->blockmode=block; - if (s->sock != INVALID_SOCKET) - { - SET_SOCK_BLOCK(s->sock,(block?1:0)); - } - else - { -#ifdef EEL_STRING_DEBUGOUT - if (!s->hostname) EEL_STRING_DEBUGOUT("tcp_set_block: connection identifier %f is not open",handle); -#endif - } - return 1; - } - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("tcp_set_block: connection identifier %f out of range",handle); -#endif - } - return 0; -} - -EEL_F eel_net_state::onClose(void *opaque, EEL_F handle) -{ - int idx=(int)handle-CONNECTION_ID_BASE; - if (idx>=0 && idxhostname; - free(s->hostname); - s->hostname = NULL; - s->state = STATE_ERR; - if (s->sock != INVALID_SOCKET) - { - shutdown(s->sock,SHUT_RDWR); - closesocket(s->sock); - s->sock = INVALID_SOCKET; - return 1.0; - } - else if (!hadhn) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("tcp_close: connection identifier %f is not open",handle); -#endif - } - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("tcp_close: connection identifier %f is out of range",handle); -#endif - } - return 0.0; -} - - -static EEL_F NSEEL_CGEN_CALL _eel_tcp_connect(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_net_state *ctx; - if (np > 1 && NULL != (ctx=EEL_NET_GET_CONTEXT(opaque))) - { - char *dest=NULL; - { - EEL_STRING_MUTEXLOCK_SCOPE - const char *fn = EEL_STRING_GET_FOR_INDEX(parms[0][0],NULL); - if (fn) dest=strdup(fn); - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("tcp_connect(): host string identifier %f invalid",parms[0][0]); -#endif - } - } - if (dest) return ctx->onConnect(dest, (int) (parms[1][0]+0.5), np < 3 || parms[2][0] >= 0.5); - } - return -1.0; -} - -static EEL_F NSEEL_CGEN_CALL _eel_tcp_set_block(void *opaque, EEL_F *handle, EEL_F *bl) -{ - eel_net_state *ctx; - if (NULL != (ctx=EEL_NET_GET_CONTEXT(opaque))) return ctx->set_block(opaque,*handle, *bl >= 0.5); - return 0; -} - -static EEL_F NSEEL_CGEN_CALL _eel_tcp_close(void *opaque, EEL_F *handle) -{ - eel_net_state *ctx; - if (NULL != (ctx=EEL_NET_GET_CONTEXT(opaque))) return ctx->onClose(opaque,*handle); - return 0; -} - -static EEL_F NSEEL_CGEN_CALL _eel_tcp_recv(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_net_state *ctx; - if (np > 1 && NULL != (ctx=EEL_NET_GET_CONTEXT(opaque))) - { - char buf[EEL_STRING_MAXUSERSTRING_LENGTH_HINT]; - int ml = np > 2 ? (int)parms[2][0] : 4096; - if (ml < 0 || ml > EEL_STRING_MAXUSERSTRING_LENGTH_HINT) ml = EEL_STRING_MAXUSERSTRING_LENGTH_HINT; - - ml=ctx->do_recv(opaque,parms[0][0],buf,ml); - - { - EEL_STRING_MUTEXLOCK_SCOPE - WDL_FastString *ws=NULL; - EEL_STRING_GET_FOR_WRITE(parms[1][0],&ws); - if (ws) - { - if (ml<=0) ws->Set(""); - else ws->SetRaw(buf,ml); - } - } - return ml; - } - return -1; -} - -static EEL_F NSEEL_CGEN_CALL _eel_tcp_send(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_net_state *ctx; - if (np > 1 && NULL != (ctx=EEL_NET_GET_CONTEXT(opaque))) - { - char buf[EEL_NET_MAXSEND]; - - int l; - { - EEL_STRING_MUTEXLOCK_SCOPE - WDL_FastString *ws=NULL; - const char *fn = EEL_STRING_GET_FOR_INDEX(parms[1][0],&ws); - l = ws ? ws->GetLength() : (int) strlen(fn); - if (np > 2) - { - int al=(int)parms[2][0]; - if (al<0) al=0; - if (al 0) memcpy(buf,fn,l); - } - if (l>0) return ctx->do_send(opaque,parms[0][0],buf,l); - return 0; - } - return -1; -} - -static EEL_F NSEEL_CGEN_CALL _eel_tcp_listen(void *opaque, INT_PTR np, EEL_F **parms) -{ - eel_net_state *ctx; - if (NULL != (ctx=EEL_NET_GET_CONTEXT(opaque))) return ctx->onListen(opaque,parms[0][0],1,np>1?parms[1]:NULL,np>2?parms[2]:NULL); - return 0; -} - -static EEL_F NSEEL_CGEN_CALL _eel_tcp_listen_end(void *opaque, EEL_F *handle) -{ - eel_net_state *ctx; - if (NULL != (ctx=EEL_NET_GET_CONTEXT(opaque))) return ctx->onListen(opaque,*handle,-1,NULL,NULL); - return 0; -} - - -void EEL_tcp_register() -{ - NSEEL_addfunc_varparm("tcp_listen",1,NSEEL_PProc_THIS,&_eel_tcp_listen); - NSEEL_addfunc_retval("tcp_listen_end",1,NSEEL_PProc_THIS,&_eel_tcp_listen_end); - - NSEEL_addfunc_varparm("tcp_connect",2,NSEEL_PProc_THIS,&_eel_tcp_connect); - NSEEL_addfunc_varparm("tcp_send",2,NSEEL_PProc_THIS,&_eel_tcp_send); - NSEEL_addfunc_varparm("tcp_recv",2,NSEEL_PProc_THIS,&_eel_tcp_recv); - - NSEEL_addfunc_retval("tcp_set_block",2,NSEEL_PProc_THIS,&_eel_tcp_set_block); - NSEEL_addfunc_retval("tcp_close",1,NSEEL_PProc_THIS,&_eel_tcp_close); -} - -#ifdef EEL_WANT_DOCUMENTATION -const char *eel_net_function_reference = - "tcp_listen\tport[,\"interface\",#ip_out]\tListens on port specified. Returns less than 0 if could not listen, 0 if no new connection available, or greater than 0 (as a TCP connection ID) if a new connection was made. If a connection made and #ip_out specified, it will be set to the remote IP. interface can be empty for all interfaces, otherwise an interface IP as a string.\0" - "tcp_listen_end\tport\tEnds listening on port specified.\0" - "tcp_connect\t\"address\",port[,block]\tCreate a new TCP connection to address:port. If block is specified and 0, connection will be made nonblocking. Returns TCP connection ID greater than 0 on success.\0" - "tcp_send\tconnection,\"str\"[,len]\tSends a string to connection. Returns -1 on error, 0 if connection is non-blocking and would block, otherwise returns length sent. If len is specified and not less than 1, only the first len bytes of the string parameter will be sent.\0" - "tcp_recv\tconnection,#str[,maxlen]\tReceives data from a connection to #str. If maxlen is specified, no more than maxlen bytes will be received. If non-blocking, 0 will be returned if would block. Returns less than 0 if error.\0" - "tcp_set_block\tconnection,block\tSets whether a connection blocks.\0" - "tcp_close\tconnection\tCloses a TCP connection created by tcp_listen() or tcp_connect().\0" -; -#endif - -#endif diff --git a/oversampling/WDL/eel2/eel_pp.cpp b/oversampling/WDL/eel2/eel_pp.cpp deleted file mode 100644 index dbca994..0000000 --- a/oversampling/WDL/eel2/eel_pp.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include -#include -#include -#include - -#include "../wdlstring.h" -#include "../ptrlist.h" -#include "eel_pproc.h" - -void NSEEL_HOSTSTUB_EnterMutex() { } -void NSEEL_HOSTSTUB_LeaveMutex() { } - -int main(int argc, char **argv) -{ - if (argc != 2) - { - fprintf(stderr,"Usage: %s [scriptfile | -]\n",argv[0]); - return 1; - } - FILE *fp = strcmp(argv[1],"-") ? fopen(argv[1],"rb") : stdin; - if (!fp) - { - fprintf(stderr,"Error: could not open %s\n",argv[1]); - return 1; - } - WDL_FastString file_str, pp_str; - for (;;) - { - char buf[4096]; - if (!fgets(buf,sizeof(buf),fp)) break; - file_str.Append(buf); - } - if (fp != stdin) fclose(fp); - - EEL2_PreProcessor pproc; - const char *err = pproc.preprocess(file_str.Get(),&pp_str); - if (err) - { - fprintf(stderr,"Error: %s\n",err); - return 1; - } - - printf("%s",pp_str.Get()); - - return 0; -} diff --git a/oversampling/WDL/eel2/eel_pproc.h b/oversampling/WDL/eel2/eel_pproc.h deleted file mode 100644 index 3f469b5..0000000 --- a/oversampling/WDL/eel2/eel_pproc.h +++ /dev/null @@ -1,469 +0,0 @@ -#ifndef _EEL2_PREPROC_H_ -#define _EEL2_PREPROC_H_ -#include "ns-eel-int.h" -#include "../win32_utf8.h" - -#define EEL2_PREPROCESS_OPEN_TOKEN " 0.0; - - int lc = 0; - const char *tag = str; - while (*tag && strncmp(tag,EEL2_PREPROCESS_OPEN_TOKEN,2)) if (*tag++ == '\n') lc++; - - if (lc) - { - input_linecnt += lc; - if (suppress) - add_line_inf(m_output_linecnt,lc); - else - m_output_linecnt += lc; - } - - if (!*tag) - { - if (!suppress) fs->Append(str); - return NULL; - } - if (!suppress && tag > str) fs->Append(str,(int)(tag-str)); - - tag += 2; - while (*tag == ' ' || *tag == '\t') tag++; - str = tag; - lc = 0; - while (*str && strncmp(str,"?>",2)) if (*str++ == '\n') lc++; - - if (!*str) - { - m_tmp.SetFormatted(512, "%d: unterminated preprocessor " EEL2_PREPROCESS_OPEN_TOKEN " block", input_linecnt+1); - return m_tmp.Get(); - } - - if (lc) - { - input_linecnt += lc; - add_line_inf(m_output_linecnt,lc); - } - if (str > tag) - { - m_tmp.Set(tag,(int)(str-tag)); - NSEEL_CODEHANDLE ch = NSEEL_code_compile_ex(m_vm, m_tmp.Get(), 0, NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS); - if (!ch) - { - const char *err = NSEEL_code_getcodeerror(m_vm); - if (err) - { - const int line_ref = atoi(err); - while (*err >= '0' && *err <= '9') err++; - m_tmp.SetFormatted(512,"%d: preprocessor%s%s",input_linecnt+line_ref,*err && *err != ':' ? ": ":"",err); - return m_tmp.Get(); - } - } - else - { - lc = 0; - const int oldlen = fs->GetLength(); - m_fsout = fs; - NSEEL_code_execute(ch); - m_fsout = NULL; - m_code_handles.Add(ch); - for (int x = oldlen; x < fs->GetLength(); x ++) if (fs->Get()[x] == '\n') lc++; - if (lc) - { - add_line_inf(m_output_linecnt,-lc); - m_output_linecnt += lc; - } - } - } - str += 2; - } - } - - const char *translate_error_line(const char *err_line) - { - if (m_line_tab.GetSize()<2) return err_line; - int l = atoi(err_line)-1; - if (l<0) return err_line; - - // tab is a list of pairs - // [, delta] - // delta>0 if input lines were skipped - // delta<0 if output lines were added - - int nl = l; - for (int x = m_line_tab.GetSize()-2; x >= 0; x -= 2) - { - int p = m_line_tab.Get()[x]; - if (nl > p) - { - int delta = m_line_tab.Get()[x+1]; - nl += delta; - if (nl < p) nl = p; - } - } - - if (l == nl) return err_line; - - while (*err_line >= '0' && *err_line <= '9') err_line++; - if (*err_line == ':') err_line++; - m_tmp.SetFormatted(512,"%d:%s",1 + nl,err_line); - return m_tmp.Get(); - } - - NSEEL_VMCTX m_vm; - WDL_PtrList m_literal_strings; - WDL_FastString m_tmp, *m_fsout; - WDL_TypedBuf m_line_tab; // expose this in case the caller wants to keep copies around - EEL_F *m_suppress; - int m_max_sz; - int m_cur_depth, m_max_include_depth; - int m_output_linecnt; - static eel_function_table m_ftab; - WDL_PtrList m_code_handles; - WDL_PtrList m_include_paths; - - void add_line_inf(int output_linecnt, int lc) - { - if (!m_cur_depth) - { - m_line_tab.Add(output_linecnt); // log lc lines of input skipped - m_line_tab.Add(lc); - } - } - - static EEL_F addStringCallback(void *opaque, struct eelStringSegmentRec *list) - { - EEL2_PreProcessor *_this = (EEL2_PreProcessor*)opaque; - if (!_this) return -1.0; - - const int sz = nseel_stringsegments_tobuf(NULL,0,list); - char *ns = (char *)malloc(sz+1); - if (WDL_NOT_NORMALLY(!ns)) return -1.0; - nseel_stringsegments_tobuf(ns,sz,list); - - const int nstr = _this->m_literal_strings.GetSize(); - for (int x=0;xm_literal_strings.Get(x); - if (!strcmp(s,ns)) - { - free(ns); - return x + LITERAL_BASE; - } - } - _this->m_literal_strings.Add(ns); - return nstr + LITERAL_BASE; - } - - const char *GetString(EEL_F v) - { - if (v >= LITERAL_BASE && v < LITERAL_BASE + m_literal_strings.GetSize()) - return m_literal_strings.Get((int) (v - LITERAL_BASE)); - return NULL; - } - - static int eel_validate_format_specifier(const char *fmt_in, char *typeOut, - char *fmtOut, int fmtOut_sz, - char *varOut, int varOut_sz, - int *varOut_used - ) - { - const char *fmt = fmt_in+1; - int state=0; - if (fmt_in[0] != '%') return 0; // ugh passed a non-specifier - - *varOut_used = 0; - *varOut = 0; - - if (fmtOut_sz-- < 2) return 0; - *fmtOut++ = '%'; - - while (*fmt) - { - const char c = *fmt++; - if (fmtOut_sz < 2) return 0; - - if (c == 'f'|| c=='e' || c=='E' || c=='g' || c=='G' || c == 'd' || c == 'u' || - c == 'x' || c == 'X' || c == 'c' || c == 'C' || c =='s' || c=='S' || c=='i') - { - *typeOut = c; - fmtOut[0] = c; - fmtOut[1] = 0; - return (int) (fmt - fmt_in); - } - else if (c == '.') - { - *fmtOut++ = c; fmtOut_sz--; - if (state&(2)) break; - state |= 2; - } - else if (c == '+') - { - *fmtOut++ = c; fmtOut_sz--; - if (state&(32|16|8|4)) break; - state |= 8; - } - else if (c == '-' || c == ' ') - { - *fmtOut++ = c; fmtOut_sz--; - if (state&(32|16|8|4)) break; - state |= 16; - } - else if (c >= '0' && c <= '9') - { - *fmtOut++ = c; fmtOut_sz--; - state|=4; - } - else if (c == '{') - { - if (state & 64) break; - state|=64; - if (*fmt == '.' || (*fmt >= '0' && *fmt <= '9')) return 0; // symbol name can't start with 0-9 or . - - while (*fmt != '}') - { - if ((*fmt >= 'a' && *fmt <= 'z') || - (*fmt >= 'A' && *fmt <= 'Z') || - (*fmt >= '0' && *fmt <= '9') || - *fmt == '_' || *fmt == '.' || *fmt == '#') - { - if (varOut_sz < 2) return 0; - *varOut++ = *fmt++; - varOut_sz -- ; - } - else - { - return 0; // bad character in variable name - } - } - fmt++; - *varOut = 0; - *varOut_used=1; - } - else - { - break; - } - } - return 0; - } - - static int eel_format_strings(void *opaque, const char *fmt, const char *fmt_end, char *buf, int buf_sz, int num_fmt_parms, EEL_F **fmt_parms) - { - EEL2_PreProcessor *_this = (EEL2_PreProcessor*)opaque; - int fmt_parmpos = 0; - char *op = buf; - while ((fmt_end ? fmt < fmt_end : *fmt) && op < buf+buf_sz-128) - { - if (fmt[0] == '%' && fmt[1] == '%') - { - *op++ = '%'; - fmt+=2; - } - else if (fmt[0] == '%') - { - char ct=0; - char fs[128]; - char varname[128]; - int varname_used=0; - const int l=eel_validate_format_specifier(fmt,&ct,fs,sizeof(fs),varname,sizeof(varname),&varname_used); - if (!l || !ct) - { - *op=0; - return -1; - } - - const EEL_F *varptr = NULL; - if (!varname_used) - { - if (fmt_parmpos < num_fmt_parms) varptr = fmt_parms[fmt_parmpos]; - fmt_parmpos++; - } - double v = varptr ? (double)*varptr : 0.0; - - if (ct == 's' || ct=='S') - { - const char *str = _this->GetString(v); - const int maxl=(int) (buf+buf_sz - 2 - op); - snprintf(op,maxl,fs,str ? str : ""); - } - else - { - if (ct == 'x' || ct == 'X' || ct == 'd' || ct == 'u' || ct=='i') - { - snprintf(op,64,fs,(int) (v)); - } - else if (ct == 'c') - { - *op++=(char) (int)v; - *op=0; - } - else if (ct == 'C') - { - const unsigned int iv = (unsigned int) v; - int bs = 0; - if (iv & 0xff000000) bs=24; - else if (iv & 0x00ff0000) bs=16; - else if (iv & 0x0000ff00) bs=8; - while (bs>=0) - { - const char c=(char) (iv>>bs); - *op++=c?c:' '; - bs-=8; - } - *op=0; - } - else - { - snprintf(op,64,fs,v); - } - } - - while (*op) op++; - - fmt += l; - } - else - { - *op++ = *fmt++; - } - - } - *op=0; - return (int) (op - buf); - } - - static EEL_F NSEEL_CGEN_CALL pp_printf(void *opaque, INT_PTR num_param, EEL_F **parms) - { - if (num_param>0 && opaque) - { - EEL2_PreProcessor *_this = (EEL2_PreProcessor*)opaque; - const char *fmt = _this->GetString(parms[0][0]); - if (fmt) - { - char buf[16384]; - const int len = eel_format_strings(opaque,fmt,NULL,buf,(int)sizeof(buf), (int)num_param-1, parms+1); - - if (len >= 0) - { - if (_this->m_fsout && _this->m_fsout->GetLength() < _this->m_max_sz) - { - _this->m_fsout->Append(buf,len); - } - return 1.0; - } - } - } - return 0.0; - } - - static EEL_F NSEEL_CGEN_CALL pp_include(void *opaque, INT_PTR num_param, EEL_F **parms) - { - if (num_param>0 && opaque) - { - EEL2_PreProcessor *_this = (EEL2_PreProcessor*)opaque; - if (_this->m_cur_depth >= _this->m_max_include_depth) return -1.0; - - const char *fn = _this->GetString(parms[0][0]); - if (!fn || !*fn) return -2.0; - - WDL_FastString fullfn; - for (int x = _this->m_include_paths.GetSize()-1; x >= 0; x--) - { - const char *p = _this->m_include_paths.Get(x); - if (p && *p) - { - fullfn.Set(p); - fullfn.Append(WDL_DIRCHAR_STR); - fullfn.Append(fn); - FILE *fp = fopenUTF8(fullfn.Get(),"rb"); - if (fp) - { - double rv = 0.0; - _this->m_cur_depth++; - fullfn.Set(""); - while (fullfn.GetLength() < (4<<20)) - { - char buf[512]; - if (!fgets(buf,sizeof(buf),fp)) break; - fullfn.Append(buf); - } - fclose(fp); - - WDL_FastString *outp = _this->m_fsout; - if (_this->preprocess(fullfn.Get(),outp)) - { - rv = -3.0; - } - _this->m_fsout = outp; - - _this->m_cur_depth--; - return rv; - } - } - } - return -4.0; - } - return 0.0; - } - -}; - -eel_function_table EEL2_PreProcessor::m_ftab; - -#endif diff --git a/oversampling/WDL/eel2/eel_strings.h b/oversampling/WDL/eel2/eel_strings.h deleted file mode 100644 index 7991721..0000000 --- a/oversampling/WDL/eel2/eel_strings.h +++ /dev/null @@ -1,1668 +0,0 @@ -#ifndef __EEL__STRINGS_H__ -#define __EEL__STRINGS_H__ - -#include "ns-eel-int.h" -#include "../wdlcstring.h" -#include "../wdlstring.h" - -// required for context -// #define EEL_STRING_GET_CONTEXT_POINTER(opaque) (((sInst *)opaque)->m_eel_string_state) - - -/* - // writeable user-strings are 0..1023 (EEL_STRING_MAX_USER_STRINGS-1), and can be up to about EEL_STRING_MAXUSERSTRING_LENGTH_HINT bytes long - - printf("string %d blah"); -- output to log, allows %d %u %f etc, if host implements formats [1] - sprintf(str,"string %d blah"); -- output to str [1] - strlen(str); -- returns string length - match("*test*", "this is a test") -- search for first parameter regex-style in second parameter - matchi("*test*", "this is a test") -- search for first parameter regex-style in second parameter (case insensitive) - // %s means 1 or more chars - // %0s means 0 or more chars - // %5s means exactly 5 chars - // %5-s means 5 or more chars - // %-10s means 1-10 chars - // %3-5s means 3-5 chars. - // %0-5s means 0-5 chars. - // %S (uppercase) indicates lazy match (%D, %F, %X, etc) - - strcpy(str, srcstr); -- replaces str with srcstr - strcat(str, srcstr); -- appends srcstr to str - strcmp(str, str2) -- compares strings - stricmp(str, str2) -- compares strings (ignoring case) - strncmp(str, str2, maxlen) -- compares strings up to maxlen bytes - strnicmp(str, str2, maxlen) -- compares strings (ignoring case) up to maxlen bytes - strncpy(str, srcstr, maxlen); -- replaces str with srcstr, up to maxlen (-1 for unlimited) - strncat(str, srcstr, maxlen); -- appends up to maxlen of srcstr to str (-1 for unlimited) - strcpy_from(str,srcstr, offset); -- copies srcstr to str, but starts reading srcstr at offset offset - strcpy_substr(str, srcstr, offs, ml) -- php-style (start at offs, offs<0 means from end, ml for maxlen, ml<0 = reduce length by this amt) - str_getchar(str, offset[, type]); -- returns value at offset offset, type can be omitted or 0 or 'c', 's', 'S', 'i', 'I', 'f', 'F', 'd', 'D', 'uc', 'us', 'US', 'ui', 'UI' - -- negative offset is offset from end of string - str_setchar(str, offset, val[, type]); - sets value at offset offset, type optional. offset must be [0,length], if length it can lengthen string, if >length then call fails - -- negative offset is offset from end of string - - str_setlen(str, len); -- sets length of string (if increasing, will be space-padded) - str_delsub(str, pos, len); -- deletes len chars at pos - str_insert(str, srcstr, pos); -- inserts srcstr at pos - - [1]: note: printf/sprintf are NOT binary safe when using %s with modifiers (such as %100s etc) -- the source string being formatted - will terminate at the first NULL character - ); - - - - */ - -// define this to allow modifying literal strings via code, i.e. foobar = strcat("foo","bar"); -// disabled by default, so literals can be pooled/reused/etc -// #define EEL_STRINGS_MUTABLE_LITERALS - -#ifndef EEL_STRING_MAXUSERSTRING_LENGTH_HINT -#define EEL_STRING_MAXUSERSTRING_LENGTH_HINT 16384 -#endif - -#ifndef EEL_STRING_MAX_USER_STRINGS -// strings 0...x-1 -#define EEL_STRING_MAX_USER_STRINGS 1024 -#endif - -#ifndef EEL_STRING_LITERAL_BASE -// strings defined by "xyz" -#define EEL_STRING_LITERAL_BASE 10000 -#endif - -// base for named mutable strings (#xyz) -#ifndef EEL_STRING_NAMED_BASE -#define EEL_STRING_NAMED_BASE 90000 -#endif - -// base for unnamed mutable strings (#) -#ifndef EEL_STRING_UNNAMED_BASE -#define EEL_STRING_UNNAMED_BASE 190000 -#endif - -// define EEL_STRING_MUTEXLOCK_SCOPE for custom, otherwise EEL_STRING_WANT_MUTEX for builtin locking -#ifndef EEL_STRING_MUTEXLOCK_SCOPE - #ifdef EEL_STRING_WANT_MUTEX - #include "../mutex.h" - #define EEL_STRING_MUTEXLOCK_SCOPE WDL_MutexLock __lock(&(EEL_STRING_GET_CONTEXT_POINTER(opaque)->m_mutex)); - #else - #define EEL_STRING_MUTEXLOCK_SCOPE - #endif -#endif - -// allow overriding behavior -#ifndef EEL_STRING_GET_FOR_INDEX -#define EEL_STRING_GET_FOR_INDEX(x, wr) (EEL_STRING_GET_CONTEXT_POINTER(opaque)->GetStringForIndex(x, wr, false)) -#endif - -#ifndef EEL_STRING_GET_FOR_WRITE -#define EEL_STRING_GET_FOR_WRITE(x, wr) (EEL_STRING_GET_CONTEXT_POINTER(opaque)->GetStringForIndex(x, wr, true)) -#endif - -#ifndef EEL_STRING_GETFMTVAR -#define EEL_STRING_GETFMTVAR(x) (EEL_STRING_GET_CONTEXT_POINTER(opaque)->GetVarForFormat(x)) -#endif - -#ifndef EEL_STRING_GETNAMEDVAR -#define EEL_STRING_GETNAMEDVAR(x,createOK,altOut) (EEL_STRING_GET_CONTEXT_POINTER(opaque)->GetNamedVar(x,createOK,altOut)) -#endif - - - - - -#ifndef EEL_STRING_STORAGECLASS -#define EEL_STRING_STORAGECLASS WDL_FastString -#endif - - - -class eel_string_context_state -{ - public: - static int cmpistr(const char **a, const char **b) { return stricmp(*a,*b); } - - eel_string_context_state() : m_named_strings_names(false), m_varname_cache(cmpistr) - { - m_vm=0; - memset(m_user_strings,0,sizeof(m_user_strings)); - } - ~eel_string_context_state() - { - clear_state(true); - } - - void clear_state(bool full) - { - if (full) - { - int x; - for (x=0;x=0 && idx < EEL_STRING_MAX_USER_STRINGS) - { - if (stringContainerOut) - { - if (!m_user_strings[idx]) m_user_strings[idx] = new EEL_STRING_STORAGECLASS; - *stringContainerOut = m_user_strings[idx]; - } - return m_user_strings[idx]?m_user_strings[idx]->Get():""; - } - EEL_STRING_STORAGECLASS *s; - s = m_unnamed_strings.Get(idx - EEL_STRING_UNNAMED_BASE); - if (!s) s= m_named_strings.Get(idx - EEL_STRING_NAMED_BASE); - - if (s) - { - // mutable string - if (stringContainerOut) *stringContainerOut=s; - } - else - { - s = m_literal_strings.Get(idx - EEL_STRING_LITERAL_BASE); - #ifdef EEL_STRINGS_MUTABLE_LITERALS - if (stringContainerOut) *stringContainerOut=s; - #else - if (stringContainerOut) *stringContainerOut=is_for_write ? NULL : s; - #endif - } - return s ? s->Get() : NULL; - } - - WDL_PtrList m_literal_strings; // "this kind", normally immutable - WDL_PtrList m_unnamed_strings; // # - WDL_PtrList m_named_strings; // #xyz by index, but stringkeyed below for names - WDL_StringKeyedArray m_named_strings_names; // #xyz->index - - EEL_STRING_STORAGECLASS *m_user_strings[EEL_STRING_MAX_USER_STRINGS]; // indices 0-1023 (etc) - WDL_AssocArray m_varname_cache; // cached pointers when using %{xyz}s, %{#xyz}s bypasses - - NSEEL_VMCTX m_vm; -#ifdef EEL_STRING_WANT_MUTEX - WDL_Mutex m_mutex; -#endif - - static EEL_F addNamedStringCallback(void *opaque, const char *name) - { - if (!opaque) return -1.0; - eel_string_context_state *_this = EEL_STRING_GET_CONTEXT_POINTER(opaque); - if (!_this) return -1.0; -#ifdef EEL_STRING_NAMEDSTRINGCALLBACK_HOOK - EEL_STRING_NAMEDSTRINGCALLBACK_HOOK -#endif - - EEL_STRING_MUTEXLOCK_SCOPE - if (!name || !name[0]) - { - _this->m_unnamed_strings.Add(new EEL_STRING_STORAGECLASS); - return (EEL_F) (_this->m_unnamed_strings.GetSize()-1 + EEL_STRING_UNNAMED_BASE); - } - - int a = _this->m_named_strings_names.Get(name); - if (a) return (EEL_F)a; - - a = _this->m_named_strings.GetSize() + EEL_STRING_NAMED_BASE; - _this->m_named_strings.Add(new EEL_STRING_STORAGECLASS); - _this->m_named_strings_names.Insert(name,a); - - return (EEL_F)a; - } - - static EEL_F addStringCallback(void *opaque, struct eelStringSegmentRec *list) - { - if (!opaque) return -1.0; - - eel_string_context_state *_this = EEL_STRING_GET_CONTEXT_POINTER(opaque); - if (!_this) return -1.0; - - EEL_STRING_STORAGECLASS *ns = new EEL_STRING_STORAGECLASS; - // could probably do a faster implementation using AddRaw() etc but this should also be OK - int sz=nseel_stringsegments_tobuf(NULL,0,list); - ns->SetLen(sz+32); - sz=nseel_stringsegments_tobuf((char *)ns->Get(),sz,list); - ns->SetLen(sz); - EEL_STRING_MUTEXLOCK_SCOPE - return (EEL_F)_this->AddString(ns); - } - int AddString(EEL_STRING_STORAGECLASS *ns) - { -#ifdef EEL_STRINGS_MUTABLE_LITERALS - m_literal_strings.Add(ns); - return m_literal_strings.GetSize()-1+EEL_STRING_LITERAL_BASE; -#else - const int l = ns->GetLength(); - const int sz=m_literal_strings.GetSize(); - int x; - for (x=0;xGetLength() == l && !strcmp(s->Get(),ns->Get())) break; - } - if (xm_varname_cache.AddUnsorted(name,val); - return 1; - } - -}; - - - -static int eel_validate_format_specifier(const char *fmt_in, char *typeOut, - char *fmtOut, int fmtOut_sz, - char *varOut, int varOut_sz, - int *varOut_used - ) -{ - const char *fmt = fmt_in+1; - int state=0; - if (fmt_in[0] != '%') return 0; // ugh passed a non-specifier - - *varOut_used = 0; - *varOut = 0; - - if (fmtOut_sz-- < 2) return 0; - *fmtOut++ = '%'; - - while (*fmt) - { - const char c = *fmt++; - if (fmtOut_sz < 2) return 0; - - if (c == 'f'|| c=='e' || c=='E' || c=='g' || c=='G' || c == 'd' || c == 'u' || - c == 'x' || c == 'X' || c == 'c' || c == 'C' || c =='s' || c=='S' || c=='i') - { - *typeOut = c; - fmtOut[0] = c; - fmtOut[1] = 0; - return (int) (fmt - fmt_in); - } - else if (c == '.') - { - *fmtOut++ = c; fmtOut_sz--; - if (state&(2)) break; - state |= 2; - } - else if (c == '+') - { - *fmtOut++ = c; fmtOut_sz--; - if (state&(32|16|8|4)) break; - state |= 8; - } - else if (c == '-' || c == ' ') - { - *fmtOut++ = c; fmtOut_sz--; - if (state&(32|16|8|4)) break; - state |= 16; - } - else if (c >= '0' && c <= '9') - { - *fmtOut++ = c; fmtOut_sz--; - state|=4; - } - else if (c == '{') - { - if (state & 64) break; - state|=64; - if (*fmt == '.' || (*fmt >= '0' && *fmt <= '9')) return 0; // symbol name can't start with 0-9 or . - - while (*fmt != '}') - { - if ((*fmt >= 'a' && *fmt <= 'z') || - (*fmt >= 'A' && *fmt <= 'Z') || - (*fmt >= '0' && *fmt <= '9') || - *fmt == '_' || *fmt == '.' || *fmt == '#') - { - if (varOut_sz < 2) return 0; - *varOut++ = *fmt++; - varOut_sz -- ; - } - else - { - return 0; // bad character in variable name - } - } - fmt++; - *varOut = 0; - *varOut_used=1; - } - else - { - break; - } - } - return 0; -} - -int eel_format_strings(void *opaque, const char *fmt, const char *fmt_end, char *buf, int buf_sz, int num_fmt_parms, EEL_F **fmt_parms) -{ - int fmt_parmpos = 0; - char *op = buf; - while ((fmt_end ? fmt < fmt_end : *fmt) && op < buf+buf_sz-128) - { - if (fmt[0] == '%' && fmt[1] == '%') - { - *op++ = '%'; - fmt+=2; - } - else if (fmt[0] == '%') - { - char ct=0; - char fs[128]; - char varname[128]; - int varname_used=0; - const int l=eel_validate_format_specifier(fmt,&ct,fs,sizeof(fs),varname,sizeof(varname),&varname_used); - if (!l || !ct) - { - *op=0; - return -1; - } - - EEL_F vv=0.0; - const EEL_F *varptr = NULL; - if (varname_used) - { -#ifdef EEL_STRING_GETNAMEDVAR - if (varname[0]) varptr=EEL_STRING_GETNAMEDVAR(varname,0,&vv); -#endif - } - else - { - if (fmt_parmpos < num_fmt_parms) varptr = fmt_parms[fmt_parmpos]; -#ifdef EEL_STRING_GETFMTVAR - if (!varptr) varptr = EEL_STRING_GETFMTVAR(fmt_parmpos); -#endif - fmt_parmpos++; - } - double v = varptr ? (double)*varptr : 0.0; - - if (ct == 's' || ct=='S') - { - EEL_STRING_STORAGECLASS *wr=NULL; - const char *str = EEL_STRING_GET_FOR_INDEX(v,&wr); - const int maxl=(int) (buf+buf_sz - 2 - op); - if (wr && !fs[2]) // %s or %S -- todo: implement padding modes for binary compat too? - { - int wl = wr->GetLength(); - if (wl > maxl) wl=maxl; - memcpy(op,wr->Get(),wl); - op += wl; - *op=0; - } - else - { - snprintf(op,maxl,fs,str ? str : ""); - } - } - else - { - if (varptr == &vv) // passed %{#str}d etc, convert to float - { - const char *str = EEL_STRING_GET_FOR_INDEX(v,NULL); - v = str ? atof(str) : 0.0; - } - - if (ct == 'x' || ct == 'X' || ct == 'd' || ct == 'u' || ct=='i') - { - snprintf(op,64,fs,(int) (v)); - } - else if (ct == 'c') - { - *op++=(char) (int)v; - *op=0; - } - else if (ct == 'C') - { - const unsigned int iv = (unsigned int) v; - int bs = 0; - if (iv & 0xff000000) bs=24; - else if (iv & 0x00ff0000) bs=16; - else if (iv & 0x0000ff00) bs=8; - while (bs>=0) - { - const char c=(char) (iv>>bs); - *op++=c?c:' '; - bs-=8; - } - *op=0; - } - else - { - snprintf(op,64,fs,v); - } - } - - while (*op) op++; - - fmt += l; - } - else - { - *op++ = *fmt++; - } - - } - *op=0; - return (int) (op - buf); -} - - - -static int eel_string_match(void *opaque, const char *fmt, const char *msg, int match_fmt_pos, int ignorecase, const char *fmt_endptr, const char *msg_endptr, int num_fmt_parms, EEL_F **fmt_parms) -{ - // check for match, updating EEL_STRING_GETFMTVAR(*) as necessary - // %d=12345 - // %f=12345[.678] - // %c=any nonzero char, ascii value - // %x=12354ab - // %*, %?, %+, %% literals - // * ? + match minimal groups of 0+,1, or 1+ chars - for (;;) - { - if (fmt>=fmt_endptr) - { - if (msg>=msg_endptr) return 1; - return 0; // format ends before matching string - } - - // if string ends and format is not on a wildcard, early-out to 0 - if (msg>=msg_endptr && *fmt != '*' && *fmt != '%') return 0; - - switch (*fmt) - { - case '*': - case '+': - // if last char of search pattern, we're done! - if (fmt+1>=fmt_endptr || (fmt[1] == '?' && fmt+2>=fmt_endptr)) return *fmt == '*' || msg= 0 && !eel_string_match(opaque,fmt, msg+len,match_fmt_pos,ignorecase,fmt_endptr, msg_endptr,num_fmt_parms,fmt_parms)) len--; - return len >= 0; - } - break; - case '?': - fmt++; - msg++; - break; - case '%': - { - fmt++; - unsigned short fmt_minlen = 1, fmt_maxlen = 0; - if (*fmt >= '0' && *fmt <= '9') - { - fmt_minlen = *fmt++ - '0'; - while (*fmt >= '0' && *fmt <= '9') fmt_minlen = fmt_minlen * 10 + (*fmt++ - '0'); - fmt_maxlen = fmt_minlen; - } - if (*fmt == '-') - { - fmt++; - fmt_maxlen = 0; - while (*fmt >= '0' && *fmt <= '9') fmt_maxlen = fmt_maxlen * 10 + (*fmt++ - '0'); - } - const char *dest_varname=NULL; - if (*fmt == '{') - { - dest_varname=++fmt; - while (*fmt && fmt < fmt_endptr && *fmt != '}') fmt++; - if (fmt >= fmt_endptr-1 || *fmt != '}') return 0; // malformed %{var}s - fmt++; // skip '}' - } - - char fmt_char = *fmt++; - if (!fmt_char) return 0; // malformed - - if (fmt_char == '*' || - fmt_char == '?' || - fmt_char == '+' || - fmt_char == '%') - { - if (*msg++ != fmt_char) return 0; - } - else if (fmt_char == 'c') - { - EEL_F *varOut = NULL; - EEL_F vv=0.0; - if (!dest_varname) - { - if (match_fmt_pos < num_fmt_parms) varOut = fmt_parms[match_fmt_pos]; -#ifdef EEL_STRING_GETFMTVAR - if (!varOut) varOut = EEL_STRING_GETFMTVAR(match_fmt_pos); -#endif - match_fmt_pos++; - } - else - { -#ifdef EEL_STRING_GETNAMEDVAR - char tmp[128]; - int idx=0; - while (dest_varname < fmt_endptr && *dest_varname && *dest_varname != '}' && idx<(int)sizeof(tmp)-1) tmp[idx++] = *dest_varname++; - tmp[idx]=0; - if (idx>0) varOut = EEL_STRING_GETNAMEDVAR(tmp,1,&vv); -#endif - } - if (msg >= msg_endptr) return 0; // out of chars - - if (varOut) - { - if (varOut == &vv) // %{#foo}c - { - EEL_STRING_STORAGECLASS *wr=NULL; - EEL_STRING_GET_FOR_WRITE(vv, &wr); - if (wr) wr->Set(msg,1); - } - else - { - *varOut = (EEL_F)*(unsigned char *)msg; - } - } - msg++; - } - else - { - int len=0; - int lazy=0; - if (fmt_char>='A'&&fmt_char<='Z') { lazy=1; fmt_char += 'a' - 'A'; } - - if (fmt_char == 's') - { - len = (int) (msg_endptr-msg); - } - else if (fmt_char == 'x') - { - while ((msg[len] >= '0' && msg[len] <= '9') || - (msg[len] >= 'A' && msg[len] <= 'F') || - (msg[len] >= 'a' && msg[len] <= 'f')) len++; - } - else if (fmt_char == 'f') - { - if (msg[len] == '-') len++; - while (msg[len] >= '0' && msg[len] <= '9') len++; - if (msg[len] == '.') - { - len++; - while (msg[len] >= '0' && msg[len] <= '9') len++; - } - } - else if (fmt_char == 'd' || fmt_char == 'u' || fmt_char == 'i') - { - if (fmt_char != 'u' && msg[len] == '-') len++; - while (msg[len] >= '0' && msg[len] <= '9') len++; - } - else - { - // bad format - return 0; - } - - if (fmt_maxlen>0 && len > fmt_maxlen) len = fmt_maxlen; - - if (!dest_varname) match_fmt_pos++; - - if (lazy) - { - if (fmt_maxlen<1 || fmt_maxlen>len) fmt_maxlen=len; - len=fmt_minlen; - while (len <= fmt_maxlen && !eel_string_match(opaque,fmt, msg+len,match_fmt_pos,ignorecase,fmt_endptr, msg_endptr,num_fmt_parms,fmt_parms)) len++; - if (len > fmt_maxlen) return 0; - } - else - { - while (len >= fmt_minlen && !eel_string_match(opaque,fmt, msg+len,match_fmt_pos,ignorecase,fmt_endptr, msg_endptr,num_fmt_parms,fmt_parms)) len--; - if (len < fmt_minlen) return 0; - } - - EEL_F vv=0.0; - EEL_F *varOut = NULL; - if (!dest_varname) - { - if (match_fmt_pos>0 && match_fmt_pos-1 < num_fmt_parms) varOut = fmt_parms[match_fmt_pos-1]; -#ifdef EEL_STRING_GETFMTVAR - if (!varOut) varOut = EEL_STRING_GETFMTVAR(match_fmt_pos-1); -#endif - } - else - { -#ifdef EEL_STRING_GETNAMEDVAR - char tmp[128]; - int idx=0; - while (dest_varname < fmt_endptr && *dest_varname && *dest_varname != '}' && idx<(int)sizeof(tmp)-1) tmp[idx++] = *dest_varname++; - tmp[idx]=0; - if (idx>0) varOut = EEL_STRING_GETNAMEDVAR(tmp,1,&vv); -#endif - } - if (varOut) - { - if (fmt_char == 's') - { - EEL_STRING_STORAGECLASS *wr=NULL; - EEL_STRING_GET_FOR_WRITE(*varOut, &wr); - if (wr) - { - if (msg_endptr >= wr->Get() && msg_endptr <= wr->Get() + wr->GetLength()) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("match: destination specifier passed is also haystack, will not update"); -#endif - } - else if (fmt_endptr >= wr->Get() && fmt_endptr <= wr->Get() + wr->GetLength()) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("match: destination specifier passed is also format, will not update"); -#endif - } - else - { - wr->SetRaw(msg,len); - } - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("match: bad destination specifier passed as %d: %f",match_fmt_pos,*varOut); -#endif - } - } - else - { - char tmp[128]; - lstrcpyn_safe(tmp,msg,wdl_min(len+1,(int)sizeof(tmp))); - if (varOut == &vv) - { - EEL_STRING_STORAGECLASS *wr=NULL; - EEL_STRING_GET_FOR_WRITE(vv, &wr); - if (wr) wr->Set(tmp); - } - else - { - char *bl=(char*)msg; - if (fmt_char == 'u') - *varOut = (EEL_F)strtoul(tmp,&bl,10); - else if (fmt_char == 'x') - *varOut = (EEL_F)strtoul(msg,&bl,16); - else - *varOut = (EEL_F)atof(tmp); - } - } - } - return 1; - } - } - break; - default: - if (ignorecase ? (toupper(*fmt) != toupper(*msg)) : (*fmt!= *msg)) return 0; - fmt++; - msg++; - break; - } - } -} - - - -static EEL_F NSEEL_CGEN_CALL _eel_sprintf(void *opaque, INT_PTR num_param, EEL_F **parms) -{ - if (num_param<2) return 0.0; - - if (opaque) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr=NULL; - EEL_STRING_GET_FOR_WRITE(*(parms[0]), &wr); - if (!wr) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("sprintf: bad destination specifier passed %f",*(parms[0])); -#endif - } - else - { - EEL_STRING_STORAGECLASS *wr_src=NULL; - const char *fmt = EEL_STRING_GET_FOR_INDEX(*(parms[1]),&wr_src); - if (fmt) - { - char buf[16384]; - const int fmt_len = eel_format_strings(opaque,fmt,wr_src?(fmt+wr_src->GetLength()):NULL,buf,(int)sizeof(buf), (int)num_param-2, parms+2); - - if (fmt_len>=0) - { - wr->SetRaw(buf,fmt_len); - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("sprintf: bad format string %s",fmt); -#endif - } - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("sprintf: bad format specifier passed %f",*(parms[1])); -#endif - } - } - } - return *(parms[0]); -} - - -static EEL_F NSEEL_CGEN_CALL _eel_strncat(void *opaque, EEL_F *strOut, EEL_F *fmt_index, EEL_F *maxlen) -{ - if (opaque) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr=NULL, *wr_src=NULL; - EEL_STRING_GET_FOR_WRITE(*strOut, &wr); - if (!wr) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str%scat: bad destination specifier passed %f",maxlen ? "n":"",*strOut); -#endif - } - else - { - const char *fmt = EEL_STRING_GET_FOR_INDEX(*fmt_index,&wr_src); - if (fmt||wr_src) - { - if (wr->GetLength() > EEL_STRING_MAXUSERSTRING_LENGTH_HINT) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str%scat: will not grow string since it is already %d bytes",maxlen ? "n":"",wr->GetLength()); -#endif - } - else - { - int ml=0; - if (maxlen && *maxlen > 0) ml = (int)*maxlen; - if (wr_src) - { - EEL_STRING_STORAGECLASS tmp; - if (wr_src == wr) *(wr_src=&tmp) = *wr; - wr->AppendRaw(wr_src->Get(), ml > 0 && ml < wr_src->GetLength() ? ml : wr_src->GetLength()); - } - else - wr->Append(fmt, ml); - } - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str%scat: bad format specifier passed %f",maxlen ? "n":"",*fmt_index); -#endif - } - } - } - return *strOut; -} - -static EEL_F NSEEL_CGEN_CALL _eel_strcpysubstr(void *opaque, INT_PTR nparm, EEL_F **parms) //EEL_F *strOut, EEL_F *fmt_index, EEL_F *offs -{ - if (opaque && nparm>=3) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr=NULL, *wr_src=NULL; - EEL_STRING_GET_FOR_WRITE(parms[0][0], &wr); - if (!wr) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("strcpy_substr: bad destination specifier passed %f",parms[0][0]); -#endif - } - else - { - const char *fmt = EEL_STRING_GET_FOR_INDEX(parms[1][0],&wr_src); - if (fmt) - { - const int fmt_len = wr_src ? wr_src->GetLength() : (int) strlen(fmt); - int maxlen, o = (int) parms[2][0]; - if (o < 0) - { - o = fmt_len + o; - if (o < 0) o=0; - } - maxlen = fmt_len - o; - if (nparm >= 4) - { - const int a = (int) parms[3][0]; - if (a<0) maxlen += a; - else if (a= fmt_len) - { - wr->Set(""); - } - else - { - if (wr_src==wr) - { - wr->DeleteSub(0,o); - if (wr->GetLength() > maxlen) wr->SetLen(maxlen); - } - else - { - wr->SetRaw(fmt+o,maxlen); - } - } - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("strcpy_substr: bad format specifier passed %f",parms[1][0]); -#endif - } - } - return parms[0][0]; - } - return 0.0; -} - - -static EEL_F NSEEL_CGEN_CALL _eel_strncpy(void *opaque, EEL_F *strOut, EEL_F *fmt_index, EEL_F *maxlen) -{ - if (opaque) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr=NULL, *wr_src=NULL; - EEL_STRING_GET_FOR_WRITE(*strOut, &wr); - if (!wr) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str%scpy: bad destination specifier passed %f",maxlen ? "n":"",*strOut); -#endif - } - else - { - const char *fmt = EEL_STRING_GET_FOR_INDEX(*fmt_index,&wr_src); - if (fmt) - { - int ml=-1; - if (maxlen && *maxlen >= 0) ml = (int)*maxlen; - - if (wr_src == wr) - { - if (ml>=0 && ml < wr->GetLength()) wr->SetLen(ml); // shorten string if strncpy(x,x,len) and len >=0 - return *strOut; - } - - if (wr_src) wr->SetRaw(fmt, ml>0 && ml < wr_src->GetLength() ? ml : wr_src->GetLength()); - else wr->Set(fmt,ml); - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str%scpy: bad format specifier passed %f",maxlen ? "n":"",*fmt_index); -#endif - } - } - } - return *strOut; -} - -static EEL_F _eel_strcmp_int(const char *a, int a_len, const char *b, int b_len, int ml, bool ignorecase) -{ - // binary-safe comparison (at least if a_len>=0 etc) - int pos = 0; - for (;;) - { - if (ml > 0 && pos == ml) return 0.0; - const bool a_end = a_len >= 0 ? pos == a_len : !a[pos]; - const bool b_end = b_len >= 0 ? pos == b_len : !b[pos]; - if (a_end || b_end) - { - if (!b_end) return -1.0; // b[pos] is nonzero, a[pos] is zero - if (!a_end) return 1.0; - return 0.0; - } - char av = a[pos]; - char bv = b[pos]; - if (ignorecase) - { - av=toupper(av); - bv=toupper(bv); - } - if (bv > av) return -1.0; - if (av > bv) return 1.0; - - pos++; - } -} - -static EEL_F NSEEL_CGEN_CALL _eel_strncmp(void *opaque, EEL_F *aa, EEL_F *bb, EEL_F *maxlen) -{ - if (opaque) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr_a=NULL,*wr_b=NULL; - const char *a = EEL_STRING_GET_FOR_INDEX(*aa,&wr_a); - const char *b = EEL_STRING_GET_FOR_INDEX(*bb,&wr_b); - if (!a || !b) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str%scmp: bad specifier(s) passed %f/%f",maxlen ? "n" : "",*aa,*bb); -#endif - } - else - { - const int ml = maxlen ? (int) *maxlen : -1; - if (!ml || a==b) return 0; // strncmp(x,y,0) == 0 - - return _eel_strcmp_int(a,wr_a ? wr_a->GetLength() : -1,b,wr_b ? wr_b->GetLength() : -1, ml, false); - } - } - return -1.0; -} - -static EEL_F NSEEL_CGEN_CALL _eel_strnicmp(void *opaque, EEL_F *aa, EEL_F *bb, EEL_F *maxlen) -{ - if (opaque) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr_a=NULL,*wr_b=NULL; - const char *a = EEL_STRING_GET_FOR_INDEX(*aa,&wr_a); - const char *b = EEL_STRING_GET_FOR_INDEX(*bb,&wr_b); - if (!a || !b) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str%sicmp: bad specifier(s) passed %f/%f",maxlen ? "n" : "",*aa,*bb); -#endif - } - else - { - const int ml = maxlen ? (int) *maxlen : -1; - if (!ml || a==b) return 0; // strncmp(x,y,0) == 0 - return _eel_strcmp_int(a,wr_a ? wr_a->GetLength() : -1,b,wr_b ? wr_b->GetLength() : -1, ml, true); - } - } - return -1.0; -} - - -static EEL_F NSEEL_CGEN_CALL _eel_strcat(void *opaque, EEL_F *strOut, EEL_F *fmt_index) -{ - return _eel_strncat(opaque,strOut,fmt_index,NULL); -} - -static EEL_F NSEEL_CGEN_CALL _eel_strcpy(void *opaque, EEL_F *strOut, EEL_F *fmt_index) -{ - return _eel_strncpy(opaque,strOut,fmt_index,NULL); -} - - -static EEL_F NSEEL_CGEN_CALL _eel_strcmp(void *opaque, EEL_F *strOut, EEL_F *fmt_index) -{ - return _eel_strncmp(opaque,strOut,fmt_index,NULL); -} - -static EEL_F NSEEL_CGEN_CALL _eel_stricmp(void *opaque, EEL_F *strOut, EEL_F *fmt_index) -{ - return _eel_strnicmp(opaque,strOut,fmt_index,NULL); -} - - -static EEL_F NSEEL_CGEN_CALL _eel_strgetchar(void *opaque, EEL_F *strOut, EEL_F *idx) -{ - if (opaque) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr=NULL; - const char *fmt = EEL_STRING_GET_FOR_INDEX(*strOut, &wr); - if (!fmt) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str_getchar: bad specifier passed %f",*strOut); -#endif - } - else - { - const int wl=(wr?wr->GetLength():(int)strlen(fmt)); - int l = (int) *idx; - if (*idx < 0.0) l+=wl; - if (l>=0 && l < wl) return ((unsigned char *)fmt)[l]; - } - } - return 0; -} - -#define EEL_GETCHAR_FLAG_ENDIANSWAP 0x10 -#define EEL_GETCHAR_FLAG_UNSIGNED 0x20 -#define EEL_GETCHAR_FLAG_FLOAT 0x40 -static int eel_getchar_flag(int type) -{ -#ifdef __ppc__ - int ret=EEL_GETCHAR_FLAG_ENDIANSWAP; // default to LE -#else - int ret=0; -#endif - - if (toupper((type>>8)&0xff) == 'U') ret|=EEL_GETCHAR_FLAG_UNSIGNED; - else if (type>255 && toupper(type&0xff) == 'U') { ret|=EEL_GETCHAR_FLAG_UNSIGNED; type>>=8; } - type&=0xff; - - if (isupper(type)) ret^=EEL_GETCHAR_FLAG_ENDIANSWAP; - else type += 'A'-'a'; - - switch (type) - { - case 'F': return ret|4|EEL_GETCHAR_FLAG_FLOAT; - case 'D': return ret|8|EEL_GETCHAR_FLAG_FLOAT; - case 'S': return ret|2; - case 'I': return ret|4; - } - - return ret|1; -} - -static void eel_setchar_do(int flag, char *dest, EEL_F val) -{ - union - { - char buf[8]; - float asFloat; - double asDouble; - int asInt; - short asShort; - char asChar; - unsigned int asUInt; - unsigned short asUShort; - unsigned char asUChar; - } a; - const int type_sz=flag&0xf; - - if (flag & EEL_GETCHAR_FLAG_FLOAT) - { - if (type_sz==8) a.asDouble=val; - else a.asFloat=(float)val; - } - else if (flag & EEL_GETCHAR_FLAG_UNSIGNED) - { - if (type_sz==4) a.asUInt=(unsigned int)val; - else if (type_sz==2) a.asUShort=(unsigned short)val; - else a.asUChar=(unsigned char)val; - } - else if (type_sz==4) a.asInt=(int)val; - else if (type_sz==2) a.asShort=(short)val; - else a.asChar=(char)val; - - if (flag & EEL_GETCHAR_FLAG_ENDIANSWAP) - { - dest += type_sz; - int x; - for(x=0;x=3) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr=NULL; - const char *fmt = EEL_STRING_GET_FOR_INDEX(parms[0][0], &wr); - if (!fmt) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str_getchar: bad specifier passed %f",parms[0][0]); -#endif - } - else - { - const int wl=(wr?wr->GetLength():(int)strlen(fmt)); - const int flags=eel_getchar_flag((int) parms[2][0]); - int l = (int) parms[1][0]; - if (parms[1][0] < 0.0) l+=wl; - - if (l>=0 && l <= wl-(flags&0xf)) - { - return eel_getchar_do(flags,fmt+l); - } - } - } - return 0; -} - -static EEL_F NSEEL_CGEN_CALL _eel_strsetchar2(void *opaque, INT_PTR np, EEL_F **parms) -{ - if (opaque && np>=4) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr=NULL; - EEL_STRING_GET_FOR_WRITE(parms[0][0], &wr); - if (!wr) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str_setchar: bad destination specifier passed %f",parms[0][0]); -#endif - } - else - { - const int wl=wr->GetLength(); - - int l = (int) parms[1][0]; - if (parms[1][0] < 0.0) l+=wl; - if (l>=0 && l <= wl) - { - const int flags=eel_getchar_flag((int) parms[3][0]); - if (l==wl) - { - if (wl > EEL_STRING_MAXUSERSTRING_LENGTH_HINT) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str_setchar: will not grow string since it is already %d bytes",wl); -#endif - } - else - { - char buf[32]; - eel_setchar_do(flags,buf,parms[2][0]); - wr->AppendRaw(buf,flags&0xf); - } - } - else - eel_setchar_do(flags,(char*)wr->Get()+l,parms[2][0]); - } - } - } - return parms[0][0]; -} - -static EEL_F NSEEL_CGEN_CALL _eel_strsetchar(void *opaque, EEL_F *strOut, EEL_F *idx, EEL_F *val) -{ - if (opaque) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr=NULL; - EEL_STRING_GET_FOR_WRITE(*strOut, &wr); - if (!wr) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str_setchar: bad destination specifier passed %f",*strOut); -#endif - } - else - { - const int wl=wr->GetLength(); - int l = (int) *idx; - if (*idx < 0.0) l+=wl; - if (l>=0 && l <= wl) - { - const unsigned char v=((int)*val)&255; - if (l==wl) - { - if (wl > EEL_STRING_MAXUSERSTRING_LENGTH_HINT) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str_setchar: will not grow string since it is already %d bytes",wl); -#endif - } - else - wr->AppendRaw((const char*)&v,1); - } - else - ((unsigned char *)wr->Get())[l]=v; // allow putting nulls in string, strlen() will still get the full size - } - } - } - return *strOut; -} - -static EEL_F NSEEL_CGEN_CALL _eel_strinsert(void *opaque, EEL_F *strOut, EEL_F *fmt_index, EEL_F *pos) -{ - if (opaque) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr=NULL, *wr_src=NULL; - EEL_STRING_GET_FOR_WRITE(*strOut, &wr); - if (!wr) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str_insert: bad destination specifier passed %f",*strOut); -#endif - } - else - { - const char *fmt = EEL_STRING_GET_FOR_INDEX(*fmt_index,&wr_src); - if (fmt) - { - EEL_STRING_STORAGECLASS tmp; - if (wr_src == wr) *(wr_src=&tmp) = *wr; // insert from copy - - // if wr_src, fmt is guaranteed to be wr_src.Get() - int p = (int)*pos; - int insert_l = wr_src ? wr_src->GetLength() : (int)strlen(fmt); - if (p < 0) - { - insert_l += p; // decrease insert_l - fmt -= p; // advance fmt -- if fmt gets advanced past NULL term, insert_l will be < 0 anyway - p=0; - } - - if (insert_l>0) - { - if (wr->GetLength() > EEL_STRING_MAXUSERSTRING_LENGTH_HINT) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str_insert: will not grow string since it is already %d bytes",wr->GetLength()); -#endif - } - else - { - if (wr_src) - { - wr->InsertRaw(fmt,p, insert_l); - } - else - { - wr->Insert(fmt,p); - } - } - } - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str_insert: bad source specifier passed %f",*fmt_index); -#endif - } - } - } - return *strOut; -} - -static EEL_F NSEEL_CGEN_CALL _eel_strdelsub(void *opaque, EEL_F *strOut, EEL_F *pos, EEL_F *len) -{ - if (opaque) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr=NULL; - EEL_STRING_GET_FOR_WRITE(*strOut, &wr); - if (!wr) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str_delsub: bad destination specifier passed %f",*strOut); -#endif - } - else - { - int p=(int)*pos; - int l=(int)*len; - if (p<0) - { - l+=p; - p=0; - } - if (l>0) - wr->DeleteSub(p,l); - } - } - return *strOut; -} - -static EEL_F NSEEL_CGEN_CALL _eel_strsetlen(void *opaque, EEL_F *strOut, EEL_F *newlen) -{ - if (opaque) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr=NULL; - EEL_STRING_GET_FOR_WRITE(*strOut, &wr); - if (!wr) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str_setlen: bad destination specifier passed %f",*strOut); -#endif - } - else - { - int l = (int) *newlen; - if (l < 0) l=0; - if (l > EEL_STRING_MAXUSERSTRING_LENGTH_HINT) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("str_setlen: clamping requested length of %d to %d",l,EEL_STRING_MAXUSERSTRING_LENGTH_HINT); -#endif - l=EEL_STRING_MAXUSERSTRING_LENGTH_HINT; - } - wr->SetLen(l); - - } - } - return *strOut; -} - - -static EEL_F NSEEL_CGEN_CALL _eel_strlen(void *opaque, EEL_F *fmt_index) -{ - if (opaque) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr=NULL; - const char *fmt = EEL_STRING_GET_FOR_INDEX(*fmt_index,&wr); - if (wr) return (EEL_F) wr->GetLength(); - if (fmt) return (EEL_F) strlen(fmt); - } - return 0.0; -} - - - - -static EEL_F NSEEL_CGEN_CALL _eel_printf(void *opaque, INT_PTR num_param, EEL_F **parms) -{ - if (num_param>0 && opaque) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *wr_src=NULL; - const char *fmt = EEL_STRING_GET_FOR_INDEX(*(parms[0]),&wr_src); - if (fmt) - { - char buf[16384]; - const int len = eel_format_strings(opaque,fmt,wr_src?(fmt+wr_src->GetLength()):NULL,buf,(int)sizeof(buf), (int)num_param-1, parms+1); - - if (len >= 0) - { -#ifdef EEL_STRING_STDOUT_WRITE - EEL_STRING_STDOUT_WRITE(buf,len); -#endif - return 1.0; - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("printf: bad format string %s",fmt); -#endif - } - } - else - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("printf: bad format specifier passed %f",*(parms[0])); -#endif - } - } - return 0.0; -} - - - -static EEL_F NSEEL_CGEN_CALL _eel_match(void *opaque, INT_PTR num_parms, EEL_F **parms) -{ - if (opaque && num_parms >= 2) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *fmt_wr=NULL, *msg_wr=NULL; - const char *fmt = EEL_STRING_GET_FOR_INDEX(*(parms[0]),&fmt_wr); - const char *msg = EEL_STRING_GET_FOR_INDEX(*(parms[1]),&msg_wr); - - if (fmt && msg) return eel_string_match(opaque,fmt,msg,0,0, fmt + (fmt_wr?fmt_wr->GetLength():strlen(fmt)), msg + (msg_wr?msg_wr->GetLength():strlen(msg)),(int)num_parms-2,parms+2) ? 1.0 : 0.0; - } - return 0.0; -} -static EEL_F NSEEL_CGEN_CALL _eel_matchi(void *opaque, INT_PTR num_parms, EEL_F **parms) -{ - if (opaque && num_parms >= 2) - { - EEL_STRING_MUTEXLOCK_SCOPE - EEL_STRING_STORAGECLASS *fmt_wr=NULL, *msg_wr=NULL; - const char *fmt = EEL_STRING_GET_FOR_INDEX(*(parms[0]),&fmt_wr); - const char *msg = EEL_STRING_GET_FOR_INDEX(*(parms[1]),&msg_wr); - - if (fmt && msg) return eel_string_match(opaque,fmt,msg,0,1, fmt + (fmt_wr?fmt_wr->GetLength():strlen(fmt)), msg + (msg_wr?msg_wr->GetLength():strlen(msg)),(int)num_parms-2,parms+2) ? 1.0 : 0.0; - } - return 0.0; -} - -void EEL_string_register() -{ - NSEEL_addfunc_retval("strlen",1,NSEEL_PProc_THIS,&_eel_strlen); - - NSEEL_addfunc_retval("strcat",2,NSEEL_PProc_THIS,&_eel_strcat); - NSEEL_addfunc_retval("strcpy",2,NSEEL_PProc_THIS,&_eel_strcpy); - NSEEL_addfunc_retval("strcmp",2,NSEEL_PProc_THIS,&_eel_strcmp); - NSEEL_addfunc_retval("stricmp",2,NSEEL_PProc_THIS,&_eel_stricmp); - - NSEEL_addfunc_retval("strncat",3,NSEEL_PProc_THIS,&_eel_strncat); - NSEEL_addfunc_retval("strncpy",3,NSEEL_PProc_THIS,&_eel_strncpy); - NSEEL_addfunc_retval("strncmp",3,NSEEL_PProc_THIS,&_eel_strncmp); - NSEEL_addfunc_retval("strnicmp",3,NSEEL_PProc_THIS,&_eel_strnicmp); - NSEEL_addfunc_retval("str_setlen",2,NSEEL_PProc_THIS,&_eel_strsetlen); - NSEEL_addfunc_exparms("strcpy_from",3,NSEEL_PProc_THIS,&_eel_strcpysubstr); // alias - NSEEL_addfunc_exparms("strcpy_substr",3,NSEEL_PProc_THIS,&_eel_strcpysubstr); // only allow 3 or 4 parms - NSEEL_addfunc_exparms("strcpy_substr",4,NSEEL_PProc_THIS,&_eel_strcpysubstr); - - NSEEL_addfunc_retval("str_getchar",2,NSEEL_PProc_THIS,&_eel_strgetchar); - NSEEL_addfunc_retval("str_setchar",3,NSEEL_PProc_THIS,&_eel_strsetchar); - NSEEL_addfunc_exparms("str_getchar",3,NSEEL_PProc_THIS,&_eel_strgetchar2); - NSEEL_addfunc_exparms("str_setchar",4,NSEEL_PProc_THIS,&_eel_strsetchar2); - - NSEEL_addfunc_retval("str_insert",3,NSEEL_PProc_THIS,&_eel_strinsert); - NSEEL_addfunc_retval("str_delsub",3,NSEEL_PProc_THIS,&_eel_strdelsub); - - NSEEL_addfunc_varparm("sprintf",2,NSEEL_PProc_THIS,&_eel_sprintf); - NSEEL_addfunc_varparm("printf",1,NSEEL_PProc_THIS,&_eel_printf); - - NSEEL_addfunc_varparm("match",2,NSEEL_PProc_THIS,&_eel_match); - NSEEL_addfunc_varparm("matchi",2,NSEEL_PProc_THIS,&_eel_matchi); - -} -void eel_string_initvm(NSEEL_VMCTX vm) -{ - NSEEL_VM_SetStringFunc(vm, eel_string_context_state::addStringCallback, eel_string_context_state::addNamedStringCallback); -} - -#ifdef EEL_WANT_DOCUMENTATION -static const char *eel_strings_function_reference = -#ifdef EEL_STRING_STDOUT_WRITE -"printf\t\"format\"[, ...]\tOutput formatted string to system-specific destination, see sprintf() for more information\0" -#endif -"sprintf\t#dest,\"format\"[, ...]\tFormats a string and stores it in #dest. Format specifiers begin with %, and may include:\3\n" - "\4 %% = %\n" - "\4 %s = string from parameter\n" - "\4 %d = parameter as integer\n" - "\4 %i = parameter as integer\n" - "\4 %u = parameter as unsigned integer\n" - "\4 %x = parameter as hex (lowercase) integer\n" - "\4 %X = parameter as hex (uppercase) integer\n" - "\4 %c = parameter as character\n" - "\4 %f = parameter as floating point\n" - "\4 %e = parameter as floating point (scientific notation, lowercase)\n" - "\4 %E = parameter as floating point (scientific notation, uppercase)\n" - "\4 %g = parameter as floating point (shortest representation, lowercase)\n" - "\4 %G = parameter as floating point (shortest representation, uppercase)\n" - "\2\n" - "Many standard C printf() modifiers can be used, including:\3\n" - "\4 %.10s = string, but only print up to 10 characters\n" - "\4 %-10s = string, left justified to 10 characters\n" - "\4 %10s = string, right justified to 10 characters\n" - "\4 %+f = floating point, always show sign\n" - "\4 %.4f = floating point, minimum of 4 digits after decimal point\n" - "\4 %10d = integer, minimum of 10 digits (space padded)\n" - "\4 %010f = integer, minimum of 10 digits (zero padded)\n" - "\2\n" - "Values for format specifiers can be specified as additional parameters to sprintf, or within {} in the format specifier (such as %{varname}d, in that case a global variable is always used).\0" - - "matchi\t\"needle\",\"haystack\"[, ...]\tCase-insensitive version of match().\0" - "match\t\"needle\",\"haystack\"[, ...]\tSearches for the first parameter in the second parameter, using a simplified regular expression syntax.\3\n" - "\4* = match 0 or more characters\n" - "\4*? = match 0 or more characters, lazy\n" - "\4+ = match 1 or more characters\n" - "\4+? = match 1 or more characters, lazy\n" - "\4? = match one character\n" - "\2\n" - "You can also use format specifiers to match certain types of data, and optionally put that into a variable:\3\n" - "\4%s means 1 or more chars\n" - "\4%0s means 0 or more chars\n" - "\4%5s means exactly 5 chars\n" - "\4%5-s means 5 or more chars\n" - "\4%-10s means 1-10 chars\n" - "\4%3-5s means 3-5 chars\n" - "\4%0-5s means 0-5 chars\n" - "\4%x, %d, %u, and %f are available for use similarly\n" - "\4%c can be used, but can't take any length modifiers\n" - "\4Use uppercase (%S, %D, etc) for lazy matching\n" - "\2\n" - "See also sprintf() for other notes, including specifying direct variable references via {}.\0" - - "strlen\t\"str\"\tReturns the length of the string passed as a parameter\0" - "strcpy\t#str,\"srcstr\"\tCopies the contents of srcstr to #str, and returns #str\0" - "strcat\t#str,\"srcstr\"\tAppends srcstr to #str, and returns #str\0" - "strcmp\t\"str\",\"str2\"\tCompares strings, returning 0 if equal\0" - "stricmp\t\"str\",\"str2\"\tCompares strings ignoring case, returning 0 if equal\0" - "strncmp\t\"str\",\"str2\",maxlen\tCompares strings giving up after maxlen characters, returning 0 if equal\0" - "strnicmp\t\"str\",\"str2\",maxlen\tCompares strings giving up after maxlen characters, ignoring case, returning 0 if equal\0" - "strncpy\t#str,\"srcstr\",maxlen\tCopies srcstr to #str, stopping after maxlen characters. Returns #str.\0" - "strncat\t#str,\"srcstr\",maxlen\tAppends srcstr to #str, stopping after maxlen characters of srcstr. Returns #str.\0" - "strcpy_from\t#str,\"srcstr\",offset\tCopies srcstr to #str, but starts reading srcstr at offset offset\0" - "strcpy_substr\t#str,\"srcstr\",offs,ml)\tPHP-style (start at offs, offs<0 means from end, ml for maxlen, ml<0 = reduce length by this amt)\0" - "str_getchar\t\"str\",offset[,type]\tReturns the data at byte-offset offset of str. If offset is negative, position is relative to end of string." - "type defaults to signed char, but can be specified to read raw binary data in other formats (note the single quotes, these are single/multi-byte characters):\3\n" - "\4'c' - signed char\n" - "\4'cu' - unsigned char\n" - "\4's' - signed short\n" - "\4'S' - signed short, big endian\n" - "\4'su' - unsigned short\n" - "\4'Su' - unsigned short, big endian\n" - "\4'i' - signed int\n" - "\4'I' - signed int, big endian\n" - "\4'iu' - unsigned int\n" - "\4'Iu' - unsigned int, big endian\n" - "\4'f' - float\n" - "\4'F' - float, big endian\n" - "\4'd' - double\n" - "\4'D' - double, big endian\n" - "\2\0" - "str_setchar\t#str,offset,val[,type])\tSets value at offset offset, type optional. offset may be negative to refer to offset relative to end of string, or between 0 and length, inclusive, and if set to length it will lengthen string. See str_getchar() for more information on types.\0" - "str_setlen\t#str,len\tSets length of #str (if increasing, will be space-padded), and returns #str.\0" - "str_delsub\t#str,pos,len\tDeletes len characters at offset pos from #str, and returns #str.\0" - "str_insert\t#str,\"srcstr\",pos\tInserts srcstr into #str at offset pos. Returns #str\0" -; -#endif - - -#endif - diff --git a/oversampling/WDL/eel2/eelscript.h b/oversampling/WDL/eel2/eelscript.h deleted file mode 100644 index 8d9e66a..0000000 --- a/oversampling/WDL/eel2/eelscript.h +++ /dev/null @@ -1,834 +0,0 @@ -#ifndef _WIN32 -#include - #ifndef EELSCRIPT_NO_LICE - #include "../swell/swell.h" - #endif -#endif - -#include "../wdltypes.h" -#include "../ptrlist.h" -#include "../wdlstring.h" -#include "../assocarray.h" -#include "../queue.h" -#include "../mutex.h" -#include "../win32_utf8.h" -#include "ns-eel.h" - - -#ifndef EELSCRIPT_MAX_FILE_HANDLES -#define EELSCRIPT_MAX_FILE_HANDLES 512 -#endif -#ifndef EELSCRIPT_FILE_HANDLE_INDEX_BASE -#define EELSCRIPT_FILE_HANDLE_INDEX_BASE 1000000 -#endif -#ifndef EEL_STRING_MAXUSERSTRING_LENGTH_HINT -#define EEL_STRING_MAXUSERSTRING_LENGTH_HINT (1<<16) // 64KB per string max -#endif -#ifndef EEL_STRING_MAX_USER_STRINGS -#define EEL_STRING_MAX_USER_STRINGS 32768 -#endif -#ifndef EEL_STRING_LITERAL_BASE -#define EEL_STRING_LITERAL_BASE 2000000 -#endif -#ifndef EELSCRIPT_LICE_MAX_IMAGES -#define EELSCRIPT_LICE_MAX_IMAGES 1024 -#endif - -#ifndef EELSCRIPT_LICE_MAX_FONTS -#define EELSCRIPT_LICE_MAX_FONTS 128 -#endif - -#ifndef EELSCRIPT_NET_MAXCON -#define EELSCRIPT_NET_MAXCON 4096 -#endif - -#ifndef EELSCRIPT_LICE_CLASSNAME -#define EELSCRIPT_LICE_CLASSNAME "eelscript_gfx" -#endif - - -// #define EELSCRIPT_NO_NET -// #define EELSCRIPT_NO_LICE -// #define EELSCRIPT_NO_FILE -// #define EELSCRIPT_NO_FFT -// #define EELSCRIPT_NO_MDCT -// #define EELSCRIPT_NO_EVAL - -class eel_string_context_state; -#ifndef EELSCRIPT_NO_NET -class eel_net_state; -#endif -#ifndef EELSCRIPT_NO_LICE -class eel_lice_state; -#endif - -#ifndef EELSCRIPT_NO_PREPROC -#include "eel_pproc.h" -#endif - -class eelScriptInst { - public: - - static int init(); - - eelScriptInst(); - virtual ~eelScriptInst(); - - NSEEL_CODEHANDLE compile_code(const char *code, const char **err); - int runcode(const char *code, int showerr, const char *showerrfn, bool canfree, bool ignoreEndOfInputChk, bool doExec); - int loadfile(const char *fn, const char *callerfn, bool allowstdin); - - NSEEL_VMCTX m_vm; - - WDL_PtrList m_code_freelist; - -#ifndef EELSCRIPT_NO_FILE - FILE *m_handles[EELSCRIPT_MAX_FILE_HANDLES]; - virtual EEL_F OpenFile(const char *fn, const char *mode) - { - if (!*fn || !*mode) return 0.0; -#ifndef EELSCRIPT_NO_STDIO - if (!strcmp(fn,"stdin")) return 1; - if (!strcmp(fn,"stdout")) return 2; - if (!strcmp(fn,"stderr")) return 3; -#endif - - WDL_FastString fnstr(fn); - if (!translateFilename(&fnstr,mode)) return 0.0; - - int x; - for (x=0;x= EELSCRIPT_MAX_FILE_HANDLES) return 0.0; - - FILE *fp = fopenUTF8(fnstr.Get(),mode); - if (!fp) return 0.0; - m_handles[x]=fp; - return x + EELSCRIPT_FILE_HANDLE_INDEX_BASE; - } - virtual EEL_F CloseFile(int fp_idx) - { - fp_idx-=EELSCRIPT_FILE_HANDLE_INDEX_BASE; - if (fp_idx>=0 && fp_idx=0 && fp_idx m_eval_cache; - virtual char *evalCacheGet(const char *str, NSEEL_CODEHANDLE *ch); - virtual void evalCacheDispose(char *key, NSEEL_CODEHANDLE ch); - WDL_Queue m_defer_eval, m_atexit_eval; - void runCodeQ(WDL_Queue *q, const char *fname); - void runAtExitCode() - { - runCodeQ(&m_atexit_eval,"atexit"); - m_atexit_eval.Clear(); // make sure nothing gets added in atexit(), in case the user called runAtExitCode before destroying - } -#endif - virtual bool run_deferred(); // requires eval support to be useful - virtual bool has_deferred(); - - - WDL_StringKeyedArray m_loaded_fnlist; // imported file list (to avoid repeats) - -#ifndef EELSCRIPT_NO_PREPROC - EEL2_PreProcessor m_preproc; -#endif -}; - -//#define EEL_STRINGS_MUTABLE_LITERALS -//#define EEL_STRING_WANT_MUTEX - - -#define EEL_STRING_GET_CONTEXT_POINTER(opaque) (((eelScriptInst *)opaque)->m_string_context) -#ifndef EEL_STRING_STDOUT_WRITE - #ifndef EELSCRIPT_NO_STDIO - #define EEL_STRING_STDOUT_WRITE(x,len) { fwrite(x,len,1,stdout); fflush(stdout); } - #endif -#endif -#include "eel_strings.h" - -#include "eel_misc.h" - - -#ifndef EELSCRIPT_NO_FILE - #define EEL_FILE_OPEN(fn,mode) ((eelScriptInst*)opaque)->OpenFile(fn,mode) - #define EEL_FILE_GETFP(fp) ((eelScriptInst*)opaque)->GetFileFP(fp) - #define EEL_FILE_CLOSE(fpindex) ((eelScriptInst*)opaque)->CloseFile(fpindex) - - #include "eel_files.h" -#endif - -#ifndef EELSCRIPT_NO_FFT - #include "eel_fft.h" -#endif - -#ifndef EELSCRIPT_NO_MDCT - #include "eel_mdct.h" -#endif - -#ifndef EELSCRIPT_NO_NET - #define EEL_NET_GET_CONTEXT(opaque) (((eelScriptInst *)opaque)->m_net_state) - #include "eel_net.h" -#endif - -#ifndef EELSCRIPT_NO_LICE - #ifndef EEL_LICE_WANT_STANDALONE - #define EEL_LICE_WANT_STANDALONE - #endif - #ifndef EELSCRIPT_LICE_NOUPDATE - #define EEL_LICE_WANT_STANDALONE_UPDATE // gfx_update() which runs message pump and updates screen etc - #endif - - #define EEL_LICE_GET_FILENAME_FOR_STRING(idx, fs, p) (((eelScriptInst*)opaque)->GetFilenameForParameter(idx,fs,p)) - #define EEL_LICE_GET_CONTEXT(opaque) ((opaque) ? (((eelScriptInst *)opaque)->m_gfx_state) : NULL) - #include "eel_lice.h" -#endif - -#ifndef EELSCRIPT_NO_EVAL - #define EEL_EVAL_GET_CACHED(str, ch) ((eelScriptInst *)opaque)->evalCacheGet(str,&(ch)) - #define EEL_EVAL_SET_CACHED(str, ch) ((eelScriptInst *)opaque)->evalCacheDispose(str,ch) - #define EEL_EVAL_GET_VMCTX(opaque) (((eelScriptInst *)opaque)->m_vm) - #define EEL_EVAL_SCOPE_ENTER (((eelScriptInst *)opaque)->m_eval_depth < 3 ? \ - ++((eelScriptInst *)opaque)->m_eval_depth : 0) - #define EEL_EVAL_SCOPE_LEAVE ((eelScriptInst *)opaque)->m_eval_depth--; - #include "eel_eval.h" - -static EEL_F NSEEL_CGEN_CALL _eel_defer(void *opaque, EEL_F *s) -{ - EEL_STRING_MUTEXLOCK_SCOPE - const char *str=EEL_STRING_GET_FOR_INDEX(*s,NULL); - if (str && *str && *s >= EEL_STRING_MAX_USER_STRINGS) // don't allow defer(0) etc - { - eelScriptInst *inst = (eelScriptInst *)opaque; - if (inst->m_defer_eval.Available() < EEL_STRING_MAXUSERSTRING_LENGTH_HINT) - { - inst->m_defer_eval.Add(str,strlen(str)+1); - return 1.0; - } -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("defer(): too much defer() code already added, ignoring"); -#endif - } -#ifdef EEL_STRING_DEBUGOUT - else if (!str) - { - EEL_STRING_DEBUGOUT("defer(): invalid string identifier specified %f",*s); - } - else if (*s < EEL_STRING_MAX_USER_STRINGS) - { - EEL_STRING_DEBUGOUT("defer(): user string identifier %f specified but not allowed",*s); - } -#endif - return 0.0; -} -static EEL_F NSEEL_CGEN_CALL _eel_atexit(void *opaque, EEL_F *s) -{ - EEL_STRING_MUTEXLOCK_SCOPE - const char *str=EEL_STRING_GET_FOR_INDEX(*s,NULL); - if (str && *str && *s >= EEL_STRING_MAX_USER_STRINGS) // don't allow atexit(0) etc - { - eelScriptInst *inst = (eelScriptInst *)opaque; - if (inst->m_atexit_eval.Available() < EEL_STRING_MAXUSERSTRING_LENGTH_HINT) - { - inst->m_atexit_eval.Add(str,strlen(str)+1); - return 1.0; - } -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("atexit(): too much atexit() code already added, ignoring"); -#endif - } -#ifdef EEL_STRING_DEBUGOUT - else if (!str) - { - EEL_STRING_DEBUGOUT("atexit(): invalid string identifier specified %f",*s); - } - else if (*s < EEL_STRING_MAX_USER_STRINGS) - { - EEL_STRING_DEBUGOUT("atexit(): user string identifier %f specified but not allowed",*s); - } -#endif - return 0.0; -} -#endif - - -#define opaque ((void *)this) - -eelScriptInst::eelScriptInst() : m_loaded_fnlist(false) -{ -#ifndef EELSCRIPT_NO_FILE - memset(m_handles,0,sizeof(m_handles)); -#endif - m_vm = NSEEL_VM_alloc(); -#ifdef EEL_STRING_DEBUGOUT - if (!m_vm) EEL_STRING_DEBUGOUT("NSEEL_VM_alloc(): failed"); -#endif - NSEEL_VM_SetCustomFuncThis(m_vm,this); -#ifdef NSEEL_ADDFUNC_DESTINATION - NSEEL_VM_SetFunctionTable(m_vm,NSEEL_ADDFUNC_DESTINATION); -#endif - - m_string_context = new eel_string_context_state; - eel_string_initvm(m_vm); -#ifndef EELSCRIPT_NO_NET - m_net_state = new eel_net_state(EELSCRIPT_NET_MAXCON,NULL); -#endif -#ifndef EELSCRIPT_NO_LICE - m_gfx_state = new eel_lice_state(m_vm,this,EELSCRIPT_LICE_MAX_IMAGES,EELSCRIPT_LICE_MAX_FONTS); - - m_gfx_state->resetVarsToStock(); -#endif -#ifndef EELSCRIPT_NO_EVAL - m_eval_depth=0; -#endif -} - -eelScriptInst::~eelScriptInst() -{ -#ifndef EELSCRIPT_NO_EVAL - if (m_atexit_eval.GetSize()>0) runAtExitCode(); -#endif - int x; - m_code_freelist.Empty((void (*)(void *))NSEEL_code_free); -#ifndef EELSCRIPT_NO_EVAL - for (x=0;xSet(fmt); - return translateFilename(fs,iswrite?"w":"r"); -} - -NSEEL_CODEHANDLE eelScriptInst::compile_code(const char *code, const char **err) -{ - if (!m_vm) - { - *err = "EEL VM not initialized"; - return NULL; - } - -#ifndef EELSCRIPT_NO_PREPROC - WDL_FastString str; - if (strstr(code,EEL2_PREPROCESS_OPEN_TOKEN)) - { - const char *pperr = m_preproc.preprocess(code,&str); - if (pperr) - { - *err = pperr; - return NULL; - } - code = str.Get(); - } - else - m_preproc.clear_line_info(); -#endif - - NSEEL_CODEHANDLE ch = NSEEL_code_compile_ex(m_vm, code, 0, NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS); - if (ch) - { - m_string_context->update_named_vars(m_vm); - m_code_freelist.Add((void*)ch); - return ch; - } - *err = NSEEL_code_getcodeerror(m_vm); -#ifndef EELSCRIPT_NO_PREPROC - if (*err) *err = m_preproc.translate_error_line(*err); -#endif - return NULL; -} - -int eelScriptInst::runcode(const char *codeptr, int showerr, const char *showerrfn, bool canfree, bool ignoreEndOfInputChk, bool doExec) -{ - if (m_vm) - { - const char *err = NULL; - NSEEL_CODEHANDLE code = NULL; -#ifndef EELSCRIPT_NO_PREPROC - WDL_FastString str; - if (strstr(codeptr,EEL2_PREPROCESS_OPEN_TOKEN)) - { - err = m_preproc.preprocess(codeptr,&str); - if (err) goto on_preproc_error; - codeptr = str.Get(); - } - else - m_preproc.clear_line_info(); -#endif - - code = NSEEL_code_compile_ex(m_vm,codeptr,0,canfree ? 0 : NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS); - if (code) m_string_context->update_named_vars(m_vm); - - if (!code && (err=NSEEL_code_getcodeerror(m_vm))) - { - if (!ignoreEndOfInputChk && (NSEEL_code_geterror_flag(m_vm)&1)) return 1; -#ifndef EELSCRIPT_NO_PREPROC - err = m_preproc.translate_error_line(err); -on_preproc_error: -#endif - if (showerr) - { -#ifdef EEL_STRING_DEBUGOUT - if (showerr==2) - { - EEL_STRING_DEBUGOUT("Warning: %s:%s",WDL_get_filepart(showerrfn),err); - } - else - { - EEL_STRING_DEBUGOUT("%s:%s",WDL_get_filepart(showerrfn),err); - } -#endif - } - return -1; - } - else - { - if (code) - { -#ifdef EELSCRIPT_DO_DISASSEMBLE - codeHandleType *p = (codeHandleType*)code; - - char buf[512]; - buf[0]=0; -#ifdef _WIN32 - GetTempPath(sizeof(buf)-64,buf); - lstrcatn(buf,"jsfx-out",sizeof(buf)); -#else - lstrcpyn_safe(buf,"/tmp/jsfx-out",sizeof(buf)); -#endif - FILE *fp = fopenUTF8(buf,"wb"); - if (fp) - { - fwrite(p->code,1,p->code_size,fp); - fclose(fp); - char buf2[2048]; -#ifdef _WIN32 - snprintf(buf2,sizeof(buf2),"disasm \"%s\"",buf); -#else - #ifdef __aarch64__ - snprintf(buf2,sizeof(buf2), "objdump -D -b binary -maarch64 \"%s\"",buf); - #elif defined(__arm__) - snprintf(buf2,sizeof(buf2), "objdump -D -b binary -m arm \"%s\"",buf); - #elif defined(__LP64__) - #ifdef __APPLE__ - snprintf(buf2,sizeof(buf2),"distorm3 --b64 \"%s\"",buf); - #else - snprintf(buf2,sizeof(buf2),"objdump -D -b binary -m i386:x86-64 \"%s\"",buf); - #endif - #else - snprintf(buf2,sizeof(buf2),"distorm3 --b32 \"%s\"",buf); - #endif -#endif - system(buf2); - } -#endif - - if (doExec) NSEEL_code_execute(code); - if (canfree) NSEEL_code_free(code); - else m_code_freelist.Add((void*)code); - } - return 0; - } - } - return -1; -} - - -FILE *eelscript_resolvePath(WDL_FastString &usefn, const char *fn, const char *callerfn) -{ - // resolve path relative to current - int x; - bool had_abs=false; - for (x=0;x<2; x ++) - { -#ifdef _WIN32 - if (!x && ((fn[0] == '\\' && fn[1] == '\\') || (fn[0] && fn[1] == ':'))) -#else - if (!x && fn[0] == '/') -#endif - { - usefn.Set(fn); - had_abs=true; - } - else - { - const char *fnu = fn; - if (x) - { - while (*fnu) fnu++; - while (fnu >= fn && *fnu != '\\' && *fnu != '/') fnu--; - if (fnu < fn) break; - fnu++; - } - - usefn.Set(callerfn); - int l=usefn.GetLength(); - while (l > 0 && usefn.Get()[l-1] != '\\' && usefn.Get()[l-1] != '/') l--; - if (l > 0) - { - usefn.SetLen(l); - usefn.Append(fnu); - } - else - { - usefn.Set(fnu); - } - int last_slash_pos=-1; - for (l = 0; l < usefn.GetLength(); l ++) - { - if (usefn.Get()[l] == '/' || usefn.Get()[l] == '\\') - { - if (usefn.Get()[l+1] == '.' && usefn.Get()[l+2] == '.' && - (usefn.Get()[l+3] == '/' || usefn.Get()[l+3] == '\\')) - { - if (last_slash_pos >= 0) - usefn.DeleteSub(last_slash_pos, l+3-last_slash_pos); - else - usefn.DeleteSub(0,l+3+1); - } - else - { - last_slash_pos=l; - } - } - // take currentfn, remove filename part, add fnu - } - } - - FILE *fp = fopenUTF8(usefn.Get(),"r"); - if (fp) return fp; - } - if (had_abs) usefn.Set(fn); - return NULL; -} - -int eelScriptInst::loadfile(const char *fn, const char *callerfn, bool allowstdin) -{ - WDL_FastString usefn; - FILE *fp = NULL; - if (!strcmp(fn,"-")) - { - if (callerfn) - { -#ifdef EEL_STRING_DEBUGOUT - EEL_STRING_DEBUGOUT("@import: can't import \"-\" (stdin)"); -#endif - return -1; - } - if (allowstdin) - { - fp = stdin; - fn = "(stdin)"; - } - } - else if (!callerfn) - { - fp = fopenUTF8(fn,"r"); - if (fp) m_loaded_fnlist.Insert(fn,true); - } - else - { - fp = eelscript_resolvePath(usefn,fn,callerfn); - if (fp) - { - if (m_loaded_fnlist.Get(usefn.Get())) - { - fclose(fp); - return 0; - } - m_loaded_fnlist.Insert(usefn.Get(),true); - fn = usefn.Get(); - } - } - - if (!fp) - { -#ifdef EEL_STRING_DEBUGOUT - if (callerfn) - EEL_STRING_DEBUGOUT("Warning: @import could not open '%s'",fn); - else - EEL_STRING_DEBUGOUT("Error opening %s",fn); -#endif - return -1; - } - -#ifndef EELSCRIPT_NO_PREPROC - WDL_FastString incpath(fn); - incpath.remove_filepart(); - m_preproc.m_include_paths.Add(incpath.Get()); -#endif - - WDL_FastString code; - char line[4096]; - for (;;) - { - line[0]=0; - fgets(line,sizeof(line),fp); - if (!line[0]) break; - if (!strnicmp(line,"@import",7) && isspace((unsigned char)line[7])) - { - char *p=line+7; - while (isspace((unsigned char)*p)) p++; - - char *ep=p; - while (*ep) ep++; - while (ep>p && isspace((unsigned char)ep[-1])) ep--; - *ep=0; - - if (*p) loadfile(p,fn,false); - } - else - { - code.Append(line); - } - } - if (fp != stdin) fclose(fp); - - int rv = runcode(code.Get(),callerfn ? 2 : 1, fn,false,true,!callerfn); - -#ifndef EELSCRIPT_NO_PREPROC - m_preproc.m_include_paths.Delete(m_preproc.m_include_paths.GetSize()-1); -#endif - - return rv; -} - -char *eelScriptInst::evalCacheGet(const char *str, NSEEL_CODEHANDLE *ch) -{ - // should mutex protect if multiple threads access this eelScriptInst context - int x=m_eval_cache.GetSize(); - while (--x >= 0) - { - char *ret; - if (!strcmp(ret=m_eval_cache.Get()[x].str, str)) - { - *ch = m_eval_cache.Get()[x].ch; - m_eval_cache.Delete(x); - return ret; - } - } - return NULL; -} - -void eelScriptInst::evalCacheDispose(char *key, NSEEL_CODEHANDLE ch) -{ - // should mutex protect if multiple threads access this eelScriptInst context - evalCacheEnt ecc; - ecc.str= key; - ecc.ch = ch; - if (m_eval_cache.GetSize() > 1024) - { - NSEEL_code_free(m_eval_cache.Get()->ch); - free(m_eval_cache.Get()->str); - m_eval_cache.Delete(0); - } - m_eval_cache.Add(ecc); -} - -int eelScriptInst::init() -{ - EEL_string_register(); -#ifndef EELSCRIPT_NO_FILE - EEL_file_register(); -#endif -#ifndef EELSCRIPT_NO_FFT - EEL_fft_register(); -#endif -#ifndef EELSCRIPT_NO_MDCT - EEL_mdct_register(); -#endif - EEL_misc_register(); -#ifndef EELSCRIPT_NO_EVAL - EEL_eval_register(); - NSEEL_addfunc_retval("defer",1,NSEEL_PProc_THIS,&_eel_defer); - NSEEL_addfunc_retval("runloop", 1, NSEEL_PProc_THIS, &_eel_defer); - NSEEL_addfunc_retval("atexit",1,NSEEL_PProc_THIS,&_eel_atexit); -#endif -#ifndef EELSCRIPT_NO_NET - EEL_tcp_register(); -#endif -#ifndef EELSCRIPT_NO_LICE - eel_lice_register(); - #ifdef _WIN32 - eel_lice_register_standalone(GetModuleHandle(NULL),EELSCRIPT_LICE_CLASSNAME,NULL,NULL); - #else - eel_lice_register_standalone(NULL,EELSCRIPT_LICE_CLASSNAME,NULL,NULL); - #endif -#endif - return 0; -} - -bool eelScriptInst::has_deferred() -{ -#ifndef EELSCRIPT_NO_EVAL - return m_defer_eval.Available() && m_vm; -#else - return false; -#endif -} - -#ifndef EELSCRIPT_NO_EVAL -void eelScriptInst::runCodeQ(WDL_Queue *q, const char *callername) -{ - const int endptr = q->Available(); - int offs = 0; - while (offs < endptr) - { - if (q->Available() < endptr) break; // should never happen, but safety first! - - const char *ptr = (const char *)q->Get() + offs; - offs += strlen(ptr)+1; - - NSEEL_CODEHANDLE ch=NULL; - char *sv=evalCacheGet(ptr,&ch); - - if (!sv) sv=strdup(ptr); - if (!ch) ch=NSEEL_code_compile(m_vm,sv,0); - if (!ch) - { - free(sv); -#ifdef EEL_STRING_DEBUGOUT - const char *err = NSEEL_code_getcodeerror(m_vm); - if (err) EEL_STRING_DEBUGOUT("%s: error in code: %s",callername,err); -#endif - } - else - { - NSEEL_code_execute(ch); - evalCacheDispose(sv,ch); - } - } - q->Advance(endptr); -} -#endif - -bool eelScriptInst::run_deferred() -{ -#ifndef EELSCRIPT_NO_EVAL - if (!m_defer_eval.Available()||!m_vm) return false; - - runCodeQ(&m_defer_eval,"defer"); - m_defer_eval.Compact(); - return m_defer_eval.Available()>0; -#else - return false; -#endif -} - -#ifdef EEL_WANT_DOCUMENTATION -#include "ns-eel-func-ref.h" - -void EELScript_GenerateFunctionList(WDL_PtrList *fs) -{ - const char *p = nseel_builtin_function_reference; - while (*p) { fs->Add(p); p += strlen(p) + 1; } - p = eel_strings_function_reference; - while (*p) { fs->Add(p); p += strlen(p) + 1; } - p = eel_misc_function_reference; - while (*p) { fs->Add(p); p += strlen(p) + 1; } -#ifndef EELSCRIPT_NO_EVAL - fs->Add("atexit\t\"code\"\t" -#ifndef EELSCRIPT_HELP_NO_DEFER_DESC - "Adds code to be executed when the script finishes." -#endif - ); - fs->Add("defer\t\"code\"\t" -#ifndef EELSCRIPT_HELP_NO_DEFER_DESC - "Adds code which will be executed some small amount of time after the current code finishes. Identical to runloop()" -#endif - ); - fs->Add("runloop\t\"code\"\t" -#ifndef EELSCRIPT_HELP_NO_DEFER_DESC - "Adds code which will be executed some small amount of time after the current code finishes. Identical to defer()" -#endif - ); - - p = eel_eval_function_reference; - while (*p) { fs->Add(p); p += strlen(p) + 1; } -#endif -#ifndef EELSCRIPT_NO_NET - p = eel_net_function_reference; - while (*p) { fs->Add(p); p += strlen(p) + 1; } -#endif -#ifndef EELSCRIPT_NO_FFT - p = eel_fft_function_reference; - while (*p) { fs->Add(p); p += strlen(p) + 1; } -#endif -#ifndef EELSCRIPT_NO_FILE - p = eel_file_function_reference; - while (*p) { fs->Add(p); p += strlen(p) + 1; } -#endif -#ifndef EELSCRIPT_NO_MDCT - p = eel_mdct_function_reference; - while (*p) { fs->Add(p); p += strlen(p) + 1; } -#endif -#ifndef EELSCRIPT_NO_LICE - p = eel_lice_function_reference; - while (*p) { fs->Add(p); p += strlen(p) + 1; } -#endif - -} - - -#endif - -#undef opaque diff --git a/oversampling/WDL/eel2/glue_aarch64.h b/oversampling/WDL/eel2/glue_aarch64.h deleted file mode 100644 index 671fe65..0000000 --- a/oversampling/WDL/eel2/glue_aarch64.h +++ /dev/null @@ -1,448 +0,0 @@ -#ifndef _NSEEL_GLUE_AARCH64_H_ -#define _NSEEL_GLUE_AARCH64_H_ - -#define GLUE_MOD_IS_64 - -// x0=return value, first parm, x1-x2 parms (x3-x7 more params) -// x8 return struct? -// x9-x15 temporary -// x16-x17 = PLT, linker -// x18 reserved (TLS) -// x19-x28 callee-saved -// x19 = worktable -// x20 = ramtable -// x21 = consttab -// x22 = worktable ptr -// x23-x28 spare -// x29 frame pointer -// x30 link register -// x31 SP/zero - -// x0=p1 -// x1=p2 -// x2=p3 - -// d0 is return value for fp? -// d/v/f0-7 = arguments/results -// 8-15 callee saved -// 16-31 temporary - -// v8-v15 spill registers -#define GLUE_MAX_SPILL_REGS 8 -#define GLUE_SAVE_TO_SPILL_SIZE(x) (4) -#define GLUE_RESTORE_SPILL_TO_FPREG2_SIZE(x) (4) - -static void GLUE_RESTORE_SPILL_TO_FPREG2(void *b, int ws) -{ - *(unsigned int *)b = 0x1e604101 + (ws<<5); // fmov d1, d8+ws -} -static void GLUE_SAVE_TO_SPILL(void *b, int ws) -{ - *(unsigned int *)b = 0x1e604008 + ws; // fmov d8+ws, d0 -} - - -#define GLUE_HAS_FPREG2 1 - -static const unsigned int GLUE_COPY_FPSTACK_TO_FPREG2[] = { 0x1e604001 }; // fmov d1, d0 -static unsigned int GLUE_POP_STACK_TO_FPREG2[] = { - 0xfc4107e1 // ldr d1, [sp], #16 -}; - -#define GLUE_MAX_FPSTACK_SIZE 0 // no stack support -#define GLUE_MAX_JMPSIZE ((1<<20) - 1024) // maximum relative jump size - -// endOfInstruction is end of jump with relative offset, offset passed in is offset from end of dest instruction. -// 0 = current instruction -static void GLUE_JMP_SET_OFFSET(void *endOfInstruction, int offset) -{ - unsigned int *a = (unsigned int*) endOfInstruction - 1; - offset += 4; - offset >>= 2; // as dwords - if ((a[0] & 0xFC000000) == 0x14000000) - { - // NC b = 0x14 + 26 bit offset - a[0] = 0x14000000 | (offset & 0x3FFFFFF); - } - else if ((a[0] & 0xFF000000) == 0x54000000) - { - // condb = 0x54 + 20 bit offset + 5 bit condition: 0=eq, 1=ne, b=lt, c=gt, d=le, a=ge - a[0] = 0x54000000 | (a[0] & 0xF) | ((offset & 0x7FFFF) << 5); - } -} - -static const unsigned int GLUE_JMP_NC[] = { 0x14000000 }; - -static const unsigned int GLUE_JMP_IF_P1_Z[]= -{ - 0x7100001f, // cmp w0, #0 - 0x54000000, // b.eq -}; -static const unsigned int GLUE_JMP_IF_P1_NZ[]= -{ - 0x7100001f, // cmp w0, #0 - 0x54000001, // b.ne -}; - -#define GLUE_MOV_PX_DIRECTVALUE_TOFPREG2_SIZE 16 // wr=-2, sets d1 -#define GLUE_MOV_PX_DIRECTVALUE_SIZE 12 -static void GLUE_MOV_PX_DIRECTVALUE_GEN(void *b, INT_PTR v, int wv) -{ - static const unsigned int tab[3] = { - 0xd2800000, // mov x0, #0000 (val<<5) | reg - 0xf2a00000, // movk x0, #0000, lsl 16 (val<<5) | reg - 0xf2c00000, // movk x0, #0000, lsl 32 (val<<5) | reg - }; - // 0xABAAA, B is register, A are bits of word - unsigned int *p=(unsigned int *)b; - int wvo = wv; - if (wv<0) wv=0; - p[0] = tab[0] | wv | ((v&0xFFFF)<<5); - p[1] = tab[1] | wv | (((v>>16)&0xFFFF)<<5); - p[2] = tab[2] | wv | (((v>>32)&0xFFFF)<<5); - if (wvo == -2) p[3] = 0xfd400001; // ldr d1, [x0] -} - -const static unsigned int GLUE_FUNC_ENTER[2] = { 0xa9bf7bfd, 0x910003fd }; // stp x29, x30, [sp, #-16]! ; mov x29, sp -#define GLUE_FUNC_ENTER_SIZE 4 -const static unsigned int GLUE_FUNC_LEAVE[1] = { 0 }; // let GLUE_RET pop -#define GLUE_FUNC_LEAVE_SIZE 0 -const static unsigned int GLUE_RET[]={ 0xa8c17bfd, 0xd65f03c0 }; // ldp x29,x30, [sp], #16 ; ret - -static int GLUE_RESET_WTP(unsigned char *out, void *ptr) -{ - const static unsigned int GLUE_SET_WTP_FROM_R19 = 0xaa1303f6; // mov r22, r19 - if (out) memcpy(out,&GLUE_SET_WTP_FROM_R19,sizeof(GLUE_SET_WTP_FROM_R19)); - return 4; -} - - -const static unsigned int GLUE_PUSH_P1[1]={ 0xf81f0fe0 }; // str x0, [sp, #-16]! - -#define GLUE_STORE_P1_TO_STACK_AT_OFFS_SIZE(offs) ((offs)>=32768 ? 8 : 4) -static void GLUE_STORE_P1_TO_STACK_AT_OFFS(void *b, int offs) -{ - if (offs >= 32768) - { - // add x1, sp, (offs/4096) lsl 12 - *(unsigned int *)b = 0x914003e1 + ((offs>>12)<<10); - - // str x0, [x1, #offs & 4095] - offs &= 4095; - offs <<= 10-3; - offs &= 0x7FFC00; - ((unsigned int *)b)[1] = 0xf9000020 + offs; - } - else - { - // str x0, [sp, #offs] - offs <<= 10-3; - offs &= 0x7FFC00; - *(unsigned int *)b = 0xf90003e0 + offs; - } -} - -#define GLUE_MOVE_PX_STACKPTR_SIZE 4 -static void GLUE_MOVE_PX_STACKPTR_GEN(void *b, int wv) -{ - // mov xX, sp - *(unsigned int *)b = 0x910003e0 + wv; -} - -#define GLUE_MOVE_STACK_SIZE 4 -static void GLUE_MOVE_STACK(void *b, int amt) -{ - if (amt>=0) - { - if (amt >= 4096) - *(unsigned int*)b = 0x914003ff | (((amt+4095)>>12)<<10); - else - *(unsigned int*)b = 0x910003ff | (amt << 10); - } - else - { - amt = -amt; - if (amt >= 4096) - *(unsigned int*)b = 0xd14003ff | (((amt+4095)>>12)<<10); - else - *(unsigned int*)b = 0xd10003ff | (amt << 10); - } -} - -#define GLUE_POP_PX_SIZE 4 -static void GLUE_POP_PX(void *b, int wv) -{ - ((unsigned int *)b)[0] = 0xf84107e0 | wv; // ldr x, [sp], 16 -} - -#define GLUE_SET_PX_FROM_P1_SIZE 4 -static void GLUE_SET_PX_FROM_P1(void *b, int wv) -{ - *(unsigned int *)b = 0xaa0003e0 | wv; -} - - -static const unsigned int GLUE_PUSH_P1PTR_AS_VALUE[] = -{ - 0xfd400007, // ldr d7, [x0] - 0xfc1f0fe7, // str d7, [sp, #-16]! -}; - -static int GLUE_POP_VALUE_TO_ADDR(unsigned char *buf, void *destptr) -{ - if (buf) - { - unsigned int *bufptr = (unsigned int *)buf; - *bufptr++ = 0xfc4107e7; // ldr d7, [sp], #16 - GLUE_MOV_PX_DIRECTVALUE_GEN(bufptr, (INT_PTR)destptr,0); - bufptr += GLUE_MOV_PX_DIRECTVALUE_SIZE/4; - *bufptr++ = 0xfd000007; // str d7, [x0] - } - return 2*4 + GLUE_MOV_PX_DIRECTVALUE_SIZE; -} - -static int GLUE_COPY_VALUE_AT_P1_TO_PTR(unsigned char *buf, void *destptr) -{ - if (buf) - { - unsigned int *bufptr = (unsigned int *)buf; - *bufptr++ = 0xfd400007; // ldr d7, [x0] - GLUE_MOV_PX_DIRECTVALUE_GEN(bufptr, (INT_PTR)destptr,0); - bufptr += GLUE_MOV_PX_DIRECTVALUE_SIZE/4; - *bufptr++ = 0xfd000007; // str d7, [x0] - } - return 2*4 + GLUE_MOV_PX_DIRECTVALUE_SIZE; -} - - -#define GLUE_CALL_CODE(bp, cp, rt) do { \ - GLUE_SCR_TYPE f; \ - static const double consttab[] = { \ - NSEEL_CLOSEFACTOR, \ - 0.0, \ - 1.0, \ - -1.0, \ - -0.5, /* for invsqrt */ \ - 1.5, \ - }; \ - if (!(h->compile_flags&NSEEL_CODE_COMPILE_FLAG_NOFPSTATE) && \ - !((f=glue_getscr())&(1<<24))) { \ - glue_setscr(f|(1<<24)); \ - eel_callcode64(bp, cp, rt, (void *)consttab); \ - glue_setscr(f); \ - } else eel_callcode64(bp, cp, rt, (void *)consttab);\ - } while(0) - -#ifndef _MSC_VER -static void eel_callcode64(INT_PTR bp, INT_PTR cp, INT_PTR rt, void *consttab) -{ - __asm__( - "mov x1, %2\n" - "mov x2, %3\n" - "mov x3, %1\n" - "mov x0, %0\n" - "stp x29, x30, [sp, #-64]!\n" - "stp x18, x20, [sp, 16]\n" - "stp x21, x19, [sp, 32]\n" - "stp x22, x23, [sp, 48]\n" - "mov x29, sp\n" - "mov x19, x3\n" - "mov x20, x1\n" - "mov x21, x2\n" - "blr x0\n" - "ldp x29, x30, [sp], 16\n" - "ldp x18, x20, [sp], 16\n" - "ldp x21, x19, [sp], 16\n" - "ldp x22, x23, [sp], 16\n" - ::"r" (cp), "r" (bp), "r" (rt), "r" (consttab) :"x0","x1","x2","x3","x4","x5","x6","x7", - "x8","x9","x10","x11","x12","x13","x14","x15", - "v8","v9","v10","v11","v12","v13","v14","v15"); - -}; -#else -void eel_callcode64(INT_PTR bp, INT_PTR cp, INT_PTR rt, void *consttab); -#endif - -static unsigned char *EEL_GLUE_set_immediate(void *_p, INT_PTR newv) -{ - unsigned int *p=(unsigned int *)_p; - WDL_ASSERT(!(newv>>48)); -// 0xd2800000, // mov x0, #0000 (val<<5) | reg - // 0xf2a00000, // movk x0, #0000, lsl 16 (val<<5) | reg - // 0xf2c00000, // movk x0, #0000, lsl 32 (val<<5) | reg - while (((p[0]>>5)&0xffff)!=0xdead || - ((p[1]>>5)&0xffff)!=0xbeef || - ((p[2]>>5)&0xffff)!=0xbeef) p++; - - p[0] = (p[0] & 0xFFE0001F) | ((newv&0xffff)<<5); - p[1] = (p[1] & 0xFFE0001F) | (((newv>>16)&0xffff)<<5); - p[2] = (p[2] & 0xFFE0001F) | (((newv>>32)&0xffff)<<5); - - return (unsigned char *)(p+2); -} - -#define GLUE_SET_PX_FROM_WTP_SIZE sizeof(int) -static void GLUE_SET_PX_FROM_WTP(void *b, int wv) -{ - *(unsigned int *)b = 0xaa1603e0 + wv; // mov x, x22 -} - -static int GLUE_POP_FPSTACK_TO_PTR(unsigned char *buf, void *destptr) -{ - if (buf) - { - unsigned int *bufptr = (unsigned int *)buf; - GLUE_MOV_PX_DIRECTVALUE_GEN(bufptr, (INT_PTR)destptr,0); - bufptr += GLUE_MOV_PX_DIRECTVALUE_SIZE/4; - - *bufptr++ = 0xfd000000; // str d0, [x0] - } - return GLUE_MOV_PX_DIRECTVALUE_SIZE + sizeof(int); -} - -#define GLUE_POP_FPSTACK_SIZE 0 -static const unsigned int GLUE_POP_FPSTACK[1] = { 0 }; // no need to pop, not a stack - -static const unsigned int GLUE_POP_FPSTACK_TOSTACK[] = { - 0xfc1f0fe0, // str d0, [sp, #-16]! - -}; - -static const unsigned int GLUE_POP_FPSTACK_TO_WTP[] = { - 0xfc0086c0, // str d0, [x22], #8 -}; - -#define GLUE_PUSH_VAL_AT_PX_TO_FPSTACK_SIZE 4 -static void GLUE_PUSH_VAL_AT_PX_TO_FPSTACK(void *b, int wv) -{ - *(unsigned int *)b = 0xfd400000 + (wv<<5); // ldr d0, [xX] -} - -#define GLUE_POP_FPSTACK_TO_WTP_TO_PX_SIZE (sizeof(GLUE_POP_FPSTACK_TO_WTP) + GLUE_SET_PX_FROM_WTP_SIZE) -static void GLUE_POP_FPSTACK_TO_WTP_TO_PX(unsigned char *buf, int wv) -{ - GLUE_SET_PX_FROM_WTP(buf,wv); - memcpy(buf + GLUE_SET_PX_FROM_WTP_SIZE,GLUE_POP_FPSTACK_TO_WTP,sizeof(GLUE_POP_FPSTACK_TO_WTP)); -}; - -static const unsigned int GLUE_SET_P1_Z[] = { 0x52800000 }; // mov w0, #0 -static const unsigned int GLUE_SET_P1_NZ[] = { 0x52800020 }; // mov w0, #1 - - -static void *GLUE_realAddress(void *fn, int *size) -{ - while ((*(int*)fn & 0xFC000000) == 0x14000000) - { - int offset = (*(int*)fn & 0x3FFFFFF); - if (offset & 0x2000000) - offset |= 0xFC000000; - - fn = (int*)fn + offset; - } - static const unsigned int sig[] = { -#ifndef _MSC_VER - 0xaa0003e0, -#endif - 0xaa0103e1, -#ifndef _MSC_VER - 0xaa0203e2 -#endif - }; - unsigned char *p = (unsigned char *)fn; - - while (memcmp(p,sig,sizeof(sig))) p+=4; - p+=sizeof(sig); - fn = p; - - while (memcmp(p,sig,sizeof(sig))) p+=4; - *size = p - (unsigned char *)fn; - return fn; -} - - - -#ifndef _MSC_VER -#define GLUE_SCR_TYPE unsigned long -static unsigned long __attribute__((unused)) glue_getscr() -{ - unsigned long rv; - asm volatile ( "mrs %0, fpcr" : "=r" (rv)); - return rv; -} -static void __attribute__((unused)) glue_setscr(unsigned long v) -{ - asm volatile ( "msr fpcr, %0" :: "r"(v)); -} -#else -#define GLUE_SCR_TYPE unsigned long long -GLUE_SCR_TYPE glue_getscr(); -void glue_setscr(unsigned long long); -#endif - -void eel_enterfp(int _s[2]) -{ - GLUE_SCR_TYPE *s = (GLUE_SCR_TYPE*)_s; - s[0] = glue_getscr(); - glue_setscr(s[0] | (1<<24)); -} -void eel_leavefp(int _s[2]) -{ - const GLUE_SCR_TYPE *s = (GLUE_SCR_TYPE*)_s; - glue_setscr(s[0]); -} - -#define GLUE_HAS_FUSE 1 -static int GLUE_FUSE(compileContext *ctx, unsigned char *code, int left_size, int right_size, int fuse_flags, int spill_reg) -{ - if (left_size>=4 && right_size == 4) - { - unsigned int instr = ((unsigned int *)code)[-1]; - if (spill_reg >= 0 && (instr & 0xfffffc1f) == 0x1e604001) // fmov d1, dX - { - const int src_reg = (instr>>5)&0x1f; - if (src_reg == spill_reg + 8) - { - instr = ((unsigned int *)code)[0]; - if ((instr & 0xffffcfff) == 0x1e600820) - { - ((unsigned int *)code)[-1] = instr + ((src_reg-1) << 5); - return -4; - } - } - } - } - return 0; -} - -#ifdef _M_ARM64EC -#define DEF_F1(n) static double eel_##n(double a) { return n(a); } -#define DEF_F2(n) static double eel_##n(double a, double b) { return n(a,b); } -DEF_F1(cos) -#define cos eel_cos -DEF_F1(sin) -#define sin eel_sin -DEF_F1(tan) -#define tan eel_tan -DEF_F1(log) -#define log eel_log -DEF_F1(log10) -#define log10 eel_log10 -DEF_F1(acos) -#define acos eel_acos -DEF_F1(asin) -#define asin eel_asin -DEF_F1(atan) -#define atan eel_atan -DEF_F1(exp) -#define exp eel_exp -DEF_F2(pow) -#define pow eel_pow -DEF_F2(atan2) -#define atan2 eel_atan2 -// ceil and floor will be wrapped by defs in nseel-compiler.c - -#pragma comment(lib,"onecore.lib") -#endif - - -#endif diff --git a/oversampling/WDL/eel2/glue_arm.h b/oversampling/WDL/eel2/glue_arm.h deleted file mode 100644 index ab9ec73..0000000 --- a/oversampling/WDL/eel2/glue_arm.h +++ /dev/null @@ -1,335 +0,0 @@ -#ifndef _NSEEL_GLUE_ARM_H_ -#define _NSEEL_GLUE_ARM_H_ - -// r0=return value, first parm, r1-r2 parms -// r3+ should be reserved -// blx addr -// stmfd sp!, {register list, lr} -// ldmfd sp!, {register list, pc} - -// let's make r8 = worktable -// let's make r7 = ramtable -// r6 = consttab -// r5 = worktable ptr - -// r0=p1 -// r1=p2 -// r2=p3 - -// d0 is return value? - - -#define GLUE_HAS_FPREG2 1 - -static const unsigned int GLUE_COPY_FPSTACK_TO_FPREG2[] = { - 0xeeb01b40 // fcpyd d1, d0 -}; - -static unsigned int GLUE_POP_STACK_TO_FPREG2[] = { - 0xed9d1b00,// vldr d1, [sp] - 0xe28dd008,// add sp, sp, #8 -}; - -#define GLUE_MAX_SPILL_REGS 8 -#define GLUE_SAVE_TO_SPILL_SIZE(x) (4) -#define GLUE_RESTORE_SPILL_TO_FPREG2_SIZE(x) (4) - -static void GLUE_RESTORE_SPILL_TO_FPREG2(void *b, int ws) -{ - *(unsigned int *)b = 0xeeb01b48 + ws; // fcpyd d1, d8+ws -} -static void GLUE_SAVE_TO_SPILL(void *b, int ws) -{ - *(unsigned int *)b = 0xeeb08b40 + (ws<<12); // fcpyd d8+ws, d0 -} - - -#define GLUE_MAX_FPSTACK_SIZE 0 // no stack support -#define GLUE_MAX_JMPSIZE ((1<<25) - 1024) // maximum relative jump size - -// endOfInstruction is end of jump with relative offset, offset passed in is offset from end of dest instruction. -// TODO: verify, but offset probably from next instruction (PC is ahead) -#define GLUE_JMP_SET_OFFSET(endOfInstruction,offset) (((int *)(endOfInstruction))[-1] = (((int *)(endOfInstruction))[-1]&0xFF000000)|((((offset)>>2)-1))) - - // /=conditional=always = 0xE - // |/= 101(L), so 8+2+0 = 10 = A -static const unsigned int GLUE_JMP_NC[] = { 0xEA000000 }; - -static const unsigned int GLUE_JMP_IF_P1_Z[]= -{ - 0xe1100000, // tst r0, r0 - 0x0A000000, // branch if Z set -}; -static const unsigned int GLUE_JMP_IF_P1_NZ[]= -{ - 0xe1100000, // tst r0, r0 - 0x1A000000, // branch if Z clear -}; - -#define GLUE_MOV_PX_DIRECTVALUE_TOFPREG2_SIZE 12 // wr=-2, sets d1 -#define GLUE_MOV_PX_DIRECTVALUE_SIZE 8 -static void GLUE_MOV_PX_DIRECTVALUE_GEN(void *b, INT_PTR v, int wv) -{ - // requires ARMv6thumb2 or later - const unsigned int reg_add = wdl_max(wv,0) << 12; - static const unsigned int tab[2] = { - 0xe3000000, // movw r0, #0000 - 0xe3400000, // movt r0, #0000 - }; - // 0xABAAA, B is register, A are bits of word - unsigned int *p=(unsigned int *)b; - p[0] = tab[0] | reg_add | (v&0xfff) | ((v&0xf000)<<4); - p[1] = tab[1] | reg_add | ((v>>16)&0xfff) | ((v&0xf0000000)>>12); - if (wv == -2) p[2] = 0xed901b00; // fldd d1, [r0] -} - -const static unsigned int GLUE_FUNC_ENTER[1] = { 0xe92d4010 }; // push {r4, lr} -#define GLUE_FUNC_ENTER_SIZE 4 -const static unsigned int GLUE_FUNC_LEAVE[1] = { 0 }; // let GLUE_RET pop -#define GLUE_FUNC_LEAVE_SIZE 0 -const static unsigned int GLUE_RET[]={ 0xe8bd8010 }; // pop {r4, pc} - -static int GLUE_RESET_WTP(unsigned char *out, void *ptr) -{ - const static unsigned int GLUE_SET_WTP_FROM_R8 = 0xe1a05008; // mov r5, r8 - if (out) memcpy(out,&GLUE_SET_WTP_FROM_R8,sizeof(GLUE_SET_WTP_FROM_R8)); - return sizeof(GLUE_SET_WTP_FROM_R8); -} - - -const static unsigned int GLUE_PUSH_P1[1]={ 0xe52d0008 }; // push {r0}, aligned to 8 - - -static int arm_encode_constforalu(int amt) -{ - int nrot = 16; - while (amt >= 0x100 && nrot > 1) - { - // ARM encodes integers for ALU operations as rotated right by third nibble*2 - amt = (amt + 3)>>2; - nrot--; - } - return ((nrot&15) << 8) | amt; -} - - -#define GLUE_STORE_P1_TO_STACK_AT_OFFS_SIZE(x) ((x)>=4096 ? 8 : 4) -static void GLUE_STORE_P1_TO_STACK_AT_OFFS(void *b, int offs) -{ - if (offs >= 4096) - { - // add r2, sp, (offs&~4095) - *(unsigned int *)b = 0xe28d2000 | arm_encode_constforalu(offs&~4095); - // str r0, [r2, offs&4095] - ((unsigned int *)b)[1] = 0xe5820000 + (offs&4095); - } - else - { - // str r0, [sp, #offs] - *(unsigned int *)b = 0xe58d0000 + offs; - } -} - -#define GLUE_MOVE_PX_STACKPTR_SIZE 4 -static void GLUE_MOVE_PX_STACKPTR_GEN(void *b, int wv) -{ - // mov rX, sp - *(unsigned int *)b = 0xe1a0000d + (wv<<12); -} - -#define GLUE_MOVE_STACK_SIZE 4 -static void GLUE_MOVE_STACK(void *b, int amt) -{ - unsigned int instr = 0xe28dd000; - if (amt < 0) - { - instr = 0xe24dd000; - amt=-amt; - } - *(unsigned int*)b = instr | arm_encode_constforalu(amt); -} - -#define GLUE_POP_PX_SIZE 4 -static void GLUE_POP_PX(void *b, int wv) -{ - ((unsigned int *)b)[0] = 0xe49d0008 | (wv<<12); // pop {rX}, aligned to 8 -} - -#define GLUE_SET_PX_FROM_P1_SIZE 4 -static void GLUE_SET_PX_FROM_P1(void *b, int wv) -{ - *(unsigned int *)b = 0xe1a00000 | (wv<<12); // mov rX, r0 -} - - -static const unsigned int GLUE_PUSH_P1PTR_AS_VALUE[] = -{ - 0xed907b00, // fldd d7, [r0] - 0xe24dd008, // sub sp, sp, #8 - 0xed8d7b00, // fstd d7, [sp] -}; - -static int GLUE_POP_VALUE_TO_ADDR(unsigned char *buf, void *destptr) -{ - if (buf) - { - unsigned int *bufptr = (unsigned int *)buf; - *bufptr++ = 0xed9d7b00; // fldd d7, [sp] - *bufptr++ = 0xe28dd008; // add sp, sp, #8 - GLUE_MOV_PX_DIRECTVALUE_GEN(bufptr, (INT_PTR)destptr,0); - bufptr += GLUE_MOV_PX_DIRECTVALUE_SIZE/4; - *bufptr++ = 0xed807b00; // fstd d7, [r0] - } - return 3*4 + GLUE_MOV_PX_DIRECTVALUE_SIZE; -} - -static int GLUE_COPY_VALUE_AT_P1_TO_PTR(unsigned char *buf, void *destptr) -{ - if (buf) - { - unsigned int *bufptr = (unsigned int *)buf; - *bufptr++ = 0xed907b00; // fldd d7, [r0] - GLUE_MOV_PX_DIRECTVALUE_GEN(bufptr, (INT_PTR)destptr,0); - bufptr += GLUE_MOV_PX_DIRECTVALUE_SIZE/4; - *bufptr++ = 0xed807b00; // fstd d7, [r0] - } - return 2*4 + GLUE_MOV_PX_DIRECTVALUE_SIZE; -} - - -#ifndef _MSC_VER -#define GLUE_CALL_CODE(bp, cp, rt) do { \ - unsigned int f; \ - if (!(h->compile_flags&NSEEL_CODE_COMPILE_FLAG_NOFPSTATE) && \ - !((f=glue_getscr())&(1<<24))) { \ - glue_setscr(f|(1<<24)); \ - eel_callcode32(bp, cp, rt); \ - glue_setscr(f); \ - } else eel_callcode32(bp, cp, rt);\ - } while(0) - -static const double __consttab[] = { - NSEEL_CLOSEFACTOR, - 0.0, - 1.0, - -1.0, - -0.5, // for invsqrt - 1.5, - }; - -static void eel_callcode32(INT_PTR bp, INT_PTR cp, INT_PTR rt) -{ - __asm__ volatile( - "mov r7, %2\n" - "mov r6, %3\n" - "mov r8, %1\n" - "mov r0, %0\n" - "mov r1, sp\n" - "bic sp, sp, #7\n" - "push {r1, lr}\n" - "blx r0\n" - "pop {r1, lr}\n" - "mov sp, r1\n" - ::"r" (cp), "r" (bp), "r" (rt), "r" (__consttab) : - "r5", "r6", "r7", "r8", "r10", - "d8","d9","d10","d11","d12","d13","d14","d15"); -}; -#endif - -static unsigned char *EEL_GLUE_set_immediate(void *_p, INT_PTR newv) -{ - unsigned int *p=(unsigned int *)_p; - while ((p[0]&0x000F0FFF) != 0x000d0ead && - (p[1]&0x000F0FFF) != 0x000b0eef) p++; - p[0] = (p[0]&0xFFF0F000) | (newv&0xFFF) | ((newv << 4) & 0xF0000); - p[1] = (p[1]&0xFFF0F000) | ((newv>>16)&0xFFF) | ((newv >> 12)&0xF0000); - - return (unsigned char *)(p+1); -} - -#define GLUE_SET_PX_FROM_WTP_SIZE sizeof(int) -static void GLUE_SET_PX_FROM_WTP(void *b, int wv) -{ - *(unsigned int *)b = 0xe1a00005 + (wv<<12); // mov rX, r5 -} - -static int GLUE_POP_FPSTACK_TO_PTR(unsigned char *buf, void *destptr) -{ - if (buf) - { - unsigned int *bufptr = (unsigned int *)buf; - GLUE_MOV_PX_DIRECTVALUE_GEN(bufptr, (INT_PTR)destptr,0); - bufptr += GLUE_MOV_PX_DIRECTVALUE_SIZE/4; - - *bufptr++ = 0xed800b00; // fstd d0, [r0] - } - return GLUE_MOV_PX_DIRECTVALUE_SIZE + sizeof(int); -} - -#define GLUE_POP_FPSTACK_SIZE 0 -static const unsigned int GLUE_POP_FPSTACK[1] = { 0 }; // no need to pop, not a stack - -static const unsigned int GLUE_POP_FPSTACK_TOSTACK[] = { - 0xe24dd008, // sub sp, sp, #8 - 0xed8d0b00, // fstd d0, [sp] -}; - -static const unsigned int GLUE_POP_FPSTACK_TO_WTP[] = { - 0xed850b00, // fstd d0, [r5] - 0xe2855008, // add r5, r5, #8 -}; - -#define GLUE_PUSH_VAL_AT_PX_TO_FPSTACK_SIZE 4 -static void GLUE_PUSH_VAL_AT_PX_TO_FPSTACK(void *b, int wv) -{ - *(unsigned int *)b = 0xed900b00 + (wv<<16); // fldd d0, [rX] -} - -#define GLUE_POP_FPSTACK_TO_WTP_TO_PX_SIZE (sizeof(GLUE_POP_FPSTACK_TO_WTP) + GLUE_SET_PX_FROM_WTP_SIZE) -static void GLUE_POP_FPSTACK_TO_WTP_TO_PX(unsigned char *buf, int wv) -{ - GLUE_SET_PX_FROM_WTP(buf,wv); - memcpy(buf + GLUE_SET_PX_FROM_WTP_SIZE,GLUE_POP_FPSTACK_TO_WTP,sizeof(GLUE_POP_FPSTACK_TO_WTP)); -}; - -static const unsigned int GLUE_SET_P1_Z[] = { 0xe3a00000 }; // mov r0, #0 -static const unsigned int GLUE_SET_P1_NZ[] = { 0xe3a00001 }; // mov r0, #1 - - -static void *GLUE_realAddress(void *fn, int *size) -{ - static const unsigned int sig[3] = { 0xe1a00000, 0xe1a01001, 0xe1a02002 }; - unsigned char *p = (unsigned char *)fn; - - while (memcmp(p,sig,sizeof(sig))) p+=4; - p+=sizeof(sig); - fn = p; - - while (memcmp(p,sig,sizeof(sig))) p+=4; - *size = p - (unsigned char *)fn; - return fn; -} - -static unsigned int __attribute__((unused)) glue_getscr() -{ - unsigned int rv; - asm volatile ( "fmrx %0, fpscr" : "=r" (rv)); - return rv; -} -static void __attribute__((unused)) glue_setscr(unsigned int v) -{ - asm volatile ( "fmxr fpscr, %0" :: "r"(v)); -} - -void eel_enterfp(int s[2]) -{ - s[0] = glue_getscr(); - glue_setscr(s[0] | (1<<24)); // could also do 3<<22 for RTZ -} -void eel_leavefp(int s[2]) -{ - glue_setscr(s[0]); -} - - -#endif diff --git a/oversampling/WDL/eel2/glue_port.h b/oversampling/WDL/eel2/glue_port.h deleted file mode 100644 index e7d06f3..0000000 --- a/oversampling/WDL/eel2/glue_port.h +++ /dev/null @@ -1,1029 +0,0 @@ -#ifndef _EEL_GLUE_PORTABLE_H_ -#define _EEL_GLUE_PORTABLE_H_ - -#define GLUE_MOD_IS_64 - -#define DECL_ASMFUNC(x) -#define GLUE_JMP_TYPE int -#define GLUE_JMP_SET_OFFSET(endOfInstruction,offset) (((GLUE_JMP_TYPE *)(endOfInstruction))[-1] = (offset)) - -#define GLUE_MAX_FPSTACK_SIZE 64 -#define BIF_FPSTACKUSE(x) (0) // fp stack is not used within functions -#define BIF_GETFPSTACKUSE(x) (1) - -enum { - EEL_BC_NOP=1, - EEL_BC_RET, - EEL_BC_JMP_NC, // followed by GLUE_JMP_TYPE - EEL_BC_JMP_IF_P1_Z, - EEL_BC_JMP_IF_P1_NZ, - - EEL_BC_MOV_FPTOP_DV, - EEL_BC_MOV_P1_DV, // followed by INT_PTR ptr - EEL_BC_MOV_P2_DV, - EEL_BC_MOV_P3_DV, - EEL_BC__RESET_WTP, - - EEL_BC_PUSH_P1, - EEL_BC_PUSH_P1PTR_AS_VALUE, - EEL_BC_POP_P1, - EEL_BC_POP_P2, - EEL_BC_POP_P3, - EEL_BC_POP_VALUE_TO_ADDR, - - EEL_BC_MOVE_STACK, - EEL_BC_STORE_P1_TO_STACK_AT_OFFS, - EEL_BC_MOVE_STACKPTR_TO_P1, - EEL_BC_MOVE_STACKPTR_TO_P2, - EEL_BC_MOVE_STACKPTR_TO_P3, - - EEL_BC_SET_P2_FROM_P1, - EEL_BC_SET_P3_FROM_P1, - EEL_BC_COPY_VALUE_AT_P1_TO_ADDR, - EEL_BC_SET_P1_FROM_WTP, - EEL_BC_SET_P2_FROM_WTP, - EEL_BC_SET_P3_FROM_WTP, - - EEL_BC_POP_FPSTACK_TO_PTR, - EEL_BC_POP_FPSTACK_TOSTACK, - - EEL_BC_PUSH_VAL_AT_P1_TO_FPSTACK, - EEL_BC_PUSH_VAL_AT_P2_TO_FPSTACK, - EEL_BC_PUSH_VAL_AT_P3_TO_FPSTACK, - EEL_BC_POP_FPSTACK_TO_WTP, - EEL_BC_SET_P1_Z, - EEL_BC_SET_P1_NZ, - - - EEL_BC_LOOP_LOADCNT, - EEL_BC_LOOP_END, - -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - EEL_BC_WHILE_SETUP, -#endif - - EEL_BC_WHILE_BEGIN, - EEL_BC_WHILE_END, - EEL_BC_WHILE_CHECK_RV, - - - - EEL_BC_BNOT, - EEL_BC_EQUAL, - EEL_BC_EQUAL_EXACT, - EEL_BC_NOTEQUAL, - EEL_BC_NOTEQUAL_EXACT, - EEL_BC_ABOVE, - EEL_BC_BELOWEQ, - - - EEL_BC_ADD, - EEL_BC_SUB, - EEL_BC_MUL, - EEL_BC_DIV, - EEL_BC_AND, - EEL_BC_OR, - EEL_BC_OR0, - EEL_BC_XOR, - - EEL_BC_ADD_OP, - EEL_BC_SUB_OP, - EEL_BC_ADD_OP_FAST, - EEL_BC_SUB_OP_FAST, - EEL_BC_MUL_OP, - EEL_BC_DIV_OP, - EEL_BC_MUL_OP_FAST, - EEL_BC_DIV_OP_FAST, - EEL_BC_AND_OP, - EEL_BC_OR_OP, - EEL_BC_XOR_OP, - - EEL_BC_UMINUS, - - EEL_BC_ASSIGN, - EEL_BC_ASSIGN_FAST, - EEL_BC_ASSIGN_FAST_FROMFP, - EEL_BC_ASSIGN_FROMFP, - EEL_BC_MOD, - EEL_BC_MOD_OP, - EEL_BC_SHR, - EEL_BC_SHL, - - EEL_BC_SQR, - EEL_BC_MIN, - EEL_BC_MAX, - EEL_BC_MIN_FP, - EEL_BC_MAX_FP, - EEL_BC_ABS, - EEL_BC_SIGN, - EEL_BC_INVSQRT, - - EEL_BC_FXCH, - EEL_BC_POP_FPSTACK, - - EEL_BC_FCALL, - EEL_BC_BOOLTOFP, - EEL_BC_FPTOBOOL, - EEL_BC_FPTOBOOL_REV, - - EEL_BC_CFUNC_1PDD, - EEL_BC_CFUNC_2PDD, - EEL_BC_CFUNC_2PDDS, - - EEL_BC_MEGABUF, - EEL_BC_GMEGABUF, - - EEL_BC_GENERIC1PARM, - EEL_BC_GENERIC2PARM, - EEL_BC_GENERIC3PARM, - EEL_BC_GENERIC1PARM_RETD, - EEL_BC_GENERIC2PARM_RETD, - EEL_BC_GENERIC2XPARM_RETD, - EEL_BC_GENERIC3PARM_RETD, - - EEL_BC_USERSTACK_PUSH, - EEL_BC_USERSTACK_POP, - EEL_BC_USERSTACK_POPFAST, - EEL_BC_USERSTACK_PEEK, - EEL_BC_USERSTACK_PEEK_INT, - EEL_BC_USERSTACK_PEEK_TOP, - EEL_BC_USERSTACK_EXCH, - - EEL_BC_DBG_GETSTACKPTR, - -}; - -#define BC_DECL(x) static const EEL_BC_TYPE GLUE_##x[] = { EEL_BC_##x }; -#define BC_DECL_JMP(x) static const EEL_BC_TYPE GLUE_##x[1 + sizeof(GLUE_JMP_TYPE) / sizeof(EEL_BC_TYPE)] = { EEL_BC_##x }; -BC_DECL_JMP(JMP_NC) -BC_DECL_JMP(JMP_IF_P1_Z) -BC_DECL_JMP(JMP_IF_P1_NZ) -BC_DECL(RET) -BC_DECL(FXCH) -BC_DECL(POP_FPSTACK) -#define GLUE_POP_FPSTACK_SIZE sizeof(EEL_BC_TYPE) -BC_DECL(PUSH_P1) -BC_DECL(PUSH_P1PTR_AS_VALUE) -BC_DECL(POP_FPSTACK_TOSTACK) -BC_DECL(POP_FPSTACK_TO_WTP) -BC_DECL(SET_P1_Z) -BC_DECL(SET_P1_NZ) -BC_DECL_JMP(LOOP_LOADCNT) - -BC_DECL_JMP(LOOP_END) - -#define GLUE_LOOP_BEGIN_SIZE 0 -#define GLUE_LOOP_BEGIN ((void*)"") -#define GLUE_LOOP_CLAMPCNT_SIZE 0 -#define GLUE_LOOP_CLAMPCNT ((void*)"") - -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - BC_DECL(WHILE_SETUP) - #define GLUE_WHILE_SETUP_SIZE sizeof(GLUE_WHILE_SETUP) - BC_DECL_JMP(WHILE_END) -#else - #define GLUE_WHILE_SETUP_SIZE 0 - #define GLUE_WHILE_SETUP ((void *)"") - #define GLUE_WHILE_END_NOJUMP - BC_DECL(WHILE_END) -#endif - -BC_DECL(WHILE_BEGIN); -BC_DECL_JMP(WHILE_CHECK_RV) - -#define GLUE_MOV_PX_DIRECTVALUE_SIZE (sizeof(EEL_BC_TYPE) + sizeof(INT_PTR)) -#define GLUE_MOV_PX_DIRECTVALUE_TOSTACK_SIZE GLUE_MOV_PX_DIRECTVALUE_SIZE -static void GLUE_MOV_PX_DIRECTVALUE_GEN(void *b, INT_PTR v, int wv) -{ - static const EEL_BC_TYPE tab[] = { - EEL_BC_MOV_FPTOP_DV, - EEL_BC_MOV_P1_DV, - EEL_BC_MOV_P2_DV, - EEL_BC_MOV_P3_DV, - }; - *(EEL_BC_TYPE *)b = tab[wv+1]; - *(INT_PTR *) ((char *)b + sizeof(EEL_BC_TYPE)) = v; -} - -#define GLUE_FUNC_ENTER_SIZE 0 -#define GLUE_FUNC_LEAVE_SIZE 0 -static const EEL_BC_TYPE GLUE_FUNC_ENTER[1]={-1}; -static const EEL_BC_TYPE GLUE_FUNC_LEAVE[1]={-1}; - -static int GLUE_RESET_WTP(unsigned char *out, void *ptr) -{ - BC_DECL(_RESET_WTP) - if (out) memcpy(out,&GLUE__RESET_WTP,sizeof(GLUE__RESET_WTP)); - if (out) *(void **) (out+sizeof(GLUE__RESET_WTP)) = ptr; - return sizeof(GLUE__RESET_WTP) + sizeof(void *); -} - -#define GLUE_POP_PX_SIZE sizeof(EEL_BC_TYPE) -static void GLUE_POP_PX(void *b, int wv) -{ - static const EEL_BC_TYPE tab[3] ={ - EEL_BC_POP_P1, - EEL_BC_POP_P2, - EEL_BC_POP_P3, - }; - *(EEL_BC_TYPE *)b = tab[wv]; -} - -#define GLUE_SET_PX_FROM_P1_SIZE sizeof(EEL_BC_TYPE) -static void GLUE_SET_PX_FROM_P1(void *b, int wv) -{ - static const unsigned int tab[3]={ - EEL_BC_NOP, - EEL_BC_SET_P2_FROM_P1, - EEL_BC_SET_P3_FROM_P1, - }; - *(EEL_BC_TYPE *)b = tab[wv]; -} - -#define GLUE_MOVE_STACK_SIZE (sizeof(EEL_BC_TYPE) + sizeof(int)) -static void GLUE_MOVE_STACK(void *b, int amt) -{ - *(EEL_BC_TYPE *)b = EEL_BC_MOVE_STACK; - *(int *)(((EEL_BC_TYPE *)b)+1) = amt; -} -#define GLUE_STORE_P1_TO_STACK_AT_OFFS_SIZE(x) (sizeof(EEL_BC_TYPE) + sizeof(int)) -static void GLUE_STORE_P1_TO_STACK_AT_OFFS(void *b, int offs) -{ - *(EEL_BC_TYPE *)b = EEL_BC_STORE_P1_TO_STACK_AT_OFFS; - *(int *)(((EEL_BC_TYPE *)b)+1) = offs; -} - -#define GLUE_MOVE_PX_STACKPTR_SIZE sizeof(EEL_BC_TYPE) -static void GLUE_MOVE_PX_STACKPTR_GEN(void *b, int wv) -{ - static const EEL_BC_TYPE tab[3] = { - EEL_BC_MOVE_STACKPTR_TO_P1, - EEL_BC_MOVE_STACKPTR_TO_P2, - EEL_BC_MOVE_STACKPTR_TO_P3 - }; - *(EEL_BC_TYPE *)b = tab[wv]; -} - - -static int GLUE_POP_VALUE_TO_ADDR(unsigned char *buf, void *destptr) -{ - if (buf) - { - *(EEL_BC_TYPE *)buf = EEL_BC_POP_VALUE_TO_ADDR; - *(void **) (buf+sizeof(EEL_BC_TYPE)) = destptr; - } - return sizeof(EEL_BC_TYPE) + sizeof(void *); -} - -static int GLUE_COPY_VALUE_AT_P1_TO_PTR(unsigned char *buf, void *destptr) -{ - if (buf) - { - *(EEL_BC_TYPE *)buf = EEL_BC_COPY_VALUE_AT_P1_TO_ADDR; - *(void **) (buf+sizeof(EEL_BC_TYPE)) = destptr; - } - return sizeof(EEL_BC_TYPE) + sizeof(void *); -} - - - - -static unsigned char *EEL_GLUE_set_immediate(void *_p, INT_PTR newv) -{ - int mv=5; - char *p=(char*)_p; - p+=sizeof(EEL_BC_TYPE); - while (*(INT_PTR*)p && mv-- > 0) p++; - if (!mv) return (unsigned char *)p; - - *(INT_PTR *)p = newv; - return (unsigned char *) p + sizeof(INT_PTR) - sizeof(EEL_BC_TYPE); -} - -#define GLUE_SET_PX_FROM_WTP_SIZE sizeof(EEL_BC_TYPE) -static void GLUE_SET_PX_FROM_WTP(void *b, int wv) -{ - static const EEL_BC_TYPE tab[3]={ - EEL_BC_SET_P1_FROM_WTP, - EEL_BC_SET_P2_FROM_WTP, - EEL_BC_SET_P3_FROM_WTP, - }; - *(EEL_BC_TYPE *)b = tab[wv]; -} - -static int GLUE_POP_FPSTACK_TO_PTR(unsigned char *buf, void *destptr) -{ - if (buf) - { - *(EEL_BC_TYPE *)buf = EEL_BC_POP_FPSTACK_TO_PTR; - *(void **) (buf+sizeof(EEL_BC_TYPE)) = destptr; - } - return sizeof(EEL_BC_TYPE) + sizeof(void *); -} - - #define GLUE_PUSH_VAL_AT_PX_TO_FPSTACK_SIZE sizeof(EEL_BC_TYPE) - static void GLUE_PUSH_VAL_AT_PX_TO_FPSTACK(void *b, int wv) - { - static const EEL_BC_TYPE tab[3] = { - EEL_BC_PUSH_VAL_AT_P1_TO_FPSTACK, - EEL_BC_PUSH_VAL_AT_P2_TO_FPSTACK, - EEL_BC_PUSH_VAL_AT_P3_TO_FPSTACK, - }; - *(EEL_BC_TYPE *)b = tab[wv]; - } - -#define GLUE_POP_FPSTACK_TO_WTP_TO_PX_SIZE (sizeof(GLUE_POP_FPSTACK_TO_WTP) + GLUE_SET_PX_FROM_WTP_SIZE) -static void GLUE_POP_FPSTACK_TO_WTP_TO_PX(unsigned char *buf, int wv) -{ - GLUE_SET_PX_FROM_WTP(buf,wv); - memcpy(buf + GLUE_SET_PX_FROM_WTP_SIZE,GLUE_POP_FPSTACK_TO_WTP,sizeof(GLUE_POP_FPSTACK_TO_WTP)); -}; - -static unsigned char GLUE_POP_STACK_TO_FPSTACK[1] = { 0 }; // todo - -#define GLUE_INLINE_LOOPS - -// end of bytecode glue, now for stubbage - - -#define BC_DECL_OPCODESZ(n) (1 + ((n)*sizeof(INT_PTR))/sizeof(EEL_BC_TYPE)) -#define BC_DECLASM_N(x,y,n) static EEL_BC_TYPE nseel_asm_##x[1 + BC_DECL_OPCODESZ(n)]={BC_DECL_OPCODESZ(n),EEL_BC_##y }; -#define BC_DECLASM_N2(x,y,n) static EEL_BC_TYPE _asm_##x[1 + BC_DECL_OPCODESZ(n)]={BC_DECL_OPCODESZ(n),EEL_BC_##y }; -#define BC_DECLASM_N_EXPORT(x,y,n) EEL_BC_TYPE _asm_##x[1 + BC_DECL_OPCODESZ(n)]={BC_DECL_OPCODESZ(n),EEL_BC_##y }; -#define BC_DECLASM(x,y) BC_DECLASM_N(x,y,0) - -BC_DECLASM(band,NOP) -BC_DECLASM(bor,NOP) - -BC_DECLASM(bnot,BNOT) -BC_DECLASM(equal,EQUAL) -BC_DECLASM(equal_exact,EQUAL_EXACT) -BC_DECLASM(notequal_exact,NOTEQUAL_EXACT) -BC_DECLASM(notequal,NOTEQUAL) -BC_DECLASM(above,ABOVE) -BC_DECLASM(beloweq,BELOWEQ) - -BC_DECLASM(add,ADD) -BC_DECLASM(sub,SUB) -BC_DECLASM(mul,MUL) -BC_DECLASM(div,DIV) -BC_DECLASM(and,AND) -BC_DECLASM(or,OR) -BC_DECLASM(or0,OR0) -BC_DECLASM(xor,XOR) - -BC_DECLASM(add_op,ADD_OP) -BC_DECLASM(sub_op,SUB_OP) -BC_DECLASM(add_op_fast,ADD_OP_FAST) -BC_DECLASM(sub_op_fast,SUB_OP_FAST) -BC_DECLASM(mul_op,MUL_OP) -BC_DECLASM(div_op,DIV_OP) -BC_DECLASM(mul_op_fast,MUL_OP_FAST) -BC_DECLASM(div_op_fast,DIV_OP_FAST) -BC_DECLASM(and_op,AND_OP) -BC_DECLASM(or_op,OR_OP) -BC_DECLASM(xor_op,XOR_OP) - -BC_DECLASM(uminus,UMINUS) - -BC_DECLASM(assign,ASSIGN) -BC_DECLASM(assign_fast,ASSIGN_FAST) -BC_DECLASM(assign_fast_fromfp,ASSIGN_FAST_FROMFP) -BC_DECLASM(assign_fromfp,ASSIGN_FROMFP) -BC_DECLASM(mod,MOD) -BC_DECLASM(mod_op,MOD_OP) -BC_DECLASM(shr,SHR) -BC_DECLASM(shl,SHL) -BC_DECLASM(sqr,SQR) - -BC_DECLASM(min,MIN) -BC_DECLASM(max,MAX) -BC_DECLASM(min_fp,MIN_FP) -BC_DECLASM(max_fp,MAX_FP) -BC_DECLASM(abs,ABS) -BC_DECLASM(sign,SIGN) -BC_DECLASM(invsqrt,INVSQRT) -BC_DECLASM(dbg_getstackptr,DBG_GETSTACKPTR) - -BC_DECLASM(booltofp,BOOLTOFP) -BC_DECLASM(fptobool,FPTOBOOL) -BC_DECLASM(fptobool_rev,FPTOBOOL_REV) - -BC_DECLASM_N(stack_push,USERSTACK_PUSH,3) -BC_DECLASM_N(stack_pop,USERSTACK_POP,3) -BC_DECLASM_N(stack_pop_fast,USERSTACK_POPFAST,3) -BC_DECLASM_N(stack_peek,USERSTACK_PEEK,3) - -BC_DECLASM_N(stack_peek_int,USERSTACK_PEEK_INT,4) - -BC_DECLASM_N(stack_peek_top,USERSTACK_PEEK_TOP,1) -BC_DECLASM_N(stack_exch,USERSTACK_EXCH,1) - -BC_DECLASM_N(fcall,FCALL,1) - -BC_DECLASM_N(1pdd,CFUNC_1PDD,1) -BC_DECLASM_N(2pdd,CFUNC_2PDD,1) -BC_DECLASM_N(2pdds,CFUNC_2PDDS,1) - -BC_DECLASM_N2(megabuf,MEGABUF,0) -BC_DECLASM_N2(gmegabuf,GMEGABUF,2) - -BC_DECLASM_N_EXPORT(generic1parm,GENERIC1PARM,2) -BC_DECLASM_N_EXPORT(generic2parm,GENERIC2PARM,2) -BC_DECLASM_N_EXPORT(generic3parm,GENERIC3PARM,2) -BC_DECLASM_N_EXPORT(generic1parm_retd,GENERIC1PARM_RETD,2) -BC_DECLASM_N_EXPORT(generic2parm_retd,GENERIC2PARM_RETD,2) -BC_DECLASM_N_EXPORT(generic2xparm_retd,GENERIC2XPARM_RETD,3) -BC_DECLASM_N_EXPORT(generic3parm_retd,GENERIC3PARM_RETD,2) - - - -static void *GLUE_realAddress(void *fn, int *size) -{ - EEL_BC_TYPE *rd = (EEL_BC_TYPE *)fn; - *size = rd[0]*sizeof(EEL_BC_TYPE); - return rd+1; -} - -#define EEL_BC_STACKSIZE (65536) - -// todo: check for stack overflows! we could determine if this is possible at compile time. -#define EEL_BC_STACK_POP_SIZE 8 -#define EEL_BC_STACK_PUSH(type, val) (*(type *)(stackptr -= EEL_BC_STACK_POP_SIZE)) = (val) -#define EEL_BC_STACK_POP() (stackptr += EEL_BC_STACK_POP_SIZE) - -#define EEL_BC_TRUE ((EEL_F*)(INT_PTR)1) - - - - -static void GLUE_CALL_CODE(INT_PTR bp, INT_PTR cp, INT_PTR rt) -{ - char __stack[EEL_BC_STACKSIZE]; - char *iptr = (char*)cp; - char *stackptr=__stack + EEL_BC_STACKSIZE; - EEL_F *p1 = NULL, *p2 = NULL, *p3 = NULL, *wtp = (EEL_F*)bp; -#define fp_top (_fpstacktop[0]) -#define fp_top2 (_fpstacktop[-1]) -#define fp_push(x) *++_fpstacktop=(x) -#define fp_pop() (*_fpstacktop--) -#define fp_rewind(x) (_fpstacktop -= (x)) - - EEL_F fpstack[GLUE_MAX_FPSTACK_SIZE]; - EEL_F *_fpstacktop=fpstack-1; - for (;;) - { - EEL_BC_TYPE inst = *(EEL_BC_TYPE *)iptr; - iptr += sizeof(EEL_BC_TYPE); - switch (inst) - { - case EEL_BC_FXCH: - { - EEL_F a = fp_top; - fp_top=fp_top2; - fp_top2=a; - } - break; - case EEL_BC_POP_FPSTACK: fp_rewind(1); break; - case EEL_BC_NOP: break; - case EEL_BC_RET: - if (EEL_BC_STACK_POP() > __stack+EEL_BC_STACKSIZE) - { - return; - } - iptr = *(void **)(stackptr - EEL_BC_STACK_POP_SIZE); - break; - case EEL_BC_JMP_NC: - iptr += sizeof(GLUE_JMP_TYPE)+*(GLUE_JMP_TYPE *)iptr; - break; - case EEL_BC_JMP_IF_P1_Z: - iptr += p1 ? sizeof(GLUE_JMP_TYPE) : sizeof(GLUE_JMP_TYPE)+*(GLUE_JMP_TYPE *)iptr; - break; - case EEL_BC_JMP_IF_P1_NZ: - iptr += p1 ? sizeof(GLUE_JMP_TYPE)+*(GLUE_JMP_TYPE *)iptr : sizeof(GLUE_JMP_TYPE); - break; - case EEL_BC_MOV_FPTOP_DV: - fp_push(**(EEL_F **)iptr); - iptr += sizeof(void*); - break; - case EEL_BC_MOV_P1_DV: - p1 = *(void **)iptr; - iptr += sizeof(void*); - break; - case EEL_BC_MOV_P2_DV: - p2 = *(void **)iptr; - iptr += sizeof(void*); - break; - case EEL_BC_MOV_P3_DV: - p3 = *(void **)iptr; - iptr += sizeof(void*); - break; - case EEL_BC__RESET_WTP: - wtp = *(void **)iptr; - iptr += sizeof(void*); - break; - case EEL_BC_PUSH_P1: - EEL_BC_STACK_PUSH(void *, p1); - break; - case EEL_BC_PUSH_P1PTR_AS_VALUE: - EEL_BC_STACK_PUSH(EEL_F, *p1); - break; - case EEL_BC_POP_P1: - p1 = *(EEL_F **) stackptr; - EEL_BC_STACK_POP(); - break; - case EEL_BC_POP_P2: - p2 = *(EEL_F **) stackptr; - EEL_BC_STACK_POP(); - break; - case EEL_BC_POP_P3: - p3 = *(EEL_F **) stackptr; - EEL_BC_STACK_POP(); - break; - case EEL_BC_POP_VALUE_TO_ADDR: - **(EEL_F**)iptr = *(EEL_F *)stackptr; - EEL_BC_STACK_POP(); - iptr += sizeof(void*); - break; - case EEL_BC_MOVE_STACK: - stackptr += *(int *)iptr; - iptr += sizeof(int); - break; - case EEL_BC_STORE_P1_TO_STACK_AT_OFFS: - *(void **) (stackptr + *(int *)iptr) = p1; - iptr += sizeof(int); - break; - case EEL_BC_MOVE_STACKPTR_TO_P1: - p1 = (double *)stackptr; - break; - case EEL_BC_MOVE_STACKPTR_TO_P2: - p2 = (double *)stackptr; - break; - case EEL_BC_MOVE_STACKPTR_TO_P3: - p3 = (double *)stackptr; - break; - case EEL_BC_SET_P2_FROM_P1: - p2=p1; - break; - case EEL_BC_SET_P3_FROM_P1: - p3=p1; - break; - case EEL_BC_COPY_VALUE_AT_P1_TO_ADDR: - **(EEL_F **)iptr = *p1; - iptr += sizeof(void*); - break; - case EEL_BC_SET_P1_FROM_WTP: - p1 = wtp; - break; - case EEL_BC_SET_P2_FROM_WTP: - p2 = wtp; - break; - case EEL_BC_SET_P3_FROM_WTP: - p3 = wtp; - break; - case EEL_BC_POP_FPSTACK_TO_PTR: - **((EEL_F **)iptr) = fp_pop(); - iptr += sizeof(void *); - break; - case EEL_BC_POP_FPSTACK_TOSTACK: - EEL_BC_STACK_PUSH(EEL_F, fp_pop()); - break; - case EEL_BC_PUSH_VAL_AT_P1_TO_FPSTACK: - fp_push(*p1); - break; - case EEL_BC_PUSH_VAL_AT_P2_TO_FPSTACK: - fp_push(*p2); - break; - case EEL_BC_PUSH_VAL_AT_P3_TO_FPSTACK: - fp_push(*p3); - break; - case EEL_BC_POP_FPSTACK_TO_WTP: - *wtp++ = fp_pop(); - break; - case EEL_BC_SET_P1_Z: - p1=NULL; - break; - case EEL_BC_SET_P1_NZ: - p1 = EEL_BC_TRUE; - break; - - case EEL_BC_LOOP_LOADCNT: - if ((EEL_BC_STACK_PUSH(int, (int)fp_pop())) < 1) - { - EEL_BC_STACK_POP(); - iptr+= sizeof(GLUE_JMP_TYPE)+*(GLUE_JMP_TYPE *)iptr; - } - else - { - iptr += sizeof(GLUE_JMP_TYPE); -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - if ((*(int *)stackptr) > NSEEL_LOOPFUNC_SUPPORT_MAXLEN) (*(int *)stackptr) = NSEEL_LOOPFUNC_SUPPORT_MAXLEN; -#endif - EEL_BC_STACK_PUSH(void *, wtp); - } - break; - case EEL_BC_LOOP_END: - wtp = *(void **) (stackptr); - if (--(*(int *)(stackptr+EEL_BC_STACK_POP_SIZE)) <= 0) - { - stackptr += EEL_BC_STACK_POP_SIZE*2; - iptr += sizeof(GLUE_JMP_TYPE); - } - else - { - iptr += sizeof(GLUE_JMP_TYPE)+*(GLUE_JMP_TYPE *)iptr; // back to the start! - } - break; - -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - case EEL_BC_WHILE_SETUP: - EEL_BC_STACK_PUSH(int,NSEEL_LOOPFUNC_SUPPORT_MAXLEN); - break; -#endif - case EEL_BC_WHILE_BEGIN: - EEL_BC_STACK_PUSH(void *, wtp); - break; - case EEL_BC_WHILE_END: - wtp = *(EEL_F **) stackptr; - EEL_BC_STACK_POP(); - -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - if (--(*(int *)stackptr) <= 0) - { - EEL_BC_STACK_POP(); - iptr += sizeof(GLUE_JMP_TYPE)+*(GLUE_JMP_TYPE *)iptr; // endpt - } - else - { - iptr += sizeof(GLUE_JMP_TYPE); - } -#endif - break; - case EEL_BC_WHILE_CHECK_RV: - if (p1) - { - iptr += sizeof(GLUE_JMP_TYPE)+*(GLUE_JMP_TYPE *)iptr; // loop - } - else - { - // done -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 - EEL_BC_STACK_POP(); -#endif - iptr += sizeof(GLUE_JMP_TYPE); - } - break; - case EEL_BC_BNOT: - p1 = p1 ? NULL : EEL_BC_TRUE; - break; - case EEL_BC_EQUAL: - p1 = fabs(fp_top - fp_top2) < NSEEL_CLOSEFACTOR ? EEL_BC_TRUE : NULL; - fp_rewind(2); - break; - case EEL_BC_EQUAL_EXACT: - p1 = fp_top == fp_top2 ? EEL_BC_TRUE : NULL; - fp_rewind(2); - break; - case EEL_BC_NOTEQUAL: - p1 = fabs(fp_top - fp_top2) >= NSEEL_CLOSEFACTOR ? EEL_BC_TRUE : NULL; - fp_rewind(2); - break; - case EEL_BC_NOTEQUAL_EXACT: - p1 = fp_top != fp_top2 ? EEL_BC_TRUE : NULL; - fp_rewind(2); - break; - case EEL_BC_ABOVE: - p1 = fp_top < fp_top2 ? EEL_BC_TRUE : NULL; - fp_rewind(2); - break; - case EEL_BC_BELOWEQ: - p1 = fp_top >= fp_top2 ? EEL_BC_TRUE : NULL; - fp_rewind(2); - break; - - case EEL_BC_ADD: - fp_top2 += fp_top; - fp_rewind(1); - break; - case EEL_BC_SUB: - fp_top2 -= fp_top; - fp_rewind(1); - break; - case EEL_BC_MUL: - fp_top2 *= fp_top; - fp_rewind(1); - break; - case EEL_BC_DIV: - fp_top2 /= fp_top; - fp_rewind(1); - break; - case EEL_BC_AND: - fp_top2 = (EEL_F) (((WDL_INT64)fp_top) & (WDL_INT64)(fp_top2)); - fp_rewind(1); - break; - case EEL_BC_OR: - fp_top2 = (EEL_F) (((WDL_INT64)fp_top) | (WDL_INT64)(fp_top2)); - fp_rewind(1); - break; - case EEL_BC_OR0: - fp_top = (EEL_F) ((WDL_INT64)(fp_top)); - break; - case EEL_BC_XOR: - fp_top2 = (EEL_F) (((WDL_INT64)fp_top) ^ (WDL_INT64)(fp_top2)); - fp_rewind(1); - break; - - case EEL_BC_ADD_OP: - *(p1 = p2) = denormal_filter_double2(*p2 + fp_pop()); - break; - case EEL_BC_SUB_OP: - *(p1 = p2) = denormal_filter_double2(*p2 - fp_pop()); - break; - case EEL_BC_ADD_OP_FAST: - *(p1 = p2) += fp_pop(); - break; - case EEL_BC_SUB_OP_FAST: - *(p1 = p2) -= fp_pop(); - break; - case EEL_BC_MUL_OP: - *(p1 = p2) = denormal_filter_double2(*p2 * fp_pop()); - break; - case EEL_BC_DIV_OP: - *(p1 = p2) = denormal_filter_double2(*p2 / fp_pop()); - break; - case EEL_BC_MUL_OP_FAST: - *(p1 = p2) *= fp_pop(); - break; - case EEL_BC_DIV_OP_FAST: - *(p1 = p2) /= fp_pop(); - break; - case EEL_BC_AND_OP: - p1 = p2; - *p2 = (EEL_F) (((WDL_INT64)*p2) & (WDL_INT64)fp_pop()); - break; - case EEL_BC_OR_OP: - p1 = p2; - *p2 = (EEL_F) (((WDL_INT64)*p2) | (WDL_INT64)fp_pop()); - break; - case EEL_BC_XOR_OP: - p1 = p2; - *p2 = (EEL_F) (((WDL_INT64)*p2) ^ (WDL_INT64)fp_pop()); - break; - case EEL_BC_UMINUS: - fp_top = -fp_top; - break; - case EEL_BC_ASSIGN: - *p2 = denormal_filter_double2(*p1); - p1 = p2; - break; - case EEL_BC_ASSIGN_FAST: - *p2 = *p1; - p1 = p2; - break; - case EEL_BC_ASSIGN_FAST_FROMFP: - *p2 = fp_pop(); - p1 = p2; - break; - case EEL_BC_ASSIGN_FROMFP: - *p2 = denormal_filter_double2(fp_pop()); - p1 = p2; - break; - case EEL_BC_MOD: - { - int a = (int) fabs(fp_pop()); - fp_top = a ? (EEL_F) (((WDL_INT64)fabs(fp_top)) % a) : 0.0; - } - break; - case EEL_BC_MOD_OP: - { - int a = (int) fabs(fp_pop()); - *p2 = a ? (EEL_F) (((WDL_INT64)fabs(*p2)) % a) : 0.0; - p1=p2; - - } - break; - case EEL_BC_SHR: - fp_top2 = (EEL_F) (((int)fp_top2) >> (int)fp_top); - fp_rewind(1); - break; - case EEL_BC_SHL: - fp_top2 = (EEL_F) (((int)fp_top2) << (int)fp_top); - fp_rewind(1); - break; - case EEL_BC_SQR: - fp_top *= fp_top; - break; - case EEL_BC_MIN: - if (*p1 > *p2) p1 = p2; - break; - case EEL_BC_MAX: - if (*p1 < *p2) p1 = p2; - break; - case EEL_BC_MIN_FP: - { - EEL_F a=fp_pop(); - if (afp_top) fp_top=a; - } - break; - case EEL_BC_ABS: - fp_top = fabs(fp_top); - break; - case EEL_BC_SIGN: - if (fp_top<0.0) fp_top=-1.0; - else if (fp_top>0.0) fp_top=1.0; - break; - case EEL_BC_DBG_GETSTACKPTR: - fp_top = (int)(stackptr - __stack); - break; - case EEL_BC_INVSQRT: - { - float y = (float)fp_top; - int i = 0x5f3759df - ( (* (int *) &y) >> 1 ); - y = *(float *) &i; - fp_top = y * ( 1.5F - ( (fp_top * 0.5) * y * y ) ); - } - break; - case EEL_BC_FCALL: - { - char *newiptr = *(char **)iptr; - EEL_BC_STACK_PUSH(void *, (iptr += sizeof(void *))); - iptr = newiptr; - } - break; - case EEL_BC_BOOLTOFP: - fp_push(p1 ? 1.0 : 0.0); - break; - case EEL_BC_FPTOBOOL: - p1 = fabs(fp_pop()) >= NSEEL_CLOSEFACTOR ? EEL_BC_TRUE : NULL; - break; - case EEL_BC_FPTOBOOL_REV: - p1 = fabs(fp_pop()) < NSEEL_CLOSEFACTOR ? EEL_BC_TRUE : NULL; - break; - - case EEL_BC_CFUNC_1PDD: - { - double (*f)(double) = *(double (**)(double)) iptr; - fp_top = f(fp_top); - iptr += sizeof(void *); - } - break; - case EEL_BC_CFUNC_2PDD: - { - double (*f)(double,double) = *(double (**)(double,double))iptr; - fp_top2 = f(fp_top2,fp_top); - fp_rewind(1); - iptr += sizeof(void *); - } - break; - case EEL_BC_CFUNC_2PDDS: - { - double (*f)(double,double) = *(double (**)(double,double))iptr; - *p2 = f(*p2,fp_pop()); - p1 = p2; - iptr += sizeof(void *); - } - break; - - case EEL_BC_MEGABUF: - { - unsigned int idx=(unsigned int) (fp_pop() + NSEEL_CLOSEFACTOR); - EEL_F **f = (EEL_F **)rt,*f2; - p1 = (idx < NSEEL_RAM_BLOCKS*NSEEL_RAM_ITEMSPERBLOCK && (f2=f[idx/NSEEL_RAM_ITEMSPERBLOCK])) ? - (f2 + (idx&(NSEEL_RAM_ITEMSPERBLOCK-1))) : - __NSEEL_RAMAlloc((void*)rt,idx); - } - break; - case EEL_BC_GMEGABUF: - { - p1 = __NSEEL_RAMAllocGMEM(*(EEL_F ****)iptr,(int) (fp_pop() + NSEEL_CLOSEFACTOR)); - iptr += sizeof(void *)*2; // also includes ptr to __NSEEL_RAMAllocGMEM, which we ignore - } - break; - case EEL_BC_GENERIC1PARM: - { - EEL_F *(*f)(void *,EEL_F*) = *(EEL_F *(**)(void *, EEL_F *)) (iptr+sizeof(void *)); - p1 = f(*(void **)iptr,p1); - iptr += sizeof(void *)*2; - } - break; - case EEL_BC_GENERIC2PARM: - { - EEL_F *(*f)(void *,EEL_F*,EEL_F*) = *(EEL_F *(**)(void *, EEL_F *, EEL_F *)) (iptr+sizeof(void *)); - p1 = f(*(void **)iptr,p2, p1); - iptr += sizeof(void *)*2; - } - break; - case EEL_BC_GENERIC3PARM: - { - EEL_F *(*f)(void *,EEL_F*,EEL_F*,EEL_F*) = *(EEL_F *(**)(void *, EEL_F *, EEL_F *, EEL_F *)) (iptr+sizeof(void *)); - p1 = f(*(void **)iptr,p3, p2, p1); - iptr += sizeof(void *)*2; - } - break; - case EEL_BC_GENERIC1PARM_RETD: - { - EEL_F (*f)(void *,EEL_F*) = *(EEL_F (**)(void *, EEL_F *)) (iptr+sizeof(void *)); - fp_push(f(*(void **)iptr,p1)); - iptr += sizeof(void *)*2; - } - break; - case EEL_BC_GENERIC2PARM_RETD: - { - EEL_F (*f)(void *,EEL_F*,EEL_F*) = *(EEL_F (**)(void *, EEL_F *, EEL_F *)) (iptr+sizeof(void *)); - fp_push(f(*(void **)iptr,p2, p1)); - iptr += sizeof(void *)*2; - } - break; - case EEL_BC_GENERIC2XPARM_RETD: - { - EEL_F (*f)(void *,void *,EEL_F*,EEL_F*) = *(EEL_F (**)(void *, void *, EEL_F *, EEL_F *)) (iptr+2*sizeof(void *)); - fp_push(f(*(void **)iptr,((void **)iptr)[1],p2, p1)); - iptr += sizeof(void *)*3; - } - break; - case EEL_BC_GENERIC3PARM_RETD: - { - EEL_F (*f)(void *,EEL_F*,EEL_F*,EEL_F*) = *(EEL_F (**)(void *, EEL_F *, EEL_F *, EEL_F *)) (iptr+sizeof(void *)); - fp_push(f(*(void **)iptr,p3, p2, p1)); - iptr += sizeof(void *)*2; - } - break; - - case EEL_BC_USERSTACK_PUSH: - { - UINT_PTR *sptr = *(UINT_PTR **)iptr; - (*sptr) += 8; - (*sptr) &= *(UINT_PTR*)(iptr+sizeof(void *)); - (*sptr) |= *(UINT_PTR*)(iptr+2*sizeof(void *)); - *(EEL_F *)*sptr = *p1; - } - iptr += sizeof(void*)*3; - break; - case EEL_BC_USERSTACK_POP: - { - UINT_PTR *sptr = *(UINT_PTR **)iptr; - *p1 = *(EEL_F *)*sptr; - (*sptr) -= 8; - (*sptr) &= *(UINT_PTR*)(iptr+sizeof(void *)); - (*sptr) |= *(UINT_PTR*)(iptr+2*sizeof(void *)); - } - iptr += sizeof(void*)*3; - break; - case EEL_BC_USERSTACK_POPFAST: - { - UINT_PTR *sptr = *(UINT_PTR **)iptr; - p1 = (EEL_F *)*sptr; - (*sptr) -= 8; - (*sptr) &= *(UINT_PTR*)(iptr+sizeof(void *)); - (*sptr) |= *(UINT_PTR*)(iptr+2*sizeof(void *)); - } - iptr += sizeof(void*)*3; - break; - case EEL_BC_USERSTACK_PEEK: - { - UINT_PTR sptr = **(UINT_PTR **)iptr; - sptr -= sizeof(EEL_F) * (int)(fp_pop()); - sptr &= *(UINT_PTR*)(iptr+sizeof(void *)); - sptr |= *(UINT_PTR*)(iptr+2*sizeof(void *)); - p1 = (EEL_F *)sptr; - } - iptr += sizeof(void*)*3; - break; - case EEL_BC_USERSTACK_PEEK_INT: - { - UINT_PTR sptr = **(UINT_PTR **)iptr; - sptr -= *(UINT_PTR*)(iptr+sizeof(void*)); - sptr &= *(UINT_PTR*)(iptr+2*sizeof(void *)); - sptr |= *(UINT_PTR*)(iptr+3*sizeof(void *)); - p1 = (EEL_F *)sptr; - } - iptr += sizeof(void*)*4; - break; - case EEL_BC_USERSTACK_PEEK_TOP: - p1 = **(EEL_F ***)iptr; - iptr += sizeof(void*); - break; - case EEL_BC_USERSTACK_EXCH: - { - EEL_F *p=**(EEL_F ***)iptr; - EEL_F a=*p; - *p=*p1; - *p1=a; - } - iptr += sizeof(void*); - break; - } - } -#undef fp_top -#undef fp_top2 -#undef fp_pop -#undef fp_push -}; - -#endif diff --git a/oversampling/WDL/eel2/glue_ppc.h b/oversampling/WDL/eel2/glue_ppc.h deleted file mode 100644 index 204959e..0000000 --- a/oversampling/WDL/eel2/glue_ppc.h +++ /dev/null @@ -1,285 +0,0 @@ -#ifndef _NSEEL_GLUE_PPC_H_ -#define _NSEEL_GLUE_PPC_H_ - -#define GLUE_MAX_FPSTACK_SIZE 0 // no stack support -#define GLUE_MAX_JMPSIZE 30000 // maximum relative jump size for this arch (if not defined, any jump is possible) - - -// endOfInstruction is end of jump with relative offset, offset passed in is offset from end of dest instruction. -// on PPC the offset needs to be from the start of the instruction (hence +4), and also the low two bits are flags so -// we make sure they are clear (they should always be clear, anyway, since we always generate 4 byte instructions) -#define GLUE_JMP_SET_OFFSET(endOfInstruction,offset) (((short *)(endOfInstruction))[-1] = ((offset) + 4) & 0xFFFC) - -static const unsigned char GLUE_JMP_NC[] = { 0x48,0, 0, 0, }; // b - -static const unsigned int GLUE_JMP_IF_P1_Z[]= -{ - 0x2f830000, //cmpwi cr7, r3, 0 - 0x419e0000, // beq cr7, offset-bytes-from-startofthisinstruction -}; -static const unsigned int GLUE_JMP_IF_P1_NZ[]= -{ - 0x2f830000, //cmpwi cr7, r3, 0 - 0x409e0000, // bne cr7, offset-bytes-from-startofthisinstruction -}; - - -#define GLUE_MOV_PX_DIRECTVALUE_SIZE 8 -static void GLUE_MOV_PX_DIRECTVALUE_GEN(void *b, INT_PTR v, int wv) -{ - static const unsigned short tab[3][2] = { - {0x3C60, 0x6063}, // addis r3, r0, hw -- ori r3,r3, lw - {0x3DC0, 0x61CE}, // addis r14, r0, hw -- ori r14, r14, lw - {0x3DE0, 0x61EF}, // addis r15, r0, hw -- oris r15, r15, lw - }; - unsigned int uv=(unsigned int)v; - unsigned short *p=(unsigned short *)b; - - *p++ = tab[wv][0]; // addis rX, r0, hw - *p++ = (uv>>16)&0xffff; - *p++ = tab[wv][1]; // ori rX, rX, lw - *p++ = uv&0xffff; -} - - -// mflr r5 -// stwu r5, -16(r1) -const static unsigned int GLUE_FUNC_ENTER[2] = { 0x7CA802A6, 0x94A1FFF0 }; -#define GLUE_FUNC_ENTER_SIZE 8 - -// lwz r5, 0(r1) -// addi r1, r1, 16 -// mtlr r5 -const static unsigned int GLUE_FUNC_LEAVE[3] = { 0x80A10000, 0x38210010, 0x7CA803A6 }; -#define GLUE_FUNC_LEAVE_SIZE 12 - -const static unsigned int GLUE_RET[]={0x4E800020}; // blr - -static int GLUE_RESET_WTP(unsigned char *out, void *ptr) -{ - const static unsigned int GLUE_SET_WTP_FROM_R17=0x7E308B78; // mr r16 (dest), r17 (src) - if (out) memcpy(out,&GLUE_SET_WTP_FROM_R17,sizeof(GLUE_SET_WTP_FROM_R17)); - return sizeof(GLUE_SET_WTP_FROM_R17); - -} - - - -// stwu r3, -16(r1) -const static unsigned int GLUE_PUSH_P1[1]={ 0x9461FFF0}; - - -#define GLUE_POP_PX_SIZE 8 -static void GLUE_POP_PX(void *b, int wv) -{ - static const unsigned int tab[3] ={ - 0x80610000, // lwz r3, 0(r1) - 0x81c10000, // lwz r14, 0(r1) - 0x81e10000, // lwz r15, 0(r1) - }; - ((unsigned int *)b)[0] = tab[wv]; - ((unsigned int *)b)[1] = 0x38210010; // addi r1,r1, 16 -} - -#define GLUE_SET_PX_FROM_P1_SIZE 4 -static void GLUE_SET_PX_FROM_P1(void *b, int wv) -{ - static const unsigned int tab[3]={ - 0x7c631b78, // never used: mr r3, r3 - 0x7c6e1b78, // mr r14, r3 - 0x7c6f1b78, // mr r15, r3 - }; - *(unsigned int *)b = tab[wv]; -} - - - -// lfd f2, 0(r3) -// stfdu f2, -16(r1) -static const unsigned int GLUE_PUSH_P1PTR_AS_VALUE[] = { 0xC8430000, 0xDC41FFF0 }; - -static int GLUE_POP_VALUE_TO_ADDR(unsigned char *buf, void *destptr) -{ - // lfd f2, 0(r1) - // addi r1,r1,16 - // GLUE_MOV_PX_DIRECTVALUE_GEN / GLUE_MOV_PX_DIRECTVALUE_SIZE (r3) - // stfd f2, 0(r3) - if (buf) - { - unsigned int *bufptr = (unsigned int *)buf; - *bufptr++ = 0xC8410000; - *bufptr++ = 0x38210010; - GLUE_MOV_PX_DIRECTVALUE_GEN(bufptr, (INT_PTR)destptr,0); - bufptr += GLUE_MOV_PX_DIRECTVALUE_SIZE/4; - *bufptr++ = 0xd8430000; - } - return 2*4 + GLUE_MOV_PX_DIRECTVALUE_SIZE + 4; -} - -static int GLUE_COPY_VALUE_AT_P1_TO_PTR(unsigned char *buf, void *destptr) -{ - // lfd f2, 0(r3) - // GLUE_MOV_PX_DIRECTVALUE_GEN / GLUE_MOV_PX_DIRECTVALUE_SIZE (r3) - // stfd f2, 0(r3) - - if (buf) - { - unsigned int *bufptr = (unsigned int *)buf; - *bufptr++ = 0xc8430000; - GLUE_MOV_PX_DIRECTVALUE_GEN(bufptr, (INT_PTR)destptr,0); - bufptr += GLUE_MOV_PX_DIRECTVALUE_SIZE/4; - *bufptr++ = 0xd8430000; - } - - return 4 + GLUE_MOV_PX_DIRECTVALUE_SIZE + 4; -} - - -static void GLUE_CALL_CODE(INT_PTR bp, INT_PTR cp, INT_PTR rt) -{ - static const double consttab[] = { - NSEEL_CLOSEFACTOR, - 4503601774854144.0 /* 0x43300000, 0x80000000, used for integer conversion*/, - }; - // we could have r18 refer to the current user-stack pointer, someday, perhaps - __asm__( - "subi r1, r1, 128\n" - "stfd f31, 8(r1)\n" - "stfd f30, 16(r1)\n" - "stmw r13, 32(r1)\n" - "mtctr %0\n" - "mr r17, %1\n" - "mr r13, %2\n" - "lfd f31, 0(%3)\n" - "lfd f30, 8(%3)\n" - "subi r17, r17, 8\n" - "mflr r0\n" - "stw r0, 24(r1)\n" - "bctrl\n" - "lwz r0, 24(r1)\n" - "mtlr r0\n" - "lmw r13, 32(r1)\n" - "lfd f31, 8(r1)\n" - "lfd f30, 16(r1)\n" - "addi r1, r1, 128\n" - ::"r" (cp), "r" (bp), "r" (rt), "r" (consttab)); -}; - -static unsigned char *EEL_GLUE_set_immediate(void *_p, INT_PTR newv) -{ - // 64 bit ppc would take some work - unsigned int *p=(unsigned int *)_p; - while ((p[0]&0x0000FFFF) != 0x0000dead && - (p[1]&0x0000FFFF) != 0x0000beef) p++; - p[0] = (p[0]&0xFFFF0000) | (((newv)>>16)&0xFFFF); - p[1] = (p[1]&0xFFFF0000) | ((newv)&0xFFFF); - - return (unsigned char *)(p+1); -} - - #define GLUE_SET_PX_FROM_WTP_SIZE sizeof(int) - static void GLUE_SET_PX_FROM_WTP(void *b, int wv) - { - static const unsigned int tab[3]={ - 0x7e038378, // mr r3, r16 - 0x7e0e8378, // mr r14, r16 - 0x7e0f8378, // mr r15, r16 - }; - *(unsigned int *)b = tab[wv]; - } - static int GLUE_POP_FPSTACK_TO_PTR(unsigned char *buf, void *destptr) - { - // set r3 to destptr - // stfd f1, 0(r3) - if (buf) - { - unsigned int *bufptr = (unsigned int *)buf; - GLUE_MOV_PX_DIRECTVALUE_GEN(bufptr, (INT_PTR)destptr,0); - bufptr += GLUE_MOV_PX_DIRECTVALUE_SIZE/4; - - *bufptr++ = 0xD8230000; // stfd f1, 0(r3) - } - return GLUE_MOV_PX_DIRECTVALUE_SIZE + sizeof(int); - } - #define GLUE_POP_FPSTACK_SIZE 0 - static const unsigned int GLUE_POP_FPSTACK[1] = { 0 }; // no need to pop, not a stack - - static const unsigned int GLUE_POP_FPSTACK_TOSTACK[] = { - 0xdc21fff0, // stfdu f1, -16(r1) - }; - - static const unsigned int GLUE_POP_FPSTACK_TO_WTP[] = { - 0xdc300008, // stfdu f1, 8(r16) - }; - - #define GLUE_PUSH_VAL_AT_PX_TO_FPSTACK_SIZE 4 - static void GLUE_PUSH_VAL_AT_PX_TO_FPSTACK(void *b, int wv) - { - static const unsigned int tab[3] = { - 0xC8230000, // lfd f1, 0(r3) - 0xC82E0000, // lfd f1, 0(r14) - 0xC82F0000, // lfd f1, 0(r15) - }; - *(unsigned int *)b = tab[wv]; - } - -#define GLUE_POP_FPSTACK_TO_WTP_TO_PX_SIZE (sizeof(GLUE_POP_FPSTACK_TO_WTP) + GLUE_SET_PX_FROM_WTP_SIZE) -static void GLUE_POP_FPSTACK_TO_WTP_TO_PX(unsigned char *buf, int wv) -{ - memcpy(buf,GLUE_POP_FPSTACK_TO_WTP,sizeof(GLUE_POP_FPSTACK_TO_WTP)); - GLUE_SET_PX_FROM_WTP(buf + sizeof(GLUE_POP_FPSTACK_TO_WTP),wv); // ppc preincs the WTP, so we do this after -}; - -static unsigned int GLUE_POP_STACK_TO_FPSTACK[1] = { 0 }; // todo - - -static const unsigned int GLUE_SET_P1_Z[] = { 0x38600000 }; // li r3, 0 -static const unsigned int GLUE_SET_P1_NZ[] = { 0x38600001 }; // li r3, 1 - - -static void *GLUE_realAddress(void *fn, int *size) -{ - // magic numbers: mr r0,r0 ; mr r1,r1 ; mr r2, r2 - static const unsigned char sig[12] = { 0x7c, 0x00, 0x03, 0x78, 0x7c, 0x21, 0x0b, 0x78, 0x7c, 0x42, 0x13, 0x78 }; - unsigned char *p = (unsigned char *)fn; - - while (memcmp(p,sig,sizeof(sig))) p+=4; - p+=sizeof(sig); - fn = p; - - while (memcmp(p,sig,sizeof(sig))) p+=4; - *size = p - (unsigned char *)fn; - return fn; -} - - #define GLUE_STORE_P1_TO_STACK_AT_OFFS_SIZE(x) 4 - static void GLUE_STORE_P1_TO_STACK_AT_OFFS(void *b, int offs) - { - // limited to 32k offset - *(unsigned int *)b = 0x90610000 + (offs&0xffff); - } - - #define GLUE_MOVE_PX_STACKPTR_SIZE 4 - static void GLUE_MOVE_PX_STACKPTR_GEN(void *b, int wv) - { - static const unsigned int tab[3] = - { - 0x7c230b78, // mr r3, r1 - 0x7c2e0b78, // mr r14, r1 - 0x7c2f0b78, // mr r15, r1 - }; - * (unsigned int *)b = tab[wv]; - } - - #define GLUE_MOVE_STACK_SIZE 4 - static void GLUE_MOVE_STACK(void *b, int amt) - { - // this should be updated to allow for more than 32k moves, but no real need - ((unsigned int *)b)[0] = 0x38210000 + (amt&0xffff); // addi r1,r1, amt - } - - - -// end of ppc - -#endif diff --git a/oversampling/WDL/eel2/glue_x86.h b/oversampling/WDL/eel2/glue_x86.h deleted file mode 100644 index d987e6a..0000000 --- a/oversampling/WDL/eel2/glue_x86.h +++ /dev/null @@ -1,678 +0,0 @@ -#ifndef _NSEEL_GLUE_X86_H_ -#define _NSEEL_GLUE_X86_H_ - -#define GLUE_MAX_FPSTACK_SIZE 8 - -// endOfInstruction is end of jump with relative offset, offset is offset from end of instruction to jump to -#define GLUE_JMP_SET_OFFSET(endOfInstruction,offset) (((int *)(endOfInstruction))[-1] = (offset)) - -static const unsigned char GLUE_JMP_NC[] = { 0xE9, 0,0,0,0, }; // jmp -static const unsigned char GLUE_JMP_IF_P1_Z[] = {0x85, 0xC0, 0x0F, 0x84, 0,0,0,0 }; // test eax, eax, jz -static const unsigned char GLUE_JMP_IF_P1_NZ[] = {0x85, 0xC0, 0x0F, 0x85, 0,0,0,0 }; // test eax, eax, jnz - -#define GLUE_FUNC_ENTER_SIZE 0 -#define GLUE_FUNC_LEAVE_SIZE 0 -const static unsigned int GLUE_FUNC_ENTER[1]; -const static unsigned int GLUE_FUNC_LEAVE[1]; - - // x86 - // stack is 16 byte aligned - // when pushing values to stack, alignment pushed first, then value (value is at the lower address) - // when pushing pointers to stack, alignment pushed first, then pointer (pointer is at the lower address) - - static const unsigned char GLUE_PUSH_P1PTR_AS_VALUE[] = - { - 0x83, 0xEC, 8, /* sub esp, 8 */ - 0xff, 0x70, 0x4, /* push dword [eax+4] */ - 0xff, 0x30, /* push dword [eax] */ - }; - - static int GLUE_POP_VALUE_TO_ADDR(unsigned char *buf, void *destptr) - { - if (buf) - { - *buf++ = 0xB8; *(void **) buf = destptr; buf+=4; // mov eax, directvalue - - *buf++ = 0x8f; *buf++ = 0x00; // pop dword [eax] - *buf++ = 0x8f; *buf++ = 0x40; *buf++ = 4; // pop dword [eax+4] - - *buf++ = 0x59; // pop ecx (alignment) - *buf++ = 0x59; // pop ecx (alignment) - } - - return 12; - } - - static int GLUE_COPY_VALUE_AT_P1_TO_PTR(unsigned char *buf, void *destptr) - { - if (buf) - { - *buf++ = 0x8B; *buf++ = 0x38; // mov edi, [eax] - *buf++ = 0x8B; *buf++ = 0x48; *buf++ = 0x04; // mov ecx, [eax+4] - - - *buf++ = 0xB8; *(void **) buf = destptr; buf+=4; // mov eax, directvalue - *buf++ = 0x89; *buf++ = 0x38; // mov [eax], edi - *buf++ = 0x89; *buf++ = 0x48; *buf++ = 0x04; // mov [eax+4], ecx - } - - return 2 + 3 + 5 + 2 + 3; - } - - static int GLUE_POP_FPSTACK_TO_PTR(unsigned char *buf, void *destptr) - { - if (buf) - { - *buf++ = 0xB8; *(void **) buf = destptr; buf+=4; // mov eax, directvalue - *buf++ = 0xDD; *buf++ = 0x18; // fstp qword [eax] - } - return 1+4+2; - } - - - #define GLUE_MOV_PX_DIRECTVALUE_SIZE 5 - #define GLUE_MOV_PX_DIRECTVALUE_TOSTACK_SIZE 6 // length when wv == -1 - - static void GLUE_MOV_PX_DIRECTVALUE_GEN(void *b, INT_PTR v, int wv) - { - if (wv==-1) - { - const static unsigned char t[2] = {0xDD, 0x05}; - memcpy(b,t,2); - b= ((unsigned char *)b)+2; - } - else - { - const static unsigned char tab[3] = { - 0xB8 /* mov eax, dv*/, - 0xBF /* mov edi, dv */ , - 0xB9 /* mov ecx, dv */ - }; - *((unsigned char *)b) = tab[wv]; // mov eax, dv - b= ((unsigned char *)b)+1; - } - *(INT_PTR *)b = v; - } - const static unsigned char GLUE_PUSH_P1[4]={0x83, 0xEC, 12, 0x50}; // sub esp, 12, push eax - - #define GLUE_STORE_P1_TO_STACK_AT_OFFS_SIZE(x) 7 - static void GLUE_STORE_P1_TO_STACK_AT_OFFS(void *b, int offs) - { - ((unsigned char *)b)[0] = 0x89; // mov [esp+offs], eax - ((unsigned char *)b)[1] = 0x84; - ((unsigned char *)b)[2] = 0x24; - *(int *)((unsigned char *)b+3) = offs; - } - - #define GLUE_MOVE_PX_STACKPTR_SIZE 2 - static void GLUE_MOVE_PX_STACKPTR_GEN(void *b, int wv) - { - static const unsigned char tab[3][GLUE_MOVE_PX_STACKPTR_SIZE]= - { - { 0x89, 0xe0 }, // mov eax, esp - { 0x89, 0xe7 }, // mov edi, esp - { 0x89, 0xe1 }, // mov ecx, esp - }; - memcpy(b,tab[wv],GLUE_MOVE_PX_STACKPTR_SIZE); - } - - #define GLUE_MOVE_STACK_SIZE 6 - static void GLUE_MOVE_STACK(void *b, int amt) - { - ((unsigned char *)b)[0] = 0x81; - if (amt <0) - { - ((unsigned char *)b)[1] = 0xEC; - *(int *)((char*)b+2) = -amt; // sub esp, -amt - } - else - { - ((unsigned char *)b)[1] = 0xc4; - *(int *)((char*)b+2) = amt; // add esp, amt - } - } - - - #define GLUE_POP_PX_SIZE 4 - static void GLUE_POP_PX(void *b, int wv) - { - static const unsigned char tab[3][GLUE_POP_PX_SIZE]= - { - {0x58,/*pop eax*/ 0x83, 0xC4, 12 /* add esp, 12*/}, - {0x5F,/*pop edi*/ 0x83, 0xC4, 12}, - {0x59,/*pop ecx*/ 0x83, 0xC4, 12}, - }; - memcpy(b,tab[wv],GLUE_POP_PX_SIZE); - } - - #define GLUE_SET_PX_FROM_P1_SIZE 2 - static void GLUE_SET_PX_FROM_P1(void *b, int wv) - { - static const unsigned char tab[3][GLUE_SET_PX_FROM_P1_SIZE]={ - {0x90,0x90}, // should never be used! (nopnop) - {0x89,0xC7}, // mov edi, eax - {0x89,0xC1}, // mov ecx, eax - }; - memcpy(b,tab[wv],GLUE_SET_PX_FROM_P1_SIZE); - } - - #define GLUE_POP_FPSTACK_SIZE 2 - static const unsigned char GLUE_POP_FPSTACK[2] = { 0xDD, 0xD8 }; // fstp st0 - - static const unsigned char GLUE_POP_FPSTACK_TOSTACK[] = { - 0x83, 0xEC, 16, // sub esp, 16 - 0xDD, 0x1C, 0x24 // fstp qword (%esp) - }; - - static const unsigned char GLUE_POP_STACK_TO_FPSTACK[] = { - 0xDD, 0x04, 0x24, // fld qword (%esp) - 0x83, 0xC4, 16 // add esp, 16 - }; - - static const unsigned char GLUE_POP_FPSTACK_TO_WTP[] = { - 0xDD, 0x1E, /* fstp qword [esi] */ - 0x83, 0xC6, 8, /* add esi, 8 */ - }; - - #define GLUE_SET_PX_FROM_WTP_SIZE 2 - static void GLUE_SET_PX_FROM_WTP(void *b, int wv) - { - static const unsigned char tab[3][GLUE_SET_PX_FROM_WTP_SIZE]={ - {0x89,0xF0}, // mov eax, esi - {0x89,0xF7}, // mov edi, esi - {0x89,0xF1}, // mov ecx, esi - }; - memcpy(b,tab[wv],GLUE_SET_PX_FROM_WTP_SIZE); - } - - #define GLUE_PUSH_VAL_AT_PX_TO_FPSTACK_SIZE 2 - static void GLUE_PUSH_VAL_AT_PX_TO_FPSTACK(void *b, int wv) - { - static const unsigned char tab[3][GLUE_PUSH_VAL_AT_PX_TO_FPSTACK_SIZE]={ - {0xDD,0x00}, // fld qword [eax] - {0xDD,0x07}, // fld qword [edi] - {0xDD,0x01}, // fld qword [ecx] - }; - memcpy(b,tab[wv],GLUE_PUSH_VAL_AT_PX_TO_FPSTACK_SIZE); - } - -#define GLUE_POP_FPSTACK_TO_WTP_TO_PX_SIZE (GLUE_SET_PX_FROM_WTP_SIZE + sizeof(GLUE_POP_FPSTACK_TO_WTP)) -static void GLUE_POP_FPSTACK_TO_WTP_TO_PX(unsigned char *buf, int wv) -{ - GLUE_SET_PX_FROM_WTP(buf,wv); - memcpy(buf + GLUE_SET_PX_FROM_WTP_SIZE,GLUE_POP_FPSTACK_TO_WTP,sizeof(GLUE_POP_FPSTACK_TO_WTP)); -}; - - -const static unsigned char GLUE_RET=0xC3; - -static int GLUE_RESET_WTP(unsigned char *out, void *ptr) -{ - if (out) - { - *out++ = 0xBE; // mov esi, constant - memcpy(out,&ptr,sizeof(void *)); - out+=sizeof(void *); - } - return 1+sizeof(void *); -} - - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4731) -#endif - -#define GLUE_TABPTR_IGNORED -#define GLUE_CALL_CODE(bp, cp, rt) do { \ - if (h->compile_flags&NSEEL_CODE_COMPILE_FLAG_NOFPSTATE) eel_callcode32_fast(cp, rt); \ - else eel_callcode32(cp, rt);\ - } while(0) - -static void eel_callcode32(INT_PTR cp, INT_PTR ramptr) -{ - #ifndef NSEEL_EEL1_COMPAT_MODE - short oldsw, newsw; - #endif - #ifdef _MSC_VER - - __asm - { -#ifndef NSEEL_EEL1_COMPAT_MODE - fnstcw [oldsw] - mov ax, [oldsw] - or ax, 0x23F // 53 or 64 bit precision (depending on whether 0x100 is set), and masking all exceptions - mov [newsw], ax - fldcw [newsw] -#endif - - mov eax, cp - mov ebx, ramptr - - pushad - mov ebp, esp - and esp, -16 - - // on win32, which _MSC_VER implies, we keep things aligned to 16 bytes, and if we call a win32 function, - // the stack is 16 byte aligned before the call, meaning that if calling a function with no frame pointer, - // the stack would be aligned to a 16 byte boundary +4, which isn't good for performance. Having said that, - // normally we compile with frame pointers (which brings that to 16 byte + 8, which is fine), or ICC, which - // for nontrivial functions will align the stack itself (for very short functions, it appears to weigh the - // cost of aligning the stack vs that of the slower misaligned double accesses). - - // it may be worthwhile (at some point) to put some logic in the code that calls out to functions - // (generic1parm etc) to detect which alignment would be most optimal. - sub esp, 12 - call eax - mov esp, ebp - popad -#ifndef NSEEL_EEL1_COMPAT_MODE - fldcw [oldsw] -#endif - }; - - #else // gcc x86 - __asm__( -#ifndef NSEEL_EEL1_COMPAT_MODE - "fnstcw %2\n" - "movw %2, %%ax\n" - "orw $0x23F, %%ax\n" // 53 or 64 bit precision (depending on whether 0x100 is set), and masking all exceptions - "movw %%ax, %3\n" - "fldcw %3\n" -#endif - "pushl %%ebx\n" - "movl %%ecx, %%ebx\n" - "pushl %%ebp\n" - "movl %%esp, %%ebp\n" - "andl $-16, %%esp\n" // align stack to 16 bytes - "subl $12, %%esp\n" // call will push 4 bytes on stack, align for that - "call *%%edx\n" - "leave\n" - "popl %%ebx\n" -#ifndef NSEEL_EEL1_COMPAT_MODE - "fldcw %2\n" -#endif - :: - "d" (cp), "c" (ramptr) -#ifndef NSEEL_EEL1_COMPAT_MODE - , "m" (oldsw), "m" (newsw) -#endif - : "%eax","%esi","%edi"); - #endif //gcc x86 -} - -void eel_enterfp(int s[2]) -{ - #ifdef _MSC_VER - __asm - { - mov ecx, s - fnstcw [ecx] - mov ax, [ecx] - or ax, 0x23F // 53 or 64 bit precision (depending on whether 0x100 is set), and masking all exceptions - mov [ecx+4], ax - fldcw [ecx+4] - }; - #else - __asm__( - "fnstcw (%%ecx)\n" - "movw (%%ecx), %%ax\n" - "orw $0x23F, %%ax\n" // 53 or 64 bit precision (depending on whether 0x100 is set), and masking all exceptions - "movw %%ax, 4(%%ecx)\n" - "fldcw 4(%%ecx)\n" - :: "c" (s) : "%eax"); - #endif -} -void eel_leavefp(int s[2]) -{ - #ifdef _MSC_VER - __asm - { - mov ecx, s - fldcw [ecx] - }; - #else - __asm__( - "fldcw (%%ecx)\n" - :: "c" (s) : "%eax"); - #endif -} - -static void eel_callcode32_fast(INT_PTR cp, INT_PTR ramptr) -{ - #ifdef _MSC_VER - - __asm - { - mov eax, cp - mov ebx, ramptr - - pushad - mov ebp, esp - and esp, -16 - - // on win32, which _MSC_VER implies, we keep things aligned to 16 bytes, and if we call a win32 function, - // the stack is 16 byte aligned before the call, meaning that if calling a function with no frame pointer, - // the stack would be aligned to a 16 byte boundary +4, which isn't good for performance. Having said that, - // normally we compile with frame pointers (which brings that to 16 byte + 8, which is fine), or ICC, which - // for nontrivial functions will align the stack itself (for very short functions, it appears to weigh the - // cost of aligning the stack vs that of the slower misaligned double accesses). - - // it may be worthwhile (at some point) to put some logic in the code that calls out to functions - // (generic1parm etc) to detect which alignment would be most optimal. - sub esp, 12 - call eax - mov esp, ebp - popad - }; - - #else // gcc x86 - __asm__( - "pushl %%ebx\n" - "movl %%ecx, %%ebx\n" - "pushl %%ebp\n" - "movl %%esp, %%ebp\n" - "andl $-16, %%esp\n" // align stack to 16 bytes - "subl $12, %%esp\n" // call will push 4 bytes on stack, align for that - "call *%%edx\n" - "leave\n" - "popl %%ebx\n" - :: - "d" (cp), "c" (ramptr) - : "%eax","%esi","%edi"); - #endif //gcc x86 -} - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - - -static unsigned char *EEL_GLUE_set_immediate(void *_p, INT_PTR newv) -{ - char *p=(char*)_p; - INT_PTR scan = 0xFEFEFEFE; - while (*(INT_PTR *)p != scan) p++; - *(INT_PTR *)p = newv; - return (unsigned char *) (((INT_PTR*)p)+1); -} - -#define INT_TO_LECHARS(x) ((x)&0xff),(((x)>>8)&0xff), (((x)>>16)&0xff), (((x)>>24)&0xff) - - -#define GLUE_INLINE_LOOPS - -#define GLUE_LOOP_LOADCNT_SIZE (nseel_has_sse3() ? sizeof(GLUE_LOOP_LOADCNT_SSE3) : sizeof(GLUE_LOOP_LOADCNT_NOSSE3)) -#define GLUE_LOOP_LOADCNT (nseel_has_sse3() ? GLUE_LOOP_LOADCNT_SSE3 : GLUE_LOOP_LOADCNT_NOSSE3) -static const unsigned char GLUE_LOOP_LOADCNT_SSE3[]={ - 0xdb, 0x0e, // fisttp dword [esi] - 0x8B, 0x0E, // mov ecx, [esi] - 0x81, 0xf9, 1,0,0,0, // cmp ecx, 1 - 0x0F, 0x8C, 0,0,0,0, // JL -}; - -static const unsigned char GLUE_LOOP_LOADCNT_NOSSE3[]={ - 0xd9, 0x7e, 0x04, // fnstcw [esi+4] - 0x66, 0x8b, 0x46, 0x04, // mov ax, [esi+4] - 0x66, 0x0d, 0x00, 0x0c, // or ax, 0xC00 - 0x66, 0x89, 0x46, 0x08, // mov [esi+8], ax - 0xd9, 0x6e, 0x08, // fldcw [esi+8] - 0xDB, 0x1E, // fistp dword [esi] - 0xd9, 0x6e, 0x04, // fldcw [esi+4] - 0x8B, 0x0E, // mov ecx, [esi] - 0x81, 0xf9, 1,0,0,0, // cmp ecx, 1 - 0x0F, 0x8C, 0,0,0,0, // JL -}; - -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 -#define GLUE_LOOP_CLAMPCNT_SIZE sizeof(GLUE_LOOP_CLAMPCNT) -static const unsigned char GLUE_LOOP_CLAMPCNT[]={ - 0x81, 0xf9, INT_TO_LECHARS(NSEEL_LOOPFUNC_SUPPORT_MAXLEN), // cmp ecx, NSEEL_LOOPFUNC_SUPPORT_MAXLEN - 0x0F, 0x8C, 5,0,0,0, // JL over-the-mov - 0xB9, INT_TO_LECHARS(NSEEL_LOOPFUNC_SUPPORT_MAXLEN), // mov ecx, NSEEL_LOOPFUNC_SUPPORT_MAXLEN -}; -#else - -#define GLUE_LOOP_CLAMPCNT_SIZE 0 -#define GLUE_LOOP_CLAMPCNT "" - -#endif - -#define GLUE_LOOP_BEGIN_SIZE sizeof(GLUE_LOOP_BEGIN) -static const unsigned char GLUE_LOOP_BEGIN[]={ - 0x56, //push esi - 0x51, // push ecx - 0x81, 0xEC, 0x08, 0,0,0, // sub esp, 8 -}; -static const unsigned char GLUE_LOOP_END[]={ - 0x81, 0xC4, 0x08, 0,0,0, // add esp, 8 - 0x59, //pop ecx - 0x5E, // pop esi - 0x49, // dec ecx - 0x0f, 0x85, 0,0,0,0, // jnz ... -}; - - -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 -#define GLUE_WHILE_SETUP_SIZE sizeof(GLUE_WHILE_SETUP) -static const unsigned char GLUE_WHILE_SETUP[]={ - 0xB9, INT_TO_LECHARS(NSEEL_LOOPFUNC_SUPPORT_MAXLEN), // mov ecx, NSEEL_LOOPFUNC_SUPPORT_MAXLEN -}; -static const unsigned char GLUE_WHILE_BEGIN[]={ - 0x56, //push esi - 0x51, // push ecx - 0x81, 0xEC, 0x08, 0,0,0, // sub esp, 8 -}; -static const unsigned char GLUE_WHILE_END[]={ - 0x81, 0xC4, 0x08, 0,0,0, // add esp, 8 - 0x59, //pop ecx - 0x5E, // pop esi - - - 0x49, // dec ecx - 0x0f, 0x84, 0,0,0,0, // jz endpt -}; - - -#else - -#define GLUE_WHILE_SETUP_SIZE 0 -#define GLUE_WHILE_SETUP "" -#define GLUE_WHILE_END_NOJUMP -static const unsigned char GLUE_WHILE_BEGIN[]={ - 0x56, //push esi - 0x81, 0xEC, 12, 0,0,0, // sub esp, 12 -}; -static const unsigned char GLUE_WHILE_END[]={ - 0x81, 0xC4, 12, 0,0,0, // add esp, 12 - 0x5E, // pop esi -}; - -#endif - -static const unsigned char GLUE_WHILE_CHECK_RV[] = { - 0x85, 0xC0, // test eax, eax - 0x0F, 0x85, 0,0,0,0 // jnz looppt -}; - -static const unsigned char GLUE_SET_P1_Z[] = { 0x29, 0xC0 }; // sub eax, eax -static const unsigned char GLUE_SET_P1_NZ[] = { 0xb0, 0x01 }; // mov al, 1 - -static const unsigned char GLUE_FXCH[] = {0xd9, 0xc9}; - -#define GLUE_HAS_FLDZ -static const unsigned char GLUE_FLDZ[] = {0xd9, 0xee}; -#define GLUE_HAS_FLD1 -static const unsigned char GLUE_FLD1[] = {0xd9, 0xe8}; - -static EEL_F negativezeropointfive=-0.5f; -static EEL_F onepointfive=1.5f; -#define GLUE_INVSQRT_NEEDREPL &negativezeropointfive, &onepointfive, - - -#define GLUE_HAS_NATIVE_TRIGSQRTLOG - - -void nseel_asm_or(void); -void nseel_asm_or0(void); -void nseel_asm_or_op(void); -void nseel_asm_and(void); -void nseel_asm_and_op(void); -void nseel_asm_xor(void); -void nseel_asm_xor_op(void); -void nseel_asm_shl(void); -void nseel_asm_shr(void); -void nseel_asm_mod(void); -void nseel_asm_mod_op(void); -void nseel_asm_stack_peek(void); -void _asm_gmegabuf(void); -void _asm_megabuf(void); - -static struct roundinftab { - void *fn; - char istores; // number of fistp's - char flag; // 0=fistpll, 1=fistpl, 2=fistpl 4(%esp) - int newsz; - void *newfn; -} s_round_fixes[] = { - { nseel_asm_or, 2, }, - { nseel_asm_or_op, 2, }, - { nseel_asm_or0, 1, }, - { nseel_asm_and, 2, }, - { nseel_asm_and_op, 2, }, - { nseel_asm_xor, 2, }, - { nseel_asm_xor_op, 2, }, - { nseel_asm_shl, 2, 1, }, - { nseel_asm_shr, 2, 1, }, - { nseel_asm_mod, 2, 1, }, - { nseel_asm_mod_op, 2, 1, }, - { nseel_asm_stack_peek, 1, 1, }, - { _asm_megabuf, 1, 1, }, - { _asm_gmegabuf, 1, 2, }, -}; - -static void eel_fixup_sse3(unsigned char *p, unsigned char *endp, int np, int flag) -{ - const int isz = flag == 2 ? 3 : 2; - while (p+isz <= endp && np > 0) - { - if (flag == 0 && p[0] == 0xdf && (p[1]&0xbe) == 0x3e) - { - *p++ = 0xdd; - *p -= 0x30; - if (*p & 0x40) p++; - np--; - } - else if (flag == 1 && p[0] == 0xdb && (p[1]&0xbe) == 0x1e) - { - *++p -= 0x10; - if (*p & 0x40) p++; - np--; - } - else if (flag == 2 && p[0] == 0xdb && (p[1]&0xbf) == 0x1c && p[2] == 0x24) - { - *++p -= 0x10; - if (*p & 0x40) p++; - p++; - np--; - } - p++; - } - WDL_ASSERT(np == 0); -} - -static int nseel_has_sse3() -{ - static char c; - if (!c) - { - int features = 1; - #ifdef _MSC_VER - __asm { - mov eax, 1 - cpuid - mov [features], ecx - }; - #else - __asm__( - "movl $1, %%eax\n" - "pushl %%ebx\n" - "pushl %%edx\n" - "cpuid\n" - "popl %%edx\n" - "popl %%ebx\n" - : "=c" (features) : : "%eax"); - #endif - c=(features&1) ? 1 : -1; - } - return c>0; -} -static void *GLUE_realAddress(void *fn, int *size) -{ - static const unsigned char sig[12] = { 0x89, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 }; - unsigned char *p = (unsigned char *)fn; - - size_t rmatch; - const size_t nmatch = sizeof(s_round_fixes) / sizeof(s_round_fixes[0]); - for (rmatch = 0; rmatch < nmatch && s_round_fixes[rmatch].fn != fn; rmatch++); - if (rmatch < nmatch && s_round_fixes[rmatch].newfn && s_round_fixes[rmatch].newsz) - { - *size = s_round_fixes[rmatch].newsz; - return s_round_fixes[rmatch].newfn; - } - - #if defined(_DEBUG) && defined(_MSC_VER) - if (*p == 0xE9) // this means jump to the following address (debug stub) - { - p += 5 + *(int *)(p+1); - } - #endif - - while (memcmp(p,sig,sizeof(sig))) p++; - p+=sizeof(sig); - fn = p; - - while (memcmp(p,sig,sizeof(sig))) p++; - *size = p - (unsigned char *)fn; - - if (rmatch < nmatch) - { - static const unsigned char prefix[] = { - 0xd9, 0x7e, 0x10, // fnstcw [esi+16] - 0x66, 0x8b, 0x46, 0x10, // mov ax, [esi+16] - 0x66, 0x0d, 0x00, 0x0c, // or ax, 0xC00 - 0x66, 0x89, 0x46, 0x14, // mov [esi+20], ax - 0xd9, 0x6e, 0x14, // fldcw [esi+20] - }; - static const unsigned char postfix[] = { - 0xd9, 0x6e, 0x10, // fldcw [esi+16] - }; - - const int has_sse = nseel_has_sse3(); - - unsigned char *tmp = (unsigned char *) malloc(*size + (has_sse ? 0 : sizeof(prefix) + sizeof(postfix))); - if (tmp) - { - if (has_sse) - { - memcpy(tmp,fn,*size); - eel_fixup_sse3(tmp,tmp + *size,s_round_fixes[rmatch].istores, s_round_fixes[rmatch].flag); - } - else - { - memcpy(tmp,prefix,sizeof(prefix)); - memcpy(tmp+sizeof(prefix),fn,*size); - memcpy(tmp+sizeof(prefix)+*size,postfix,sizeof(postfix)); - - *size += sizeof(prefix) + sizeof(postfix); - } - fn = tmp; - s_round_fixes[rmatch].newsz = *size; - s_round_fixes[rmatch].newfn = fn; - } - } - - return fn; -} - -#endif diff --git a/oversampling/WDL/eel2/glue_x86_64_sse.h b/oversampling/WDL/eel2/glue_x86_64_sse.h deleted file mode 100644 index 651efa6..0000000 --- a/oversampling/WDL/eel2/glue_x86_64_sse.h +++ /dev/null @@ -1,638 +0,0 @@ -#ifndef _NSEEL_GLUE_X86_64_SSE_H_ -#define _NSEEL_GLUE_X86_64_SSE_H_ - -// SSE version (needs the appropriate .o linked!) -#define GLUE_MOD_IS_64 -#define GLUE_PREFER_NONFP_DV_ASSIGNS -#define GLUE_HAS_FPREG2 1 - -static const unsigned int GLUE_COPY_FPSTACK_TO_FPREG2[] = { 0xc8100ff2 }; // movsd %xmm0,%xmm1 -static unsigned char GLUE_POP_STACK_TO_FPREG2[] = { - 0xf2, 0x0f, 0x10, 0x0c, 0x24, // movsd (%rsp), %xmm1 - 0x48, 0x81, 0xC4, 16, 0,0,0, // add rsp, 16 -}; - -// spill registers -#define GLUE_MAX_SPILL_REGS 4 -#ifdef _WIN32 - // win64: xmm6-xmm15 are nonvolatile, so we use xmm6-xmm9 as spill registers (xmm8/xmm9 are 5 byte encodings) - #define GLUE_SAVE_TO_SPILL_SIZE(x) (4 + ((x)>1)) - #define GLUE_RESTORE_SPILL_TO_FPREG2_SIZE(x) (4 + ((x)>1)) - - static void GLUE_RESTORE_SPILL_TO_FPREG2(void *b, int ws) - { - if (ws < 2) - { - *(unsigned int *)b = 0xce100ff2 + (ws<<24); // movsd xmm1, xmm6+ws - } - else - { - // movsd xmm1, xmm8 + (ws-2) - *(unsigned int *)b = 0x100f41f2; - ((unsigned char *)b)[4] = 0xc8 + (ws-2); - } - } - static void GLUE_SAVE_TO_SPILL(void *b, int ws) - { - if (ws < 2) - { - *(unsigned int *)b = 0xf0100ff2 + (ws<<27); // movsd xmm6+ws, xmm0 - } - else - { - // movsd xmm8+(ws-2), xmm0 - *(unsigned int *)b = 0x100f44f2; - ((unsigned char *)b)[4] = 0xc0 + ((ws-2)<<3); - } - } -#else - // non-win32: our function stubs preserve xmm4-xmm7 - -#ifdef _DEBUG -#define GLUE_VALIDATE_SPILLS -#endif - -#ifdef GLUE_VALIDATE_SPILLS - -static unsigned char save_validate[]={ -0x48,0x83,0xec,0x10, // subq $16, %rsp -0xf2,0x0f,0x11,0x04,0x24, // movsd %xmm0, (%rsp) -0x66,0x48,0x0f,0x6e,0xe4, // movq %rsp, %xmm4 (+ws<<3) -}; - -static unsigned char restore_validate[] = { - 0xf2, 0x0f, 0x10, 0xcc, // movsd %xmm7, %xmm1 (+ws) - 0x66, 0x48, 0x0f, 0x6e, 0xdc, // movq %rsp, %xmm3 - 0x66, 0x0f, 0x2e, 0xd9, // ucomisd %xmm1, %xmm3 - 0x74, 0x02, // je 2 - 0xcd, 0x03, // int $3 - 0xf2, 0x0f, 0x10, 0x0c, 0x24, // movsd (%rsp), %xmm1 - 0x48, 0x83, 0xc4, 0x10, // addq $16, %rsp -}; - #define GLUE_SAVE_TO_SPILL_SIZE(x) (sizeof(save_validate)) - #define GLUE_RESTORE_SPILL_TO_FPREG2_SIZE(x) (sizeof(restore_validate)) - -#else - - #define GLUE_SAVE_TO_SPILL_SIZE(x) (4) - #define GLUE_RESTORE_SPILL_TO_FPREG2_SIZE(x) (4) - -#endif - - static void GLUE_RESTORE_SPILL_TO_FPREG2(void *b, int ws) - { -#ifdef GLUE_VALIDATE_SPILLS - char *p = (char*) b; - memcpy(p,restore_validate,sizeof(restore_validate)); - p[3] += ws; -#else - *(unsigned int *)b = 0xcc100ff2 + (ws<<24); // movsd xmm1, xmm4+ws -#endif - } - static void GLUE_SAVE_TO_SPILL(void *b, int ws) - { -#ifdef GLUE_VALIDATE_SPILLS - char *p = (char*) b; - memcpy(p,save_validate,sizeof(save_validate)); - p[sizeof(save_validate)-1] += ws<<3; -#else - *(unsigned int *)b = 0xe0100ff2 + (ws<<27); // movsd xmm4+ws, xmm0 -#endif - } -#endif - -#define GLUE_MAX_FPSTACK_SIZE 0 -#define GLUE_JMP_SET_OFFSET(endOfInstruction,offset) (((int *)(endOfInstruction))[-1] = (int) (offset)) - -static const unsigned char GLUE_JMP_NC[] = { 0xE9, 0,0,0,0, }; // jmp -static const unsigned char GLUE_JMP_IF_P1_Z[] = {0x85, 0xC0, 0x0F, 0x84, 0,0,0,0 }; // test eax, eax, jz -static const unsigned char GLUE_JMP_IF_P1_NZ[] = {0x85, 0xC0, 0x0F, 0x85, 0,0,0,0 }; // test eax, eax, jnz - - -#define GLUE_FUNC_ENTER_SIZE 0 -#define GLUE_FUNC_LEAVE_SIZE 0 -const static unsigned int GLUE_FUNC_ENTER[1]; -const static unsigned int GLUE_FUNC_LEAVE[1]; - - // on x86-64: - // stack is always 16 byte aligned - // pushing values to the stack (for eel functions) has alignment pushed first, then value (value is at the lower address) - // pushing pointers to the stack has the pointer pushed first, then the alignment (pointer is at the higher address) - #define GLUE_MOV_PX_DIRECTVALUE_SIZE 10 - #define GLUE_MOV_PX_DIRECTVALUE_TOSTACK_SIZE 14 // wr=-1, sets xmm0 - #define GLUE_MOV_PX_DIRECTVALUE_TOFPREG2_SIZE 14 // wr=-2, sets xmm1 - static void GLUE_MOV_PX_DIRECTVALUE_GEN(void *b, INT_PTR v, int wr) { - const static unsigned short tab[3] = - { - 0xB848 /* mov rax, dv*/, - 0xBF48 /* mov rdi, dv */ , - 0xB948 /* mov rcx, dv */ - }; - unsigned short *bb = (unsigned short *)b; - *bb++ = tab[wdl_max(wr,0)]; // mov rax, directvalue - *(INT_PTR *)bb = v; - if (wr == -2) *(unsigned int *)(bb + 4) = 0x08100ff2; // movsd (%rax), %xmm1 - else if (wr == -1) *(unsigned int *)(bb + 4) = 0x00100ff2; // movsd (%rax), %xmm0 - } - - const static unsigned char GLUE_PUSH_P1[2]={ 0x50,0x50}; // push rax (pointer); push rax (alignment) - - #define GLUE_STORE_P1_TO_STACK_AT_OFFS_SIZE(x) 8 - static void GLUE_STORE_P1_TO_STACK_AT_OFFS(void *b, int offs) - { - ((unsigned char *)b)[0] = 0x48; // mov [rsp+offs], rax - ((unsigned char *)b)[1] = 0x89; - ((unsigned char *)b)[2] = 0x84; - ((unsigned char *)b)[3] = 0x24; - *(int *)((unsigned char *)b+4) = offs; - } - - #define GLUE_MOVE_PX_STACKPTR_SIZE 3 - static void GLUE_MOVE_PX_STACKPTR_GEN(void *b, int wv) - { - static const unsigned char tab[3][GLUE_MOVE_PX_STACKPTR_SIZE]= - { - { 0x48, 0x89, 0xe0 }, // mov rax, rsp - { 0x48, 0x89, 0xe7 }, // mov rdi, rsp - { 0x48, 0x89, 0xe1 }, // mov rcx, rsp - }; - memcpy(b,tab[wv],GLUE_MOVE_PX_STACKPTR_SIZE); - } - - #define GLUE_MOVE_STACK_SIZE 7 - static void GLUE_MOVE_STACK(void *b, int amt) - { - ((unsigned char *)b)[0] = 0x48; - ((unsigned char *)b)[1] = 0x81; - if (amt < 0) - { - ((unsigned char *)b)[2] = 0xEC; - *(int *)((char*)b+3) = -amt; // sub rsp, -amt32 - } - else - { - ((unsigned char *)b)[2] = 0xc4; - *(int *)((char*)b+3) = amt; // add rsp, amt32 - } - } - - #define GLUE_POP_PX_SIZE 2 - static void GLUE_POP_PX(void *b, int wv) - { - static const unsigned char tab[3][GLUE_POP_PX_SIZE]= - { - {0x58,/*pop rax*/ 0x58}, // pop alignment, then pop pointer - {0x5F,/*pop rdi*/ 0x5F}, - {0x59,/*pop rcx*/ 0x59}, - }; - memcpy(b,tab[wv],GLUE_POP_PX_SIZE); - } - - static const unsigned char GLUE_PUSH_P1PTR_AS_VALUE[] = - { - 0x50, /*push rax - for alignment */ - 0xff, 0x30, /* push qword [rax] */ - }; - - static int GLUE_POP_VALUE_TO_ADDR(unsigned char *buf, void *destptr) // trashes P2 (rdi) and P3 (rcx) - { - if (buf) - { - *buf++ = 0x48; *buf++ = 0xB9; *(void **) buf = destptr; buf+=8; // mov rcx, directvalue - *buf++ = 0x8f; *buf++ = 0x01; // pop qword [rcx] - *buf++ = 0x5F ; // pop rdi (alignment, safe to trash rdi though) - } - return 1+10+2; - } - - static int GLUE_COPY_VALUE_AT_P1_TO_PTR(unsigned char *buf, void *destptr) // trashes P2/P3 - { - if (buf) - { - *buf++ = 0x48; *buf++ = 0xB9; *(void **) buf = destptr; buf+=8; // mov rcx, directvalue - *buf++ = 0x48; *buf++ = 0x8B; *buf++ = 0x38; // mov rdi, [rax] - *buf++ = 0x48; *buf++ = 0x89; *buf++ = 0x39; // mov [rcx], rdi - } - - return 3 + 10 + 3; - } - - static int GLUE_POP_FPSTACK_TO_PTR(unsigned char *buf, void *destptr) - { - if (buf) - { - *buf++ = 0x48; - *buf++ = 0xB8; - *(void **) buf = destptr; buf+=8; // mov rax, directvalue - - *buf++ = 0xf2; // movsd %xmm0, (%rax) - *buf++ = 0x0f; - *buf++ = 0x11; - *buf++ = 0x00; - } - return 2+8+4; - } - - - #define GLUE_SET_PX_FROM_P1_SIZE 3 - static void GLUE_SET_PX_FROM_P1(void *b, int wv) - { - static const unsigned char tab[3][GLUE_SET_PX_FROM_P1_SIZE]={ - {0x90,0x90,0x90}, // should never be used! (nopnop) - {0x48,0x89,0xC7}, // mov rdi, rax - {0x48,0x89,0xC1}, // mov rcx, rax - }; - memcpy(b,tab[wv],GLUE_SET_PX_FROM_P1_SIZE); - } - - - #define GLUE_POP_FPSTACK_SIZE 0 - static const unsigned char GLUE_POP_FPSTACK[1] = { 0 }; - - static const unsigned char GLUE_POP_FPSTACK_TOSTACK[] = { - 0x48, 0x81, 0xEC, 16, 0,0,0, // sub rsp, 16 - 0xf2, 0x0f, 0x11, 0x04, 0x24, // movsd xmm0, (%rsp) - }; - - static const unsigned char GLUE_POP_FPSTACK_TO_WTP[] = { - 0xf2, 0x0f, 0x11, 0x06, // movsd xmm0, (%rsi) - 0x48, 0x81, 0xC6, 8, 0,0,0,/* add rsi, 8 */ - }; - - #define GLUE_SET_PX_FROM_WTP_SIZE 3 - static void GLUE_SET_PX_FROM_WTP(void *b, int wv) - { - static const unsigned char tab[3][GLUE_SET_PX_FROM_WTP_SIZE]={ - {0x48, 0x89,0xF0}, // mov rax, rsi - {0x48, 0x89,0xF7}, // mov rdi, rsi - {0x48, 0x89,0xF1}, // mov rcx, rsi - }; - memcpy(b,tab[wv],GLUE_SET_PX_FROM_WTP_SIZE); - } - - #define GLUE_PUSH_VAL_AT_PX_TO_FPSTACK_SIZE 4 - static void GLUE_PUSH_VAL_AT_PX_TO_FPSTACK(void *b, int wv) - { - static const unsigned char tab[3][GLUE_PUSH_VAL_AT_PX_TO_FPSTACK_SIZE]={ - {0xf2, 0x0f, 0x10, 0x00}, // movsd (%rax), %xmm0 - {0xf2, 0x0f, 0x10, 0x07}, // movsd (%rdi), %xmm0 - {0xf2, 0x0f, 0x10, 0x01}, // movsd (%rcx), %xmm0 - }; - memcpy(b,tab[wv],GLUE_PUSH_VAL_AT_PX_TO_FPSTACK_SIZE); - } - -#define GLUE_POP_FPSTACK_TO_WTP_TO_PX_SIZE (GLUE_SET_PX_FROM_WTP_SIZE + sizeof(GLUE_POP_FPSTACK_TO_WTP)) -static void GLUE_POP_FPSTACK_TO_WTP_TO_PX(unsigned char *buf, int wv) -{ - GLUE_SET_PX_FROM_WTP(buf,wv); - memcpy(buf + GLUE_SET_PX_FROM_WTP_SIZE,GLUE_POP_FPSTACK_TO_WTP,sizeof(GLUE_POP_FPSTACK_TO_WTP)); -}; - - -const static unsigned char GLUE_RET=0xC3; - -static int GLUE_RESET_WTP(unsigned char *out, void *ptr) -{ - if (out) - { - *out++ = 0x48; - *out++ = 0xBE; // mov rsi, constant64 - *(void **)out = ptr; - out+=sizeof(void *); - } - return 2+sizeof(void *); -} - -extern void eel_callcode64(INT_PTR code, INT_PTR ram_tab); -extern void eel_callcode64_fast(INT_PTR code, INT_PTR ram_tab); -#define GLUE_CALL_CODE(bp, cp, rt) do { \ - if (h->compile_flags&NSEEL_CODE_COMPILE_FLAG_NOFPSTATE) eel_callcode64_fast(cp, rt); \ - else eel_callcode64(cp, rt);\ - } while(0) -#define GLUE_TABPTR_IGNORED - -static unsigned char *EEL_GLUE_set_immediate(void *_p, INT_PTR newv) -{ - char *p=(char*)_p; - INT_PTR scan = 0xFEFEFEFEFEFEFEFE; - while (*(INT_PTR *)p != scan) p++; - *(INT_PTR *)p = newv; - return (unsigned char *) (((INT_PTR*)p)+1); -} - -#define INT_TO_LECHARS(x) ((x)&0xff),(((x)>>8)&0xff), (((x)>>16)&0xff), (((x)>>24)&0xff) - -#define GLUE_INLINE_LOOPS - -static const unsigned char GLUE_LOOP_LOADCNT[]={ - 0xf2, 0x48, 0x0f, 0x2c, 0xc8, // cvttsd2si %xmm0, %rcx - 0x48, 0x81, 0xf9, 1,0,0,0, // cmp rcx, 1 - 0x0F, 0x8C, 0,0,0,0, // JL -}; - -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 -#define GLUE_LOOP_CLAMPCNT_SIZE sizeof(GLUE_LOOP_CLAMPCNT) -static const unsigned char GLUE_LOOP_CLAMPCNT[]={ - 0x48, 0x81, 0xf9, INT_TO_LECHARS(NSEEL_LOOPFUNC_SUPPORT_MAXLEN), // cmp rcx, NSEEL_LOOPFUNC_SUPPORT_MAXLEN - 0x0F, 0x8C, 10,0,0,0, // JL over-the-mov - 0x48, 0xB9, INT_TO_LECHARS(NSEEL_LOOPFUNC_SUPPORT_MAXLEN), 0,0,0,0, // mov rcx, NSEEL_LOOPFUNC_SUPPORT_MAXLEN -}; -#else -#define GLUE_LOOP_CLAMPCNT_SIZE 0 -#define GLUE_LOOP_CLAMPCNT "" -#endif - -#define GLUE_LOOP_BEGIN_SIZE sizeof(GLUE_LOOP_BEGIN) -static const unsigned char GLUE_LOOP_BEGIN[]={ - 0x56, //push rsi - 0x51, // push rcx -}; -static const unsigned char GLUE_LOOP_END[]={ - 0x59, //pop rcx - 0x5E, // pop rsi - 0xff, 0xc9, // dec rcx - 0x0f, 0x85, 0,0,0,0, // jnz ... -}; - - - -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN > 0 -static const unsigned char GLUE_WHILE_SETUP[]={ - 0x48, 0xB9, INT_TO_LECHARS(NSEEL_LOOPFUNC_SUPPORT_MAXLEN), 0,0,0,0, // mov rcx, NSEEL_LOOPFUNC_SUPPORT_MAXLEN -}; -#define GLUE_WHILE_SETUP_SIZE sizeof(GLUE_WHILE_SETUP) - -static const unsigned char GLUE_WHILE_BEGIN[]={ - 0x56, //push rsi - 0x51, // push rcx -}; -static const unsigned char GLUE_WHILE_END[]={ - 0x59, //pop rcx - 0x5E, // pop rsi - - 0xff, 0xc9, // dec rcx - 0x0f, 0x84, 0,0,0,0, // jz endpt -}; - - -#else -#define GLUE_WHILE_SETUP "" -#define GLUE_WHILE_SETUP_SIZE 0 -#define GLUE_WHILE_END_NOJUMP - -static const unsigned char GLUE_WHILE_BEGIN[]={ - 0x56, //push rsi - 0x51, // push rcx -}; -static const unsigned char GLUE_WHILE_END[]={ - 0x59, //pop rcx - 0x5E, // pop rsi -}; - -#endif - - -static const unsigned char GLUE_WHILE_CHECK_RV[] = { - 0x85, 0xC0, // test eax, eax - 0x0F, 0x85, 0,0,0,0 // jnz looppt -}; - -static const unsigned char GLUE_SET_P1_Z[] = { 0x48, 0x29, 0xC0 }; // sub rax, rax -static const unsigned char GLUE_SET_P1_NZ[] = { 0xb0, 0x01 }; // mov al, 1 - - -#define GLUE_HAS_FLDZ -static const unsigned char GLUE_FLDZ[] = { - 0x0f, 0x57, 0xc0 //xorps %xmm0, %xmm0 -}; - - -static EEL_F negativezeropointfive=-0.5f; -static EEL_F onepointfive=1.5f; -#define GLUE_INVSQRT_NEEDREPL &negativezeropointfive, &onepointfive, - - -static void *GLUE_realAddress(void *fn, int *size) -{ - static const unsigned char new_sig[8] = { 0x89, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x00 }; - int sz = 0; - while (memcmp((char*)fn + sz,new_sig,sizeof(new_sig))) sz++; - *size = sz; - return fn; -} - -#define GLUE_HAS_FUSE 1 -static int GLUE_FUSE(compileContext *ctx, unsigned char *code, int left_size, int right_size, int fuse_flags, int spill_reg) -{ - const UINT_PTR base = (UINT_PTR) ctx->ram_state->blocks; - const int is_sse_op = right_size == 4 && // add/mul/sub/min/max - code[0] == 0xf2 && - code[1] == 0x0f && - code[3] == 0xc1 && // low nibble is xmm1 - (code[2] == 0x58 || code[2] == 0x59 || code[2] == 0x5c || code[2]==0x5d || code[2] == 0x5f); - - if (spill_reg >= 0) - { -#ifndef GLUE_VALIDATE_SPILLS - if (is_sse_op) - { - char tmp[32]; - const int sz = GLUE_RESTORE_SPILL_TO_FPREG2_SIZE(spill_reg); - GLUE_RESTORE_SPILL_TO_FPREG2(tmp,spill_reg); - if (left_size>=sz && !memcmp(code-sz,tmp,sz)) - { - code[-2] = code[2]; // modify the movsd into an addsd - code[-1] -= 8; // movsd uses 0xc8+(xmmX&7), addsd etc use 0xc0 - return -4; - } - } -#endif - } - else - { - if (left_size==28) - { - // if const64_1 is within a 32-bit offset of ctx->ram_blocks->blocks, we can use [r12+offs] - if (code[-28] == 0x48 && code[-27] == 0xb8 && // mov rax, const64_1 - *(int *)(code - 18) == 0x08100ff2 && // movsd xmm1, [rax] - code[-14] == 0x48 && code[-13] == 0xb8 && // mov rax, const64_2 - *(int *)(code - 4) == 0x00100ff2 // movsd xmm0, [rax] - ) - { - UINT_PTR c1, c2; - INT_PTR c2offs,c1offs; - unsigned char opc[3]; - int wrpos = -28; - if (is_sse_op) memcpy(opc,code,3); - memcpy(&c1,code-26,8); - memcpy(&c2,code-12,8); - -#define PTR_32_OK(x) ((x) == (INT_PTR)(int)(x)) - c2offs = c2-base; - if (!PTR_32_OK(c2offs)) - { - code[wrpos++] = 0x48; - code[wrpos++] = 0xb8; - memcpy(code+wrpos,&c2,8); // mov rax, const64_2 - wrpos += 8; - } - - c1offs = c1-base; - if (!PTR_32_OK(c1offs)) - { - code[wrpos++] = 0x48; - code[wrpos++] = 0xbf; - memcpy(code+wrpos,&c1,8); // mov rdi, const64_1 - wrpos += 8; - } - - if (!PTR_32_OK(c2offs)) - { - *(int *)(code+wrpos) = 0x00100ff2; // movsd xmm0, [rax] - wrpos += 4; - } - else - { - // movsd xmm0, [r12+offs] - code[wrpos++] = 0xf2; - code[wrpos++] = 0x41; - code[wrpos++] = 0x0f; - code[wrpos++] = 0x10; - code[wrpos++] = 0x84; - code[wrpos++] = 0x24; - *(int *)(code+wrpos) = (int)c2offs; - wrpos += 4; - } - - if (!is_sse_op) - { - // load xmm1 from rdi/c1offs - if (!PTR_32_OK(c1offs)) - { - *(int *)(code+wrpos) = 0x0f100ff2; // movsd xmm1, [rdi] - wrpos += 4; - } - else - { - // movsd xmm1, [r12+offs] - code[wrpos++] = 0xf2; - code[wrpos++] = 0x41; - code[wrpos++] = 0x0f; - code[wrpos++] = 0x10; - code[wrpos++] = 0x8c; - code[wrpos++] = 0x24; - *(int *)(code+wrpos) = (int)c1offs; - wrpos += 4; - } - if (wrpos<0) memmove(code+wrpos,code,right_size); - return wrpos; - } - - // fuse to sse op - if (!PTR_32_OK(c1offs)) - { - memcpy(code+wrpos,opc,3); - code[wrpos+3] = 0x07; // [rdi] - wrpos += 4; - } - else - { - // mul/add/sub/min/max/sd xmm0, [r12+offs] - code[wrpos++] = opc[0]; // 0xf2 - code[wrpos++] = 0x41; - code[wrpos++] = opc[1]; // 0x0f - code[wrpos++] = opc[2]; // 0x58 etc - code[wrpos++] = 0x84; - code[wrpos++] = 0x24; - *(int *)(code+wrpos) = (int)c1offs; - wrpos += 4; - } - return wrpos - right_size; - } - } - if ((fuse_flags&1) && left_size >= 14) - { - if (code[-14] == 0x48 && code[-13] == 0xb8 && // mov rax, const64_2 - *(int *)(code - 4) == 0x00100ff2) // movsd xmm0, [rax] - { - INT_PTR c1; - memcpy(&c1,code-12,8); - c1 -= base; - if (PTR_32_OK(c1)) - { - // movsd xmm0, [r12+offs] - int wrpos = -14; - code[wrpos++] = 0xf2; - code[wrpos++] = 0x41; - code[wrpos++] = 0x0f; - code[wrpos++] = 0x10; - code[wrpos++] = 0x84; - code[wrpos++] = 0x24; - *(int *)(code+wrpos) = (int)c1; - wrpos += 4; - if (wrpos<0) memmove(code+wrpos,code,right_size); - return wrpos; - } - } - } - - if (left_size == 20 && right_size == 9 && - code[-20]==0x48 && code[-19] == 0xbf && // mov rdi, const64_1 - code[-10]==0x48 && code[-9] == 0xb8 // mov rax, const64_2 - ) - { - static unsigned char assign_copy[9] = { 0x48, 0x8b, 0x10, // mov rdx, [rax] - 0x48, 0x89, 0x17, // mov [rdi], rdx - 0x48, 0x89, 0xf8, // mov rax, rdi - }; - if (!memcmp(code,assign_copy,9)) - { - int wrpos = -20; - INT_PTR c1,c2; // c1 is dest, c2 is src - memcpy(&c1,code-18,8); - memcpy(&c2,code-8,8); - - if (!PTR_32_OK(c2-base)) - { - code[wrpos++] = 0x48; // mov rdi, src - code[wrpos++] = 0xbf; - memcpy(code+wrpos,&c2,8); - wrpos +=8; - } - - code[wrpos++] = 0x48; // mov rax, dest - code[wrpos++] = 0xb8; - memcpy(code+wrpos,&c1,8); - wrpos +=8; - - if (PTR_32_OK(c2-base)) - { - // mov rdx, [r12+offs] - code[wrpos++] = 0x49; - code[wrpos++] = 0x8b; - code[wrpos++] = 0x94; - code[wrpos++] = 0x24; - *(int *)(code+wrpos) = (int)(c2-base); - wrpos += 4; - } - else - { - code[wrpos++] = 0x48; // mov rdx, [rdi] - code[wrpos++] = 0x8b; - code[wrpos++] = 0x17; - } - - code[wrpos++] = 0x48; // mov [rax], rdx - code[wrpos++] = 0x89; - code[wrpos++] = 0x10; - - return wrpos - right_size; - } - } - - - } - return 0; -} - -#endif diff --git a/oversampling/WDL/eel2/loose_eel.cpp b/oversampling/WDL/eel2/loose_eel.cpp deleted file mode 100644 index b41211c..0000000 --- a/oversampling/WDL/eel2/loose_eel.cpp +++ /dev/null @@ -1,165 +0,0 @@ -#include -#include -#include -#include -#include -#include "../mutex.h" - -int g_verbose, g_interactive; - -static void writeToStandardError(const char *fmt, ...) -{ - va_list arglist; - va_start(arglist, fmt); - vfprintf(stderr,fmt,arglist); - fprintf(stderr,"\n"); - fflush(stderr); - va_end(arglist); -} -#define EEL_STRING_DEBUGOUT writeToStandardError // no parameters, since it takes varargs - -#ifndef EEL_LICE_WANT_STANDALONE - #define EELSCRIPT_NO_LICE -#endif - -#include "eelscript.h" - - -void NSEEL_HOSTSTUB_EnterMutex() { } -void NSEEL_HOSTSTUB_LeaveMutex() { } - - -int main(int argc, char **argv) -{ - bool want_args = true; - int argpos = 1; - const char *scriptfn = argv[0]; - while (argpos < argc && argv[argpos][0] == '-' && argv[argpos][1]) - { - if (!strcmp(argv[argpos],"-v")) g_verbose++; - else if (!strcmp(argv[argpos],"-i")) g_interactive++; - else if (!strcmp(argv[argpos],"--no-args")) want_args=false; - else - { - fprintf(stderr,"Usage: %s [-v] [--no-args] [-i | scriptfile | -]\n",argv[0]); - return -1; - } - argpos++; - } - if (argpos < argc && !g_interactive) - { - scriptfn = argv[argpos++]; - } - else - { -#ifndef _WIN32 - if (!g_interactive && isatty(0)) -#else - if (1) -#endif - g_interactive=1; - } - - if (eelScriptInst::init()) - { - fprintf(stderr,"NSEEL_init(): error initializing\n"); - return -1; - } - - -#ifndef EELSCRIPT_NO_LICE - #ifdef __APPLE__ - SWELL_InitAutoRelease(); - #endif -#endif - - WDL_FastString code,t; - - eelScriptInst inst; - if (want_args) - { -#ifndef EELSCRIPT_DO_DISASSEMBLE - const int argv_offs = 1<<22; - code.SetFormatted(64,"argc=0; argv=%d;\n",argv_offs); - int x; - for (x=argpos-1;xAddString(new WDL_FastString(xm_gfx_clear) inst.m_gfx_state->m_gfx_clear[0] = -1; -#endif - - printf("EEL interactive mode, type quit to quit, abort to abort multiline entry\n"); - EEL_F *resultVar = NSEEL_VM_regvar(inst.m_vm,"__result"); - code.Set(""); - char line[4096]; - for (;;) - { -#ifndef EELSCRIPT_NO_LICE - _gfx_update(&inst,NULL); -#endif - if (!code.Get()[0]) printf("EEL> "); - else printf("> "); - fflush(stdout); - line[0]=0; - fgets(line,sizeof(line),stdin); - if (!line[0]) break; - code.Append(line); - while (line[0] && ( - line[strlen(line)-1] == '\r' || - line[strlen(line)-1] == '\n' || - line[strlen(line)-1] == '\t' || - line[strlen(line)-1] == ' ' - )) line[strlen(line)-1]=0; - - if (!strcmp(line,"quit")) break; - if (!strcmp(line,"abort")) code.Set(""); - -#ifndef EELSCRIPT_DO_DISASSEMBLE - t.Set("__result = ("); -#else - t.Set(""); -#endif - t.Append(code.Get()); -#ifndef EELSCRIPT_DO_DISASSEMBLE - t.Append(");"); -#endif - int res=inst.runcode(t.Get(),false,"",true,true,true); // allow free, since functions can't be defined locally - if (!res) - { - if (resultVar) printf("=%g ",*resultVar); - code.Set(""); - } - else // try compiling again allowing function definitions (and not allowing free) - // but show errors if not continuation - { - res=inst.runcode(code.Get(),true,"(stdin)", false,false,true); - if (res<=0) code.Set(""); - // res>0 means need more lines - } - while (inst.run_deferred()); - } - } - else - { - inst.loadfile(scriptfn,NULL,true); - while (inst.run_deferred()); - } - - return 0; -} - -#ifndef _WIN32 -INT_PTR SWELLAppMain(int msg, INT_PTR parm1, INT_PTR parm2) -{ - return 0; -} -#endif diff --git a/oversampling/WDL/eel2/loose_eel.dsp b/oversampling/WDL/eel2/loose_eel.dsp deleted file mode 100644 index 123789a..0000000 --- a/oversampling/WDL/eel2/loose_eel.dsp +++ /dev/null @@ -1,194 +0,0 @@ -# Microsoft Developer Studio Project File - Name="loose_eel" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=loose_eel - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "loose_eel.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "loose_eel.mak" CFG="loose_eel - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "loose_eel - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "loose_eel - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "loose_eel - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D WDL_FFT_REALSIZE=8 /D NSEEL_LOOPFUNC_SUPPORT_MAXLEN=0 /D "EEL_LICE_WANT_STANDALONE" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "loose_eel - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D WDL_FFT_REALSIZE=8 /D NSEEL_LOOPFUNC_SUPPORT_MAXLEN=0 /D "EEL_LICE_WANT_STANDALONE" /YX /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "loose_eel - Win32 Release" -# Name "loose_eel - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Group "eel2" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=".\ns-eel-addfuncs.h" -# End Source File -# Begin Source File - -SOURCE=".\ns-eel-int.h" -# End Source File -# Begin Source File - -SOURCE=".\ns-eel.h" -# End Source File -# Begin Source File - -SOURCE=".\nseel-caltab.c" -# End Source File -# Begin Source File - -SOURCE=".\nseel-cfunc.c" -# End Source File -# Begin Source File - -SOURCE=".\nseel-compiler.c" -# End Source File -# Begin Source File - -SOURCE=".\nseel-eval.c" -# End Source File -# Begin Source File - -SOURCE=".\nseel-lextab.c" -# End Source File -# Begin Source File - -SOURCE=".\nseel-ram.c" -# End Source File -# Begin Source File - -SOURCE=".\nseel-yylex.c" -# End Source File -# End Group -# Begin Group "lice" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\lice\lice.cpp -# End Source File -# Begin Source File - -SOURCE=..\lice\lice_arc.cpp -# End Source File -# Begin Source File - -SOURCE=..\lice\lice_bmp.cpp -# End Source File -# Begin Source File - -SOURCE=..\lice\lice_ico.cpp -# End Source File -# Begin Source File - -SOURCE=..\lice\lice_image.cpp -# End Source File -# Begin Source File - -SOURCE=..\lice\lice_line.cpp -# End Source File -# Begin Source File - -SOURCE=..\lice\lice_lvg.cpp -# End Source File -# Begin Source File - -SOURCE=..\lice\lice_pcx.cpp -# End Source File -# Begin Source File - -SOURCE=..\lice\lice_text.cpp -# End Source File -# Begin Source File - -SOURCE=..\lice\lice_textnew.cpp -# End Source File -# End Group -# Begin Source File - -SOURCE=..\fft.c -# End Source File -# Begin Source File - -SOURCE=.\loose_eel.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project diff --git a/oversampling/WDL/eel2/loose_eel.dsw b/oversampling/WDL/eel2/loose_eel.dsw deleted file mode 100644 index 9d0726e..0000000 --- a/oversampling/WDL/eel2/loose_eel.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "loose_eel"=.\loose_eel.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/oversampling/WDL/eel2/loose_eel.sln b/oversampling/WDL/eel2/loose_eel.sln deleted file mode 100644 index 9eb0142..0000000 --- a/oversampling/WDL/eel2/loose_eel.sln +++ /dev/null @@ -1,28 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2013 for Windows Desktop -VisualStudioVersion = 12.0.30110.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "loose_eel", "loose_eel.vcxproj", "{893B9C0E-73CA-4843-A3BC-8A3FF9055FA8}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {893B9C0E-73CA-4843-A3BC-8A3FF9055FA8}.Debug|Win32.ActiveCfg = Debug|Win32 - {893B9C0E-73CA-4843-A3BC-8A3FF9055FA8}.Debug|Win32.Build.0 = Debug|Win32 - {893B9C0E-73CA-4843-A3BC-8A3FF9055FA8}.Debug|x64.ActiveCfg = Debug|x64 - {893B9C0E-73CA-4843-A3BC-8A3FF9055FA8}.Debug|x64.Build.0 = Debug|x64 - {893B9C0E-73CA-4843-A3BC-8A3FF9055FA8}.Release|Win32.ActiveCfg = Release|Win32 - {893B9C0E-73CA-4843-A3BC-8A3FF9055FA8}.Release|Win32.Build.0 = Release|Win32 - {893B9C0E-73CA-4843-A3BC-8A3FF9055FA8}.Release|x64.ActiveCfg = Release|x64 - {893B9C0E-73CA-4843-A3BC-8A3FF9055FA8}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/oversampling/WDL/eel2/loose_eel.vcxproj b/oversampling/WDL/eel2/loose_eel.vcxproj deleted file mode 100644 index d1c88e4..0000000 --- a/oversampling/WDL/eel2/loose_eel.vcxproj +++ /dev/null @@ -1,190 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {893B9C0E-73CA-4843-A3BC-8A3FF9055FA8} - Win32Proj - loose_eel - - - - Application - true - v120 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - - - - - - - - - - - - - - - - - true - $(Configuration)_new\ - $(SolutionDir)$(Configuration)_new\ - .exe - - - true - .exe - - - false - $(Configuration)_new\ - $(SolutionDir)$(Configuration)_new\ - .exe - - - false - .exe - - - - Level3 - Disabled - WIN32;BUILD_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;WDL_FFT_REALSIZE=8;EEL_LICE_WANT_STANDALONE;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - false - - - Console - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;winmm.lib;wsock32.lib;comctl32.lib;%(AdditionalDependencies) - - - - - Level3 - Disabled - WIN32;BUILD_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;WDL_FFT_REALSIZE=8;EEL_LICE_WANT_STANDALONE;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - false - - - Console - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;winmm.lib;wsock32.lib;comctl32.lib;%(AdditionalDependencies) - - - - - Level3 - NotUsing - MaxSpeed - true - true - WIN32;BUILD_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;WDL_FFT_REALSIZE=8;EEL_LICE_WANT_STANDALONE;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - MultiThreaded - - - Console - true - true - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;winmm.lib;wsock32.lib;comctl32.lib;%(AdditionalDependencies) - - - - - Level3 - NotUsing - MaxSpeed - true - true - WIN32;BUILD_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;WDL_FFT_REALSIZE=8;EEL_LICE_WANT_STANDALONE;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - MultiThreaded - - - Console - true - true - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;winmm.lib;wsock32.lib;comctl32.lib;%(AdditionalDependencies) - - - - - - \ No newline at end of file diff --git a/oversampling/WDL/eel2/loose_eel.vcxproj.filters b/oversampling/WDL/eel2/loose_eel.vcxproj.filters deleted file mode 100644 index 46afb87..0000000 --- a/oversampling/WDL/eel2/loose_eel.vcxproj.filters +++ /dev/null @@ -1,95 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {3A983C0A-E7C1-449D-B869-8CC1CE792C2F} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files\lice - - - Source Files\lice - - - Source Files\lice - - - Source Files\lice - - - Source Files\lice - - - Source Files\lice - - - Source Files\lice - - - Source Files\lice - - - Source Files\lice - - - Source Files\lice - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - \ No newline at end of file diff --git a/oversampling/WDL/eel2/makefile.vc b/oversampling/WDL/eel2/makefile.vc deleted file mode 100644 index 03aa237..0000000 --- a/oversampling/WDL/eel2/makefile.vc +++ /dev/null @@ -1,63 +0,0 @@ - -EEL_SOURCE = nseel-caltab.c nseel-cfunc.c nseel-compiler.c nseel-eval.c nseel-lextab.c nseel-ram.c nseel-yylex.c - -LICE_SOURCE = ../lice/lice.cpp ../lice/lice_image.cpp ../lice/lice_line.cpp ../lice/lice_ico.cpp ../lice/lice_bmp.cpp ../lice/lice_textnew.cpp ../lice/lice_text.cpp ../lice/lice_arc.cpp - -FFT_SOURCE = ../fft.c -CFLAGS = /DWDL_FFT_REALSIZE=8 /DEEL_LICE_WANT_STANDALONE - -CFLAGS = $(CFLAGS) -DNSEEL_LOOPFUNC_SUPPORT_MAXLEN=0 - -LFLAGS = shell32.lib user32.lib comdlg32.lib - -!ifndef VC6 -CFLAGS = $(CFLAGS) /MT -!else -CFLAGS = $(CFLAGS) /MD -LFLAGS = $(LFLAGS) /OPT:NOWIN98 -!endif - -!ifdef x64 -!ifndef PORTABLE -EEL_SOURCE = $(EEL_SOURCE) asm-nseel-x64.obj -!endif -!endif - -!ifdef arm64 -!ifndef PORTABLE -EEL_SOURCE = $(EEL_SOURCE) asm-nseel-aarch64-msvc.obj -!endif -!endif - -!ifdef arm64ec -!ifndef PORTABLE -EEL_SOURCE = $(EEL_SOURCE) asm-nseel-arm64ec.obj -!endif -!endif - - -default: loose_eel.exe - -!ifdef PORTABLE -CFLAGS = $(CFLAGS) -DEEL_TARGET_PORTABLE -!endif - -loose_eel.cpp: eel*.h ns-eel*.h - -$(EEL_SOURCE): ns-eel*.h - - -loose_eel.exe: loose_eel.cpp $(EEL_SOURCE) $(FFT_SOURCE) $(LICE_SOURCE) ..\win32_utf8.c - cl $(CFLAGS) $** /link wsock32.lib user32.lib gdi32.lib advapi32.lib $(LFLAGS) /out:$@ - -eel_disasm.exe: eel_disasm.cpp $(EEL_SOURCE) - cl $(CFLAGS) $** /link wsock32.lib user32.lib gdi32.lib advapi32.lib $(LFLAGS) /out:$@ - -asm-nseel-aarch64-msvc.obj: asm-nseel-aarch64-msvc.asm - armasm64 asm-nseel-aarch64-msvc.asm - -asm-nseel-arm64ec.obj: asm-nseel-arm64ec.asm - armasm64 /machine arm64EC asm-nseel-arm64ec.asm - -test: eel_disasm.exe - eel_disasm "buf[a] = x*y" diff --git a/oversampling/WDL/eel2/ns-eel-addfuncs.h b/oversampling/WDL/eel2/ns-eel-addfuncs.h deleted file mode 100644 index ffb92a0..0000000 --- a/oversampling/WDL/eel2/ns-eel-addfuncs.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - Nullsoft Expression Evaluator Library (NS-EEL) - Copyright (C) 1999-2003 Nullsoft, Inc. - - ns-eel-addfuncs.h: defines macros useful for adding functions to the compiler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef __NS_EEL_ADDFUNCS_H__ -#define __NS_EEL_ADDFUNCS_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -struct _compileContext; - -void *NSEEL_PProc_RAM(void *data, int data_size, struct _compileContext *ctx); -void *NSEEL_PProc_THIS(void *data, int data_size, struct _compileContext *ctx); - - -#ifdef EEL_TARGET_PORTABLE - -extern EEL_BC_TYPE _asm_generic3parm[]; // 3 double * parms, returning double * -extern EEL_BC_TYPE _asm_generic3parm_retd[]; // 3 double * parms, returning double -extern EEL_BC_TYPE _asm_generic2parm[]; // 2 double * parms, returning double * -extern EEL_BC_TYPE _asm_generic2parm_retd[]; // 2 double * parms, returning double -extern EEL_BC_TYPE _asm_generic2xparm_retd[]; // 2 double * parms, returning double -extern EEL_BC_TYPE _asm_generic1parm[]; // 1 double * parms, returning double * -extern EEL_BC_TYPE _asm_generic1parm_retd[]; // 1 double * parms, returning double - -#else - -void _asm_generic3parm(void); // 3 double * parms, returning double * -void _asm_generic3parm_retd(void); // 3 double * parms, returning double -void _asm_generic2parm(void); // 2 double * parms, returning double * -void _asm_generic2parm_retd(void); // 2 double * parms, returning double -void _asm_generic2xparm_retd(void); // 2 double * parms, returning double -void _asm_generic1parm(void); // 1 double * parms, returning double * -void _asm_generic1parm_retd(void); // 1 double * parms, returning double - -#endif - -#ifdef __cplusplus -}; - -#endif -#endif//__NS_EEL_ADDFUNCS_H__ diff --git a/oversampling/WDL/eel2/ns-eel-func-ref.h b/oversampling/WDL/eel2/ns-eel-func-ref.h deleted file mode 100644 index a4b70ac..0000000 --- a/oversampling/WDL/eel2/ns-eel-func-ref.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef _NSEEL_FUNC_REF_H_ -#define _NSEEL_FUNC_REF_H_ - -#include "ns-eel.h" -#define TMP_MKSTR2(x) #x -#define TMP_MKSTR(x) TMP_MKSTR2(x) - -const char *nseel_builtin_function_reference= - "while\texpression\tExecutes expression until expression evaluates to zero" -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN - ", or until " TMP_MKSTR(NSEEL_LOOPFUNC_SUPPORT_MAXLEN) "iterations occur" -#endif - ". An alternate and more useful syntax is while (expression) ( statements ), which evaluates statements after " - "every non-zero evaluation of expression.\0" - "loop\tcount,expression\tEvaluates count once, and then executes expression count" -#if NSEEL_LOOPFUNC_SUPPORT_MAXLEN - ", but not more than " TMP_MKSTR(NSEEL_LOOPFUNC_SUPPORT_MAXLEN) "," -#endif - " times.\0" - "sin\tangle\tReturns the sine of the angle specified (specified in radians -- to convert from degrees to radians, multiply by $pi/180, or 0.017453).\0" - "cos\tangle\tReturns the cosine of the angle specified (specified in radians).\0" - "tan\tangle\tReturns the tangent of the angle specified (specified in radians).\0" - "sqrt\tvalue\tReturns the square root of the parameter. If the parameter is negative, the return value is undefined.\0" - "log\tvalue\tReturns the natural logarithm (base e) of the parameter. If the value is not greater than 0, the return value is undefined.\0" - "log10\tvalue\tReturns the base-10 logarithm of the parameter. If the value is not greater than 0, the return value is undefined.\0" - "asin\tvalue\tReturns the arc sine of the value specified (return value is in radians). If the parameter is not between -1.0 and 1.0 inclusive, the return value is undefined.\0" - "acos\tvalue\tReturns the arc cosine of the value specified (return value is in radians). If the parameter is not between -1.0 and 1.0 inclusive, the return value is undefined.\0" - "atan\tvalue\tReturns the arc tangent of the value specified (return value is in radians). If the parameter is not between -1.0 and 1.0 inclusive, the return value is undefined.\0" - "atan2\tnumerator,denominator\tReturns the arc tangent of the numerator divided by the denominator, allowing the denominator to be 0, and using their signs to produce a more meaningful result.\0" - "exp\texponent\tReturns the number e ($e, approximately 2.718) raised to the parameter-th power. This function is significantly faster than pow() or the ^ operator.\0" - "abs\tvalue\tReturns the absolute value of the parameter.\0" - "sqr\tvalue\tReturns the square of the parameter (similar to value*value, but only evaluating value once).\0" - "min\t&value,&value\tReturns (by reference) the minimum value of the two parameters. Since min() returns by reference, expressions such as min(x,y) = 5 are possible.\0" - "max\t&value,&value\tReturns (by reference) the maximum value of the two parameters. Since max() returns by reference, expressions such as max(x,y) = 5 are possible.\0" - "sign\tvalue\tReturns 1.0 if the parameter is greater than 0, -1.0 if the parameter is less than 0, or 0 if the parameter is 0.\0" - "floor\tvalue\tReturns the value rounded to the next lowest integer (floor(3.9)==3, floor(-3.1)==-4).\0" - "ceil\tvalue\tReturns the value rounded to the next highest integer (ceil(3.1)==4, ceil(-3.9)==-3).\0" - "invsqrt\tvalue\tReturns a fast inverse square root (1/sqrt(x)) approximation of the parameter.\0" - "freembuf\taddress\tHints the runtime that memory above the address specified may no longer be used. The runtime may, at its leisure, choose to lose the contents of memory above the address specified.\0" - "memcpy\tdest,src,length\tCopies length items of memory from src to dest. Regions are permitted to overlap.\0" - "memset\toffset,value,length\tSets length items of memory at offset to value.\0" - "mem_get_values\toffset, ...\tReads values from memory starting at offset into variables specified. Slower than regular memory reads for less than a few variables, faster for more than a few. Undefined behavior if used with more than 32767 variables.\0" - "mem_set_values\toffset, ...\tWrites values to memory starting at offset from variables specified. Slower than regular memory writes for less than a few variables, faster for more than a few. Undefined behavior if used with more than 32767 variables.\0" - "mem_multiply_sum\tsrc1,src2,length\tCalculates the sum of the products of values pointed to by src1 and src2. If src2 is -1, then calculates the sum of squares of src1, if -2, the sum of the absolute values of src, if -3, calculates the sum of the values of src1. Other negative values are undefined.\0" - "mem_insert_shuffle\tbuf,len,value\tShuffles contents of buf right by 1, inserts value at buf[0], returns previous buf[len-1].\0" - "stack_push\t&value\tPushes value onto the user stack, returns a reference to the parameter.\0" - "stack_pop\t&value\tPops a value from the user stack into value, or into a temporary buffer if value is not specified, and returns a reference to where the stack was popped. Note that no checking is done to determine if the stack is empty, and as such stack_pop() will never fail.\0" - "stack_peek\tindex\tReturns a reference to the item on the top of the stack (if index is 0), or to the Nth item on the stack if index is greater than 0. \0" - "stack_exch\t&value\tExchanges a value with the top of the stack, and returns a reference to the parameter (with the new value).\0" -#ifdef NSEEL_EEL1_COMPAT_MODE - "rand\tmax\tReturns a pseudorandom non-negative integer number less than the parameter.\0" - "sigmoid\tvalue,constraint\tReturns 1.0/(1+exp(-x * (constraint))), or 0 if a divide by 0 would occur.\0" - "band\tx,y\tReturns 1 if both x and y evaluate to nonzero, 0 if otherwise. Both parameters are always evaluated.\0" - "bor\tx,y\tReturns 1 if either x or y evaluate to nonzero, 0 if otherwise. Both parameters are always evaluated.\0" - "exec2\tx,y\tEvaluates x, then evaluates and returns y.\0" - "exec3\tx,y,z\tEvaluates x, evaluates y, then evaluates and returns z.\0" -#else - "rand\t[max]\tReturns a pseudorandom real number between 0 and the parameter, inclusive. If the parameter is omitted or less than 1.0, 1.0 is used as a maximum instead.\0" - -#endif -; -#undef TMP_MKSTR - -#endif diff --git a/oversampling/WDL/eel2/ns-eel-int.h b/oversampling/WDL/eel2/ns-eel-int.h deleted file mode 100644 index 83b53ed..0000000 --- a/oversampling/WDL/eel2/ns-eel-int.h +++ /dev/null @@ -1,331 +0,0 @@ -/* - Nullsoft Expression Evaluator Library (NS-EEL) - Copyright (C) 1999-2003 Nullsoft, Inc. - - ns-eel-int.h: internal code definition header. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef __NS_EELINT_H__ -#define __NS_EELINT_H__ - -#ifdef _WIN32 -#include -#else -#include "../wdltypes.h" -#endif - -#include "ns-eel.h" -#include "ns-eel-addfuncs.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -enum { - - // these ignore fn in opcodes, just use fntype to determine function - FN_MULTIPLY=0, - FN_DIVIDE, - FN_JOIN_STATEMENTS, - FN_DENORMAL_LIKELY, - FN_DENORMAL_UNLIKELY, - FN_ADD, - FN_SUB, - FN_AND, - FN_OR, - FN_UMINUS, - FN_NOT, - FN_NOTNOT, - FN_XOR, - FN_SHL, - FN_SHR, - FN_MOD, - FN_POW, - FN_LT, - FN_GT, - FN_LTE, - FN_GTE, - FN_EQ, - FN_EQ_EXACT, - FN_NE, - FN_NE_EXACT, - FN_LOGICAL_AND, - FN_LOGICAL_OR, - FN_IF_ELSE, - FN_MEMORY, - FN_GMEMORY, - FN_NONCONST_BEGIN, - FN_ASSIGN=FN_NONCONST_BEGIN, - - FN_ADD_OP, - FN_SUB_OP, - FN_MOD_OP, - FN_OR_OP, - FN_AND_OP, - FN_XOR_OP, - FN_DIV_OP, - FN_MUL_OP, - FN_POW_OP, - - FN_WHILE, - FN_LOOP, - - FUNCTYPE_SIMPLEMAX, - - - FUNCTYPE_FUNCTIONTYPEREC=1000, // fn is a functionType * - FUNCTYPE_EELFUNC, // fn is a _codeHandleFunctionRec * -}; - - - -#define YYSTYPE opcodeRec * - -#define NSEEL_CLOSEFACTOR 0.00001 - - -typedef struct opcodeRec opcodeRec; - -typedef struct _codeHandleFunctionRec -{ - struct _codeHandleFunctionRec *next; // main linked list (only used for high level functions) - struct _codeHandleFunctionRec *derivedCopies; // separate linked list, head being the main function, other copies being derived versions - - void *startptr; // compiled code (may be cleared + recompiled when shared) - opcodeRec *opcodes; - - int startptr_size; // 0=no code. -1 = needs calculation. >0 = size. - int startptr_base_size; // initially calculated size of root function - int tmpspace_req; - - int num_params; - - int rvMode; // RETURNVALUE_* - int fpStackUsage; // 0-8, usually - int canHaveDenormalOutput; - - // local storage's first items are the parameters, then locals. Note that the opcodes will reference localstorage[] via VARPTRPTR, but - // the values localstorage[x] points are reallocated from context-to-context, if it is a common function. - - // separately allocated list of pointers, the contents of the list should be zeroed on context changes if a common function - // note that when making variations on a function (context), it is shared, but since it is zeroed on context changes, it is context-local - int localstorage_size; - EEL_F **localstorage; - - int isCommonFunction; - int usesNamespaces; - unsigned int parameterAsNamespaceMask; - - char fname[NSEEL_MAX_FUNCSIG_NAME+1]; -} _codeHandleFunctionRec; - -typedef struct _llBlock { - struct _llBlock *next; - int sizeused; - int sizealloc; - // data follows -} llBlock; - -typedef struct { - llBlock *blocks_code, *blocks_data; - void *workTable; // references a chunk in blocks_data - - void *code; - int code_size; // in case the caller wants to write it out - int code_stats[4]; - - int want_stack; - void *stack; // references a chunk in blocks_data, somewhere within the complete NSEEL_STACK_SIZE aligned at NSEEL_STACK_SIZE - - void *ramPtr; - - int workTable_size; // size (minus padding/extra space) of workTable -- only used if EEL_VALIDATE_WORKTABLE_USE set, but might be handy to have around too - int compile_flags; -} codeHandleType; - -typedef struct -{ - EEL_F *value; - int refcnt; - char isreg; - char str[1]; -} varNameRec; - -typedef struct -{ - void *ptr; - int size, alloc; -} eel_growbuf; -#define EEL_GROWBUF(type) union { eel_growbuf _growbuf; type *_tval; } -#define EEL_GROWBUF_RESIZE(gb, newsz) __growbuf_resize(&(gb)->_growbuf, (newsz)*(int)sizeof((gb)->_tval[0])) // <0 to free, does not realloc down otherwise -#define EEL_GROWBUF_GET(gb) ((gb)->_tval) -#define EEL_GROWBUF_GET_SIZE(gb) ((gb)->_growbuf.size/(int)sizeof((gb)->_tval[0])) - -typedef struct _compileContext -{ - eel_function_table *registered_func_tab; - const char *(*func_check)(const char *fn_name, void *user); // return error message if not permitted - void *func_check_user; - - EEL_GROWBUF(varNameRec *) varNameList; - EEL_F *varValueStore; - int varValueStore_left; - - int errVar,gotEndOfInput; - opcodeRec *result; - char last_error_string[256]; - - void *scanner; - const char *rdbuf_start, *rdbuf, *rdbuf_end; - - llBlock *tmpblocks, // used while compiling, and freed after compiling - - *blocks_head_code, // used while compiling, transferred to code context (whole pages marked as executable) - *blocks_head_data, // used while compiling, transferred to code context - - *ctx_pblocks; // persistent blocks, stores data used by varTable_Names, varTable_Values, etc. - - int l_stats[4]; // source bytes, static code bytes, call code bytes, data bytes - int has_used_global_vars; - - _codeHandleFunctionRec *functions_local, *functions_common; - - // state used while generating functions - int optimizeDisableFlags; - int current_compile_flags; - struct opcodeRec *directValueCache; // linked list using fn as next - - int isSharedFunctions; - int isGeneratingCommonFunction; - int function_usesNamespaces; - int function_globalFlag; // set if restrict globals to function_localTable_Names[2] - // [0] is parameter+local symbols (combined space) - // [1] is symbols which get implied "this." if used - // [2] is globals permitted - int function_localTable_Size[3]; // for parameters only - char **function_localTable_Names[3]; // lists of pointers - EEL_F **function_localTable_ValuePtrs; - const char *function_curName; // name of current function - - EEL_F (*onString)(void *caller_this, struct eelStringSegmentRec *list); - EEL_F (*onNamedString)(void *caller_this, const char *name); - - EEL_F *(*getVariable)(void *userctx, const char *name); - void *getVariable_userctx; - - codeHandleType *tmpCodeHandle; - - struct - { - WDL_UINT64 sign_mask[2]; - WDL_UINT64 abs_mask[2]; - int needfree; - int maxblocks; - double closefact; - EEL_F *blocks[NSEEL_RAM_BLOCKS]; - } *ram_state; // allocated from blocks with 16 byte alignment - - void *gram_blocks; - - void *caller_this; -} -compileContext; - -#define NSEEL_NPARAMS_FLAG_CONST 0x80000 -typedef struct functionType { - const char *name; - void *afunc; - int nParams; - void *replptrs[4]; - NSEEL_PPPROC pProc; -} functionType; - -functionType *nseel_getFunctionByName(compileContext *ctx, const char *name, int *mchk); // sets mchk (if non-NULL) to how far allowed to scan forward for duplicate names -functionType *nseel_enumFunctions(compileContext *ctx, int idx); - -opcodeRec *nseel_createCompiledValue(compileContext *ctx, EEL_F value); -opcodeRec *nseel_createCompiledValuePtr(compileContext *ctx, EEL_F *addrValue, const char *namestr); - -opcodeRec *nseel_createMoreParametersOpcode(compileContext *ctx, opcodeRec *code1, opcodeRec *code2); -opcodeRec *nseel_createSimpleCompiledFunction(compileContext *ctx, int fn, int np, opcodeRec *code1, opcodeRec *code2); -opcodeRec *nseel_createMemoryAccess(compileContext *ctx, opcodeRec *code1, opcodeRec *code2); -opcodeRec *nseel_createIfElse(compileContext *ctx, opcodeRec *code1, opcodeRec *code2, opcodeRec *code3); -opcodeRec *nseel_createFunctionByName(compileContext *ctx, const char *name, int np, opcodeRec *code1, opcodeRec *code2, opcodeRec *code3); - -// converts a generic identifier (VARPTR) opcode into either an actual variable reference (parmcnt = -1), -// or if parmcnt >= 0, to a function call (see nseel_setCompiledFunctionCallParameters()) -opcodeRec *nseel_resolve_named_symbol(compileContext *ctx, opcodeRec *rec, int parmcnt, int *errOut); - -// sets parameters and calculates parameter count for opcode, and calls nseel_resolve_named_symbol() with the right -// parameter count -opcodeRec *nseel_setCompiledFunctionCallParameters(compileContext *ctx, opcodeRec *fn, opcodeRec *code1, opcodeRec *code2, opcodeRec *code3, opcodeRec *postCode, int *errOut); -// errOut will be set if return NULL: -// -1 if postCode set when not wanted (i.e. not while()) -// 0 if func not found, -// 1 if function requires 2+ parameters but was given more -// 2 if function needs more parameters -// 4 if function requires 1 parameter but was given more - - - -struct eelStringSegmentRec *nseel_createStringSegmentRec(compileContext *ctx, const char *str, int len); -opcodeRec *nseel_eelMakeOpcodeFromStringSegments(compileContext *ctx, struct eelStringSegmentRec *rec); - -EEL_F *nseel_int_register_var(compileContext *ctx, const char *name, int isReg, const char **namePtrOut); -_codeHandleFunctionRec *eel_createFunctionNamespacedInstance(compileContext *ctx, _codeHandleFunctionRec *fr, const char *nameptr); - -typedef struct nseel_globalVarItem -{ - EEL_F data; - struct nseel_globalVarItem *_next; - char name[1]; // varlen, does not include _global. prefix -} nseel_globalVarItem; - -extern nseel_globalVarItem *nseel_globalreg_list; // if NSEEL_EEL1_COMPAT_MODE, must use NSEEL_getglobalregs() for regxx values - -#include "y.tab.h" - -// nseel_simple_tokenizer will return comments as tokens if state is non-NULL -const char *nseel_simple_tokenizer(const char **ptr, const char *endptr, int *lenOut, int *state); -int nseel_filter_escaped_string(char *outbuf, int outbuf_sz, const char *rdptr, size_t rdptr_size, char delim_char); // returns length used, minus NUL char - -opcodeRec *nseel_translate(compileContext *ctx, const char *tmp, size_t tmplen); // tmplen=0 for nul-term -int nseel_lookup(compileContext *ctx, opcodeRec **opOut, const char *sname); - -EEL_F * NSEEL_CGEN_CALL __NSEEL_RAMAlloc(EEL_F **blocks, unsigned int w); -EEL_F * NSEEL_CGEN_CALL __NSEEL_RAMAllocGMEM(EEL_F ***blocks, unsigned int w); -EEL_F * NSEEL_CGEN_CALL __NSEEL_RAM_MemSet(EEL_F **blocks,EEL_F *dest, EEL_F *v, EEL_F *lenptr); -EEL_F * NSEEL_CGEN_CALL __NSEEL_RAM_MemFree(void *blocks, EEL_F *which); -EEL_F * NSEEL_CGEN_CALL __NSEEL_RAM_MemTop(void *blocks, EEL_F *which); -EEL_F * NSEEL_CGEN_CALL __NSEEL_RAM_MemCpy(EEL_F **blocks,EEL_F *dest, EEL_F *src, EEL_F *lenptr); -EEL_F NSEEL_CGEN_CALL __NSEEL_RAM_MemSumProducts(EEL_F **blocks,EEL_F *dest, EEL_F *src, EEL_F *lenptr); -EEL_F NSEEL_CGEN_CALL __NSEEL_RAM_MemInsertShuffle(EEL_F **blocks,EEL_F *buf, EEL_F *len, EEL_F *value); -EEL_F NSEEL_CGEN_CALL __NSEEL_RAM_Mem_SetValues(EEL_F **blocks, INT_PTR np, EEL_F **parms); -EEL_F NSEEL_CGEN_CALL __NSEEL_RAM_Mem_GetValues(EEL_F **blocks, INT_PTR np, EEL_F **parms); - -extern EEL_F nseel_ramalloc_onfail; // address returned by __NSEEL_RAMAlloc et al on failure -extern EEL_F * volatile nseel_gmembuf_default; // can free/zero this on DLL unload if needed - -#ifdef __cplusplus -} -#endif - - -#endif//__NS_EELINT_H__ diff --git a/oversampling/WDL/eel2/ns-eel.h b/oversampling/WDL/eel2/ns-eel.h deleted file mode 100644 index 8e1a372..0000000 --- a/oversampling/WDL/eel2/ns-eel.h +++ /dev/null @@ -1,264 +0,0 @@ -/* - Nullsoft Expression Evaluator Library (NS-EEL) - Copyright (C) 1999-2003 Nullsoft, Inc. - - ns-eel.h: main application interface header - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef __NS_EEL_H__ -#define __NS_EEL_H__ - -// put standard includes here -#include -#include - -#ifndef EEL_F_SIZE -#define EEL_F_SIZE 8 -#endif - -#include "../wdltypes.h" - -typedef double EEL_F WDL_FIXALIGN; -typedef double *EEL_F_PTR; - -#ifdef _MSC_VER -#define NSEEL_CGEN_CALL __cdecl -#else -#define NSEEL_CGEN_CALL -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - -// host should implement these (can be empty stub functions if no VM will execute code in multiple threads at once) - - // implement if you will be running the code in same VM from multiple threads, - // or VMs that have the same GRAM pointer from different threads, or multiple - // VMs that have a NULL GRAM pointer from multiple threads. - // if you give each VM it's own unique GRAM and only run each VM in one thread, then you can leave it blank. - - // or if you're daring.... - -void NSEEL_HOSTSTUB_EnterMutex(); -void NSEEL_HOSTSTUB_LeaveMutex(); - - -int NSEEL_init(); // returns nonzero on failure (only if EEL_VALIDATE_FSTUBS defined), otherwise the same as NSEEL_quit(), and completely optional -void NSEEL_quit(); // clears any added functions - - -// adds a function that returns a value (EEL_F) -#define NSEEL_addfunc_retval(name,np,pproc,fptr) \ - NSEEL_addfunc_ret_type(name,np,1,pproc,(void *)(fptr),NSEEL_ADDFUNC_DESTINATION) - -// adds a function that returns a pointer (EEL_F*) -#define NSEEL_addfunc_retptr(name,np,pproc,fptr) \ - NSEEL_addfunc_ret_type(name,np,0,pproc,(void *)(fptr),NSEEL_ADDFUNC_DESTINATION) - -// adds a void or bool function -#define NSEEL_addfunc_retbool(name,np,pproc,fptr) \ - NSEEL_addfunc_ret_type(name,np,-1,pproc,(void *)(fptr),NSEEL_ADDFUNC_DESTINATION) - -// adds a function that takes min_np or more parameters (func sig needs to be EEL_F func(void *ctx, INT_PTR np, EEL_F **parms) -#define NSEEL_addfunc_varparm(name, min_np, pproc, fptr) \ - NSEEL_addfunc_varparm_ex(name,min_np,0,pproc,fptr,NSEEL_ADDFUNC_DESTINATION) - -// adds a function that takes np parameters via func: sig needs to be EEL_F func(void *ctx, INT_PTR np, EEL_F **parms) -#define NSEEL_addfunc_exparms(name, np, pproc, fptr) \ - NSEEL_addfunc_varparm_ex(name,np,1,pproc,fptr,NSEEL_ADDFUNC_DESTINATION) - - -// deprecated -#define NSEEL_addfunction(name,nparms,code,len) NSEEL_addfunctionex((name),(nparms),(code),(len),0,0) -#define NSEEL_addfunctionex(name,nparms,code,len,pproc,fptr) NSEEL_addfunctionex2((name),(nparms),(code),(len),(pproc),(fptr),0, NSEEL_ADDFUNC_DESTINATION) - -#ifndef NSEEL_ADDFUNC_DESTINATION -#define NSEEL_ADDFUNC_DESTINATION (NULL) -#endif - -struct functionType; - -typedef struct -{ - struct functionType *list; - int list_size; -} eel_function_table; - -struct _compileContext; -typedef void *(*NSEEL_PPPROC)(void *data, int data_size, struct _compileContext *userfunc_data); -void NSEEL_addfunctionex2(const char *name, int nparms, char *code_startaddr, int code_len, NSEEL_PPPROC pproc, void *fptr, void *fptr2, eel_function_table *destination); - -void NSEEL_addfunc_ret_type(const char *name, int np, int ret_type, NSEEL_PPPROC pproc, void *fptr, eel_function_table *destination); // ret_type=-1 for bool, 1 for value, 0 for ptr -void NSEEL_addfunc_varparm_ex(const char *name, int min_np, int want_exact, NSEEL_PPPROC pproc, EEL_F (NSEEL_CGEN_CALL *fptr)(void *, INT_PTR, EEL_F **), eel_function_table *destination); -void NSEEL_addfunc_varparm_ctxptr(const char *name, int min_np, int want_exact, void *ctxptr, EEL_F (NSEEL_CGEN_CALL *fptr)(void *, INT_PTR, EEL_F **), eel_function_table *destination); -void NSEEL_addfunc_varparm_ctxptr2(const char *name, int min_np, int want_exact, NSEEL_PPPROC pproc, void *ctx, EEL_F (NSEEL_CGEN_CALL *fptr)(void *, void *,INT_PTR, EEL_F **), eel_function_table *destination); - -int *NSEEL_getstats(); // returns a pointer to 5 ints... source bytes, static code bytes, call code bytes, data bytes, number of code handles - -typedef void *NSEEL_VMCTX; -typedef void *NSEEL_CODEHANDLE; - -NSEEL_VMCTX NSEEL_VM_alloc(); // return a handle -void NSEEL_VM_free(NSEEL_VMCTX ctx); // free when done with a VM and ALL of its code have been freed, as well - -void NSEEL_VM_SetFunctionTable(NSEEL_VMCTX, eel_function_table *tab); // use NULL to use default (global) table - -// validateFunc can return error message if not permitted -void NSEEL_VM_SetFunctionValidator(NSEEL_VMCTX, const char * (*validateFunc)(const char *fn_name, void *user), void *user); - -void NSEEL_VM_remove_unused_vars(NSEEL_VMCTX _ctx); -void NSEEL_VM_clear_var_refcnts(NSEEL_VMCTX _ctx); -void NSEEL_VM_remove_all_nonreg_vars(NSEEL_VMCTX _ctx); -void NSEEL_VM_enumallvars(NSEEL_VMCTX ctx, int (*func)(const char *name, EEL_F *val, void *ctx), void *userctx); // return false from func to stop - -EEL_F *NSEEL_VM_regvar(NSEEL_VMCTX ctx, const char *name); // register a variable (before compilation) -EEL_F *NSEEL_VM_getvar(NSEEL_VMCTX ctx, const char *name); // get a variable (if registered or created by code) -int NSEEL_VM_get_var_refcnt(NSEEL_VMCTX _ctx, const char *name); // returns -1 if not registered, or >=0 -void NSEEL_VM_set_var_resolver(NSEEL_VMCTX ctx, EEL_F *(*res)(void *userctx, const char *name), void *userctx); - -void NSEEL_VM_freeRAM(NSEEL_VMCTX ctx); // clears and frees all (VM) RAM used -void NSEEL_VM_freeRAMIfCodeRequested(NSEEL_VMCTX); // call after code to free the script-requested memory -int NSEEL_VM_wantfreeRAM(NSEEL_VMCTX ctx); // want NSEEL_VM_freeRAMIfCodeRequested? - -// if you set this, it uses a local GMEM context. -// Must be set before compilation. -// void *p=NULL; -// NSEEL_VM_SetGRAM(ctx,&p); -// .. do stuff -// NSEEL_VM_FreeGRAM(&p); -void NSEEL_VM_SetGRAM(NSEEL_VMCTX ctx, void **gram); -void NSEEL_VM_FreeGRAM(void **ufd); // frees a gmem context. -void NSEEL_VM_SetCustomFuncThis(NSEEL_VMCTX ctx, void *thisptr); - -EEL_F *NSEEL_VM_getramptr(NSEEL_VMCTX ctx, unsigned int offs, int *validCount); -EEL_F *NSEEL_VM_getramptr_noalloc(NSEEL_VMCTX ctx, unsigned int offs, int *validCount); - - -// set 0 to query. returns actual value used (limits, granularity apply -- see NSEEL_RAM_BLOCKS) -int NSEEL_VM_setramsize(NSEEL_VMCTX ctx, int maxent); -void NSEEL_VM_preallocram(NSEEL_VMCTX ctx, int maxent); // maxent=-1 for all allocated - - -struct eelStringSegmentRec { - struct eelStringSegmentRec *_next; - const char *str_start; // escaped characters, including opening/trailing characters - int str_len; -}; -void NSEEL_VM_SetStringFunc(NSEEL_VMCTX ctx, - EEL_F (*onString)(void *caller_this, struct eelStringSegmentRec *list), - EEL_F (*onNamedString)(void *caller_this, const char *name)); - -// call with NULL to calculate size, or non-null to generate to buffer (returning size used -- will not null terminate, caller responsibility) -int nseel_stringsegments_tobuf(char *bufOut, int bufout_sz, struct eelStringSegmentRec *list); - - -NSEEL_CODEHANDLE NSEEL_code_compile(NSEEL_VMCTX ctx, const char *code, int lineoffs); -#define NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS 1 // allows that code's functions to be used in other code (note you shouldn't destroy that codehandle without destroying others first if used) -#define NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS_RESET 2 // resets common code functions -#define NSEEL_CODE_COMPILE_FLAG_NOFPSTATE 4 // hint that the FPU/SSE state should be good-to-go -#define NSEEL_CODE_COMPILE_FLAG_ONLY_BUILTIN_FUNCTIONS 8 // very restrictive mode (only math functions really) - -NSEEL_CODEHANDLE NSEEL_code_compile_ex(NSEEL_VMCTX ctx, const char *code, int lineoffs, int flags); - -char *NSEEL_code_getcodeerror(NSEEL_VMCTX ctx); -int NSEEL_code_geterror_flag(NSEEL_VMCTX ctx); -void NSEEL_code_execute(NSEEL_CODEHANDLE code); -void NSEEL_code_free(NSEEL_CODEHANDLE code); -int *NSEEL_code_getstats(NSEEL_CODEHANDLE code); // 4 ints...source bytes, static code bytes, call code bytes, data bytes - - -// global memory control/view -extern unsigned int NSEEL_RAM_limitmem; // if nonzero, memory limit for user data, in bytes -extern unsigned int NSEEL_RAM_memused; -extern int NSEEL_RAM_memused_errors; - - - -// configuration: - -// use the handwritten lexer -- the flex (eel2.l generated) lexer mostly works, but doesn't support string parsing at the moment -// this mode is faster and uses less ram than eel2.l anyway, so leave it on -#define NSEEL_SUPER_MINIMAL_LEXER - - // #define NSEEL_EEL1_COMPAT_MODE // supports old behaviors (continue after failed compile), old functions _bnot etc. disables string support (strings were used as comments in eel1 etc) - -#define NSEEL_MAX_VARIABLE_NAMELEN 128 // define this to override the max variable length -#define NSEEL_MAX_EELFUNC_PARAMETERS 40 -#define NSEEL_MAX_FUNCSIG_NAME 2048 // longer than variable maxlen, due to multiple namespaces - -// maximum loop length (0 for unlimited) -#ifndef NSEEL_LOOPFUNC_SUPPORT_MAXLEN -#define NSEEL_LOOPFUNC_SUPPORT_MAXLEN 1048576 -#endif - -#define NSEEL_MAX_FUNCTION_SIZE_FOR_INLINE 2048 - -// when a VM ctx doesn't have a GRAM context set, make the global one this big -#define NSEEL_SHARED_GRAM_SIZE (1<<20) - -//#define EEL_DUMP_OPS // used for testing frontend parser/logic changes - -// note: if you wish to change NSEEL_RAM_*, and your target is x86-64, you will -// need to edit asm-nseel-x64-sse.asm to match - -// 512 * 65536 = 32 million entries maximum (256MB RAM) -// default is limited to 128 * 65536 = 8 million entries (64MB RAM) - -// default to 8 million entries, use NSEEL_VM_setramsize() to change at runtime -#define NSEEL_RAM_BLOCKS_DEFAULTMAX 128 - -// 512 entry block table maximum (2k/4k per VM) -#define NSEEL_RAM_BLOCKS_LOG2 9 - - // 65536 items per block (512KB) -#define NSEEL_RAM_ITEMSPERBLOCK_LOG2 16 - -#define NSEEL_RAM_BLOCKS (1 << NSEEL_RAM_BLOCKS_LOG2) -#define NSEEL_RAM_ITEMSPERBLOCK (1< -#include - - - -// these are used by our assembly code - - -#define N 624 -#define M 397 -#define MATRIX_A 0x9908b0dfUL /* constant vector a */ -#define UPPER_MASK 0x80000000UL /* most significant w-r bits */ -#define LOWER_MASK 0x7fffffffUL /* least significant r bits */ - -static unsigned int genrand_int32(void) -{ - - unsigned int y; - static unsigned int mag01[2]={0x0UL, MATRIX_A}; - /* mag01[x] = x * MATRIX_A for x=0,1 */ - - static unsigned int mt[N]; /* the array for the state vector */ - static unsigned int __idx; - - unsigned int mti = __idx; - - if (!mti) - { - unsigned int s=0x4141f00d; - mt[0]= s & 0xffffffffUL; - for (mti=1; mti> 30)) + mti); - /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ - /* In the previous versions, MSBs of the seed affect */ - /* only MSBs of the array mt[]. */ - /* 2002/01/09 modified by Makoto Matsumoto */ - mt[mti] &= 0xffffffffUL; - /* for >32 bit machines */ - } - __idx = N; // mti = N (from loop) - } - - if (mti >= N) { /* generate N words at one time */ - int kk; - __idx = 1; - - for (kk=0;kk> 1) ^ mag01[y & 0x1UL]; - } - for (;kk> 1) ^ mag01[y & 0x1UL]; - } - y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK); - mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL]; - - mti = 0; - } - else - __idx++; - - y = mt[mti]; - - /* Tempering */ - y ^= (y >> 11); - y ^= (y << 7) & 0x9d2c5680UL; - y ^= (y << 15) & 0xefc60000UL; - y ^= (y >> 18); - - return y; -} - - - -//--------------------------------------------------------------------------------------------------------------- -EEL_F NSEEL_CGEN_CALL nseel_int_rand(EEL_F f) -{ - EEL_F x=floor(f); - if (x < 1.0) x=1.0; - -#ifdef NSEEL_EEL1_COMPAT_MODE - return (EEL_F)(genrand_int32()%(int)x); -#else - return (EEL_F) (genrand_int32()*(1.0/(double)0xFFFFFFFF)*x); -#endif -} - -//--------------------------------------------------------------------------------------------------------------- - - -#ifndef EEL_TARGET_PORTABLE - -#ifdef __ppc__ -#include "asm-nseel-ppc-gcc.c" -#elif defined(__aarch64__) -#include "asm-nseel-aarch64-gcc.c" -#elif defined(_M_ARM64) || defined(_M_ARM64EC) -// add asm-nseel-aarch64-msvc.obj / asm-nseel-arm64ec.obj to project -#elif defined(__arm__) -#include "asm-nseel-arm-gcc.c" -#elif defined (_M_ARM) && _M_ARM == 7 - // vc on ARM, tbd -#else - #ifdef _MSC_VER - #ifdef _WIN64 - //nasm - #else - #include "asm-nseel-x86-msvc.c" - #endif - #elif !defined(__LP64__) && !defined(_WIN64) - #define EEL_F_SUFFIX "l" - #define FUNCTION_MARKER "\n.byte 0x89,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90\n" - #include "asm-nseel-x86-gcc.c" - #endif -#endif - -#endif diff --git a/oversampling/WDL/eel2/nseel-compiler.c b/oversampling/WDL/eel2/nseel-compiler.c deleted file mode 100644 index a0c39cb..0000000 --- a/oversampling/WDL/eel2/nseel-compiler.c +++ /dev/null @@ -1,5819 +0,0 @@ -/* - Expression Evaluator Library (NS-EEL) v2 - Copyright (C) 2004-2013 Cockos Incorporated - Copyright (C) 1999-2003 Nullsoft, Inc. - - nseel-compiler.c - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "ns-eel-int.h" - -#include "../denormal.h" - -#include -#include -#include -#include - -#include "../wdlcstring.h" - -#if !defined(EEL_TARGET_PORTABLE) && !defined(_WIN32) -#include -#include -#include -#endif - -#ifdef __APPLE__ -#include -#endif - -#define NSEEL_VARS_MALLOC_CHUNKSIZE 8 - -//#define LOG_OPT -//#define EEL_PRINT_FAILS -//#define EEL_VALIDATE_WORKTABLE_USE - - -#ifdef EEL_PRINT_FAILS - #define RET_MINUS1_FAIL(x) { wdl_log("%s\n",x); return -1; } -#else -#define RET_MINUS1_FAIL(x) return -1; -#endif - -#ifdef EEL_DUMP_OPS -FILE *g_eel_dump_fp, *g_eel_dump_fp2; -#endif - -#ifdef EEL_VALIDATE_WORKTABLE_USE - #define MIN_COMPUTABLE_SIZE 0 - #define COMPUTABLE_EXTRA_SPACE 64 // safety buffer, if EEL_VALIDATE_WORKTABLE_USE set, used for magic-value-checking -#else - #define MIN_COMPUTABLE_SIZE 32 // always use at least this big of a temp storage table (and reset the temp ptr when it goes past this boundary) - #define COMPUTABLE_EXTRA_SPACE 16 // safety buffer, if EEL_VALIDATE_WORKTABLE_USE set, used for magic-value-checking -#endif - - -/* - P1 is rightmost parameter - P2 is second rightmost, if any - P3 is third rightmost, if any - registers on x86 are (RAX etc on x86-64) - P1(ret) EAX - P2 EDI - P3 ECX - WTP RSI - x86_64: r12 is a pointer to ram_state->blocks - x86_64: r13 is a pointer to closenessfactor - - registers on PPC are: - P1(ret) r3 - P2 r14 - P3 r15 - WTP r16 (r17 has the original value) - r13 is a pointer to ram_state->blocks - - ppc uses f31 and f30 and others for certain constants - - */ - - -#ifdef EEL_TARGET_PORTABLE - -#define EEL_DOESNT_NEED_EXEC_PERMS - -#ifdef EEL_PORTABLE_TAILCALL -#include "glue_port_new.h" -#else -#include "glue_port.h" -#endif - -#elif defined(__ppc__) - -#include "glue_ppc.h" - -#elif defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC) - -#include "glue_aarch64.h" - -#elif defined(__arm__) || (defined (_M_ARM) && _M_ARM == 7) - -#include "glue_arm.h" - -#elif defined(_WIN64) || defined(__LP64__) - -#include "glue_x86_64_sse.h" - -#else - -#include "glue_x86.h" - -#endif - -#ifndef GLUE_INVSQRT_NEEDREPL -#define GLUE_INVSQRT_NEEDREPL 0 -#endif - - -// used by //#eel-no-optimize:xxx, in ctx->optimizeDisableFlags -#define OPTFLAG_NO_OPTIMIZE 1 -#define OPTFLAG_NO_FPSTACK 2 -#define OPTFLAG_NO_INLINEFUNC 4 -#define OPTFLAG_FULL_DENORMAL_CHECKS 8 // if set, denormals/NaN are always filtered on assign -#define OPTFLAG_NO_DENORMAL_CHECKS 16 // if set and FULL not set, denormals/NaN are never filtered on assign - - -#define DENORMAL_CLEARING_THRESHOLD 1.0e-50 // when adding/subtracting a constant, assume if it's greater than this, it will clear denormal (the actual value is probably 10^-290...) - - -#define MAX_SUB_NAMESPACES 32 -typedef struct -{ - const char *namespacePathToThis; - const char *subParmInfo[MAX_SUB_NAMESPACES]; -} namespaceInformation; - - - - -static int nseel_evallib_stats[5]; // source bytes, static code bytes, call code bytes, data bytes, segments -int *NSEEL_getstats() -{ - return nseel_evallib_stats; -} - -static int findLineNumber(const char *exp, int byteoffs) -{ - int lc=0; - while (byteoffs-->0 && *exp) if (*exp++ =='\n') lc++; - return lc; -} - - -static int nseel_vms_referencing_globallist_cnt; -nseel_globalVarItem *nseel_globalreg_list; -static EEL_F *get_global_var(compileContext *ctx, const char *gv, int addIfNotPresent); - -static void *__newBlock_align(llBlock **start,int size, int align, int code_page_size); - -#define OPCODE_IS_TRIVIAL(x) ((x)->opcodeType <= OPCODETYPE_VARPTRPTR) -enum { - OPCODETYPE_DIRECTVALUE=0, - OPCODETYPE_DIRECTVALUE_TEMPSTRING, // like directvalue, but will generate a new tempstring value on generate - OPCODETYPE_VALUE_FROM_NAMESPACENAME, // this.* or namespace.* are encoded this way - OPCODETYPE_VARPTR, - OPCODETYPE_VARPTRPTR, - OPCODETYPE_FUNC1, - OPCODETYPE_FUNC2, - OPCODETYPE_FUNC3, - OPCODETYPE_FUNCX, - - OPCODETYPE_MOREPARAMS, - - OPCODETYPE_INVALID, -}; - -struct opcodeRec -{ - int opcodeType; - int fntype; - void *fn; - - union { - struct opcodeRec *parms[3]; - struct { - double directValue; - EEL_F *valuePtr; // if direct value, valuePtr can be cached - } dv; - } parms; - - int namespaceidx; - - // OPCODETYPE_VALUE_FROM_NAMESPACENAME (relname is either empty or blah) - // OPCODETYPE_VARPTR if it represents a global variable, will be nonempty - // OPCODETYPE_FUNC* with fntype=FUNCTYPE_EELFUNC - const char *relname; -}; - - - - - -static opcodeRec *newOpCode(compileContext *ctx, const char *str, int opType) -{ - const size_t strszfull = str ? strlen(str) : 0; - const size_t str_sz = wdl_min(NSEEL_MAX_VARIABLE_NAMELEN, strszfull); - - opcodeRec *rec = (opcodeRec*)__newBlock_align(ctx->isSharedFunctions ? &ctx->blocks_head_data : &ctx->tmpblocks, - (int) (sizeof(opcodeRec) + (str_sz>0 ? str_sz+1 : 0)), - 8, 0); - if (rec) - { - memset(rec,0,sizeof(*rec)); - rec->opcodeType = opType; - - if (str_sz > 0) - { - char *p = (char *)(rec+1); - memcpy(p,str,str_sz); - p[str_sz]=0; - - rec->relname = p; - } - else - { - rec->relname = ""; - } - } - - return rec; -} - -#ifndef EEL_DOESNT_NEED_EXEC_PERMS -static int eel_get_page_size(void) -{ - static int pagesize; - if (!pagesize) - { -#ifndef _WIN32 - const int ps = (int)sysconf(_SC_PAGESIZE); - pagesize = wdl_max(ps, 4096); -#else - SYSTEM_INFO inf = { 0 }; - GetSystemInfo(&inf); - pagesize = wdl_max(inf.dwPageSize, 4096); -#endif - } - return pagesize; -} -#endif - -#define newCodeBlock(x,a) __newBlock_align(&ctx->blocks_head_code,x,a, 1) -#define newDataBlock(x,a) __newBlock_align(&ctx->blocks_head_data,x,a,0) -#define newCtxDataBlock(x,a) __newBlock_align(&ctx->ctx_pblocks,x,a,0) -#define newTmpBlock(ctx, size) __newBlock_align(&(ctx)->tmpblocks, size, 8,0) - -static char *eel_get_llblock_buffer(llBlock *llb) { return (char *) (llb+1); } - -#ifndef EEL_DOESNT_NEED_EXEC_PERMS -static void eel_set_blocks_allow_execute(llBlock *llb, int exec) -{ - while (llb) - { - const size_t sz = sizeof(*llb) + llb->sizealloc; - #ifdef _WIN32 - DWORD ov; - VirtualProtect(llb,sz,exec ? (PAGE_EXECUTE_READ) : (PAGE_READWRITE),&ov); - FlushInstructionCache(GetCurrentProcess(),llb,sz); - #else - mprotect(llb,sz,exec ? (PROT_READ|PROT_EXEC) : (PROT_READ|PROT_WRITE)); - #ifdef __APPLE__ - if (exec) sys_icache_invalidate(llb,sz); - #endif - #endif - WDL_ASSERT((((INT_PTR)llb) & (eel_get_page_size()-1)) == 0); - WDL_ASSERT((sz & (eel_get_page_size()-1)) == 0); - llb = llb->next; - } -} -#endif - -static void freeBlocks(llBlock **start, int is_code); - -static int __growbuf_resize(eel_growbuf *buf, int newsize) -{ - if (newsize<0) - { - free(buf->ptr); - buf->ptr=NULL; - buf->alloc=buf->size=0; - return 0; - } - - if (newsize > buf->alloc) - { - const int newalloc = newsize + 4096 + newsize/2; - void *newptr = realloc(buf->ptr,newalloc); - if (!newptr) - { - newptr = malloc(newalloc); - if (!newptr) return 1; - if (buf->ptr && buf->size) memcpy(newptr,buf->ptr,buf->size); - free(buf->ptr); - buf->ptr=newptr; - } - else - buf->ptr = newptr; - - buf->alloc=newalloc; - } - buf->size = newsize; - return 0; -} - - -#ifndef DECL_ASMFUNC -#define DECL_ASMFUNC(x) void nseel_asm_##x(void); - - -void _asm_megabuf(void); -void _asm_gmegabuf(void); - -#endif - - - DECL_ASMFUNC(booltofp) - DECL_ASMFUNC(fptobool) - DECL_ASMFUNC(fptobool_rev) - DECL_ASMFUNC(sin) - DECL_ASMFUNC(cos) - DECL_ASMFUNC(tan) - DECL_ASMFUNC(1pdd) - DECL_ASMFUNC(2pdd) - DECL_ASMFUNC(2pdds) - DECL_ASMFUNC(1pp) - DECL_ASMFUNC(2pp) - DECL_ASMFUNC(sqr) - DECL_ASMFUNC(sqrt) - DECL_ASMFUNC(log) - DECL_ASMFUNC(log10) - DECL_ASMFUNC(abs) - DECL_ASMFUNC(min) - DECL_ASMFUNC(max) - DECL_ASMFUNC(min_fp) - DECL_ASMFUNC(max_fp) - DECL_ASMFUNC(sig) - DECL_ASMFUNC(sign) - DECL_ASMFUNC(band) - DECL_ASMFUNC(bor) - DECL_ASMFUNC(bnot) - DECL_ASMFUNC(if) - DECL_ASMFUNC(fcall) - DECL_ASMFUNC(repeat) - DECL_ASMFUNC(repeatwhile) - DECL_ASMFUNC(equal) - DECL_ASMFUNC(equal_exact) - DECL_ASMFUNC(notequal_exact) - DECL_ASMFUNC(notequal) - DECL_ASMFUNC(below) - DECL_ASMFUNC(above) - DECL_ASMFUNC(beloweq) - DECL_ASMFUNC(aboveeq) - DECL_ASMFUNC(assign) - DECL_ASMFUNC(assign_fromfp) - DECL_ASMFUNC(assign_fast) - DECL_ASMFUNC(assign_fast_fromfp) - DECL_ASMFUNC(add) - DECL_ASMFUNC(sub) - DECL_ASMFUNC(add_op) - DECL_ASMFUNC(sub_op) - DECL_ASMFUNC(add_op_fast) - DECL_ASMFUNC(sub_op_fast) - DECL_ASMFUNC(mul) - DECL_ASMFUNC(div) - DECL_ASMFUNC(mul_op) - DECL_ASMFUNC(div_op) - DECL_ASMFUNC(mul_op_fast) - DECL_ASMFUNC(div_op_fast) - DECL_ASMFUNC(mod) - DECL_ASMFUNC(shl) - DECL_ASMFUNC(shr) - DECL_ASMFUNC(mod_op) - DECL_ASMFUNC(or) - DECL_ASMFUNC(or0) - DECL_ASMFUNC(xor) - DECL_ASMFUNC(xor_op) - DECL_ASMFUNC(and) - DECL_ASMFUNC(or_op) - DECL_ASMFUNC(and_op) - DECL_ASMFUNC(uminus) - DECL_ASMFUNC(invsqrt) - DECL_ASMFUNC(dbg_getstackptr) - - DECL_ASMFUNC(stack_push) - DECL_ASMFUNC(stack_pop) - DECL_ASMFUNC(stack_pop_fast) // just returns value, doesn't mod param - DECL_ASMFUNC(stack_peek) - DECL_ASMFUNC(stack_peek_int) - DECL_ASMFUNC(stack_peek_top) - DECL_ASMFUNC(stack_exch) - -static void *NSEEL_PProc_GRAM(void *data, int data_size, compileContext *ctx) -{ - if (data_size>0) data=EEL_GLUE_set_immediate(data, (INT_PTR)ctx->gram_blocks); - return data; -} - -static void *NSEEL_PProc_Stack(void *data, int data_size, compileContext *ctx) -{ - codeHandleType *ch=ctx->tmpCodeHandle; - - if (data_size>0) - { - UINT_PTR m1=(UINT_PTR)(NSEEL_STACK_SIZE * sizeof(EEL_F) - 1); - UINT_PTR stackptr = ((UINT_PTR) (&ch->stack)); - - ch->want_stack=1; - if (!ch->stack) ch->stack = newDataBlock(NSEEL_STACK_SIZE*sizeof(EEL_F),NSEEL_STACK_SIZE*sizeof(EEL_F)); // stack functions need this alignment - - data=EEL_GLUE_set_immediate(data, stackptr); - data=EEL_GLUE_set_immediate(data, m1); // and - data=EEL_GLUE_set_immediate(data, ((UINT_PTR)ch->stack&~m1)); //or - } - return data; -} - -static void *NSEEL_PProc_Stack_PeekInt(void *data, int data_size, compileContext *ctx, INT_PTR offs) -{ - codeHandleType *ch=ctx->tmpCodeHandle; - - if (data_size>0) - { - UINT_PTR m1=(UINT_PTR)(NSEEL_STACK_SIZE * sizeof(EEL_F) - 1); - UINT_PTR stackptr = ((UINT_PTR) (&ch->stack)); - - ch->want_stack=1; - if (!ch->stack) ch->stack = newDataBlock(NSEEL_STACK_SIZE*sizeof(EEL_F),NSEEL_STACK_SIZE*sizeof(EEL_F)); // stack functions need this alignment - - data=EEL_GLUE_set_immediate(data, stackptr); - data=EEL_GLUE_set_immediate(data, offs); - data=EEL_GLUE_set_immediate(data, m1); // and - data=EEL_GLUE_set_immediate(data, ((UINT_PTR)ch->stack&~m1)); //or - } - return data; -} -static void *NSEEL_PProc_Stack_PeekTop(void *data, int data_size, compileContext *ctx) -{ - codeHandleType *ch=ctx->tmpCodeHandle; - - if (data_size>0) - { - UINT_PTR stackptr = ((UINT_PTR) (&ch->stack)); - - ch->want_stack=1; - if (!ch->stack) ch->stack = newDataBlock(NSEEL_STACK_SIZE*sizeof(EEL_F),NSEEL_STACK_SIZE*sizeof(EEL_F)); // stack functions need this alignment - - data=EEL_GLUE_set_immediate(data, stackptr); - } - return data; -} - -#if defined(_MSC_VER) && _MSC_VER >= 1400 -static double eel__floor(double a) { return floor(a); } -static double eel__ceil(double a) { return ceil(a); } -#define floor eel__floor -#define ceil eel__ceil -#endif - - -#ifdef NSEEL_EEL1_COMPAT_MODE -static double eel1band(double a, double b) -{ - return (fabs(a)>NSEEL_CLOSEFACTOR && fabs(b) > NSEEL_CLOSEFACTOR) ? 1.0 : 0.0; -} -static double eel1bor(double a, double b) -{ - return (fabs(a)>NSEEL_CLOSEFACTOR || fabs(b) > NSEEL_CLOSEFACTOR) ? 1.0 : 0.0; -} - -static double eel1sigmoid(double x, double constraint) -{ - double t = (1+exp(-x * (constraint))); - return fabs(t)>NSEEL_CLOSEFACTOR ? 1.0/t : 0; -} - -#endif - - - -#define FUNCTIONTYPE_PARAMETERCOUNTMASK 0xff - -#define BIF_NPARAMS_MASK 0x7ffff00 -#define BIF_RETURNSONSTACK 0x0000100 -#define BIF_LASTPARMONSTACK 0x0000200 -#define BIF_RETURNSBOOL 0x0000400 -#define BIF_LASTPARM_ASBOOL 0x0000800 -// 0x00?0000 -- taken by FP stack flags -#define BIF_TAKES_VARPARM 0x0400000 -#define BIF_TAKES_VARPARM_EX 0x0C00000 // this is like varparm but check count exactly -#define BIF_WONTMAKEDENORMAL 0x0100000 -#define BIF_CLEARDENORMAL 0x0200000 - -#if GLUE_HAS_FPREG2 > 0 && GLUE_MAX_FPSTACK_SIZE > 0 -#error GLUE_HAS_FPREG2 and GLUE_MAX_FPSTACK_SIZE are exclusive -#endif - -#if GLUE_MAX_SPILL_REGS > 0 && GLUE_HAS_FPREG2 <= 0 -#error GLUE_MAX_SPILL_REGS requires GLUE_HAS_FPREG2 -#endif - -#if GLUE_MAX_FPSTACK_SIZE > 0 || GLUE_HAS_FPREG2 > 0 - #define BIF_SECONDLASTPARMST 0x0001000 // use with BIF_LASTPARMONSTACK only (last two parameters get passed on fp stack) - #define BIF_LAZYPARMORDERING 0x0002000 // allow optimizer to avoid fxch when using BIF_TWOPARMSONFPSTACK_LAZY etc -#else - #define BIF_SECONDLASTPARMST 0 - #define BIF_LAZYPARMORDERING 0 -#endif - -#if GLUE_MAX_FPSTACK_SIZE > 0 - #define BIF_REVERSEFPORDER 0x0004000 // force a fxch (reverse order of last two parameters on fp stack, used by comparison functions) - #ifndef BIF_FPSTACKUSE - #define BIF_FPSTACKUSE(x) (((x)>=0&&(x)<8) ? ((7-(x))<<16):0) - #endif - #ifndef BIF_GETFPSTACKUSE - #define BIF_GETFPSTACKUSE(x) (7 - (((x)>>16)&7)) - #endif -#else - #define BIF_REVERSEFPORDER 0 - #define BIF_FPSTACKUSE(x) 0 - #define BIF_GETFPSTACKUSE(x) 0 -#endif - -#define BIF_TWOPARMSONFPSTACK (BIF_SECONDLASTPARMST|BIF_LASTPARMONSTACK) -#define BIF_TWOPARMSONFPSTACK_LAZY (BIF_LAZYPARMORDERING|BIF_SECONDLASTPARMST|BIF_LASTPARMONSTACK) - - -#ifndef GLUE_HAS_NATIVE_TRIGSQRTLOG -static double sqrt_fabs(double a) { return sqrt(fabs(a)); } -#endif - - -EEL_F NSEEL_CGEN_CALL nseel_int_rand(EEL_F f); - -#define FNPTR_HAS_CONDITIONAL_EXEC(op) \ - (op->fntype == FN_LOGICAL_AND || \ - op->fntype == FN_LOGICAL_OR || \ - op->fntype == FN_IF_ELSE || \ - op->fntype == FN_WHILE || \ - op->fntype == FN_LOOP) - -static functionType fnTable1[] = { -#ifndef GLUE_HAS_NATIVE_TRIGSQRTLOG - { "sin", nseel_asm_1pdd, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_WONTMAKEDENORMAL, {&sin} }, - { "cos", nseel_asm_1pdd, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_CLEARDENORMAL, {&cos} }, - { "tan", nseel_asm_1pdd, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK, {&tan} }, - { "sqrt", nseel_asm_1pdd, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_WONTMAKEDENORMAL, {&sqrt_fabs}, }, - { "log", nseel_asm_1pdd, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK, {&log} }, - { "log10", nseel_asm_1pdd, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK, {&log10} }, -#else - { "sin", nseel_asm_sin, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_WONTMAKEDENORMAL|BIF_FPSTACKUSE(1) }, - { "cos", nseel_asm_cos, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_CLEARDENORMAL|BIF_FPSTACKUSE(1) }, - { "tan", nseel_asm_tan, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(1) }, - { "sqrt", nseel_asm_sqrt, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(1)|BIF_WONTMAKEDENORMAL }, - { "log", nseel_asm_log, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(3), }, - { "log10", nseel_asm_log10, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(3), }, -#endif - - - { "asin", nseel_asm_1pdd, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK, {&asin}, }, - { "acos", nseel_asm_1pdd, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK, {&acos}, }, - { "atan", nseel_asm_1pdd, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK, {&atan}, }, - { "atan2", nseel_asm_2pdd, 2|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK, {&atan2}, }, - { "exp", nseel_asm_1pdd, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK, {&exp}, }, - { "abs", nseel_asm_abs, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(0)|BIF_WONTMAKEDENORMAL }, - { "sqr", nseel_asm_sqr, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(1) }, - { "min", nseel_asm_min, 2|NSEEL_NPARAMS_FLAG_CONST|BIF_FPSTACKUSE(3)|BIF_WONTMAKEDENORMAL }, - { "max", nseel_asm_max, 2|NSEEL_NPARAMS_FLAG_CONST|BIF_FPSTACKUSE(3)|BIF_WONTMAKEDENORMAL }, - { "sign", nseel_asm_sign, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(2)|BIF_CLEARDENORMAL, }, - { "rand", nseel_asm_1pdd, 1|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_CLEARDENORMAL, {&nseel_int_rand}, }, - - { "floor", nseel_asm_1pdd, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_CLEARDENORMAL, {&floor} }, - { "ceil", nseel_asm_1pdd, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_CLEARDENORMAL, {&ceil} }, - - { "invsqrt", nseel_asm_invsqrt, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(3), {GLUE_INVSQRT_NEEDREPL} }, - - { "__dbg_getstackptr", nseel_asm_dbg_getstackptr, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(1), }, - -#ifdef NSEEL_EEL1_COMPAT_MODE - { "sigmoid", nseel_asm_2pdd, 2|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK, {&eel1sigmoid}, }, - - // these differ from _and/_or, they always evaluate both... - { "band", nseel_asm_2pdd, 2|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK|BIF_CLEARDENORMAL , {&eel1band}, }, - { "bor", nseel_asm_2pdd, 2|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK|BIF_CLEARDENORMAL , {&eel1bor}, }, - - {"exec2", NULL, 2|NSEEL_NPARAMS_FLAG_CONST|BIF_WONTMAKEDENORMAL}, - {"exec3", NULL, 3|NSEEL_NPARAMS_FLAG_CONST|BIF_WONTMAKEDENORMAL}, -#endif // end EEL1 compat - - - {"freembuf",_asm_generic1parm,1,{&__NSEEL_RAM_MemFree},NSEEL_PProc_RAM}, - {"memcpy",_asm_generic3parm, 3,{&__NSEEL_RAM_MemCpy},NSEEL_PProc_RAM}, - {"memset",_asm_generic3parm, 3,{&__NSEEL_RAM_MemSet},NSEEL_PProc_RAM}, - {"__memtop",_asm_generic1parm,1,{&__NSEEL_RAM_MemTop},NSEEL_PProc_RAM}, - {"mem_set_values",_asm_generic2parm_retd,2|BIF_TAKES_VARPARM|BIF_RETURNSONSTACK,{&__NSEEL_RAM_Mem_SetValues},NSEEL_PProc_RAM}, - {"mem_get_values",_asm_generic2parm_retd,2|BIF_TAKES_VARPARM|BIF_RETURNSONSTACK,{&__NSEEL_RAM_Mem_GetValues},NSEEL_PProc_RAM}, - {"mem_multiply_sum",_asm_generic3parm_retd, 3|BIF_RETURNSONSTACK,{&__NSEEL_RAM_MemSumProducts},NSEEL_PProc_RAM}, - {"mem_insert_shuffle",_asm_generic3parm_retd, 3|BIF_RETURNSONSTACK, {&__NSEEL_RAM_MemInsertShuffle},NSEEL_PProc_RAM}, - - {"stack_push",nseel_asm_stack_push,1|BIF_FPSTACKUSE(0),{0,},NSEEL_PProc_Stack}, - {"stack_pop",nseel_asm_stack_pop, 1|BIF_FPSTACKUSE(1),{0,},NSEEL_PProc_Stack}, - {"stack_peek",nseel_asm_stack_peek,1|NSEEL_NPARAMS_FLAG_CONST|BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(0),{0,},NSEEL_PProc_Stack}, - {"stack_exch",nseel_asm_stack_exch,1|BIF_FPSTACKUSE(1), {0,},NSEEL_PProc_Stack_PeekTop}, -}; -static functionType fn_min2 = { "min2", nseel_asm_min_fp, 2|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK_LAZY|BIF_FPSTACKUSE(2)|BIF_WONTMAKEDENORMAL }; -static functionType fn_max2 = { "max2", nseel_asm_max_fp, 2|NSEEL_NPARAMS_FLAG_CONST|BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK_LAZY|BIF_FPSTACKUSE(2)|BIF_WONTMAKEDENORMAL }; -static functionType fn_or0 = { "or0", nseel_asm_or0, 1|NSEEL_NPARAMS_FLAG_CONST|BIF_LASTPARMONSTACK|BIF_RETURNSONSTACK|BIF_CLEARDENORMAL }; - -static eel_function_table default_user_funcs; - -static int functable_lowerbound(functionType *list, int list_sz, const char *name, int *ismatch) -{ - int a = 0, c = list_sz; - while (a != c) - { - const int b = (a+c)/2; - const int cmp = stricmp(name,list[b].name); - if (cmp > 0) a = b+1; - else if (cmp < 0) c = b; - else - { - *ismatch = 1; - return b; - } - } - *ismatch = 0; - return a; -} - -static int funcTypeCmp(const void *a, const void *b) { return stricmp(((functionType*)a)->name,((functionType*)b)->name); } - -functionType *nseel_getFunctionByName(compileContext *ctx, const char *name, int *mchk) -{ - eel_function_table *tab = ctx && ctx->registered_func_tab ? ctx->registered_func_tab : &default_user_funcs; - static char sorted; - const int fn1size = (int) (sizeof(fnTable1)/sizeof(fnTable1[0])); - int idx,match; - if (!sorted) - { - NSEEL_HOSTSTUB_EnterMutex(); - if (!sorted) qsort(fnTable1,fn1size,sizeof(fnTable1[0]),funcTypeCmp); - sorted=1; - NSEEL_HOSTSTUB_LeaveMutex(); - } - idx=functable_lowerbound(fnTable1,fn1size,name,&match); - if (match) return fnTable1+idx; - - if ((!ctx || !(ctx->current_compile_flags&NSEEL_CODE_COMPILE_FLAG_ONLY_BUILTIN_FUNCTIONS)) && tab->list) - { - idx=functable_lowerbound(tab->list,tab->list_size,name,&match); - if (match) - { - if (mchk) - { - while (idx>0 && !stricmp(tab->list[idx-1].name,name)) idx--; - *mchk = tab->list_size - 1 - idx; - } - return tab->list + idx; - } - } - - return NULL; -} - -functionType *nseel_enumFunctions(compileContext *ctx, int idx) -{ - eel_function_table *tab = ctx && ctx->registered_func_tab ? ctx->registered_func_tab : &default_user_funcs; - const int fn1size = (int) (sizeof(fnTable1)/sizeof(fnTable1[0])); - if (idx >= 0 && idx < fn1size) return fnTable1 + idx; - if ((!ctx || !(ctx->current_compile_flags&NSEEL_CODE_COMPILE_FLAG_ONLY_BUILTIN_FUNCTIONS)) && tab->list) - { - idx -= fn1size; - if (idx>=0 && idx < tab->list_size) - return tab->list + idx; - } - - return NULL; -} - -int NSEEL_init() // returns 0 on success -{ - NSEEL_quit(); - return 0; -} - -void NSEEL_quit() -{ - free(default_user_funcs.list); - default_user_funcs.list = NULL; - default_user_funcs.list_size = 0; -} - -void NSEEL_addfunc_varparm_ex(const char *name, int min_np, int want_exact, NSEEL_PPPROC pproc, EEL_F (NSEEL_CGEN_CALL *fptr)(void *, INT_PTR, EEL_F **), eel_function_table *destination) -{ - NSEEL_addfunctionex2(name,min_np|(want_exact?BIF_TAKES_VARPARM_EX:BIF_TAKES_VARPARM),(char *)_asm_generic2parm_retd,0,pproc,fptr,NULL,destination); -} - -void NSEEL_addfunc_varparm_ctxptr(const char *name, int min_np, int want_exact, void *ctxptr, EEL_F (NSEEL_CGEN_CALL *fptr)(void *, INT_PTR, EEL_F **), eel_function_table *destination) -{ - NSEEL_addfunctionex2(name,min_np|(want_exact?BIF_TAKES_VARPARM_EX:BIF_TAKES_VARPARM),(char *)_asm_generic2parm_retd,0,NULL,ctxptr,fptr,destination); -} - -void NSEEL_addfunc_varparm_ctxptr2(const char *name, int min_np, int want_exact, NSEEL_PPPROC pproc, void *ctx, EEL_F (NSEEL_CGEN_CALL *fptr)(void *, void *, INT_PTR, EEL_F **), eel_function_table *destination) -{ - NSEEL_addfunctionex2(name,min_np|(want_exact?BIF_TAKES_VARPARM_EX:BIF_TAKES_VARPARM),(char *)_asm_generic2xparm_retd,0,pproc,ctx,fptr,destination); -} - -void NSEEL_addfunc_ret_type(const char *name, int np, int ret_type, NSEEL_PPPROC pproc, void *fptr, eel_function_table *destination) // ret_type=-1 for bool, 1 for value, 0 for ptr -{ - char *stub=NULL; - int stubsz=0; -#define DOSTUB(np) { \ - stub = (ret_type == 1 ? (char*)_asm_generic##np##parm_retd : (char*)_asm_generic##np##parm); \ - } - - WDL_ASSERT(np >= 1 && np <= 3); // use np=1 if you want "zero" parameters - - if (np == 1) DOSTUB(1) - else if (np == 2) DOSTUB(2) - else if (np == 3) DOSTUB(3) -#undef DOSTUB - - if (stub) NSEEL_addfunctionex2(name,np|(ret_type == -1 ? BIF_RETURNSBOOL:0), stub, stubsz, pproc,fptr,NULL,destination); -} - -void NSEEL_addfunctionex2(const char *name, int nparms, char *code_startaddr, int code_len /* ignored*/, - NSEEL_PPPROC pproc, void *fptr, void *fptr2, eel_function_table *destination) -{ - const int list_size_chunk = 128; - functionType *r; - if (!destination) destination = &default_user_funcs; - - if (!destination->list || !(destination->list_size & (list_size_chunk-1))) - { - void *nv = realloc(destination->list, (destination->list_size + list_size_chunk)*sizeof(functionType)); - if (!nv) return; - destination->list = (functionType *)nv; - } - if (destination->list) - { - int match,idx; - - idx=functable_lowerbound(destination->list,destination->list_size,name,&match); - - r = destination->list + idx; - if (idx < destination->list_size) - memmove(r + 1, r, (destination->list_size - idx) * sizeof(functionType)); - destination->list_size++; - - memset(r, 0, sizeof(functionType)); - - if (!(nparms & BIF_RETURNSBOOL)) - { - if (code_startaddr == (void *)&_asm_generic1parm_retd || - code_startaddr == (void *)&_asm_generic2parm_retd || - code_startaddr == (void *)&_asm_generic2xparm_retd || - code_startaddr == (void *)&_asm_generic3parm_retd) - { - nparms |= BIF_RETURNSONSTACK; - } - } - r->nParams = nparms; - r->name = name; - r->afunc = code_startaddr; - r->pProc = pproc; - r->replptrs[0] = fptr; - r->replptrs[1] = fptr2; - } -} - - -//--------------------------------------------------------------------------------------------------------------- -static void freeBlocks(llBlock **start, int is_code) -{ - llBlock *s=*start; - *start=0; - while (s) - { - llBlock *llB = s->next; -#ifndef EEL_DOESNT_NEED_EXEC_PERMS - if (is_code) - { - #ifdef _WIN32 - VirtualFree(s, 0, MEM_RELEASE); - #else - munmap(s,sizeof(*s) + s->sizealloc); - #endif - } - else -#endif - { - free(s); - } - s=llB; - } -} - - -//--------------------------------------------------------------------------------------------------------------- -static void *__newBlock_align(llBlock **start, int size, int align, int is_for_code) -{ - llBlock *llb = *start; - int alloc_amt, align_pos, scan_cnt=8; - if (WDL_NOT_NORMALLY(align < 1)) align = 1; - - while (llb && --scan_cnt > 0) - { - const int sizeused = llb->sizeused; - if (sizeused + size <= llb->sizealloc) - { - align_pos = (int) (((INT_PTR)eel_get_llblock_buffer(llb) + sizeused)&(align-1)); - if (align_pos) align_pos = align - align_pos; - - if (sizeused + size + align_pos <= llb->sizealloc) - { - llb->sizeused += size + align_pos; - return eel_get_llblock_buffer(llb) + sizeused + align_pos; - } - } - llb = llb->next; - } - -#ifndef EEL_DOESNT_NEED_EXEC_PERMS - if (is_for_code) - { - const int code_page_size = eel_get_page_size(); - alloc_amt = (sizeof(*llb) + size + code_page_size - 1) & ~(code_page_size-1); - #ifdef _WIN32 - #ifdef _M_ARM64EC - { - MEM_EXTENDED_PARAMETER ext; - memset(&ext,0,sizeof(ext)); - ext.Type = MemExtendedParameterAttributeFlags; - ext.ULong64 = MEM_EXTENDED_PARAMETER_EC_CODE; - llb = (llBlock *)VirtualAlloc2(NULL,NULL,alloc_amt,MEM_COMMIT,PAGE_EXECUTE_READ,&ext,1); - if (WDL_NORMALLY(llb)) - { - DWORD ov; - VirtualProtect(llb, alloc_amt, PAGE_READWRITE, &ov); - } - } - #else - llb = (llBlock *)VirtualAlloc(NULL,alloc_amt,MEM_COMMIT,PAGE_READWRITE); - #endif - if (llb == NULL) return NULL; - #else - #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) - llb = (llBlock *)mmap(NULL,alloc_amt, PROT_READ|PROT_WRITE,MAP_ANON|MAP_PRIVATE,-1,0); - #else - llb = (llBlock *)mmap(NULL,alloc_amt, PROT_READ|PROT_WRITE,MAP_ANONYMOUS|MAP_PRIVATE,-1,0); - #endif - if (llb == MAP_FAILED) return NULL; - #endif - alloc_amt -= sizeof(*llb); - align_pos = 0; - - WDL_ASSERT(((INT_PTR)llb & (code_page_size - 1))==0); - WDL_ASSERT(((INT_PTR)(eel_get_llblock_buffer(llb) + alloc_amt) & (code_page_size - 1))==0); - } - else -#endif - { - // data block, allocate in larger chunks - alloc_amt = (size + align - 1 + 31)&~31; - if (alloc_amt < 65536-64) alloc_amt = 65536-64; - - llb = (llBlock *)malloc(sizeof(*llb) + alloc_amt); - if (!llb) return NULL; - align_pos = (int) (((INT_PTR)eel_get_llblock_buffer(llb))&(align-1)); - if (align_pos) align_pos = align - align_pos; - } - - WDL_ASSERT(size+align_pos <= alloc_amt); - llb->sizeused = size + align_pos; - llb->sizealloc = alloc_amt; - llb->next = *start; - *start = llb; - return eel_get_llblock_buffer(llb) + align_pos; -} - - -//--------------------------------------------------------------------------------------------------------------- -opcodeRec *nseel_createCompiledValue(compileContext *ctx, EEL_F value) -{ - opcodeRec *r=newOpCode(ctx,NULL,OPCODETYPE_DIRECTVALUE); - if (r) - { - r->parms.dv.directValue = value; - } - return r; -} - -opcodeRec *nseel_createCompiledValuePtr(compileContext *ctx, EEL_F *addrValue, const char *namestr) -{ - opcodeRec *r=newOpCode(ctx,namestr,OPCODETYPE_VARPTR); - if (!r) return 0; - - r->parms.dv.valuePtr=addrValue; - - return r; -} - -static int validate_varname_for_function(compileContext *ctx, const char *name) -{ - if (!ctx->function_curName || !ctx->function_globalFlag) return 1; - - if (ctx->function_localTable_Size[2] > 0 && ctx->function_localTable_Names[2]) - { - char * const * const namelist = ctx->function_localTable_Names[2]; - const int namelist_sz = ctx->function_localTable_Size[2]; - int i; - const size_t name_len = strlen(name); - - for (i=0;i 1 && nmchk[l-1] == '*') - { - if (name_len >= l && !strnicmp(nmchk,name,l-1) && name[l-1]=='.') return 1; - } - else - { - if (name_len == l && !stricmp(nmchk,name)) return 1; - } - } - } - - return 0; -} - -opcodeRec *nseel_resolve_named_symbol(compileContext *ctx, opcodeRec *rec, int parmcnt, int *errOut) -{ - const int isFunctionMode = parmcnt >= 0; - int rel_prefix_len=0; - int rel_prefix_idx=-2; - int i; - char match_parmcnt[4]={-1,-1,-1,-1}; // [3] is guess - unsigned char match_parmcnt_pos=0; - char *sname = (char *)rec->relname; - int is_string_prefix = parmcnt < 0 && sname[0] == '#'; - const char *prevent_function_calls = NULL; - - if (errOut) *errOut = 0; - - if (sname) sname += is_string_prefix; - - if (rec->opcodeType != OPCODETYPE_VARPTR || !sname || !sname[0]) return NULL; - - if (!isFunctionMode && !is_string_prefix && !strnicmp(sname,"reg",3) && isdigit(sname[3]) && isdigit(sname[4]) && !sname[5]) - { - EEL_F *a=get_global_var(ctx,sname,1); - if (a) - { - rec->parms.dv.valuePtr = a; - sname[0]=0; // for dump_ops compat really, but this shouldn't be needed anyway - } - return rec; - } - - if (ctx->function_curName) - { - if (!strnicmp(sname,"this.",5)) - { - rel_prefix_len=5; - rel_prefix_idx=-1; - } - else if (!stricmp(sname,"this")) - { - rel_prefix_len=4; - rel_prefix_idx=-1; - } - - // scan for parameters/local variables before user functions - if (rel_prefix_idx < -1 && - ctx->function_localTable_Size[0] > 0 && - ctx->function_localTable_Names[0] && - ctx->function_localTable_ValuePtrs) - { - char * const * const namelist = ctx->function_localTable_Names[0]; - const int namelist_sz = ctx->function_localTable_Size[0]; - for (i=0; i < namelist_sz; i++) - { - const char *p = namelist[i]; - if (p) - { - if (!isFunctionMode && !is_string_prefix && !strnicmp(p,sname,NSEEL_MAX_VARIABLE_NAMELEN)) - { - rec->opcodeType = OPCODETYPE_VARPTRPTR; - rec->parms.dv.valuePtr=(EEL_F *)(ctx->function_localTable_ValuePtrs+i); - rec->parms.dv.directValue=0.0; - return rec; - } - else - { - const size_t plen = strlen(p); - if (plen > 1 && p[plen-1] == '*' && !strnicmp(p,sname,plen-1) && ((sname[plen-1] == '.'&&sname[plen]) || !sname[plen-1])) - { - rel_prefix_len=(int) (sname[plen-1] ? plen : plen-1); - rel_prefix_idx=i; - break; - } - } - } - } - } - // if instance name set, translate sname or sname.* into "this.sname.*" - if (rel_prefix_idx < -1 && - ctx->function_localTable_Size[1] > 0 && - ctx->function_localTable_Names[1]) - { - char * const * const namelist = ctx->function_localTable_Names[1]; - const int namelist_sz = ctx->function_localTable_Size[1]; - const char *full_sname = rec->relname; // include # in checks - for (i=0; i < namelist_sz; i++) - { - const char *p = namelist[i]; - if (p && *p) - { - const size_t tl = strlen(p); - if (!strnicmp(p,full_sname,tl) && (full_sname[tl] == 0 || full_sname[tl] == '.')) - { - rel_prefix_len=0; // treat as though this. prefixes is present - rel_prefix_idx=-1; - break; - } - } - } - } - if (rel_prefix_idx >= -1) - { - ctx->function_usesNamespaces=1; - } - } // ctx->function_curName - - if (!isFunctionMode) - { - // instance variables - if (rel_prefix_idx >= -1) - { - rec->opcodeType = OPCODETYPE_VALUE_FROM_NAMESPACENAME; - rec->namespaceidx = rel_prefix_idx; - if (rel_prefix_len > 0) - { - if (is_string_prefix) sname[-1] = '#'; - memmove(sname, sname+rel_prefix_len, strlen(sname + rel_prefix_len) + 1); - } - } - else - { - // no namespace index, so it must be a global - if (!validate_varname_for_function(ctx,rec->relname)) - { - if (errOut) *errOut = 1; - if (ctx->last_error_string[0]) lstrcatn(ctx->last_error_string, ", ", sizeof(ctx->last_error_string)); - snprintf_append(ctx->last_error_string,sizeof(ctx->last_error_string),"global '%s' inaccessible",rec->relname); - return NULL; - } - } - - return rec; - } - - if (ctx->func_check) - prevent_function_calls = ctx->func_check(sname,ctx->func_check_user); - - ////////// function mode - // first off, while() and loop() are special and can't be overridden - // - if (parmcnt == 1 && !stricmp("while",sname) && !prevent_function_calls) - { - rec->opcodeType = OPCODETYPE_FUNC1; - rec->fntype = FN_WHILE; - return rec; - } - if (parmcnt == 2 && !stricmp("loop",sname) && !prevent_function_calls) - { - rec->opcodeType = OPCODETYPE_FUNC2; - rec->fntype = FN_LOOP; - return rec; - } - - // - // resolve user function names before builtin functions -- this allows the user to override default functions - if (!(ctx->current_compile_flags & NSEEL_CODE_COMPILE_FLAG_ONLY_BUILTIN_FUNCTIONS)) - { - _codeHandleFunctionRec *best=NULL; - size_t bestlen=0; - const char * const ourcall = sname+rel_prefix_len; - const size_t ourcall_len = strlen(ourcall); - int pass; - for (pass=0;pass<2;pass++) - { - _codeHandleFunctionRec *fr = pass ? ctx->functions_common : ctx->functions_local; - // sname is [namespace.[ns.]]function, find best match of function that matches the right end - while (fr) - { - int this_np = fr->num_params; - const char *thisfunc = fr->fname; - const size_t thisfunc_len = strlen(thisfunc); - if (this_np < 1) this_np=1; - if (thisfunc_len == ourcall_len && !stricmp(thisfunc,ourcall)) - { - if (this_np == parmcnt) - { - bestlen = thisfunc_len; - best = fr; - break; // found exact match, finished - } - else - { - if (match_parmcnt_pos < 3) match_parmcnt[match_parmcnt_pos++] = fr->num_params; - } - } - - if (thisfunc_len > bestlen && thisfunc_len < ourcall_len && ourcall[ourcall_len - thisfunc_len - 1] == '.' && !stricmp(thisfunc,ourcall + ourcall_len - thisfunc_len)) - { - if (this_np == parmcnt) - { - bestlen = thisfunc_len; - best = fr; - } - else - if (match_parmcnt[3]<0) match_parmcnt[3]=fr->num_params; - } - fr=fr->next; - } - if (fr) break; // found exact match, finished - } - - if (best) - { - switch (parmcnt) - { - case 0: - case 1: rec->opcodeType = OPCODETYPE_FUNC1; break; - case 2: rec->opcodeType = OPCODETYPE_FUNC2; break; - case 3: rec->opcodeType = OPCODETYPE_FUNC3; break; - default: rec->opcodeType = OPCODETYPE_FUNCX; break; - } - if (ourcall != rec->relname) memmove((char *)rec->relname, ourcall, strlen(ourcall)+1); - - if (ctx->function_curName && rel_prefix_idx<0) - { - // if no namespace specified, and this.commonprefix.func() called, remove common prefixes and set prefixidx to be this - const char *p=ctx->function_curName; - if (*p) p++; - while (*p && *p != '.') p++; - if (*p && p[1]) // we have a dot! - { - while (p[1]) p++; // go to last char of string, which doesn't allow possible trailing dot to be checked - - while (--p > ctx->function_curName) // do not check possible leading dot - { - if (*p == '.') - { - const size_t cmplen = p+1-ctx->function_curName; - if (!strnicmp(rec->relname,ctx->function_curName,cmplen) && rec->relname[cmplen]) - { - const char *src=rec->relname + cmplen; - memmove((char *)rec->relname, src, strlen(src)+1); - rel_prefix_idx=-1; - ctx->function_usesNamespaces=1; - break; - } - } - } - } - } - - if (ctx->function_curName && rel_prefix_idx < -1 && - strchr(rec->relname,'.') && !validate_varname_for_function(ctx,rec->relname)) - { - if (errOut) *errOut = 1; - if (ctx->last_error_string[0]) lstrcatn(ctx->last_error_string, ", ", sizeof(ctx->last_error_string)); - snprintf_append(ctx->last_error_string,sizeof(ctx->last_error_string),"namespaced function '%s' inaccessible",rec->relname); - return NULL; - } - - rec->namespaceidx = rel_prefix_idx; - rec->fntype = FUNCTYPE_EELFUNC; - rec->fn = best; - return rec; - } - } - - if (prevent_function_calls) - { - if (ctx->last_error_string[0]) lstrcatn(ctx->last_error_string, ", ", sizeof(ctx->last_error_string)); - snprintf_append(ctx->last_error_string,sizeof(ctx->last_error_string),"'%.30s': %s",sname, prevent_function_calls); - if (errOut) *errOut = 0; - return NULL; - } - -#ifdef NSEEL_EEL1_COMPAT_MODE - if (!stricmp(sname,"assign")) - { - if (parmcnt == 2) - { - rec->opcodeType = OPCODETYPE_FUNC2; - rec->fntype = FN_ASSIGN; - return rec; - } - if (match_parmcnt_pos < 3) match_parmcnt[match_parmcnt_pos++] = 2; - } - else if (!stricmp(sname,"if")) - { - if (parmcnt == 3) - { - rec->opcodeType = OPCODETYPE_FUNC3; - rec->fntype = FN_IF_ELSE; - return rec; - } - if (match_parmcnt_pos < 3) match_parmcnt[match_parmcnt_pos++] = 3; - } - else if (!stricmp(sname,"equal")) - { - if (parmcnt == 2) - { - rec->opcodeType = OPCODETYPE_FUNC2; - rec->fntype = FN_EQ; - return rec; - } - if (match_parmcnt_pos < 3) match_parmcnt[match_parmcnt_pos++] = 2; - } - else if (!stricmp(sname,"below")) - { - if (parmcnt == 2) - { - rec->opcodeType = OPCODETYPE_FUNC2; - rec->fntype = FN_LT; - return rec; - } - if (match_parmcnt_pos < 3) match_parmcnt[match_parmcnt_pos++] = 2; - } - else if (!stricmp(sname,"above")) - { - if (parmcnt == 2) - { - rec->opcodeType = OPCODETYPE_FUNC2; - rec->fntype = FN_GT; - return rec; - } - if (match_parmcnt_pos < 3) match_parmcnt[match_parmcnt_pos++] = 2; - } - else if (!stricmp(sname,"bnot")) - { - if (parmcnt == 1) - { - rec->opcodeType = OPCODETYPE_FUNC1; - rec->fntype = FN_NOT; - return rec; - } - if (match_parmcnt_pos < 3) match_parmcnt[match_parmcnt_pos++] = 1; - } - else if (!stricmp(sname,"megabuf")) - { - if (parmcnt == 1) - { - rec->opcodeType = OPCODETYPE_FUNC1; - rec->fntype = FN_MEMORY; - return rec; - } - if (match_parmcnt_pos < 3) match_parmcnt[match_parmcnt_pos++] = 1; - } - else if (!stricmp(sname,"gmegabuf")) - { - if (parmcnt == 1) - { - rec->opcodeType = OPCODETYPE_FUNC1; - rec->fntype = FN_GMEMORY; - return rec; - } - if (match_parmcnt_pos < 3) match_parmcnt[match_parmcnt_pos++] = 1; - } - else -#endif - // convert legacy pow() to FN_POW - if (!stricmp("pow",sname)) - { - if (parmcnt == 2) - { - rec->opcodeType = OPCODETYPE_FUNC2; - rec->fntype = FN_POW; - return rec; - } - if (match_parmcnt_pos < 3) match_parmcnt[match_parmcnt_pos++] = 2; - } - else if (!stricmp("__denormal_likely",sname) || !stricmp("__denormal_unlikely",sname)) - { - if (parmcnt == 1) - { - rec->opcodeType = OPCODETYPE_FUNC1; - rec->fntype = !stricmp("__denormal_likely",sname) ? FN_DENORMAL_LIKELY : FN_DENORMAL_UNLIKELY; - return rec; - } - } - - { - int chkamt=0; - functionType *f=nseel_getFunctionByName(ctx,sname,&chkamt); - if (f) while (chkamt-->=0) - { - const int pc_needed=(f->nParams&FUNCTIONTYPE_PARAMETERCOUNTMASK); - if ((f->nParams&BIF_TAKES_VARPARM_EX)==BIF_TAKES_VARPARM ? (parmcnt >= pc_needed) : (parmcnt == pc_needed)) - { - rec->fntype = FUNCTYPE_FUNCTIONTYPEREC; - rec->fn = (void *)f; - switch (parmcnt) - { - case 0: - case 1: rec->opcodeType = OPCODETYPE_FUNC1; break; - case 2: rec->opcodeType = OPCODETYPE_FUNC2; break; - case 3: rec->opcodeType = OPCODETYPE_FUNC3; break; - default: rec->opcodeType = OPCODETYPE_FUNCX; break; - } - return rec; - } - if (match_parmcnt_pos < 3) match_parmcnt[match_parmcnt_pos++] = (f->nParams&FUNCTIONTYPE_PARAMETERCOUNTMASK); - f++; - if (stricmp(f->name,sname)) break; - } - } - if (ctx->last_error_string[0]) lstrcatn(ctx->last_error_string, ", ", sizeof(ctx->last_error_string)); - if (match_parmcnt[3] >= 0) - { - if (match_parmcnt_pos<3) match_parmcnt[match_parmcnt_pos] = match_parmcnt[3]; - match_parmcnt_pos++; - } - - if (!match_parmcnt_pos) - snprintf_append(ctx->last_error_string,sizeof(ctx->last_error_string),"'%.30s' undefined",sname); - else - { - int x; - snprintf_append(ctx->last_error_string,sizeof(ctx->last_error_string),"'%.30s' needs ",sname); - for (x = 0; x < match_parmcnt_pos; x++) - snprintf_append(ctx->last_error_string,sizeof(ctx->last_error_string),"%s%d",x==0?"" : x == match_parmcnt_pos-1?" or ":",",match_parmcnt[x]); - lstrcatn(ctx->last_error_string," parms",sizeof(ctx->last_error_string)); - } - if (errOut) *errOut = match_parmcnt_pos > 0 ? parmcntopcodeType != OPCODETYPE_VARPTR || !fn->relname || !fn->relname[0]) - { - return NULL; - } - fn->parms.parms[0] = code1; - fn->parms.parms[1] = code2; - fn->parms.parms[2] = code3; - - for (x=0;x<3;x++) - { - opcodeRec *prni=fn->parms.parms[x]; - while (prni && np < NSEEL_MAX_EELFUNC_PARAMETERS) - { - const int isMP = prni->opcodeType == OPCODETYPE_MOREPARAMS; - np++; - if (!isMP) break; - prni = prni->parms.parms[1]; - } - } - r = nseel_resolve_named_symbol(ctx, fn, np<1 ? 1 : np ,errOut); - if (postCode && r) - { - if (code1 && r->opcodeType == OPCODETYPE_FUNC1 && r->fntype == FN_WHILE) - { - // change while(x) (postcode) to be - // while ((x) ? (postcode;1) : 0); - - r->parms.parms[0] = - nseel_createIfElse(ctx,r->parms.parms[0], - nseel_createSimpleCompiledFunction(ctx,FN_JOIN_STATEMENTS,2,postCode,nseel_createCompiledValue(ctx,1.0f)), - NULL); // NULL defaults to 0.0 - - } - else - { - snprintf_append(ctx->last_error_string,sizeof(ctx->last_error_string),"syntax error following function"); - *errOut = -1; - return NULL; - } - } - return r; -} - - -struct eelStringSegmentRec *nseel_createStringSegmentRec(compileContext *ctx, const char *str, int len) -{ - struct eelStringSegmentRec *r = newTmpBlock(ctx,sizeof(struct eelStringSegmentRec)); - if (r) - { - r->_next=0; - r->str_start=str; - r->str_len = len; - } - return r; -} - -opcodeRec *nseel_eelMakeOpcodeFromStringSegments(compileContext *ctx, struct eelStringSegmentRec *rec) -{ - if (ctx && ctx->onString) - { - return nseel_createCompiledValue(ctx, ctx->onString(ctx->caller_this,rec)); - } - - return NULL; -} - -opcodeRec *nseel_createMoreParametersOpcode(compileContext *ctx, opcodeRec *code1, opcodeRec *code2) -{ - opcodeRec *r=code1 && code2 ? newOpCode(ctx,NULL,OPCODETYPE_MOREPARAMS) : NULL; - if (r) - { - r->parms.parms[0] = code1; - r->parms.parms[1] = code2; - } - return r; -} - - -opcodeRec *nseel_createIfElse(compileContext *ctx, opcodeRec *code1, opcodeRec *code2, opcodeRec *code3) -{ - opcodeRec *r=code1 ? newOpCode(ctx,NULL,OPCODETYPE_FUNC3) : NULL; - if (r) - { - if (!code2) code2 = nseel_createCompiledValue(ctx,0.0); - if (!code3) code3 = nseel_createCompiledValue(ctx,0.0); - if (!code2||!code3) return NULL; - - r->fntype = FN_IF_ELSE; - r->parms.parms[0] = code1; - r->parms.parms[1] = code2; - r->parms.parms[2] = code3; - } - return r; -} - - -opcodeRec *nseel_createMemoryAccess(compileContext *ctx, opcodeRec *code1, opcodeRec *code2) -{ - if (code1 && code1->opcodeType == OPCODETYPE_VARPTR && !stricmp(code1->relname,"gmem")) - { - return nseel_createSimpleCompiledFunction(ctx, FN_GMEMORY,1,code2?code2:nseel_createCompiledValue(ctx,0.0),0); - } - if (code2 && (code2->opcodeType != OPCODETYPE_DIRECTVALUE || code2->parms.dv.directValue != 0.0)) - { - code1 = nseel_createSimpleCompiledFunction(ctx,FN_ADD,2,code1,code2); - } - return nseel_createSimpleCompiledFunction(ctx, FN_MEMORY,1,code1,0); -} - -opcodeRec *nseel_createSimpleCompiledFunction(compileContext *ctx, int fn, int np, opcodeRec *code1, opcodeRec *code2) -{ - opcodeRec *r=code1 && (np<2 || code2) ? newOpCode(ctx,NULL,np>=2 ? OPCODETYPE_FUNC2:OPCODETYPE_FUNC1) : NULL; - if (r) - { - r->fntype = fn; - r->parms.parms[0] = code1; - r->parms.parms[1] = code2; - if (fn == FN_JOIN_STATEMENTS) - { - r->fn = r; // for joins, fn is temporarily used for tail pointers - if (code1 && code1->opcodeType == OPCODETYPE_FUNC2 && code1->fntype == fn) - { - opcodeRec *t = (opcodeRec *)code1->fn; - // keep joins in the form of dosomething->morestuff. - // in this instance, code1 is previous stuff to do, code2 is new stuff to do - r->parms.parms[0] = t->parms.parms[1]; - - code1->fn = (t->parms.parms[1] = r); - return code1; - } - } - } - return r; -} - - -// these are bitmasks; on request you can tell what is supported, and compileOpcodes will return one of them -#define RETURNVALUE_IGNORE 0 // ignore return value -#define RETURNVALUE_NORMAL 1 // pointer -#define RETURNVALUE_FPSTACK 2 -#define RETURNVALUE_BOOL 4 // P1 is nonzero if true -#define RETURNVALUE_BOOL_REVERSED 8 // P1 is zero if true -#define RETURNVALUE_CACHEABLE 16 // only to be used when (at least) RETURNVALUE_NORMAL is set -#if GLUE_HAS_FPREG2 > 0 -#define RETURNVALUE_FPREG2 32 // only usable for compileOpcodes() on a trivial opcode -#endif - - - -static int compileOpcodes(compileContext *ctx, opcodeRec *op, unsigned char *bufOut, int bufOut_len, int *computTable, const namespaceInformation *namespacePathToThis, - int supportedReturnValues, int *rvType, int *fpStackUsage, int *canHaveDenormalOutput); - - -static unsigned char *compileCodeBlockWithRet(compileContext *ctx, opcodeRec *rec, int *computTableSize, const namespaceInformation *namespacePathToThis, - int supportedReturnValues, int *rvType, int *fpStackUse, int *canHaveDenormalOutput); - -_codeHandleFunctionRec *eel_createFunctionNamespacedInstance(compileContext *ctx, _codeHandleFunctionRec *fr, const char *nameptr) -{ - size_t n; - _codeHandleFunctionRec *subfr = - fr->isCommonFunction ? - ctx->isSharedFunctions ? newDataBlock(sizeof(_codeHandleFunctionRec),8) : - newCtxDataBlock(sizeof(_codeHandleFunctionRec),8) : // if common function, but derived version is in non-common context, set ownership to VM rather than us - newTmpBlock(ctx,sizeof(_codeHandleFunctionRec)); - - if (!subfr) return 0; - // fr points to functionname()'s rec, nameptr to blah.functionname() - - *subfr = *fr; - n = strlen(nameptr); - if (n > sizeof(subfr->fname)-1) n=sizeof(subfr->fname)-1; - memcpy(subfr->fname,nameptr,n); - subfr->fname[n]=0; - - subfr->next = NULL; - subfr->startptr=0; // make sure this code gets recompiled (with correct member ptrs) for this instance! - subfr->startptr_size=-1; - - // subfr->derivedCopies already points to the right place - fr->derivedCopies = subfr; - - return subfr; - -} -static void combineNamespaceFields(char *nm, const namespaceInformation *namespaceInfo, const char *relname, int thisctx) // nm must be NSEEL_MAX_VARIABLE_NAMELEN+1 bytes -{ - const char *prefix = namespaceInfo ? - thisctx<0 ? (thisctx == -1 ? namespaceInfo->namespacePathToThis : NULL) : (thisctx < MAX_SUB_NAMESPACES ? namespaceInfo->subParmInfo[thisctx] : NULL) - : NULL; - int lfp = 0, lrn=relname ? (int)strlen(relname) : 0; - if (prefix) while (prefix[lfp] && prefix[lfp] != ':' && lfp < NSEEL_MAX_VARIABLE_NAMELEN) lfp++; - if (!relname) relname = ""; - - while (*relname == '.') // if relname begins with ., then remove a chunk of context from prefix - { - relname++; - while (lfp>0 && prefix[lfp-1] != '.') lfp--; - if (lfp>0) lfp--; - } - - if (lfp > NSEEL_MAX_VARIABLE_NAMELEN-3) lfp=NSEEL_MAX_VARIABLE_NAMELEN-3; - if (lfp>0) memcpy(nm,prefix,lfp); - - if (lrn > NSEEL_MAX_VARIABLE_NAMELEN - lfp - (lfp>0)) lrn=NSEEL_MAX_VARIABLE_NAMELEN - lfp - (lfp>0); - if (lrn > 0) - { - if (lfp>0) nm[lfp++] = '.'; - memcpy(nm+lfp,relname,lrn); - lfp+=lrn; - } - nm[lfp++]=0; -} - - -//--------------------------------------------------------------------------------------------------------------- -static void *nseel_getBuiltinFunctionAddress(compileContext *ctx, - int fntype, void *fn, - NSEEL_PPPROC *pProc, void ***replList, - int *abiInfo, int preferredReturnValues, const EEL_F *hasConstParm1, const EEL_F *hasConstParm2) -{ - const EEL_F *firstConstParm = hasConstParm1 ? hasConstParm1 : hasConstParm2; - static void *pow_replptrs[4]={&pow,}; - - switch (fntype) - { -#define RF(x) return (void*)nseel_asm_##x - - case FN_MUL_OP: - *abiInfo=BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(2)|BIF_CLEARDENORMAL; - RF(mul_op); - case FN_DIV_OP: - *abiInfo=BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(2)|BIF_CLEARDENORMAL; - RF(div_op); - case FN_OR_OP: - *abiInfo=BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(2)|BIF_CLEARDENORMAL; - RF(or_op); - case FN_XOR_OP: - *abiInfo=BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(2)|BIF_CLEARDENORMAL; - RF(xor_op); - case FN_AND_OP: - *abiInfo=BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(2)|BIF_CLEARDENORMAL; - RF(and_op); - case FN_MOD_OP: - *abiInfo=BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(2)|BIF_CLEARDENORMAL; - RF(mod_op); - case FN_ADD_OP: - *abiInfo=BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(2)|BIF_CLEARDENORMAL; - RF(add_op); - case FN_SUB_OP: - *abiInfo=BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(2)|BIF_CLEARDENORMAL; - RF(sub_op); - case FN_POW_OP: - *abiInfo=BIF_LASTPARMONSTACK|BIF_CLEARDENORMAL; - *replList = pow_replptrs; - RF(2pdds); - case FN_POW: - *abiInfo = BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK;//BIF_FPSTACKUSE(2) might be safe, need to look at pow()'s implementation, but safer bet is to disallow fp stack caching for this expression - *replList = pow_replptrs; - RF(2pdd); - case FN_ADD: - *abiInfo = BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK_LAZY|BIF_FPSTACKUSE(2); - // for x +- non-denormal-constant, we can set BIF_CLEARDENORMAL - if (firstConstParm && fabs(*firstConstParm) > DENORMAL_CLEARING_THRESHOLD) *abiInfo |= BIF_CLEARDENORMAL; - RF(add); - case FN_SUB: - *abiInfo = BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK|BIF_FPSTACKUSE(2); - // for x +- non-denormal-constant, we can set BIF_CLEARDENORMAL - if (firstConstParm && fabs(*firstConstParm) > DENORMAL_CLEARING_THRESHOLD) *abiInfo |= BIF_CLEARDENORMAL; - RF(sub); - case FN_MULTIPLY: - *abiInfo = BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK_LAZY|BIF_FPSTACKUSE(2); - // for x*constant-greater-than-eq-1, we can set BIF_WONTMAKEDENORMAL - if (firstConstParm && fabs(*firstConstParm) >= 1.0) *abiInfo |= BIF_WONTMAKEDENORMAL; - RF(mul); - case FN_DIVIDE: - *abiInfo = BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK|BIF_FPSTACKUSE(2); - // for x/constant-less-than-eq-1, we can set BIF_WONTMAKEDENORMAL - if (firstConstParm && fabs(*firstConstParm) <= 1.0) *abiInfo |= BIF_WONTMAKEDENORMAL; - RF(div); - case FN_MOD: - *abiInfo = BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK|BIF_FPSTACKUSE(1)|BIF_CLEARDENORMAL; - RF(mod); - case FN_ASSIGN: - *abiInfo = BIF_FPSTACKUSE(1)|BIF_CLEARDENORMAL; - RF(assign); - case FN_AND: *abiInfo = BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK_LAZY|BIF_FPSTACKUSE(2)|BIF_CLEARDENORMAL; RF(and); - case FN_OR: *abiInfo = BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK_LAZY|BIF_FPSTACKUSE(2)|BIF_CLEARDENORMAL; RF(or); - case FN_XOR: - *abiInfo = BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK_LAZY|BIF_FPSTACKUSE(2)|BIF_CLEARDENORMAL; - RF(xor); - case FN_SHR: - *abiInfo = BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK|BIF_FPSTACKUSE(2)|BIF_CLEARDENORMAL; - RF(shr); - case FN_SHL: - *abiInfo = BIF_RETURNSONSTACK|BIF_TWOPARMSONFPSTACK|BIF_FPSTACKUSE(2)|BIF_CLEARDENORMAL; - RF(shl); - case FN_NOTNOT: *abiInfo = BIF_LASTPARM_ASBOOL|BIF_RETURNSBOOL|BIF_FPSTACKUSE(1); break; - case FN_UMINUS: *abiInfo = BIF_RETURNSONSTACK|BIF_LASTPARMONSTACK|BIF_WONTMAKEDENORMAL; RF(uminus); - case FN_NOT: *abiInfo = BIF_LASTPARM_ASBOOL|BIF_RETURNSBOOL|BIF_FPSTACKUSE(1); RF(bnot); - - case FN_EQ: - *abiInfo = BIF_TWOPARMSONFPSTACK_LAZY|BIF_RETURNSBOOL|BIF_FPSTACKUSE(2); - RF(equal); - case FN_EQ_EXACT: - *abiInfo=BIF_TWOPARMSONFPSTACK_LAZY|BIF_RETURNSBOOL|BIF_FPSTACKUSE(2); - RF(equal_exact); - case FN_NE: - *abiInfo=BIF_TWOPARMSONFPSTACK_LAZY|BIF_RETURNSBOOL|BIF_FPSTACKUSE(2); - RF(notequal); - case FN_NE_EXACT: - *abiInfo=BIF_TWOPARMSONFPSTACK_LAZY|BIF_RETURNSBOOL|BIF_FPSTACKUSE(2); - RF(notequal_exact); - case FN_LOGICAL_AND: - *abiInfo = BIF_RETURNSBOOL; - RF(band); - case FN_LOGICAL_OR: - *abiInfo = BIF_RETURNSBOOL; - RF(bor); - - case FN_GT: - *abiInfo = BIF_TWOPARMSONFPSTACK|BIF_RETURNSBOOL|BIF_FPSTACKUSE(2); - RF(above); - case FN_GTE: - *abiInfo = BIF_TWOPARMSONFPSTACK|BIF_RETURNSBOOL|BIF_REVERSEFPORDER|BIF_FPSTACKUSE(2); -#if BIF_REVERSEFPORDER > 0 - RF(beloweq); -#else - RF(aboveeq); -#endif - case FN_LT: - *abiInfo = BIF_TWOPARMSONFPSTACK|BIF_RETURNSBOOL|BIF_REVERSEFPORDER|BIF_FPSTACKUSE(2); -#if BIF_REVERSEFPORDER > 0 - RF(above); -#else - RF(below); -#endif - case FN_LTE: - *abiInfo = BIF_TWOPARMSONFPSTACK|BIF_RETURNSBOOL|BIF_FPSTACKUSE(2); - RF(beloweq); - -#undef RF -#define RF(x) return (void*)_asm_##x - - case FN_MEMORY: - { - static void *replptrs[4]={&__NSEEL_RAMAlloc,}; - *replList = replptrs; - *abiInfo = BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(1)|BIF_CLEARDENORMAL; - #ifdef GLUE_MEM_NEEDS_PPROC - *pProc = NSEEL_PProc_RAM; - #endif - RF(megabuf); - } - break; - case FN_GMEMORY: - { - static void *replptrs[4]={&__NSEEL_RAMAllocGMEM,}; - *replList = replptrs; - *abiInfo=BIF_LASTPARMONSTACK|BIF_FPSTACKUSE(1)|BIF_CLEARDENORMAL; - *pProc=NSEEL_PProc_GRAM; - RF(gmegabuf); - } - break; -#undef RF - - case FUNCTYPE_FUNCTIONTYPEREC: - if (fn) - { - functionType *p=(functionType *)fn; - - // if prefers fpstack or bool, or ignoring value, then use fp-stack versions - if ((preferredReturnValues&(RETURNVALUE_BOOL|RETURNVALUE_FPSTACK)) || !preferredReturnValues) - { - if (p->afunc == (void*)nseel_asm_min) p = &fn_min2; - else if (p->afunc == (void*)nseel_asm_max) p = &fn_max2; - } - - *replList=p->replptrs; - *pProc=p->pProc; - *abiInfo = p->nParams & BIF_NPARAMS_MASK; - if (firstConstParm) - { - const char *name=p->name; - if (!strcmp(name,"min") && *firstConstParm < -1.0e-10) *abiInfo |= BIF_CLEARDENORMAL; - else if (!strcmp(name,"max") && *firstConstParm > 1.0e-10) *abiInfo |= BIF_CLEARDENORMAL; - } - return p->afunc; - } - break; - } - - return NULL; -} - - - -static void *nseel_getEELFunctionAddress(compileContext *ctx, - opcodeRec *op, - int *customFuncParmSize, int *customFuncLocalStorageSize, - EEL_F ***customFuncLocalStorage, int *computTableTop, - void **endP, int *isRaw, int wantCodeGenerated, - const namespaceInformation *namespacePathToThis, int *rvMode, int *fpStackUse, int *canHaveDenormalOutput, - opcodeRec **ordered_parmptrs, int num_ordered_parmptrs - ) // if wantCodeGenerated is false, can return bogus pointers in raw mode -{ - _codeHandleFunctionRec *fn = (_codeHandleFunctionRec*)op->fn; - - namespaceInformation local_namespace={NULL}; - char prefix_buf[NSEEL_MAX_VARIABLE_NAMELEN+1], nm[NSEEL_MAX_FUNCSIG_NAME+1]; - if (!fn) return NULL; - - // op->relname ptr is [whatever.]funcname - if (fn->parameterAsNamespaceMask || fn->usesNamespaces) - { - if (wantCodeGenerated) - { - char *p = prefix_buf; - combineNamespaceFields(nm,namespacePathToThis,op->relname,op->namespaceidx); - lstrcpyn_safe(prefix_buf,nm,sizeof(prefix_buf)); - local_namespace.namespacePathToThis = prefix_buf; - // nm is full path of function, prefix_buf will be the path not including function name (unless function name only) - while (*p) p++; - while (p >= prefix_buf && *p != '.') p--; - if (p > prefix_buf) *p=0; - } - if (fn->parameterAsNamespaceMask) - { - int x; - for(x=0;xnum_params;x++) - { - if (fn->parameterAsNamespaceMask & (((unsigned int)1)<opcodeType == OPCODETYPE_VARPTR) - { - rn=ordered_parmptrs[x]->relname; - } - else if (ordered_parmptrs[x]->opcodeType == OPCODETYPE_VALUE_FROM_NAMESPACENAME) - { - const char *p=ordered_parmptrs[x]->relname; - if (*p == '#') p++; - combineNamespaceFields(tmp,namespacePathToThis,p,ordered_parmptrs[x]->namespaceidx); - rn = tmp; - } - } - - if (!rn) - { - // todo: figure out how to give correct line number/offset (ugh) - snprintf(ctx->last_error_string,sizeof(ctx->last_error_string),"parameter %d to %.120s() must be namespace",x+1,fn->fname); - return NULL; - } - - lstrcatn(nm,":",sizeof(nm)); - - local_namespace.subParmInfo[x] = nm+strlen(nm); - lstrcatn(nm,rn,sizeof(nm)); - } - ordered_parmptrs[x] = NULL; // prevent caller from bothering generating parameters - } - } - } - if (wantCodeGenerated) - { - _codeHandleFunctionRec *fr = fn; - // find namespace-adjusted function (if generating code, otherwise assume size is the same) - fn = 0; // if this gets re-set, it will be the new function - while (fr && !fn) - { - if (!stricmp(fr->fname,nm)) fn = fr; - fr=fr->derivedCopies; - } - if (!fn) // generate copy of function - { - fn = eel_createFunctionNamespacedInstance(ctx,(_codeHandleFunctionRec*)op->fn,nm); - } - } - } - if (!fn) return NULL; - - if (!fn->startptr && fn->opcodes && fn->startptr_size != 0) - { - int sz = fn->startptr_size; - - if (sz < 0) - { - fn->tmpspace_req=0; - fn->rvMode = RETURNVALUE_IGNORE; - fn->canHaveDenormalOutput=0; - - sz = compileOpcodes(ctx,fn->opcodes,NULL,128*1024*1024,&fn->tmpspace_req, - wantCodeGenerated ? &local_namespace : NULL,RETURNVALUE_FPSTACK, - &fn->rvMode,&fn->fpStackUsage,&fn->canHaveDenormalOutput); - if (sz<0) return NULL; - - fn->startptr_base_size = fn->startptr_size = sz; - } - - if (!wantCodeGenerated) - { - // don't compile anything for now, just give stats - if (computTableTop) *computTableTop += fn->tmpspace_req; - *customFuncParmSize = fn->num_params; - *customFuncLocalStorage = fn->localstorage; - *customFuncLocalStorageSize = fn->localstorage_size; - *rvMode = fn->rvMode; - *fpStackUse = fn->fpStackUsage; - if (canHaveDenormalOutput) *canHaveDenormalOutput=fn->canHaveDenormalOutput; - - if (fn->startptr_base_size <= NSEEL_MAX_FUNCTION_SIZE_FOR_INLINE && - !(ctx->optimizeDisableFlags&OPTFLAG_NO_INLINEFUNC)) - { - *isRaw = 1; - *endP = ((char *)1) + fn->startptr_base_size; - return (char *)1; - } - return (void*)nseel_asm_fcall; - } - - if (fn->startptr_base_size <= NSEEL_MAX_FUNCTION_SIZE_FOR_INLINE && - !(ctx->optimizeDisableFlags&OPTFLAG_NO_INLINEFUNC)) - { - void *p=newTmpBlock(ctx,sz); - fn->tmpspace_req=0; - if (p) - { - fn->canHaveDenormalOutput=0; - if (fn->isCommonFunction) ctx->isGeneratingCommonFunction++; - sz=compileOpcodes(ctx,fn->opcodes,(unsigned char*)p,sz,&fn->tmpspace_req,&local_namespace,RETURNVALUE_FPSTACK,&fn->rvMode,&fn->fpStackUsage,&fn->canHaveDenormalOutput); - if (fn->isCommonFunction) ctx->isGeneratingCommonFunction--; - // recompile function with native context pointers - if (sz>0) - { - fn->startptr_size=sz; - fn->startptr=p; - } - } - } - else - { - unsigned char *codeCall; - fn->tmpspace_req=0; - fn->fpStackUsage=0; - fn->canHaveDenormalOutput=0; - if (fn->isCommonFunction) ctx->isGeneratingCommonFunction++; - codeCall=compileCodeBlockWithRet(ctx,fn->opcodes,&fn->tmpspace_req,&local_namespace,RETURNVALUE_FPSTACK,&fn->rvMode,&fn->fpStackUsage,&fn->canHaveDenormalOutput); - if (fn->isCommonFunction) ctx->isGeneratingCommonFunction--; - if (codeCall) - { - void *f=GLUE_realAddress(nseel_asm_fcall,&sz); - fn->startptr = newTmpBlock(ctx,sz); - if (fn->startptr) - { - memcpy(fn->startptr,f,sz); - EEL_GLUE_set_immediate(fn->startptr,(INT_PTR)codeCall); - fn->startptr_size = sz; - } - } - } - } - - if (fn->startptr) - { - if (computTableTop) *computTableTop += fn->tmpspace_req; - *customFuncParmSize = fn->num_params; - *customFuncLocalStorage = fn->localstorage; - *customFuncLocalStorageSize = fn->localstorage_size; - *rvMode = fn->rvMode; - *fpStackUse = fn->fpStackUsage; - if (canHaveDenormalOutput) *canHaveDenormalOutput= fn->canHaveDenormalOutput; - *endP = (char*)fn->startptr + fn->startptr_size; - if (!wantCodeGenerated && - fn->startptr_base_size <= NSEEL_MAX_FUNCTION_SIZE_FOR_INLINE && - !(ctx->optimizeDisableFlags&OPTFLAG_NO_INLINEFUNC)) - { - // report the correct maximum base length for the calculation pass - *endP = (char*)fn->startptr + fn->startptr_base_size; - } - *isRaw=1; - return fn->startptr; - } - - return 0; -} - - - -// returns true if does something (other than calculating and throwing away a value) -static char optimizeOpcodes(compileContext *ctx, opcodeRec *op, int needsResult) -{ - opcodeRec *lastJoinOp=NULL; - char retv, retv_parm[3], joined_retv=0; - while (op && op->opcodeType == OPCODETYPE_FUNC2 && op->fntype == FN_JOIN_STATEMENTS) - { - if (!optimizeOpcodes(ctx,op->parms.parms[0], 0) || OPCODE_IS_TRIVIAL(op->parms.parms[0])) - { - // direct value, can skip ourselves - memcpy(op,op->parms.parms[1],sizeof(*op)); - } - else - { - joined_retv |= 1; - lastJoinOp = op; - op = op->parms.parms[1]; - } - } -goto start_over; - -#define RESTART_DIRECTVALUE(X) { op->parms.dv.directValue = (X); goto start_over_directvalue; } -start_over_directvalue: - op->opcodeType = OPCODETYPE_DIRECTVALUE; - op->parms.dv.valuePtr=NULL; - -start_over: // when an opcode changed substantially in optimization, goto here to reprocess it - - retv = retv_parm[0]=retv_parm[1]=retv_parm[2]=0; - - if (!op || // should never really happen - OPCODE_IS_TRIVIAL(op) || // should happen often (vars) - op->opcodeType < 0 || op->opcodeType >= OPCODETYPE_INVALID // should never happen (assert would be appropriate heh) - ) return joined_retv; - - if (!needsResult) - { - if (op->fntype == FUNCTYPE_EELFUNC) - { - needsResult=1; // assume eel functions are non-const for now - } - else if (op->fntype == FUNCTYPE_FUNCTIONTYPEREC) - { - functionType *pfn = (functionType *)op->fn; - if (!pfn || !(pfn->nParams&NSEEL_NPARAMS_FLAG_CONST)) needsResult=1; - } - else if (op->fntype >= FN_NONCONST_BEGIN && op->fntype < FUNCTYPE_SIMPLEMAX) - { - needsResult=1; - } - } - - if (op->opcodeType>=OPCODETYPE_FUNC2) retv_parm[1] = optimizeOpcodes(ctx,op->parms.parms[1], needsResult); - if (op->opcodeType>=OPCODETYPE_FUNC3) retv_parm[2] = optimizeOpcodes(ctx,op->parms.parms[2], needsResult); - - retv_parm[0] = optimizeOpcodes(ctx,op->parms.parms[0], needsResult || - (FNPTR_HAS_CONDITIONAL_EXEC(op) && (retv_parm[1] || retv_parm[2] || op->opcodeType <= OPCODETYPE_FUNC1)) ); - - if (op->opcodeType != OPCODETYPE_MOREPARAMS) - { - if (op->fntype >= 0 && op->fntype < FUNCTYPE_SIMPLEMAX) - { - if (op->opcodeType == OPCODETYPE_FUNC1) // within FUNCTYPE_SIMPLE - { - if (op->parms.parms[0]->opcodeType == OPCODETYPE_DIRECTVALUE) - { - switch (op->fntype) - { - case FN_NOTNOT: RESTART_DIRECTVALUE(fabs(op->parms.parms[0]->parms.dv.directValue)>=NSEEL_CLOSEFACTOR ? 1.0 : 0.0); - case FN_NOT: RESTART_DIRECTVALUE(fabs(op->parms.parms[0]->parms.dv.directValue)>=NSEEL_CLOSEFACTOR ? 0.0 : 1.0); - case FN_UMINUS: RESTART_DIRECTVALUE(- op->parms.parms[0]->parms.dv.directValue); - } - } - else if (op->fntype == FN_NOT || op->fntype == FN_NOTNOT) - { - if (op->parms.parms[0]->opcodeType == OPCODETYPE_FUNC1) - { - switch (op->parms.parms[0]->fntype) - { - case FN_UMINUS: - case FN_NOTNOT: // ignore any NOTNOTs UMINUS or UPLUS, they would have no effect anyway - op->parms.parms[0] = op->parms.parms[0]->parms.parms[0]; - goto start_over; - - case FN_NOT: - op->fntype = op->fntype==FN_NOT ? FN_NOTNOT : FN_NOT; // switch between FN_NOT and FN_NOTNOT - op->parms.parms[0] = op->parms.parms[0]->parms.parms[0]; - goto start_over; - } - } - else if (op->parms.parms[0]->opcodeType == OPCODETYPE_FUNC2) - { - int repl_type = -1; - switch (op->parms.parms[0]->fntype) - { - case FN_EQ: repl_type = FN_NE; break; - case FN_NE: repl_type = FN_EQ; break; - case FN_EQ_EXACT: repl_type = FN_NE_EXACT; break; - case FN_NE_EXACT: repl_type = FN_EQ_EXACT; break; - case FN_LT: repl_type = FN_GTE; break; - case FN_LTE: repl_type = FN_GT; break; - case FN_GT: repl_type = FN_LTE; break; - case FN_GTE: repl_type = FN_LT; break; - } - if (repl_type != -1) - { - const int oldtype = op->fntype; - memcpy(op,op->parms.parms[0],sizeof(*op)); - if (oldtype == FN_NOT) op->fntype = repl_type; - goto start_over; - } - } - } - } - else if (op->opcodeType == OPCODETYPE_FUNC2) // within FUNCTYPE_SIMPLE - { - const int dv0 = op->parms.parms[0]->opcodeType == OPCODETYPE_DIRECTVALUE; - const int dv1 = op->parms.parms[1]->opcodeType == OPCODETYPE_DIRECTVALUE; - if (dv0 && dv1) - { - int reval = -1; - switch (op->fntype) - { - case FN_MOD: - { - EEL_F ret = 0.0; - int a = (int) fabs(op->parms.parms[1]->parms.dv.directValue); - if (a) - { -#ifdef GLUE_MOD_IS_64 - ret = ((WDL_INT64) fabs(op->parms.parms[0]->parms.dv.directValue)) % a; -#else - ret = ((int) fabs(op->parms.parms[0]->parms.dv.directValue)) % a; -#endif - if (WDL_NOT_NORMALLY(ret<0)) ret = -ret; - } - RESTART_DIRECTVALUE(ret); - } - break; - case FN_SHL: RESTART_DIRECTVALUE(((int)op->parms.parms[0]->parms.dv.directValue) << ((int)op->parms.parms[1]->parms.dv.directValue)); - case FN_SHR: RESTART_DIRECTVALUE(((int)op->parms.parms[0]->parms.dv.directValue) >> ((int)op->parms.parms[1]->parms.dv.directValue)); - case FN_POW: RESTART_DIRECTVALUE(pow(op->parms.parms[0]->parms.dv.directValue, op->parms.parms[1]->parms.dv.directValue)); - case FN_DIVIDE: RESTART_DIRECTVALUE(op->parms.parms[0]->parms.dv.directValue / op->parms.parms[1]->parms.dv.directValue); - case FN_MULTIPLY: RESTART_DIRECTVALUE(op->parms.parms[0]->parms.dv.directValue * op->parms.parms[1]->parms.dv.directValue); - - case FN_ADD: RESTART_DIRECTVALUE(op->parms.parms[0]->parms.dv.directValue + op->parms.parms[1]->parms.dv.directValue); - case FN_SUB: RESTART_DIRECTVALUE(op->parms.parms[0]->parms.dv.directValue - op->parms.parms[1]->parms.dv.directValue); - case FN_AND: RESTART_DIRECTVALUE((double) (((WDL_INT64)op->parms.parms[0]->parms.dv.directValue) & ((WDL_INT64)op->parms.parms[1]->parms.dv.directValue))); - case FN_OR: RESTART_DIRECTVALUE((double) (((WDL_INT64)op->parms.parms[0]->parms.dv.directValue) | ((WDL_INT64)op->parms.parms[1]->parms.dv.directValue))); - case FN_XOR: RESTART_DIRECTVALUE((double) (((WDL_INT64)op->parms.parms[0]->parms.dv.directValue) ^ ((WDL_INT64)op->parms.parms[1]->parms.dv.directValue))); - - case FN_EQ: reval = fabs(op->parms.parms[0]->parms.dv.directValue - op->parms.parms[1]->parms.dv.directValue) < NSEEL_CLOSEFACTOR; break; - case FN_NE: reval = fabs(op->parms.parms[0]->parms.dv.directValue - op->parms.parms[1]->parms.dv.directValue) >= NSEEL_CLOSEFACTOR; break; - case FN_EQ_EXACT: reval = op->parms.parms[0]->parms.dv.directValue == op->parms.parms[1]->parms.dv.directValue; break; - case FN_NE_EXACT: reval = op->parms.parms[0]->parms.dv.directValue != op->parms.parms[1]->parms.dv.directValue; break; - case FN_LT: reval = op->parms.parms[0]->parms.dv.directValue < op->parms.parms[1]->parms.dv.directValue; break; - case FN_LTE: reval = op->parms.parms[0]->parms.dv.directValue <= op->parms.parms[1]->parms.dv.directValue; break; - case FN_GT: reval = op->parms.parms[0]->parms.dv.directValue > op->parms.parms[1]->parms.dv.directValue; break; - case FN_GTE: reval = op->parms.parms[0]->parms.dv.directValue >= op->parms.parms[1]->parms.dv.directValue; break; - case FN_LOGICAL_AND: reval = fabs(op->parms.parms[0]->parms.dv.directValue) >= NSEEL_CLOSEFACTOR && fabs(op->parms.parms[1]->parms.dv.directValue) >= NSEEL_CLOSEFACTOR; break; - case FN_LOGICAL_OR: reval = fabs(op->parms.parms[0]->parms.dv.directValue) >= NSEEL_CLOSEFACTOR || fabs(op->parms.parms[1]->parms.dv.directValue) >= NSEEL_CLOSEFACTOR; break; - } - - if (reval >= 0) RESTART_DIRECTVALUE((EEL_F) reval); - } - else if (dv0 || dv1) - { - double dvalue = op->parms.parms[!dv0]->parms.dv.directValue; - switch (op->fntype) - { - case FN_OR: - case FN_XOR: - if (!(WDL_INT64)dvalue) - { - // replace with or0 - op->opcodeType = OPCODETYPE_FUNC1; - op->fntype = FUNCTYPE_FUNCTIONTYPEREC; - op->fn = &fn_or0; - if (dv0) op->parms.parms[0] = op->parms.parms[1]; - goto start_over; - } - break; - case FN_SUB: - if (dv0) - { - if (dvalue == 0.0) - { - op->opcodeType = OPCODETYPE_FUNC1; - op->fntype = FN_UMINUS; - op->parms.parms[0] = op->parms.parms[1]; - goto start_over; - } - break; - } - WDL_FALLTHROUGH; // fall through, if dv1 we can remove +0.0 - - case FN_ADD: - if (dvalue == 0.0) - { - memcpy(op,op->parms.parms[!!dv0],sizeof(*op)); - goto start_over; - } - break; - case FN_AND: - if ((WDL_INT64)dvalue) break; - dvalue = 0.0; // treat x&0 as x*0, which optimizes to 0 - - WDL_FALLTHROUGH; // fall through - case FN_MULTIPLY: - if (dvalue == 0.0) // remove multiply by 0.0 (using 0.0 direct value as replacement), unless the nonzero side did something - { - if (!retv_parm[!!dv0]) - { - memcpy(op,op->parms.parms[!dv0],sizeof(*op)); // set to 0 if other action wouldn't do anything - goto start_over; - } - else - { - // this is 0.0 * oldexpressionthatmustbeprocessed or oldexpressionthatmustbeprocessed*0.0 - op->fntype = FN_JOIN_STATEMENTS; - - if (dv0) // 0.0*oldexpression, reverse the order so that 0 is returned - { - // set to (oldexpression;0) - opcodeRec *tmp = op->parms.parms[1]; - op->parms.parms[1] = op->parms.parms[0]; - op->parms.parms[0] = tmp; - } - goto start_over; - } - } - else if (dvalue == 1.0) // remove multiply by 1.0 (using non-1.0 value as replacement) - { - memcpy(op,op->parms.parms[!!dv0],sizeof(*op)); - goto start_over; - } - break; - case FN_POW: - if (dv1) - { - // x^0 = 1 - if (fabs(dvalue) < 1e-30) - { - RESTART_DIRECTVALUE(1.0); - } - // x^1 = x - if (fabs(dvalue-1.0) < 1e-30) - { - memcpy(op,op->parms.parms[0],sizeof(*op)); - goto start_over; - } - } - else if (dv0) - { - // pow(constant, x) = exp((x) * ln(constant)), if constant>0 - // opcodeRec *parm0 = op->parms.parms[0]; - if (dvalue > 0.0) - { - static functionType *expcpy; - if (!expcpy) - { - expcpy = nseel_getFunctionByName(NULL,"exp",NULL); - if (WDL_NOT_NORMALLY(!expcpy)) break; - } - - // 1^x = 1 - if (fabs(dvalue-1.0) < 1e-30) - { - RESTART_DIRECTVALUE(1.0); - } - - dvalue=log(dvalue); - - if (fabs(dvalue-1.0) < 1e-9) - { - // caller wanted e^x - op->parms.parms[0]=op->parms.parms[1]; - } - else - { - // it would be nice to replace 10^x with exp(log(10)*x) or 2^x with exp(log(2),x), but - // doing so breaks rounding. we could maybe only allow 10^x, which is used for dB conversion, - // but for now we should just force the programmer do it exp(log(10)*x) themselves. - break; - - /* - parm0->opcodeType = OPCODETYPE_FUNC2; - parm0->fntype = FN_MULTIPLY; - parm0->parms.parms[0] = nseel_createCompiledValue(ctx,dvalue); - parm0->parms.parms[1] = op->parms.parms[1]; - */ - } - - op->opcodeType = OPCODETYPE_FUNC1; - op->fntype = FUNCTYPE_FUNCTIONTYPEREC; - op->fn = expcpy; - goto start_over; - } - } - break; - case FN_MOD: - if (dv1) - { - const int a = (int) dvalue; - if (!a) - { - RESTART_DIRECTVALUE(0.0); - } - } - break; - case FN_DIVIDE: - if (dv1) - { - if (dvalue == 1.0) // remove divide by 1.0 (using non-1.0 value as replacement) - { - memcpy(op,op->parms.parms[!!dv0],sizeof(*op)); - goto start_over; - } - else - { - // change to a multiply - if (dvalue == 0.0) - { - op->fntype = FN_MULTIPLY; - goto start_over; - } - else - { - double d = 1.0/dvalue; - WDL_UINT64 w; - memcpy(&w,&d,sizeof(d)); - // allow conversion to multiply if reciprocal is exact - // we could also just look to see if the last few digits of the mantissa were 0, which would probably be good - // enough, but if the user really wants it they should do * (1/x) instead to force precalculation of reciprocal. - if (!(w & WDL_UINT64_CONST(0xfffffffffffff))) - { - op->fntype = FN_MULTIPLY; - op->parms.parms[1]->parms.dv.directValue = d; - op->parms.parms[1]->parms.dv.valuePtr=NULL; - goto start_over; - } - } - } - } - else if (dvalue == 0.0) - { - if (!retv_parm[!!dv0]) - { - // if 0/x set to always 0. - // this is 0.0 / (oldexpression that can be eliminated) - memcpy(op,op->parms.parms[!dv0],sizeof(*op)); // set to 0 if other action wouldn't do anything - } - else - { - opcodeRec *tmp; - // this is 0.0 / oldexpressionthatmustbeprocessed - op->fntype = FN_JOIN_STATEMENTS; - tmp = op->parms.parms[1]; - op->parms.parms[1] = op->parms.parms[0]; - op->parms.parms[0] = tmp; - // set to (oldexpression;0) - } - goto start_over; - } - break; - case FN_EQ: - if (dvalue == 0.0) - { - // convert x == 0.0 to !x - op->opcodeType=OPCODETYPE_FUNC1; - op->fntype = FN_NOT; - if (dv0) op->parms.parms[0]=op->parms.parms[1]; - goto start_over; - } - break; - case FN_NE: - if (dvalue == 0.0) - { - // convert x != 0.0 to !! - op->opcodeType=OPCODETYPE_FUNC1; - op->fntype = FN_NOTNOT; - if (dv0) op->parms.parms[0]=op->parms.parms[1]; - goto start_over; - } - break; - case FN_LOGICAL_AND: - if (dv0) - { - // dvalue && expr - if (fabs(dvalue) < NSEEL_CLOSEFACTOR) - { - // 0 && expr, replace with 0 - RESTART_DIRECTVALUE(0.0); - } - else - { - // 1 && expr, replace with 0 != expr - op->fntype = FN_NE; - op->parms.parms[0]->parms.dv.valuePtr=NULL; - op->parms.parms[0]->parms.dv.directValue = 0.0; - } - } - else - { - // expr && dvalue - if (fabs(dvalue) < NSEEL_CLOSEFACTOR) - { - // expr && 0 - if (!retv_parm[0]) - { - // expr has no consequence, drop it - RESTART_DIRECTVALUE(0.0); - } - else - { - // replace with (expr; 0) - op->fntype = FN_JOIN_STATEMENTS; - op->parms.parms[1]->parms.dv.valuePtr=NULL; - op->parms.parms[1]->parms.dv.directValue = 0.0; - } - } - else - { - // expr && 1, replace with expr != 0 - op->fntype = FN_NE; - op->parms.parms[1]->parms.dv.valuePtr=NULL; - op->parms.parms[1]->parms.dv.directValue = 0.0; - } - } - goto start_over; - case FN_LOGICAL_OR: - if (dv0) - { - // dvalue || expr - if (fabs(dvalue) >= NSEEL_CLOSEFACTOR) - { - // 1 || expr, replace with 1 - RESTART_DIRECTVALUE(1.0); - } - else - { - // 0 || expr, replace with 0 != expr - op->fntype = FN_NE; - op->parms.parms[0]->parms.dv.valuePtr=NULL; - op->parms.parms[0]->parms.dv.directValue = 0.0; - } - } - else - { - // expr || dvalue - if (fabs(dvalue) >= NSEEL_CLOSEFACTOR) - { - // expr || 1 - if (!retv_parm[0]) - { - // expr has no consequence, drop it and return 1 - RESTART_DIRECTVALUE(1.0); - } - else - { - // replace with (expr; 1) - op->fntype = FN_JOIN_STATEMENTS; - op->parms.parms[1]->parms.dv.valuePtr=NULL; - op->parms.parms[1]->parms.dv.directValue = 1.0; - } - } - else - { - // expr || 0, replace with expr != 0 - op->fntype = FN_NE; - op->parms.parms[1]->parms.dv.valuePtr=NULL; - op->parms.parms[1]->parms.dv.directValue = 0.0; - } - } - goto start_over; - } - } // dv0 || dv1 - - // general optimization of two parameters - switch (op->fntype) - { - case FN_MULTIPLY: - { - opcodeRec *first_parm = op->parms.parms[0],*second_parm = op->parms.parms[1]; - - if (second_parm->opcodeType == first_parm->opcodeType) - { - switch(first_parm->opcodeType) - { - case OPCODETYPE_VALUE_FROM_NAMESPACENAME: - if (first_parm->namespaceidx != second_parm->namespaceidx) break; - WDL_FALLTHROUGH; // fall through - case OPCODETYPE_VARPTR: - if (first_parm->relname && second_parm->relname && !stricmp(second_parm->relname,first_parm->relname)) second_parm=NULL; - break; - case OPCODETYPE_VARPTRPTR: - if (first_parm->parms.dv.valuePtr && first_parm->parms.dv.valuePtr==second_parm->parms.dv.valuePtr) second_parm=NULL; - break; - - } - if (!second_parm) // switch from x*x to sqr(x) - { - static functionType *sqrcpy; - if (!sqrcpy) sqrcpy = nseel_getFunctionByName(NULL,"sqr",NULL); - if (WDL_NORMALLY(sqrcpy)) - { - op->opcodeType = OPCODETYPE_FUNC1; - op->fntype = FUNCTYPE_FUNCTIONTYPEREC; - op->fn = sqrcpy; - goto start_over; - } - } - } - } - break; - case FN_POW: - { - opcodeRec *first_parm = op->parms.parms[0]; - if (first_parm->opcodeType == op->opcodeType && first_parm->fntype == FN_POW) - { - // since first_parm is a pow too, we can multiply the exponents. - - // set our base to be the base of the inner pow - op->parms.parms[0] = first_parm->parms.parms[0]; - - // make the old extra pow be a multiply of the exponents - first_parm->fntype = FN_MULTIPLY; - first_parm->parms.parms[0] = op->parms.parms[1]; - - // put that as the exponent - op->parms.parms[1] = first_parm; - - goto start_over; - } - } - break; - case FN_LOGICAL_AND: - case FN_LOGICAL_OR: - if (op->parms.parms[0]->fntype == FN_NOTNOT) - { - // remove notnot, unnecessary for input to &&/|| operators - op->parms.parms[0] = op->parms.parms[0]->parms.parms[0]; - goto start_over; - } - if (op->parms.parms[1]->fntype == FN_NOTNOT) - { - // remove notnot, unnecessary for input to &&/|| operators - op->parms.parms[1] = op->parms.parms[1]->parms.parms[0]; - goto start_over; - } - break; - } - } - else if (op->opcodeType==OPCODETYPE_FUNC3) // within FUNCTYPE_SIMPLE - { - if (op->fntype == FN_IF_ELSE) - { - if (op->parms.parms[0]->opcodeType == OPCODETYPE_DIRECTVALUE) - { - int s = fabs(op->parms.parms[0]->parms.dv.directValue) >= NSEEL_CLOSEFACTOR; - memcpy(op,op->parms.parms[s ? 1 : 2],sizeof(opcodeRec)); - goto start_over; - } - if (op->parms.parms[0]->opcodeType == OPCODETYPE_FUNC1) - { - if (op->parms.parms[0]->fntype == FN_NOTNOT) - { - // remove notnot, unnecessary for input to ? operator - op->parms.parms[0] = op->parms.parms[0]->parms.parms[0]; - goto start_over; - } - } - } - } - if (op->fntype >= FN_NONCONST_BEGIN && op->fntype < FUNCTYPE_SIMPLEMAX) retv|=1; - - // FUNCTYPE_SIMPLE - } - else if (op->fntype == FUNCTYPE_FUNCTIONTYPEREC && op->fn) - { - - /* - probably worth doing reduction on: - _divop (constant change to multiply) - _and - _or - abs - - maybe: - min - max - - - also, optimize should (recursively or maybe iteratively?) search transitive functions (mul/div) for more constant reduction possibilities - - - */ - - - functionType *pfn = (functionType *)op->fn; - - if (!(pfn->nParams&NSEEL_NPARAMS_FLAG_CONST)) retv|=1; - - if (op->opcodeType==OPCODETYPE_FUNC1) // within FUNCTYPE_FUNCTIONTYPEREC - { - if (op->parms.parms[0]->opcodeType == OPCODETYPE_DIRECTVALUE) - { - int suc=1; - EEL_F v = op->parms.parms[0]->parms.dv.directValue; - #define DOF(x) if (!strcmp(pfn->name,#x)) v = x(v); else - #define DOF2(x,y) if (!strcmp(pfn->name,#x)) v = x(y); else - DOF(sin) - DOF(cos) - DOF(tan) - DOF(asin) - DOF(acos) - DOF(atan) - DOF2(sqrt, fabs(v)) - DOF(exp) - DOF(log) - DOF(log10) - /* else */ suc=0; - #undef DOF - #undef DOF2 - if (suc) - { - RESTART_DIRECTVALUE(v); - } - - - } - } - else if (op->opcodeType==OPCODETYPE_FUNC2) // within FUNCTYPE_FUNCTIONTYPEREC - { - const int dv0=op->parms.parms[0]->opcodeType == OPCODETYPE_DIRECTVALUE; - const int dv1=op->parms.parms[1]->opcodeType == OPCODETYPE_DIRECTVALUE; - if (dv0 && dv1) - { - if (!strcmp(pfn->name,"atan2")) - { - RESTART_DIRECTVALUE(atan2(op->parms.parms[0]->parms.dv.directValue, op->parms.parms[1]->parms.dv.directValue)); - } - } - } - // FUNCTYPE_FUNCTIONTYPEREC - } - else - { - // unknown or eel func, assume non-const - retv |= 1; - } - } - - // if we need results, or our function has effects itself, then finish - if (retv || needsResult) - { - return retv || joined_retv || retv_parm[0] || retv_parm[1] || retv_parm[2]; - } - - // we don't need results here, and our function is const, which means we can remove it - { - int cnt=0, idx1=0, idx2=0, x; - for (x=0;x<3;x++) if (retv_parm[x]) { if (!cnt++) idx1=x; else idx2=x; } - - if (!cnt) // none of the parameters do anything, remove this opcode - { - if (lastJoinOp) - { - // replace previous join with its first linked opcode, removing this opcode completely - memcpy(lastJoinOp,lastJoinOp->parms.parms[0],sizeof(*lastJoinOp)); - } - else if (op->opcodeType != OPCODETYPE_DIRECTVALUE) - { - // allow caller to easily detect this as trivial and remove it - op->opcodeType = OPCODETYPE_DIRECTVALUE; - op->parms.dv.valuePtr=NULL; - op->parms.dv.directValue=0.0; - } - // return joined_retv below - } - else - { - // if parameters are non-const, and we're a conditional, preserve our function - if (FNPTR_HAS_CONDITIONAL_EXEC(op)) return 1; - - // otherwise, condense into either the non-const statement, or a join - if (cnt==1) - { - memcpy(op,op->parms.parms[idx1],sizeof(*op)); - } - else if (cnt == 2) - { - op->opcodeType = OPCODETYPE_FUNC2; - op->fntype = FN_JOIN_STATEMENTS; - op->fn = op; - op->parms.parms[0] = op->parms.parms[idx1]; - op->parms.parms[1] = op->parms.parms[idx2]; - op->parms.parms[2] = NULL; - } - else - { - // todo need to create a new opcodeRec here, for now just leave as is - // (non-conditional const 3 parameter functions are rare anyway) - } - return 1; - } - } - return joined_retv; -} - - -static int generateValueToReg(compileContext *ctx, opcodeRec *op, unsigned char *bufOut, int whichReg, const namespaceInformation *functionPrefix, int allowCache) -{ - EEL_F *b=NULL; - if (op->opcodeType==OPCODETYPE_VALUE_FROM_NAMESPACENAME) - { - char nm[NSEEL_MAX_VARIABLE_NAMELEN+1]; - const char *p = op->relname; - combineNamespaceFields(nm,functionPrefix,p+(*p == '#'),op->namespaceidx); - if (!nm[0]) return -1; - if (*p == '#') - { - if (ctx->isGeneratingCommonFunction) - b = newCtxDataBlock(sizeof(EEL_F),sizeof(EEL_F)); - else - b = newDataBlock(sizeof(EEL_F),sizeof(EEL_F)); - - if (!b) RET_MINUS1_FAIL("error creating storage for str") - - if (!ctx->onNamedString) return -1; // should never happen, will not generate OPCODETYPE_VALUE_FROM_NAMESPACENAME with # prefix if !onNamedString - - *b = ctx->onNamedString(ctx->caller_this,nm); - } - else - { - b = nseel_int_register_var(ctx,nm,0,NULL); - if (!b) RET_MINUS1_FAIL("error registering var") - } - } - else - { - if (op->opcodeType != OPCODETYPE_DIRECTVALUE) allowCache=0; - - if (op->opcodeType==OPCODETYPE_DIRECTVALUE_TEMPSTRING && ctx->onNamedString) - { - op->parms.dv.directValue = ctx->onNamedString(ctx->caller_this,""); - op->parms.dv.valuePtr = NULL; - } - - b=op->parms.dv.valuePtr; - if (!b && op->opcodeType == OPCODETYPE_VARPTR && op->relname && op->relname[0]) - { - op->parms.dv.valuePtr = b = nseel_int_register_var(ctx,op->relname,0,NULL); - } - - if (b && op->opcodeType == OPCODETYPE_VARPTRPTR) b = *(EEL_F **)b; - if (!b && allowCache) - { - int n=50; // only scan last X items - opcodeRec *r = ctx->directValueCache; - while (r && n--) - { - if (r->parms.dv.directValue == op->parms.dv.directValue && (b=r->parms.dv.valuePtr)) break; - r=(opcodeRec*)r->fn; - } - } - if (!b) - { - ctx->l_stats[3]++; - if (ctx->isGeneratingCommonFunction) - b = newCtxDataBlock(sizeof(EEL_F),sizeof(EEL_F)); - else - b = newDataBlock(sizeof(EEL_F),sizeof(EEL_F)); - - if (!b) RET_MINUS1_FAIL("error allocating data block") - - if (op->opcodeType != OPCODETYPE_VARPTRPTR) op->parms.dv.valuePtr = b; - *b = denormal_filter_double2(op->parms.dv.directValue); - - if (allowCache) - { - op->fn = ctx->directValueCache; - ctx->directValueCache = op; - } - } - } - - GLUE_MOV_PX_DIRECTVALUE_GEN(bufOut,(INT_PTR)b,whichReg); - return GLUE_MOV_PX_DIRECTVALUE_SIZE; -} - - -unsigned char *compileCodeBlockWithRet(compileContext *ctx, opcodeRec *rec, int *computTableSize, const namespaceInformation *namespacePathToThis, - int supportedReturnValues, int *rvType, int *fpStackUsage, int *canHaveDenormalOutput) -{ - unsigned char *p, *newblock2; - // generate code call - int funcsz=compileOpcodes(ctx,rec,NULL,1024*1024*128,NULL,namespacePathToThis,supportedReturnValues, rvType,fpStackUsage, NULL); - if (funcsz<0) return NULL; - - p = newblock2 = newCodeBlock(funcsz+ sizeof(GLUE_RET)+GLUE_FUNC_ENTER_SIZE+GLUE_FUNC_LEAVE_SIZE,32); - if (!newblock2) return NULL; - #if GLUE_FUNC_ENTER_SIZE > 0 - memcpy(p,&GLUE_FUNC_ENTER,GLUE_FUNC_ENTER_SIZE); - p += GLUE_FUNC_ENTER_SIZE; - #endif - *fpStackUsage=0; - funcsz=compileOpcodes(ctx,rec,p, funcsz, computTableSize,namespacePathToThis,supportedReturnValues, rvType,fpStackUsage, canHaveDenormalOutput); - if (funcsz<0) return NULL; - p+=funcsz; - - #if GLUE_FUNC_LEAVE_SIZE > 0 - memcpy(p,&GLUE_FUNC_LEAVE,GLUE_FUNC_LEAVE_SIZE); - p+=GLUE_FUNC_LEAVE_SIZE; - #endif - memcpy(p,&GLUE_RET,sizeof(GLUE_RET)); p+=sizeof(GLUE_RET); -#if defined(__arm__) || defined(__aarch64__) - __clear_cache(newblock2,p); -#endif - - ctx->l_stats[2]+=funcsz+2; - return newblock2; -} - -static int compileNativeFunctionCall(compileContext *ctx, opcodeRec *op, unsigned char *bufOut, int bufOut_len, int *computTableSize, const namespaceInformation *namespacePathToThis, - int *rvMode, int *fpStackUsage, int preferredReturnValues, int *canHaveDenormalOutput) -{ - // builtin function generation - int func_size=0; - int cfunc_abiinfo=0; - int local_fpstack_use=0; // how many items we have pushed onto the fp stack - int parm_size=0; - int restore_stack_amt=0; -#ifdef GLUE_HAS_FUSE - int fuse_flags = 0; // 1 = last parm was trivial (likely mov rax, movsd xmm0 ,[rax]) -#endif -#if GLUE_MAX_SPILL_REGS > 0 - int spill_reg = -1; -#endif - - NSEEL_PPPROC preProc=0; - void **repl=NULL; - - int n_params= 1 + op->opcodeType - OPCODETYPE_FUNC1; - - const int parm0_dv = op->parms.parms[0]->opcodeType == OPCODETYPE_DIRECTVALUE; - const int parm1_dv = n_params > 1 && op->parms.parms[1]->opcodeType == OPCODETYPE_DIRECTVALUE; - - void *func = nseel_getBuiltinFunctionAddress(ctx, op->fntype, op->fn, &preProc,&repl, - &cfunc_abiinfo,preferredReturnValues, - parm0_dv ? &op->parms.parms[0]->parms.dv.directValue : NULL, - parm1_dv ? &op->parms.parms[1]->parms.dv.directValue : NULL - ); - - *fpStackUsage=BIF_GETFPSTACKUSE(cfunc_abiinfo); - *rvMode = RETURNVALUE_NORMAL; - - if (cfunc_abiinfo & BIF_TAKES_VARPARM) - { -#if defined(__arm__) || (defined (_M_ARM) && _M_ARM == 7) - const int max_params=16384; // arm uses up to two instructions, should be good for at leaast 64k (16384*4) -#elif defined(__ppc__) - const int max_params=4096; // 32kb max offset addressing for stack, so 4096*4 = 16384, should be safe -#elif defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC) - const int max_params=32768; -#else - const int max_params=32768; // sanity check, the stack is free to grow on x86/x86-64 -#endif - int x; - // this mode is less efficient in that it creates a list of pointers on the stack to pass to the function - // but it is more flexible and works for >3 parameters. - if (op->opcodeType == OPCODETYPE_FUNCX) - { - n_params=0; - for (x=0;x<3;x++) - { - opcodeRec *prni=op->parms.parms[x]; - while (prni) - { - const int isMP = prni->opcodeType == OPCODETYPE_MOREPARAMS; - n_params++; - if (!isMP||n_params>=max_params) break; - prni = prni->parms.parms[1]; - } - } - } - - restore_stack_amt = (sizeof(void *) * n_params + 15)&~15; - - if (restore_stack_amt) - { - int offs = restore_stack_amt; - while (offs > 0) - { - int amt = offs; - if (amt > 4096) amt=4096; - - if (bufOut_len < parm_size+GLUE_MOVE_STACK_SIZE) RET_MINUS1_FAIL("insufficient size for varparm") - if (bufOut) GLUE_MOVE_STACK(bufOut+parm_size, - amt); - parm_size += GLUE_MOVE_STACK_SIZE; - offs -= amt; - - if (offs>0) // make sure this page is in memory - { - if (bufOut_len < parm_size+GLUE_STORE_P1_TO_STACK_AT_OFFS_SIZE(0)) - RET_MINUS1_FAIL("insufficient size for varparm stackchk") - if (bufOut) GLUE_STORE_P1_TO_STACK_AT_OFFS(bufOut+parm_size,0); - parm_size += GLUE_STORE_P1_TO_STACK_AT_OFFS_SIZE(0); - } - } - } - - if (op->opcodeType == OPCODETYPE_FUNCX) - { - n_params=0; - for (x=0;x<3;x++) - { - opcodeRec *prni=op->parms.parms[x]; - while (prni) - { - const int isMP = prni->opcodeType == OPCODETYPE_MOREPARAMS; - opcodeRec *r = isMP ? prni->parms.parms[0] : prni; - if (r) - { - int canHaveDenorm=0; - int rvt=RETURNVALUE_NORMAL; - int subfpstackuse=0, use_offs; - - int lsz = compileOpcodes(ctx,r,bufOut ? bufOut + parm_size : NULL,bufOut_len - parm_size, computTableSize, namespacePathToThis, rvt,&rvt, &subfpstackuse, &canHaveDenorm); - if (canHaveDenorm && canHaveDenormalOutput) *canHaveDenormalOutput = 1; - - if (lsz<0) RET_MINUS1_FAIL("call coc for varparmX failed") - if (rvt != RETURNVALUE_NORMAL) RET_MINUS1_FAIL("call coc for varparmX gave bad type back"); - - parm_size += lsz; - use_offs = n_params*(int) sizeof(void *); - - if (bufOut_len < parm_size+GLUE_STORE_P1_TO_STACK_AT_OFFS_SIZE(use_offs)) - RET_MINUS1_FAIL("call coc for varparmX size"); - if (bufOut) GLUE_STORE_P1_TO_STACK_AT_OFFS(bufOut + parm_size, use_offs); - parm_size+=GLUE_STORE_P1_TO_STACK_AT_OFFS_SIZE(use_offs); - - if (subfpstackuse+local_fpstack_use > *fpStackUsage) *fpStackUsage = subfpstackuse+local_fpstack_use; - } - else RET_MINUS1_FAIL("zero parameter varparmX") - - n_params++; - - if (!isMP||n_params>=max_params) break; - prni = prni->parms.parms[1]; - } - } - } - else for (x=0;xparms.parms[x]; - if (r) - { - int canHaveDenorm=0; - int subfpstackuse=0; - int rvt=RETURNVALUE_NORMAL; - int use_offs; - - int lsz = compileOpcodes(ctx,r,bufOut ? bufOut + parm_size : NULL,bufOut_len - parm_size, computTableSize, namespacePathToThis, rvt,&rvt, &subfpstackuse, &canHaveDenorm); - if (canHaveDenorm && canHaveDenormalOutput) *canHaveDenormalOutput = 1; - - if (lsz<0) RET_MINUS1_FAIL("call coc for varparm123 failed") - if (rvt != RETURNVALUE_NORMAL) RET_MINUS1_FAIL("call coc for varparm123 gave bad type back"); - - parm_size += lsz; - - use_offs = x*(int)sizeof(void *); - if (bufOut_len < parm_size+GLUE_STORE_P1_TO_STACK_AT_OFFS_SIZE(use_offs)) - RET_MINUS1_FAIL("call coc for varparm123 size"); - if (bufOut) GLUE_STORE_P1_TO_STACK_AT_OFFS(bufOut + parm_size, use_offs); - parm_size+=GLUE_STORE_P1_TO_STACK_AT_OFFS_SIZE(use_offs); - - if (subfpstackuse+local_fpstack_use > *fpStackUsage) *fpStackUsage = subfpstackuse+local_fpstack_use; - } - else RET_MINUS1_FAIL("zero parameter for varparm123"); - } - - if (bufOut_len < parm_size+GLUE_MOV_PX_DIRECTVALUE_SIZE+GLUE_MOVE_PX_STACKPTR_SIZE) RET_MINUS1_FAIL("insufficient size for varparm p1") - if (bufOut) GLUE_MOV_PX_DIRECTVALUE_GEN(bufOut+parm_size, (INT_PTR)n_params,1); - parm_size+=GLUE_MOV_PX_DIRECTVALUE_SIZE; - if (bufOut) GLUE_MOVE_PX_STACKPTR_GEN(bufOut+parm_size, 0); - parm_size+=GLUE_MOVE_PX_STACKPTR_SIZE; - - } - else // not varparm - { - int pn; - #if GLUE_MAX_FPSTACK_SIZE > 0 - int need_fxch=0; - #endif - int last_nt_parm=-1, last_nt_parm_type=-1; - - if (op->opcodeType == OPCODETYPE_FUNCX) - { - // this is not yet supported (calling conventions will need to be sorted, among other things) - RET_MINUS1_FAIL("funcx for native functions requires BIF_TAKES_VARPARM or BIF_TAKES_VARPARM_EX") - } - - if (parm0_dv) - { - if (func == nseel_asm_stack_pop) - { - func = GLUE_realAddress(nseel_asm_stack_pop_fast,&func_size); - if (!func || bufOut_len < func_size) RET_MINUS1_FAIL(func?"failed on popfast size":"failed on popfast addr") - - if (bufOut) - { - memcpy(bufOut,func,func_size); - NSEEL_PProc_Stack(bufOut,func_size,ctx); - } - return func_size; - } - else if (func == nseel_asm_stack_peek) - { - int f = (int) op->parms.parms[0]->parms.dv.directValue; - if (!f) - { - func = GLUE_realAddress(nseel_asm_stack_peek_top,&func_size); - if (!func || bufOut_len < func_size) RET_MINUS1_FAIL(func?"failed on peek size":"failed on peek addr") - - if (bufOut) - { - memcpy(bufOut,func,func_size); - NSEEL_PProc_Stack_PeekTop(bufOut,func_size,ctx); - } - return func_size; - } - else - { - func = GLUE_realAddress(nseel_asm_stack_peek_int,&func_size); - if (!func || bufOut_len < func_size) RET_MINUS1_FAIL(func?"failed on peekint size":"failed on peekint addr") - - if (bufOut) - { - memcpy(bufOut,func,func_size); - NSEEL_PProc_Stack_PeekInt(bufOut,func_size,ctx,f*sizeof(EEL_F)); - } - return func_size; - } - } - } - // end of built-in function specific special casing - - - // first pass, calculate any non-trivial parameters - for (pn=0; pn < n_params; pn++) - { - if (!OPCODE_IS_TRIVIAL(op->parms.parms[pn])) - { - int canHaveDenorm=0; - int subfpstackuse=0; - int lsz=0; - int rvt=RETURNVALUE_NORMAL; - int may_need_fppush=-1; - if (last_nt_parm>=0) - { - if (last_nt_parm_type==RETURNVALUE_FPSTACK) - { - may_need_fppush= parm_size; - } - else - { - // push last result - if (bufOut_len < parm_size + (int)sizeof(GLUE_PUSH_P1)) RET_MINUS1_FAIL("failed on size, pushp1") - if (bufOut) memcpy(bufOut + parm_size, &GLUE_PUSH_P1, sizeof(GLUE_PUSH_P1)); - parm_size += sizeof(GLUE_PUSH_P1); - } - } - - if (func == nseel_asm_bnot) rvt=RETURNVALUE_BOOL_REVERSED|RETURNVALUE_BOOL; - else if (pn == n_params - 1) - { - if (cfunc_abiinfo&BIF_LASTPARMONSTACK) rvt=RETURNVALUE_FPSTACK; - else if (cfunc_abiinfo&BIF_LASTPARM_ASBOOL) rvt=RETURNVALUE_BOOL; - else if (func == nseel_asm_assign) rvt=RETURNVALUE_FPSTACK|RETURNVALUE_NORMAL; - } - else if (pn == n_params -2 && (cfunc_abiinfo&BIF_SECONDLASTPARMST)) - { - rvt=RETURNVALUE_FPSTACK; - } - - lsz = compileOpcodes(ctx,op->parms.parms[pn],bufOut ? bufOut + parm_size : NULL,bufOut_len - parm_size, computTableSize, namespacePathToThis, rvt,&rvt, &subfpstackuse, &canHaveDenorm); - - if (lsz<0) RET_MINUS1_FAIL("call coc failed") - - if (func == nseel_asm_bnot && rvt==RETURNVALUE_BOOL_REVERSED) - { - // remove bnot, compileOpcodes() used fptobool_rev - func = NULL; - rvt = RETURNVALUE_BOOL; - } - - if (canHaveDenorm && canHaveDenormalOutput) *canHaveDenormalOutput = 1; - - parm_size += lsz; - - if (may_need_fppush>=0) - { -#if GLUE_MAX_SPILL_REGS > 0 - if (local_fpstack_use+subfpstackuse < GLUE_MAX_SPILL_REGS && pn == n_params - 1 && !(ctx->optimizeDisableFlags&OPTFLAG_NO_FPSTACK)) - { - int spill_sz; - spill_reg = local_fpstack_use+subfpstackuse; - spill_sz = GLUE_SAVE_TO_SPILL_SIZE(spill_reg); - if (bufOut_len < parm_size + spill_sz) RET_MINUS1_FAIL("failed on size, savetospilll") - - if (bufOut) - { - memmove(bufOut + may_need_fppush + spill_sz, bufOut + may_need_fppush, parm_size - may_need_fppush); - GLUE_SAVE_TO_SPILL(bufOut + may_need_fppush, spill_reg); - } - parm_size += spill_sz; - local_fpstack_use++; - } - else -#endif - if (local_fpstack_use+subfpstackuse >= (GLUE_MAX_FPSTACK_SIZE-1) || (ctx->optimizeDisableFlags&OPTFLAG_NO_FPSTACK)) - { - if (bufOut_len < parm_size + (int)sizeof(GLUE_POP_FPSTACK_TOSTACK)) - RET_MINUS1_FAIL("failed on size, popfpstacktostack") - - if (bufOut) - { - memmove(bufOut + may_need_fppush + sizeof(GLUE_POP_FPSTACK_TOSTACK), bufOut + may_need_fppush, parm_size - may_need_fppush); - memcpy(bufOut + may_need_fppush, &GLUE_POP_FPSTACK_TOSTACK, sizeof(GLUE_POP_FPSTACK_TOSTACK)); - - } - parm_size += sizeof(GLUE_POP_FPSTACK_TOSTACK); - } - else - { - local_fpstack_use++; - } - } - - if (subfpstackuse+local_fpstack_use > *fpStackUsage) *fpStackUsage = subfpstackuse+local_fpstack_use; - - last_nt_parm = pn; - last_nt_parm_type = rvt; - - if (pn == n_params - 1 && func == nseel_asm_assign) - { - if (!(ctx->optimizeDisableFlags & OPTFLAG_FULL_DENORMAL_CHECKS) && - (!canHaveDenorm || (ctx->optimizeDisableFlags & OPTFLAG_NO_DENORMAL_CHECKS))) - { - if (rvt == RETURNVALUE_FPSTACK) - { - cfunc_abiinfo |= BIF_LASTPARMONSTACK; - func = nseel_asm_assign_fast_fromfp; - } - else - { - func = nseel_asm_assign_fast; - } - } - else - { - if (rvt == RETURNVALUE_FPSTACK) - { - cfunc_abiinfo |= BIF_LASTPARMONSTACK; - func = nseel_asm_assign_fromfp; - } - } - - } - } - } - - pn = last_nt_parm; - - if (pn >= 0) // if the last thing executed doesn't go to the last parameter, move it there - { - if ((cfunc_abiinfo&BIF_SECONDLASTPARMST) && pn == n_params-2) - { - // do nothing, things are in the right place - } - else if (pn != n_params-1) - { - // generate mov p1->pX - if (bufOut_len < parm_size + GLUE_SET_PX_FROM_P1_SIZE) RET_MINUS1_FAIL("size, pxfromp1") - if (bufOut) GLUE_SET_PX_FROM_P1(bufOut + parm_size,n_params - 1 - pn); - parm_size += GLUE_SET_PX_FROM_P1_SIZE; - } - } - - // pop any pushed parameters - while (--pn >= 0) - { - if (!OPCODE_IS_TRIVIAL(op->parms.parms[pn])) - { - if ((cfunc_abiinfo&BIF_SECONDLASTPARMST) && pn == n_params-2) - { - if (!local_fpstack_use) - { - #if GLUE_HAS_FPREG2 > 0 - if (bufOut_len < parm_size + (int)sizeof(GLUE_POP_STACK_TO_FPREG2)) RET_MINUS1_FAIL("size, popstacktofpstack2 2") - if (bufOut) memcpy(bufOut+parm_size,GLUE_POP_STACK_TO_FPREG2,sizeof(GLUE_POP_STACK_TO_FPREG2)); - parm_size += sizeof(GLUE_POP_STACK_TO_FPREG2); - #else - if (bufOut_len < parm_size + (int)sizeof(GLUE_POP_STACK_TO_FPSTACK)) RET_MINUS1_FAIL("size, popstacktofpstack 2") - if (bufOut) memcpy(bufOut+parm_size,GLUE_POP_STACK_TO_FPSTACK,sizeof(GLUE_POP_STACK_TO_FPSTACK)); - parm_size += sizeof(GLUE_POP_STACK_TO_FPSTACK); - #endif - #if GLUE_MAX_FPSTACK_SIZE > 0 - need_fxch = 1; - #endif - } - else - { -#if GLUE_MAX_SPILL_REGS > 0 - if (spill_reg<0) RET_MINUS1_FAIL("spill reg not allocated"); - - if (bufOut_len < parm_size + GLUE_RESTORE_SPILL_TO_FPREG2_SIZE(spill_reg)) RET_MINUS1_FAIL("size, copy fps to fpreg2") - if (bufOut) GLUE_RESTORE_SPILL_TO_FPREG2(bufOut+parm_size,spill_reg); - parm_size += GLUE_RESTORE_SPILL_TO_FPREG2_SIZE(spill_reg); -#endif - local_fpstack_use--; - } - } - else - { - if (bufOut_len < parm_size + GLUE_POP_PX_SIZE) RET_MINUS1_FAIL("size, poppx") - if (bufOut) GLUE_POP_PX(bufOut + parm_size,n_params - 1 - pn); - parm_size += GLUE_POP_PX_SIZE; - } - } - } - - // finally, set trivial pointers - for (pn=0; pn < n_params; pn++) - { - if (OPCODE_IS_TRIVIAL(op->parms.parms[pn])) - { - if (pn == n_params-2 && (cfunc_abiinfo&(BIF_SECONDLASTPARMST))) // second to last parameter - { - #if GLUE_HAS_FPREG2 > 0 - const int req = RETURNVALUE_FPREG2; - #else - const int req = RETURNVALUE_FPSTACK; - #endif - int a = compileOpcodes(ctx,op->parms.parms[pn],bufOut ? bufOut+parm_size : NULL,bufOut_len - parm_size,computTableSize,namespacePathToThis, - req,NULL,NULL,canHaveDenormalOutput); - if (a<0) RET_MINUS1_FAIL("coc call here 2") - parm_size+=a; - - #if GLUE_MAX_FPSTACK_SIZE > 0 - need_fxch = 1; - #endif - } - else if (pn == n_params-1) // last parameter, but we should call compileOpcodes to get it in the right format (compileOpcodes can optimize that process if it needs to) - { - int rvt=0, a; - int wantFpStack = func == nseel_asm_assign; - #ifdef GLUE_PREFER_NONFP_DV_ASSIGNS // x86-64, and maybe others, prefer to avoid the fp stack for a simple copy - if (wantFpStack && - (op->parms.parms[pn]->opcodeType != OPCODETYPE_DIRECTVALUE || - op->parms.parms[pn]->parms.dv.directValue != 0.0)) - { - wantFpStack=-1; // cacheable but non-FP stack - } - #endif - #if GLUE_HAS_FPREG2 > 0 - if (pn > 0 && (cfunc_abiinfo&(BIF_SECONDLASTPARMST) && !OPCODE_IS_TRIVIAL(op->parms.parms[pn-1]))) - { - if (bufOut_len < parm_size+(int)sizeof(GLUE_COPY_FPSTACK_TO_FPREG2)) RET_MINUS1_FAIL("fptofpstack2tfp"); - if (bufOut) memcpy(bufOut+parm_size,GLUE_COPY_FPSTACK_TO_FPREG2,sizeof(GLUE_COPY_FPSTACK_TO_FPREG2)); - parm_size += sizeof(GLUE_COPY_FPSTACK_TO_FPREG2); - } - #endif - - a = compileOpcodes(ctx,op->parms.parms[pn],bufOut ? bufOut+parm_size : NULL,bufOut_len - parm_size,computTableSize,namespacePathToThis, - func == nseel_asm_bnot ? (RETURNVALUE_BOOL_REVERSED|RETURNVALUE_BOOL) : - (cfunc_abiinfo & BIF_LASTPARMONSTACK) ? RETURNVALUE_FPSTACK : - (cfunc_abiinfo & BIF_LASTPARM_ASBOOL) ? RETURNVALUE_BOOL : - wantFpStack < 0 ? (RETURNVALUE_CACHEABLE|RETURNVALUE_NORMAL) : - wantFpStack ? (RETURNVALUE_FPSTACK|RETURNVALUE_NORMAL) : - RETURNVALUE_NORMAL, - &rvt, NULL,canHaveDenormalOutput); - - if (a<0) RET_MINUS1_FAIL("coc call here 3") -#ifdef GLUE_HAS_FUSE - if (rvt == RETURNVALUE_FPSTACK) fuse_flags |= 1; -#endif - - if (func == nseel_asm_bnot && rvt == RETURNVALUE_BOOL_REVERSED) - { - // remove bnot, compileOpcodes() used fptobool_rev - // case: !b ? 2 : 3, for example - func = NULL; - rvt = RETURNVALUE_BOOL; - } - - parm_size+=a; - #if GLUE_MAX_FPSTACK_SIZE > 0 - need_fxch = 0; - #endif - - if (func == nseel_asm_assign) - { - if (rvt == RETURNVALUE_FPSTACK) - { - if (!(ctx->optimizeDisableFlags & OPTFLAG_FULL_DENORMAL_CHECKS)) - { - func = nseel_asm_assign_fast_fromfp; - } - else - { - func = nseel_asm_assign_fromfp; - } - } - else if (!(ctx->optimizeDisableFlags & OPTFLAG_FULL_DENORMAL_CHECKS)) - { - // assigning a value (from a variable or other non-computer), can use a fast assign (no denormal/result checking) - func = nseel_asm_assign_fast; - } - } - } - else - { - if (bufOut_len < parm_size + GLUE_MOV_PX_DIRECTVALUE_SIZE) RET_MINUS1_FAIL("size, pxdvsz") - if (bufOut) - { - if (generateValueToReg(ctx,op->parms.parms[pn],bufOut + parm_size,n_params - 1 - pn,namespacePathToThis, 0/*nocaching, function gets pointer*/)<0) RET_MINUS1_FAIL("gvtr") - } - parm_size += GLUE_MOV_PX_DIRECTVALUE_SIZE; - } - } - } - - #if GLUE_MAX_FPSTACK_SIZE > 0 - if ((cfunc_abiinfo&(BIF_SECONDLASTPARMST)) && !(cfunc_abiinfo&(BIF_LAZYPARMORDERING))&& - ((!!need_fxch)^!!(cfunc_abiinfo&BIF_REVERSEFPORDER)) - ) - { - // emit fxch - if (bufOut_len < sizeof(GLUE_FXCH)) RET_MINUS1_FAIL("len,fxch") - if (bufOut) - { - memcpy(bufOut+parm_size,GLUE_FXCH,sizeof(GLUE_FXCH)); - } - parm_size+=sizeof(GLUE_FXCH); - } - #endif - - if (!*canHaveDenormalOutput) - { - // if add_op or sub_op, and constant non-denormal input, safe to omit denormal checks - if (func == (void*)nseel_asm_add_op && parm1_dv && fabs(op->parms.parms[1]->parms.dv.directValue) >= DENORMAL_CLEARING_THRESHOLD) - { - func = nseel_asm_add_op_fast; - } - else if (func == (void*)nseel_asm_sub_op && parm1_dv && fabs(op->parms.parms[1]->parms.dv.directValue) >= DENORMAL_CLEARING_THRESHOLD) - { - func = nseel_asm_sub_op_fast; - } - // or if mul/div by a fixed value of >= or <= 1.0 - else if (func == (void *)nseel_asm_mul_op && parm1_dv && fabs(op->parms.parms[1]->parms.dv.directValue) >= 1.0) - { - func = nseel_asm_mul_op_fast; - } - else if (func == (void *)nseel_asm_div_op && parm1_dv && fabs(op->parms.parms[1]->parms.dv.directValue) <= 1.0) - { - func = nseel_asm_div_op_fast; - } - } - } // not varparm - - if (cfunc_abiinfo & (BIF_CLEARDENORMAL | BIF_RETURNSBOOL) ) *canHaveDenormalOutput=0; - else if (!(cfunc_abiinfo & BIF_WONTMAKEDENORMAL)) *canHaveDenormalOutput=1; - - if (func) - { - func = GLUE_realAddress(func,&func_size); - if (!func) RET_MINUS1_FAIL("failrealladdrfunc") - } - else - { - func_size = 0; - } - - if (bufOut_len < parm_size + func_size) RET_MINUS1_FAIL("funcsz") - - if (bufOut) - { - unsigned char *p=bufOut + parm_size; - memcpy(p, func, func_size); -#if GLUE_HAS_FUSE - parm_size += GLUE_FUSE(ctx,p,parm_size,func_size,fuse_flags, -#if GLUE_MAX_SPILL_REGS > 0 - spill_reg -#else - -1 -#endif - ); - p = bufOut + parm_size; -#endif - if (preProc) p=preProc(p,func_size,ctx); - if (repl) - { - if (repl[0]) p=EEL_GLUE_set_immediate(p,(INT_PTR)repl[0]); - if (repl[1]) p=EEL_GLUE_set_immediate(p,(INT_PTR)repl[1]); - if (repl[2]) p=EEL_GLUE_set_immediate(p,(INT_PTR)repl[2]); - if (repl[3]) p=EEL_GLUE_set_immediate(p,(INT_PTR)repl[3]); - } - } - - if (restore_stack_amt) - { - int rem = restore_stack_amt; - while (rem > 0) - { - int amt = rem; - if (amt > 4096) amt=4096; - rem -= amt; - - if (bufOut_len < parm_size + func_size + GLUE_MOVE_STACK_SIZE) RET_MINUS1_FAIL("insufficient size for varparm") - if (bufOut) GLUE_MOVE_STACK(bufOut + parm_size + func_size, amt); - parm_size += GLUE_MOVE_STACK_SIZE; - } - } - - if (cfunc_abiinfo&BIF_RETURNSONSTACK) *rvMode = RETURNVALUE_FPSTACK; - else if (cfunc_abiinfo&BIF_RETURNSBOOL) *rvMode=RETURNVALUE_BOOL; - - return parm_size + func_size; -} - -static int compileEelFunctionCall(compileContext *ctx, opcodeRec *op, unsigned char *bufOut, int bufOut_len, int *computTableSize, const namespaceInformation *namespacePathToThis, - int *rvMode, int *fpStackUse, int *canHaveDenormalOutput) -{ - int func_size=0, parm_size=0; - int pn; - int last_nt_parm=-1,last_nt_parm_mode=0; - void *func_e=NULL; - int n_params; - opcodeRec *parmptrs[NSEEL_MAX_EELFUNC_PARAMETERS]; - int cfp_numparams=-1; - int cfp_statesize=0; - EEL_F **cfp_ptrs=NULL; - int func_raw=0; - int do_parms; - int x; - - void *func; - - for (x=0; x < 3; x ++) parmptrs[x] = op->parms.parms[x]; - - if (op->opcodeType == OPCODETYPE_FUNCX) - { - n_params=0; - for (x=0;x<3;x++) - { - opcodeRec *prni=op->parms.parms[x]; - while (prni && n_params < NSEEL_MAX_EELFUNC_PARAMETERS) - { - const int isMP = prni->opcodeType == OPCODETYPE_MOREPARAMS; - parmptrs[n_params++] = isMP ? prni->parms.parms[0] : prni; - if (!isMP) break; - prni = prni->parms.parms[1]; - } - } - } - else - { - n_params = 1 + op->opcodeType - OPCODETYPE_FUNC1; - } - - *fpStackUse = 0; - func = nseel_getEELFunctionAddress(ctx, op, - &cfp_numparams,&cfp_statesize,&cfp_ptrs, - computTableSize, - &func_e, &func_raw, - !!bufOut,namespacePathToThis,rvMode,fpStackUse,canHaveDenormalOutput, parmptrs, n_params); - - if (func_raw) func_size = (int) ((char*)func_e - (char*)func); - else if (func) func = GLUE_realAddress(func,&func_size); - - if (!func) RET_MINUS1_FAIL("eelfuncaddr") - -#if GLUE_MAX_FPSTACK_SIZE > 0 - *fpStackUse += 1; -#endif - - if (cfp_numparams>0 && n_params != cfp_numparams) - { - RET_MINUS1_FAIL("eelfuncnp") - } - - // user defined function - do_parms = cfp_numparams>0 && cfp_ptrs && cfp_statesize>0; - - // if function local/parameter state is zero, we need to allocate storage for it - if (cfp_statesize>0 && cfp_ptrs && !cfp_ptrs[0]) - { - EEL_F *pstate = newDataBlock(sizeof(EEL_F)*cfp_statesize,8); - if (!pstate) RET_MINUS1_FAIL("eelfuncdb") - - for (pn=0;pn= 0 && do_parms) - { - if (last_nt_parm_mode == RETURNVALUE_FPSTACK) - { - if (bufOut_len < parm_size + (int)sizeof(GLUE_POP_FPSTACK_TOSTACK)) RET_MINUS1_FAIL("eelfunc_size popfpstacktostack") - if (bufOut) memcpy(bufOut + parm_size,GLUE_POP_FPSTACK_TOSTACK,sizeof(GLUE_POP_FPSTACK_TOSTACK)); - parm_size+=sizeof(GLUE_POP_FPSTACK_TOSTACK); - } - else - { - if (bufOut_len < parm_size + (int)sizeof(GLUE_PUSH_P1PTR_AS_VALUE)) RET_MINUS1_FAIL("eelfunc_size pushp1ptrasval") - - // push - if (bufOut) memcpy(bufOut + parm_size,&GLUE_PUSH_P1PTR_AS_VALUE,sizeof(GLUE_PUSH_P1PTR_AS_VALUE)); - parm_size+=sizeof(GLUE_PUSH_P1PTR_AS_VALUE); - } - } - - last_nt_parm_mode=0; - lsz = compileOpcodes(ctx,parmptrs[pn],bufOut ? bufOut + parm_size : NULL,bufOut_len - parm_size, computTableSize, namespacePathToThis, - do_parms ? (RETURNVALUE_FPSTACK|RETURNVALUE_NORMAL) : RETURNVALUE_IGNORE,&last_nt_parm_mode,&sUse, &needDenorm); - - // todo: if needDenorm, denorm convert when copying parameter - - if (lsz<0) RET_MINUS1_FAIL("eelfunc, coc fail") - - if (last_nt_parm_mode == RETURNVALUE_FPSTACK) sUse++; - if (sUse > *fpStackUse) *fpStackUse=sUse; - parm_size += lsz; - - last_nt_parm = pn; - } - // pop non-trivial results into place - if (last_nt_parm >=0 && do_parms) - { - while (--pn >= 0) - { - if (!parmptrs[pn] || OPCODE_IS_TRIVIAL(parmptrs[pn])) continue; // skip and process after - if (pn == last_nt_parm) - { - if (last_nt_parm_mode == RETURNVALUE_FPSTACK) - { - // pop to memory directly - const int cpsize = GLUE_POP_FPSTACK_TO_PTR(NULL,NULL); - if (bufOut_len < parm_size + cpsize) RET_MINUS1_FAIL("eelfunc size popfpstacktoptr") - - if (bufOut) GLUE_POP_FPSTACK_TO_PTR((unsigned char *)bufOut + parm_size,cfp_ptrs[pn]); - parm_size += cpsize; - } - else - { - // copy direct p1ptr to mem - const int cpsize = GLUE_COPY_VALUE_AT_P1_TO_PTR(NULL,NULL); - if (bufOut_len < parm_size + cpsize) RET_MINUS1_FAIL("eelfunc size copyvalueatp1toptr") - - if (bufOut) GLUE_COPY_VALUE_AT_P1_TO_PTR((unsigned char *)bufOut + parm_size,cfp_ptrs[pn]); - parm_size += cpsize; - } - } - else - { - const int popsize = GLUE_POP_VALUE_TO_ADDR(NULL,NULL); - if (bufOut_len < parm_size + popsize) RET_MINUS1_FAIL("eelfunc size pop value to addr") - - if (bufOut) GLUE_POP_VALUE_TO_ADDR((unsigned char *)bufOut + parm_size,cfp_ptrs[pn]); - parm_size+=popsize; - - } - } - } - - // finally, set any trivial parameters - if (do_parms) - { - const int cpsize = GLUE_MOV_PX_DIRECTVALUE_SIZE + GLUE_COPY_VALUE_AT_P1_TO_PTR(NULL,NULL); - for (pn=0; pn < n_params; pn++) - { - if (!parmptrs[pn] || !OPCODE_IS_TRIVIAL(parmptrs[pn])) continue; // set trivial values, we already set nontrivials - - if (bufOut_len < parm_size + cpsize) RET_MINUS1_FAIL("eelfunc size trivial set") - - if (bufOut) - { - if (generateValueToReg(ctx,parmptrs[pn],bufOut + parm_size,0,namespacePathToThis, 1)<0) RET_MINUS1_FAIL("eelfunc gvr fail") - GLUE_COPY_VALUE_AT_P1_TO_PTR(bufOut + parm_size + GLUE_MOV_PX_DIRECTVALUE_SIZE,cfp_ptrs[pn]); - } - parm_size += cpsize; - - } - } - - if (bufOut_len < parm_size + func_size) RET_MINUS1_FAIL("eelfunc size combined") - - if (bufOut) memcpy(bufOut + parm_size, func, func_size); - - return parm_size + func_size; - // end of EEL function generation -} - -#ifdef DUMP_OPS_DURING_COMPILE -void dumpOp(compileContext *ctx, opcodeRec *op, int start); -#endif - -#ifdef EEL_DUMP_OPS -void dumpOpcodeTree(compileContext *ctx, FILE *fp, opcodeRec *op, int indent_amt) -{ - const char *fname=""; - fprintf(fp,"%*sOP TYPE %d", indent_amt, "", - op->opcodeType==OPCODETYPE_DIRECTVALUE_TEMPSTRING ? 10000 : // remap around OPCODETYPE_DIRECTVALUE_TEMPSTRING - op->opcodeType > OPCODETYPE_DIRECTVALUE_TEMPSTRING ? op->opcodeType - 1 : - op->opcodeType); - - if ((op->opcodeType == OPCODETYPE_FUNC1 || - op->opcodeType == OPCODETYPE_FUNC2 || - op->opcodeType == OPCODETYPE_FUNC3 || - op->opcodeType == OPCODETYPE_FUNCX)) - { - if (op->fntype == FUNCTYPE_FUNCTIONTYPEREC) - { - functionType *fn_ptr = (functionType *)op->fn; - fname = fn_ptr->name; - } - else if (op->fntype == FUNCTYPE_EELFUNC) - { - fname = op->relname; - } - if (!fname) fname =""; - } - - switch (op->opcodeType) - { - case OPCODETYPE_DIRECTVALUE: - fprintf(fp," DV=%f\r\n",op->parms.dv.directValue); - break; - case OPCODETYPE_VALUE_FROM_NAMESPACENAME: // this.* or namespace.* are encoded this way - fprintf(fp," NSN=%s(%d)\r\n",op->relname?op->relname : "(null)",op->namespaceidx); - break; - case OPCODETYPE_VARPTR: - { - const char *nm = op->relname; - if (!nm || !*nm) - { - int wb; - for (wb = 0; wb < ctx->varTable_numBlocks; wb ++) - { - char **plist=ctx->varTable_Names[wb]; - if (!plist) break; - - if (op->parms.dv.valuePtr >= ctx->varTable_Values[wb] && op->parms.dv.valuePtr < ctx->varTable_Values[wb] + NSEEL_VARS_PER_BLOCK) - { - nm = plist[op->parms.dv.valuePtr - ctx->varTable_Values[wb]]; - break; - } - } - } - fprintf(fp," VP=%s\r\n", nm?nm : "(null)"); - } - break; - case OPCODETYPE_VARPTRPTR: - fprintf(fp, " VPP?\r\n"); - break; - case OPCODETYPE_FUNC1: - if (op->fntype == FN_NOT) - fprintf(fp," FUNC1 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_not"); - else if (op->fntype == FN_NOTNOT) - fprintf(fp," FUNC1 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_notnot"); - else if (op->fntype == FN_MEMORY) - fprintf(fp," FUNC1 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_mem"); - else if (op->fntype == FN_GMEMORY) - fprintf(fp," FUNC1 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_gmem"); - else if (op->fntype == FN_WHILE) - fprintf(fp," FUNC1 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "while"); - else - fprintf(fp," FUNC1 %d %s {\r\n",op->fntype, fname); - - if (op->parms.parms[0]) - dumpOpcodeTree(ctx,fp,op->parms.parms[0],indent_amt+2); - else - fprintf(fp,"%*sINVALID PARM\r\n",indent_amt+2,""); - fprintf(fp,"%*s}\r\n", indent_amt, ""); - break; - case OPCODETYPE_MOREPARAMS: - case OPCODETYPE_FUNC2: - if (op->opcodeType == OPCODETYPE_MOREPARAMS) - fprintf(fp," MOREPARAMS {\r\n"); - else - { - if (op->fntype == FN_POW) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "pow"); - else if (op->fntype == FN_MOD) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_mod"); - else if (op->fntype == FN_XOR) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_xor"); - else if (op->fntype == FN_SHL) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_shl"); - else if (op->fntype == FN_SHR) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_shr"); - else if (op->fntype == FN_LT) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_below"); - else if (op->fntype == FN_GT) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_above"); - else if (op->fntype == FN_LTE) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_beleq"); - else if (op->fntype == FN_GTE) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_aboeq"); - else if (op->fntype == FN_EQ) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_equal"); - else if (op->fntype == FN_NE) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_noteq"); - else if (op->fntype == FN_EQ_EXACT) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_equal_exact"); - else if (op->fntype == FN_NE_EXACT) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_noteq_exact"); - else if (op->fntype == FN_LOGICAL_AND) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_and"); - else if (op->fntype == FN_LOGICAL_OR) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_or"); - else if (op->fntype == FN_ASSIGN) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_set"); - else if (op->fntype == FN_ADD_OP) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_addop"); - else if (op->fntype == FN_SUB_OP) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_subop"); - else if (op->fntype == FN_MUL_OP) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_mulop"); - else if (op->fntype == FN_DIV_OP) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_divop"); - else if (op->fntype == FN_OR_OP) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_orop"); - else if (op->fntype == FN_AND_OP) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_andop"); - else if (op->fntype == FN_XOR_OP) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_xorop"); - else if (op->fntype == FN_MOD_OP) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_modop"); - else if (op->fntype == FN_POW_OP) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_powop"); - else if (op->fntype == FN_LOOP) - fprintf(fp," FUNC2 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "loop"); - else - fprintf(fp," FUNC2 %d %s {\r\n",op->fntype, fname); - } - if (op->parms.parms[0]) - dumpOpcodeTree(ctx,fp,op->parms.parms[0],indent_amt+2); - else - fprintf(fp,"%*sINVALID PARM\r\n",indent_amt+2,""); - - if (op->parms.parms[1]) - dumpOpcodeTree(ctx,fp,op->parms.parms[1],indent_amt+2); - else - fprintf(fp,"%*sINVALID PARM\r\n",indent_amt+2,""); - fprintf(fp,"%*s}\r\n", indent_amt, ""); - break; - case OPCODETYPE_FUNCX: - case OPCODETYPE_FUNC3: - if (op->opcodeType == OPCODETYPE_FUNCX) - fprintf(fp," FUNCX %d %s {\r\n",op->fntype, fname); - else if (op->fntype == FN_IF_ELSE) - fprintf(fp," FUNC3 %d %s {\r\n",FUNCTYPE_FUNCTIONTYPEREC, "_if"); - else - fprintf(fp," FUNC3 %d %s {\r\n",op->fntype, fname); - if (op->parms.parms[0]) - dumpOpcodeTree(ctx,fp,op->parms.parms[0],indent_amt+2); - else - fprintf(fp,"%*sINVALID PARM\r\n",indent_amt+2,""); - - if (op->parms.parms[1]) - dumpOpcodeTree(ctx,fp,op->parms.parms[1],indent_amt+2); - else - fprintf(fp,"%*sINVALID PARM\r\n",indent_amt+2,""); - - if (op->parms.parms[2]) - dumpOpcodeTree(ctx,fp,op->parms.parms[2],indent_amt+2); - else - fprintf(fp,"%*sINVALID PARM\r\n",indent_amt+2,""); - fprintf(fp,"%*s}\r\n", indent_amt, ""); - - break; - } -} - -#endif - -#ifdef GLUE_MAX_JMPSIZE -#define CHECK_SIZE_FORJMP(x,y) if ((x)<0 || (x)>=GLUE_MAX_JMPSIZE) goto y; -#define RET_MINUS1_FAIL_FALLBACK(err,j) goto j; -#else -#define CHECK_SIZE_FORJMP(x,y) -#define RET_MINUS1_FAIL_FALLBACK(err,j) RET_MINUS1_FAIL(err) -#endif -static int compileOpcodesInternal(compileContext *ctx, opcodeRec *op, unsigned char *bufOut, int bufOut_len, int *computTableSize, const namespaceInformation *namespacePathToThis, int *calledRvType, int preferredReturnValues, int *fpStackUse, int *canHaveDenormalOutput) -{ - int rv_offset=0, denormal_force=-1; - if (!op) RET_MINUS1_FAIL("coi !op") - - *fpStackUse=0; - for (;;) - { - // special case: statement delimiting means we can process the left side into place, and iteratively do the second parameter without recursing - // also we don't need to save/restore anything to the stack (which the normal 2 parameter function processing does) - if (op->opcodeType == OPCODETYPE_FUNC2 && op->fntype == FN_JOIN_STATEMENTS) - { - int fUse1; - int parm_size = compileOpcodes(ctx,op->parms.parms[0],bufOut,bufOut_len, computTableSize, namespacePathToThis, RETURNVALUE_IGNORE, NULL,&fUse1,NULL); - if (parm_size < 0) RET_MINUS1_FAIL("coc join fail") - op = op->parms.parms[1]; - if (!op) RET_MINUS1_FAIL("join got to null") - - if (fUse1>*fpStackUse) *fpStackUse=fUse1; - if (bufOut) bufOut += parm_size; - bufOut_len -= parm_size; - rv_offset += parm_size; -#ifdef DUMP_OPS_DURING_COMPILE - if (op->opcodeType != OPCODETYPE_FUNC2 || op->fntype != FN_JOIN_STATEMENTS) dumpOp(ctx,op,0); -#endif - denormal_force=-1; - } - // special case: __denormal_likely(), __denormal_unlikely() - else if (op->opcodeType == OPCODETYPE_FUNC1 && (op->fntype == FN_DENORMAL_LIKELY || op->fntype == FN_DENORMAL_UNLIKELY)) - { - denormal_force = op->fntype == FN_DENORMAL_LIKELY; - op = op->parms.parms[0]; - } - else - { - break; - } - } - if (denormal_force >= 0 && canHaveDenormalOutput) - { - *canHaveDenormalOutput = denormal_force; - canHaveDenormalOutput = &denormal_force; // prevent it from being changed by functions below - } - - // special case: BAND/BOR - if (op->opcodeType == OPCODETYPE_FUNC2 && (op->fntype == FN_LOGICAL_AND || op->fntype == FN_LOGICAL_OR)) - { - int fUse1=0; - int parm_size; -#ifdef GLUE_MAX_JMPSIZE - int parm_size_pre; -#endif - int retType=RETURNVALUE_IGNORE; - if (preferredReturnValues != RETURNVALUE_IGNORE) retType = RETURNVALUE_BOOL; - - *calledRvType = retType; - - parm_size = compileOpcodes(ctx,op->parms.parms[0],bufOut,bufOut_len, computTableSize, namespacePathToThis, RETURNVALUE_BOOL, NULL, &fUse1, NULL); - if (parm_size < 0) RET_MINUS1_FAIL("loop band/bor coc fail") - - if (fUse1 > *fpStackUse) *fpStackUse=fUse1; - - -#ifdef GLUE_MAX_JMPSIZE - parm_size_pre=parm_size; -#endif - - { - int sz2, fUse2=0; - const int testsz=op->fntype == FN_LOGICAL_OR ? sizeof(GLUE_JMP_IF_P1_NZ) : sizeof(GLUE_JMP_IF_P1_Z); - if (bufOut_len < parm_size+testsz) RET_MINUS1_FAIL_FALLBACK("band/bor size fail",doNonInlinedAndOr_) - - if (bufOut) memcpy(bufOut+parm_size,op->fntype == FN_LOGICAL_OR ? GLUE_JMP_IF_P1_NZ : GLUE_JMP_IF_P1_Z,testsz); - parm_size += testsz; - - sz2 = compileOpcodes(ctx,op->parms.parms[1],bufOut?bufOut+parm_size:NULL,bufOut_len-parm_size, computTableSize, namespacePathToThis, retType, NULL,&fUse2, NULL); - - CHECK_SIZE_FORJMP(sz2,doNonInlinedAndOr_) - if (sz2<0) RET_MINUS1_FAIL("band/bor coc fail") - - if (bufOut) GLUE_JMP_SET_OFFSET(bufOut + parm_size, sz2); - parm_size+=sz2; - - if (fUse2 > *fpStackUse) *fpStackUse=fUse2; - return rv_offset + parm_size; - } -#ifdef GLUE_MAX_JMPSIZE - if (0) - { - void *stub; - int stubsize; - unsigned char *newblock2, *p; - - // encode as function call -doNonInlinedAndOr_: - parm_size = parm_size_pre; - - if (op->fntype == FN_LOGICAL_AND) - { - stub = GLUE_realAddress(nseel_asm_band,&stubsize); - } - else - { - stub = GLUE_realAddress(nseel_asm_bor,&stubsize); - } - - if (bufOut_len < parm_size + stubsize) RET_MINUS1_FAIL("band/bor len fail") - - if (bufOut) - { - int fUse2=0; - newblock2 = compileCodeBlockWithRet(ctx,op->parms.parms[1],computTableSize,namespacePathToThis, retType, NULL, &fUse2, NULL); - if (!newblock2) RET_MINUS1_FAIL("band/bor ccbwr fail") - - if (fUse2 > *fpStackUse) *fpStackUse=fUse2; - - p = bufOut + parm_size; - memcpy(p, stub, stubsize); - - p=EEL_GLUE_set_immediate(p,(INT_PTR)newblock2); - } - return rv_offset + parm_size + stubsize; - } -#endif - } - - if (op->opcodeType == OPCODETYPE_FUNC3 && op->fntype == FN_IF_ELSE) // special case: IF - { - int fUse1=0; -#ifdef GLUE_MAX_JMPSIZE - int parm_size_pre; -#endif - int use_rv = RETURNVALUE_IGNORE; - int rvMode=0; - int parm_size = compileOpcodes(ctx,op->parms.parms[0],bufOut,bufOut_len, computTableSize, namespacePathToThis, RETURNVALUE_BOOL|RETURNVALUE_BOOL_REVERSED, &rvMode,&fUse1, NULL); - if (parm_size < 0) RET_MINUS1_FAIL("if coc fail") - if (fUse1 > *fpStackUse) *fpStackUse=fUse1; - - if (preferredReturnValues & RETURNVALUE_NORMAL) use_rv=RETURNVALUE_NORMAL; - else if (preferredReturnValues & RETURNVALUE_FPSTACK) use_rv=RETURNVALUE_FPSTACK; - else if (preferredReturnValues & RETURNVALUE_BOOL) use_rv=RETURNVALUE_BOOL; - - *calledRvType = use_rv; -#ifdef GLUE_MAX_JMPSIZE - parm_size_pre = parm_size; -#endif - - { - int csz,hasSecondHalf; - if (rvMode & RETURNVALUE_BOOL_REVERSED) - { - if (bufOut_len < parm_size + (int)sizeof(GLUE_JMP_IF_P1_NZ)) RET_MINUS1_FAIL_FALLBACK("if size fail",doNonInlineIf_) - if (bufOut) memcpy(bufOut+parm_size,GLUE_JMP_IF_P1_NZ,sizeof(GLUE_JMP_IF_P1_NZ)); - parm_size += sizeof(GLUE_JMP_IF_P1_NZ); - } - else - { - if (bufOut_len < parm_size + (int)sizeof(GLUE_JMP_IF_P1_Z)) RET_MINUS1_FAIL_FALLBACK("if size fail",doNonInlineIf_) - if (bufOut) memcpy(bufOut+parm_size,GLUE_JMP_IF_P1_Z,sizeof(GLUE_JMP_IF_P1_Z)); - parm_size += sizeof(GLUE_JMP_IF_P1_Z); - } - csz=compileOpcodes(ctx,op->parms.parms[1],bufOut ? bufOut+parm_size : NULL,bufOut_len - parm_size, computTableSize, namespacePathToThis, use_rv, NULL,&fUse1, canHaveDenormalOutput); - if (fUse1 > *fpStackUse) *fpStackUse=fUse1; - hasSecondHalf = preferredReturnValues || !OPCODE_IS_TRIVIAL(op->parms.parms[2]); - - CHECK_SIZE_FORJMP(csz,doNonInlineIf_) - if (csz<0) RET_MINUS1_FAIL("if coc fial") - - if (bufOut) GLUE_JMP_SET_OFFSET(bufOut + parm_size, csz + (hasSecondHalf?sizeof(GLUE_JMP_NC):0)); - parm_size+=csz; - - if (hasSecondHalf) - { - if (bufOut_len < parm_size + (int)sizeof(GLUE_JMP_NC)) RET_MINUS1_FAIL_FALLBACK("if len fail",doNonInlineIf_) - if (bufOut) memcpy(bufOut+parm_size,GLUE_JMP_NC,sizeof(GLUE_JMP_NC)); - parm_size+=sizeof(GLUE_JMP_NC); - - csz=compileOpcodes(ctx,op->parms.parms[2],bufOut ? bufOut+parm_size : NULL,bufOut_len - parm_size, computTableSize, namespacePathToThis, use_rv, NULL, &fUse1, canHaveDenormalOutput); - - CHECK_SIZE_FORJMP(csz,doNonInlineIf_) - if (csz<0) RET_MINUS1_FAIL("if coc 2 fail") - - // update jump address - if (bufOut) GLUE_JMP_SET_OFFSET(bufOut + parm_size,csz); - parm_size+=csz; - if (fUse1 > *fpStackUse) *fpStackUse=fUse1; - } - return rv_offset + parm_size; - } -#ifdef GLUE_MAX_JMPSIZE - if (0) - { - unsigned char *newblock2,*newblock3,*ptr; - void *stub; - int stubsize; -doNonInlineIf_: - parm_size = parm_size_pre; - stub = GLUE_realAddress(nseel_asm_if,&stubsize); - - if (!stub || bufOut_len < parm_size + stubsize) RET_MINUS1_FAIL(stub ? "if sz fail" : "if addr fail") - - if (bufOut) - { - int fUse2=0; - newblock2 = compileCodeBlockWithRet(ctx,op->parms.parms[1],computTableSize,namespacePathToThis, use_rv, NULL,&fUse2, canHaveDenormalOutput); - if (fUse2 > *fpStackUse) *fpStackUse=fUse2; - newblock3 = compileCodeBlockWithRet(ctx,op->parms.parms[2],computTableSize,namespacePathToThis, use_rv, NULL,&fUse2, canHaveDenormalOutput); - if (fUse2 > *fpStackUse) *fpStackUse=fUse2; - if (!newblock2 || !newblock3) RET_MINUS1_FAIL("if subblock gen fail") - - ptr = bufOut + parm_size; - memcpy(ptr, stub, stubsize); - - ptr=EEL_GLUE_set_immediate(ptr,(INT_PTR)newblock2); - EEL_GLUE_set_immediate(ptr,(INT_PTR)newblock3); - } - return rv_offset + parm_size + stubsize; - } -#endif - } - - { - // special case: while - if (op->opcodeType == OPCODETYPE_FUNC1 && op->fntype == FN_WHILE) - { - *calledRvType = RETURNVALUE_BOOL; - -#ifndef GLUE_INLINE_LOOPS - // todo: PPC looping support when loop length is small enough - { - unsigned char *pwr=bufOut; - unsigned char *newblock2; - int stubsz; - void *stubfunc = GLUE_realAddress(nseel_asm_repeatwhile,&stubsz); - if (!stubfunc || bufOut_len < stubsz) RET_MINUS1_FAIL(stubfunc ? "repeatwhile size fail" :"repeatwhile addr fail") - - if (bufOut) - { - int fUse1 = 0; - newblock2=compileCodeBlockWithRet(ctx,op->parms.parms[0],computTableSize,namespacePathToThis, RETURNVALUE_BOOL, NULL, &fUse1, NULL); - if (!newblock2) RET_MINUS1_FAIL("repeatwhile ccbwr fail") - - if (fUse1 > *fpStackUse) *fpStackUse = fUse1; - memcpy(pwr,stubfunc,stubsz); - pwr=EEL_GLUE_set_immediate(pwr,(INT_PTR)newblock2); - } - - return rv_offset+stubsz; - } -#else - { -#ifndef GLUE_WHILE_END_NOJUMP - unsigned char *jzoutpt; -#endif - unsigned char *looppt; - int parm_size=0,subsz, fUse1=0; - if (bufOut_len < parm_size + (int)(GLUE_WHILE_SETUP_SIZE + sizeof(GLUE_WHILE_BEGIN))) RET_MINUS1_FAIL("while size fail 1") - - if (bufOut) memcpy(bufOut + parm_size,GLUE_WHILE_SETUP,GLUE_WHILE_SETUP_SIZE); - parm_size+=GLUE_WHILE_SETUP_SIZE; - - looppt = bufOut + parm_size; - if (bufOut) memcpy(bufOut + parm_size,GLUE_WHILE_BEGIN,sizeof(GLUE_WHILE_BEGIN)); - parm_size+=sizeof(GLUE_WHILE_BEGIN); - - subsz = compileOpcodes(ctx,op->parms.parms[0],bufOut ? (bufOut + parm_size) : NULL,bufOut_len - parm_size, computTableSize, namespacePathToThis, RETURNVALUE_BOOL, NULL,&fUse1, NULL); - if (fUse1 > *fpStackUse) *fpStackUse = fUse1; - if (subsz<0) RET_MINUS1_FAIL("while coc fail") - - if (bufOut_len < parm_size + (int)(sizeof(GLUE_WHILE_END) + sizeof(GLUE_WHILE_CHECK_RV))) RET_MINUS1_FAIL("which size fial 2") - - parm_size+=subsz; - if (bufOut) memcpy(bufOut + parm_size, GLUE_WHILE_END, sizeof(GLUE_WHILE_END)); - parm_size+=sizeof(GLUE_WHILE_END); -#ifndef GLUE_WHILE_END_NOJUMP - jzoutpt = bufOut + parm_size; -#endif - - if (bufOut) memcpy(bufOut + parm_size, GLUE_WHILE_CHECK_RV, sizeof(GLUE_WHILE_CHECK_RV)); - parm_size+=sizeof(GLUE_WHILE_CHECK_RV); - if (bufOut) - { - GLUE_JMP_SET_OFFSET(bufOut + parm_size,(looppt - (bufOut+parm_size)) ); -#ifndef GLUE_WHILE_END_NOJUMP - GLUE_JMP_SET_OFFSET(jzoutpt, (bufOut + parm_size) - jzoutpt); -#endif - } - return rv_offset+parm_size; - } - -#endif - } - - // special case: loop - if (op->opcodeType == OPCODETYPE_FUNC2 && op->fntype == FN_LOOP) - { - int fUse1; - int parm_size = compileOpcodes(ctx,op->parms.parms[0],bufOut,bufOut_len, computTableSize, namespacePathToThis, RETURNVALUE_FPSTACK, NULL,&fUse1, NULL); - if (parm_size < 0) RET_MINUS1_FAIL("loop coc fail") - - *calledRvType = RETURNVALUE_BOOL; - if (fUse1 > *fpStackUse) *fpStackUse=fUse1; - -#ifndef GLUE_INLINE_LOOPS - // todo: PPC looping support when loop length is small enough - { - void *stub; - int stubsize; - unsigned char *newblock2, *p; - stub = GLUE_realAddress(nseel_asm_repeat,&stubsize); - if (bufOut_len < parm_size + stubsize) RET_MINUS1_FAIL("loop size fail") - if (bufOut) - { - newblock2 = compileCodeBlockWithRet(ctx,op->parms.parms[1],computTableSize,namespacePathToThis, RETURNVALUE_IGNORE, NULL,fpStackUse, NULL); - - p = bufOut + parm_size; - memcpy(p, stub, stubsize); - - p=EEL_GLUE_set_immediate(p,(INT_PTR)newblock2); - } - return rv_offset + parm_size + stubsize; - } -#else - { - int subsz; - int fUse2=0; - unsigned char *skipptr1,*loopdest; - -#ifndef GLUE_LOOP_LOADCNT_SIZE -#define GLUE_LOOP_LOADCNT_SIZE sizeof(GLUE_LOOP_LOADCNT) -#endif - if (bufOut_len < parm_size + (int)(GLUE_LOOP_LOADCNT_SIZE + GLUE_LOOP_CLAMPCNT_SIZE + GLUE_LOOP_BEGIN_SIZE)) RET_MINUS1_FAIL("loop size fail") - - // store, convert to int, compare against 1, if less than, skip to end - if (bufOut) memcpy(bufOut+parm_size,GLUE_LOOP_LOADCNT,GLUE_LOOP_LOADCNT_SIZE); - parm_size += GLUE_LOOP_LOADCNT_SIZE; - skipptr1 = bufOut+parm_size; - - // compare aginst max loop length, jump to loop start if not above it - if (bufOut) memcpy(bufOut+parm_size,GLUE_LOOP_CLAMPCNT,GLUE_LOOP_CLAMPCNT_SIZE); - parm_size += GLUE_LOOP_CLAMPCNT_SIZE; - - // loop code: - loopdest = bufOut + parm_size; - - if (bufOut) memcpy(bufOut+parm_size,GLUE_LOOP_BEGIN,GLUE_LOOP_BEGIN_SIZE); - parm_size += GLUE_LOOP_BEGIN_SIZE; - - subsz = compileOpcodes(ctx,op->parms.parms[1],bufOut ? (bufOut + parm_size) : NULL,bufOut_len - parm_size, computTableSize, namespacePathToThis, RETURNVALUE_IGNORE, NULL, &fUse2, NULL); - if (subsz<0) RET_MINUS1_FAIL("loop coc fail") - if (fUse2 > *fpStackUse) *fpStackUse=fUse2; - - parm_size += subsz; - - if (bufOut_len < parm_size + (int)sizeof(GLUE_LOOP_END)) RET_MINUS1_FAIL("loop size fail 2") - - if (bufOut) memcpy(bufOut+parm_size,GLUE_LOOP_END,sizeof(GLUE_LOOP_END)); - parm_size += sizeof(GLUE_LOOP_END); - - if (bufOut) - { - GLUE_JMP_SET_OFFSET(bufOut + parm_size,loopdest - (bufOut+parm_size)); - GLUE_JMP_SET_OFFSET(skipptr1, (bufOut+parm_size) - skipptr1); - } - - return rv_offset + parm_size; - - } -#endif - } - } - - switch (op->opcodeType) - { - case OPCODETYPE_DIRECTVALUE: - if (preferredReturnValues == RETURNVALUE_BOOL) - { - int w = fabs(op->parms.dv.directValue) >= NSEEL_CLOSEFACTOR; - int wsz=(w?sizeof(GLUE_SET_P1_NZ):sizeof(GLUE_SET_P1_Z)); - - *calledRvType = RETURNVALUE_BOOL; - if (bufOut_len < wsz) RET_MINUS1_FAIL("direct bool size fail3") - if (bufOut) memcpy(bufOut,w?GLUE_SET_P1_NZ:GLUE_SET_P1_Z,wsz); - return rv_offset+wsz; - } - else if (preferredReturnValues & RETURNVALUE_FPSTACK) - { -#ifdef GLUE_HAS_FLDZ - if (op->parms.dv.directValue == 0.0) - { -#if GLUE_MAX_FPSTACK_SIZE > 0 - if (*fpStackUse < 1) *fpStackUse = 1; -#endif - *calledRvType = RETURNVALUE_FPSTACK; - if (bufOut_len < sizeof(GLUE_FLDZ)) RET_MINUS1_FAIL("direct fp fail 1") - if (bufOut) memcpy(bufOut,GLUE_FLDZ,sizeof(GLUE_FLDZ)); - return rv_offset+sizeof(GLUE_FLDZ); - } -#endif -#ifdef GLUE_HAS_FLD1 - if (op->parms.dv.directValue == 1.0) - { -#if GLUE_MAX_FPSTACK_SIZE > 0 - if (*fpStackUse < 1) *fpStackUse = 1; -#endif - *calledRvType = RETURNVALUE_FPSTACK; - if (bufOut_len < sizeof(GLUE_FLD1)) RET_MINUS1_FAIL("direct fp fail 1") - if (bufOut) memcpy(bufOut,GLUE_FLD1,sizeof(GLUE_FLD1)); - return rv_offset+sizeof(GLUE_FLD1); - } -#endif - } - WDL_FALLTHROUGH; // fall through - case OPCODETYPE_DIRECTVALUE_TEMPSTRING: - case OPCODETYPE_VALUE_FROM_NAMESPACENAME: - case OPCODETYPE_VARPTR: - case OPCODETYPE_VARPTRPTR: - - #if GLUE_HAS_FPREG2 > 0 - if (preferredReturnValues & RETURNVALUE_FPREG2) - { - if (preferredReturnValues != RETURNVALUE_FPREG2) RET_MINUS1_FAIL("RETURNVALUE_FPREG2 but not exact hm") - if (bufOut_len < GLUE_MOV_PX_DIRECTVALUE_TOFPREG2_SIZE) RET_MINUS1_FAIL("direct fp2 fail 2") - if (bufOut) - { - if (generateValueToReg(ctx,op,bufOut,-2,namespacePathToThis, 1 /*allow caching*/)<0) RET_MINUS1_FAIL("direct fp2 fail gvr") - } - *calledRvType = RETURNVALUE_FPREG2; - return rv_offset+GLUE_MOV_PX_DIRECTVALUE_TOFPREG2_SIZE; - } - #endif - - #ifdef GLUE_MOV_PX_DIRECTVALUE_TOSTACK_SIZE - if (OPCODE_IS_TRIVIAL(op)) - { - if (preferredReturnValues & RETURNVALUE_FPSTACK) - { -#if GLUE_MAX_FPSTACK_SIZE > 0 - if (*fpStackUse < 1) *fpStackUse = 1; -#endif - if (bufOut_len < GLUE_MOV_PX_DIRECTVALUE_TOSTACK_SIZE) RET_MINUS1_FAIL("direct fp fail 2") - if (bufOut) - { - if (generateValueToReg(ctx,op,bufOut,-1,namespacePathToThis, 1 /*allow caching*/)<0) RET_MINUS1_FAIL("direct fp fail gvr") - } - *calledRvType = RETURNVALUE_FPSTACK; - return rv_offset+GLUE_MOV_PX_DIRECTVALUE_TOSTACK_SIZE; - } - } - #endif - - if (bufOut_len < GLUE_MOV_PX_DIRECTVALUE_SIZE) - { - RET_MINUS1_FAIL("direct value fail 1") - } - if (bufOut) - { - if (generateValueToReg(ctx,op,bufOut,0,namespacePathToThis, - (preferredReturnValues&(RETURNVALUE_FPSTACK|RETURNVALUE_CACHEABLE))!=0)<0) - { - RET_MINUS1_FAIL("direct value gvr fail3") - } - } - return rv_offset + GLUE_MOV_PX_DIRECTVALUE_SIZE; - - case OPCODETYPE_FUNCX: - case OPCODETYPE_FUNC1: - case OPCODETYPE_FUNC2: - case OPCODETYPE_FUNC3: - - if (op->fntype == FUNCTYPE_EELFUNC) - { - int a, fpUse1=0; - - a = compileEelFunctionCall(ctx,op,bufOut,bufOut_len,computTableSize,namespacePathToThis, calledRvType,&fpUse1,canHaveDenormalOutput); - if (a<0) return a; - if (fpUse1 > *fpStackUse) *fpStackUse = fpUse1; - rv_offset += a; - } - else - { - int a, fpUse1=0; - a = compileNativeFunctionCall(ctx,op,bufOut,bufOut_len,computTableSize,namespacePathToThis, calledRvType,&fpUse1,preferredReturnValues,canHaveDenormalOutput); - if (a<0)return a; - if (fpUse1 > *fpStackUse) *fpStackUse = fpUse1; - rv_offset += a; - } - return rv_offset; - } - - RET_MINUS1_FAIL("default opcode fail") -} - -#ifdef DUMP_OPS_DURING_COMPILE -FILE *g_debugfp; -int g_debugfp_indent; -int g_debugfp_histsz=0; - -void dumpOp(compileContext *ctx, opcodeRec *op, int start) -{ - if (start>=0) - { - if (g_debugfp) - { - static opcodeRec **hist; - - int x; - int hit=0; - if (!hist) hist = (opcodeRec**) calloc(1024,1024*sizeof(opcodeRec*)); - for(x=0;x=100) *(char *)1=0; - fprintf(g_debugfp,"%*s{ %p : %d%s: ",g_debugfp_indent," ",op,op->opcodeType, hit ? " -- DUPLICATE" : ""); - switch (op->opcodeType) - { - case OPCODETYPE_DIRECTVALUE: - fprintf(g_debugfp,"dv %f",op->parms.dv.directValue); - break; - case OPCODETYPE_VARPTR: - if (op->relname && op->relname[0]) - { - fprintf(g_debugfp,"var %s",op->relname); - } - else - { - int wb; - for (wb = 0; wb < ctx->varTable_numBlocks; wb ++) - { - char **plist=ctx->varTable_Names[wb]; - if (!plist) break; - - if (op->parms.dv.valuePtr >= ctx->varTable_Values[wb] && op->parms.dv.valuePtr < ctx->varTable_Values[wb] + NSEEL_VARS_PER_BLOCK) - { - fprintf(g_debugfp,"var %s",plist[op->parms.dv.valuePtr - ctx->varTable_Values[wb]]); - break; - } - } - } - break; - case OPCODETYPE_FUNC1: - case OPCODETYPE_FUNC2: - case OPCODETYPE_FUNC3: - case OPCODETYPE_FUNCX: - if (op->fntype == FUNCTYPE_FUNCTIONTYPEREC) - { - functionType *p=(functionType*)op->fn; - fprintf(g_debugfp,"func %d: %s",p->nParams&0xff,p->name); - } - else - fprintf(g_debugfp,"sf %d",op->fntype); - break; - - } - fprintf(g_debugfp,"\n"); - g_debugfp_indent+=2; - } - } - else - { - if (g_debugfp) - { - g_debugfp_indent-=2; - fprintf(g_debugfp,"%*s}%p\n",g_debugfp_indent," ",op); - } - } -} -#endif - -int compileOpcodes(compileContext *ctx, opcodeRec *op, unsigned char *bufOut, int bufOut_len, int *computTableSize, const namespaceInformation *namespacePathToThis, - int supportedReturnValues, int *rvType, int *fpStackUse, int *canHaveDenormalOutput) -{ - int code_returns=RETURNVALUE_NORMAL; - int fpsu=0; - int codesz; - int denorm=0; - -#ifdef DUMP_OPS_DURING_COMPILE - dumpOp(ctx,op,1); -#endif - - codesz = compileOpcodesInternal(ctx,op,bufOut,bufOut_len,computTableSize,namespacePathToThis,&code_returns, supportedReturnValues,&fpsu,&denorm); - if (denorm && canHaveDenormalOutput) *canHaveDenormalOutput=1; - -#ifdef DUMP_OPS_DURING_COMPILE - dumpOp(ctx,op,-1); -#endif -#ifdef EEL_DUMP_OPS - // dump opcode trees for verification, after optimizing - if (g_eel_dump_fp2) - { - fprintf(g_eel_dump_fp2,"-- compileOpcodes generated %d bytes of code!\r\n",codesz); - } -#endif - if (codesz < 0) return codesz; - -#if GLUE_HAS_FPREG2 > 0 - if (supportedReturnValues & RETURNVALUE_FPREG2) - { - if (code_returns != RETURNVALUE_FPREG2) - RET_MINUS1_FAIL("fpstack2 not return correct fail"); - } -#endif - - /* - { - wdl_log("opcode %d %d (%s): fpu use: %d\n",op->opcodeType,op->fntype, - op->opcodeType >= OPCODETYPE_FUNC1 && op->fntype == FUNCTYPE_FUNCTIONTYPEREC ? ( - ((functionType *)op->fn)->name - ) : "", - fpsu); - } - */ - - if (fpStackUse) *fpStackUse=fpsu; - - if (bufOut) bufOut += codesz; - bufOut_len -= codesz; - - - if (code_returns == RETURNVALUE_BOOL && !(supportedReturnValues & RETURNVALUE_BOOL) && supportedReturnValues) - { - int stubsize; - void *stub = GLUE_realAddress(nseel_asm_booltofp,&stubsize); - if (!stub || bufOut_len < stubsize) RET_MINUS1_FAIL(stub?"booltofp size":"booltfp addr") - if (bufOut) - { - memcpy(bufOut,stub,stubsize); - bufOut += stubsize; - } - codesz+=stubsize; - bufOut_len -= stubsize; - - code_returns = RETURNVALUE_FPSTACK; - } - - - // default processing of code_returns to meet return value requirements - if (supportedReturnValues & code_returns) - { - if (rvType) *rvType = code_returns; - return codesz; - } - - - if (rvType) *rvType = RETURNVALUE_IGNORE; - - - if (code_returns == RETURNVALUE_NORMAL) - { - if (supportedReturnValues & (RETURNVALUE_FPSTACK|RETURNVALUE_BOOL)) - { - if (bufOut_len < GLUE_PUSH_VAL_AT_PX_TO_FPSTACK_SIZE) RET_MINUS1_FAIL("pushvalatpxtofpstack,size") - if (bufOut) - { - GLUE_PUSH_VAL_AT_PX_TO_FPSTACK(bufOut,0); // always fld qword [eax] but we might change that later - bufOut += GLUE_PUSH_VAL_AT_PX_TO_FPSTACK_SIZE; - } - codesz += GLUE_PUSH_VAL_AT_PX_TO_FPSTACK_SIZE; - bufOut_len -= GLUE_PUSH_VAL_AT_PX_TO_FPSTACK_SIZE; - - if (supportedReturnValues & RETURNVALUE_BOOL) - { - code_returns = RETURNVALUE_FPSTACK; - } - else - { - if (rvType) *rvType = RETURNVALUE_FPSTACK; - } - } - } - - if (code_returns == RETURNVALUE_FPSTACK) - { - if (supportedReturnValues & (RETURNVALUE_BOOL|RETURNVALUE_BOOL_REVERSED)) - { - int stubsize; - void *stub; - - if (supportedReturnValues & RETURNVALUE_BOOL_REVERSED) - { - if (rvType) *rvType = RETURNVALUE_BOOL_REVERSED; - stub = GLUE_realAddress(nseel_asm_fptobool_rev,&stubsize); - } - else - { - if (rvType) *rvType = RETURNVALUE_BOOL; - stub = GLUE_realAddress(nseel_asm_fptobool,&stubsize); - } - - - if (!stub || bufOut_len < stubsize) RET_MINUS1_FAIL(stub?"fptobool size":"fptobool addr") - if (bufOut) - { - memcpy(bufOut,stub,stubsize); - bufOut += stubsize; - } - codesz+=stubsize; - bufOut_len -= stubsize; - } - else if (supportedReturnValues & RETURNVALUE_NORMAL) - { - if (computTableSize) (*computTableSize) ++; - - if (bufOut_len < GLUE_POP_FPSTACK_TO_WTP_TO_PX_SIZE) RET_MINUS1_FAIL("popfpstacktowtptopxsize") - - // generate fp-pop to temp space - if (bufOut) GLUE_POP_FPSTACK_TO_WTP_TO_PX(bufOut,0); - codesz+=GLUE_POP_FPSTACK_TO_WTP_TO_PX_SIZE; - if (rvType) *rvType = RETURNVALUE_NORMAL; - } - else - { - // toss return value that will be ignored - if (bufOut_len < GLUE_POP_FPSTACK_SIZE) RET_MINUS1_FAIL("popfpstack size") - if (bufOut) memcpy(bufOut,GLUE_POP_FPSTACK,GLUE_POP_FPSTACK_SIZE); - codesz+=GLUE_POP_FPSTACK_SIZE; - } - } - - return codesz; -} - - -#if 0 -static void movestringover(char *str, int amount) -{ - char tmp[1024+8]; - - int l=(int)strlen(str); - l=wdl_min(1024-amount-1,l); - - memcpy(tmp,str,l+1); - - while (l >= 0 && tmp[l]!='\n') l--; - l++; - - tmp[l]=0;//ensure we null terminate - - memcpy(str+amount,tmp,l+1); -} -#endif - -//------------------------------------------------------------------------------ -NSEEL_CODEHANDLE NSEEL_code_compile(NSEEL_VMCTX _ctx, const char *_expression, int lineoffs) -{ - return NSEEL_code_compile_ex(_ctx,_expression,lineoffs,0); -} - -typedef struct topLevelCodeSegmentRec { - struct topLevelCodeSegmentRec *_next; - void *code; - int codesz; - int tmptable_use; -} topLevelCodeSegmentRec; - - -NSEEL_CODEHANDLE NSEEL_code_compile_ex(NSEEL_VMCTX _ctx, const char *_expression, int lineoffs, int compile_flags) -{ - compileContext *ctx = (compileContext *)_ctx; - const char *endptr; - const char *_expression_end; - codeHandleType *handle; - topLevelCodeSegmentRec *startpts_tail=NULL; - topLevelCodeSegmentRec *startpts=NULL; - _codeHandleFunctionRec *oldCommonFunctionList; - int curtabptr_sz=0; - void *curtabptr=NULL; - int had_err=0; - - if (!ctx) return 0; - - ctx->directValueCache=0; - ctx->optimizeDisableFlags=0; - ctx->gotEndOfInput=0; - ctx->current_compile_flags = compile_flags; - - if (compile_flags & NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS_RESET) - { - ctx->functions_common=NULL; // reset common function list - } - else - { - // reset common compiled function code, forcing a recompile if shared - _codeHandleFunctionRec *a = ctx->functions_common; - while (a) - { - _codeHandleFunctionRec *b = a->derivedCopies; - - if (a->localstorage) - { - // force local storage actual values to be reallocated if used again - memset(a->localstorage,0,sizeof(EEL_F *) * a->localstorage_size); - } - - a->startptr = NULL; // force this copy to be recompiled - a->startptr_size = -1; - - while (b) - { - b->startptr = NULL; // force derived copies to get recompiled - b->startptr_size = -1; - // no need to reset b->localstorage, since it points to a->localstorage - b=b->derivedCopies; - } - - a=a->next; - } - } - - ctx->last_error_string[0]=0; - - if (!_expression || !*_expression) return 0; - - _expression_end = _expression + strlen(_expression); - - oldCommonFunctionList = ctx->functions_common; - - ctx->isGeneratingCommonFunction=0; - ctx->isSharedFunctions = !!(compile_flags & NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS); - ctx->functions_local = NULL; - - freeBlocks(&ctx->tmpblocks,0); - freeBlocks(&ctx->blocks_head_code,1); - freeBlocks(&ctx->blocks_head_data,0); - memset(ctx->l_stats,0,sizeof(ctx->l_stats)); - - handle = (codeHandleType*)newDataBlock(sizeof(codeHandleType),8); - - if (!handle) - { - return 0; - } - - - memset(handle,0,sizeof(codeHandleType)); - - ctx->l_stats[0] += (int)(_expression_end - _expression); - ctx->tmpCodeHandle = handle; - endptr=_expression; - - while (*endptr) - { - int computTableTop = 0; - int startptr_size=0; - void *startptr=NULL; - opcodeRec *start_opcode=NULL; - const char *expr=endptr; - - int function_numparms=0; - char is_fname[NSEEL_MAX_VARIABLE_NAMELEN+1]; - is_fname[0]=0; - - memset(ctx->function_localTable_Size,0,sizeof(ctx->function_localTable_Size)); - memset(ctx->function_localTable_Names,0,sizeof(ctx->function_localTable_Names)); - ctx->function_localTable_ValuePtrs=0; - ctx->function_usesNamespaces=0; - ctx->function_curName=NULL; - ctx->function_globalFlag=0; - - ctx->errVar=0; - - // single out top level segment - { - int had_something = 0, pcnt=0, pcnt2=0; - int state=0; - for (;;) - { - int l; - const char *p=nseel_simple_tokenizer(&endptr,_expression_end,&l,&state); - if (!p) - { - if (pcnt || pcnt2) ctx->gotEndOfInput|=4; - break; - } - - if (*p == ';') - { - if (had_something && !pcnt && !pcnt2) break; - } - else if (*p == '/' && l > 1 && (p[1] == '/' || p[1] == '*')) - { - if (l > 19 && !strnicmp(p,"//#eel-no-optimize:",19)) - ctx->optimizeDisableFlags = atoi(p+19); - } - else - { - if (!had_something) - { - expr = p; - had_something = 1; - } - - if (*p == '(') pcnt++; - else if (*p == ')') { if (--pcnt<0) pcnt=0; } - else if (*p == '[') pcnt2++; - else if (*p == ']') { if (--pcnt2<0) pcnt2=0; } - } - } - if (!*expr || !had_something) break; - } - - // parse - - { - int tmplen,funcname_len; - const char *p = expr; - const char *tok1 = nseel_simple_tokenizer(&p,endptr,&tmplen,NULL); - const char *funcname = nseel_simple_tokenizer(&p,endptr,&funcname_len,NULL); - if (tok1 && funcname && tmplen == 8 && !strnicmp(tok1,"function",8) && (isalpha((unsigned char)funcname[0]) || funcname[0] == '_')) - { - int had_parms_locals=0; - if (funcname_len > sizeof(is_fname)-1) funcname_len=sizeof(is_fname)-1; - memcpy(is_fname, funcname, funcname_len); - is_fname[funcname_len]=0; - ctx->function_curName = is_fname; // only assigned for the duration of the loop, cleared later //-V507 - - while (NULL != (tok1 = nseel_simple_tokenizer(&p,endptr,&tmplen,NULL))) - { - int is_parms = 0, localTableContext = 0; - int maxcnt=0; - const char *sp_save; - - if (tok1[0] == '(') - { - if (had_parms_locals) - { - expr = p-1; // begin compilation at this code! - break; - } - is_parms = 1; - } - else - { - if (tmplen == 5 && !strnicmp(tok1,"local",tmplen)) localTableContext=0; - else if (tmplen == 6 && !strnicmp(tok1,"static",tmplen)) localTableContext=0; - else if (tmplen == 8 && !strnicmp(tok1,"instance",tmplen)) localTableContext=1; - else if ((tmplen == 7 && !strnicmp(tok1,"globals",tmplen)) || - (tmplen == 6 && !strnicmp(tok1,"global",tmplen))) - { - ctx->function_globalFlag = 1; - localTableContext=2; - } - else break; // unknown token! - - tok1 = nseel_simple_tokenizer(&p,endptr,&tmplen,NULL); - if (!tok1 || tok1[0] != '(') break; - } - had_parms_locals = 1; - - - sp_save=p; - - while (NULL != (tok1 = nseel_simple_tokenizer(&p,endptr,&tmplen,NULL))) - { - if (tok1[0] == ')') break; - if (*tok1 == '#' && localTableContext!=1 && localTableContext!=2) - { - ctx->errVar = (int) (tok1 - _expression); - lstrcpyn_safe(ctx->last_error_string,"#string can only be in instance() or globals()",sizeof(ctx->last_error_string)); - goto had_error; - } - - if (isalpha((unsigned char)*tok1) || *tok1 == '_' || *tok1 == '#') - { - maxcnt++; - if (p < endptr && *p == '*') - { - if (!is_parms && localTableContext!=2) - { - ctx->errVar = (int) (p - _expression); - lstrcpyn_safe(ctx->last_error_string,"namespace* can only be used in parameters or globals()",sizeof(ctx->last_error_string)); - goto had_error; - } - p++; - } - } - else if (*tok1 != ',') - { - ctx->errVar = (int)(tok1 - _expression); - lstrcpyn_safe(ctx->last_error_string,"unknown character in function parameters",sizeof(ctx->last_error_string)); - goto had_error; - } - } - - if (tok1 && maxcnt > 0) - { - char **ot = ctx->function_localTable_Names[localTableContext]; - const int osz = ctx->function_localTable_Size[localTableContext]; - - maxcnt += osz; - - ctx->function_localTable_Names[localTableContext] = (char **)newTmpBlock(ctx,sizeof(char *) * maxcnt); - - if (ctx->function_localTable_Names[localTableContext]) - { - int i=osz; - if (osz && ot) memcpy(ctx->function_localTable_Names[localTableContext],ot,sizeof(char *) * osz); - p=sp_save; - - while (NULL != (tok1 = nseel_simple_tokenizer(&p,endptr,&tmplen,NULL))) - { - if (tok1[0] == ')') break; - if (isalpha((unsigned char)*tok1) || *tok1 == '_' || *tok1 == '#') - { - char *newstr; - int l = tmplen; - if (*p == '*') // xyz* for namespace - { - p++; - l++; - } - if (l > NSEEL_MAX_VARIABLE_NAMELEN) l = NSEEL_MAX_VARIABLE_NAMELEN; - newstr = newTmpBlock(ctx,l+1); - if (newstr) - { - memcpy(newstr,tok1,l); - newstr[l]=0; - ctx->function_localTable_Names[localTableContext][i++] = newstr; - } - } - } - ctx->function_localTable_Size[localTableContext]=i; - if (is_parms) function_numparms = i; - } - } - } - } - } - if (ctx->function_localTable_Size[0]>0) - { - ctx->function_localTable_ValuePtrs = - ctx->isSharedFunctions ? newDataBlock(ctx->function_localTable_Size[0] * sizeof(EEL_F *),8) : - newTmpBlock(ctx,ctx->function_localTable_Size[0] * sizeof(EEL_F *)); - if (!ctx->function_localTable_ValuePtrs) - { - ctx->function_localTable_Size[0]=0; - function_numparms=0; - } - else - { - memset(ctx->function_localTable_ValuePtrs,0,sizeof(EEL_F *) * ctx->function_localTable_Size[0]); // force values to be allocated - } - } - - { - int nseelparse(compileContext* context); - void nseelrestart (void *input_file ,void *yyscanner ); - - ctx->rdbuf_start = _expression; - -#ifdef NSEEL_SUPER_MINIMAL_LEXER - - ctx->rdbuf = expr; - ctx->rdbuf_end = endptr; - if (!nseelparse(ctx) && !ctx->errVar) - { - start_opcode = ctx->result; - } -#else - - nseelrestart(NULL,ctx->scanner); - - ctx->rdbuf = expr; - ctx->rdbuf_end = endptr; - - if (!nseelparse(ctx) && !ctx->errVar) - { - start_opcode = ctx->result; - } - if (ctx->errVar) - { - const char *p=expr; - ctx->errVar += expr-_expression; - } -#endif - ctx->rdbuf = NULL; - } - - if (start_opcode) - { - int rvMode=0, fUse=0; - -#ifdef LOG_OPT - int sd=0; - wdl_log("pre opt sz=%d (tsackDepth=%d)\n",compileOpcodes(ctx,start_opcode,NULL,1024*1024*256,NULL, NULL,RETURNVALUE_IGNORE,NULL,&sd,NULL),sd); -#endif - -#ifdef EEL_DUMP_OPS - // dump opcode trees for verification, before optimizing - if (g_eel_dump_fp) - { - fprintf(g_eel_dump_fp,"-- opcode chunk --\r\n"); - dumpOpcodeTree(ctx,g_eel_dump_fp,start_opcode,2); - } -#endif - - if (!(ctx->optimizeDisableFlags&OPTFLAG_NO_OPTIMIZE)) optimizeOpcodes(ctx,start_opcode,is_fname[0] ? 1 : 0); -#ifdef LOG_OPT - wdl_log("post opt sz=%d, stack depth=%d\n",compileOpcodes(ctx,start_opcode,NULL,1024*1024*256,NULL,NULL, RETURNVALUE_IGNORE,NULL,&sd,NULL),sd); -#endif - -#ifdef EEL_DUMP_OPS - // dump opcode trees for verification, after optimizing - if (g_eel_dump_fp2) - { - fprintf(g_eel_dump_fp2,"-- POST-OPTIMIZED opcode chunk --\r\n"); - dumpOpcodeTree(ctx,g_eel_dump_fp2,start_opcode,2); - } -#endif - - if (is_fname[0]) - { - _codeHandleFunctionRec *fr = ctx->isSharedFunctions ? newDataBlock(sizeof(_codeHandleFunctionRec),8) : - newTmpBlock(ctx,sizeof(_codeHandleFunctionRec)); - if (fr) - { - memset(fr,0,sizeof(_codeHandleFunctionRec)); - fr->startptr_size = -1; - fr->opcodes = start_opcode; - - if (ctx->function_localTable_Size[0] > 0 && ctx->function_localTable_ValuePtrs) - { - if (ctx->function_localTable_Names[0]) - { - int i; - for(i=0;ifunction_localTable_Names[0][i]; - if (nptr && *nptr && nptr[strlen(nptr)-1] == '*') - { - fr->parameterAsNamespaceMask |= ((unsigned int)1)<num_params=function_numparms; - fr->localstorage = ctx->function_localTable_ValuePtrs; - fr->localstorage_size = ctx->function_localTable_Size[0]; - } - - fr->usesNamespaces = ctx->function_usesNamespaces; - fr->isCommonFunction = ctx->isSharedFunctions; - - lstrcpyn_safe(fr->fname,is_fname,sizeof(fr->fname)); - - if (ctx->isSharedFunctions) - { - fr->next = ctx->functions_common; - ctx->functions_common = fr; - } - else - { - fr->next = ctx->functions_local; - ctx->functions_local = fr; - } - } - continue; - } - -#ifdef DUMP_OPS_DURING_COMPILE - g_debugfp_indent=0; - g_debugfp_histsz=0; - g_debugfp = fopen("C:/temp/foo.txt","w"); -#endif - startptr_size = compileOpcodes(ctx,start_opcode,NULL,1024*1024*256,NULL, NULL, - is_fname[0] ? (RETURNVALUE_NORMAL|RETURNVALUE_FPSTACK) : RETURNVALUE_IGNORE, &rvMode, &fUse, NULL); // if not a function, force return value as address (avoid having to pop it ourselves - // if a function, allow the code to decide how return values are generated - -#ifdef DUMP_OPS_DURING_COMPILE - if (g_debugfp) fclose(g_debugfp); - g_debugfp=0; -#endif - - - if (!startptr_size) continue; // optimized away - if (startptr_size>0) - { - startptr = newTmpBlock(ctx,startptr_size); - if (startptr) - { - startptr_size=compileOpcodes(ctx,start_opcode,(unsigned char*)startptr,startptr_size,&computTableTop, NULL, RETURNVALUE_IGNORE, NULL,NULL, NULL); - if (startptr_size<=0) startptr = NULL; - - } - } - } - - if (!startptr) - { -had_error: -#ifdef NSEEL_EEL1_COMPAT_MODE - continue; - -#else - //if (!ctx->last_error_string[0]) - { - int byteoffs = ctx->errVar; - int linenumber; - char cur_err[sizeof(ctx->last_error_string)]; - lstrcpyn_safe(cur_err,ctx->last_error_string,sizeof(cur_err)); - if (cur_err[0]) lstrcatn(cur_err,": ",sizeof(cur_err)); - else lstrcpyn_safe(cur_err,"syntax error: ",sizeof(cur_err)); - - if (_expression + byteoffs >= _expression_end) - { - if (ctx->gotEndOfInput&4) byteoffs = (int)(expr-_expression); - else byteoffs=(int)(_expression_end-_expression); - } - - if (byteoffs < 0) byteoffs=0; - - linenumber=findLineNumber(_expression,byteoffs)+1; - - if (ctx->gotEndOfInput&4) - { - snprintf(ctx->last_error_string,sizeof(ctx->last_error_string),"%d: %.200smissing ) or ]",linenumber+lineoffs,cur_err); - } - else - { - const char *p = _expression + byteoffs; - int x=1, right_amt_nospace=0, left_amt_nospace=0; - while (x < 32 && p-x >= _expression && p[-x] != '\r' && p[-x] != '\n') - { - if (!isspace((unsigned char)p[-x])) left_amt_nospace=x; - x++; - } - x=0; - while (x < 60 && p[x] && p[x] != '\r' && p[x] != '\n') - { - if (!isspace((unsigned char)p[x])) right_amt_nospace=x+1; - x++; - } - - // display left_amt >>>> right_amt_nospace - snprintf(ctx->last_error_string,sizeof(ctx->last_error_string),"%d: %.200s'%.*s %.*s'",linenumber+lineoffs,cur_err, - left_amt_nospace, p-left_amt_nospace, - right_amt_nospace ? right_amt_nospace : 5,right_amt_nospace ? p : ""); - } - } - - startpts=NULL; - startpts_tail=NULL; - had_err=1; - break; -#endif - } - - if (!is_fname[0]) // redundant check (if is_fname[0] is set and we succeeded, it should continue) - // but we'll be on the safe side - { - topLevelCodeSegmentRec *p = newTmpBlock(ctx,sizeof(topLevelCodeSegmentRec)); - p->_next=0; - p->code = startptr; - p->codesz = startptr_size; - p->tmptable_use = computTableTop; - - if (!startpts_tail) startpts_tail=startpts=p; - else - { - startpts_tail->_next=p; - startpts_tail=p; - } - - if (curtabptr_sz < computTableTop) - { - curtabptr_sz=computTableTop; - } - } - } - - memset(ctx->function_localTable_Size,0,sizeof(ctx->function_localTable_Size)); - memset(ctx->function_localTable_Names,0,sizeof(ctx->function_localTable_Names)); - ctx->function_localTable_ValuePtrs=0; - ctx->function_usesNamespaces=0; - ctx->function_curName=NULL; - ctx->function_globalFlag=0; - - ctx->tmpCodeHandle = NULL; - - if (handle->want_stack) - { - if (!handle->stack) startpts=NULL; - } - - if (startpts) - { - curtabptr_sz += 2; // many functions use the worktable for temporary storage of up to 2 EEL_F's - - handle->workTable_size = curtabptr_sz; - handle->workTable = curtabptr = newDataBlock((curtabptr_sz+MIN_COMPUTABLE_SIZE + COMPUTABLE_EXTRA_SPACE) * sizeof(EEL_F),32); - -#ifdef EEL_VALIDATE_WORKTABLE_USE - if (curtabptr) memset(curtabptr,0x3a,(curtabptr_sz+MIN_COMPUTABLE_SIZE + COMPUTABLE_EXTRA_SPACE) * sizeof(EEL_F)); -#endif - if (!curtabptr) startpts=NULL; - } - - - if (startpts || (!had_err && (compile_flags & NSEEL_CODE_COMPILE_FLAG_COMMONFUNCS))) - { - unsigned char *writeptr; - topLevelCodeSegmentRec *p=startpts; - int size=sizeof(GLUE_RET)+GLUE_FUNC_ENTER_SIZE+GLUE_FUNC_LEAVE_SIZE; // for ret at end :) - int wtpos=0; - - // now we build one big code segment out of our list of them, inserting a mov esi, computable before each item as necessary - while (p) - { - if (wtpos <= 0) - { - wtpos=MIN_COMPUTABLE_SIZE; - size += GLUE_RESET_WTP(NULL,0); - } - size+=p->codesz; - wtpos -= p->tmptable_use; - p=p->_next; - } - handle->code = newCodeBlock(size,32); - if (handle->code) - { - writeptr=(unsigned char *)handle->code; - #if GLUE_FUNC_ENTER_SIZE > 0 - memcpy(writeptr,&GLUE_FUNC_ENTER,GLUE_FUNC_ENTER_SIZE); - writeptr += GLUE_FUNC_ENTER_SIZE; - #endif - p=startpts; - wtpos=0; - while (p) - { - if (wtpos <= 0) - { - wtpos=MIN_COMPUTABLE_SIZE; - writeptr+=GLUE_RESET_WTP(writeptr,curtabptr); - } - memcpy(writeptr,(char*)p->code,p->codesz); - writeptr += p->codesz; - wtpos -= p->tmptable_use; - - p=p->_next; - } - #if GLUE_FUNC_LEAVE_SIZE > 0 - memcpy(writeptr,&GLUE_FUNC_LEAVE,GLUE_FUNC_LEAVE_SIZE); - writeptr += GLUE_FUNC_LEAVE_SIZE; - #endif - memcpy(writeptr,&GLUE_RET,sizeof(GLUE_RET)); writeptr += sizeof(GLUE_RET); - ctx->l_stats[1]=size; - handle->code_size = (int) (writeptr - (unsigned char *)handle->code); -#if defined(__arm__) || defined(__aarch64__) - __clear_cache(handle->code,writeptr); -#endif - } - - handle->blocks_code = ctx->blocks_head_code; -#ifndef EEL_DOESNT_NEED_EXEC_PERMS - eel_set_blocks_allow_execute(handle->blocks_code,1); -#endif - handle->blocks_data = ctx->blocks_head_data; - ctx->blocks_head_code=0; - ctx->blocks_head_data=0; - } - else - { - // failed compiling, or failed calloc() - handle=NULL; - } - - - ctx->directValueCache=0; - ctx->functions_local = NULL; - - ctx->isGeneratingCommonFunction=0; - ctx->isSharedFunctions=0; - - freeBlocks(&ctx->tmpblocks,0); - freeBlocks(&ctx->blocks_head_code,1); - freeBlocks(&ctx->blocks_head_data,0); - - if (handle) - { - handle->compile_flags = compile_flags; - handle->ramPtr = ctx->ram_state->blocks; - memcpy(handle->code_stats,ctx->l_stats,sizeof(ctx->l_stats)); - nseel_evallib_stats[0]+=ctx->l_stats[0]; - nseel_evallib_stats[1]+=ctx->l_stats[1]; - nseel_evallib_stats[2]+=ctx->l_stats[2]; - nseel_evallib_stats[3]+=ctx->l_stats[3]; - nseel_evallib_stats[4]++; - } - else - { - ctx->functions_common = oldCommonFunctionList; // failed compiling, remove any added common functions from the list - - // remove any derived copies of functions due to error, since we may have added some that have been freed - while (oldCommonFunctionList) - { - oldCommonFunctionList->derivedCopies=NULL; - oldCommonFunctionList=oldCommonFunctionList->next; - } - } - memset(ctx->l_stats,0,sizeof(ctx->l_stats)); - - return (NSEEL_CODEHANDLE)handle; -} - -//------------------------------------------------------------------------------ -void NSEEL_code_execute(NSEEL_CODEHANDLE code) -{ -#ifndef GLUE_TABPTR_IGNORED - INT_PTR tabptr; -#endif - INT_PTR codeptr; - codeHandleType *h = (codeHandleType *)code; - if (!h || !h->code) return; - - codeptr = (INT_PTR) h->code; -#if 0 - { - unsigned int *p=(unsigned int *)codeptr; - while (*p != GLUE_RET[0]) - { - printf("instr:%04X:%04X\n",*p>>16,*p&0xffff); - p++; - } - } -#endif - -#ifndef GLUE_TABPTR_IGNORED - tabptr=(INT_PTR)h->workTable; -#endif - //printf("calling code!\n"); - GLUE_CALL_CODE(tabptr,codeptr,(INT_PTR)h->ramPtr); - -} - -int NSEEL_code_geterror_flag(NSEEL_VMCTX ctx) -{ - compileContext *c=(compileContext *)ctx; - if (c) return (c->gotEndOfInput ? 1 : 0); - return 0; -} - -char *NSEEL_code_getcodeerror(NSEEL_VMCTX ctx) -{ - compileContext *c=(compileContext *)ctx; - if (ctx && c->last_error_string[0]) return c->last_error_string; - return 0; -} - -//------------------------------------------------------------------------------ -void NSEEL_code_free(NSEEL_CODEHANDLE code) -{ - codeHandleType *h = (codeHandleType *)code; - if (h != NULL) - { -#ifdef EEL_VALIDATE_WORKTABLE_USE - if (h->workTable) - { - char *p = ((char*)h->workTable) + h->workTable_size*sizeof(EEL_F); - int x; - for(x=COMPUTABLE_EXTRA_SPACE*sizeof(EEL_F) - 1;x >= 0; x --) - if (p[x] != 0x3a) - { - wdl_log("worktable overrun at byte %d (wts=%d), value = %f\n",x,h->workTable_size, *(EEL_F*)(p+(x&~(sizeof(EEL_F)-1)))); - break; - } - } -#endif - - nseel_evallib_stats[0]-=h->code_stats[0]; - nseel_evallib_stats[1]-=h->code_stats[1]; - nseel_evallib_stats[2]-=h->code_stats[2]; - nseel_evallib_stats[3]-=h->code_stats[3]; - nseel_evallib_stats[4]--; - - freeBlocks(&h->blocks_code,1); - freeBlocks(&h->blocks_data,0); - } - -} - -//------------------------------------------------------------------------------ - -NSEEL_VMCTX NSEEL_VM_alloc() // return a handle -{ - compileContext *ctx=calloc(1,sizeof(compileContext)); - - #ifdef NSEEL_SUPER_MINIMAL_LEXER - if (ctx) ctx->scanner = ctx; - #else - if (ctx) - { - int nseellex_init(void ** ptr_yy_globals); - void nseelset_extra(void *user_defined , void *yyscanner); - if (nseellex_init(&ctx->scanner)) - { - free(ctx); - return NULL; - } - nseelset_extra(ctx,ctx->scanner); - } - #endif - - if (ctx) - { - ctx->ram_state = __newBlock_align(&ctx->ctx_pblocks,sizeof(*ctx->ram_state),16,0); - memset(ctx->ram_state,0,sizeof(*ctx->ram_state)); - ctx->ram_state->sign_mask[0] = ctx->ram_state->sign_mask[1] = WDL_UINT64_CONST(0x8000000000000000); - ctx->ram_state->abs_mask[0] = ctx->ram_state->abs_mask[1] = WDL_UINT64_CONST(0x7FFFFFFFFFFFFFFF); - ctx->ram_state->maxblocks = NSEEL_RAM_BLOCKS_DEFAULTMAX; - ctx->ram_state->closefact = NSEEL_CLOSEFACTOR; - } - return ctx; -} - -int NSEEL_VM_setramsize(NSEEL_VMCTX _ctx, int maxent) -{ - compileContext *ctx = (compileContext *)_ctx; - if (!ctx) return 0; - if (maxent > 0) - { - maxent = (maxent + NSEEL_RAM_ITEMSPERBLOCK - 1)/NSEEL_RAM_ITEMSPERBLOCK; - if (maxent > NSEEL_RAM_BLOCKS) maxent = NSEEL_RAM_BLOCKS; - ctx->ram_state->maxblocks = maxent; - } - - return ctx->ram_state->maxblocks * NSEEL_RAM_ITEMSPERBLOCK; -} - -void NSEEL_VM_preallocram(NSEEL_VMCTX _ctx, int maxent) -{ - compileContext *ctx = (compileContext *)_ctx; - int x; - if (!ctx || !maxent) return; - - if (maxent < 0) - { - maxent = ctx->ram_state->maxblocks; - } - else - { - maxent = (maxent + NSEEL_RAM_ITEMSPERBLOCK - 1)/NSEEL_RAM_ITEMSPERBLOCK; - if (maxent > ctx->ram_state->maxblocks) maxent = ctx->ram_state->maxblocks; - } - for (x = 0; x < maxent; x ++) - __NSEEL_RAMAlloc(ctx->ram_state->blocks,x * NSEEL_RAM_ITEMSPERBLOCK); -} - -void NSEEL_VM_SetFunctionValidator(NSEEL_VMCTX _ctx, const char * (*validateFunc)(const char *fn_name, void *user), void *user) -{ - if (_ctx) - { - compileContext *ctx = (compileContext *)_ctx; - ctx->func_check = validateFunc; - ctx->func_check_user = user; - } -} - -void NSEEL_VM_SetFunctionTable(NSEEL_VMCTX _ctx, eel_function_table *tab) -{ - if (_ctx) - { - compileContext *ctx = (compileContext *)_ctx; - ctx->registered_func_tab = tab; - } -} -void NSEEL_VM_free(NSEEL_VMCTX _ctx) // free when done with a VM and ALL of its code have been freed, as well -{ - - if (_ctx) - { - compileContext *ctx=(compileContext *)_ctx; - EEL_GROWBUF_RESIZE(&ctx->varNameList,-1); - NSEEL_VM_freeRAM(_ctx); - - freeBlocks(&ctx->ctx_pblocks,0); - - // these should be 0 normally but just in case - freeBlocks(&ctx->tmpblocks,0); - freeBlocks(&ctx->blocks_head_code,1); - freeBlocks(&ctx->blocks_head_data,0); - - - #ifndef NSEEL_SUPER_MINIMAL_LEXER - if (ctx->scanner) - { - int nseellex_destroy(void *yyscanner); - nseellex_destroy(ctx->scanner); - } - #endif - ctx->scanner=0; - if (ctx->has_used_global_vars) - { - nseel_globalVarItem *p = NULL; - NSEEL_HOSTSTUB_EnterMutex(); - if (--nseel_vms_referencing_globallist_cnt == 0) - { - // clear and free globals - p = nseel_globalreg_list; - nseel_globalreg_list=0; - } - NSEEL_HOSTSTUB_LeaveMutex(); - - while (p) - { - nseel_globalVarItem *op = p; - p=p->_next; - free(op); - } - } - free(ctx); - } - -} - -int *NSEEL_code_getstats(NSEEL_CODEHANDLE code) -{ - codeHandleType *h = (codeHandleType *)code; - if (h) - { - return h->code_stats; - } - return 0; -} - -void NSEEL_VM_SetStringFunc(NSEEL_VMCTX ctx, - EEL_F (*onString)(void *caller_this, struct eelStringSegmentRec *list), - EEL_F (*onNamedString)(void *caller_this, const char *name)) -{ - if (ctx) - { - compileContext *c=(compileContext*)ctx; - c->onString = onString; - c->onNamedString = onNamedString; - } -} - -void NSEEL_VM_SetCustomFuncThis(NSEEL_VMCTX ctx, void *thisptr) -{ - if (ctx) - { - compileContext *c=(compileContext*)ctx; - c->caller_this=thisptr; - } -} - - - - - -void *NSEEL_PProc_RAM(void *data, int data_size, compileContext *ctx) -{ - if (data_size>0) data=EEL_GLUE_set_immediate(data, (INT_PTR)ctx->ram_state->blocks); - return data; -} - -void *NSEEL_PProc_THIS(void *data, int data_size, compileContext *ctx) -{ - if (data_size>0) data=EEL_GLUE_set_immediate(data, (INT_PTR)ctx->caller_this); - return data; -} - -static int vartable_lowerbound(compileContext *ctx, const char *name, int *ismatch) -{ - int a = 0, c = EEL_GROWBUF_GET_SIZE(&ctx->varNameList); - varNameRec **list = EEL_GROWBUF_GET(&ctx->varNameList); - while (a != c) - { - const int b = (a+c)/2; - const int cmp = strnicmp(name,list[b]->str,NSEEL_MAX_VARIABLE_NAMELEN); - if (cmp > 0) a = b+1; - else if (cmp < 0) c = b; - else - { - *ismatch = 1; - return b; - } - } - *ismatch = 0; - return a; -} - -static void vartable_cull_list(compileContext *ctx, int refcnt_chk) -{ - const int ni = EEL_GROWBUF_GET_SIZE(&ctx->varNameList); - int i = ni, ndel = 0; - varNameRec **rd = EEL_GROWBUF_GET(&ctx->varNameList), **wr=rd; - while (i--) - { - varNameRec *v = rd[0]; - if ((!refcnt_chk || !v->refcnt) && !v->isreg) - { - ndel++; - } - else - { - if (wr != rd) *wr = *rd; - wr++; - } - rd++; - } - if (ndel) EEL_GROWBUF_RESIZE(&ctx->varNameList,ni - ndel); -} - -void NSEEL_VM_remove_unused_vars(NSEEL_VMCTX _ctx) -{ - compileContext *ctx = (compileContext *)_ctx; - if (ctx) vartable_cull_list(ctx,1); -} - -void NSEEL_VM_remove_all_nonreg_vars(NSEEL_VMCTX _ctx) -{ - compileContext *ctx = (compileContext *)_ctx; - if (ctx) vartable_cull_list(ctx,0); -} - -void NSEEL_VM_clear_var_refcnts(NSEEL_VMCTX _ctx) -{ - compileContext *ctx = (compileContext *)_ctx; - if (ctx) - { - int i = EEL_GROWBUF_GET_SIZE(&ctx->varNameList); - varNameRec **rd = EEL_GROWBUF_GET(&ctx->varNameList); - while (i--) - { - rd[0]->refcnt=0; - rd++; - } - } -} - - -#ifdef NSEEL_EEL1_COMPAT_MODE -static EEL_F __nseel_global_regs[100]; -double *NSEEL_getglobalregs() { return __nseel_global_regs; } -#endif - -EEL_F *get_global_var(compileContext *ctx, const char *gv, int addIfNotPresent) -{ - nseel_globalVarItem *p; -#ifdef NSEEL_EEL1_COMPAT_MODE - if (!strnicmp(gv,"reg",3) && gv[3]>='0' && gv[3] <= '9' && gv[4] >= '0' && gv[4] <= '9' && !gv[5]) - { - return __nseel_global_regs + atoi(gv+3); - } -#endif - - NSEEL_HOSTSTUB_EnterMutex(); - if (!ctx->has_used_global_vars) - { - ctx->has_used_global_vars++; - nseel_vms_referencing_globallist_cnt++; - } - - p = nseel_globalreg_list; - while (p) - { - if (!stricmp(p->name,gv)) break; - p=p->_next; - } - - if (!p && addIfNotPresent) - { - size_t gvl = strlen(gv); - p = (nseel_globalVarItem*)malloc(sizeof(nseel_globalVarItem) + gvl); - if (p) - { - p->data=0.0; - strcpy(p->name,gv); - p->_next = nseel_globalreg_list; - nseel_globalreg_list=p; - } - } - NSEEL_HOSTSTUB_LeaveMutex(); - return p ? &p->data : NULL; -} - - - -EEL_F *nseel_int_register_var(compileContext *ctx, const char *name, int isReg, const char **namePtrOut) -{ - int slot, match; - - if (isReg == 0 && ctx->getVariable) - { - EEL_F *ret = ctx->getVariable(ctx->getVariable_userctx, name); - if (ret) return ret; - } - - if (!strnicmp(name,"_global.",8) && name[8]) - { - EEL_F *a=get_global_var(ctx,name+8,isReg >= 0); - if (a) return a; - } - - slot = vartable_lowerbound(ctx,name, &match); - if (match) - { - varNameRec *v = EEL_GROWBUF_GET(&ctx->varNameList)[slot]; - if (isReg >= 0) - { - v->refcnt++; - if (isReg) v->isreg=isReg; - if (namePtrOut) *namePtrOut = v->str; - } - return v->value; - } - if (isReg < 0) return NULL; - - if (ctx->varValueStore_left<1) - { - const int sz=500; - ctx->varValueStore_left = sz; - ctx->varValueStore = (EEL_F *)newCtxDataBlock((int)sizeof(EEL_F)*sz,8); - } - if (ctx->varValueStore) - { - int listsz = EEL_GROWBUF_GET_SIZE(&ctx->varNameList); - size_t l = strlen(name); - varNameRec *vh; - if (l > NSEEL_MAX_VARIABLE_NAMELEN) l = NSEEL_MAX_VARIABLE_NAMELEN; - vh = (varNameRec*) newCtxDataBlock( (int) (sizeof(varNameRec) + l),8); - if (!vh || EEL_GROWBUF_RESIZE(&ctx->varNameList, (listsz+1))) return NULL; // alloc fail - - (vh->value = ctx->varValueStore++)[0]=0.0; - ctx->varValueStore_left--; - - vh->refcnt=1; - vh->isreg=isReg; - memcpy(vh->str,name,l); - vh->str[l] = 0; - if (namePtrOut) *namePtrOut = vh->str; - - if (slot < listsz) - { - memmove(EEL_GROWBUF_GET(&ctx->varNameList) + slot+1, - EEL_GROWBUF_GET(&ctx->varNameList) + slot, (listsz - slot) * sizeof(EEL_GROWBUF_GET(&ctx->varNameList)[0])); - } - EEL_GROWBUF_GET(&ctx->varNameList)[slot] = vh; - - return vh->value; - } - return NULL; -} - - -//------------------------------------------------------------------------------ - -void NSEEL_VM_enumallvars(NSEEL_VMCTX ctx, int (*func)(const char *name, EEL_F *val, void *ctx), void *userctx) -{ - compileContext *tctx = (compileContext *) ctx; - int ni; - varNameRec **rd; - if (!tctx) return; - - ni = EEL_GROWBUF_GET_SIZE(&tctx->varNameList); - rd = EEL_GROWBUF_GET(&tctx->varNameList); - while (ni--) - { - if (!func(rd[0]->str,rd[0]->value,userctx)) break; - rd++; - } -} - - -//------------------------------------------------------------------------------ -EEL_F *NSEEL_VM_regvar(NSEEL_VMCTX _ctx, const char *var) -{ - compileContext *ctx = (compileContext *)_ctx; - if (!ctx) return 0; - - if (!strnicmp(var,"reg",3) && strlen(var) == 5 && isdigit(var[3]) && isdigit(var[4])) - { - EEL_F *a=get_global_var(ctx,var,1); - if (a) return a; - } - - return nseel_int_register_var(ctx,var,1,NULL); -} - -EEL_F *NSEEL_VM_getvar(NSEEL_VMCTX _ctx, const char *var) -{ - compileContext *ctx = (compileContext *)_ctx; - if (!ctx) return 0; - - if (!strnicmp(var,"reg",3) && strlen(var) == 5 && isdigit(var[3]) && isdigit(var[4])) - { - EEL_F *a=get_global_var(ctx,var,0); - if (a) return a; - } - - return nseel_int_register_var(ctx,var,-1,NULL); -} - -int NSEEL_VM_get_var_refcnt(NSEEL_VMCTX _ctx, const char *name) -{ - compileContext *ctx = (compileContext *)_ctx; - int slot,match; - if (!ctx) return -1; - slot = vartable_lowerbound(ctx,name, &match); - return match ? EEL_GROWBUF_GET(&ctx->varNameList)[slot]->refcnt : -1; -} - - - - -opcodeRec *nseel_createFunctionByName(compileContext *ctx, const char *name, int np, opcodeRec *code1, opcodeRec *code2, opcodeRec *code3) -{ - int chkamt=0; - functionType *f=nseel_getFunctionByName(ctx,name,&chkamt); - if (f) while (chkamt-->=0) - { - if ((f->nParams&FUNCTIONTYPE_PARAMETERCOUNTMASK) == np) - { - opcodeRec *o=newOpCode(ctx,NULL, np==3?OPCODETYPE_FUNC3:np==2?OPCODETYPE_FUNC2:OPCODETYPE_FUNC1); - if (o) - { - o->fntype = FUNCTYPE_FUNCTIONTYPEREC; - o->fn = f; - o->parms.parms[0]=code1; - o->parms.parms[1]=code2; - o->parms.parms[2]=code3; - } - return o; - } - f++; - if (stricmp(f->name,name)) break; - } - return NULL; -} - - - - -//------------------------------------------------------------------------------ -opcodeRec *nseel_translate(compileContext *ctx, const char *tmp, size_t tmplen) // tmplen 0 = null term -{ - // this depends on the string being nul terminated eventually, tmplen is used more as a hint than anything else - if ((tmp[0] == '0' || tmp[0] == '$') && toupper(tmp[1])=='X') - { - char *p; - return nseel_createCompiledValue(ctx,(EEL_F)strtoul(tmp+2,&p,16)); - } - else if (tmp[0] == '$') - { - if (tmp[1] == '~') - { - char *p=(char*)tmp+2; - unsigned int v=(unsigned int) strtoul(tmp+2,&p,10); - if (v>53) v=53; - return nseel_createCompiledValue(ctx,(EEL_F)((((WDL_INT64)1) << v) - 1)); - } - else if (!tmplen ? !stricmp(tmp,"$E") : (tmplen == 2 && !strnicmp(tmp,"$E",2))) - return nseel_createCompiledValue(ctx,(EEL_F)2.718281828459045); - else if (!tmplen ? !stricmp(tmp, "$PI") : (tmplen == 3 && !strnicmp(tmp, "$PI", 3))) - return nseel_createCompiledValue(ctx,(EEL_F)3.141592653589793); - else if (!tmplen ? !stricmp(tmp, "$PHI") : (tmplen == 4 && !strnicmp(tmp, "$PHI", 4))) - return nseel_createCompiledValue(ctx,(EEL_F)1.6180339887498948); - else if ((!tmplen || tmplen == 4) && tmp[1] == '\'' && tmp[2] && tmp[3] == '\'') - return nseel_createCompiledValue(ctx,(EEL_F)tmp[2]); - else return NULL; - } - else if (tmp[0] == '\'') - { - char b[64]; - int x,sz; - unsigned int rv=0; - - if (!tmplen) // nul terminated tmplen, calculate a workable length - { - // faster than strlen(tmp) if tmp is large, we'll never need more than ~18 chars anyway - while (tmplen < 32 && tmp[tmplen]) tmplen++; - } - - sz = tmplen > 0 ? nseel_filter_escaped_string(b,sizeof(b),tmp+1, tmplen - 1, '\'') : 0; - - if (sz > 4) - { - if (ctx->last_error_string[0]) lstrcatn(ctx->last_error_string, ", ", sizeof(ctx->last_error_string)); - snprintf_append(ctx->last_error_string,sizeof(ctx->last_error_string),"multi-byte character '%.5s...' too long",b); - return NULL; // do not allow 'xyzxy', limit to 4 bytes - } - - for (x=0;x sizeof(buf)-1) tmplen = sizeof(buf)-1; - memcpy(buf,tmp,tmplen); - buf[tmplen]=0; - if (ctx->onNamedString) - { - if (tmplen>0 && buf[1]&&ctx->function_curName) - { - int err=0; - opcodeRec *r = nseel_resolve_named_symbol(ctx,nseel_createCompiledValuePtr(ctx,NULL,buf),-1, &err); - if (r) - { - if (r->opcodeType!=OPCODETYPE_VALUE_FROM_NAMESPACENAME) - { - r->opcodeType = OPCODETYPE_DIRECTVALUE; - r->parms.dv.directValue = ctx->onNamedString(ctx->caller_this,buf+1); - r->parms.dv.valuePtr=NULL; - } - return r; - } - if (err) return NULL; - } - - // if not namespaced symbol, return directly - if (!buf[1]) - { - opcodeRec *r=newOpCode(ctx,NULL,OPCODETYPE_DIRECTVALUE_TEMPSTRING); - if (r) r->parms.dv.directValue = -10000.0; - return r; - } - return nseel_createCompiledValue(ctx,ctx->onNamedString(ctx->caller_this,buf+1)); - } - } - return nseel_createCompiledValue(ctx,(EEL_F)atof(tmp)); -} - -void NSEEL_VM_set_var_resolver(NSEEL_VMCTX _ctx, EEL_F *(*res)(void *userctx, const char *name), void *userctx) -{ - compileContext *ctx = (compileContext *)_ctx; - if (ctx) - { - ctx->getVariable = res; - ctx->getVariable_userctx = userctx; - } -} - - -#if defined(__ppc__) || defined(EEL_TARGET_PORTABLE) - // blank stubs - void eel_enterfp(int s[2]) {} - void eel_leavefp(int s[2]) {} -#endif diff --git a/oversampling/WDL/eel2/nseel-eval.c b/oversampling/WDL/eel2/nseel-eval.c deleted file mode 100644 index f92028b..0000000 --- a/oversampling/WDL/eel2/nseel-eval.c +++ /dev/null @@ -1,469 +0,0 @@ -/* - Expression Evaluator Library (NS-EEL) v2 - Copyright (C) 2004-2013 Cockos Incorporated - Copyright (C) 1999-2003 Nullsoft, Inc. - - nseel-eval.c - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include -#include -#include "ns-eel-int.h" -#include "../wdlcstring.h" - - -static const char *nseel_skip_space_and_comments(const char *p, const char *endptr) -{ - for (;;) - { - while (p < endptr && isspace((unsigned char)p[0])) p++; - if (p >= endptr-1 || *p != '/') return p; - - if (p[1]=='/') - { - while (p < endptr && *p != '\r' && *p != '\n') p++; - } - else if (p[1] == '*') - { - p+=2; - while (p < endptr-1 && (p[0] != '*' || p[1] != '/')) p++; - p+=2; - if (p>=endptr) return endptr; - } - else return p; - } -} - -// removes any escaped characters, also will convert pairs delim_char into single delim_chars -int nseel_filter_escaped_string(char *outbuf, int outbuf_sz, const char *rdptr, size_t rdptr_size, char delim_char) -{ - int outpos = 0; - const char *rdptr_end = rdptr + rdptr_size; - while (rdptr < rdptr_end && outpos < outbuf_sz-1) - { - char thisc=*rdptr; - if (thisc == '\\' && rdptr < rdptr_end-1) - { - const char nc = rdptr[1]; - if (nc == 'r' || nc == 'R') { thisc = '\r'; } - else if (nc == 'n' || nc == 'N') { thisc = '\n'; } - else if (nc == 't' || nc == 'T') { thisc = '\t'; } - else if (nc == 'b' || nc == 'B') { thisc = '\b'; } - else if ((nc >= '0' && nc <= '9') || nc == 'x' || nc == 'X') - { - unsigned char c=0; - char base_shift = 3; - char num_top = '7'; - - rdptr++; // skip backslash - if (nc > '9') // implies xX - { - base_shift = 4; - num_top = '9'; - rdptr ++; // skip x - } - - while (rdptr < rdptr_end) - { - char tc=*rdptr; - if (tc >= '0' && tc <= num_top) - { - c = (c<= 'a' && tc <= 'f') - { - c = (c<= 'A' && tc <= 'F') - { - c = (c<str_len; - } - else if (list->str_len > 1) - { - if (pos >= bufout_sz) break; - pos += nseel_filter_escaped_string(bufOut + pos, bufout_sz-pos, list->str_start+1, list->str_len-1, list->str_start[0]); - } - list = list->_next; - } - return pos; -} - - - -// state can be NULL, it will be set if finished with unterminated thing: 1 for multiline comment, ' or " for string -const char *nseel_simple_tokenizer(const char **ptr, const char *endptr, int *lenOut, int *state) -{ - const char *p = *ptr; - const char *rv = p; - char delim; - - if (state) // if state set, returns comments as tokens - { - if (*state == 1) goto in_comment; - - #ifndef NSEEL_EEL1_COMPAT_MODE - if (*state == '\'' || *state == '\"') - { - delim = (char)*state; - goto in_string; - } - #endif - - // skip any whitespace - while (p < endptr && isspace((unsigned char)p[0])) p++; - } - else - { - // state not passed, skip comments (do not return them as tokens) - p = nseel_skip_space_and_comments(p,endptr); - } - - if (p >= endptr) - { - *ptr = endptr; - *lenOut = 0; - return NULL; - } - - rv=p; - - if (*p == '$' && p+3 < endptr && p[1] == '\'' && p[3] == '\'') - { - p+=4; - } - else if (state && *p == '/' && p < endptr-1 && (p[1] == '/' || p[1] == '*')) - { - if (p[1] == '/') - { - while (p < endptr && *p != '\r' && *p != '\n') p++; // advance to end of line - } - else - { - if (state) *state=1; - p+=2; -in_comment: - while (p < endptr) - { - const char c = *p++; - if (c == '*' && p < endptr && *p == '/') - { - p++; - if (state) *state=0; - break; - } - } - - } - } - else if (isalnum((unsigned char)*p) || *p == '_' || *p == '#' || *p == '$' || (*p == '.' && p < endptr-1 && p[1] >= '0' && p[1] <= '9')) - { - if (*p == '$' && p < endptr-1 && p[1] == '~') p++; - p++; - while (p < endptr && (isalnum((unsigned char)*p) || *p == '_' || *p == '.')) p++; - } -#ifndef NSEEL_EEL1_COMPAT_MODE - else if (*p == '\'' || *p == '\"') - { - delim = *p++; - if (state) *state=delim; -in_string: - - while (p < endptr) - { - const char c = *p++; - if (p < endptr && c == '\\') p++; // skip escaped characters - else if (c == delim) - { - if (state) *state=0; - break; - } - } - } -#endif - else - { - p++; - } - *ptr = p; - *lenOut = (int) (p - rv); - return p>rv ? rv : NULL; -} - - - -#ifdef NSEEL_SUPER_MINIMAL_LEXER - - int nseellex(opcodeRec **output, YYLTYPE * yylloc_param, compileContext *scctx) - { - int rv=0,toklen=0; - const char *rdptr = scctx->rdbuf; - const char *endptr = scctx->rdbuf_end; - const char *tok = nseel_simple_tokenizer(&rdptr,endptr,&toklen,NULL); - *output = 0; - if (tok) - { - rv = tok[0]; - if ((rv == '0' || rv == '$') && toklen > 1 && (tok[1] == 'x' || tok[1] == 'X')) // 0xf00 or $xf00 - { - int x; - for (x = 2; x < toklen; x ++) - if (!((tok[x] >= '0' && tok[x] <= '9') || - (tok[x] >= 'a' && tok[x] <= 'f') || - (tok[x] >= 'A' && tok[x] <= 'F'))) - { - tok += x; - break; - } - - *output = x == toklen && toklen > 2 ? nseel_translate(scctx,tok,toklen) : NULL; - if (*output) rv=VALUE; - } -#ifndef NSEEL_EEL1_COMPAT_MODE - else if (rv == '#' && scctx->onNamedString) - { - *output = nseel_translate(scctx,tok,toklen); - if (*output) rv=STRING_IDENTIFIER; - } - else if (rv == '\'') - { - if (toklen > 1 && tok[toklen-1] == '\'') - { - *output = nseel_translate(scctx, tok, toklen); - if (*output) rv = VALUE; - } - else scctx->gotEndOfInput|=8; - } - else if (rv == '\"' && scctx->onString) - { - if (toklen > 1 && tok[toklen-1] == '\"') - { - *output = (opcodeRec *)nseel_createStringSegmentRec(scctx,tok,toklen); - if (*output) rv = STRING_LITERAL; - } - else scctx->gotEndOfInput|=16; - } -#endif - else if (isalpha((unsigned char)rv) || rv == '_') - { - char buf[NSEEL_MAX_VARIABLE_NAMELEN*2]; - if (toklen > sizeof(buf) - 1) toklen=sizeof(buf) - 1; - memcpy(buf,tok,toklen); - buf[toklen]=0; - *output = nseel_createCompiledValuePtr(scctx, NULL, buf); - if (*output) rv = IDENTIFIER; - } - else if ((rv >= '0' && rv <= '9') || (rv == '.' && toklen > 1 && tok[1] >= '0' && tok[1] <= '9')) // 123.45 or .45 - { - int x, pcnt = 0; - for (x = 0; x < toklen; x ++) - { - if (tok[x] == '.' ? (++pcnt > 1) : (tok[x] < '0' || tok[x] > '9')) - { - tok += x; - break; - } - } - *output = x == toklen ? nseel_translate(scctx,tok,toklen) : NULL; - if (*output) rv=VALUE; - } - else if (rv == '$' && toklen > 1) - { - if (tok[1] == '~') - { - int x; - for (x = 2; x < toklen; x ++) - if (tok[x] < '0' || tok[x] > '9') - { - tok += x; - break; - } - - if (x 1 ? nseel_translate(scctx,tok,toklen) : NULL; - if (*output) rv=VALUE; - } - else if (rv == '<') - { - const char nc=*rdptr; - if (nc == '<') - { - rdptr++; - rv=TOKEN_SHL; - } - else if (nc == '=') - { - rdptr++; - rv=TOKEN_LTE; - } - } - else if (rv == '>') - { - const char nc=*rdptr; - if (nc == '>') - { - rdptr++; - rv=TOKEN_SHR; - } - else if (nc == '=') - { - rdptr++; - rv=TOKEN_GTE; - } - } - else if (rv == '&' && *rdptr == '&') - { - rdptr++; - rv = TOKEN_LOGICAL_AND; - } - else if (rv == '|' && *rdptr == '|') - { - rdptr++; - rv = TOKEN_LOGICAL_OR; - } - else if (*rdptr == '=') - { - switch (rv) - { - case '+': rv=TOKEN_ADD_OP; rdptr++; break; - case '-': rv=TOKEN_SUB_OP; rdptr++; break; - case '%': rv=TOKEN_MOD_OP; rdptr++; break; - case '|': rv=TOKEN_OR_OP; rdptr++; break; - case '&': rv=TOKEN_AND_OP; rdptr++; break; - case '~': rv=TOKEN_XOR_OP; rdptr++; break; - case '/': rv=TOKEN_DIV_OP; rdptr++; break; - case '*': rv=TOKEN_MUL_OP; rdptr++; break; - case '^': rv=TOKEN_POW_OP; rdptr++; break; - case '!': - rdptr++; - if (rdptr < endptr && *rdptr == '=') - { - rdptr++; - rv=TOKEN_NE_EXACT; - } - else - rv=TOKEN_NE; - break; - case '=': - rdptr++; - if (rdptr < endptr && *rdptr == '=') - { - rdptr++; - rv=TOKEN_EQ_EXACT; - } - else - rv=TOKEN_EQ; - break; - } - } - } - - scctx->rdbuf = rdptr; - yylloc_param->first_column = (int)(tok - scctx->rdbuf_start); - return rv; - } - - - void nseelerror(YYLTYPE *pos,compileContext *ctx, const char *str) - { - ctx->errVar=pos->first_column>0?pos->first_column:(int)(ctx->rdbuf_end - ctx->rdbuf_start); - } - - -#else - - int nseel_gets(compileContext *ctx, char *buf, size_t sz) - { - int n=0; - const char *endptr = ctx->rdbuf_end; - const char *rdptr = ctx->rdbuf; - if (!rdptr) return 0; - - while (n < sz && rdptr < endptr) buf[n++] = *rdptr++; - ctx->rdbuf=rdptr; - return n; - - } - - - //#define EEL_TRACE_LEX - - #ifdef EEL_TRACE_LEX - #define nseellex nseellex2 - - #endif - #include "lex.nseel.c" - - #ifdef EEL_TRACE_LEX - - #undef nseellex - - int nseellex(YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner) - { - int a=nseellex2(yylval_param,yylloc_param,yyscanner); - - wdl_log("tok: %c (%d)\n",a,a); - return a; - } - #endif//EEL_TRACE_LEX - - - void nseelerror(YYLTYPE *pos,compileContext *ctx, const char *str) - { - ctx->errVar=pos->first_column>0?pos->first_column:(int)(ctx->rdbuf_end - ctx->rdbuf_start); - } -#endif // !NSEEL_SUPER_MINIMAL_LEXER diff --git a/oversampling/WDL/eel2/nseel-lextab.c b/oversampling/WDL/eel2/nseel-lextab.c deleted file mode 100644 index 6138b65..0000000 --- a/oversampling/WDL/eel2/nseel-lextab.c +++ /dev/null @@ -1 +0,0 @@ -// no longer used \ No newline at end of file diff --git a/oversampling/WDL/eel2/nseel-ram.c b/oversampling/WDL/eel2/nseel-ram.c deleted file mode 100644 index ccc8580..0000000 --- a/oversampling/WDL/eel2/nseel-ram.c +++ /dev/null @@ -1,580 +0,0 @@ -/* - Expression Evaluator Library (NS-EEL) v2 - Copyright (C) 2004-2013 Cockos Incorporated - Copyright (C) 1999-2003 Nullsoft, Inc. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "ns-eel.h" -#include "ns-eel-int.h" -#include -#include -#include -#include - - -#ifdef _WIN32 -#include -#ifdef _MSC_VER -#define inline __inline -#endif - -#endif - -unsigned int NSEEL_RAM_limitmem=0; -unsigned int NSEEL_RAM_memused=0; -int NSEEL_RAM_memused_errors=0; - - - -int NSEEL_VM_wantfreeRAM(NSEEL_VMCTX ctx) -{ - if (ctx) - { - compileContext *c=(compileContext*)ctx; - if (c->ram_state->needfree) - return 1; - } - return 0; -} - -void NSEEL_VM_freeRAMIfCodeRequested(NSEEL_VMCTX ctx) // check to see if our free flag was set -{ - if (ctx) - { - compileContext *c=(compileContext*)ctx; - if (c->ram_state->needfree) - { - NSEEL_HOSTSTUB_EnterMutex(); - { - INT_PTR startpos=((INT_PTR)c->ram_state->needfree)-1; - EEL_F **blocks = c->ram_state->blocks; - INT_PTR pos=0; - int x; - for (x = 0; x < NSEEL_RAM_BLOCKS; x ++) - { - if (pos >= startpos) - { - if (blocks[x]) - { - if (NSEEL_RAM_memused >= sizeof(EEL_F) * NSEEL_RAM_ITEMSPERBLOCK) - NSEEL_RAM_memused -= sizeof(EEL_F) * NSEEL_RAM_ITEMSPERBLOCK; - else NSEEL_RAM_memused_errors++; - free(blocks[x]); - blocks[x]=0; - } - } - pos+=NSEEL_RAM_ITEMSPERBLOCK; - } - c->ram_state->needfree=0; - } - NSEEL_HOSTSTUB_LeaveMutex(); - } - - } -} - -EEL_F nseel_ramalloc_onfail; -EEL_F * volatile nseel_gmembuf_default; - - -void *(*nseel_gmem_calloc)(size_t a, size_t b); - -EEL_F * NSEEL_CGEN_CALL __NSEEL_RAMAllocGMEM(EEL_F ***blocks, unsigned int w) -{ - if (blocks) - { - EEL_F **pblocks=*blocks; - - if (w < NSEEL_RAM_BLOCKS*NSEEL_RAM_ITEMSPERBLOCK) - { - const unsigned int whichblock = w/NSEEL_RAM_ITEMSPERBLOCK; - EEL_F *p=NULL; - if (!pblocks || !(p=pblocks[whichblock])) - { - NSEEL_HOSTSTUB_EnterMutex(); - if (!nseel_gmem_calloc) nseel_gmem_calloc=calloc; - - if (!(pblocks=*blocks)) pblocks = *blocks = (EEL_F **)nseel_gmem_calloc(sizeof(EEL_F *),NSEEL_RAM_BLOCKS); - else p = pblocks[whichblock]; - - if (!p && pblocks) - { - p=pblocks[whichblock]=(EEL_F *)nseel_gmem_calloc(sizeof(EEL_F),NSEEL_RAM_ITEMSPERBLOCK); - } - NSEEL_HOSTSTUB_LeaveMutex(); - } - if (p) return p + (w&(NSEEL_RAM_ITEMSPERBLOCK-1)); - } - return &nseel_ramalloc_onfail; - } - - if (!nseel_gmembuf_default) - { - NSEEL_HOSTSTUB_EnterMutex(); - if (!nseel_gmembuf_default) nseel_gmembuf_default=(EEL_F*)calloc(sizeof(EEL_F),NSEEL_SHARED_GRAM_SIZE); - NSEEL_HOSTSTUB_LeaveMutex(); - if (!nseel_gmembuf_default) return &nseel_ramalloc_onfail; - } - - return nseel_gmembuf_default+(((unsigned int)w)&((NSEEL_SHARED_GRAM_SIZE)-1)); -} - - -EEL_F * NSEEL_CGEN_CALL __NSEEL_RAMAlloc(EEL_F **pblocks, unsigned int w) -{ -// fprintf(stderr,"got request at %d, %d\n",w/NSEEL_RAM_ITEMSPERBLOCK, w&(NSEEL_RAM_ITEMSPERBLOCK-1)); - if (w < NSEEL_RAM_BLOCKS*NSEEL_RAM_ITEMSPERBLOCK) - { - unsigned int whichblock = w/NSEEL_RAM_ITEMSPERBLOCK; - EEL_F *p=pblocks[whichblock]; - if (!p && whichblock < ((unsigned int *)pblocks)[-3]) // pblocks -1/-2 are closefact, -3 is maxblocks - { - NSEEL_HOSTSTUB_EnterMutex(); - - if (!(p=pblocks[whichblock])) - { - - const int msize=sizeof(EEL_F) * NSEEL_RAM_ITEMSPERBLOCK; - if (!NSEEL_RAM_limitmem || NSEEL_RAM_memused+msize < NSEEL_RAM_limitmem) - { - p=pblocks[whichblock]=(EEL_F *)calloc(sizeof(EEL_F),NSEEL_RAM_ITEMSPERBLOCK); - if (p) NSEEL_RAM_memused+=msize; - } - } - NSEEL_HOSTSTUB_LeaveMutex(); - } - if (p) return p + (w&(NSEEL_RAM_ITEMSPERBLOCK-1)); - } -// fprintf(stderr,"ret 0\n"); - return &nseel_ramalloc_onfail; -} - - -EEL_F * NSEEL_CGEN_CALL __NSEEL_RAM_MemFree(void *blocks, EEL_F *which) -{ - // blocks points to ram_state->blocks, so back it up past closefact and maxblocks to needfree - int *flag = (int *)((char *)blocks - sizeof(double) - 2*sizeof(int)); - int d=(int)(*which); - if (d < 0) d=0; - if (d < flag[1]*NSEEL_RAM_ITEMSPERBLOCK) flag[0]=1+d; - return which; -} - -EEL_F * NSEEL_CGEN_CALL __NSEEL_RAM_MemTop(void *blocks, EEL_F *which) -{ - // blocks points to ram_state->blocks, so back it up past closefact to maxblocks - const int *flag = (int *)((char *)blocks - sizeof(double) - sizeof(int)); - *which = flag[0]*NSEEL_RAM_ITEMSPERBLOCK; - return which; -} - - -EEL_F NSEEL_CGEN_CALL __NSEEL_RAM_MemInsertShuffle(EEL_F **blocks,EEL_F *buf, EEL_F *lenptr, EEL_F *value) -{ - int src_offs = (int)*buf; - int len = (int)*lenptr; - int copy_len; - - EEL_F ret = *value; - - unsigned int sbidx = (unsigned int)src_offs / NSEEL_RAM_ITEMSPERBLOCK; - - if (len < 1 || src_offs < 0) return 0.0; - - src_offs = src_offs&(NSEEL_RAM_ITEMSPERBLOCK-1); - copy_len = wdl_min(len,NSEEL_RAM_ITEMSPERBLOCK - src_offs); - - for (;;) - { - EEL_F *srcptr; - if (sbidx >= NSEEL_RAM_BLOCKS) break; - - srcptr = blocks[sbidx]; - - if (WDL_unlikely(!srcptr)) - { - srcptr = __NSEEL_RAMAlloc(blocks,sbidx * NSEEL_RAM_ITEMSPERBLOCK); - if (srcptr==&nseel_ramalloc_onfail) break; - } - - len-=copy_len; - srcptr += src_offs; - while (copy_len-- > 0) - { - EEL_F v = *srcptr; - *srcptr++ = ret; - ret = v; - } - if (!len) break; - - sbidx++; - src_offs=0; - copy_len = wdl_min(len,NSEEL_RAM_ITEMSPERBLOCK); - } - return ret; -} - -EEL_F NSEEL_CGEN_CALL __NSEEL_RAM_MemSumProducts(EEL_F **blocks,EEL_F *dest, EEL_F *src, EEL_F *lenptr) -{ - int src_offs = (int)*src; - int len = (int)*lenptr; - - EEL_F sum = 0.0; - - if (len < 1 || src_offs < 0) return 0.0; - - if (*dest < 0.0) - { - int copy_len; - unsigned int sbidx = (unsigned int)src_offs / NSEEL_RAM_ITEMSPERBLOCK; - src_offs = src_offs&(NSEEL_RAM_ITEMSPERBLOCK-1); - copy_len = wdl_min(len,NSEEL_RAM_ITEMSPERBLOCK - src_offs); - for (;;) - { - const EEL_F *srcptr; - if (sbidx >= NSEEL_RAM_BLOCKS) break; - - srcptr = blocks[sbidx]; - - if (WDL_likely(srcptr)) - { - int i; - srcptr += src_offs; - if (*dest == -1.0) - for (i = 0; i < copy_len; i ++) sum += srcptr[i] * srcptr[i]; - else if (*dest == -2.0) - for (i = 0; i < copy_len; i ++) sum += fabs(srcptr[i]); - else - for (i = 0; i < copy_len; i ++) sum += srcptr[i]; - } - len-=copy_len; - if (!len) break; - - sbidx++; - src_offs=0; - copy_len = wdl_min(len,NSEEL_RAM_ITEMSPERBLOCK); - } - } - else - { - unsigned int dest_offs = (unsigned int) (int)*dest; - for (;;) - { - unsigned int sbidx = (unsigned int)src_offs / NSEEL_RAM_ITEMSPERBLOCK; - const int sbo = (src_offs&(NSEEL_RAM_ITEMSPERBLOCK-1)); - unsigned int dbidx = dest_offs / NSEEL_RAM_ITEMSPERBLOCK; - const int dbo = (dest_offs&(NSEEL_RAM_ITEMSPERBLOCK-1)); - - const int copy_len = wdl_min(len,NSEEL_RAM_ITEMSPERBLOCK - wdl_max(dbo,sbo)); - - const EEL_F *srcptr, *destptr; - - if (sbidx >= NSEEL_RAM_BLOCKS || dbidx >= NSEEL_RAM_BLOCKS) break; - srcptr = blocks[sbidx]; - destptr = blocks[dbidx]; - if (WDL_likely(srcptr && destptr)) - { - int i; - srcptr += sbo; - destptr += dbo; - for (i = 0; i < copy_len; i ++) sum += destptr[i] * srcptr[i]; - } - len-=copy_len; - if (!len) break; - - src_offs += copy_len; - dest_offs += copy_len; - } - } - return sum; -} - - -EEL_F * NSEEL_CGEN_CALL __NSEEL_RAM_MemCpy(EEL_F **blocks,EEL_F *dest, EEL_F *src, EEL_F *lenptr) -{ - const int mem_size=NSEEL_RAM_BLOCKS*NSEEL_RAM_ITEMSPERBLOCK; - int dest_offs = (int)(*dest + 0.0001); - int src_offs = (int)(*src + 0.0001); - int len = (int)(*lenptr + 0.0001); - int want_mmove=0; - - // trim to front - if (src_offs<0) - { - len += src_offs; - dest_offs -= src_offs; - src_offs=0; - } - if (dest_offs<0) - { - len += dest_offs; - src_offs -= dest_offs; - dest_offs=0; - } - if (src_offs + len > mem_size) len = mem_size-src_offs; - if (dest_offs + len > mem_size) len = mem_size-dest_offs; - - if (src_offs == dest_offs || len < 1) return dest; - - if (src_offs < dest_offs && src_offs+len > dest_offs) - { - // if src_offs < dest_offs and overlapping, must copy right to left - if ((dest_offs - src_offs) < NSEEL_RAM_ITEMSPERBLOCK) want_mmove = 1; - src_offs += len; - dest_offs += len; - while (len > 0) - { - const int maxdlen=((dest_offs-1)&(NSEEL_RAM_ITEMSPERBLOCK-1)) + 1; - const int maxslen=((src_offs-1)&(NSEEL_RAM_ITEMSPERBLOCK-1)) + 1; - int copy_len = len; - EEL_F *srcptr,*destptr; - - if (copy_len > maxdlen) copy_len=maxdlen; - if (copy_len > maxslen) copy_len=maxslen; - - srcptr = __NSEEL_RAMAlloc(blocks,src_offs - copy_len); - destptr = __NSEEL_RAMAlloc(blocks,dest_offs - copy_len); - if (srcptr==&nseel_ramalloc_onfail || destptr==&nseel_ramalloc_onfail) break; - - if (want_mmove) memmove(destptr,srcptr,sizeof(EEL_F)*copy_len); - else memcpy(destptr,srcptr,sizeof(EEL_F)*copy_len); - src_offs-=copy_len; - dest_offs-=copy_len; - len-=copy_len; - } - return dest; - } - - if (dest_offs < src_offs && dest_offs+len > src_offs) - { - // if dest_offs < src_offs and overlapping, and less than NSEEL_RAM_ITEMSPERBLOCK apart, use memmove() - if ((src_offs-dest_offs) < NSEEL_RAM_ITEMSPERBLOCK) want_mmove = 1; - } - - while (len > 0) - { - const int maxdlen=NSEEL_RAM_ITEMSPERBLOCK - (dest_offs&(NSEEL_RAM_ITEMSPERBLOCK-1)); - const int maxslen=NSEEL_RAM_ITEMSPERBLOCK - (src_offs&(NSEEL_RAM_ITEMSPERBLOCK-1)); - int copy_len = len; - EEL_F *srcptr,*destptr; - - if (copy_len > maxdlen) copy_len=maxdlen; - if (copy_len > maxslen) copy_len=maxslen; - - srcptr = __NSEEL_RAMAlloc(blocks,src_offs); - destptr = __NSEEL_RAMAlloc(blocks,dest_offs); - if (srcptr==&nseel_ramalloc_onfail || destptr==&nseel_ramalloc_onfail) break; - - if (want_mmove) memmove(destptr,srcptr,sizeof(EEL_F)*copy_len); - else memcpy(destptr,srcptr,sizeof(EEL_F)*copy_len); - src_offs+=copy_len; - dest_offs+=copy_len; - len-=copy_len; - } - return dest; -} - -EEL_F * NSEEL_CGEN_CALL __NSEEL_RAM_MemSet(EEL_F **blocks,EEL_F *dest, EEL_F *v, EEL_F *lenptr) -{ - int offs = (int)(*dest + 0.0001); - int len = (int)(*lenptr + 0.0001); - EEL_F t; - if (offs<0) - { - len += offs; - offs=0; - } - if (offs >= NSEEL_RAM_BLOCKS*NSEEL_RAM_ITEMSPERBLOCK) return dest; - - if (offs+len > NSEEL_RAM_BLOCKS*NSEEL_RAM_ITEMSPERBLOCK) len = NSEEL_RAM_BLOCKS*NSEEL_RAM_ITEMSPERBLOCK - offs; - - if (len < 1) return dest; - - - t=*v; // set value - -// int lastBlock=-1; - while (len > 0) - { - int lcnt; - EEL_F *ptr=__NSEEL_RAMAlloc(blocks,offs); - if (ptr==&nseel_ramalloc_onfail) break; - - lcnt=NSEEL_RAM_ITEMSPERBLOCK-(offs&(NSEEL_RAM_ITEMSPERBLOCK-1)); - if (lcnt > len) lcnt=len; - - len -= lcnt; - offs += lcnt; - - while (lcnt--) - { - *ptr++=t; - } - } - return dest; -} - - -static inline int __getset_values(EEL_F **blocks, int isset, int len, EEL_F **parms) -{ - int offs, lout=0; - unsigned int pageidx, sub_offs; - if (--len < 1) return 0; - offs = (int)(parms++[0][0] + 0.0001); - - if (offs<=0) - { - len += offs; - parms -= offs; - offs=0; - pageidx=sub_offs=0; - if (len<1) return 0; - } - else - { - sub_offs = ((unsigned int)offs) & (NSEEL_RAM_ITEMSPERBLOCK-1); - pageidx = ((unsigned int)offs)>>NSEEL_RAM_ITEMSPERBLOCK_LOG2; - if (pageidx>=NSEEL_RAM_BLOCKS) return 0; - } - - for (;;) - { - int lcnt=NSEEL_RAM_ITEMSPERBLOCK-sub_offs; - EEL_F *ptr=blocks[pageidx]; - if (!ptr) - { - ptr = __NSEEL_RAMAlloc(blocks,offs + lout); - if (ptr==&nseel_ramalloc_onfail) return lout; - } - else - { - ptr += sub_offs; - } - - if (lcnt >= len) - { - // this page satisfies the request (normal behavior) - lout += len; - if (isset) while (len--) *ptr++=parms++[0][0]; - else while (len--) parms++[0][0] = *ptr++; - return lout; - } - - // crossing a page boundary - len -= lcnt; - lout += lcnt; - if (isset) while (lcnt--) *ptr++=parms++[0][0]; - else while (lcnt--) parms++[0][0] = *ptr++; - - if (len <= 0 || ++pageidx >= NSEEL_RAM_BLOCKS) return lout; - sub_offs=0; - } -} - -EEL_F NSEEL_CGEN_CALL __NSEEL_RAM_Mem_SetValues(EEL_F **blocks, INT_PTR np, EEL_F **parms) -{ - return __getset_values(blocks,1,(int)np,parms); -} - -EEL_F NSEEL_CGEN_CALL __NSEEL_RAM_Mem_GetValues(EEL_F **blocks, INT_PTR np, EEL_F **parms) -{ - return __getset_values(blocks,0,(int)np,parms); -} - -void NSEEL_VM_SetGRAM(NSEEL_VMCTX ctx, void **gram) -{ - if (ctx) - { - compileContext *c=(compileContext*)ctx; - c->gram_blocks = gram; - } -} - - -void NSEEL_VM_freeRAM(NSEEL_VMCTX ctx) -{ - if (ctx) - { - int x; - compileContext *c=(compileContext*)ctx; - EEL_F **blocks = c->ram_state->blocks; - for (x = 0; x < NSEEL_RAM_BLOCKS; x ++) - { - if (blocks[x]) - { - if (NSEEL_RAM_memused >= sizeof(EEL_F) * NSEEL_RAM_ITEMSPERBLOCK) - NSEEL_RAM_memused -= sizeof(EEL_F) * NSEEL_RAM_ITEMSPERBLOCK; - else NSEEL_RAM_memused_errors++; - free(blocks[x]); - blocks[x]=0; - } - } - c->ram_state->needfree=0; // no need to free anymore - } -} - -void NSEEL_VM_FreeGRAM(void **ufd) -{ - if (ufd[0]) - { - EEL_F **blocks = (EEL_F **)ufd[0]; - int x; - for (x = 0; x < NSEEL_RAM_BLOCKS; x ++) - { - if (blocks[x]) - { - if (NSEEL_RAM_memused >= sizeof(EEL_F) * NSEEL_RAM_ITEMSPERBLOCK) - NSEEL_RAM_memused -= sizeof(EEL_F) * NSEEL_RAM_ITEMSPERBLOCK; - else NSEEL_RAM_memused_errors++; - } - free(blocks[x]); - blocks[x]=0; - } - free(blocks); - ufd[0]=0; - } -} - -EEL_F *NSEEL_VM_getramptr(NSEEL_VMCTX ctx, unsigned int offs, int *validCount) -{ - EEL_F *d=__NSEEL_RAMAlloc(ctx ? ((compileContext*)ctx)->ram_state->blocks : 0,offs); - if (!d || d == &nseel_ramalloc_onfail) return NULL; - if (validCount) *validCount = NSEEL_RAM_ITEMSPERBLOCK - (offs%NSEEL_RAM_ITEMSPERBLOCK); - - return d; -} - -EEL_F *NSEEL_VM_getramptr_noalloc(NSEEL_VMCTX ctx, unsigned int offs, int *validCount) -{ - EEL_F *d; - compileContext *cc = (compileContext *)ctx; - - if (!cc || - offs >= NSEEL_RAM_ITEMSPERBLOCK*NSEEL_RAM_BLOCKS || - NULL == (d = cc->ram_state->blocks[offs/NSEEL_RAM_ITEMSPERBLOCK]) - ) - { - if (validCount) *validCount = 0; - return NULL; - } - - offs %= NSEEL_RAM_ITEMSPERBLOCK; - if (validCount) *validCount = NSEEL_RAM_ITEMSPERBLOCK - offs; - return d + offs; -} diff --git a/oversampling/WDL/eel2/nseel-yylex.c b/oversampling/WDL/eel2/nseel-yylex.c deleted file mode 100644 index 84a29de..0000000 --- a/oversampling/WDL/eel2/nseel-yylex.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - Expression Evaluator Library (NS-EEL) - Copyright (C) 2004-2013 Cockos Incorporated - Copyright (C) 1999-2003 Nullsoft, Inc. - - nseel-yylex.c - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "ns-eel-int.h" - - - -# define YYMALLOC malloc -# define YYFREE free - -int nseellex(void * yylval_param,void * yylloc_param ,void *yyscanner); -void nseelerror(void *pos,compileContext *ctx, const char *str); - -// inhibit a warning: -static void WDL_STATICFUNC_UNUSED yydestruct(const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, compileContext* context); - -#include -#include - -#include "y.tab.c" - diff --git a/oversampling/WDL/eel2/regenerate-x64-objects.sh b/oversampling/WDL/eel2/regenerate-x64-objects.sh deleted file mode 100644 index 7d3aa2d..0000000 --- a/oversampling/WDL/eel2/regenerate-x64-objects.sh +++ /dev/null @@ -1,8 +0,0 @@ -# regenerates x86_64 objects -rm -f asm-nseel-x64-macho.o asm-nseel-x64.obj foo.o -nasm -f win64 asm-nseel-x64-sse.asm -o asm-nseel-x64.obj || echo "error assembling win64 object" -nasm -D AMD64ABI -f macho64 --prefix _ asm-nseel-x64-sse.asm -o asm-nseel-x64-macho.o || echo "error assembling macOS x86_64" -echo > foo.c -clang -arch arm64 -c -o foo.o foo.c || echo "error compiling arm64 stub" -lipo foo.o asm-nseel-x64-macho.o -create -output asm-nseel-multi-macho.o || echo "error making asm-nseel-multi-macho.o" -rm -f -- foo.c foo.o diff --git a/oversampling/WDL/eel2/scripts/circle.eel b/oversampling/WDL/eel2/scripts/circle.eel deleted file mode 100644 index 0917bc7..0000000 --- a/oversampling/WDL/eel2/scripts/circle.eel +++ /dev/null @@ -1,50 +0,0 @@ -gfx_init("vis",1024,768); - -zp=-0.84; -fill=0; -radj=1; -while ((c=gfx_getchar())!=27 && c >= 0) -( - c == 'f' ? fill=!fill; - c == 'j' ? jitter=!jitter; - c == 'm' ? radj = !radj; - - gfx_r=gfx_g=gfx_b=1; - gfx_a=1; - gfx_x=gfx_y=0; - gfx_printf("[f]ill=%s, [j]itter=%s, [m]ove=%s [%f] %d,%d",fill?"on":"off",jitter?"on":"off",radj?"on":"off",zp,mouse_x,mouse_y); - gfx_a=0.25; - - - radj ? zp+=0.03; - gfx_getchar('up') ? zp+=0.03; - gfx_getchar('down') ? zp-=0.03; - zp2+=0.1; - rd = (1+sin(zp*1.3))*(gfx_w/8-16) + 3; - jitter ? ( - xoffs=0.5+sin(zp2*6.7)*0.5; - yoffs=0.5+sin(zp2*7.7)*0.5; - rd|=0; - rd += 0.5+sin(zp2*3.1)*0.5 - ) : ( xoffs=yoffs=0; rd|= 0;); - - - gfx_circle(xoffs+(gfx_w/4)|0,yoffs+(gfx_h/2)|0,rd, fill,0); - gfx_circle(xoffs+(gfx_w*3/4)|0,yoffs+(gfx_h/2)|0,rd, fill,1); - - gfx_mode=4+(1<<4); // filtering off, additive - gfx_a=1; - zsz=20; - outsz=gfx_w/4; - gfx_blit(-1,0,0, - gfx_w/4-zsz, gfx_h/2-zsz, zsz*2,zsz*2, - 0,gfx_h-outsz,outsz,outsz); - - gfx_blit(-1,0,0, - gfx_w*3/4-zsz, gfx_h/2-zsz, zsz*2,zsz*2, - gfx_w-outsz,gfx_h-outsz,outsz,outsz); - gfx_mode=0; - - gfx_update(); - sleep(30); -); diff --git a/oversampling/WDL/eel2/scripts/eval_test.eel b/oversampling/WDL/eel2/scripts/eval_test.eel deleted file mode 100644 index 17fba0c..0000000 --- a/oversampling/WDL/eel2/scripts/eval_test.eel +++ /dev/null @@ -1,20 +0,0 @@ -argc < 2 ? ( - printf("Usage: %s [script]\n",argv[0]); - -) : ( - printf("loading '%s'\n",argv[1]); - x = fopen(argv[1],"r"); - !x ? ( - printf("Error opening '%s'\n",argv[1]) - ) : ( - #str=""; - while (fgets(x,#line)) ( #str += #line; ); - fclose(x); - loop(30, - start_t = time_precise(); - eval(#str) || printf("error evaluating script\n"); - start_t = time_precise()-start_t; - printf("finished in %f milliseconds\n",start_t*1000.0); - ); - ); -); diff --git a/oversampling/WDL/eel2/scripts/gfx_test.eel b/oversampling/WDL/eel2/scripts/gfx_test.eel deleted file mode 100644 index 90a55db..0000000 --- a/oversampling/WDL/eel2/scripts/gfx_test.eel +++ /dev/null @@ -1,24 +0,0 @@ -gfx_init("vis",1024,768); - -gfx_clear=-1; -while ((c=gfx_getchar())!=27 && c >= 0) -( - c == ' ' ? (mode += 1) >= 2 ? mode=0; - t=time_precise(); - zsc = 0.01*cos(t*0.73); -// gfx_x=gfx_y=0; gfx_blurto(gfx_w,gfx_h); - gfx_blit(-1,0,0.3*(sin(t*0.3)^2),gfx_w*zsc,gfx_h*zsc, gfx_w*(1-2*zsc),gfx_h*(1-2*zsc), 0,0,gfx_w,gfx_h); - gfx_r=(cos(t)+1.0)*0.5; - gfx_g=(cos(t*1.74)+1.0)*0.5; - gfx_b=(cos(t*1.2+0.56)+1.0)*0.5; - gfx_a=0.15; - sz=gfx_w*0.03; - loop(20, - mode == 1 ? - gfx_circle(rand(gfx_w-sz),rand(gfx_h-sz),sz,1) : - gfx_rect(rand(gfx_w-sz),rand(gfx_h-sz),sz,sz); - ); - - - gfx_update(); -); diff --git a/oversampling/WDL/eel2/scripts/gfx_test_defer.eel b/oversampling/WDL/eel2/scripts/gfx_test_defer.eel deleted file mode 100644 index a5af640..0000000 --- a/oversampling/WDL/eel2/scripts/gfx_test_defer.eel +++ /dev/null @@ -1,29 +0,0 @@ -gfx_init("vis",1024,768); - -gfx_clear=-1; - -function frame() -( - c=gfx_getchar(); - c == ' ' ? (mode += 1) >= 2 ? mode=0; - t=time_precise(); - zsc = 0.01*cos(t*0.73); -// gfx_x=gfx_y=0; gfx_blurto(gfx_w,gfx_h); - gfx_blit(-1,0,0.3*(sin(t*0.3)^2),gfx_w*zsc,gfx_h*zsc, gfx_w*(1-2*zsc),gfx_h*(1-2*zsc), 0,0,gfx_w,gfx_h); - gfx_r=(cos(t)+1.0)*0.5; - gfx_g=(cos(t*1.74)+1.0)*0.5; - gfx_b=(cos(t*1.2+0.56)+1.0)*0.5; - gfx_a=0.15; - sz=gfx_w*0.03; - loop(20, - mode == 1 ? - gfx_circle(rand(gfx_w-sz),rand(gfx_h-sz),sz,1) : - gfx_rect(rand(gfx_w-sz),rand(gfx_h-sz),sz,sz); - ); - - - gfx_update(); - c>=0 && c != 27 ? defer("frame()"); -); - -frame(); diff --git a/oversampling/WDL/eel2/scripts/gpx_edit.eel b/oversampling/WDL/eel2/scripts/gpx_edit.eel deleted file mode 100644 index 8517f5d..0000000 --- a/oversampling/WDL/eel2/scripts/gpx_edit.eel +++ /dev/null @@ -1,208 +0,0 @@ -// does not work for all .gpx files -// writes to output on every mouseup after edit -// move points with mouse, alt+click to delete -// click/drag to pan -// mousewheel to zoom - -tab = 10000; -tabsz = 0; - -is_dirty = 0; -circle_size = 5; - -function scale(v) global() ( (v - this.min) / (this.max-this.min) ); -function unscale(v) global() ( v * (this.max-this.min) + this.min); -function zoom(sc) global() local(c h) ( - h = (this.max - this.min) * sc; - c = (this.max + this.min) * .5; - this.max = c + h*.5; - this.min = c - h*.5; -); -function include(v) global() ( this.min = min(v,this.min); this.max = max(v,this.max); ); - -function scroll(amt) global() ( amt *= (this.max-this.min); this.max += amt; this.min += amt; ); -function zoom_view(sc) ( v_lon.zoom(sc); v_lat.zoom(sc); ); -function scroll_view(dx, dy) ( v_lat.scroll(-dy/gfx_h); v_lon.scroll(-dx/gfx_w); ); - -function hit_test(x,y,p) global(tab tabsz circle_size gfx_w gfx_h v_lat.scale v_lon.scale) local(p hit) ( - hit = -1; - while (p < tabsz && hit < 0) ( - sqr(v_lat.scale(tab[p*2+1])*gfx_h-y)+sqr(v_lon.scale(tab[p*2])*gfx_w-x) < circle_size*circle_size ? hit = p; - p += 1; - ); - hit -); - -function linearize(p,sz, slon, slat, elon, elat, rev) local(x) global() -( - rev ? ( x=slon; slon=elon; elon=x; x=slat; slat=elat; elat=x; ); - elon = (elon - slon) / sz; - elat = (elat - slat) / sz; - loop(sz, - p[0] = slon; - p[1] = slat; - slon += elon; - slat += elat; - p += 2; - ); -); - -function make_lowpass(f filtsize filtpos) global() local(windowpos sincpos x) -( - x = 0; - loop(filtsize, - x == filtsize/2 ? ( - f[x] = 1.0; - ) : ( - windowpos = 2 * x * $pi / filtsize; - sincpos = filtpos * $pi * (x - filtsize/2); - - // blackman-harris * window - f[x] = (0.35875 - 0.48829 * cos(windowpos) + 0.14128 * cos(2*windowpos) - 0.01168 * cos(3*windowpos)) * sin(sincpos) / sincpos; - ); - x+=1; - ); -); - -function lowpass() local(src sz i j lpf_pos v sx sy filt p) global(tab tabsz) -( - lpf_pos>0.001 ? lpf_pos *= 0.95 : lpf_pos = 0.9; - sz = 64; - src = tab+tabsz*2 + sz*4 + 1024; - filt = src + tabsz*2 + sz*4 + 1024; - make_lowpass(filt, sz, lpf_pos); - memcpy(src, tab, tabsz*2); - i = src; - j = src + tabsz*2; - loop(sz/2, - memcpy(i-2,i,2); - memcpy(j,j-2,2); - j+=2; - i-=2; - ); - i = 0; - loop(tabsz, - tab[i*2] != 10000 ? ( - p = j = sx = sy = 0; - loop(sz, - v = src[(i+j-sz/2)*2]; - v != 10000 ? ( - p += filt[j]; - sx += v * filt[j]; - sy += src[(i+j-sz/2)*2 + 1] * filt[j]; - ); - j+=1; - ); - tab[i*2] = sx/p; - tab[i*2+1] = sy/p; - ); - i+=1; - ); - -); - -function do_file(srcfn, destfn) local(fp fpout p lat lon skipping) ( - (fp = fopen(srcfn,"r")) > 0 ? ( - destfn < 0 || (fpout = fopen(destfn,"w")) > 0 ? ( - p = tab; - skipping = 0; - while (fgets(fp,#line)) ( - match("%s%s",#line,#lead,lat,lon,#trail) ? ( - destfn < 0 ? ( tabsz+=1; v_lat.include(p[1] = -lat); v_lon.include(p[0] = lon);) : - ( !(skipping = p[0] == 10000) ? fprintf(fpout,"%s%s",#lead,-p[1],p[0],#trail); ); - p += 2; - ) : destfn >= 0 ? ( skipping ? ( match("**",#line) ? skipping = 0; ) : fwrite(fpout,#line,0) ); - ); - destfn >= 0 ? fclose(fpout); - ); - fclose(fp); - ); -); - - -function run() ( - mouse_wheel ? ( zoom_view(mouse_wheel < 0 ? 1.1 : 1/1.1); mouse_wheel = 0;); - (mouse_cap&1)? ( - !(last_mouse_cap & 1) ? ( - cap_mode >= 0 && (mouse_cap&4) ? ( - tmp = hit_test(mouse_x,mouse_y,0); - tmp >= 0 ? ( - tmp < cap_mode ? ( - cap_cnt = cap_mode+cap_cnt - tmp; - cap_mode = tmp; - ) : ( - cap_cnt = max(cap_mode+cap_cnt, tmp) - cap_mode; - ); - ) : cap_mode = tmp; - ) : ( - cap_mode = hit_test(mouse_x,mouse_y,0); - cap_mode >= 0 ? ( - cap_cnt = 1; - while (hit_test(mouse_x,mouse_y,cap_mode+cap_cnt) >= 0) ( cap_cnt += 1; ); - ); - ); - cap_start_lon = v_lon.unscale(mouse_x/gfx_w); - cap_start_lat = v_lat.unscale(mouse_y/gfx_h); - ) : cap_mode >= 0 ? ( - cap_cnt > 1 && (mouse_cap&4) ? ( - linearize(tab + cap_mode*2,cap_cnt, cap_start_lon, cap_start_lat, - v_lon.unscale(mouse_x/gfx_w), v_lat.unscale(mouse_y/gfx_h), - mouse_cap&8); - ) : ( - tab[cap_mode*2] = v_lon.unscale(mouse_x/gfx_w); - tab[cap_mode*2+1] = v_lat.unscale(mouse_y/gfx_h); - ); - is_dirty = 1; - ) : scroll_view(mouse_x-last_mouse_x,mouse_y-last_mouse_y); - ) : ( - (last_mouse_cap & 1) && (last_mouse_cap & 16) && cap_mode >= 0 ? ( - tab[cap_mode*2] = 10000; - is_dirty = 1; - ); - is_dirty ? ( do_file(argv[1], argv[2]); is_dirty = 0; ); - ); - last_mouse_cap = mouse_cap; - last_mouse_x = mouse_x; - last_mouse_y = mouse_y; - - p = tab; - hadprev = dist = 0; - loop(tabsz, - p[0] != 10000 ? ( - x = v_lon.scale(p[0])*gfx_w; - y = v_lat.scale(p[1])*gfx_h; - hadprev ? ( - gfx_set(0,.5,.7); - gfx_line(v_lon.scale(llon)*gfx_w,v_lat.scale(llat)*gfx_h,x,y); - dist += sqrt(sqr((p[0] - llon) * cos(llat*$pi/180.0)*69.172) + sqr((p[1] - llat)*60)); - ); - cap_mode == (p-tab)/2 ? gfx_set(1,0,1) : gfx_set(0,1,0); - gfx_circle(x,y,circle_size); - llon = p[0]; - llat = p[1]; - hadprev = 1; - ); - p += 2; - ); - - gfx_x=gfx_y=0; - gfx_set(1,1,0); - gfx_printf("distance (approx) %.2f mi\n",dist); - - gfx_update(); - c = gfx_getchar(); - c == 'l' ? ( lowpass(); is_dirty = 1; ); - c >= 0 && c != 27 ? defer("run()"); -); - -argc < 2 ? printf("Usage: %s file.gpx output.gpx\n",argv[0]) : ( - v_lat.min = v_lon.min = 100000; - v_lat.max = v_lon.max = -100000; - do_file(argv[1],-1); - tabsz > 0 ? ( - zoom_view(1.3); - gfx_init("gpx edit",1024,768); - defer("run()"); - ) : printf("Error: %s has no = 0 && conid < this.maxcon ? ( - parm == 'sock' ? this.tab + conid*this.recsz + 0 : // socket - parm == 'st' ? this.tab + conid*this.recsz + 1 : // state - parm == 'fh' ? this.tab + conid*this.recsz + 2 : // file handle - 0) - : 0 -); - -function httpd.set(conid, parm, value) local(x) global() -( - x = httpd.getrecval(conid,parm); - x>=0 ? x[]=value; -); -function httpd.get(conid, parm) local(x) global() -( - x=httpd.getrecval(conid,parm); - x>=0?x[]; -); -function httpd.getbuf(conid, w) global() -( - conid >=0 && conid < this.maxcon ? this.stringtab + this.string_recsz*conid + w : -1; -); -function httpd.close(conid) global() -( - conid >=0 && conid < this.maxcon ? - ( - tcp_close(httpd.get(conid,'sock')); - fclose(httpd.get(conid,'fh')); - httpd.set(conid,'sock',0); - httpd.set(conid,'fh',0); - ); -); -function httpd.file_for_req(req, response) local(fn,fp) global() ( - !strcmp(req,"") || !strcmp(req,"/") ? req = "/index.html"; - - str_getchar(req,0) == '/' && - !match("*..*",req) && - (fp=fopen(fn = strcat(#=#this.wwwroot,req),"rb")) > 0 ? - ( - fseek(fp,0,1); - printf("GET %s -- 200: %s\n",req,fn); - strcat(response,sprintf(#, "HTTP/1.1 200 OK\r\n" - "Content-length: %d\r\n" - "Content-type: text/html\r\n" - "\r\n", - ftell(fp))); - fseek(fp,0,-1); - fp; - ) : ( - printf("GET %s -- 404\n",req); - - fn = "The file specified could not be found."; - strcat(response,sprintf(#, "HTTP/1.1 404 NOT FOUND\r\n" - "Content-length: %d\r\n" - "Content-type: text/plain\r\n" - "\r\n" - "%s", strlen(fn),fn)); - 0; - ); -); - -// run input and output buffers -function httpd.runcon(idx) local(sock,x,str,rv,buffers) global() ( - rv=0; - sock = httpd.get(idx,'sock'); - sock > 0 ? - ( - x=tcp_recv(sock,str=#); - x<0 ? ( - httpd.close(idx); - ) : ( - buffers=httpd.getbuf(idx,0); - x>0 ? strcat(buffers,str); - rv+=x; - - strlen(buffers+1)>0 ? - ( - (x=tcp_send(sock,buffers+1)) > 0 ? - ( - rv+=1; - str_delsub(buffers+1.1,0,x); - ); - ); - ); - ); - rv; -); - - -function httpd.run() local(sock, x, i, str, rv, t,hdrs,httpdver) global() ( - str=#; - hdrs=#; - rv=0; - sock=tcp_listen(this.port,"",str); - sock > 0 ? - ( - i=0; - while (i < this.maxcon && httpd.get(i,'sock')) ( i += 1; ); - i < this.maxcon ? ( - tcp_set_block(sock,0); - httpd.set(i,'sock',sock); - httpd.set(i,'st',0); - - x=0; - loop(this.string_recsz, strcpy(httpd.getbuf(i,x), ""); x+=1; ); - printf("httpd.run(): connection from '%s'\n",str); - rv+=1; - - ) : ( - printf("httpd.run(): dropping connect from '%s', slots full\n",str); - tcp_close(x); - ); - ); - - i=0; - while (i < this.maxcon) - ( - this.httpd.runcon(i) ? - ( - t = httpd.getbuf(i,0); - this.httpd.get(i,'st') == 0 ? - ( - match("GET %S HTTP/1.%1d%S",t,str,httpdver,hdrs) && - str_getchar(hdrs,0)=='\r' && str_getchar(hdrs,1)=='\n' && - !strcmp(strcpy_substr(#,hdrs,-4),"\r\n\r\n") - ? - ( - httpd.set(i,'st',1 | - ((httpdver==0 || matchi("\r\nConnection:*close\r\n",hdrs))?2:0) - ); - - httpd.set(i,'fh',httpd.file_for_req(str,t+1)); - ); - ); - - httpd.get(i,'fh') && !strlen(t+1) ? fread(httpd.get(i,'fh'),t+1,4096); - - httpd.get(i,'st') == 3 ? ( - strlen(t+1) == 0 ? ( - httpd.close(i); - printf("sent data, closing\n"); - ); - ); - - rv+=1; - ); - i+=1; - ); - - - rv; -); - -argc != 3 || strlen(argv[1])<1 || !match("%d",argv[2],port) ? ( - printf("Usage: \n\t%s www_root port\n",argv[0]); -) : ( - srv.httpd.init(port, 100, 100000, 10000, argv[1]); - // string [conidx] = send buffe - while(1) - ( - srv.httpd.run() || Sleep(10); - ); -); - diff --git a/oversampling/WDL/eel2/scripts/pproc_test.eel b/oversampling/WDL/eel2/scripts/pproc_test.eel deleted file mode 100644 index ad1432c..0000000 --- a/oversampling/WDL/eel2/scripts/pproc_test.eel +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - -printf("this will not get compiled\n"); - - -printf("apparently y is now %d but x is %d\n",y,x); diff --git a/oversampling/WDL/eel2/scripts/sinewave_text.eel b/oversampling/WDL/eel2/scripts/sinewave_text.eel deleted file mode 100644 index bbf67cf..0000000 --- a/oversampling/WDL/eel2/scripts/sinewave_text.eel +++ /dev/null @@ -1,17 +0,0 @@ -width = 80; -lx=-1; -loop(1000000, - x = ((1+sin(pos))*0.5 * width)|0; - lx >= -1 && lx!=x ? ( - loop(min(x,lx), printf(" ")); - loop(abs(x-lx), printf("*")); - loop(width-max(x,lx), printf(" ")); - ) : ( - loop(x, printf(" ")); - printf("*"); - loop(width-1-x, printf(" ")); - ); - lx=x; - printf("\n"); - pos += 0.25 + sin(pos*0.32)*0.2; -); diff --git a/oversampling/WDL/eel2/scripts/space.eel b/oversampling/WDL/eel2/scripts/space.eel deleted file mode 100644 index c517aa1..0000000 --- a/oversampling/WDL/eel2/scripts/space.eel +++ /dev/null @@ -1,73 +0,0 @@ - - -gfx_init("space",640,480); - -function enemylist.init(buf, rows, cols, maxwid) global() -( - this.buf = buf; - this.rows=rows; - this.cols=cols; - this.maxwid = maxwid; - loop(rows*cols, buf[]=1; buf += 1; ); -); - - -function enemylist.draw(pos, vpos, destextent*) - local(rad,buf,xpos,ypos,dxpos) - global(gfx_w,gfx_h,gfx_r,gfx_g,gfx_b,gfx_a) -( - gfx_r=gfx_a=1; - gfx_g=gfx_b=0; - dxpos = this.maxwid/this.cols*gfx_w; - buf=this.buf; - rad = dxpos*0.3; - destextent.right = 0; - destextent.bottom = 0; - destextent.left=2^20; - destextent.top=2^20; - - ypos=dxpos*0.5 + gfx_h*vpos; - loop(this.rows, - xpos=pos*gfx_w + dxpos*0.5; - loop(this.cols, - buf[] ? ( - destextent.left = min(destextent.left,xpos-rad); - destextent.right = max(destextent.right,xpos+rad); - destextent.top = min(destextent.top,ypos-rad); - destextent.bottom = max(destextent.bottom,ypos+rad); - gfx_circle(xpos,ypos,rad); - ); - xpos += dxpos; - buf += 1; - ); - ypos += dxpos; - ); -); - - -enemylist.init(0, 4, 8, 0.8); - - -last_time = time_precise(); -enemy_pos = 0; -enemy_vpos = 0; -enemy_vel = 0.05; -while ((curchar = gfx_getchar()) != 27) -( - now = time_precise(); - enemylist.draw(enemy_pos, enemy_vpos, area); - enemy_vel > 0 ? ( - area.right >= gfx_w ? ( enemy_vel = -enemy_vel; enemy_vpos += abs(enemy_vel); enemy_vel *= 1.3; ); - ) : ( - area.left <= 0 ? ( enemy_vel = -enemy_vel; enemy_vpos += abs(enemy_vel); enemy_vel *= 1.3; ); - ); - - enemy_pos += (now-last_time)*enemy_vel; - - - - - last_time = now; - sleep(33); - gfx_update(); -); diff --git a/oversampling/WDL/eel2/scripts/test_a.eel b/oversampling/WDL/eel2/scripts/test_a.eel deleted file mode 100644 index 923c122..0000000 --- a/oversampling/WDL/eel2/scripts/test_a.eel +++ /dev/null @@ -1,22 +0,0 @@ -sum=0; -a= 1; -b = .1; -c= .2; -d = .5; -e = 4; -f = -0.2; -g = 0.3; -h = .37; - -loop(62000, - i = 0; - sum=0.0; - loop(8192, - sum += i*(3+ a * b + c*d + e * (f - b*(-c) + g*(e-g*(-g)*g)) ); - sum2 += (a*b)+(a*b)+((a*b)*((b*c)*((h*i)*(f*g)))); - i += 0.001; - i2+=1; - ); -); -printf("sum error %.18f %.18f\n", sum - 245333.476966294896556064, sum2 - 101488440.519564077258110046); -printf("sum error per inst %.18f %.18f\n", (sum - 245333.476966294896556064) / i, (sum2 - 101488440.519564077258110046)/i2); diff --git a/oversampling/WDL/eel2/scripts/test_or64.eel b/oversampling/WDL/eel2/scripts/test_or64.eel deleted file mode 100644 index 084caeb..0000000 --- a/oversampling/WDL/eel2/scripts/test_or64.eel +++ /dev/null @@ -1,35 +0,0 @@ -v1 = 2^50; -v2 = 2^50; -z=0; - -(floor(v1)/v2) !== 1 ? printf("fail test floor\n"); -(floor(v1)/(2^50)) !== 1 ? printf("fail test floor/const\n"); -(floor(2^50)/v2) !== 1 ? printf("fail test floor-const\n"); -(floor(2^50)/(2^50)) !== 1 ? printf("fail test floor-const/const\n"); -(floor(v1+1)/(v2+1)) !== 1 ? printf("fail test floor+1\n"); -(floor(v1+1)/(2^50+1)) !== 1 ? printf("fail test floor+1/const\n"); -(floor(2^50 + 1)/(v2+1)) !== 1 ? printf("fail test floor-const+1"); -(floor(2^50 + 1)/(2^50 + 1)) !== 1 ? printf("fail test floor-const+1/const\n"); - -((v1|0)/v2) !== 1 ? printf("fail test |0\n"); -((v1|0)/(2^50)) !== 1 ? printf("fail test |0/const\n"); -(((2^50)|0)/v2) !== 1 ? printf("fail test const|0\n"); -(((2^50)|0)/(2^50)) !== 1 ? printf("fail test const|0/const\n"); -((v1|1)/(v2+1)) !== 1 ? printf("fail test |1\n"); -((v1|1)/(2^50+1)) !== 1 ? printf("fail test |1/const\n"); -(((2^50)|1)/(v2 + 1)) !== 1 ? printf("fail test const|1\n"); -(((2^50)|1)/(2^50 + 1)) !== 1 ? printf("fail test const|1/const\n"); - -((v1~1)/(v2+1)) !== 1 ? printf("fail test ~1\n"); -((v1~1)/(2^50+1)) !== 1 ? printf("fail test ~1/const\n"); -(((2^50)~1)/(v2 + 1)) !== 1 ? printf("fail test const~1\n"); -(((2^50)~1)/(2^50 + 1)) !== 1 ? printf("fail test const~1/const\n"); - -c = v1; c |= v1; -c !== v1 ? printf("fail test |= \n"); -c = v1; c |= 0; -c !== v1 ? printf("fail test |= 0\n"); -c = v1; c &= v1; -c !== v1 ? printf("fail test &=\n"); -c = v1; c ~= z; -c !== v1 ? printf("fail test ~= \n"); diff --git a/oversampling/WDL/eel2/y.tab.c b/oversampling/WDL/eel2/y.tab.c deleted file mode 100644 index 6b264b7..0000000 --- a/oversampling/WDL/eel2/y.tab.c +++ /dev/null @@ -1,2186 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.3. */ - -/* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - - 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, 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., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* C LALR(1) parser skeleton written by Richard Stallman, by - simplifying the original so-called "semantic" parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Bison version. */ -#define YYBISON_VERSION "2.3" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 1 - -/* Using locations. */ -#define YYLSP_NEEDED 1 - -/* Substitute the variable and function names. */ -#define yyparse nseelparse -#define yylex nseellex -#define yyerror nseelerror -#define yylval nseellval -#define yychar nseelchar -#define yydebug nseeldebug -#define yynerrs nseelnerrs -#define yylloc nseellloc - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - VALUE = 258, - IDENTIFIER = 259, - TOKEN_SHL = 260, - TOKEN_SHR = 261, - TOKEN_LTE = 262, - TOKEN_GTE = 263, - TOKEN_EQ = 264, - TOKEN_EQ_EXACT = 265, - TOKEN_NE = 266, - TOKEN_NE_EXACT = 267, - TOKEN_LOGICAL_AND = 268, - TOKEN_LOGICAL_OR = 269, - TOKEN_ADD_OP = 270, - TOKEN_SUB_OP = 271, - TOKEN_MOD_OP = 272, - TOKEN_OR_OP = 273, - TOKEN_AND_OP = 274, - TOKEN_XOR_OP = 275, - TOKEN_DIV_OP = 276, - TOKEN_MUL_OP = 277, - TOKEN_POW_OP = 278, - STRING_LITERAL = 279, - STRING_IDENTIFIER = 280 - }; -#endif -/* Tokens. */ -#define VALUE 258 -#define IDENTIFIER 259 -#define TOKEN_SHL 260 -#define TOKEN_SHR 261 -#define TOKEN_LTE 262 -#define TOKEN_GTE 263 -#define TOKEN_EQ 264 -#define TOKEN_EQ_EXACT 265 -#define TOKEN_NE 266 -#define TOKEN_NE_EXACT 267 -#define TOKEN_LOGICAL_AND 268 -#define TOKEN_LOGICAL_OR 269 -#define TOKEN_ADD_OP 270 -#define TOKEN_SUB_OP 271 -#define TOKEN_MOD_OP 272 -#define TOKEN_OR_OP 273 -#define TOKEN_AND_OP 274 -#define TOKEN_XOR_OP 275 -#define TOKEN_DIV_OP 276 -#define TOKEN_MUL_OP 277 -#define TOKEN_POW_OP 278 -#define STRING_LITERAL 279 -#define STRING_IDENTIFIER 280 - - - - -/* Copy the first part of user declarations. */ -#line 13 "eel2.y" - -#ifdef _WIN32 -#include -#endif -#include -#include -#include -#include - -#include "y.tab.h" -#include "ns-eel-int.h" - -#define scanner context->scanner -#define YY_(x) ("") - - - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 -#endif - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef int YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - -#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED -typedef struct YYLTYPE -{ - int first_line; - int first_column; - int last_line; - int last_column; -} YYLTYPE; -# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 -#endif - - -/* Copy the second part of user declarations. */ - - -/* Line 216 of yacc.c. */ -#line 193 "y.tab.c" - -#ifdef short -# undef short -#endif - -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; -#endif - -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -typedef signed char yytype_int8; -#else -typedef short int yytype_int8; -#endif - -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; -#else -typedef unsigned short int yytype_uint16; -#endif - -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; -#else -typedef short int yytype_int16; -#endif - -#ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned int -# endif -#endif - -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) - -#ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) -#else -# define YYUSE(e) /* empty */ -#endif - -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(n) (n) -#else -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static int -YYID (int i) -#else -static int -YYID (i) - int i; -#endif -{ - return i; -} -#endif - -#if ! defined yyoverflow || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# elif defined __BUILTIN_VA_ARG_INCR -# include /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include /* INFRINGES ON USER NAME SPACE */ -# define alloca _alloca -# else -# define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -# endif -# if (defined __cplusplus && ! defined _STDLIB_H \ - && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - - -#if (! defined yyoverflow \ - && (! defined __cplusplus \ - || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ - && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yytype_int16 yyss; - YYSTYPE yyvs; - YYLTYPE yyls; -}; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ - + 2 * YYSTACK_GAP_MAXIMUM) - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) - -#endif - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 68 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 141 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 47 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 19 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 73 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 127 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 280 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const yytype_uint8 yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 34, 2, 2, 2, 36, 39, 2, - 27, 28, 38, 32, 26, 33, 2, 37, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 45, 46, - 42, 31, 43, 44, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 29, 2, 30, 35, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 40, 2, 41, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint16 yyprhs[] = -{ - 0, 0, 3, 5, 9, 11, 14, 16, 20, 28, - 33, 37, 44, 53, 57, 62, 64, 66, 68, 70, - 72, 76, 80, 84, 88, 92, 96, 100, 104, 108, - 112, 116, 120, 122, 125, 128, 131, 133, 137, 139, - 143, 147, 151, 153, 157, 159, 163, 165, 169, 171, - 175, 177, 181, 185, 189, 191, 195, 199, 203, 207, - 211, 215, 219, 223, 225, 229, 233, 235, 241, 246, - 250, 252, 256, 259 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int8 yyrhs[] = -{ - 65, 0, -1, 64, -1, 64, 26, 48, -1, 24, - -1, 24, 49, -1, 4, -1, 27, 64, 28, -1, - 4, 27, 64, 28, 27, 64, 28, -1, 4, 27, - 64, 28, -1, 4, 27, 28, -1, 4, 27, 64, - 26, 64, 28, -1, 4, 27, 64, 26, 64, 26, - 48, 28, -1, 51, 29, 30, -1, 51, 29, 64, - 30, -1, 3, -1, 25, -1, 49, -1, 50, -1, - 51, -1, 50, 31, 63, -1, 50, 15, 63, -1, - 50, 16, 63, -1, 50, 17, 63, -1, 50, 18, - 63, -1, 50, 19, 63, -1, 50, 20, 63, -1, - 50, 21, 63, -1, 50, 22, 63, -1, 50, 23, - 63, -1, 25, 31, 63, -1, 25, 15, 63, -1, - 52, -1, 32, 53, -1, 33, 53, -1, 34, 53, - -1, 53, -1, 54, 35, 53, -1, 54, -1, 55, - 36, 54, -1, 55, 5, 54, -1, 55, 6, 54, - -1, 55, -1, 56, 37, 55, -1, 56, -1, 57, - 38, 56, -1, 57, -1, 58, 33, 57, -1, 58, - -1, 59, 32, 58, -1, 59, -1, 60, 39, 59, - -1, 60, 40, 59, -1, 60, 41, 59, -1, 60, - -1, 61, 42, 60, -1, 61, 43, 60, -1, 61, - 7, 60, -1, 61, 8, 60, -1, 61, 9, 60, - -1, 61, 10, 60, -1, 61, 11, 60, -1, 61, - 12, 60, -1, 61, -1, 62, 13, 61, -1, 62, - 14, 61, -1, 62, -1, 62, 44, 63, 45, 63, - -1, 62, 44, 45, 63, -1, 62, 44, 63, -1, - 63, -1, 64, 46, 63, -1, 64, 46, -1, 64, - -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = -{ - 0, 40, 40, 41, 48, 49, 57, 67, 71, 83, - 93, 103, 114, 126, 130, 137, 138, 139, 143, 148, - 149, 153, 157, 161, 165, 169, 173, 177, 181, 185, - 189, 193, 200, 201, 205, 209, 216, 217, 224, 225, - 229, 233, 240, 241, 249, 250, 258, 259, 266, 267, - 274, 275, 279, 283, 290, 291, 295, 299, 303, 307, - 311, 315, 319, 326, 327, 331, 338, 339, 343, 347, - 355, 356, 360, 368 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "VALUE", "IDENTIFIER", "TOKEN_SHL", - "TOKEN_SHR", "TOKEN_LTE", "TOKEN_GTE", "TOKEN_EQ", "TOKEN_EQ_EXACT", - "TOKEN_NE", "TOKEN_NE_EXACT", "TOKEN_LOGICAL_AND", "TOKEN_LOGICAL_OR", - "TOKEN_ADD_OP", "TOKEN_SUB_OP", "TOKEN_MOD_OP", "TOKEN_OR_OP", - "TOKEN_AND_OP", "TOKEN_XOR_OP", "TOKEN_DIV_OP", "TOKEN_MUL_OP", - "TOKEN_POW_OP", "STRING_LITERAL", "STRING_IDENTIFIER", "','", "'('", - "')'", "'['", "']'", "'='", "'+'", "'-'", "'!'", "'^'", "'%'", "'/'", - "'*'", "'&'", "'|'", "'~'", "'<'", "'>'", "'?'", "':'", "';'", "$accept", - "more_params", "string", "assignable_value", "rvalue", "assignment", - "unary_expr", "pow_expr", "mod_expr", "div_expr", "mul_expr", "sub_expr", - "add_expr", "andor_expr", "cmp_expr", "logical_and_or_expr", - "if_else_expr", "expression", "program", 0 -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const yytype_uint16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 44, 40, 41, 91, - 93, 61, 43, 45, 33, 94, 37, 47, 42, 38, - 124, 126, 60, 62, 63, 58, 59 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 47, 48, 48, 49, 49, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 51, 51, 51, 51, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 53, 53, 53, 53, 54, 54, 55, 55, - 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, - 60, 60, 60, 60, 61, 61, 61, 61, 61, 61, - 61, 61, 61, 62, 62, 62, 63, 63, 63, 63, - 64, 64, 64, 65 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 1, 3, 1, 2, 1, 3, 7, 4, - 3, 6, 8, 3, 4, 1, 1, 1, 1, 1, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 1, 2, 2, 2, 1, 3, 1, 3, - 3, 3, 1, 3, 1, 3, 1, 3, 1, 3, - 1, 3, 3, 3, 1, 3, 3, 3, 3, 3, - 3, 3, 3, 1, 3, 3, 1, 5, 4, 3, - 1, 3, 2, 1 -}; - -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const yytype_uint8 yydefact[] = -{ - 0, 15, 6, 4, 16, 0, 0, 0, 0, 17, - 18, 19, 32, 36, 38, 42, 44, 46, 48, 50, - 54, 63, 66, 70, 73, 0, 0, 5, 0, 0, - 0, 33, 34, 35, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 72, 1, 10, - 0, 31, 30, 7, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 20, 13, 0, 37, 40, 41, 39, - 43, 45, 47, 49, 51, 52, 53, 57, 58, 59, - 60, 61, 62, 55, 56, 64, 65, 0, 69, 71, - 0, 9, 14, 68, 0, 0, 0, 67, 0, 11, - 0, 0, 2, 8, 12, 0, 3 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int8 yydefgoto[] = -{ - -1, 121, 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 122, 25 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -38 -static const yytype_int8 yypact[] = -{ - 70, -38, -21, 12, -11, 70, 70, 70, 70, -38, - 102, 6, -38, -38, 50, 19, 4, 8, 14, 25, - 51, 22, 40, -38, 47, 96, 34, -38, 70, 70, - 43, -38, -38, -38, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 45, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 18, 70, -38, -38, - 55, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, -38, 30, -38, 50, 50, 50, - 19, 4, 8, 14, 25, 25, 25, 51, 51, 51, - 51, 51, 51, 51, 51, 22, 22, 70, 53, -38, - 70, 72, -38, -38, 70, 60, 70, -38, 70, -38, - 54, 77, -23, -38, -38, 70, -38 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int8 yypgoto[] = -{ - -38, -10, 111, -38, -38, -38, 11, 61, 79, 76, - 80, 75, 58, 78, -37, -38, -27, 0, -38 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -1 -static const yytype_uint8 yytable[] = -{ - 24, 71, 72, 125, 28, 30, 26, 74, 75, 76, - 77, 78, 79, 80, 81, 82, 83, 31, 32, 33, - 29, 1, 2, 67, 46, 47, 70, 105, 106, 56, - 57, 58, 59, 60, 61, 44, 3, 1, 2, 108, - 109, 49, 3, 4, 85, 5, 50, 51, 1, 2, - 6, 7, 8, 64, 65, 48, 86, 52, 3, 4, - 112, 5, 69, 107, 62, 63, 6, 7, 8, 3, - 4, 73, 5, 1, 2, 84, 67, 6, 7, 8, - 113, 110, 123, 111, 66, 45, 118, 117, 119, 67, - 53, 54, 55, 67, 3, 4, 68, 5, 114, 116, - 67, 67, 6, 7, 8, 124, 67, 87, 88, 89, - 115, 94, 95, 96, 27, 126, 120, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 91, 93, 90, 0, - 0, 92, 0, 43, 97, 98, 99, 100, 101, 102, - 103, 104 -}; - -static const yytype_int8 yycheck[] = -{ - 0, 28, 29, 26, 15, 5, 27, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 6, 7, 8, - 31, 3, 4, 46, 5, 6, 26, 64, 65, 7, - 8, 9, 10, 11, 12, 29, 24, 3, 4, 66, - 67, 37, 24, 25, 44, 27, 38, 33, 3, 4, - 32, 33, 34, 13, 14, 36, 45, 32, 24, 25, - 30, 27, 28, 45, 42, 43, 32, 33, 34, 24, - 25, 28, 27, 3, 4, 30, 46, 32, 33, 34, - 107, 26, 28, 28, 44, 35, 26, 114, 28, 46, - 39, 40, 41, 46, 24, 25, 0, 27, 45, 27, - 46, 46, 32, 33, 34, 28, 46, 46, 47, 48, - 110, 53, 54, 55, 3, 125, 116, 15, 16, 17, - 18, 19, 20, 21, 22, 23, 50, 52, 49, -1, - -1, 51, -1, 31, 56, 57, 58, 59, 60, 61, - 62, 63 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = -{ - 0, 3, 4, 24, 25, 27, 32, 33, 34, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, - 60, 61, 62, 63, 64, 65, 27, 49, 15, 31, - 64, 53, 53, 53, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 31, 29, 35, 5, 6, 36, 37, - 38, 33, 32, 39, 40, 41, 7, 8, 9, 10, - 11, 12, 42, 43, 13, 14, 44, 46, 0, 28, - 64, 63, 63, 28, 63, 63, 63, 63, 63, 63, - 63, 63, 63, 63, 30, 64, 53, 54, 54, 54, - 55, 56, 57, 58, 59, 59, 59, 60, 60, 60, - 60, 60, 60, 60, 60, 61, 61, 45, 63, 63, - 26, 28, 30, 63, 45, 64, 27, 63, 26, 28, - 64, 48, 64, 28, 28, 26, 48 -}; - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ - -#define YYFAIL goto yyerrlab - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK (1); \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (&yylloc, context, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (YYID (0)) - - -#define YYTERROR 1 -#define YYERRCODE 256 - - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) -#endif - - -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ - -#ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) -#else -# define YYLEX yylex (&yylval, &yylloc, scanner) -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (YYID (0)) - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value, Location, context); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (YYID (0)) - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, compileContext* context) -#else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, context) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; - YYLTYPE const * const yylocationp; - compileContext* context; -#endif -{ - if (!yyvaluep) - return; - YYUSE (yylocationp); - YYUSE (context); -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); -# endif - switch (yytype) - { - default: - break; - } -} - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, compileContext* context) -#else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, context) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; - YYLTYPE const * const yylocationp; - compileContext* context; -#endif -{ - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - YY_LOCATION_PRINT (yyoutput, *yylocationp); - YYFPRINTF (yyoutput, ": "); - yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, context); - YYFPRINTF (yyoutput, ")"); -} - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) -#else -static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, compileContext* context) -#else -static void -yy_reduce_print (yyvsp, yylsp, yyrule, context) - YYSTYPE *yyvsp; - YYLTYPE *yylsp; - int yyrule; - compileContext* context; -#endif -{ - int yynrhs = yyr2[yyrule]; - int yyi; - unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); - /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - fprintf (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - , &(yylsp[(yyi + 1) - (yynrhs)]) , context); - fprintf (stderr, "\n"); - } -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyvsp, yylsp, Rule, context); \ -} while (YYID (0)) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static YYSIZE_T -yystrlen (const char *yystr) -#else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; -#endif -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif - -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static char * -yystpcpy (char *yydest, const char *yysrc) -#else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -#endif -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) -{ - int yyn = yypact[yystate]; - - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else - { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - - if (yysize_overflow) - return YYSIZE_MAXIMUM; - - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; - } -} -#endif /* YYERROR_VERBOSE */ - - -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, compileContext* context) -#else -static void -yydestruct (yymsg, yytype, yyvaluep, yylocationp, context) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; - YYLTYPE *yylocationp; - compileContext* context; -#endif -{ - YYUSE (yyvaluep); - YYUSE (yylocationp); - YYUSE (context); - - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - switch (yytype) - { - case 3: /* "VALUE" */ -#line 8 "eel2.y" - { - #define yydestruct(a,b,c,d,e) -}; -#line 1222 "y.tab.c" - break; - - default: - break; - } -} - - -/* Prevent warnings from -Wmissing-prototypes. */ - -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse (compileContext* context); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - - - - - -/*----------. -| yyparse. | -`----------*/ - -#ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) -#else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -#endif -#else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (compileContext* context) -#else -int -yyparse (context) - compileContext* context; -#endif -#endif -{ - /* The look-ahead symbol. */ -int yychar; - -/* The semantic value of the look-ahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; -/* Location data for the look-ahead symbol. */ -YYLTYPE yylloc; - - int yystate; - int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; - - /* The location stack. */ - YYLTYPE yylsa[YYINITDEPTH]; - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[2]; - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) - - YYSIZE_T yystacksize = YYINITDEPTH; - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - YYLTYPE yyloc; - - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; - yylsp = yyls; -#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL - /* Initialize the default location before parsing starts. */ - yylloc.first_line = yylloc.last_line = 1; - yylloc.first_column = yylloc.last_column = 0; -#endif - - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. So pushing a state here evens the stacks. */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - YYLTYPE *yyls1 = yyls; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yyls1, yysize * sizeof (*yylsp), - &yystacksize); - yyls = yyls1; - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - YYSTACK_RELOCATE (yyls); -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - yylsp = yyls + yysize - 1; - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - - /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ - - /* First try to decide what to do without reference to look-ahead token. */ - yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) - goto yydefault; - - /* Not known => get a look-ahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - if (yyn == YYFINAL) - YYACCEPT; - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - /* Shift the look-ahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - yystate = yyn; - *++yyvsp = yylval; - *++yylsp = yylloc; - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - /* Default location. */ - YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 3: -#line 42 "eel2.y" - { - (yyval) = nseel_createMoreParametersOpcode(context,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 5: -#line 50 "eel2.y" - { - ((struct eelStringSegmentRec *)(yyvsp[(1) - (2)]))->_next = (struct eelStringSegmentRec *)(yyvsp[(2) - (2)]); - (yyval) = (yyvsp[(1) - (2)]); - } - break; - - case 6: -#line 58 "eel2.y" - { - if (!((yyval) = nseel_resolve_named_symbol(context, (yyvsp[(1) - (1)]), -1, NULL))) /* convert from purely named to namespace-relative, etc */ - { - yyerror(&yyloc, context, ""); - YYERROR; - } - } - break; - - case 7: -#line 68 "eel2.y" - { - (yyval) = (yyvsp[(2) - (3)]); - } - break; - - case 8: -#line 72 "eel2.y" - { - int err; - if (!((yyval) = nseel_setCompiledFunctionCallParameters(context,(yyvsp[(1) - (7)]), (yyvsp[(3) - (7)]), 0, 0, (yyvsp[(6) - (7)]), &err))) - { - if (err == -1) yyerror(&yylsp[-2], context, ""); - else if (err == 0) yyerror(&yylsp[-6], context, ""); - else yyerror(&yylsp[-3], context, ""); // parameter count wrong - - YYERROR; - } - } - break; - - case 9: -#line 84 "eel2.y" - { - int err; - if (!((yyval) = nseel_setCompiledFunctionCallParameters(context,(yyvsp[(1) - (4)]), (yyvsp[(3) - (4)]), 0, 0, 0, &err))) - { - if (err == 0) yyerror(&yylsp[-3], context, ""); - else yyerror(&yylsp[0], context, ""); // parameter count wrong - YYERROR; - } - } - break; - - case 10: -#line 94 "eel2.y" - { - int err; - if (!((yyval) = nseel_setCompiledFunctionCallParameters(context,(yyvsp[(1) - (3)]), nseel_createCompiledValue(context,0.0), 0, 0, 0,&err))) - { - if (err == 0) yyerror(&yylsp[-2], context, ""); // function not found - else yyerror(&yylsp[0], context, ""); // parameter count wrong - YYERROR; - } - } - break; - - case 11: -#line 104 "eel2.y" - { - int err; - if (!((yyval) = nseel_setCompiledFunctionCallParameters(context,(yyvsp[(1) - (6)]), (yyvsp[(3) - (6)]), (yyvsp[(5) - (6)]), 0, 0,&err))) - { - if (err == 0) yyerror(&yylsp[-5], context, ""); - else if (err == 2) yyerror(&yylsp[0], context, ""); // needs more than 2 parameters - else yyerror(&yylsp[-2], context, ""); // less than 2 - YYERROR; - } - } - break; - - case 12: -#line 115 "eel2.y" - { - int err; - if (!((yyval) = nseel_setCompiledFunctionCallParameters(context,(yyvsp[(1) - (8)]), (yyvsp[(3) - (8)]), (yyvsp[(5) - (8)]), (yyvsp[(7) - (8)]), 0, &err))) - { - if (err == 0) yyerror(&yylsp[-7], context, ""); - else if (err==2) yyerror(&yylsp[0], context, ""); // needs more parameters - else if (err==4) yyerror(&yylsp[-4], context, ""); // needs single parameter - else yyerror(&yylsp[-2], context, ""); // less parm - YYERROR; - } - } - break; - - case 13: -#line 127 "eel2.y" - { - (yyval) = nseel_createMemoryAccess(context,(yyvsp[(1) - (3)]),0); - } - break; - - case 14: -#line 131 "eel2.y" - { - (yyval) = nseel_createMemoryAccess(context,(yyvsp[(1) - (4)]),(yyvsp[(3) - (4)])); - } - break; - - case 17: -#line 140 "eel2.y" - { - (yyval) = nseel_eelMakeOpcodeFromStringSegments(context,(struct eelStringSegmentRec *)(yyvsp[(1) - (1)])); - } - break; - - case 20: -#line 150 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_ASSIGN,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 21: -#line 154 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_ADD_OP,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 22: -#line 158 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_SUB_OP,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 23: -#line 162 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_MOD_OP,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 24: -#line 166 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_OR_OP,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 25: -#line 170 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_AND_OP,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 26: -#line 174 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_XOR_OP,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 27: -#line 178 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_DIV_OP,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 28: -#line 182 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_MUL_OP,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 29: -#line 186 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_POW_OP,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 30: -#line 190 "eel2.y" - { - (yyval) = nseel_createFunctionByName(context,"strcpy",2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),NULL); - } - break; - - case 31: -#line 194 "eel2.y" - { - (yyval) = nseel_createFunctionByName(context,"strcat",2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)]),NULL); - } - break; - - case 33: -#line 202 "eel2.y" - { - (yyval) = (yyvsp[(2) - (2)]); - } - break; - - case 34: -#line 206 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_UMINUS,1,(yyvsp[(2) - (2)]),0); - } - break; - - case 35: -#line 210 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_NOT,1,(yyvsp[(2) - (2)]),0); - } - break; - - case 37: -#line 218 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_POW,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 39: -#line 226 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_MOD,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 40: -#line 230 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_SHL,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 41: -#line 234 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_SHR,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 43: -#line 242 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_DIVIDE,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 45: -#line 251 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_MULTIPLY,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 47: -#line 260 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_SUB,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 49: -#line 268 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_ADD,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 51: -#line 276 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_AND,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 52: -#line 280 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_OR,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 53: -#line 284 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_XOR,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 55: -#line 292 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_LT,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 56: -#line 296 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_GT,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 57: -#line 300 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_LTE,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 58: -#line 304 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_GTE,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 59: -#line 308 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_EQ,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 60: -#line 312 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_EQ_EXACT,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 61: -#line 316 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_NE,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 62: -#line 320 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_NE_EXACT,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 64: -#line 328 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_LOGICAL_AND,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 65: -#line 332 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_LOGICAL_OR,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 67: -#line 340 "eel2.y" - { - (yyval) = nseel_createIfElse(context, (yyvsp[(1) - (5)]), (yyvsp[(3) - (5)]), (yyvsp[(5) - (5)])); - } - break; - - case 68: -#line 344 "eel2.y" - { - (yyval) = nseel_createIfElse(context, (yyvsp[(1) - (4)]), 0, (yyvsp[(4) - (4)])); - } - break; - - case 69: -#line 348 "eel2.y" - { - (yyval) = nseel_createIfElse(context, (yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), 0); - } - break; - - case 71: -#line 357 "eel2.y" - { - (yyval) = nseel_createSimpleCompiledFunction(context,FN_JOIN_STATEMENTS,2,(yyvsp[(1) - (3)]),(yyvsp[(3) - (3)])); - } - break; - - case 72: -#line 361 "eel2.y" - { - (yyval) = (yyvsp[(1) - (2)]); - } - break; - - case 73: -#line 369 "eel2.y" - { - if ((yylsp[(1) - (1)]).first_line) { } - context->result = (yyvsp[(1) - (1)]); - } - break; - - -/* Line 1267 of yacc.c. */ -#line 1965 "y.tab.c" - default: break; - } - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); - - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - *++yylsp = yyloc; - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if ! YYERROR_VERBOSE - yyerror (&yylloc, context, YY_("syntax error")); -#else - { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (&yylloc, context, yymsg); - } - else - { - yyerror (&yylloc, context, YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } - } -#endif - } - - yyerror_range[0] = yylloc; - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse look-ahead token after an - error, discard it. */ - - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", - yytoken, &yylval, &yylloc, context); - yychar = YYEMPTY; - } - } - - /* Else will try to reuse look-ahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; - - yyerror_range[0] = yylsp[1-yylen]; - /* Do not reclaim the symbols of the rule which action triggered - this YYERROR. */ - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - yyerror_range[0] = *yylsp; - yydestruct ("Error: popping", - yystos[yystate], yyvsp, yylsp, context); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - if (yyn == YYFINAL) - YYACCEPT; - - *++yyvsp = yylval; - - yyerror_range[1] = yylloc; - /* Using YYLLOC is tempting, but would change the location of - the look-ahead. YYLOC is available though. */ - YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); - *++yylsp = yyloc; - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#ifndef yyoverflow -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror (&yylloc, context, YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, &yylloc, context); - /* Do not reclaim the symbols of the rule which action triggered - this YYABORT or YYACCEPT. */ - YYPOPSTACK (yylen); - YY_STACK_PRINT (yyss, yyssp); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp, yylsp, context); - YYPOPSTACK (1); - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif - /* Make sure YYID is used. */ - return YYID (yyresult); -} - - -#line 376 "eel2.y" - - diff --git a/oversampling/WDL/eel2/y.tab.h b/oversampling/WDL/eel2/y.tab.h deleted file mode 100644 index c02dace..0000000 --- a/oversampling/WDL/eel2/y.tab.h +++ /dev/null @@ -1,117 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.3. */ - -/* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - - 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, 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., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - VALUE = 258, - IDENTIFIER = 259, - TOKEN_SHL = 260, - TOKEN_SHR = 261, - TOKEN_LTE = 262, - TOKEN_GTE = 263, - TOKEN_EQ = 264, - TOKEN_EQ_EXACT = 265, - TOKEN_NE = 266, - TOKEN_NE_EXACT = 267, - TOKEN_LOGICAL_AND = 268, - TOKEN_LOGICAL_OR = 269, - TOKEN_ADD_OP = 270, - TOKEN_SUB_OP = 271, - TOKEN_MOD_OP = 272, - TOKEN_OR_OP = 273, - TOKEN_AND_OP = 274, - TOKEN_XOR_OP = 275, - TOKEN_DIV_OP = 276, - TOKEN_MUL_OP = 277, - TOKEN_POW_OP = 278, - STRING_LITERAL = 279, - STRING_IDENTIFIER = 280 - }; -#endif -/* Tokens. */ -#define VALUE 258 -#define IDENTIFIER 259 -#define TOKEN_SHL 260 -#define TOKEN_SHR 261 -#define TOKEN_LTE 262 -#define TOKEN_GTE 263 -#define TOKEN_EQ 264 -#define TOKEN_EQ_EXACT 265 -#define TOKEN_NE 266 -#define TOKEN_NE_EXACT 267 -#define TOKEN_LOGICAL_AND 268 -#define TOKEN_LOGICAL_OR 269 -#define TOKEN_ADD_OP 270 -#define TOKEN_SUB_OP 271 -#define TOKEN_MOD_OP 272 -#define TOKEN_OR_OP 273 -#define TOKEN_AND_OP 274 -#define TOKEN_XOR_OP 275 -#define TOKEN_DIV_OP 276 -#define TOKEN_MUL_OP 277 -#define TOKEN_POW_OP 278 -#define STRING_LITERAL 279 -#define STRING_IDENTIFIER 280 - - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef int YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 -#endif - - - -#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED -typedef struct YYLTYPE -{ - int first_line; - int first_column; - int last_line; - int last_column; -} YYLTYPE; -# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ -# define YYLTYPE_IS_DECLARED 1 -# define YYLTYPE_IS_TRIVIAL 1 -#endif - - diff --git a/oversampling/WDL/fastqueue.h b/oversampling/WDL/fastqueue.h deleted file mode 100644 index 415b13a..0000000 --- a/oversampling/WDL/fastqueue.h +++ /dev/null @@ -1,322 +0,0 @@ -/* - WDL - fastqueue.h - Copyright (C) 2006 and later Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - - This file defines and implements a class which can queue arbitrary amounts of data. - It is optimized for lots of reads and writes with a significant queue (i.e. it doesnt - have to shuffle much memory around). - - The downside is that you can't just ask for a pointer to specific bytes, it may have to peice - it together into a buffer of your choosing (or you can step through the buffers using GetPtr()). - - -*/ - -#ifndef _WDL_FASTQUEUE_H_ -#define _WDL_FASTQUEUE_H_ - - -#include "ptrlist.h" - -#define WDL_FASTQUEUE_ADD_NOZEROBUF ((void *)(INT_PTR)0xf0) - -class WDL_FastQueue -{ - struct fqBuf - { - int alloc_size; - int used; - char data[8]; - }; -public: - WDL_FastQueue(int bsize=65536-64, int maxemptieskeep=-1) - { - m_avail=0; - m_bsize=bsize<32?32:bsize; - m_offs=0; - m_maxemptieskeep=maxemptieskeep; - } - ~WDL_FastQueue() - { - m_queue.Empty(true,free); - m_empties.Empty(true,free); - } - - void AddInBlocks(const void *buf, int len, int reqbsize) - { - int pass=0; - if (reqbsize<128) reqbsize=128; - while (len > 0) - { - int amt = reqbsize; - fqBuf *qb; - if (!pass++ && (qb=m_queue.Get(m_queue.GetSize()-1)) && qb->used < qb->alloc_size) - amt = qb->alloc_size - qb->used; - else - { - qb=m_empties.Get(m_empties.GetSize()-1); - if (qb) amt = qb->alloc_size; - } - - if (amt > len) amt=len; - Add(buf,amt); - if (buf) buf = (char*)buf + amt; - len -= amt; - } - } - - void *Add(const void *buf, int len) // buf can be NULL to add zeroes - { - if (len < 1) return NULL; - - fqBuf *qb=m_queue.Get(m_queue.GetSize()-1); - if (!qb || (qb->used + len) > qb->alloc_size) - { - const int esz=m_empties.GetSize()-1; - qb=m_empties.Get(esz); - m_empties.Delete(esz); - if (qb && qb->alloc_size < len) // spare buffer is not big enough, toss it - { - free(qb); - qb=NULL; - } - if (!qb) - { - const int sz=len < m_bsize ? m_bsize : len; - qb=(fqBuf *)malloc(sz + sizeof(fqBuf) - sizeof(qb->data)); - if (!qb) return NULL; - qb->alloc_size = sz; - } - qb->used=0; - m_queue.Add(qb); - } - - void *ret = qb->data + qb->used; - if (buf) - { - if (buf != WDL_FASTQUEUE_ADD_NOZEROBUF) - { - memcpy(ret, buf, len); - } - } - else - { - memset(ret, 0, len); - } - - qb->used += len; - m_avail+=len; - return ret; - } - - void Clear(int limitmaxempties=-1) - { - int x=m_queue.GetSize(); - if (limitmaxempties<0) limitmaxempties = m_maxemptieskeep; - while (x > 0) - { - if (limitmaxempties<0 || m_empties.GetSize()used; - if (m_offs < sz) break; - m_offs -= sz; - - if (m_maxemptieskeep<0 || m_empties.GetSize()used; - if (offset < sz) - { - *buf = (char *)mq->data + offset; - return sz-offset; - } - x++; - offset -= sz; - } - *buf=NULL; - return 0; - } - - int SetFromBuf(int offs, void *buf, int len) // returns length set - { - int pos=0; - while (len > 0) - { - void *p=NULL; - int l=GetPtr(offs+pos,&p); - if (!l || !p) break; - if (l > len) l=len; - memcpy(p,(char *)buf + pos,l); - pos += l; - len -= l; - } - return pos; - } - - int GetToBuf(int offs, void *buf, int len) const - { - int pos=0; - while (len > 0) - { - void *p=NULL; - int l=GetPtr(offs+pos,&p); - if (!l || !p) break; - if (l > len) l=len; - memcpy((char *)buf + pos,p,l); - pos += l; - len -= l; - } - return pos; - } - - void UnAdd(int len) - { - len=wdl_clamp(len, 0, m_avail); - if (!len) return; - m_avail -= len; - while (fqBuf *qb=m_queue.Get(m_queue.GetSize()-1)) - { - if (qb->used > len) - { - qb->used -= len; - break; - } - len -= qb->used; - if (m_maxemptieskeep < 0 || m_empties.GetSize() < m_maxemptieskeep) - { - m_empties.Add(qb); - } - else - { - free(qb); - } - m_queue.Delete(m_queue.GetSize()-1); - if (!len) break; - } - } - - void *PushFront(const void *buf, int len) - { - fqBuf *qb=NULL; - if (m_offs && m_queue.GetSize()) - { - qb=m_queue.Get(0); - const int sz=wdl_min(m_offs, len); - if (!buf) - { - memset(qb->data+m_offs-sz, 0, sz); - } - else if (buf != WDL_FASTQUEUE_ADD_NOZEROBUF) - { - memcpy(qb->data+m_offs-sz, (unsigned char*)buf+len-sz, sz); - } - m_offs -= sz; - len -= sz; - m_avail += sz; - } - if (len) - { - const int esz=m_empties.GetSize()-1; - qb=m_empties.Get(esz); - m_empties.Delete(esz); - if (qb && qb->alloc_size < len) - { - free(qb); - qb=NULL; - } - if (!qb) - { - const int sz = len < m_bsize ? m_bsize : len; - qb=(fqBuf*)malloc(sz+sizeof(fqBuf)-sizeof(qb->data)); - if (!qb) return NULL; - qb->alloc_size=sz; - } - if (!buf) - { - memset(qb->data+qb->alloc_size-len, 0, len); - } - else if (buf != WDL_FASTQUEUE_ADD_NOZEROBUF) - { - memcpy(qb->data+qb->alloc_size-len, (unsigned char*)buf, len); - } - qb->used=qb->alloc_size; - m_queue.Insert(0, qb); - m_offs=qb->used-len; - m_avail += len; - } - return qb ? qb->data+m_offs : NULL; - } - -private: - - WDL_PtrList m_queue, m_empties; - int m_offs; - int m_avail; - int m_bsize; - int m_maxemptieskeep; -} WDL_FIXALIGN; - - -#endif //_WDL_FASTQUEUE_H_ diff --git a/oversampling/WDL/fft.c b/oversampling/WDL/fft.c deleted file mode 100644 index 8b15d6c..0000000 --- a/oversampling/WDL/fft.c +++ /dev/null @@ -1,1199 +0,0 @@ -/* - WDL - fft.cpp - Copyright (C) 2006 and later Cockos Incorporated - Copyright 1999 D. J. Bernstein - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - - - This file implements the WDL FFT library. These routines are based on the - DJBFFT library, which are Copyright 1999 D. J. Bernstein, djb@pobox.com - - The DJB FFT web page is: http://cr.yp.to/djbfft.html - -*/ - - -// this is based on djbfft - -#include -#include "fft.h" - - -#define FFT_MAXBITLEN 15 - -#ifdef _MSC_VER -#define inline __inline -#endif - -#define PI 3.1415926535897932384626433832795 - -static WDL_FFT_COMPLEX d16[3]; -static WDL_FFT_COMPLEX d32[7]; -static WDL_FFT_COMPLEX d64[15]; -static WDL_FFT_COMPLEX d128[31]; -static WDL_FFT_COMPLEX d256[63]; -static WDL_FFT_COMPLEX d512[127]; -static WDL_FFT_COMPLEX d1024[127]; -static WDL_FFT_COMPLEX d2048[255]; -static WDL_FFT_COMPLEX d4096[511]; -static WDL_FFT_COMPLEX d8192[1023]; -static WDL_FFT_COMPLEX d16384[2047]; -static WDL_FFT_COMPLEX d32768[4095]; - - -#define sqrthalf (d16[1].re) - -#define VOL *(volatile WDL_FFT_REAL *)& - -#define TRANSFORM(a0,a1,a2,a3,wre,wim) { \ - t6 = a2.re; \ - t1 = a0.re - t6; \ - t6 += a0.re; \ - a0.re = t6; \ - t3 = a3.im; \ - t4 = a1.im - t3; \ - t8 = t1 - t4; \ - t1 += t4; \ - t3 += a1.im; \ - a1.im = t3; \ - t5 = wre; \ - t7 = t8 * t5; \ - t4 = t1 * t5; \ - t8 *= wim; \ - t2 = a3.re; \ - t3 = a1.re - t2; \ - t2 += a1.re; \ - a1.re = t2; \ - t1 *= wim; \ - t6 = a2.im; \ - t2 = a0.im - t6; \ - t6 += a0.im; \ - a0.im = t6; \ - t6 = t2 + t3; \ - t2 -= t3; \ - t3 = t6 * wim; \ - t7 -= t3; \ - a2.re = t7; \ - t6 *= t5; \ - t6 += t8; \ - a2.im = t6; \ - t5 *= t2; \ - t5 -= t1; \ - a3.im = t5; \ - t2 *= wim; \ - t4 += t2; \ - a3.re = t4; \ - } - -#define TRANSFORMHALF(a0,a1,a2,a3) { \ - t1 = a2.re; \ - t5 = a0.re - t1; \ - t1 += a0.re; \ - a0.re = t1; \ - t4 = a3.im; \ - t8 = a1.im - t4; \ - t1 = t5 - t8; \ - t5 += t8; \ - t4 += a1.im; \ - a1.im = t4; \ - t3 = a3.re; \ - t7 = a1.re - t3; \ - t3 += a1.re; \ - a1.re = t3; \ - t8 = a2.im; \ - t6 = a0.im - t8; \ - t2 = t6 + t7; \ - t6 -= t7; \ - t8 += a0.im; \ - a0.im = t8; \ - t4 = t6 + t5; \ - t3 = sqrthalf; \ - t4 *= t3; \ - a3.re = t4; \ - t6 -= t5; \ - t6 *= t3; \ - a3.im = t6; \ - t7 = t1 - t2; \ - t7 *= t3; \ - a2.re = t7; \ - t2 += t1; \ - t2 *= t3; \ - a2.im = t2; \ - } - -#define TRANSFORMZERO(a0,a1,a2,a3) { \ - t5 = a2.re; \ - t1 = a0.re - t5; \ - t5 += a0.re; \ - a0.re = t5; \ - t8 = a3.im; \ - t4 = a1.im - t8; \ - t7 = a3.re; \ - t6 = t1 - t4; \ - a2.re = t6; \ - t1 += t4; \ - a3.re = t1; \ - t8 += a1.im; \ - a1.im = t8; \ - t3 = a1.re - t7; \ - t7 += a1.re; \ - a1.re = t7; \ - t6 = a2.im; \ - t2 = a0.im - t6; \ - t7 = t2 + t3; \ - a2.im = t7; \ - t2 -= t3; \ - a3.im = t2; \ - t6 += a0.im; \ - a0.im = t6; \ - } - -#define UNTRANSFORM(a0,a1,a2,a3,wre,wim) { \ - t6 = VOL wre; \ - t1 = VOL a2.re; \ - t1 *= t6; \ - t8 = VOL wim; \ - t3 = VOL a2.im; \ - t3 *= t8; \ - t2 = VOL a2.im; \ - t4 = VOL a2.re; \ - t5 = VOL a3.re; \ - t5 *= t6; \ - t7 = VOL a3.im; \ - t1 += t3; \ - t7 *= t8; \ - t5 -= t7; \ - t3 = t5 + t1; \ - t5 -= t1; \ - t2 *= t6; \ - t6 *= a3.im; \ - t4 *= t8; \ - t2 -= t4; \ - t8 *= a3.re; \ - t6 += t8; \ - t1 = a0.re - t3; \ - t3 += a0.re; \ - a0.re = t3; \ - t7 = a1.im - t5; \ - t5 += a1.im; \ - a1.im = t5; \ - t4 = t2 - t6; \ - t6 += t2; \ - t8 = a1.re - t4; \ - t4 += a1.re; \ - a1.re = t4; \ - t2 = a0.im - t6; \ - t6 += a0.im; \ - a0.im = t6; \ - a2.re = t1; \ - a3.im = t7; \ - a3.re = t8; \ - a2.im = t2; \ - } - - -#define UNTRANSFORMHALF(a0,a1,a2,a3) { \ - t6 = sqrthalf; \ - t1 = a2.re; \ - t2 = a2.im - t1; \ - t2 *= t6; \ - t1 += a2.im; \ - t1 *= t6; \ - t4 = a3.im; \ - t3 = a3.re - t4; \ - t3 *= t6; \ - t4 += a3.re; \ - t4 *= t6; \ - t8 = t3 - t1; \ - t7 = t2 - t4; \ - t1 += t3; \ - t2 += t4; \ - t4 = a1.im - t8; \ - a3.im = t4; \ - t8 += a1.im; \ - a1.im = t8; \ - t3 = a1.re - t7; \ - a3.re = t3; \ - t7 += a1.re; \ - a1.re = t7; \ - t5 = a0.re - t1; \ - a2.re = t5; \ - t1 += a0.re; \ - a0.re = t1; \ - t6 = a0.im - t2; \ - a2.im = t6; \ - t2 += a0.im; \ - a0.im = t2; \ - } - -#define UNTRANSFORMZERO(a0,a1,a2,a3) { \ - t2 = a3.im; \ - t3 = a2.im - t2; \ - t2 += a2.im; \ - t1 = a2.re; \ - t4 = a3.re - t1; \ - t1 += a3.re; \ - t5 = a0.re - t1; \ - a2.re = t5; \ - t6 = a0.im - t2; \ - a2.im = t6; \ - t7 = a1.re - t3; \ - a3.re = t7; \ - t8 = a1.im - t4; \ - a3.im = t8; \ - t1 += a0.re; \ - a0.re = t1; \ - t2 += a0.im; \ - a0.im = t2; \ - t3 += a1.re; \ - a1.re = t3; \ - t4 += a1.im; \ - a1.im = t4; \ - } - -static void c2(register WDL_FFT_COMPLEX *a) -{ - register WDL_FFT_REAL t1; - - t1 = a[1].re; - a[1].re = a[0].re - t1; - a[0].re += t1; - - t1 = a[1].im; - a[1].im = a[0].im - t1; - a[0].im += t1; -} - -static inline void c4(register WDL_FFT_COMPLEX *a) -{ - register WDL_FFT_REAL t1, t2, t3, t4, t5, t6, t7, t8; - - t5 = a[2].re; - t1 = a[0].re - t5; - t7 = a[3].re; - t5 += a[0].re; - t3 = a[1].re - t7; - t7 += a[1].re; - t8 = t5 + t7; - a[0].re = t8; - t5 -= t7; - a[1].re = t5; - t6 = a[2].im; - t2 = a[0].im - t6; - t6 += a[0].im; - t5 = a[3].im; - a[2].im = t2 + t3; - t2 -= t3; - a[3].im = t2; - t4 = a[1].im - t5; - a[3].re = t1 + t4; - t1 -= t4; - a[2].re = t1; - t5 += a[1].im; - a[0].im = t6 + t5; - t6 -= t5; - a[1].im = t6; -} - -static void c8(register WDL_FFT_COMPLEX *a) -{ - register WDL_FFT_REAL t1, t2, t3, t4, t5, t6, t7, t8; - - t7 = a[4].im; - t4 = a[0].im - t7; - t7 += a[0].im; - a[0].im = t7; - - t8 = a[6].re; - t5 = a[2].re - t8; - t8 += a[2].re; - a[2].re = t8; - - t7 = a[6].im; - a[6].im = t4 - t5; - t4 += t5; - a[4].im = t4; - - t6 = a[2].im - t7; - t7 += a[2].im; - a[2].im = t7; - - t8 = a[4].re; - t3 = a[0].re - t8; - t8 += a[0].re; - a[0].re = t8; - - a[4].re = t3 - t6; - t3 += t6; - a[6].re = t3; - - t7 = a[5].re; - t3 = a[1].re - t7; - t7 += a[1].re; - a[1].re = t7; - - t8 = a[7].im; - t6 = a[3].im - t8; - t8 += a[3].im; - a[3].im = t8; - t1 = t3 - t6; - t3 += t6; - - t7 = a[5].im; - t4 = a[1].im - t7; - t7 += a[1].im; - a[1].im = t7; - - t8 = a[7].re; - t5 = a[3].re - t8; - t8 += a[3].re; - a[3].re = t8; - - t2 = t4 - t5; - t4 += t5; - - t6 = t1 - t4; - t8 = sqrthalf; - t6 *= t8; - a[5].re = a[4].re - t6; - t1 += t4; - t1 *= t8; - a[5].im = a[4].im - t1; - t6 += a[4].re; - a[4].re = t6; - t1 += a[4].im; - a[4].im = t1; - - t5 = t2 - t3; - t5 *= t8; - a[7].im = a[6].im - t5; - t2 += t3; - t2 *= t8; - a[7].re = a[6].re - t2; - t2 += a[6].re; - a[6].re = t2; - t5 += a[6].im; - a[6].im = t5; - - c4(a); -} - -static void c16(register WDL_FFT_COMPLEX *a) -{ - register WDL_FFT_REAL t1, t2, t3, t4, t5, t6, t7, t8; - - TRANSFORMZERO(a[0],a[4],a[8],a[12]); - TRANSFORM(a[1],a[5],a[9],a[13],d16[0].re,d16[0].im); - TRANSFORMHALF(a[2],a[6],a[10],a[14]); - TRANSFORM(a[3],a[7],a[11],a[15],d16[0].im,d16[0].re); - c4(a + 8); - c4(a + 12); - - c8(a); -} - -/* a[0...8n-1], w[0...2n-2]; n >= 2 */ -static void cpass(register WDL_FFT_COMPLEX *a,register const WDL_FFT_COMPLEX *w,register unsigned int n) -{ - register WDL_FFT_REAL t1, t2, t3, t4, t5, t6, t7, t8; - register WDL_FFT_COMPLEX *a1; - register WDL_FFT_COMPLEX *a2; - register WDL_FFT_COMPLEX *a3; - - a2 = a + 4 * n; - a1 = a + 2 * n; - a3 = a2 + 2 * n; - --n; - - TRANSFORMZERO(a[0],a1[0],a2[0],a3[0]); - TRANSFORM(a[1],a1[1],a2[1],a3[1],w[0].re,w[0].im); - - for (;;) { - TRANSFORM(a[2],a1[2],a2[2],a3[2],w[1].re,w[1].im); - TRANSFORM(a[3],a1[3],a2[3],a3[3],w[2].re,w[2].im); - if (!--n) break; - a += 2; - a1 += 2; - a2 += 2; - a3 += 2; - w += 2; - } -} - -static void c32(register WDL_FFT_COMPLEX *a) -{ - cpass(a,d32,4); - c8(a + 16); - c8(a + 24); - c16(a); -} - -static void c64(register WDL_FFT_COMPLEX *a) -{ - cpass(a,d64,8); - c16(a + 32); - c16(a + 48); - c32(a); -} - -static void c128(register WDL_FFT_COMPLEX *a) -{ - cpass(a,d128,16); - c32(a + 64); - c32(a + 96); - c64(a); -} - -static void c256(register WDL_FFT_COMPLEX *a) -{ - cpass(a,d256,32); - c64(a + 128); - c64(a + 192); - c128(a); -} - -static void c512(register WDL_FFT_COMPLEX *a) -{ - cpass(a,d512,64); - c128(a + 384); - c128(a + 256); - c256(a); -} - -/* a[0...8n-1], w[0...n-2]; n even, n >= 4 */ -static void cpassbig(register WDL_FFT_COMPLEX *a,register const WDL_FFT_COMPLEX *w,register unsigned int n) -{ - register WDL_FFT_REAL t1, t2, t3, t4, t5, t6, t7, t8; - register WDL_FFT_COMPLEX *a1; - register WDL_FFT_COMPLEX *a2; - register WDL_FFT_COMPLEX *a3; - register unsigned int k; - - a2 = a + 4 * n; - a1 = a + 2 * n; - a3 = a2 + 2 * n; - k = n - 2; - - TRANSFORMZERO(a[0],a1[0],a2[0],a3[0]); - TRANSFORM(a[1],a1[1],a2[1],a3[1],w[0].re,w[0].im); - a += 2; - a1 += 2; - a2 += 2; - a3 += 2; - - do { - TRANSFORM(a[0],a1[0],a2[0],a3[0],w[1].re,w[1].im); - TRANSFORM(a[1],a1[1],a2[1],a3[1],w[2].re,w[2].im); - a += 2; - a1 += 2; - a2 += 2; - a3 += 2; - w += 2; - } while (k -= 2); - - TRANSFORMHALF(a[0],a1[0],a2[0],a3[0]); - TRANSFORM(a[1],a1[1],a2[1],a3[1],w[0].im,w[0].re); - a += 2; - a1 += 2; - a2 += 2; - a3 += 2; - - k = n - 2; - do { - TRANSFORM(a[0],a1[0],a2[0],a3[0],w[-1].im,w[-1].re); - TRANSFORM(a[1],a1[1],a2[1],a3[1],w[-2].im,w[-2].re); - a += 2; - a1 += 2; - a2 += 2; - a3 += 2; - w -= 2; - } while (k -= 2); -} - - -static void c1024(register WDL_FFT_COMPLEX *a) -{ - cpassbig(a,d1024,128); - c256(a + 768); - c256(a + 512); - c512(a); -} - -static void c2048(register WDL_FFT_COMPLEX *a) -{ - cpassbig(a,d2048,256); - c512(a + 1536); - c512(a + 1024); - c1024(a); -} - -static void c4096(register WDL_FFT_COMPLEX *a) -{ - cpassbig(a,d4096,512); - c1024(a + 3072); - c1024(a + 2048); - c2048(a); -} - -static void c8192(register WDL_FFT_COMPLEX *a) -{ - cpassbig(a,d8192,1024); - c2048(a + 6144); - c2048(a + 4096); - c4096(a); -} - -static void c16384(register WDL_FFT_COMPLEX *a) -{ - cpassbig(a,d16384,2048); - c4096(a + 8192 + 4096); - c4096(a + 8192); - c8192(a); -} - -static void c32768(register WDL_FFT_COMPLEX *a) -{ - cpassbig(a,d32768,4096); - c8192(a + 16384 + 8192); - c8192(a + 16384); - c16384(a); -} - - -/* n even, n > 0 */ -void WDL_fft_complexmul(WDL_FFT_COMPLEX *a,WDL_FFT_COMPLEX *b,int n) -{ - register WDL_FFT_REAL t1, t2, t3, t4, t5, t6, t7, t8; - if (n<2 || (n&1)) return; - - do { - t1 = a[0].re * b[0].re; - t2 = a[0].im * b[0].im; - t3 = a[0].im * b[0].re; - t4 = a[0].re * b[0].im; - t5 = a[1].re * b[1].re; - t6 = a[1].im * b[1].im; - t7 = a[1].im * b[1].re; - t8 = a[1].re * b[1].im; - t1 -= t2; - t3 += t4; - t5 -= t6; - t7 += t8; - a[0].re = t1; - a[1].re = t5; - a[0].im = t3; - a[1].im = t7; - a += 2; - b += 2; - } while (n -= 2); -} - -void WDL_fft_complexmul2(WDL_FFT_COMPLEX *c, WDL_FFT_COMPLEX *a, WDL_FFT_COMPLEX *b, int n) -{ - register WDL_FFT_REAL t1, t2, t3, t4, t5, t6, t7, t8; - if (n<2 || (n&1)) return; - - do { - t1 = a[0].re * b[0].re; - t2 = a[0].im * b[0].im; - t3 = a[0].im * b[0].re; - t4 = a[0].re * b[0].im; - t5 = a[1].re * b[1].re; - t6 = a[1].im * b[1].im; - t7 = a[1].im * b[1].re; - t8 = a[1].re * b[1].im; - t1 -= t2; - t3 += t4; - t5 -= t6; - t7 += t8; - c[0].re = t1; - c[1].re = t5; - c[0].im = t3; - c[1].im = t7; - a += 2; - b += 2; - c += 2; - } while (n -= 2); -} -void WDL_fft_complexmul3(WDL_FFT_COMPLEX *c, WDL_FFT_COMPLEX *a, WDL_FFT_COMPLEX *b, int n) -{ - register WDL_FFT_REAL t1, t2, t3, t4, t5, t6, t7, t8; - if (n<2 || (n&1)) return; - - do { - t1 = a[0].re * b[0].re; - t2 = a[0].im * b[0].im; - t3 = a[0].im * b[0].re; - t4 = a[0].re * b[0].im; - t5 = a[1].re * b[1].re; - t6 = a[1].im * b[1].im; - t7 = a[1].im * b[1].re; - t8 = a[1].re * b[1].im; - t1 -= t2; - t3 += t4; - t5 -= t6; - t7 += t8; - c[0].re += t1; - c[1].re += t5; - c[0].im += t3; - c[1].im += t7; - a += 2; - b += 2; - c += 2; - } while (n -= 2); -} - - -static inline void u4(register WDL_FFT_COMPLEX *a) -{ - register WDL_FFT_REAL t1, t2, t3, t4, t5, t6, t7, t8; - - t1 = VOL a[1].re; - t3 = a[0].re - t1; - t6 = VOL a[2].re; - t1 += a[0].re; - t8 = a[3].re - t6; - t6 += a[3].re; - a[0].re = t1 + t6; - t1 -= t6; - a[2].re = t1; - - t2 = VOL a[1].im; - t4 = a[0].im - t2; - t2 += a[0].im; - t5 = VOL a[3].im; - a[1].im = t4 + t8; - t4 -= t8; - a[3].im = t4; - - t7 = a[2].im - t5; - t5 += a[2].im; - a[1].re = t3 + t7; - t3 -= t7; - a[3].re = t3; - a[0].im = t2 + t5; - t2 -= t5; - a[2].im = t2; -} - -static void u8(register WDL_FFT_COMPLEX *a) -{ - register WDL_FFT_REAL t1, t2, t3, t4, t5, t6, t7, t8; - - u4(a); - - t1 = a[5].re; - a[5].re = a[4].re - t1; - t1 += a[4].re; - - t3 = a[7].re; - a[7].re = a[6].re - t3; - t3 += a[6].re; - - t8 = t3 - t1; - t1 += t3; - - t6 = a[2].im - t8; - t8 += a[2].im; - a[2].im = t8; - - t5 = a[0].re - t1; - a[4].re = t5; - t1 += a[0].re; - a[0].re = t1; - - t2 = a[5].im; - a[5].im = a[4].im - t2; - t2 += a[4].im; - - t4 = a[7].im; - a[7].im = a[6].im - t4; - t4 += a[6].im; - - a[6].im = t6; - - t7 = t2 - t4; - t2 += t4; - - t3 = a[2].re - t7; - a[6].re = t3; - t7 += a[2].re; - a[2].re = t7; - - t6 = a[0].im - t2; - a[4].im = t6; - t2 += a[0].im; - a[0].im = t2; - - t6 = sqrthalf; - - t1 = a[5].re; - t2 = a[5].im - t1; - t2 *= t6; - t1 += a[5].im; - t1 *= t6; - t4 = a[7].im; - t3 = a[7].re - t4; - t3 *= t6; - t4 += a[7].re; - t4 *= t6; - - t8 = t3 - t1; - t1 += t3; - t7 = t2 - t4; - t2 += t4; - - t4 = a[3].im - t8; - a[7].im = t4; - t5 = a[1].re - t1; - a[5].re = t5; - t3 = a[3].re - t7; - a[7].re = t3; - t6 = a[1].im - t2; - a[5].im = t6; - - t8 += a[3].im; - a[3].im = t8; - t1 += a[1].re; - a[1].re = t1; - t7 += a[3].re; - a[3].re = t7; - t2 += a[1].im; - a[1].im = t2; -} - -static void u16(register WDL_FFT_COMPLEX *a) -{ - register WDL_FFT_REAL t1, t2, t3, t4, t5, t6, t7, t8; - - u8(a); - u4(a + 8); - u4(a + 12); - - UNTRANSFORMZERO(a[0],a[4],a[8],a[12]); - UNTRANSFORMHALF(a[2],a[6],a[10],a[14]); - UNTRANSFORM(a[1],a[5],a[9],a[13],d16[0].re,d16[0].im); - UNTRANSFORM(a[3],a[7],a[11],a[15],d16[0].im,d16[0].re); -} - -/* a[0...8n-1], w[0...2n-2] */ -static void upass(register WDL_FFT_COMPLEX *a,register const WDL_FFT_COMPLEX *w,register unsigned int n) -{ - register WDL_FFT_REAL t1, t2, t3, t4, t5, t6, t7, t8; - register WDL_FFT_COMPLEX *a1; - register WDL_FFT_COMPLEX *a2; - register WDL_FFT_COMPLEX *a3; - - a2 = a + 4 * n; - a1 = a + 2 * n; - a3 = a2 + 2 * n; - n -= 1; - - UNTRANSFORMZERO(a[0],a1[0],a2[0],a3[0]); - UNTRANSFORM(a[1],a1[1],a2[1],a3[1],w[0].re,w[0].im); - - for (;;) { - UNTRANSFORM(a[2],a1[2],a2[2],a3[2],w[1].re,w[1].im); - UNTRANSFORM(a[3],a1[3],a2[3],a3[3],w[2].re,w[2].im); - if (!--n) break; - a += 2; - a1 += 2; - a2 += 2; - a3 += 2; - w += 2; - } -} - -static void u32(register WDL_FFT_COMPLEX *a) -{ - u16(a); - u8(a + 16); - u8(a + 24); - upass(a,d32,4); -} - -static void u64(register WDL_FFT_COMPLEX *a) -{ - u32(a); - u16(a + 32); - u16(a + 48); - upass(a,d64,8); -} - -static void u128(register WDL_FFT_COMPLEX *a) -{ - u64(a); - u32(a + 64); - u32(a + 96); - upass(a,d128,16); -} - -static void u256(register WDL_FFT_COMPLEX *a) -{ - u128(a); - u64(a + 128); - u64(a + 192); - upass(a,d256,32); -} - -static void u512(register WDL_FFT_COMPLEX *a) -{ - u256(a); - u128(a + 256); - u128(a + 384); - upass(a,d512,64); -} - - -/* a[0...8n-1], w[0...n-2]; n even, n >= 4 */ -static void upassbig(register WDL_FFT_COMPLEX *a,register const WDL_FFT_COMPLEX *w,register unsigned int n) -{ - register WDL_FFT_REAL t1, t2, t3, t4, t5, t6, t7, t8; - register WDL_FFT_COMPLEX *a1; - register WDL_FFT_COMPLEX *a2; - register WDL_FFT_COMPLEX *a3; - register unsigned int k; - - a2 = a + 4 * n; - a1 = a + 2 * n; - a3 = a2 + 2 * n; - k = n - 2; - - UNTRANSFORMZERO(a[0],a1[0],a2[0],a3[0]); - UNTRANSFORM(a[1],a1[1],a2[1],a3[1],w[0].re,w[0].im); - a += 2; - a1 += 2; - a2 += 2; - a3 += 2; - - do { - UNTRANSFORM(a[0],a1[0],a2[0],a3[0],w[1].re,w[1].im); - UNTRANSFORM(a[1],a1[1],a2[1],a3[1],w[2].re,w[2].im); - a += 2; - a1 += 2; - a2 += 2; - a3 += 2; - w += 2; - } while (k -= 2); - - UNTRANSFORMHALF(a[0],a1[0],a2[0],a3[0]); - UNTRANSFORM(a[1],a1[1],a2[1],a3[1],w[0].im,w[0].re); - a += 2; - a1 += 2; - a2 += 2; - a3 += 2; - - k = n - 2; - do { - UNTRANSFORM(a[0],a1[0],a2[0],a3[0],w[-1].im,w[-1].re); - UNTRANSFORM(a[1],a1[1],a2[1],a3[1],w[-2].im,w[-2].re); - a += 2; - a1 += 2; - a2 += 2; - a3 += 2; - w -= 2; - } while (k -= 2); -} - - - -static void u1024(register WDL_FFT_COMPLEX *a) -{ - u512(a); - u256(a + 512); - u256(a + 768); - upassbig(a,d1024,128); -} - -static void u2048(register WDL_FFT_COMPLEX *a) -{ - u1024(a); - u512(a + 1024); - u512(a + 1536); - upassbig(a,d2048,256); -} - - -static void u4096(register WDL_FFT_COMPLEX *a) -{ - u2048(a); - u1024(a + 2048); - u1024(a + 3072); - upassbig(a,d4096,512); -} - -static void u8192(register WDL_FFT_COMPLEX *a) -{ - u4096(a); - u2048(a + 4096); - u2048(a + 6144); - upassbig(a,d8192,1024); -} - -static void u16384(register WDL_FFT_COMPLEX *a) -{ - u8192(a); - u4096(a + 8192); - u4096(a + 8192 + 4096); - upassbig(a,d16384,2048); -} - -static void u32768(register WDL_FFT_COMPLEX *a) -{ - u16384(a); - u8192(a + 16384); - u8192(a + 16384 + 8192 ); - upassbig(a,d32768,4096); -} - - -static void __fft_gen(WDL_FFT_COMPLEX *buf, const WDL_FFT_COMPLEX *buf2, int sz, int isfull) -{ - int x; - double div=PI*0.25/(sz+1); - - if (isfull) div*=2.0; - - for (x = 0; x < sz; x ++) - { - if (!(x & 1) || !buf2) - { - buf[x].re = (WDL_FFT_REAL) cos((x+1)*div); - buf[x].im = (WDL_FFT_REAL) sin((x+1)*div); - } - else - { - buf[x].re = buf2[x >> 1].re; - buf[x].im = buf2[x >> 1].im; - } - } -} - -#ifndef WDL_FFT_NO_PERMUTE - -static unsigned int fftfreq_c(unsigned int i,unsigned int n) -{ - unsigned int m; - - if (n <= 2) return i; - - m = n >> 1; - if (i < m) return fftfreq_c(i,m) << 1; - - i -= m; - m >>= 1; - if (i < m) return (fftfreq_c(i,m) << 2) + 1; - i -= m; - return ((fftfreq_c(i,m) << 2) - 1) & (n - 1); -} - -static int _idxperm[2<> 1, quart = half >> 1, eighth = quart >> 1; - const int *permute = WDL_fft_permute_tab(half); - unsigned int i, j; - - WDL_FFT_COMPLEX *p, *q, tw, sum, diff; - WDL_FFT_REAL tw1, tw2; - - if (!isInverse) - { - WDL_fft((WDL_FFT_COMPLEX*)buf, half, isInverse); - r2(buf); - } - else - { - v2(buf); - } - - /* Source: http://www.katjaas.nl/realFFT/realFFT2.html */ - - for (i = 1; i < quart; ++i) - { - p = (WDL_FFT_COMPLEX*)buf + permute[i]; - q = (WDL_FFT_COMPLEX*)buf + permute[half - i]; - -/* tw.re = cos(2*PI * i / len); - tw.im = sin(2*PI * i / len); */ - - if (i < eighth) - { - j = i - 1; - tw.re = d[j].re; - tw.im = d[j].im; - } - else if (i > eighth) - { - j = quart - i - 1; - tw.re = d[j].im; - tw.im = d[j].re; - } - else - { - tw.re = tw.im = sqrthalf; - } - - if (!isInverse) tw.re = -tw.re; - - sum.re = p->re + q->re; - sum.im = p->im + q->im; - diff.re = p->re - q->re; - diff.im = p->im - q->im; - - tw1 = tw.re * sum.im + tw.im * diff.re; - tw2 = tw.im * sum.im - tw.re * diff.re; - - p->re = sum.re - tw1; - p->im = diff.im - tw2; - q->re = sum.re + tw1; - q->im = -(diff.im + tw2); - } - - p = (WDL_FFT_COMPLEX*)buf + permute[i]; - p->re *= 2; - p->im *= -2; - - if (isInverse) WDL_fft((WDL_FFT_COMPLEX*)buf, half, isInverse); -} - -void WDL_real_fft(WDL_FFT_REAL* buf, int len, int isInverse) -{ - switch (len) - { - case 2: if (!isInverse) r2(buf); else v2(buf); break; - case 4: case 8: two_for_one(buf, 0, len, isInverse); break; -#define TMP(x) case x: two_for_one(buf, d##x, len, isInverse); break; - TMP(16) - TMP(32) - TMP(64) - TMP(128) - TMP(256) - TMP(512) - TMP(1024) - TMP(2048) - TMP(4096) - TMP(8192) - TMP(16384) - TMP(32768) -#undef TMP - } -} diff --git a/oversampling/WDL/fft.h b/oversampling/WDL/fft.h deleted file mode 100644 index d2be245..0000000 --- a/oversampling/WDL/fft.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - WDL - fft.h - Copyright (C) 2006 and later Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - - - This file defines the interface to the WDL FFT library. These routines are based on the - DJBFFT library, which are Copyright 1999 D. J. Bernstein, djb@pobox.com - - The DJB FFT web page is: http://cr.yp.to/djbfft.html - -*/ - -#ifndef _WDL_FFT_H_ -#define _WDL_FFT_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef WDL_FFT_REALSIZE -#define WDL_FFT_REALSIZE 4 -#endif - -#if WDL_FFT_REALSIZE == 4 -typedef float WDL_FFT_REAL; -#elif WDL_FFT_REALSIZE == 8 -typedef double WDL_FFT_REAL; -#else -#error invalid FFT item size -#endif - -typedef struct { - WDL_FFT_REAL re; - WDL_FFT_REAL im; -} WDL_FFT_COMPLEX; - -extern void WDL_fft_init(); - -extern void WDL_fft_complexmul(WDL_FFT_COMPLEX *dest, WDL_FFT_COMPLEX *src, int len); -extern void WDL_fft_complexmul2(WDL_FFT_COMPLEX *dest, WDL_FFT_COMPLEX *src, WDL_FFT_COMPLEX *src2, int len); -extern void WDL_fft_complexmul3(WDL_FFT_COMPLEX *destAdd, WDL_FFT_COMPLEX *src, WDL_FFT_COMPLEX *src2, int len); - -/* Expects WDL_FFT_COMPLEX input[0..len-1] scaled by 1.0/len, returns -WDL_FFT_COMPLEX output[0..len-1] order by WDL_fft_permute(len). */ -extern void WDL_fft(WDL_FFT_COMPLEX *, int len, int isInverse); - -/* Expects WDL_FFT_REAL input[0..len-1] scaled by 0.5/len, returns -WDL_FFT_COMPLEX output[0..len/2-1], for len >= 4 order by -WDL_fft_permute(len/2). Note that output[len/2].re is stored in -output[0].im. */ -extern void WDL_real_fft(WDL_FFT_REAL *, int len, int isInverse); - -extern int WDL_fft_permute(int fftsize, int idx); -extern int *WDL_fft_permute_tab(int fftsize); - -#ifdef __cplusplus -}; -#endif - -#endif \ No newline at end of file diff --git a/oversampling/WDL/filebrowse.cpp b/oversampling/WDL/filebrowse.cpp deleted file mode 100644 index f2d979e..0000000 --- a/oversampling/WDL/filebrowse.cpp +++ /dev/null @@ -1,493 +0,0 @@ -// todo: support win7/vista extensions rather than GetOpenFileName? -- merge win7filedialog into here. - - -#include "filebrowse.h" - -#include "win32_utf8.h" -#include "wdlcstring.h" - - -#ifdef _WIN32 - #ifdef _MSC_VER // todo: win7filedialog.cpp support for mingw32 - #define WDL_FILEBROWSE_WIN7VISTAMODE - #endif -#endif - - - - -#ifdef WDL_FILEBROWSE_WIN7VISTAMODE // win7/vista file dialog support - #include "win7filedialog.cpp" - - // stuff since win7filedialog.h collides with shlobj.h below - #define tagSHCONTF tagSHCONTF___ - #define SHCONTF SHCONTF___ - #define SHCONTF_FOLDERS SHCONTF_FOLDERS___ - #define SHCONTF_NONFOLDERS SHCONTF_NONFOLDERS___ - #define SHCONTF_INCLUDEHIDDEN SHCONTF_INCLUDEHIDDEN___ - #define SHCONTF_SHAREABLE SHCONTF_SHAREABLE__ - #define SHCONTF_INIT_ON_FIRST_NEXT SHCONTF_INIT_ON_FIRST_NEXT__ - #define SHCONTF_NETPRINTERSRCH SHCONTF_NETPRINTERSRCH__ - #define SHCONTF_STORAGE SHCONTF_STORAGE__ -#endif - - -#ifdef _WIN32 -// include after win7filedialog.* - - #include - #include -#endif - -#ifndef BIF_NEWDIALOGSTYLE - #define BIF_NEWDIALOGSTYLE 0x40 -#endif - - -static void WDL_fixfnforopenfn(char *buf) -{ - char *p=buf; - while (*p) - { - if (WDL_IS_DIRCHAR(*p)) *p = WDL_DIRCHAR; - p++; - } -#ifdef _WIN32 - if (buf[0] && buf[1] == ':') - { - p=buf+2; - char *op=p; - while (*p) - { - while (p[0]==WDL_DIRCHAR && p[1] == WDL_DIRCHAR) p++; - *op++ = *p++; - } - *op=0; - } -#endif -} - - -#ifdef _WIN32 -static int CALLBACK WINAPI WDL_BrowseCallbackProc( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) -{ - switch (uMsg) - { - case BFFM_INITIALIZED: - { - if (lpData && ((char *)lpData)[0]) - { -#ifndef WDL_NO_SUPPORT_UTF8 - WDL_UTF8_SendBFFM_SETSEL(hwnd, (const char *)lpData); -#else - SendMessage(hwnd, BFFM_SETSELECTION, 1, lpData); -#endif - } - break; - } - } - return 0; -} -#endif - - -bool WDL_ChooseDirectory(HWND parent, const char *text, const char *initialdir, char *fn, int fnsize, bool preservecwd) -{ - char olddir[2048]; - GetCurrentDirectory(sizeof(olddir),olddir); -#ifdef _WIN32 - char name[4096]; - lstrcpyn_safe(name,initialdir?initialdir:"",sizeof(name)); - BROWSEINFO bi={parent,NULL, name, text, BIF_RETURNONLYFSDIRS|BIF_NEWDIALOGSTYLE, WDL_BrowseCallbackProc, (LPARAM)name,}; - LPITEMIDLIST idlist = SHBrowseForFolderUTF8( &bi ); - if (idlist && SHGetPathFromIDListUTF8(idlist, name, sizeof(name))) - { - IMalloc *m; - SHGetMalloc(&m); - m->Free(idlist); - lstrcpyn_safe(fn,name,fnsize); - return true; - } - return false; - -#else - bool r = BrowseForDirectory(text,initialdir,fn,fnsize); - if (preservecwd) SetCurrentDirectory(olddir); - return r; -#endif -} - - -#ifdef _WIN32 -struct WDL_FileBrowse_Dis { - enum { DLSZ = 10 }; - WDL_FileBrowse_Dis(HWND par) - { - m_par = par; - memset(m_dislist,0,sizeof(m_dislist)); - if (par) EnableOwnerWnds(par,0); - } - ~WDL_FileBrowse_Dis() - { - if (m_dislist[0]) EnableOwnerWnds(m_par, 1); - } - void EnableOwnerWnds(HWND p, int en) - { - int limit = 0, dlsz = 0; - HWND t; - while (NULL != (t = GetParent(p)) && limit++ < 20) - { - p = t; - if (!(GetWindowLong(p,GWL_STYLE)&WS_CHILD) && !en != !IsWindowEnabled(p)) - { - if (!en) - { - EnableWindow(p,0); - m_dislist[dlsz] = p; - if (++dlsz == DLSZ) break; - } - else - { - for (dlsz = 0; dlsz < DLSZ && m_dislist[dlsz] != p && m_dislist[dlsz]; dlsz++); - if (dlsz < DLSZ && m_dislist[dlsz] == p) EnableWindow(p,1); - } - } - } - } - HWND m_par, m_dislist[DLSZ]; -}; -#endif - -#ifdef _WIN32 -bool wdl_use_legacy_filebrowse; -#endif - -bool WDL_ChooseFileForSave(HWND parent, - const char *text, - const char *initialdir, - const char *initialfile, - const char *extlist, - const char *defext, - bool preservecwd, - char *fn, - int fnsize, - const char *dlgid, - void *dlgProc, -#ifdef _WIN32 - HINSTANCE hInstance -#else - struct SWELL_DialogResourceIndex *reshead -#endif - ) -{ - char cwd[2048]; - GetCurrentDirectory(sizeof(cwd),cwd); - - while (defext && *defext == '.') defext++; // this function can be passed defext of either .wav or wav, we always want it to be the latter - -#ifdef _WIN32 - WDL_FileBrowse_Dis win32disfix(parent); - char temp[4096]; - memset(temp,0,sizeof(temp)); - if (initialfile) lstrcpyn_safe(temp,initialfile,sizeof(temp)); - WDL_fixfnforopenfn(temp); - -#ifdef WDL_FILEBROWSE_WIN7VISTAMODE - if (!wdl_use_legacy_filebrowse) - { - Win7FileDialog fd(text, 1); - if(fd.inited()) - { - fd.addOptions(FOS_DONTADDTORECENT); - //vista+ file open dialog - char olddir[2048]; - GetCurrentDirectory(sizeof(olddir),olddir); - - fd.setFilterList(extlist); - if (defext) - { - fd.setDefaultExtension(defext); - - int i = 0; - const char *p = extlist; - while(*p) - { - if(*p) p+=strlen(p)+1; - if(!*p) break; - const char *ext = WDL_get_fileext(p); - if (*ext == '.') ext++; - if(!stricmp(ext,defext)) - { - fd.setFileTypeIndex(i+1); - break; - } - i++; - p+=strlen(p)+1; - } - } - fd.setFolder(initialdir?initialdir:olddir, 0); - if(initialfile) - { - //check for folder name - if (WDL_remove_filepart(temp)) - { - //folder found - fd.setFolder(temp, 0); - fd.setFilename(temp + strlen(temp) + 1); - } - else - fd.setFilename(*temp ? temp : initialfile); - } - fd.setTemplate(hInstance, dlgid, (LPOFNHOOKPROC)dlgProc); - - if(fd.show(parent)) - { - //ifilesavedialog saves the last folder automatically - fd.getResult(fn, fnsize); - - if (preservecwd) SetCurrentDirectory(olddir); - return true; - } - - if (preservecwd) SetCurrentDirectory(olddir); - return NULL; - } - } -#endif - - - OPENFILENAME l={sizeof(l),parent, hInstance, extlist, NULL,0, 0, temp, sizeof(temp)-1, NULL, 0, initialdir&&initialdir[0] ? initialdir : cwd, text, - OFN_HIDEREADONLY|OFN_EXPLORER|OFN_OVERWRITEPROMPT,0,0,defext, 0, (LPOFNHOOKPROC)dlgProc, dlgid}; - - if (hInstance&&dlgProc&&dlgid) l.Flags |= OFN_ENABLEHOOK|OFN_ENABLETEMPLATE|OFN_ENABLESIZING; - if (preservecwd) l.Flags |= OFN_NOCHANGEDIR; - - if (!GetSaveFileName(&l)||!temp[0]) - { - if (preservecwd) SetCurrentDirectory(cwd); - return false; - } - if (preservecwd) SetCurrentDirectory(cwd); - lstrcpyn_safe(fn,temp,fnsize); - return true; - -#else - BrowseFile_SetTemplate(dlgid,(DLGPROC)dlgProc,reshead); - char if_temp[4096]; - if (initialfile && *initialfile) - { - lstrcpyn_safe(if_temp,initialfile,sizeof(if_temp)); - WDL_fixfnforopenfn(if_temp); - initialfile = if_temp; - } - else - { - if (defext && *defext) - { - snprintf(if_temp,sizeof(if_temp),".%s",defext); // SWELL treats initialfile of ".ext" as default extension - initialfile = if_temp; - } - } - - bool r = BrowseForSaveFile(text,initialdir,initialfile,extlist,fn,fnsize); - - if (preservecwd) SetCurrentDirectory(cwd); - - return r; -#endif -} - - -char *WDL_ChooseFileForOpen2(HWND parent, - const char *text, - const char *initialdir, - const char *initialfile, - const char *extlist, - const char *defext, - - bool preservecwd, - int allowmul, - - const char *dlgid, - void *dlgProc, -#ifdef _WIN32 - HINSTANCE hInstance -#else - struct SWELL_DialogResourceIndex *reshead -#endif - ) -{ - char olddir[2048]; - GetCurrentDirectory(sizeof(olddir),olddir); - -#ifdef _WIN32 - WDL_FileBrowse_Dis win32disfix(parent); - -#ifdef WDL_FILEBROWSE_WIN7VISTAMODE - if (!wdl_use_legacy_filebrowse && allowmul!=1) - { - Win7FileDialog fd(text); - if(fd.inited()) - { - //vista+ file open dialog - fd.addOptions(FOS_FILEMUSTEXIST|(allowmul?FOS_ALLOWMULTISELECT:0)); - fd.setFilterList(extlist); - if (defext) - { - fd.setDefaultExtension(defext); - - int i = 0; - const char *p = extlist; - while(*p) - { - if(*p) p+=strlen(p)+1; - if(!*p) break; - if(WDL_stristr(p, defext)) - { - fd.setFileTypeIndex(i+1); - break; - } - i++; - p+=strlen(p)+1; - } - } - fd.setFolder(initialdir?initialdir:olddir, 0); - fd.setTemplate(hInstance, dlgid, (LPOFNHOOKPROC)dlgProc); - if(initialfile) - { - char temp[4096]; - lstrcpyn_safe(temp,initialfile,sizeof(temp)); - WDL_fixfnforopenfn(temp); - //check for folder name - if (WDL_remove_filepart(temp)) - { - //folder found - fd.setFolder(temp, 0); - fd.setFilename(temp + strlen(temp) + 1); - } - else - fd.setFilename(temp); - } - - if(fd.show(parent)) - { - char *ret=NULL; - char temp[4096]; - temp[0]=0; - - //ifileopendialog saves the last folder automatically - if (!allowmul) - { - fd.getResult(temp, sizeof(temp)-1); - ret= temp[0] ? strdup(temp) : NULL; - } - else - { - char* p=NULL; - int totallen=0, cnt=fd.getResultCount(); - if (cnt>1) - { - // sets an empty path as 1st returned string for multipath support - // (when selecting files among search results for ex.) - ret = strdup(""); - totallen=1; - } - - int i; - for (i=0; i -#else -#include "swell/swell.h" -#endif - -bool WDL_ChooseDirectory(HWND parent, const char *text, const char *initialdir, char *fn, int fnsize, bool preservecwd); -bool WDL_ChooseFileForSave(HWND parent, - const char *text, - const char *initialdir, - const char *initialfile, - const char *extlist, - const char *defext, - bool preservecwd, - char *fn, - int fnsize, - const char *dlgid=NULL, - void *dlgProc=NULL, -#ifdef _WIN32 - HINSTANCE hInstance=NULL -#else - struct SWELL_DialogResourceIndex *reshead=NULL -#endif - ); - - -char *WDL_ChooseFileForOpen(HWND parent, - const char *text, - const char *initialdir, - const char *initialfile, - const char *extlist, - const char *defext, - - bool preservecwd, - bool allowmul, - - const char *dlgid=NULL, - void *dlgProc=NULL, -#ifdef _WIN32 - HINSTANCE hInstance=NULL -#else - struct SWELL_DialogResourceIndex *reshead=NULL -#endif - ); - - -// allowmul=1: multi-selection in same folder, -// the double NULL terminated return value of WDL_ChooseFileForOpen2 is like: -// "some/single/path\0bla1.txt\0bla2.txt\0bla3.txt\0\0" -// allowmul=2: multi-selection with multipath support (vista+) -// the double NULL terminated return value of WDL_ChooseFileForOpen2 is like: -// "\0/some/path1/bla1.txt\0/some/path2/bla2.txt\0/some/path3/bla3.txt\0\0" -char *WDL_ChooseFileForOpen2(HWND parent, - const char *text, - const char *initialdir, - const char *initialfile, - const char *extlist, - const char *defext, - - bool preservecwd, - int allowmul, - - const char *dlgid=NULL, - void *dlgProc=NULL, -#ifdef _WIN32 - HINSTANCE hInstance=NULL -#else - struct SWELL_DialogResourceIndex *reshead=NULL -#endif - ); - - -#endif diff --git a/oversampling/WDL/filename.h b/oversampling/WDL/filename.h deleted file mode 100644 index bcad07b..0000000 --- a/oversampling/WDL/filename.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - WDL - filename.h - Copyright (C) 2005 and later, Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - -*/ - -#ifndef _WDL_FILENAME_H_ -#define _WDL_FILENAME_H_ - -#include "wdltypes.h" - -static WDL_STATICFUNC_UNUSED char WDL_filename_filterchar(char p, char repl='_', bool filterSlashes=true) -{ - if (p == '?' || - p == '*' || - (p > 0 && p <= 0x1f) || - p == ':' || - p == '\"' || - p == '|' || - p == '<' || - p == '>') - { - return repl; - } - - if (filterSlashes && (p == '/' || p == '\\' )) - { - return repl; - } - - return p; -} - -static WDL_STATICFUNC_UNUSED void WDL_filename_filterstr(char *rd, char repl='_', int path_filter_mode=1) -{ - char *wr, lc = WDL_DIRCHAR; - // path_filter_mode: - // 0 = remove leading slashes, consolidate duplicate slashes (use when filtering the filepart but allowing subdirectories) - // >0 = filter slashes (use when filtering the filepart, disallowing subdirectories) - // <0 = allow absolute paths, consolidate duplicate slashes (filtering a full path) - if (path_filter_mode<0) - { - #ifdef _WIN32 - if (rd[0] && rd[1] == ':' && WDL_IS_DIRCHAR(rd[2])) rd += 3; - else if (WDL_IS_DIRCHAR(rd[0]) && WDL_IS_DIRCHAR(rd[1])) rd += 2; - #else - if (WDL_IS_DIRCHAR(*rd)) rd++; - #endif - } - wr = rd; - while (*rd) - { - char r=WDL_filename_filterchar(*rd++,repl,path_filter_mode>0); - if (!r || (WDL_IS_DIRCHAR(r) && WDL_IS_DIRCHAR(lc))) continue; // filter multiple slashes in a row, or leading slash -#ifdef _WIN32 - if (r == ' ' && WDL_IS_DIRCHAR(lc)) continue; // filter space after slash (problematic on win32, allowed on macOS/linux) -#endif - *wr++ = lc = r; - } - *wr=0; -} - - - -#endif // _WDL_FILENAME_H_ diff --git a/oversampling/WDL/fileread.h b/oversampling/WDL/fileread.h deleted file mode 100644 index 83e88ce..0000000 --- a/oversampling/WDL/fileread.h +++ /dev/null @@ -1,847 +0,0 @@ -/* - WDL - fileread.h - Copyright (C) 2005 and later Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - - This file provides the WDL_FileRead object, which can be used to read files. - On windows systems it supports reading synchronous, asynchronous, memory mapped, and asynchronous unbuffered. - On non-windows systems it acts as a wrapper for fopen()/etc. - - -*/ - - -#ifndef _WDL_FILEREAD_H_ -#define _WDL_FILEREAD_H_ - - - - -#include "ptrlist.h" - - - -#if defined(_WIN32) && !defined(WDL_NO_WIN32_FILEREAD) - #ifndef WDL_WIN32_NATIVE_READ - #define WDL_WIN32_NATIVE_READ - #endif -#else - #ifdef WDL_WIN32_NATIVE_READ - #undef WDL_WIN32_NATIVE_READ - #endif - - #if !defined(WDL_NO_POSIX_FILEREAD) - #define WDL_POSIX_NATIVE_READ - #include - #include - #include - #include - #include - #ifdef __APPLE__ - #include - #include - #endif - extern struct stat wdl_stat_chk; - // if this fails on linux, use CFLAGS += -D_FILE_OFFSET_BITS=64 - typedef char wdl_fileread_assert_failed_stat_not_64[sizeof(wdl_stat_chk.st_size)!=8 ? -1 : 1]; - typedef char wdl_fileread_assert_failed_off_t_64[sizeof(off_t)!=8 ? -1 : 1]; - #endif - -#endif - - - -#ifdef _MSC_VER -#define WDL_FILEREAD_POSTYPE __int64 -#else -#define WDL_FILEREAD_POSTYPE long long -#endif -class WDL_FileRead -{ - -#ifdef WDL_WIN32_NATIVE_READ - - -class WDL_FileRead__ReadEnt -{ -public: - WDL_FileRead__ReadEnt(int sz, char *buf) - { - m_size=0; - memset(&m_ol,0,sizeof(m_ol)); - m_ol.hEvent=CreateEvent(NULL,TRUE,TRUE,NULL); - m_buf=buf; - } - ~WDL_FileRead__ReadEnt() - { - CloseHandle(m_ol.hEvent); - } - - OVERLAPPED m_ol; - DWORD m_size; - LPVOID m_buf; -}; - -#endif - -#if defined(_WIN32) && !defined(WDL_NO_SUPPORT_UTF8) - BOOL HasUTF8(const char *_str) - { - const unsigned char *str = (const unsigned char *)_str; - if (!str) return FALSE; - while (*str) - { - unsigned char c = *str; - if (c >= 0xC2) - { - if (c <= 0xDF && str[1] >=0x80 && str[1] <= 0xBF) return TRUE; - else if (c <= 0xEF && str[1] >=0x80 && str[1] <= 0xBF && str[2] >=0x80 && str[2] <= 0xBF) return TRUE; - else if (c <= 0xF4 && str[1] >=0x80 && str[1] <= 0xBF && str[2] >=0x80 && str[2] <= 0xBF) return TRUE; - } - str++; - if (((const char *)str-_str) >= 256) return TRUE; // long filenames get converted to wide - } - return FALSE; - } -#endif - -public: - // allow_async=1 for unbuffered async, 2 for buffered async, =-1 for unbuffered sync - // async aspect is unused on OS X, but the buffered mode affects F_NOCACHE - WDL_FileRead(const char *filename, int allow_async=1, int bufsize=8192, int nbufs=4, unsigned int mmap_minsize=0, unsigned int mmap_maxsize=0) : m_bufspace(4096 WDL_HEAPBUF_TRACEPARM("WDL_FileRead")) - { - m_async_hashaderr=false; - m_sync_bufmode_used=m_sync_bufmode_pos=0; - m_async_readpos=m_file_position=0; - m_fsize=0; - m_fsize_maychange=false; - m_syncrd_firstbuf=true; - m_mmap_view=0; - m_mmap_totalbufmode=0; - -#define WDL_UNBUF_ALIGN 8192 - if (bufsize&(WDL_UNBUF_ALIGN-1)) bufsize=(bufsize&~(WDL_UNBUF_ALIGN-1))+WDL_UNBUF_ALIGN; // ensure bufsize is multiple of 4kb - -#ifdef WDL_WIN32_NATIVE_READ - - m_mmap_fmap=0; - - #ifdef WDL_SUPPORT_WIN9X - const bool isNT = GetVersion()<0x80000000; - #else - const bool isNT = true; - #endif - m_async = isNT ? allow_async : 0; - - int flags=FILE_ATTRIBUTE_NORMAL; - if (m_async>0) - { - flags|=FILE_FLAG_OVERLAPPED; - if (m_async==1) flags|=FILE_FLAG_NO_BUFFERING; - } - else if (nbufs*bufsize>=WDL_UNBUF_ALIGN && !mmap_maxsize && m_async==-1) - flags|=FILE_FLAG_NO_BUFFERING; // non-async mode unbuffered if we do our own buffering - -#ifndef WDL_NO_SUPPORT_UTF8 - m_fh = INVALID_HANDLE_VALUE; - if (isNT && HasUTF8(filename)) // only convert to wide if there are UTF-8 chars - { - int szreq=MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,filename,-1,NULL,0); - if (szreq > 1000) - { - WDL_TypedBuf wfilename; - wfilename.Resize(szreq+20); - - if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,filename,-1,wfilename.Get(),wfilename.GetSize()-10)) - { - correctlongpath(wfilename.Get()); - m_fh = CreateFileW(wfilename.Get(),GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,flags,NULL); - if (m_fh == INVALID_HANDLE_VALUE && GetLastError()==ERROR_SHARING_VIOLATION) - { - m_fh = CreateFileW(wfilename.Get(),GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,flags,NULL); - m_fsize_maychange=true; - } - } - } - else - { - WCHAR wfilename[1024]; - - if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,filename,-1,wfilename,1024-10)) - { - correctlongpath(wfilename); - m_fh = CreateFileW(wfilename,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,flags,NULL); - if (m_fh == INVALID_HANDLE_VALUE && GetLastError()==ERROR_SHARING_VIOLATION) - { - m_fh = CreateFileW(wfilename,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,flags,NULL); - m_fsize_maychange=true; - } - } - } - } - if (m_fh == INVALID_HANDLE_VALUE) -#endif - { - m_fh = CreateFileA(filename,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,flags,NULL); - if (m_fh == INVALID_HANDLE_VALUE && GetLastError()==ERROR_SHARING_VIOLATION) - { - m_fh = CreateFileA(filename,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,flags,NULL); - m_fsize_maychange=true; - } - } - - if (m_fh != INVALID_HANDLE_VALUE) - { - DWORD h=0; - DWORD l=GetFileSize(m_fh,&h); - m_fsize=(((WDL_FILEREAD_POSTYPE)h)<<32)|l; - if (m_fsize<0 || (l == INVALID_FILE_SIZE && GetLastError() != NO_ERROR)) m_fsize=0; - - if (!h && l < mmap_maxsize && m_async<=0) - { - if (l >= mmap_minsize) - { - m_mmap_fmap=CreateFileMapping(m_fh,NULL,PAGE_READONLY,NULL,0,NULL); - if (m_mmap_fmap) - { - m_mmap_view=MapViewOfFile(m_mmap_fmap,FILE_MAP_READ,0,0,(int)m_fsize); - if (!m_mmap_view) - { - CloseHandle(m_mmap_fmap); - m_mmap_fmap=0; - } - else m_fsize_maychange=false; - } - } - else if (l>0) - { - m_mmap_totalbufmode = malloc(l); - if (m_mmap_totalbufmode) - { - DWORD sz; - ReadFile(m_fh,m_mmap_totalbufmode,l,&sz,NULL); - } - m_fsize_maychange=false; - } - } - - if (m_async>0) - { - m_async_bufsize=bufsize; - int x; - char *bptr=(char *)m_bufspace.Resize(nbufs*bufsize + (WDL_UNBUF_ALIGN-1)); - int a=((int)(INT_PTR)bptr)&(WDL_UNBUF_ALIGN-1); - if (a) bptr += WDL_UNBUF_ALIGN-a; - for (x = 0; x < nbufs; x ++) - { - WDL_FileRead__ReadEnt *t=new WDL_FileRead__ReadEnt(m_async_bufsize,bptr); - m_empties.Add(t); - bptr+=m_async_bufsize; - } - } - else if (!m_mmap_view && !m_mmap_totalbufmode && nbufs*bufsize>=WDL_UNBUF_ALIGN) - { - m_bufspace.Resize(nbufs*bufsize+(WDL_UNBUF_ALIGN-1)); - } - } - -#elif defined(WDL_POSIX_NATIVE_READ) - m_filedes_locked=false; - m_filedes_rdpos=0; - m_filedes=open(filename,O_RDONLY - // todo: use fcntl() for platforms when O_CLOEXEC is not available (if we ever need to support them) - // (currently the only platform that meets this criteria is macOS w/ old SDK, but we don't use execve() - // there -#ifdef O_CLOEXEC - | O_CLOEXEC -#endif - ); - if (m_filedes>=0) - { - if (flock(m_filedes,LOCK_SH|LOCK_NB)>=0) // get shared lock - m_filedes_locked=true; - else - m_fsize_maychange=true; // if couldnt get shared lock, then it may change - -#ifdef __APPLE__ - if (allow_async==1 || allow_async==-1) - { - struct statfs sfs; - if (fstatfs(m_filedes,&sfs)||(sfs.f_flags&MNT_LOCAL)) // don't use F_NOCACHE on nfs/smb/afp mounts, we need caching there! - fcntl(m_filedes,F_NOCACHE,1); - } -#endif - m_fsize=lseek(m_filedes,0,SEEK_END); - lseek(m_filedes,0,SEEK_SET); - if (m_fsize<0) m_fsize=0; - - if (m_fsize < mmap_maxsize) - { - if (m_fsize >= mmap_minsize) - { - m_mmap_view = mmap(NULL,(size_t)m_fsize,PROT_READ,MAP_SHARED,m_filedes,0); - if (m_mmap_view == MAP_FAILED) m_mmap_view = 0; - else m_fsize_maychange=false; - } - else - { - m_mmap_totalbufmode = malloc((size_t)m_fsize); - if (m_mmap_totalbufmode) - m_fsize = pread(m_filedes,m_mmap_totalbufmode,(size_t)m_fsize,0); - m_fsize_maychange=false; - } - } - } - if (!m_mmap_view && !m_mmap_totalbufmode && m_filedes>=0 && nbufs*bufsize>=WDL_UNBUF_ALIGN) - m_bufspace.Resize(nbufs*bufsize+(WDL_UNBUF_ALIGN-1)); - -#else - m_fp=fopen(filename,"rb"); - if(m_fp) - { - fseek(m_fp,0,SEEK_END); - m_fsize=ftell(m_fp); - fseek(m_fp,0,SEEK_SET); - } - if (m_fp && nbufs*bufsize>=WDL_UNBUF_ALIGN) - m_bufspace.Resize(nbufs*bufsize+(WDL_UNBUF_ALIGN-1)); -#endif - } - - ~WDL_FileRead() - { - free(m_mmap_totalbufmode); - m_mmap_totalbufmode=0; - -#ifdef WDL_WIN32_NATIVE_READ - int x; - for (x = 0; x < m_empties.GetSize();x ++) delete m_empties.Get(x); - m_empties.Empty(); - for (x = 0; x < m_full.GetSize();x ++) delete m_full.Get(x); - m_full.Empty(); - for (x = 0; x < m_pending.GetSize();x ++) - { - WaitForSingleObject(m_pending.Get(x)->m_ol.hEvent,INFINITE); - delete m_pending.Get(x); - } - m_pending.Empty(); - - if (m_mmap_view) UnmapViewOfFile(m_mmap_view); - m_mmap_view=0; - - if (m_mmap_fmap) CloseHandle(m_mmap_fmap); - m_mmap_fmap=0; - - if (m_fh != INVALID_HANDLE_VALUE) CloseHandle(m_fh); - m_fh=INVALID_HANDLE_VALUE; -#elif defined(WDL_POSIX_NATIVE_READ) - if (m_mmap_view) munmap(m_mmap_view,(size_t)m_fsize); - m_mmap_view=0; - if (m_filedes>=0) - { - if (m_filedes_locked) flock(m_filedes,LOCK_UN); // release shared lock - close(m_filedes); - } - m_filedes=-1; -#else - if (m_fp) fclose(m_fp); - m_fp=0; -#endif - - } - - bool IsOpen() - { -#ifdef WDL_WIN32_NATIVE_READ - return (m_fh != INVALID_HANDLE_VALUE); -#elif defined(WDL_POSIX_NATIVE_READ) - return m_filedes >= 0; -#else - return m_fp != NULL; -#endif - } - - void CloseHandlesIfFullyInMemory() - { - if (!m_mmap_totalbufmode) return; -#ifdef WDL_WIN32_NATIVE_READ - if (m_fh != INVALID_HANDLE_VALUE) - { - CloseHandle(m_fh); - m_fh=INVALID_HANDLE_VALUE; - } -#elif defined(WDL_POSIX_NATIVE_READ) - if (m_filedes>=0) - { - if (m_filedes_locked) flock(m_filedes,LOCK_UN); // release shared lock - close(m_filedes); - m_filedes=-1; - } -#else - if (m_fp) - { - fclose(m_fp); - m_fp=NULL; - } -#endif - } - -#ifdef WDL_WIN32_NATIVE_READ - - int RunReads() - { - while (m_pending.GetSize()) - { - WDL_FileRead__ReadEnt *ent=m_pending.Get(0); - DWORD s=0; - - if (!ent->m_size && !GetOverlappedResult(m_fh,&ent->m_ol,&s,FALSE)) break; - m_pending.Delete(0); - if (!ent->m_size) ent->m_size=s; - m_full.Add(ent); - } - - - if (m_empties.GetSize()>0) - { - if (m_async_readpos < m_file_position) m_async_readpos = m_file_position; - - if (m_async==1) m_async_readpos &= ~((WDL_FILEREAD_POSTYPE) WDL_UNBUF_ALIGN-1); - - if (m_async_readpos >= m_fsize) return 0; - - const int rdidx=m_empties.GetSize()-1; - WDL_FileRead__ReadEnt *t=m_empties.Get(rdidx); - - ResetEvent(t->m_ol.hEvent); - - *(WDL_FILEREAD_POSTYPE *)&t->m_ol.Offset = m_async_readpos; - - m_async_readpos += m_async_bufsize; - DWORD dw; - if (ReadFile(m_fh,t->m_buf,m_async_bufsize,&dw,&t->m_ol)) - { - if (!dw) return 1; - } - else - { - if (GetLastError() != ERROR_IO_PENDING) return 1; - dw=0; - } - t->m_size=dw; - m_empties.Delete(rdidx); - m_pending.Add(t); - } - return 0; - } - - int AsyncRead(char *buf, int maxlen) - { - int lenout=0; - if (m_file_position+maxlen > m_fsize) - { - maxlen=(int) (m_fsize-m_file_position); - } - if (maxlen<1) return 0; - - int errcnt=!!m_async_hashaderr; - do - { - while (m_full.GetSize() > 0) - { - WDL_FileRead__ReadEnt *ti=m_full.Get(0); - WDL_FILEREAD_POSTYPE tiofs=*(WDL_FILEREAD_POSTYPE *)&ti->m_ol.Offset; - if (m_file_position >= tiofs && m_file_position < tiofs + ti->m_size) - { - if (maxlen < 1) break; - - int l=ti->m_size-(int) (m_file_position-tiofs); - if (l > maxlen) l=maxlen; - - memcpy(buf,(char *)ti->m_buf+m_file_position - tiofs,l); - buf += l; - m_file_position += l; - maxlen -= l; - lenout += l; - } - else - { - m_empties.Add(ti); - m_full.Delete(0); - } - } - - if (maxlen > 0 && m_async_readpos != m_file_position) - { - int x; - for (x = 0; x < m_pending.GetSize(); x ++) - { - WDL_FileRead__ReadEnt *ent=m_pending.Get(x); - WDL_FILEREAD_POSTYPE tiofs=*(WDL_FILEREAD_POSTYPE *)&ent->m_ol.Offset; - if (m_file_position >= tiofs && m_file_position < tiofs + m_async_bufsize) break; - } - if (x == m_pending.GetSize()) - { - m_async_readpos=m_file_position; - } - } - - errcnt+=RunReads(); - - if (maxlen > 0 && m_pending.GetSize() && !m_full.GetSize()) - { - WDL_FileRead__ReadEnt *ent=m_pending.Get(0); - m_pending.Delete(0); - - if (ent->m_size) m_full.Add(ent); - else - { -// WaitForSingleObject(ent->m_ol.hEvent,INFINITE); - - DWORD s=0; - if (GetOverlappedResult(m_fh,&ent->m_ol,&s,TRUE) && s) - { - ent->m_size=s; - m_full.Add(ent); - } - else // failed read, set the error flag - { - errcnt++; - ent->m_size=0; - m_empties.Add(ent); - } - } - } - } - while (maxlen > 0 && (m_pending.GetSize()||m_full.GetSize()) && !errcnt); - if (!errcnt) RunReads(); - else m_async_hashaderr=true; - - return lenout; - } - -#endif - - void *GetMappedView(int offs, int *len) - { - if (!m_mmap_view && !m_mmap_totalbufmode) return 0; - - int maxl=(int) (m_fsize-(WDL_FILEREAD_POSTYPE)offs); - if (*len > maxl) *len=maxl; - if (m_mmap_view) - return (char *)m_mmap_view + offs; - else - return (char *)m_mmap_totalbufmode + offs; - } - - int Read(void *buf, int len) - { - if (m_mmap_view||m_mmap_totalbufmode) - { - int maxl=(int) (m_fsize-m_file_position); - if (maxl > len) maxl=len; - if (maxl < 0) maxl=0; - if (maxl>0) - { - if (m_mmap_view) - memcpy(buf,(char *)m_mmap_view + (int)m_file_position,maxl); - else - memcpy(buf,(char *)m_mmap_totalbufmode + (int)m_file_position,maxl); - - } - m_file_position+=maxl; - return maxl; - } - - if (m_fsize_maychange) GetSize(); // update m_fsize - -#ifdef WDL_WIN32_NATIVE_READ - if (m_fh == INVALID_HANDLE_VALUE||len<1) return 0; - - if (m_async>0) - { - return AsyncRead((char *)buf,len); - } -#elif defined(WDL_POSIX_NATIVE_READ) - if (m_filedes<0 || len<1) return 0; - -#else - if (!m_fp || len<1) return 0; - -#endif - - if (m_bufspace.GetSize()>=WDL_UNBUF_ALIGN*2-1) - { - int rdout=0; - int sz=m_bufspace.GetSize()-(WDL_UNBUF_ALIGN-1); - char *srcbuf=(char *)m_bufspace.Get(); // read size - if (((int)(INT_PTR)srcbuf)&(WDL_UNBUF_ALIGN-1)) srcbuf += WDL_UNBUF_ALIGN-(((int)(INT_PTR)srcbuf)&(WDL_UNBUF_ALIGN-1)); - while (len > rdout) - { - int a=m_sync_bufmode_used-m_sync_bufmode_pos; - if (a>(len-rdout)) a=(len-rdout); - if (a>0) - { - memcpy((char*)buf+rdout,srcbuf+m_sync_bufmode_pos,a); - rdout+=a; - m_sync_bufmode_pos+=a; - m_file_position+=a; - } - - if (len > rdout) - { - m_sync_bufmode_used=0; - m_sync_bufmode_pos=0; - - int thissz=sz; - if (m_syncrd_firstbuf) // this is a scheduling mechanism to avoid having reads on various files always happening at the same time -- not needed in async modes, only in sync with large buffers - { - m_syncrd_firstbuf=false; - const int blocks = thissz/WDL_UNBUF_ALIGN; - if (blocks > 1) - { - static int rrs; // may not be ideal on multithread, but having it incorrect isnt a big deal. - if (blocks>7) thissz >>= (rrs++)&3; - else thissz>>= (rrs++)&1; - } - } - - #ifdef WDL_WIN32_NATIVE_READ - DWORD o; - if (m_async==-1) - { - if (m_file_position&(WDL_UNBUF_ALIGN-1)) - { - int offs = (int)(m_file_position&(WDL_UNBUF_ALIGN-1)); - LONG high=(LONG) ((m_file_position-offs)>>32); - SetFilePointer(m_fh,(LONG)((m_file_position-offs)&((WDL_FILEREAD_POSTYPE)0xFFFFFFFF)),&high,FILE_BEGIN); - m_sync_bufmode_pos=offs; - } - } - if (!ReadFile(m_fh,srcbuf,thissz,&o,NULL) || o<1 || m_sync_bufmode_pos>=(int)o) - { - break; - } - #elif defined(WDL_POSIX_NATIVE_READ) - int o=(int)pread(m_filedes,srcbuf,thissz,m_filedes_rdpos); - if (o>0) m_filedes_rdpos+=o; - if (o<1 || m_sync_bufmode_pos>=o) break; - - #else - int o=(int)fread(srcbuf,1,thissz,m_fp); - if (o<1 || m_sync_bufmode_pos>=o) break; - #endif - m_sync_bufmode_used=o; - } - - } - return rdout; - } - else - { - #ifdef WDL_WIN32_NATIVE_READ - DWORD dw=0; - ReadFile(m_fh,buf,len,&dw,NULL); - m_file_position+=dw; - return dw; - #elif defined(WDL_POSIX_NATIVE_READ) - - int ret=(int)pread(m_filedes,buf,len,m_filedes_rdpos); - if (ret>0) m_filedes_rdpos+=ret; - m_file_position+=ret; - return ret; - #else - int ret=fread(buf,1,len,m_fp); - m_file_position+=ret; - return ret; - #endif - } - - } - - WDL_FILEREAD_POSTYPE GetSize() - { - if (m_mmap_totalbufmode) return m_fsize; -#ifdef WDL_WIN32_NATIVE_READ - if (m_fh == INVALID_HANDLE_VALUE) return 0; -#elif defined(WDL_POSIX_NATIVE_READ) - if (m_filedes<0) return -1; - -#else - if (!m_fp) return -1; -#endif - - if (m_fsize_maychange) - { -#ifdef WDL_WIN32_NATIVE_READ - DWORD h=0; - DWORD l=GetFileSize(m_fh,&h); - m_fsize=(((WDL_FILEREAD_POSTYPE)h)<<32)|l; -#elif defined(WDL_POSIX_NATIVE_READ) - struct stat st; - if (!fstat(m_filedes,&st)) m_fsize = st.st_size; -#endif - } - - return m_fsize; - } - - WDL_FILEREAD_POSTYPE GetPosition() - { - if (m_mmap_totalbufmode) return m_file_position; -#ifdef WDL_WIN32_NATIVE_READ - if (m_fh == INVALID_HANDLE_VALUE) return -1; -#elif defined(WDL_POSIX_NATIVE_READ) - if (m_filedes<0) return -1; -#else - if (!m_fp) return -1; -#endif - return m_file_position; - } - - bool SetPosition(WDL_FILEREAD_POSTYPE pos) // returns 0 on success - { - m_async_hashaderr=false; - - if (!m_mmap_totalbufmode) - { - #ifdef WDL_WIN32_NATIVE_READ - if (m_fh == INVALID_HANDLE_VALUE) return true; - #elif defined(WDL_POSIX_NATIVE_READ) - if (m_filedes<0) return true; - #else - if (!m_fp) return true; - #endif - } - - if (m_fsize_maychange) GetSize(); - - if (pos < 0) pos=0; - if (pos > m_fsize) pos=m_fsize; - WDL_FILEREAD_POSTYPE oldpos=m_file_position; - if (m_file_position!=pos) m_file_position=pos; - else return false; - - if (m_mmap_view||m_mmap_totalbufmode) return false; - -#ifdef WDL_WIN32_NATIVE_READ - if (m_async>0) - { - WDL_FileRead__ReadEnt *ent; - - if (pos > m_async_readpos || !(ent=m_full.Get(0)) || pos < *(WDL_FILEREAD_POSTYPE *)&ent->m_ol.Offset) - { - m_async_readpos=pos; - } - - return FALSE; - } -#endif - - - if (m_bufspace.GetSize()>=WDL_UNBUF_ALIGN*2-1) - { - if (pos >= oldpos-m_sync_bufmode_pos && pos < oldpos-m_sync_bufmode_pos + m_sync_bufmode_used) - { - int diff=(int) (pos-oldpos); - m_sync_bufmode_pos+=diff; - - return 0; - } - m_sync_bufmode_pos=m_sync_bufmode_used=0; - } - - m_syncrd_firstbuf=true; -#ifdef WDL_WIN32_NATIVE_READ - LONG high=(LONG) (m_file_position>>32); - return SetFilePointer(m_fh,(LONG)(m_file_position&((WDL_FILEREAD_POSTYPE)0xFFFFFFFF)),&high,FILE_BEGIN)==0xFFFFFFFF && GetLastError() != NO_ERROR; -#elif defined(WDL_POSIX_NATIVE_READ) - m_filedes_rdpos = m_file_position; - return false; -#else - return !!fseek(m_fp,m_file_position,SEEK_SET); -#endif - } - - WDL_HeapBuf m_bufspace; - int m_sync_bufmode_used, m_sync_bufmode_pos; - - WDL_FILEREAD_POSTYPE m_file_position,m_async_readpos; - WDL_FILEREAD_POSTYPE m_fsize; - - void *m_mmap_view; - void *m_mmap_totalbufmode; - -#ifdef WDL_WIN32_NATIVE_READ - HANDLE GetHandle() { return m_fh; } - HANDLE m_fh; - HANDLE m_mmap_fmap; - int m_mmap_size; - int m_async; // 1=nobuf, 2=buffered async, -1=unbuffered sync - - int m_async_bufsize; - WDL_PtrList m_empties; - WDL_PtrList m_pending; - WDL_PtrList m_full; - -#elif defined(WDL_POSIX_NATIVE_READ) - WDL_FILEREAD_POSTYPE m_filedes_rdpos; - int m_filedes; - bool m_filedes_locked; - - int GetHandle() { return m_filedes; } -#else - FILE *m_fp; - - int GetHandle() { return fileno(m_fp); } -#endif - - bool m_fsize_maychange; - bool m_syncrd_firstbuf; - bool m_async_hashaderr; - -#ifdef _WIN32 - static void correctlongpath(WCHAR *buf) // this also exists as wdl_utf8_correctlongpath - { - const WCHAR *insert; - WCHAR *wr; - int skip = 0; - if (!buf || !buf[0] || wcslen(buf) < 256) return; - if (buf[1] == ':') insert=L"\\\\?\\"; - else if (buf[0] == '\\' && buf[1] == '\\') { insert = L"\\\\?\\UNC\\"; skip=2; } - else return; - - wr = buf + wcslen(insert); - memmove(wr, buf + skip, (wcslen(buf+skip)+1)*2); - memmove(buf,insert,wcslen(insert)*2); - while (*wr) - { - if (*wr == '/') *wr = '\\'; - wr++; - } - } -#endif -} WDL_FIXALIGN; - - - - - - -#endif diff --git a/oversampling/WDL/filewrite.h b/oversampling/WDL/filewrite.h deleted file mode 100644 index 22aea53..0000000 --- a/oversampling/WDL/filewrite.h +++ /dev/null @@ -1,707 +0,0 @@ -/* - WDL - filewrite.h - Copyright (C) 2005 and later Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - - This file provides the WDL_FileWrite object, which can be used to create/write files. - On windows systems it supports writing synchronously, asynchronously, and asynchronously without buffering. - On windows systems it supports files larger than 4gb. - On non-windows systems it acts as a wrapper for fopen()/etc. - - -*/ - - -#ifndef _WDL_FILEWRITE_H_ -#define _WDL_FILEWRITE_H_ - -#ifndef WDL_FILEWRITE_ON_ERROR -#define WDL_FILEWRITE_ON_ERROR(is_full) -#endif - -#include "ptrlist.h" - - - -#if defined(_WIN32) && !defined(WDL_NO_WIN32_FILEWRITE) - #ifndef WDL_WIN32_NATIVE_WRITE - #define WDL_WIN32_NATIVE_WRITE - #endif -#else - #ifdef WDL_WIN32_NATIVE_WRITE - #undef WDL_WIN32_NATIVE_WRITE - #endif - #if !defined(WDL_NO_POSIX_FILEWRITE) - #include - #include - #include - #include - #define WDL_POSIX_NATIVE_WRITE - extern struct stat wdl_stat_chk; - // if this fails on linux, use CFLAGS += -D_FILE_OFFSET_BITS=64 - typedef char wdl_filewrite_assert_failed_stat_not_64[sizeof(wdl_stat_chk.st_size)!=8 ? -1 : 1]; - typedef char wdl_filewrite_assert_failed_off_t_64[sizeof(off_t)!=8 ? -1 : 1]; - #endif -#endif - - - -#ifdef _MSC_VER -#define WDL_FILEWRITE_POSTYPE __int64 -#else -#define WDL_FILEWRITE_POSTYPE long long -#endif - -class WDL_FileWrite -{ -#ifdef WDL_WIN32_NATIVE_WRITE - -class WDL_FileWrite__WriteEnt -{ -public: - WDL_FileWrite__WriteEnt(int sz) - { - m_last_writepos=0; - m_bufused=0; - m_bufsz=sz; - m_bufptr = (char *)__buf.Resize(sz+4095); - int a=((int)(INT_PTR)m_bufptr)&4095; - if (a) m_bufptr += 4096-a; - - memset(&m_ol,0,sizeof(m_ol)); - m_ol.hEvent=CreateEvent(NULL,TRUE,TRUE,NULL); - } - ~WDL_FileWrite__WriteEnt() - { - CloseHandle(m_ol.hEvent); - } - - WDL_FILEWRITE_POSTYPE m_last_writepos; - - int m_bufused,m_bufsz; - OVERLAPPED m_ol; - char *m_bufptr; - WDL_TypedBuf __buf; -}; - -#endif - -#if defined(_WIN32) && !defined(WDL_NO_SUPPORT_UTF8) - BOOL HasUTF8(const char *_str) - { - const unsigned char *str = (const unsigned char *)_str; - if (!str) return FALSE; - while (*str) - { - unsigned char c = *str; - if (c >= 0xC2) - { - if (c <= 0xDF && str[1] >=0x80 && str[1] <= 0xBF) return TRUE; - else if (c <= 0xEF && str[1] >=0x80 && str[1] <= 0xBF && str[2] >=0x80 && str[2] <= 0xBF) return TRUE; - else if (c <= 0xF4 && str[1] >=0x80 && str[1] <= 0xBF && str[2] >=0x80 && str[2] <= 0xBF) return TRUE; - } - str++; - if (((const char *)str-_str) >= 256) return TRUE; // long filenames get converted to wide - } - return FALSE; - } -#endif - - -public: - // async==2 is write-through - // async==3 is non-buffered (win32-only) - WDL_FileWrite(const char *filename, int allow_async=1, int bufsize=8192, int minbufs=16, int maxbufs=16, bool wantAppendTo=false, bool noFileLocking=false) - { - m_file_position=0; - m_file_max_position=0; - if(!filename) - { -#ifdef WDL_WIN32_NATIVE_WRITE - m_fh = INVALID_HANDLE_VALUE; - m_async = 0; -#elif defined(WDL_POSIX_NATIVE_WRITE) - m_filedes_locked=false; - m_filedes=-1; - m_bufspace_used=0; -#else - m_fp = NULL; -#endif - return; - } - -#ifdef WDL_WIN32_NATIVE_WRITE - #ifdef WDL_SUPPORT_WIN9X - const bool isNT = (GetVersion()<0x80000000); - #else - const bool isNT = true; - #endif - m_async = allow_async && isNT ? 1 : 0; - if (m_async && allow_async == 3 && !wantAppendTo) - { - m_async = 3; - bufsize = (bufsize+4095)&~4095; - if (bufsize<4096) bufsize=4096; - } - - int rwflag = GENERIC_WRITE; - int createFlag= wantAppendTo?OPEN_ALWAYS:CREATE_ALWAYS; - int shareFlag = noFileLocking ? (FILE_SHARE_READ|FILE_SHARE_WRITE) : FILE_SHARE_READ; - int flag = FILE_ATTRIBUTE_NORMAL; - - if (m_async) - { - rwflag |= GENERIC_READ; - if (m_async == 3) - flag |= FILE_FLAG_OVERLAPPED|FILE_FLAG_NO_BUFFERING|FILE_FLAG_WRITE_THROUGH; - else - flag |= FILE_FLAG_OVERLAPPED|(allow_async>1 ? FILE_FLAG_WRITE_THROUGH: 0); - } - - { -#ifndef WDL_NO_SUPPORT_UTF8 - m_fh=INVALID_HANDLE_VALUE; - if (isNT && HasUTF8(filename)) - { - int szreq=MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,filename,-1,NULL,0); - if (szreq > 1000) - { - WDL_TypedBuf wfilename; - wfilename.Resize(szreq+20); - if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,filename,-1,wfilename.Get(),wfilename.GetSize()-10)) - { - correctlongpath(wfilename.Get()); - m_fh = CreateFileW(wfilename.Get(),rwflag,shareFlag,NULL,createFlag,flag,NULL); - } - } - else - { - WCHAR wfilename[1024]; - if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,filename,-1,wfilename,1024-10)) - { - correctlongpath(wfilename); - m_fh = CreateFileW(wfilename,rwflag,shareFlag,NULL,createFlag,flag,NULL); - } - } - } - - if (m_fh == INVALID_HANDLE_VALUE) -#endif - m_fh = CreateFileA(filename,rwflag,shareFlag,NULL,createFlag,flag,NULL); - } - - if (m_async && m_fh != INVALID_HANDLE_VALUE) - { - m_async_bufsize=bufsize; - m_async_maxbufs=maxbufs; - m_async_minbufs=minbufs; - int x; - for (x = 0; x < m_async_minbufs; x ++) - { - WDL_FileWrite__WriteEnt *t=new WDL_FileWrite__WriteEnt(m_async_bufsize); - m_empties.Add(t); - } - } - - if (m_fh != INVALID_HANDLE_VALUE && wantAppendTo) - SetPosition(GetSize()); - -#elif defined(WDL_POSIX_NATIVE_WRITE) - m_bufspace_used=0; - m_filedes_locked=false; - m_filedes=open(filename,O_WRONLY|O_CREAT - // todo: use fcntl() for platforms when O_CLOEXEC is not available (if we ever need to support them) - // (currently the only platform that meets this criteria is macOS w/ old SDK, but we don't use execve() - // there -#ifdef O_CLOEXEC - | O_CLOEXEC -#endif - ,0644); - if (m_filedes>=0) - { - - if (!noFileLocking) - { - m_filedes_locked = !flock(m_filedes,LOCK_EX|LOCK_NB); - if (!m_filedes_locked) - { - // this check might not be necessary, it might be sufficient to just fail and close if no exclusive lock possible - if (errno == EWOULDBLOCK) - { - // FAILED exclusive locking because someone else has a lock - close(m_filedes); - m_filedes=-1; - } - else // failed for some other reason, try to keep a shared lock at least - { - m_filedes_locked = !flock(m_filedes,LOCK_SH|LOCK_NB); - } - } - } - - if (m_filedes>=0) - { - if (!wantAppendTo) - { - if (ftruncate(m_filedes,0) < 0) - { - WDL_ASSERT( false /* ftruncate() failed in WDL_FileWrite */ ); - } - } - else - { - struct stat st; - if (!fstat(m_filedes,&st)) SetPosition(st.st_size); - } - } - - -#ifdef __APPLE__ - if (m_filedes >= 0 && allow_async>1) fcntl(m_filedes,F_NOCACHE,1); -#endif - } - if (minbufs * bufsize >= 16384) m_bufspace.Resize((minbufs*bufsize+4095)&~4095); -#else - m_fp=fopen(filename,wantAppendTo ? "a+b" : "wb"); - if (wantAppendTo && m_fp) - fseek(m_fp,0,SEEK_END); -#endif - } - - ~WDL_FileWrite() - { -#ifdef WDL_WIN32_NATIVE_WRITE - // todo, async close stuff? - if (m_fh != INVALID_HANDLE_VALUE && m_async) - { - SyncOutput(true); - } - - m_empties.Empty(true); - m_pending.Empty(true); - - if (m_fh != INVALID_HANDLE_VALUE) CloseHandle(m_fh); - m_fh=INVALID_HANDLE_VALUE; -#elif defined(WDL_POSIX_NATIVE_WRITE) - if (m_filedes >= 0) - { - if (m_bufspace.GetSize() > 0 && m_bufspace_used>0) - { - int v=(int)pwrite(m_filedes,m_bufspace.Get(),m_bufspace_used,m_file_position); - if (v>0) m_file_position+=v; - if (m_file_position > m_file_max_position) m_file_max_position=m_file_position; - m_bufspace_used=0; - } - if (m_filedes_locked) flock(m_filedes,LOCK_UN); - close(m_filedes); - } - m_filedes=-1; - -#else - if (m_fp) fclose(m_fp); - m_fp=0; -#endif - - } - - bool IsOpen() - { -#ifdef WDL_WIN32_NATIVE_WRITE - return (m_fh != INVALID_HANDLE_VALUE); -#elif defined(WDL_POSIX_NATIVE_WRITE) - return m_filedes >= 0; -#else - return m_fp != NULL; -#endif - } - - - int Write(const void *buf, int len) - { -#ifdef WDL_WIN32_NATIVE_WRITE - if (m_fh == INVALID_HANDLE_VALUE) return 0; - - if (m_async) - { - int rdpos = 0; - while (len > 0) - { - if (!m_empties.GetSize()) - { - WDL_FileWrite__WriteEnt *ent=m_pending.Get(0); - DWORD s=0; - if (ent) - { - bool wasabort=false; - DWORD err; - if (GetOverlappedResult(m_fh,&ent->m_ol,&s,FALSE)|| - (wasabort=((err=GetLastError())==ERROR_OPERATION_ABORTED))) - { - m_pending.Delete(0); - - if (wasabort) - { - if (!RunAsyncWrite(ent,false)) m_empties.Add(ent); - } - else - { - m_empties.Add(ent); - ent->m_bufused=0; - } - } - else if (err != ERROR_IO_PENDING && err != ERROR_IO_INCOMPLETE) - { - WDL_FILEWRITE_ON_ERROR(err == ERROR_DISK_FULL) - } - } - } - - - WDL_FileWrite__WriteEnt *ent=m_empties.Get(0); - if (!ent) - { - if (m_pending.GetSize()>=m_async_maxbufs) - { - SyncOutput(false); - } - - if (!(ent=m_empties.Get(0))) - m_empties.Add(ent = new WDL_FileWrite__WriteEnt(m_async_bufsize)); // new buffer - - - } - - int ml=ent->m_bufsz-ent->m_bufused; - if (ml>len) ml=len; - memcpy(ent->m_bufptr+ent->m_bufused,(const char *)buf + rdpos,ml); - - ent->m_bufused+=ml; - len-=ml; - rdpos+=ml; - - if (ent->m_bufused >= ent->m_bufsz) - { - if (RunAsyncWrite(ent,true)) m_empties.Delete(0); // if queued remove from list - } - } - return rdpos; - } - else - { - DWORD dw=0; - if (!WriteFile(m_fh,buf,len,&dw,NULL)) - { - WDL_FILEWRITE_ON_ERROR(GetLastError() == ERROR_DISK_FULL) - } - m_file_position+=dw; - if (m_file_position>m_file_max_position) m_file_max_position=m_file_position; - return dw; - } -#elif defined(WDL_POSIX_NATIVE_WRITE) - if (m_bufspace.GetSize()>0) - { - char *rdptr = (char *)buf; - int rdlen = len; - while (rdlen>0) - { - int amt = m_bufspace.GetSize() - m_bufspace_used; - if (amt>0) - { - if (amt>rdlen) amt=rdlen; - memcpy((char *)m_bufspace.Get()+m_bufspace_used,rdptr,amt); - m_bufspace_used += amt; - rdptr+=amt; - rdlen -= amt; - - if (m_file_position+m_bufspace_used > m_file_max_position) m_file_max_position=m_file_position + m_bufspace_used; - } - if (m_bufspace_used >= m_bufspace.GetSize()) - { - int v=(int)pwrite(m_filedes,m_bufspace.Get(),m_bufspace_used,m_file_position); - if (v != m_bufspace_used) { WDL_FILEWRITE_ON_ERROR(v>=0 || errno == EDQUOT || errno == ENOSPC) } - if (v>0) m_file_position+=v; - m_bufspace_used=0; - } - } - return len; - } - else - { - int v=(int)pwrite(m_filedes,buf,len,m_file_position); - if (v != len) { WDL_FILEWRITE_ON_ERROR(v>=0 || errno == EDQUOT || errno == ENOSPC) } - if (v>0) m_file_position+=v; - if (m_file_position > m_file_max_position) m_file_max_position=m_file_position; - return v; - } -#else - int written = (int)fwrite(buf,1,len,m_fp); - if (written != len) { WDL_FILEWRITE_ON_ERROR(false) } - return written; -#endif - - - } - - WDL_FILEWRITE_POSTYPE GetSize() - { -#ifdef WDL_WIN32_NATIVE_WRITE - if (m_fh == INVALID_HANDLE_VALUE) return 0; - DWORD h=0; - DWORD l=GetFileSize(m_fh,&h); - WDL_FILEWRITE_POSTYPE tmp=(((WDL_FILEWRITE_POSTYPE)h)<<32)|l; - WDL_FILEWRITE_POSTYPE tmp2=GetPosition(); - if (tmpm_bufused; - } - return pos; -#elif defined(WDL_POSIX_NATIVE_WRITE) - if (m_filedes < 0) return -1; - return m_file_position + m_bufspace_used; -#else - if (!m_fp) return -1; - return ftell(m_fp); - -#endif - } - -#ifdef WDL_WIN32_NATIVE_WRITE - - bool RunAsyncWrite(WDL_FileWrite__WriteEnt *ent, bool updatePosition) // returns true if ent is added to pending - { - if (ent && ent->m_bufused>0) - { - if (updatePosition) - { - ent->m_last_writepos = m_file_position; - m_file_position += ent->m_bufused; - if (m_file_position>m_file_max_position) m_file_max_position=m_file_position; - } - - if (m_async == 3 && (ent->m_bufused&4095)) - { - int offs=(ent->m_bufused&4095); - char tmp[4096]; - memset(tmp,0,4096); - - *(WDL_FILEWRITE_POSTYPE *)&ent->m_ol.Offset = ent->m_last_writepos + ent->m_bufused - offs; - ResetEvent(ent->m_ol.hEvent); - - DWORD dw=0; - if (!ReadFile(m_fh,tmp,4096,&dw,&ent->m_ol)) - { - if (GetLastError() == ERROR_IO_PENDING) - WaitForSingleObject(ent->m_ol.hEvent,INFINITE); - } - memcpy(ent->m_bufptr+ent->m_bufused,tmp+offs,4096-offs); - - ent->m_bufused += 4096-offs; - } - - DWORD d=0; - - *(WDL_FILEWRITE_POSTYPE *)&ent->m_ol.Offset = ent->m_last_writepos; - - ResetEvent(ent->m_ol.hEvent); - - if (!WriteFile(m_fh,ent->m_bufptr,ent->m_bufused,&d,&ent->m_ol)) - { - if (GetLastError()==ERROR_IO_PENDING) - { - m_pending.Add(ent); - return true; - } - else { WDL_FILEWRITE_ON_ERROR(GetLastError()==ERROR_DISK_FULL) } - } - ent->m_bufused=0; - } - return false; - } - - void SyncOutput(bool syncall) - { - if (syncall) - { - if (RunAsyncWrite(m_empties.Get(0),true)) m_empties.Delete(0); - } - for (;;) - { - WDL_FileWrite__WriteEnt *ent=m_pending.Get(0); - if (!ent) break; - DWORD s=0; - m_pending.Delete(0); - BOOL ok = GetOverlappedResult(m_fh,&ent->m_ol,&s,TRUE); - int errcode; - if (!ok && (errcode=GetLastError())==ERROR_OPERATION_ABORTED) - { - // rewrite this one - if (!RunAsyncWrite(ent,false)) m_empties.Add(ent); - } - else - { - if (!ok) { WDL_FILEWRITE_ON_ERROR(errcode==ERROR_DISK_FULL) } - m_empties.Add(ent); - ent->m_bufused=0; - if (!syncall) break; - } - } - } - -#endif - - - bool SetPosition(WDL_FILEWRITE_POSTYPE pos) // returns 0 on success - { -#ifdef WDL_WIN32_NATIVE_WRITE - if (m_fh == INVALID_HANDLE_VALUE) return true; - if (m_async) - { - SyncOutput(true); - m_file_position=pos; - if (m_file_position>m_file_max_position) m_file_max_position=m_file_position; - - if (m_async==3 && (m_file_position&4095)) - { - WDL_FileWrite__WriteEnt *ent=m_empties.Get(0); - if (ent) - { - int psz=(int) (m_file_position&4095); - - m_file_position -= psz; - *(WDL_FILEWRITE_POSTYPE *)&ent->m_ol.Offset = m_file_position; - ResetEvent(ent->m_ol.hEvent); - - DWORD dwo=0; - if (!ReadFile(m_fh,ent->m_bufptr,4096,&dwo,&ent->m_ol)) - { - if (GetLastError() == ERROR_IO_PENDING) - WaitForSingleObject(ent->m_ol.hEvent,INFINITE); - } - ent->m_bufused=(int)psz; - } - } - return false; - } - - m_file_position=pos; - if (m_file_position>m_file_max_position) m_file_max_position=m_file_position; - - LONG high=(LONG) (m_file_position>>32); - return SetFilePointer(m_fh,(LONG)(m_file_position&((WDL_FILEWRITE_POSTYPE)0xFFFFFFFF)),&high,FILE_BEGIN)==0xFFFFFFFF && GetLastError() != NO_ERROR; -#elif defined(WDL_POSIX_NATIVE_WRITE) - - if (m_filedes < 0) return true; - if (m_bufspace.GetSize() > 0 && m_bufspace_used>0) - { - int v=(int)pwrite(m_filedes,m_bufspace.Get(),m_bufspace_used,m_file_position); - if (v>0) m_file_position+=v; - if (m_file_position > m_file_max_position) m_file_max_position=m_file_position; - m_bufspace_used=0; - } - - m_file_position = pos; // seek! - if (m_file_position>m_file_max_position) m_file_max_position=m_file_position; - return false; -#else - if (!m_fp) return true; - return !!fseek(m_fp,pos,SEEK_SET); -#endif - } - - WDL_FILEWRITE_POSTYPE m_file_position, m_file_max_position; - -#ifdef WDL_WIN32_NATIVE_WRITE - HANDLE GetHandle() { return m_fh; } - HANDLE m_fh; - int m_async; // 3 = unbuffered - - int m_async_bufsize, m_async_minbufs, m_async_maxbufs; - - WDL_PtrList m_empties; - WDL_PtrList m_pending; - -#elif defined(WDL_POSIX_NATIVE_WRITE) - int GetHandle() { return m_filedes; } - - WDL_HeapBuf m_bufspace; - int m_bufspace_used; - int m_filedes; - - bool m_filedes_locked; - -#else - int GetHandle() { return fileno(m_fp); } - - FILE *m_fp; -#endif - -#ifdef _WIN32 - static void correctlongpath(WCHAR *buf) // this also exists as wdl_utf8_correctlongpath - { - const WCHAR *insert; - WCHAR *wr; - int skip = 0; - if (!buf || !buf[0] || wcslen(buf) < 256) return; - if (buf[1] == ':') insert=L"\\\\?\\"; - else if (buf[0] == '\\' && buf[1] == '\\') { insert = L"\\\\?\\UNC\\"; skip=2; } - else return; - - wr = buf + wcslen(insert); - memmove(wr, buf + skip, (wcslen(buf+skip)+1)*2); - memmove(buf,insert,wcslen(insert)*2); - while (*wr) - { - if (*wr == '/') *wr = '\\'; - wr++; - } - } -#endif -} WDL_FIXALIGN; - - - - - - -#endif diff --git a/oversampling/WDL/fnv64.h b/oversampling/WDL/fnv64.h deleted file mode 100644 index f005431..0000000 --- a/oversampling/WDL/fnv64.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _WDL_FNV64_H_ -#define _WDL_FNV64_H_ - -#include "wdltypes.h" - -#define WDL_FNV64_IV WDL_UINT64_CONST(0xCBF29CE484222325) - -static WDL_STATICFUNC_UNUSED WDL_UINT64 WDL_FNV64(WDL_UINT64 h, const unsigned char* data, int sz) -{ - int i; - for (i=0; i < sz; ++i) - { - h *= WDL_UINT64_CONST(0x00000100000001B3); - h ^= data[i]; - } - return h; -} -#endif \ No newline at end of file diff --git a/oversampling/WDL/giflib/AUTHORS b/oversampling/WDL/giflib/AUTHORS deleted file mode 100644 index 43dee90..0000000 --- a/oversampling/WDL/giflib/AUTHORS +++ /dev/null @@ -1,36 +0,0 @@ -Lennie Araki - Windows code providing a nicer interface and example program - -Michael Brown - callbacks to write data via user defined function - -Daniel Eisenbud - Fixes for crashes with invalid gif files and double freeing of - colormaps - -Gershon Elber - original giflib code - -Marc Ewing - spec file (for rpms) updates - -Toshio Kuratomi - uncompressed gif writing code - autoconf/automake process - current maintainer - -marek - Gif initialization fix - windows build code - -Peter Mehlitz - callbacks to read data from arbitrary sources (like libjpeg/libpng) - -Dick Porter - int/pointer fixes for Alpha - -Eric Raymond - long time maintainer of giflib code - -Georg Schwarz - IRIX fixes diff --git a/oversampling/WDL/giflib/COPYING b/oversampling/WDL/giflib/COPYING deleted file mode 100644 index da54357..0000000 --- a/oversampling/WDL/giflib/COPYING +++ /dev/null @@ -1,19 +0,0 @@ -The GIFLIB distribution is Copyright (c) 1997 Eric S. Raymond - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/oversampling/WDL/giflib/ChangeLog b/oversampling/WDL/giflib/ChangeLog deleted file mode 100644 index 4186f25..0000000 --- a/oversampling/WDL/giflib/ChangeLog +++ /dev/null @@ -1,549 +0,0 @@ -2005-10-09 Toshio Kuratomi - r94 - * Sync with libungif r93. - * ChangeLog: Update to r92. - * NEWS: Update with combined libungif/giflib changes. - -2005-10-09 Toshio Kuratomi - r92 - * lib/gif_lib.h: Change GifPrefixType to unsigned. - -2005-10-09 Toshio Kuratomi - r91 - * ChangeLog: Update to r90. - * NEWS: Update on GBA and Windows fixes. - -2005-10-06 Toshio Kuratomi - r90 - Changes from Lennie Araki: - * gba/giftest.mak: Prefix the names of defines for the GBA build with _GBA. - * lib/dgif_lib.c, lib/gif_lib_private.h, lib/gif_err.c: - - When Compiling for Game Boy Advance, file functions are not needed so - exclude DGifOpenFileName(), DGifOpenFileHandle(), DGifSlurp(), and - PrintGifError(). - - On Game Boy Advance we need to reduce memory usage. Change values to - short int where appropriate. - * lib/gif_lib.h: - - Handle te GBA changes by defining GifPrefixType and GifWord to int - unless compiling on GBA. Then use unsigned short and short - respectively. - - Fix a problem with the API on _WIN32. DrawText conflicts with the - Windows API. Call it DrawGifText instead. - -2005-09-27 Toshio Kuratomi - r86 - * Sync with libungif r85. - -2005-09-27 Toshio Kuratomi - r82 - * AUTHORS: Add Daniel Eisenbud. Obscure email addresses. - * libungif.spec: Bump to version 4.1.4. - * configure.ac: Bump to 4.1.4. No longer check for ranlib. - * doc/lzgif.txt: Change dos line encoding to UNIX. - * lib/dgif_lib.c: (eisenbud) - - Set GifFile's ColorMaps to NULL when we free a colormap object. - - Detect some cases of corrupted GIFs which were crashing the library. - * lib/egif_lib.c: Set ColorMaps to NULL when we free a colormap object. - * lib/gifalloc.c: Set ColorMaps to NULL when we free a colormap object. - * lib/dev2gif.c: Fix redefinition problem on IRIX. - * NEWS: Update to 4.1.4 - * util/gifcomb.c: Set a olorMap to NULL. - -2004-07-11 Toshio Kuratomi - r79 - * gif2iris.c: Fixes from Georg Schwarz . - - stdlib.h is available and needs to be included on IRIX. - - ColorMapSize was being set from non-existent variables. - -2004-05-29 Toshio Kuratomi - r76 - * Sync with libungif-4.1.3. - -2004-05-29 Toshio Kuratomi - r74 - * ChangeLog, prop=lastlog: Sync with the subversion logs. - -2004-05-29 Toshio Kuratomi - r73 - * test-unx: Add a test of extension code. - * lib/egif_lib.c: Remove a debugging statement - -2004-05-29 Toshio Kuratomi - r72 - * Makefile.am, doc/Makefile.am, pic/Makefile.am: Change wildcarded entries - into explicit filenames so make distcheck will succeed. - -2004-05-29 Toshio Kuratomi - r71 - * ChangeLog, prop=lastlog: Sync the ChangeLog for the release. - -2004-05-29 Toshio Kuratomi - r70 - * AUTHORS: Add Lennie Araki to the list of contributers. - * windows: The windows subdirectory and all files under it are contributions - from Lennie Araki to provide a nice interface on MS Windows. - * README: Redundancy fix. - * doc/gif_lib.html: Add EGifPutExtension{First,Next,Last} to the documentation - so people know they should use it instead of EGifPutExtension. - * Makefile.am: Mark the windows files to be distributed. - * NEWS: Complete the NEWS item for 4.1.3. - -2004-05-29 Toshio Kuratomi - r69 - * libungif.spec: Some updates from the latest RedHat spec. - * configure.ac: Bump version to 4.1.3. - * lib/gifalloc.c: Add to my comments on ESR's note about Extension blocks. - * lib/egif_lib.c: - - EGifPutComment(): reimplemented using EGifPutExtensionFirst, Next, and - Last so that it won't break on unusually long comments. - - EGifPutExtension{First,Next,Last}: Changed fwrites to WRITE so any - user defined write function will get called properly. - - EGifPutExtensionLast: if the Extension block is empty (Zero length) - then don't attempt to output a last extension block, just output the - block terminator. - - EGifPutExtension: Comment that this function does not work when there - are multiple subblocks in an Extension block. Use the functions - EGifPutExtension{First,Next,Last} instead. - - EGifSpew: Reimplement to use EGifPutExtension{First,Next,Last} so we - don't output broken GIFs when there are multiple sub-blocks on an - extension. - * lib/Makefile.am: Bump version to 4.1.3. - * NEWS: Begin writing an entry for 4.1.3. - * util/icon2gif.c: Few casting fixes to make gcc -Wall happy. - * util/gif2ps.c: printf format string corrections. - -2004-05-26 Toshio Kuratomi - r67 - * Clean up some typos. - -2004-05-25 Toshio Kuratomi - r66 - * Sync with libungif-4.1.2. - -2004-03-03 Toshio Kuratomi - r64 - Last minute updates to the release notes in various files. - -2004-03-03 Toshio Kuratomi - r63 - * Set property lastlog to remind me when I last synced the ChangeLog - -2004-03-03 Toshio Kuratomi - r62 - * ChangeLog: Update - -2004-03-03 Toshio Kuratomi - r61 - * configure.ac: Bump version to 4.1.2 - -2004-02-22 Toshio Kuratomi - r59 - * configure.ac, lib/Makefile.am: Bump version. Forgot to do this for 4.1.1... - -2004-02-22 Toshio Kuratomi - r58 - * TODO: Take out -Wall as that's all ready now. - -2004-02-22 Toshio Kuratomi - r57 - Merge changes to the code from branch indent-audit r55 - * README: MakeExtension deprecation note. - * TODO: Bunch of things I need to fix or check that I saw while doing the - indentation of the code. - * lib/getarg.h: indent changes - * lib/dgif_lib.c: indent changes - - Move stdlib.h out of #ifdef's as it's included on all platforms. - - Add checks to be sure malloc and MakeMapObject succeed. - * lib/quantize.c: indent changes - - Move stdlib.h out of #ifdef's as it's included on all platforms. - - _GifError already pulled in through gif_lib_private.h. Remove decl. - - Make Count in NewColorMapType be unsigned. - - Separated mallocs from conditionals in a few places. Easier reading. - * lib/gifalloc.c: indent changes - - Added four FIXME's where I think the code might not be doing what we - want. Need to do more research to figure out. - - Add note to MakeExtension that I think it needs to be deprecated. - - Separated mallocs from conditionals in a few places. Easier reading. - - FreeLastSavedImage: New private function to free the last image in a - GifFile structure. Used to back out when unable to completely - allocate a new SavedImage structure. - - check for NULL values before deallocating in Free* functions and make - sure all Free* functions set the pointer to NULL after they deallocate - the memory. - * lib/egif_lib.c: indent changes - - EGifPutScreenDesc: If we have no colormap, output a default value for - its size instead of trying to reference its unallocated BitsPerPixel - field. (Fixes bug noted in r46) - * lib/gif_lib.h: indent changes - - Condense the #else #if VARARGS to #elif VARARGS check. - * lib/qprintf.c: indent changes - - Condense the #else #if VARARGS to #elif VARARGS check. - * lib/dev2gif.c: indent changes - * lib/getarg.c: indent changes - * lib/gif_lib_private.h: indent changes - * lib/gif_font.c: indent changes - * lib/gif_err.c: indent changes - -2004-02-22 Toshio Kuratomi - r56 - * lib/Makefile.am, util/Makefile.am: Add -Wall to the compilation flags so - we can keep the code from acquiring too much bad style. - -2004-02-20 Toshio Kuratomi - r46 - * egif_lib.c: Note for a bug fix (Can wait until after indent because - there's no patch.) - * gif_lib.h, dev2gif.c: Change int type to explicit long type in - DumpScreen2Gif. - * util/gifinto.c: Give the fprintf back its %d format. - GifFile->ImageCount is used as the Image number. - -2004-02-20 Toshio Kuratomi - r45 - * README: add varargs to the deprecation list - -2004-02-20 Toshio Kuratomi - r44 - * test-unx: Quote the program names. - * lib/dgif_lib.c: - - Make sure memory was allocated for the colormap - - Some reformatting of code but no syntactic changes. - * lib/gif_lib.h: - - C++ extern "C" fix - - Fix typo with EGifOpen - * lib/qprintf.c, lib/getarg.c: Update the varargs code. Some users reported - that not all systems can handle the hybridized varargs parameter lists - we had. Need to use old-style declarations instead. - -2004-02-20 Toshio Kuratomi - r43 - * NEWS: Note bugfixes and deprecations - * README: Deprecation list is now being compiled in this file. - * TODO: Notes about interlace bug, -Wall status, merging of old bug status - -2004-02-19 Toshio Kuratomi - r42 - * Makefile.am: Disable testing for now because gif2x11 is broken so none - of the tests _appear_ to complete successfully. - -2004-02-19 Toshio Kuratomi - r38 - Merge -Wall fixes from branches/Wall-audit r29 - * configure.ac: - - Make the stdarg vs varargs check simpler by relying on - AC_CHECK_HEADERS() magic. - - Check for unistd.h - * dgif_lib.c, gif_lib.h, egif_lib.c, gifalloc.c, quantize.c, dev2gif.c, - getarg.c, gif_lib_private.h, gif_font.c gif_err.c, gifinto.c, icon2gif.c, - raw2gif.c, gifcolor.c, gifasm.c, gif2epsn.c, gif2iris.c, gifrotat.c, - gifovly.c, gif2x11.c, rle2gif.c, gif2rle.c, text2gif.c, gifspnge.c, - gifclrmp.c, giffiltr.c, giftext.c, gifinfo.c, rgb2gif.c, gif2rgb.c, gif2ps.c - - Changes to get rid of -Wall compile warnings. - + Casting of types - + New header includes for unistd.h and fcntl.h - + Explicit declaration of many types to unsigned - + Removed unused variables and functions - + Removed VersionStr from every library file. Instead include it via - gif_lib_private.h - * gif_lib.h, gif_lib_private.h: Moved the VersionStr into gif_lib_private.h - and made it a #define instead of a static char *. - -2004-02-19 Toshio Kuratomi - r37 - Deprecation notes - -2004-02-19 Toshio Kuratomi - r36 - Add notes about security things to do and giflib syncing - -2004-02-18 Toshio Kuratomi - r32 - * TODO: Add notes about how to go about syncing Wall-audit and indent changes - into giflib. It won't be pretty. - * svn:ignore: Change the tarball names from libungif to giflib - -2004-02-18 Toshio Kuratomi - r31 - Add config.h include to gif_hash.c - -2004-02-17 Toshio Kuratomi - r30 - Sync up with libungif 4.1.1 - -2004-02-17 Toshio Kuratomi - r26 - Updated ChangeLog - -2004-02-17 Toshio Kuratomi - * Updated libungif.spec to look more like fedora core spec - * Updated version numbers in all files - -2004-02-17 Toshio Kuratomi - * Add the libungif*.tar.bz2 distribution tarball to the ignored files - * configure.ac, lib/getarg.c, lib/getarg.h, lib/gif_lib.h, lib/qprintf.c: - Prefer stdarg.h over vararg.h - * TODO: Add information about functions that will go away in 5.0 - (In reality, I don't think new software uses libungif, so there may never - be a 5.0 release.) - * lib/gif_lib.h: Change version from 4.0 to 4.1 - * NEWS: add deprecation warning for the qprintf stuff: GifQuietPrint var and - GifQprintf function. - -2004-02-16 Toshio Kuratomi - * util/gif2iris.c, util/gif2rle.c, util/gifinfo.c: Fix problems with fprintf error statements in the utils - -2004-02-16 Toshio Kuratomi - Add DEVELOPERS file to the distribution. - -2004-02-16 Toshio Kuratomi - * AUTHORS, libungif.spec, libungif.lsm, README, BUGS, NEWS: - Lots of changes to my email address and the website/download. (libungif is - moving to sourceforge.) - * TODO: Few notes on cleanups that need to happen. State what needs to be done - for 4.1.1 to be released. - -2004-02-15 Toshio Kuratomi - Changes imported from last cvs checkout - * TODO: note to check return of malloc everywhere - * lib/dgif_lib.c, lib/egif_lib.c: Fix some deallocation bugs - * lib/gifalloc.c: Fix a colormap allocation problem - * lib/gif_font.c: Fix to drawing text - -2004-02-15 Toshio Kuratomi - Added libgetarg.a to the ignore list. - -2004-02-15 Toshio Kuratomi - Changes to the build infrastructure to build under current libtool, automake, - and libtool. - * configure.in: renamed to configure.ac - * acconfig.h: deleted. Functionality moved into the configure.ac - * autogen.sh: now runs libtoolize --automake - * lib/Makefile.am, util/Makefile.am: CFLAGS=>AM_CFLAGS; INCLUDES=>AM_CPPFLAGS - * configure.ac: - - initialization macros for automake and autoconf have changed - - removed checks for C++ compiler and Awk - - acconfig.h functionality moved here. - - add other X11 libraries to the X11_LIB define - -2004-02-15 Toshio Kuratomi - * Remove INSTALL file as it's autogenerated.\n* Add stamp-h1 to ignored files - -2004-02-15 Toshio Kuratomi - Additional adds and deletes to make version 4.1.0b1 - -2004-02-15 Toshio Kuratomi - Import of version 4.1.0b1 - -2004-02-15 Toshio Kuratomi - r10 - Import giflib 4.1.0 - -2004-02-15 Toshio Kuratomi - r9 - Copy the 4.1.0 libungif release to be the base of the 4.1.0 giflib release. - -2004-02-15 Toshio Kuratomi - r7 - Release 4.1.0 - -2004-02-15 Toshio Kuratomi - r6 - Import of version 4.1.0 - -2004-02-15 Toshio Kuratomi - r5 - Set ignore patterns on the project directories. - -2004-02-15 Toshio Kuratomi - r3 - Remove a Makefile.in that was left in in the first commit. - -2004-02-14 Toshio Kuratomi - r2 - Commit revision 3.1.0 to subversion - -2004-02-14 Toshio Kuratomi - r1 - Initial SVN Repository Layout - -2000 6 Feb Toshio Kuratomi - * configure.in: Change to using config.h - - Every .c file: Change to using config.h. - * configure.in: added check for varargs header. - * lib/getarg.c: Changed the ifdef USE_VARARGS to ifdef HAVE_VARARGS_H. - - lib/getarg.h: Ditto. - - lib/gif_lib.h: Ditto. - - lib/qprintf.h: Ditto. - -2000 6 Feb Toshio Kuratomi - * lib/getarg.h: Prepend an underscore to the header file define. - * lib/gif_lib.h: Ditto - * lib/gif_lib_private.h: Ditto - * lib/getarg.c: ifdef'd MyMalloc so it actually won't define if it already - is. - -2000 3 Feb Toshio Kuratomi - * A new cvs repository based my private tree from home. It now goes back - to giflib-3.0. - * Updated the cvs repository to make multiple developers possible. - * Merge all of Michael's patches into the distribution. - * DEVELOPER: Updated to reflect the new versions of - autoconf/automake/libtool we're using. - * libungif.spec: Updated a few things from the latest redhat spec file. - -1999 5 Dec Toshio Kuratomi - * Update links to the web pages as I have reorganized them somewhat. - * Add the welcome2.gif to the pic directory and a test that utilizes - it to test-unx. - -1999 17 Nov Toshio Kuratomi - * New cvs Repository. Hopefully I've got everything that was in the - old one. This one is available on anonymous cvs. - * Update to libtool 1.3.3, automake 1.4, and autoconf 2.13 - -1999 23 May Michael R Brown - * Lots of 'const' qualifiers added, thanks Alexis - Wilke for finding these. - -1999 22 Mar Michael R Brown - * util/gif2x11.c: Patch by (who?) to fix lots of memory leeks. - * util/*.c: - lib/dgif_lib.c: - Makefile.in: - Patch by David Kaelbling to compile on IRIX 6.x. Basically fixing - lots of bad/missing parameter passing to printf, scanf and similar. - * Added pics/welcome2.gif, from Peter Merz which provokes a bug prior - to patch 19990224 to do with colour map management. There is still - a problem with util/gifspnge processing this image, so it will not - be added to test-unx yet. - -1999 05 Mar Michael R Brown - * lib/getarg.c: Lines 107 and 189 - Added ifdef's to use stdarg when available. On dec-alpha the - default code was causing programs to crash, probably because - it assumes a stack that grows-up. - -1999 24 Feb Michael R Brown - * lib/dgif_lib.c: Lines 363 and 367 - Bug reported by Steve Sanders, where &'s where causing the - memcpy to overwrite the pointers. Fixed by removing the &'s - so that memcpy overwrote the memory pointed to. - -1999 09 Feb Toshio Kuratomi - * Release 4.1.0 - -1999 09 Feb Toshio Kuratomi - * Merge libungif changes into the giflib tree: - - upgrade to libtool 1.2b - - util/Makefile.am: Minor change to allow compilation outside the - source_dir. - - lib/egif_lib.c: FILE_STATE_WRITE, FILE_STATE_SCREEN, - FILE_STATE_IMAGE, IS_WRITEABLE are now in gif_lib_private.h - - lib/dgif_lib.c: FILE_STATE_READ and IS_READABLE are now in - gif_lib_private.h - - lib/gif_lib_private.h: Above mentioned constants and macros are now - here. FILE_STATE_READ is now 0x08 instead of 0x00. - - configure.in: Update version to 4.1.0 - - lib/Makefile.am: Update libtool version to 5:0:1 (libtool) - - giflib.spec: Update for version 4.1.0 (Add libungif-4.1 - compatibility stuff and change version.) - - giflib.lsm: Update for version 4.1.0 - - lib/egif_lib.c: (WRITE) change from a function to a macro. - - lib/dgif_lib.c: (DGifOpenFileName) close FileHandle on error. - - lib/dgif_lib.c: (DGifOpenFileHandle) make sure the FILE stream is - closed if we hit an error. - - lib/dev2gif.c, lib/quantize.c, lib/gif_err.c, lib/gif_lib_private.h: - Reflect Eric's copyright notice rather than Gershon's - -1999 14 Jan Michael R Brown - * lib/gif_lib.h: Add OutputFunc type - * lib/gif_lib.h: Add EGifOpen for user supplied output function - * lib/egif_lib.c: (EGifOpenFileName) Fixed wasted memory when an - error occurs in EGifOpenFileHandle - * lib/egif_lib.c: Add EGifOpen, WRITE, and lots of changes to - support user supplied output function. Basically changing - all fwrite's to WRITE, and then all of the knock on effects. - -1998 17 Dec Toshio Kuratomi - * configure.in: Change references to libungif to giflib. - * libungif.lsm: Rename to giflib.lsm and change to reflect giflib - rather than libungif. - * libungif.spec: Rename to giflib.spec and change to reflect giflib - rather than libungif. - * UNCOMPRESSED_GIF: Removed from this branch. - * PATENT_PROBLEMS: Add file explaining Unisys's patent claims. - * Makefile.am: Replace libungif with giflib. - * README: Adapted language to giflib. - * lib/Makefile.am: Changed references to libungif to libgif. - * util/Makefile.am: Changed references to libungif to libgif. - -1998 17 Dec Toshio Kuratomi - * lib/egif_lib.c: Merge LZW stuff into this branch of the library. - This includes numerous changes to initialize the hash table as well - as the code forthe encoder. - * lib/gif_hash.c: Functions needed for the LZW encoder. - * lib/gif_hash.h: Functions needed for the LZW encoder. - * lib/Makefile.am: Add gif_hash.c gif_hash.h to the list of sources. - -1998 15 Dec Toshio Kuratomi - * lib/dgif_lib.c: (DGifSlurp) Fix a Seg Fault when an image contains - no extension blocks. - -1998 14 Dec Toshio Kuratomi - * configure.in: Update version to 4.0 - * lib/Makefile.am: Update libtool version to 4:0:0 (libtool) - * libungif.spec: Update for version 4.0 (not binary compatible with - giflib, change version.) - * lib/gif_lib_private.h: (PrivateType) New header for common stuff - private to the library. Currently, this is only the Private struct. - * lib/dgif_lib.c: (PrivateType) Extract the Private struct to - gif_lib_private.h - * lib/egif_lib.c: (PrivateType) Extract the Private struct to - gif_lib_private.h - * lib/Makefile.am: Add gif_lib_private.h to the list of source files. - * lib/gif_lib.h: (ExtensionBlock) Add a Function entry to the - ExtensionBlock record. Note that this is not entirely correct: - the GifLib ExtensionBlock structure is actually a data sub-block - record. By adding the function entry here, we are pushing the - ExtensionBlockType in with the DataSubBlock. - Sometime in the future, we need to change the API to have true - ExtensionBlocks which have DataSubBlocks belonging to them. - * lib/gif_lib.h: (ExtensionBlock) Deprecate the use of Function in - the SavedImage struct. Use ExtensionBlock's Function instead. - * lib/egif_lib.c: (EGifSpew) Changes to use the new Function variable. - * lib/dgif_lib.c: (DGifSlurp) Changes to put data into the new - Function variable. - -1998 3 Dec Toshio Kuratomi - * lib/dgif_lib.c: (DGifSlurp) Three changes: - - No longer allocate SaveImage in this function. All allocations - of SaveImage take place in DGifGetImageDesc. - - Extension blocks are now associated with the Image Block that is - read in subsequent to them, not before. This should now be - conformant to the gif89a specification. - - Fix an off-by-one error when copying extension data from structure - to structure. - * lib/dgif_lib.c: (DGifGetImageDesc) Change the function to do its own - allocation of space for the SavedImage structure no matter what. - * lib/egif_lib.c: (EGifSpew) The function now spits out - ExtensionBlocks before the associated Image Block to conform with - the gif89a specification. - * lib/egif_lib.c: (EGifOpenFileHandle) Move the write of the - GifVersion (gif87a or gif89a) from this function into - EGifPutScreenDesc so that it can be controlled by EGifSpew. Note - that this is still a hack as the GifVersion write doesn't really - belong in either of these functions. - * lib/egif_lib.c: (EGifPutScreenDesc) Moved writing the version - (gif87a or gif89a) into the file into this function from - EGifOpenFileHandle. - * test-unx: Now test the extension code. - * pic/x-trans.gif: New image with Comments and transparency to test - the extension code with. - -1998 29 Nov Toshio Kuratomi - * lib/dgif_lib.c: (DGifSlurp) Fix a few of the minor bugs plaguing - this function. At this point, the function should no longer cause - a Seg Fault. It is now losing all extension data however. I know - how to hack a fix in, but I need to commit these changes first. - * lib/dgif_lib.c: (DGifGetImageDesc) Fix my bug fix: the colormap is - now only copied if it exists :-). - -1998 10 Nov Toshio Kuratomi - * test-unx: Add a test for DGifSlurp and EGifSpew - -1998 14 Oct Toshio Kuratomi - * lib/dgif_lib.c: (DGifGetImageDesc) Fix a bug where the Colormap for - the image description and the SaveImage were pointers to the same - structure, causing a SegV when DGifClosing the file. - -1998 9 Oct Toshio Kuratomi - * lib/dgif_lib.c: (DGifSlurp) memory for the extensions was not being - allocated. Now I call AddExtensionBlock when I add an extension to - the structure. Additionally, fix a memory leak here. - * configure.in, NEWS, lib/Makefile.am: Update to version 3.1.1 - * ltmain.sh, ltconfig: removed from the cvs repository - * BUGS: add the BUGS file to list unresolved BUGS. - -1998 9 Sep Toshio Kuratomi - * libungif.spec: Fix wrong version in %files and %install section. - -1998 8 Sep Toshio Kuratomi - * lib/gif_hash.c, lib/gif_hash.h: Removed these because a hash table - is not needed to create uncompressed gifs. - * lib/egif_lib.c: Remove all references to the hash functions. - * lib/Makefile.am: Remove gif_hash.c gif_hash.h from the source files. - * libungif.lsm: added this file - -1998 7 Sep Toshio Kuratomi - * lib/dgif_lib.c, lib/gif_lib.h: (DGifOpen) Add callback to read gif - image through user supplied function (Peter Mehlitz). - -1998 6 Sep Toshio Kuratomi - * util/*.{gif.rle}: removed files that were left by my testing - process and shouldn't have been in the distribution. - * UNCOMPRESSED_GIF: add section on why software that can decode - LZW compressed gifs (but not write them) is legal. - * .cvsignore: added .cvsignore files to ignore Makefiles and other - generated files in my cvs repository. - * Makefile.am's: Fixes to allow the dist* family of targets to work - correctly. Preliminary support for make check as well. - * configure.in: Update version to 3.1.0 - * lib/Makefile.am: Update libtool version to 4:0:1 libtool) - * libungif-3.0.spec: Update from Marc Ewing. - * Add int/pointer Alpha fixes from Dick Porter to many source files. diff --git a/oversampling/WDL/giflib/DEVELOPERS b/oversampling/WDL/giflib/DEVELOPERS deleted file mode 100644 index 2d3f6de..0000000 --- a/oversampling/WDL/giflib/DEVELOPERS +++ /dev/null @@ -1,29 +0,0 @@ -Things to tell developers of libungif.... - -======= -Build Tools: -libungif presently uses autoconf, automake, and libtool in order to build -shared libraries for a wide variety of platforms. The distributed tarball has -files prebuilt from these tools. The cvs repository does not. If you want to -build libungif you will need to have these tools available. I currently run -with the following versions: -autoconf 2.57 -automake 1.7.8 -libtool 1.5 - -(P.S. I use the autogen.sh script in the top level directory to generate -configure, Makefile.in, etc using these tools.) - -======= -cvs: -I currently do my work in a subversion repository. Since sourceforge is still -using cvs and not subversion, there's nothing in the sourceforge tree. - -If someone else wants to do development we can definitely talk about the best -way to share version control access. - -======= -I create the distribution tar ball by using the `make dist` command.... After -hacking all I want, I check my sources into cvs, checkout a clean tree, run -./autogen.sh; make dist and then attempt to compile from the libungif-*.tar.gz -file that is generated. diff --git a/oversampling/WDL/giflib/README b/oversampling/WDL/giflib/README deleted file mode 100644 index 90e8dbf..0000000 --- a/oversampling/WDL/giflib/README +++ /dev/null @@ -1,69 +0,0 @@ -This is giflib version 4.1.2, a library for manipulating gif files. It is based -on Eric S. Raymond's giflib-3.0 with bugfixes and changes generated for the -libungif library. - -PLEASE BE AWARE OF POSSIBLE LEGAL PROBLEMS WITH USING THIS LIBRARY: READ -THE PATENT_PROBLEMS FILE NOW! - -======= -Latest versions of giflib, as well as a library which does not have the -mentioned patent problems (libungif), are available from: - http://sourceforge.net/projects/libungif - -==== -Building this package should be as simple as: - - ./configure - gmake - gmake install - -==== -Deprecation list. Will be removed in giflib 5.0: -* GIF_ERROR and GIF_MESSAGE are on the deprecation list as they are also - utility helper functions rather than essential to the functioning of the - library. -* The qprintf methods of the library are now deprecated. Do not use - GifQuietPrint or GifQprintf. These should have been pushed out into the - utility helper library instead of sitting around in the library proper at - the same time as the getarg functions were moved out. Getting rid of these - will let us get rid of our dependence on stdarg.h/varargs.h (Which a Gif - reading library has no business requiring.) -* In the SavedImage struct: int Function will be removed. Use - SavedImage.ExtensionBlocks[x].Function instead. -* In gifalloc.c: MakeExtension is deprecated as well. Use AddExtensionBlock - instead. (This and the previous int Function were deprecated because they - only handle one Extension per image. The new code handles multiple - extensions.) -* varargs style interface in qprintf and getarg: It's a mistake to have two - different interfaces that depend on compile time choices between varargs - and stdargs. The future is to get rid of varargs style altogether. - (Also: these are probably going strictly into the utility functions so - the library won't have to worry about them at all.) -==== - -I have found that automake currently generates Makefile's containing some -GNUmake specific syntax. If you're having troubles building with your -system provided make, please install GNU make and try rebuilding. - -==== -This package uses autoconf, automake, and libtool to create the configure -script, so if you need to edit the configure.ac or change a makefile target -you should read the DEVELOPER file for hints on recreating the distribution -using these tools. - -Good luck! --Toshio Kuratomi - -==== READ.ME file for giflib version 3.0: - - READ ME for GIFLIB - -For complete documentation on the package, point a web browser at -doc/index.html. See the file INSTALL for instructions on how to -install and test the package. - -GIFLIB has a home page at http://www.ccil.org/~esr/giflib. - - Eric S. Raymond - esr@snark.thyrsus.com. - (http://www.ccil.org/~esr) diff --git a/oversampling/WDL/giflib/config.h b/oversampling/WDL/giflib/config.h deleted file mode 100644 index ba731f4..0000000 --- a/oversampling/WDL/giflib/config.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _CONFIG_H_ -#define _CONFIG_H_ -#ifdef _WIN32 -#include -#include -#define _OPEN_BINARY -#else -typedef unsigned int UINT32; -#include -#include -#include -#endif -#include -#endif diff --git a/oversampling/WDL/giflib/dgif_lib.c b/oversampling/WDL/giflib/dgif_lib.c deleted file mode 100644 index c460616..0000000 --- a/oversampling/WDL/giflib/dgif_lib.c +++ /dev/null @@ -1,962 +0,0 @@ -/****************************************************************************** - * "Gif-Lib" - Yet another gif library. - * - * Written by: Gershon Elber IBM PC Ver 1.1, Aug. 1990 - ****************************************************************************** - * The kernel of the GIF Decoding process can be found here. - ****************************************************************************** - * History: - * 16 Jun 89 - Version 1.0 by Gershon Elber. - * 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). - *****************************************************************************/ - -#include "config.h" - -#include -#if defined (__MSDOS__) && !defined(__DJGPP__) && !defined(__GNUC__) -#include -#include -#include -#else -#include -#include -#endif /* __MSDOS__ */ - -#ifdef HAVE_IO_H -#include -#endif - -#ifdef HAVE_FCNTL_H -#include -#endif /* HAVE_FCNTL_H */ -#ifdef HAVE_UNISTD_H -#include -#endif /* HAVE_UNISTD_H */ -#include -#include -#include "gif_lib.h" -#include "gif_lib_private.h" - -#define COMMENT_EXT_FUNC_CODE 0xfe /* Extension function code for - comment. */ - -/* avoid extra function call in case we use fread (TVT) */ -#define READ(_gif,_buf,_len) \ - (((GifFilePrivateType*)_gif->Private)->Read ? \ - ((GifFilePrivateType*)_gif->Private)->Read(_gif,_buf,_len) : \ - fread(_buf,1,_len,((GifFilePrivateType*)_gif->Private)->File)) - -static int DGifGetWord(GifFileType *GifFile, GifWord *Word); -static int DGifSetupDecompress(GifFileType *GifFile); -static int DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line, - int LineLen); -static int DGifGetPrefixChar(GifPrefixType *Prefix, int Code, int ClearCode); -static int DGifDecompressInput(GifFileType *GifFile, int *Code); -static int DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf, - GifByteType *NextByte); -#ifndef _GBA_NO_FILEIO - -/****************************************************************************** - * Open a new gif file for read, given by its name. - * Returns GifFileType pointer dynamically allocated which serves as the gif - * info record. _GifError is cleared if succesfull. - *****************************************************************************/ -GifFileType * -DGifOpenFileName(const char *FileName) { - int FileHandle; - GifFileType *GifFile; - - if ((FileHandle = open(FileName, O_RDONLY -#if defined(__MSDOS__) || defined(_OPEN_BINARY) - | O_BINARY -#endif /* __MSDOS__ || _OPEN_BINARY */ - )) == -1) { - _GifError = D_GIF_ERR_OPEN_FAILED; - return NULL; - } - - GifFile = DGifOpenFileHandle(FileHandle); - if (GifFile == (GifFileType *)NULL) - close(FileHandle); - return GifFile; -} - -/****************************************************************************** - * Update a new gif file, given its file handle. - * Returns GifFileType pointer dynamically allocated which serves as the gif - * info record. _GifError is cleared if succesfull. - *****************************************************************************/ -GifFileType * -DGifOpenFileHandle(int FileHandle) { - - unsigned char Buf[GIF_STAMP_LEN + 1]; - GifFileType *GifFile; - GifFilePrivateType *Private; - FILE *f; - - GifFile = (GifFileType *)malloc(sizeof(GifFileType)); - if (GifFile == NULL) { - _GifError = D_GIF_ERR_NOT_ENOUGH_MEM; - return NULL; - } - - memset(GifFile, '\0', sizeof(GifFileType)); - - Private = (GifFilePrivateType *)malloc(sizeof(GifFilePrivateType)); - if (Private == NULL) { - _GifError = D_GIF_ERR_NOT_ENOUGH_MEM; - free((char *)GifFile); - return NULL; - } -#ifdef __MSDOS__ - setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */ -#endif /* __MSDOS__ */ - - f = fdopen(FileHandle, "rb"); /* Make it into a stream: */ - -#ifdef __MSDOS__ - setvbuf(f, NULL, _IOFBF, GIF_FILE_BUFFER_SIZE); /* And inc. stream - buffer. */ -#endif /* __MSDOS__ */ - - GifFile->Private = (VoidPtr)Private; - Private->FileHandle = FileHandle; - Private->File = f; - Private->FileState = FILE_STATE_READ; - Private->Read = 0; /* don't use alternate input method (TVT) */ - GifFile->UserData = 0; /* TVT */ - - /* Lets see if this is a GIF file: */ - if (READ(GifFile, Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) { - _GifError = D_GIF_ERR_READ_FAILED; - fclose(f); - free((char *)Private); - free((char *)GifFile); - return NULL; - } - - /* The GIF Version number is ignored at this time. Maybe we should do - * something more useful with it. */ - Buf[GIF_STAMP_LEN] = 0; - if (strncmp(GIF_STAMP, (char*)Buf, GIF_VERSION_POS) != 0) { - _GifError = D_GIF_ERR_NOT_GIF_FILE; - fclose(f); - free((char *)Private); - free((char *)GifFile); - return NULL; - } - - if (DGifGetScreenDesc(GifFile) == GIF_ERROR) { - fclose(f); - free((char *)Private); - free((char *)GifFile); - return NULL; - } - - _GifError = 0; - - return GifFile; -} - -#endif /* _GBA_NO_FILEIO */ - -/****************************************************************************** - * GifFileType constructor with user supplied input function (TVT) - *****************************************************************************/ -GifFileType * -DGifOpen(void *userData, - InputFunc readFunc) { - - unsigned char Buf[GIF_STAMP_LEN + 1]; - GifFileType *GifFile; - GifFilePrivateType *Private; - - GifFile = (GifFileType *)malloc(sizeof(GifFileType)); - if (GifFile == NULL) { - _GifError = D_GIF_ERR_NOT_ENOUGH_MEM; - return NULL; - } - - memset(GifFile, '\0', sizeof(GifFileType)); - - Private = (GifFilePrivateType *)malloc(sizeof(GifFilePrivateType)); - if (!Private) { - _GifError = D_GIF_ERR_NOT_ENOUGH_MEM; - free((char *)GifFile); - return NULL; - } - - GifFile->Private = (VoidPtr)Private; - Private->FileHandle = 0; - Private->File = 0; - Private->FileState = FILE_STATE_READ; - - Private->Read = readFunc; /* TVT */ - GifFile->UserData = userData; /* TVT */ - - /* Lets see if this is a GIF file: */ - if (READ(GifFile, Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) { - _GifError = D_GIF_ERR_READ_FAILED; - free((char *)Private); - free((char *)GifFile); - return NULL; - } - - /* The GIF Version number is ignored at this time. Maybe we should do - * something more useful with it. */ - Buf[GIF_STAMP_LEN] = 0; - if (strncmp(GIF_STAMP, (char*)Buf, GIF_VERSION_POS) != 0) { - _GifError = D_GIF_ERR_NOT_GIF_FILE; - free((char *)Private); - free((char *)GifFile); - return NULL; - } - - if (DGifGetScreenDesc(GifFile) == GIF_ERROR) { - free((char *)Private); - free((char *)GifFile); - return NULL; - } - - _GifError = 0; - - return GifFile; -} - -/****************************************************************************** - * This routine should be called before any other DGif calls. Note that - * this routine is called automatically from DGif file open routines. - *****************************************************************************/ -int -DGifGetScreenDesc(GifFileType * GifFile) { - - int i, BitsPerPixel; - GifByteType Buf[3]; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_READABLE(Private)) { - /* This file was NOT open for reading: */ - _GifError = D_GIF_ERR_NOT_READABLE; - return GIF_ERROR; - } - - /* Put the screen descriptor into the file: */ - if (DGifGetWord(GifFile, &GifFile->SWidth) == GIF_ERROR || - DGifGetWord(GifFile, &GifFile->SHeight) == GIF_ERROR) - return GIF_ERROR; - - if (READ(GifFile, Buf, 3) != 3) { - _GifError = D_GIF_ERR_READ_FAILED; - return GIF_ERROR; - } - GifFile->SColorResolution = (((Buf[0] & 0x70) + 1) >> 4) + 1; - BitsPerPixel = (Buf[0] & 0x07) + 1; - GifFile->SBackGroundColor = Buf[1]; - if (Buf[0] & 0x80) { /* Do we have global color map? */ - - GifFile->SColorMap = MakeMapObject(1 << BitsPerPixel, NULL); - if (GifFile->SColorMap == NULL) { - _GifError = D_GIF_ERR_NOT_ENOUGH_MEM; - return GIF_ERROR; - } - - /* Get the global color map: */ - for (i = 0; i < GifFile->SColorMap->ColorCount; i++) { - if (READ(GifFile, Buf, 3) != 3) { - FreeMapObject(GifFile->SColorMap); - GifFile->SColorMap = NULL; - _GifError = D_GIF_ERR_READ_FAILED; - return GIF_ERROR; - } - GifFile->SColorMap->Colors[i].Red = Buf[0]; - GifFile->SColorMap->Colors[i].Green = Buf[1]; - GifFile->SColorMap->Colors[i].Blue = Buf[2]; - } - } else { - GifFile->SColorMap = NULL; - } - - return GIF_OK; -} - -/****************************************************************************** - * This routine should be called before any attempt to read an image. - *****************************************************************************/ -int -DGifGetRecordType(GifFileType * GifFile, - GifRecordType * Type) { - - GifByteType Buf; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_READABLE(Private)) { - /* This file was NOT open for reading: */ - _GifError = D_GIF_ERR_NOT_READABLE; - return GIF_ERROR; - } - - if (READ(GifFile, &Buf, 1) != 1) { - _GifError = D_GIF_ERR_READ_FAILED; - return GIF_ERROR; - } - - switch (Buf) { - case ',': - *Type = IMAGE_DESC_RECORD_TYPE; - break; - case '!': - *Type = EXTENSION_RECORD_TYPE; - break; - case ';': - *Type = TERMINATE_RECORD_TYPE; - break; - default: - *Type = UNDEFINED_RECORD_TYPE; - _GifError = D_GIF_ERR_WRONG_RECORD; - return GIF_ERROR; - } - - return GIF_OK; -} - -/****************************************************************************** - * This routine should be called before any attempt to read an image. - * Note it is assumed the Image desc. header (',') has been read. - *****************************************************************************/ -int -DGifGetImageDesc(GifFileType * GifFile) { - - int i, BitsPerPixel; - GifByteType Buf[3]; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_READABLE(Private)) { - /* This file was NOT open for reading: */ - _GifError = D_GIF_ERR_NOT_READABLE; - return GIF_ERROR; - } - - if (DGifGetWord(GifFile, &GifFile->Image.Left) == GIF_ERROR || - DGifGetWord(GifFile, &GifFile->Image.Top) == GIF_ERROR || - DGifGetWord(GifFile, &GifFile->Image.Width) == GIF_ERROR || - DGifGetWord(GifFile, &GifFile->Image.Height) == GIF_ERROR) - return GIF_ERROR; - if (READ(GifFile, Buf, 1) != 1) { - _GifError = D_GIF_ERR_READ_FAILED; - return GIF_ERROR; - } - BitsPerPixel = (Buf[0] & 0x07) + 1; - GifFile->Image.Interlace = (Buf[0] & 0x40); - if (Buf[0] & 0x80) { /* Does this image have local color map? */ - - if (GifFile->Image.ColorMap) - FreeMapObject(GifFile->Image.ColorMap); - - GifFile->Image.ColorMap = MakeMapObject(1 << BitsPerPixel, NULL); - if (GifFile->Image.ColorMap == NULL) { - _GifError = D_GIF_ERR_NOT_ENOUGH_MEM; - return GIF_ERROR; - } - - /* Get the image local color map: */ - for (i = 0; i < GifFile->Image.ColorMap->ColorCount; i++) { - if (READ(GifFile, Buf, 3) != 3) { - FreeMapObject(GifFile->Image.ColorMap); - _GifError = D_GIF_ERR_READ_FAILED; - GifFile->Image.ColorMap = NULL; - return GIF_ERROR; - } - GifFile->Image.ColorMap->Colors[i].Red = Buf[0]; - GifFile->Image.ColorMap->Colors[i].Green = Buf[1]; - GifFile->Image.ColorMap->Colors[i].Blue = Buf[2]; - } - } else if (GifFile->Image.ColorMap) { - FreeMapObject(GifFile->Image.ColorMap); - GifFile->Image.ColorMap = NULL; - } - - GifFile->ImageCount++; - - Private->PixelCount = (long)GifFile->Image.Width * - (long)GifFile->Image.Height; - - DGifSetupDecompress(GifFile); /* Reset decompress algorithm parameters. */ - - return GIF_OK; -} - -/****************************************************************************** - * Get one full scanned line (Line) of length LineLen from GIF file. - *****************************************************************************/ -int -DGifGetLine(GifFileType * GifFile, - GifPixelType * Line, - int LineLen) { - - GifByteType *Dummy; - GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; - - if (!IS_READABLE(Private)) { - /* This file was NOT open for reading: */ - _GifError = D_GIF_ERR_NOT_READABLE; - return GIF_ERROR; - } - - if (!LineLen) - LineLen = GifFile->Image.Width; - -#if defined(__MSDOS__) || defined(__GNUC__) - if ((Private->PixelCount -= LineLen) > 0xffff0000UL) { -#else - if ((Private->PixelCount -= LineLen) > 0xffff0000) { -#endif /* __MSDOS__ */ - _GifError = D_GIF_ERR_DATA_TOO_BIG; - return GIF_ERROR; - } - - if (DGifDecompressLine(GifFile, Line, LineLen) == GIF_OK) { - if (Private->PixelCount == 0) { - /* We probably would not be called any more, so lets clean - * everything before we return: need to flush out all rest of - * image until empty block (size 0) detected. We use GetCodeNext. */ - do - if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR) - return GIF_ERROR; - while (Dummy != NULL) ; - } - return GIF_OK; - } else - return GIF_ERROR; -} - -/****************************************************************************** - * Put one pixel (Pixel) into GIF file. - *****************************************************************************/ -int -DGifGetPixel(GifFileType * GifFile, - GifPixelType Pixel) { - - GifByteType *Dummy; - GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; - - if (!IS_READABLE(Private)) { - /* This file was NOT open for reading: */ - _GifError = D_GIF_ERR_NOT_READABLE; - return GIF_ERROR; - } -#if defined(__MSDOS__) || defined(__GNUC__) - if (--Private->PixelCount > 0xffff0000UL) -#else - if (--Private->PixelCount > 0xffff0000) -#endif /* __MSDOS__ */ - { - _GifError = D_GIF_ERR_DATA_TOO_BIG; - return GIF_ERROR; - } - - if (DGifDecompressLine(GifFile, &Pixel, 1) == GIF_OK) { - if (Private->PixelCount == 0) { - /* We probably would not be called any more, so lets clean - * everything before we return: need to flush out all rest of - * image until empty block (size 0) detected. We use GetCodeNext. */ - do - if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR) - return GIF_ERROR; - while (Dummy != NULL) ; - } - return GIF_OK; - } else - return GIF_ERROR; -} - -/****************************************************************************** - * Get an extension block (see GIF manual) from gif file. This routine only - * returns the first data block, and DGifGetExtensionNext should be called - * after this one until NULL extension is returned. - * The Extension should NOT be freed by the user (not dynamically allocated). - * Note it is assumed the Extension desc. header ('!') has been read. - *****************************************************************************/ -int -DGifGetExtension(GifFileType * GifFile, - int *ExtCode, - GifByteType ** Extension) { - - GifByteType Buf; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_READABLE(Private)) { - /* This file was NOT open for reading: */ - _GifError = D_GIF_ERR_NOT_READABLE; - return GIF_ERROR; - } - - if (READ(GifFile, &Buf, 1) != 1) { - _GifError = D_GIF_ERR_READ_FAILED; - return GIF_ERROR; - } - *ExtCode = Buf; - - return DGifGetExtensionNext(GifFile, Extension); -} - -/****************************************************************************** - * Get a following extension block (see GIF manual) from gif file. This - * routine should be called until NULL Extension is returned. - * The Extension should NOT be freed by the user (not dynamically allocated). - *****************************************************************************/ -int -DGifGetExtensionNext(GifFileType * GifFile, - GifByteType ** Extension) { - - GifByteType Buf; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (READ(GifFile, &Buf, 1) != 1) { - _GifError = D_GIF_ERR_READ_FAILED; - return GIF_ERROR; - } - if (Buf > 0) { - *Extension = Private->Buf; /* Use private unused buffer. */ - (*Extension)[0] = Buf; /* Pascal strings notation (pos. 0 is len.). */ - if (READ(GifFile, &((*Extension)[1]), Buf) != Buf) { - _GifError = D_GIF_ERR_READ_FAILED; - return GIF_ERROR; - } - } else - *Extension = NULL; - - return GIF_OK; -} - -/****************************************************************************** - * This routine should be called last, to close the GIF file. - *****************************************************************************/ -int -DGifCloseFile(GifFileType * GifFile) { - - GifFilePrivateType *Private; - FILE *File; - - if (GifFile == NULL) - return GIF_ERROR; - - Private = (GifFilePrivateType *) GifFile->Private; - - if (!IS_READABLE(Private)) { - /* This file was NOT open for reading: */ - _GifError = D_GIF_ERR_NOT_READABLE; - return GIF_ERROR; - } - - File = Private->File; - - if (GifFile->Image.ColorMap) { - FreeMapObject(GifFile->Image.ColorMap); - GifFile->Image.ColorMap = NULL; - } - - if (GifFile->SColorMap) { - FreeMapObject(GifFile->SColorMap); - GifFile->SColorMap = NULL; - } - - if (Private) { - free((char *)Private); - Private = NULL; - } - - free(GifFile); - - if (File && (fclose(File) != 0)) { - _GifError = D_GIF_ERR_CLOSE_FAILED; - return GIF_ERROR; - } - return GIF_OK; -} - -/****************************************************************************** - * Get 2 bytes (word) from the given file: - *****************************************************************************/ -static int -DGifGetWord(GifFileType * GifFile, - GifWord *Word) { - - unsigned char c[2]; - - if (READ(GifFile, c, 2) != 2) { - _GifError = D_GIF_ERR_READ_FAILED; - return GIF_ERROR; - } - - *Word = (((unsigned int)c[1]) << 8) + c[0]; - return GIF_OK; -} - -/****************************************************************************** - * Get the image code in compressed form. This routine can be called if the - * information needed to be piped out as is. Obviously this is much faster - * than decoding and encoding again. This routine should be followed by calls - * to DGifGetCodeNext, until NULL block is returned. - * The block should NOT be freed by the user (not dynamically allocated). - *****************************************************************************/ -int -DGifGetCode(GifFileType * GifFile, - int *CodeSize, - GifByteType ** CodeBlock) { - - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_READABLE(Private)) { - /* This file was NOT open for reading: */ - _GifError = D_GIF_ERR_NOT_READABLE; - return GIF_ERROR; - } - - *CodeSize = Private->BitsPerPixel; - - return DGifGetCodeNext(GifFile, CodeBlock); -} - -/****************************************************************************** - * Continue to get the image code in compressed form. This routine should be - * called until NULL block is returned. - * The block should NOT be freed by the user (not dynamically allocated). - *****************************************************************************/ -int -DGifGetCodeNext(GifFileType * GifFile, - GifByteType ** CodeBlock) { - - GifByteType Buf; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (READ(GifFile, &Buf, 1) != 1) { - _GifError = D_GIF_ERR_READ_FAILED; - return GIF_ERROR; - } - - if (Buf > 0) { - *CodeBlock = Private->Buf; /* Use private unused buffer. */ - (*CodeBlock)[0] = Buf; /* Pascal strings notation (pos. 0 is len.). */ - if (READ(GifFile, &((*CodeBlock)[1]), Buf) != Buf) { - _GifError = D_GIF_ERR_READ_FAILED; - return GIF_ERROR; - } - } else { - *CodeBlock = NULL; - Private->Buf[0] = 0; /* Make sure the buffer is empty! */ - Private->PixelCount = 0; /* And local info. indicate image read. */ - } - - return GIF_OK; -} - -/****************************************************************************** - * Setup the LZ decompression for this image: - *****************************************************************************/ -static int -DGifSetupDecompress(GifFileType * GifFile) { - - int i, BitsPerPixel; - GifByteType CodeSize; - GifPrefixType *Prefix; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - READ(GifFile, &CodeSize, 1); /* Read Code size from file. */ - BitsPerPixel = CodeSize; - - Private->Buf[0] = 0; /* Input Buffer empty. */ - Private->BitsPerPixel = BitsPerPixel; - Private->ClearCode = (1 << BitsPerPixel); - Private->EOFCode = Private->ClearCode + 1; - Private->RunningCode = Private->EOFCode + 1; - Private->RunningBits = BitsPerPixel + 1; /* Number of bits per code. */ - Private->MaxCode1 = 1 << Private->RunningBits; /* Max. code + 1. */ - Private->StackPtr = 0; /* No pixels on the pixel stack. */ - Private->LastCode = NO_SUCH_CODE; - Private->CrntShiftState = 0; /* No information in CrntShiftDWord. */ - Private->CrntShiftDWord = 0; - - Prefix = Private->Prefix; - for (i = 0; i <= LZ_MAX_CODE; i++) - Prefix[i] = NO_SUCH_CODE; - - return GIF_OK; -} - -/****************************************************************************** - * The LZ decompression routine: - * This version decompress the given gif file into Line of length LineLen. - * This routine can be called few times (one per scan line, for example), in - * order the complete the whole image. - *****************************************************************************/ -static int -DGifDecompressLine(GifFileType * GifFile, - GifPixelType * Line, - int LineLen) { - - int i = 0; - int j, CrntCode, EOFCode, ClearCode, CrntPrefix, LastCode, StackPtr; - GifByteType *Stack, *Suffix; - GifPrefixType *Prefix; - GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; - - StackPtr = Private->StackPtr; - Prefix = Private->Prefix; - Suffix = Private->Suffix; - Stack = Private->Stack; - EOFCode = Private->EOFCode; - ClearCode = Private->ClearCode; - LastCode = Private->LastCode; - - if (StackPtr != 0) { - /* Let pop the stack off before continueing to read the gif file: */ - while (StackPtr != 0 && i < LineLen) - Line[i++] = Stack[--StackPtr]; - } - - while (i < LineLen) { /* Decode LineLen items. */ - if (DGifDecompressInput(GifFile, &CrntCode) == GIF_ERROR) - return GIF_ERROR; - - if (CrntCode == EOFCode) { - /* Note however that usually we will not be here as we will stop - * decoding as soon as we got all the pixel, or EOF code will - * not be read at all, and DGifGetLine/Pixel clean everything. */ - if (i != LineLen - 1 || Private->PixelCount != 0) { - _GifError = D_GIF_ERR_EOF_TOO_SOON; - return GIF_ERROR; - } - i++; - } else if (CrntCode == ClearCode) { - /* We need to start over again: */ - for (j = 0; j <= LZ_MAX_CODE; j++) - Prefix[j] = NO_SUCH_CODE; - Private->RunningCode = Private->EOFCode + 1; - Private->RunningBits = Private->BitsPerPixel + 1; - Private->MaxCode1 = 1 << Private->RunningBits; - LastCode = Private->LastCode = NO_SUCH_CODE; - } else { - /* Its regular code - if in pixel range simply add it to output - * stream, otherwise trace to codes linked list until the prefix - * is in pixel range: */ - if (CrntCode < ClearCode) { - /* This is simple - its pixel scalar, so add it to output: */ - Line[i++] = CrntCode; - } else { - /* Its a code to needed to be traced: trace the linked list - * until the prefix is a pixel, while pushing the suffix - * pixels on our stack. If we done, pop the stack in reverse - * (thats what stack is good for!) order to output. */ - if (Prefix[CrntCode] == NO_SUCH_CODE) { - /* Only allowed if CrntCode is exactly the running code: - * In that case CrntCode = XXXCode, CrntCode or the - * prefix code is last code and the suffix char is - * exactly the prefix of last code! */ - if (CrntCode == Private->RunningCode - 2) { - CrntPrefix = LastCode; - Suffix[Private->RunningCode - 2] = - Stack[StackPtr++] = DGifGetPrefixChar(Prefix, - LastCode, - ClearCode); - } else { - _GifError = D_GIF_ERR_IMAGE_DEFECT; - return GIF_ERROR; - } - } else - CrntPrefix = CrntCode; - - /* Now (if image is O.K.) we should not get an NO_SUCH_CODE - * During the trace. As we might loop forever, in case of - * defective image, we count the number of loops we trace - * and stop if we got LZ_MAX_CODE. obviously we can not - * loop more than that. */ - j = 0; - while (j++ <= LZ_MAX_CODE && - CrntPrefix > ClearCode && CrntPrefix <= LZ_MAX_CODE) { - Stack[StackPtr++] = Suffix[CrntPrefix]; - CrntPrefix = Prefix[CrntPrefix]; - } - if (j >= LZ_MAX_CODE || CrntPrefix > LZ_MAX_CODE) { - _GifError = D_GIF_ERR_IMAGE_DEFECT; - return GIF_ERROR; - } - /* Push the last character on stack: */ - Stack[StackPtr++] = CrntPrefix; - - /* Now lets pop all the stack into output: */ - while (StackPtr != 0 && i < LineLen) - Line[i++] = Stack[--StackPtr]; - } - if (LastCode != NO_SUCH_CODE) { - Prefix[Private->RunningCode - 2] = LastCode; - - if (CrntCode == Private->RunningCode - 2) { - /* Only allowed if CrntCode is exactly the running code: - * In that case CrntCode = XXXCode, CrntCode or the - * prefix code is last code and the suffix char is - * exactly the prefix of last code! */ - Suffix[Private->RunningCode - 2] = - DGifGetPrefixChar(Prefix, LastCode, ClearCode); - } else { - Suffix[Private->RunningCode - 2] = - DGifGetPrefixChar(Prefix, CrntCode, ClearCode); - } - } - LastCode = CrntCode; - } - } - - Private->LastCode = LastCode; - Private->StackPtr = StackPtr; - - return GIF_OK; -} - -/****************************************************************************** - * Routine to trace the Prefixes linked list until we get a prefix which is - * not code, but a pixel value (less than ClearCode). Returns that pixel value. - * If image is defective, we might loop here forever, so we limit the loops to - * the maximum possible if image O.k. - LZ_MAX_CODE times. - *****************************************************************************/ -static int -DGifGetPrefixChar(GifPrefixType *Prefix, - int Code, - int ClearCode) { - - int i = 0; - - while (Code > ClearCode && i++ <= LZ_MAX_CODE) - Code = Prefix[Code]; - return Code; -} - -/****************************************************************************** - * Interface for accessing the LZ codes directly. Set Code to the real code - * (12bits), or to -1 if EOF code is returned. - *****************************************************************************/ -int -DGifGetLZCodes(GifFileType * GifFile, - int *Code) { - - GifByteType *CodeBlock; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_READABLE(Private)) { - /* This file was NOT open for reading: */ - _GifError = D_GIF_ERR_NOT_READABLE; - return GIF_ERROR; - } - - if (DGifDecompressInput(GifFile, Code) == GIF_ERROR) - return GIF_ERROR; - - if (*Code == Private->EOFCode) { - /* Skip rest of codes (hopefully only NULL terminating block): */ - do { - if (DGifGetCodeNext(GifFile, &CodeBlock) == GIF_ERROR) - return GIF_ERROR; - } while (CodeBlock != NULL) ; - - *Code = -1; - } else if (*Code == Private->ClearCode) { - /* We need to start over again: */ - Private->RunningCode = Private->EOFCode + 1; - Private->RunningBits = Private->BitsPerPixel + 1; - Private->MaxCode1 = 1 << Private->RunningBits; - } - - return GIF_OK; -} - -/****************************************************************************** - * The LZ decompression input routine: - * This routine is responsable for the decompression of the bit stream from - * 8 bits (bytes) packets, into the real codes. - * Returns GIF_OK if read succesfully. - *****************************************************************************/ -static int -DGifDecompressInput(GifFileType * GifFile, - int *Code) { - - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - GifByteType NextByte; - static unsigned short CodeMasks[] = { - 0x0000, 0x0001, 0x0003, 0x0007, - 0x000f, 0x001f, 0x003f, 0x007f, - 0x00ff, 0x01ff, 0x03ff, 0x07ff, - 0x0fff - }; - /* The image can't contain more than LZ_BITS per code. */ - if (Private->RunningBits > LZ_BITS) { - _GifError = D_GIF_ERR_IMAGE_DEFECT; - return GIF_ERROR; - } - - while (Private->CrntShiftState < Private->RunningBits) { - /* Needs to get more bytes from input stream for next code: */ - if (DGifBufferedInput(GifFile, Private->Buf, &NextByte) == GIF_ERROR) { - return GIF_ERROR; - } - Private->CrntShiftDWord |= - ((unsigned long)NextByte) << Private->CrntShiftState; - Private->CrntShiftState += 8; - } - *Code = Private->CrntShiftDWord & CodeMasks[Private->RunningBits]; - - Private->CrntShiftDWord >>= Private->RunningBits; - Private->CrntShiftState -= Private->RunningBits; - - /* If code cannot fit into RunningBits bits, must raise its size. Note - * however that codes above 4095 are used for special signaling. - * If we're using LZ_BITS bits already and we're at the max code, just - * keep using the table as it is, don't increment Private->RunningCode. - */ - if (Private->RunningCode < LZ_MAX_CODE + 2 && - ++Private->RunningCode > Private->MaxCode1 && - Private->RunningBits < LZ_BITS) { - Private->MaxCode1 <<= 1; - Private->RunningBits++; - } - return GIF_OK; -} - -/****************************************************************************** - * This routines read one gif data block at a time and buffers it internally - * so that the decompression routine could access it. - * The routine returns the next byte from its internal buffer (or read next - * block in if buffer empty) and returns GIF_OK if succesful. - *****************************************************************************/ -static int -DGifBufferedInput(GifFileType * GifFile, - GifByteType * Buf, - GifByteType * NextByte) { - - if (Buf[0] == 0) { - /* Needs to read the next buffer - this one is empty: */ - if (READ(GifFile, Buf, 1) != 1) { - _GifError = D_GIF_ERR_READ_FAILED; - return GIF_ERROR; - } - /* There shouldn't be any empty data blocks here as the LZW spec - * says the LZW termination code should come first. Therefore we - * shouldn't be inside this routine at that point. - */ - if (Buf[0] == 0) { - _GifError = D_GIF_ERR_IMAGE_DEFECT; - return GIF_ERROR; - } - if (READ(GifFile, &Buf[1], Buf[0]) != Buf[0]) { - _GifError = D_GIF_ERR_READ_FAILED; - return GIF_ERROR; - } - *NextByte = Buf[1]; - Buf[1] = 2; /* We use now the second place as last char read! */ - Buf[0]--; - } else { - *NextByte = Buf[Buf[1]++]; - Buf[0]--; - } - - return GIF_OK; -} diff --git a/oversampling/WDL/giflib/egif_lib.c b/oversampling/WDL/giflib/egif_lib.c deleted file mode 100644 index 79108ae..0000000 --- a/oversampling/WDL/giflib/egif_lib.c +++ /dev/null @@ -1,998 +0,0 @@ -/****************************************************************************** - * "Gif-Lib" - Yet another gif library. - * - * Written by: Gershon Elber Ver 1.1, Aug. 1990 - ****************************************************************************** - * The kernel of the GIF Encoding process can be found here. - ****************************************************************************** - * History: - * 14 Jun 89 - Version 1.0 by Gershon Elber. - * 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). - * 26 Jun 96 - Version 3.0 by Eric S. Raymond (Full GIF89 support) - *****************************************************************************/ - -#include "config.h" - -/* Find a thirty-two bit int type */ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_STDINT_H -#include -#endif - -#ifdef __MSDOS__ -#include -#include -#include -#else -#include -#include -#ifdef R6000 - -/* FIXME: What is sys/mode.h? Can we substitute a check for this file rather - * than a check based on machine type? - */ -#include -#endif -#endif /* __MSDOS__ */ - -#ifdef HAVE_IO_H -#include -#endif - -#ifdef HAVE_FCNTL_H -#include -#endif /* HAVE_FCNTL_H */ -#ifdef HAVE_UNISTD_H -#include -#endif /* HAVE_UNISTD_H */ -#include -#include -#include -#include "gif_lib.h" -#include "gif_lib_private.h" - -/* #define DEBUG_NO_PREFIX Dump only compressed data. */ - -/* Masks given codes to BitsPerPixel, to make sure all codes are in range: */ -static GifPixelType CodeMask[] = { - 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff -}; - -static char GifVersionPrefix[GIF_STAMP_LEN + 1] = GIF87_STAMP; - -#define WRITE(_gif,_buf,_len) \ - (((GifFilePrivateType*)_gif->Private)->Write ? \ - ((GifFilePrivateType*)_gif->Private)->Write(_gif,_buf,_len) : \ - fwrite(_buf, 1, _len, ((GifFilePrivateType*)_gif->Private)->File)) - -static int EGifPutWord(int Word, GifFileType * GifFile); -static int EGifSetupCompress(GifFileType * GifFile); -static int EGifCompressLine(GifFileType * GifFile, GifPixelType * Line, - int LineLen); -static int EGifCompressOutput(GifFileType * GifFile, int Code); -static int EGifBufferedOutput(GifFileType * GifFile, GifByteType * Buf, - int c); - -/****************************************************************************** - * Open a new gif file for write, given by its name. If TestExistance then - * if the file exists this routines fails (returns NULL). - * Returns GifFileType pointer dynamically allocated which serves as the gif - * info record. _GifError is cleared if succesfull. - *****************************************************************************/ -GifFileType * -EGifOpenFileName(const char *FileName, - int TestExistance) { - - int FileHandle; - GifFileType *GifFile; - - if (TestExistance) - FileHandle = open(FileName, O_WRONLY | O_CREAT | O_EXCL -#if defined(__MSDOS__) || defined(_WIN32) - | O_BINARY -#endif /* __MSDOS__ */ - , 0644 ); - else - FileHandle = open(FileName, O_WRONLY | O_CREAT | O_TRUNC -#if defined(__MSDOS__) || defined(_WIN32) - | O_BINARY -#endif /* __MSDOS__ */ - , 0644 ); - - if (FileHandle == -1) { - _GifError = E_GIF_ERR_OPEN_FAILED; - return NULL; - } - GifFile = EGifOpenFileHandle(FileHandle); - if (GifFile == (GifFileType *) NULL) - close(FileHandle); - return GifFile; -} - -/****************************************************************************** - * Update a new gif file, given its file handle, which must be opened for - * write in binary mode. - * Returns GifFileType pointer dynamically allocated which serves as the gif - * info record. _GifError is cleared if succesfull. - *****************************************************************************/ -GifFileType * -EGifOpenFileHandle(int FileHandle) { - - GifFileType *GifFile; - GifFilePrivateType *Private; - FILE *f; - - GifFile = (GifFileType *) malloc(sizeof(GifFileType)); - if (GifFile == NULL) { - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return NULL; - } - - memset(GifFile, '\0', sizeof(GifFileType)); - - Private = (GifFilePrivateType *)malloc(sizeof(GifFilePrivateType)); - if (Private == NULL) { - free(GifFile); - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return NULL; - } - if ((Private->HashTable = _InitHashTable()) == NULL) { - free(GifFile); - free(Private); - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return NULL; - } - -#ifdef __MSDOS__ - setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */ -#endif /* __MSDOS__ */ - - f = fdopen(FileHandle, "wb"); /* Make it into a stream: */ - -#ifdef __MSDOS__ - setvbuf(f, NULL, _IOFBF, GIF_FILE_BUFFER_SIZE); /* And inc. stream - * buffer. */ -#endif /* __MSDOS__ */ - - GifFile->Private = (VoidPtr)Private; - Private->FileHandle = FileHandle; - Private->File = f; - Private->FileState = FILE_STATE_WRITE; - - Private->Write = (OutputFunc) 0; /* No user write routine (MRB) */ - GifFile->UserData = (VoidPtr) 0; /* No user write handle (MRB) */ - - _GifError = 0; - - return GifFile; -} - -/****************************************************************************** - * Output constructor that takes user supplied output function. - * Basically just a copy of EGifOpenFileHandle. (MRB) - *****************************************************************************/ -GifFileType * -EGifOpen(void *userData, - OutputFunc writeFunc) { - - GifFileType *GifFile; - GifFilePrivateType *Private; - - GifFile = (GifFileType *)malloc(sizeof(GifFileType)); - if (GifFile == NULL) { - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return NULL; - } - - memset(GifFile, '\0', sizeof(GifFileType)); - - Private = (GifFilePrivateType *)malloc(sizeof(GifFilePrivateType)); - if (Private == NULL) { - free(GifFile); - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return NULL; - } - - Private->HashTable = _InitHashTable(); - if (Private->HashTable == NULL) { - free (GifFile); - free (Private); - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return NULL; - } - - GifFile->Private = (VoidPtr) Private; - Private->FileHandle = 0; - Private->File = (FILE *) 0; - Private->FileState = FILE_STATE_WRITE; - - Private->Write = writeFunc; /* User write routine (MRB) */ - GifFile->UserData = userData; /* User write handle (MRB) */ - - _GifError = 0; - - return GifFile; -} - -/****************************************************************************** - * Routine to set current GIF version. All files open for write will be - * using this version until next call to this routine. Version consists of - * 3 characters as "87a" or "89a". No test is made to validate the version. - *****************************************************************************/ -void -EGifSetGifVersion(const char *Version) { - strncpy(GifVersionPrefix + GIF_VERSION_POS, Version, 3); -} - -/****************************************************************************** - * This routine should be called before any other EGif calls, immediately - * follows the GIF file openning. - *****************************************************************************/ -int -EGifPutScreenDesc(GifFileType * GifFile, - int Width, - int Height, - int ColorRes, - int BackGround, - const ColorMapObject * ColorMap) { - - int i; - GifByteType Buf[3]; - GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; - - if (Private->FileState & FILE_STATE_SCREEN) { - /* If already has screen descriptor - something is wrong! */ - _GifError = E_GIF_ERR_HAS_SCRN_DSCR; - return GIF_ERROR; - } - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - -/* First write the version prefix into the file. */ -#ifndef DEBUG_NO_PREFIX - if (WRITE(GifFile, (unsigned char *)GifVersionPrefix, - strlen(GifVersionPrefix)) != strlen(GifVersionPrefix)) { - _GifError = E_GIF_ERR_WRITE_FAILED; - return GIF_ERROR; - } -#endif /* DEBUG_NO_PREFIX */ - - GifFile->SWidth = Width; - GifFile->SHeight = Height; - GifFile->SColorResolution = ColorRes; - GifFile->SBackGroundColor = BackGround; - if (ColorMap) { - GifFile->SColorMap = MakeMapObject(ColorMap->ColorCount, - ColorMap->Colors); - if (GifFile->SColorMap == NULL) { - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return GIF_ERROR; - } - } else - GifFile->SColorMap = NULL; - - /* - * Put the logical screen descriptor into the file: - */ - /* Logical Screen Descriptor: Dimensions */ - EGifPutWord(Width, GifFile); - EGifPutWord(Height, GifFile); - - /* Logical Screen Descriptor: Packed Fields */ - /* Note: We have actual size of the color table default to the largest - * possible size (7+1 == 8 bits) because the decoder can use it to decide - * how to display the files. - */ - Buf[0] = (ColorMap ? 0x80 : 0x00) | /* Yes/no global colormap */ - ((ColorRes - 1) << 4) | /* Bits allocated to each primary color */ - (ColorMap ? ColorMap->BitsPerPixel - 1 : 0x07 ); /* Actual size of the - color table. */ - Buf[1] = BackGround; /* Index into the ColorTable for background color */ - Buf[2] = 0; /* Pixel Aspect Ratio */ -#ifndef DEBUG_NO_PREFIX - WRITE(GifFile, Buf, 3); -#endif /* DEBUG_NO_PREFIX */ - - /* If we have Global color map - dump it also: */ -#ifndef DEBUG_NO_PREFIX - if (ColorMap != NULL) - for (i = 0; i < ColorMap->ColorCount; i++) { - /* Put the ColorMap out also: */ - Buf[0] = ColorMap->Colors[i].Red; - Buf[1] = ColorMap->Colors[i].Green; - Buf[2] = ColorMap->Colors[i].Blue; - if (WRITE(GifFile, Buf, 3) != 3) { - _GifError = E_GIF_ERR_WRITE_FAILED; - return GIF_ERROR; - } - } -#endif /* DEBUG_NO_PREFIX */ - - /* Mark this file as has screen descriptor, and no pixel written yet: */ - Private->FileState |= FILE_STATE_SCREEN; - - return GIF_OK; -} - -/****************************************************************************** - * This routine should be called before any attempt to dump an image - any - * call to any of the pixel dump routines. - *****************************************************************************/ -int -EGifPutImageDesc(GifFileType * GifFile, - int Left, - int Top, - int Width, - int Height, - int Interlace, - const ColorMapObject * ColorMap) { - - int i; - GifByteType Buf[3]; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (Private->FileState & FILE_STATE_IMAGE && -#if defined(__MSDOS__) || defined(__GNUC__) - Private->PixelCount > 0xffff0000UL) { -#else - Private->PixelCount > 0xffff0000) { -#endif /* __MSDOS__ */ - /* If already has active image descriptor - something is wrong! */ - _GifError = E_GIF_ERR_HAS_IMAG_DSCR; - return GIF_ERROR; - } - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - GifFile->Image.Left = Left; - GifFile->Image.Top = Top; - GifFile->Image.Width = Width; - GifFile->Image.Height = Height; - GifFile->Image.Interlace = Interlace; - if (ColorMap) { - GifFile->Image.ColorMap = MakeMapObject(ColorMap->ColorCount, - ColorMap->Colors); - if (GifFile->Image.ColorMap == NULL) { - _GifError = E_GIF_ERR_NOT_ENOUGH_MEM; - return GIF_ERROR; - } - } else { - GifFile->Image.ColorMap = NULL; - } - - /* Put the image descriptor into the file: */ - Buf[0] = ','; /* Image seperator character. */ -#ifndef DEBUG_NO_PREFIX - WRITE(GifFile, Buf, 1); -#endif /* DEBUG_NO_PREFIX */ - EGifPutWord(Left, GifFile); - EGifPutWord(Top, GifFile); - EGifPutWord(Width, GifFile); - EGifPutWord(Height, GifFile); - Buf[0] = (ColorMap ? 0x80 : 0x00) | - (Interlace ? 0x40 : 0x00) | - (ColorMap ? ColorMap->BitsPerPixel - 1 : 0); -#ifndef DEBUG_NO_PREFIX - WRITE(GifFile, Buf, 1); -#endif /* DEBUG_NO_PREFIX */ - - /* If we have Global color map - dump it also: */ -#ifndef DEBUG_NO_PREFIX - if (ColorMap != NULL) - for (i = 0; i < ColorMap->ColorCount; i++) { - /* Put the ColorMap out also: */ - Buf[0] = ColorMap->Colors[i].Red; - Buf[1] = ColorMap->Colors[i].Green; - Buf[2] = ColorMap->Colors[i].Blue; - if (WRITE(GifFile, Buf, 3) != 3) { - _GifError = E_GIF_ERR_WRITE_FAILED; - return GIF_ERROR; - } - } -#endif /* DEBUG_NO_PREFIX */ - if (GifFile->SColorMap == NULL && GifFile->Image.ColorMap == NULL) { - _GifError = E_GIF_ERR_NO_COLOR_MAP; - return GIF_ERROR; - } - - /* Mark this file as has screen descriptor: */ - Private->FileState |= FILE_STATE_IMAGE; - Private->PixelCount = (long)Width *(long)Height; - - EGifSetupCompress(GifFile); /* Reset compress algorithm parameters. */ - - return GIF_OK; -} - -/****************************************************************************** - * Put one full scanned line (Line) of length LineLen into GIF file. - *****************************************************************************/ -int -EGifPutLine(GifFileType * GifFile, - GifPixelType * Line, - int LineLen) { - - int i; - GifPixelType Mask; - GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; - - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - - if (!LineLen) - LineLen = GifFile->Image.Width; - if (Private->PixelCount < (unsigned)LineLen) { - _GifError = E_GIF_ERR_DATA_TOO_BIG; - return GIF_ERROR; - } - Private->PixelCount -= LineLen; - - /* Make sure the codes are not out of bit range, as we might generate - * wrong code (because of overflow when we combine them) in this case: */ - Mask = CodeMask[Private->BitsPerPixel]; - for (i = 0; i < LineLen; i++) - Line[i] &= Mask; - - return EGifCompressLine(GifFile, Line, LineLen); -} - -/****************************************************************************** - * Put one pixel (Pixel) into GIF file. - *****************************************************************************/ -int -EGifPutPixel(GifFileType * GifFile, - GifPixelType Pixel) { - - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - - if (Private->PixelCount == 0) { - _GifError = E_GIF_ERR_DATA_TOO_BIG; - return GIF_ERROR; - } - --Private->PixelCount; - - /* Make sure the code is not out of bit range, as we might generate - * wrong code (because of overflow when we combine them) in this case: */ - Pixel &= CodeMask[Private->BitsPerPixel]; - - return EGifCompressLine(GifFile, &Pixel, 1); -} - -/****************************************************************************** - * Put a comment into GIF file using the GIF89 comment extension block. - *****************************************************************************/ -int -EGifPutComment(GifFileType * GifFile, - const char *Comment) { - - unsigned int length = strlen(Comment); - char *buf; - - length = strlen(Comment); - if (length <= 255) { - return EGifPutExtension(GifFile, COMMENT_EXT_FUNC_CODE, - length, Comment); - } else { - buf = (char *)Comment; - if (EGifPutExtensionFirst(GifFile, COMMENT_EXT_FUNC_CODE, 255, buf) - == GIF_ERROR) { - return GIF_ERROR; - } - length -= 255; - buf = buf + 255; - - /* Break the comment into 255 byte sub blocks */ - while (length > 255) { - if (EGifPutExtensionNext(GifFile, 0, 255, buf) == GIF_ERROR) { - return GIF_ERROR; - } - buf = buf + 255; - length -= 255; - } - /* Output any partial block and the clear code. */ - if (length > 0) { - if (EGifPutExtensionLast(GifFile, 0, length, buf) == GIF_ERROR) { - return GIF_ERROR; - } - } else { - if (EGifPutExtensionLast(GifFile, 0, 0, NULL) == GIF_ERROR) { - return GIF_ERROR; - } - } - } - return GIF_OK; -} - -/****************************************************************************** - * Put a first extension block (see GIF manual) into gif file. Here more - * extensions can be dumped using EGifPutExtensionNext until - * EGifPutExtensionLast is invoked. - *****************************************************************************/ -int -EGifPutExtensionFirst(GifFileType * GifFile, - int ExtCode, - int ExtLen, - const VoidPtr Extension) { - - GifByteType Buf[3]; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - - if (ExtCode == 0) { - WRITE(GifFile, (GifByteType *)&ExtLen, 1); - } else { - Buf[0] = '!'; - Buf[1] = ExtCode; - Buf[2] = ExtLen; - WRITE(GifFile, Buf, 3); - } - - WRITE(GifFile, Extension, ExtLen); - - return GIF_OK; -} - -/****************************************************************************** - * Put a middle extension block (see GIF manual) into gif file. - *****************************************************************************/ -int -EGifPutExtensionNext(GifFileType * GifFile, - int ExtCode, - int ExtLen, - const VoidPtr Extension) { - - GifByteType Buf; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - - Buf = ExtLen; - WRITE(GifFile, &Buf, 1); - WRITE(GifFile, Extension, ExtLen); - - return GIF_OK; -} - -/****************************************************************************** - * Put a last extension block (see GIF manual) into gif file. - *****************************************************************************/ -int -EGifPutExtensionLast(GifFileType * GifFile, - int ExtCode, - int ExtLen, - const VoidPtr Extension) { - - GifByteType Buf; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - - /* If we are given an extension sub-block output it now. */ - if (ExtLen > 0) { - Buf = ExtLen; - WRITE(GifFile, &Buf, 1); - WRITE(GifFile, Extension, ExtLen); - } - - /* Write the block terminator */ - Buf = 0; - WRITE(GifFile, &Buf, 1); - - return GIF_OK; -} - -/****************************************************************************** - * Put an extension block (see GIF manual) into gif file. - * Warning: This function is only useful for Extension blocks that have at - * most one subblock. Extensions with more than one subblock need to use the - * EGifPutExtension{First,Next,Last} functions instead. - *****************************************************************************/ -int -EGifPutExtension(GifFileType * GifFile, - int ExtCode, - int ExtLen, - const VoidPtr Extension) { - - GifByteType Buf[3]; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - - if (ExtCode == 0) - WRITE(GifFile, (GifByteType *)&ExtLen, 1); - else { - Buf[0] = '!'; /* Extension Introducer 0x21 */ - Buf[1] = ExtCode; /* Extension Label */ - Buf[2] = ExtLen; /* Extension length */ - WRITE(GifFile, Buf, ExtCode==0xff ? 2 : 3); - } - WRITE(GifFile, Extension, ExtLen); - Buf[0] = 0; - WRITE(GifFile, Buf, 1); - - return GIF_OK; -} - -/****************************************************************************** - * Put the image code in compressed form. This routine can be called if the - * information needed to be piped out as is. Obviously this is much faster - * than decoding and encoding again. This routine should be followed by calls - * to EGifPutCodeNext, until NULL block is given. - * The block should NOT be freed by the user (not dynamically allocated). - *****************************************************************************/ -int -EGifPutCode(GifFileType * GifFile, - int CodeSize, - const GifByteType * CodeBlock) { - - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - - /* No need to dump code size as Compression set up does any for us: */ - /* - * Buf = CodeSize; - * if (WRITE(GifFile, &Buf, 1) != 1) { - * _GifError = E_GIF_ERR_WRITE_FAILED; - * return GIF_ERROR; - * } - */ - - return EGifPutCodeNext(GifFile, CodeBlock); -} - -/****************************************************************************** - * Continue to put the image code in compressed form. This routine should be - * called with blocks of code as read via DGifGetCode/DGifGetCodeNext. If - * given buffer pointer is NULL, empty block is written to mark end of code. - *****************************************************************************/ -int -EGifPutCodeNext(GifFileType * GifFile, - const GifByteType * CodeBlock) { - - GifByteType Buf; - GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; - - if (CodeBlock != NULL) { - if (WRITE(GifFile, CodeBlock, CodeBlock[0] + 1) - != (unsigned)(CodeBlock[0] + 1)) { - _GifError = E_GIF_ERR_WRITE_FAILED; - return GIF_ERROR; - } - } else { - Buf = 0; - if (WRITE(GifFile, &Buf, 1) != 1) { - _GifError = E_GIF_ERR_WRITE_FAILED; - return GIF_ERROR; - } - Private->PixelCount = 0; /* And local info. indicate image read. */ - } - - return GIF_OK; -} - -/****************************************************************************** - * This routine should be called last, to close GIF file. - *****************************************************************************/ -int -EGifCloseFile(GifFileType * GifFile) { - - GifByteType Buf; - GifFilePrivateType *Private; - FILE *File; - - if (GifFile == NULL) - return GIF_ERROR; - - Private = (GifFilePrivateType *) GifFile->Private; - if (!IS_WRITEABLE(Private)) { - /* This file was NOT open for writing: */ - _GifError = E_GIF_ERR_NOT_WRITEABLE; - return GIF_ERROR; - } - - File = Private->File; - - Buf = ';'; - WRITE(GifFile, &Buf, 1); - - if (GifFile->Image.ColorMap) { - FreeMapObject(GifFile->Image.ColorMap); - GifFile->Image.ColorMap = NULL; - } - if (GifFile->SColorMap) { - FreeMapObject(GifFile->SColorMap); - GifFile->SColorMap = NULL; - } - if (Private) { - if (Private->HashTable) { - free((char *) Private->HashTable); - } - free((char *) Private); - } - free(GifFile); - - if (File && fclose(File) != 0) { - _GifError = E_GIF_ERR_CLOSE_FAILED; - return GIF_ERROR; - } - return GIF_OK; -} - -/****************************************************************************** - * Put 2 bytes (word) into the given file: - *****************************************************************************/ -static int -EGifPutWord(int Word, - GifFileType * GifFile) { - - unsigned char c[2]; - - c[0] = Word & 0xff; - c[1] = (Word >> 8) & 0xff; -#ifndef DEBUG_NO_PREFIX - if (WRITE(GifFile, c, 2) == 2) - return GIF_OK; - else - return GIF_ERROR; -#else - return GIF_OK; -#endif /* DEBUG_NO_PREFIX */ -} - -/****************************************************************************** - * Setup the LZ compression for this image: - *****************************************************************************/ -static int -EGifSetupCompress(GifFileType * GifFile) { - - int BitsPerPixel; - GifByteType Buf; - GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; - - /* Test and see what color map to use, and from it # bits per pixel: */ - if (GifFile->Image.ColorMap) - BitsPerPixel = GifFile->Image.ColorMap->BitsPerPixel; - else if (GifFile->SColorMap) - BitsPerPixel = GifFile->SColorMap->BitsPerPixel; - else { - _GifError = E_GIF_ERR_NO_COLOR_MAP; - return GIF_ERROR; - } - - Buf = BitsPerPixel = (BitsPerPixel < 2 ? 2 : BitsPerPixel); - WRITE(GifFile, &Buf, 1); /* Write the Code size to file. */ - - Private->Buf[0] = 0; /* Nothing was output yet. */ - Private->BitsPerPixel = BitsPerPixel; - Private->ClearCode = (1 << BitsPerPixel); - Private->EOFCode = Private->ClearCode + 1; - Private->RunningCode = Private->EOFCode + 1; - Private->RunningBits = BitsPerPixel + 1; /* Number of bits per code. */ - Private->MaxCode1 = 1 << Private->RunningBits; /* Max. code + 1. */ - Private->CrntCode = FIRST_CODE; /* Signal that this is first one! */ - Private->CrntShiftState = 0; /* No information in CrntShiftDWord. */ - Private->CrntShiftDWord = 0; - - /* Clear hash table and send Clear to make sure the decoder do the same. */ - _ClearHashTable(Private->HashTable); - - if (EGifCompressOutput(GifFile, Private->ClearCode) == GIF_ERROR) { - _GifError = E_GIF_ERR_DISK_IS_FULL; - return GIF_ERROR; - } - return GIF_OK; -} - -/****************************************************************************** - * The LZ compression routine: - * This version compresses the given buffer Line of length LineLen. - * This routine can be called a few times (one per scan line, for example), in - * order to complete the whole image. -******************************************************************************/ -static int -EGifCompressLine(GifFileType * GifFile, - GifPixelType * Line, - int LineLen) { - - int i = 0, CrntCode, NewCode; - unsigned long NewKey; - GifPixelType Pixel; - GifHashTableType *HashTable; - GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; - - HashTable = Private->HashTable; - - if (Private->CrntCode == FIRST_CODE) /* Its first time! */ - CrntCode = Line[i++]; - else - CrntCode = Private->CrntCode; /* Get last code in compression. */ - - while (i < LineLen) { /* Decode LineLen items. */ - Pixel = Line[i++]; /* Get next pixel from stream. */ - /* Form a new unique key to search hash table for the code combines - * CrntCode as Prefix string with Pixel as postfix char. - */ - NewKey = (((UINT32) CrntCode) << 8) + Pixel; - if ((NewCode = _ExistsHashTable(HashTable, NewKey)) >= 0) { - /* This Key is already there, or the string is old one, so - * simple take new code as our CrntCode: - */ - CrntCode = NewCode; - } else { - /* Put it in hash table, output the prefix code, and make our - * CrntCode equal to Pixel. - */ - if (EGifCompressOutput(GifFile, CrntCode) == GIF_ERROR) { - _GifError = E_GIF_ERR_DISK_IS_FULL; - return GIF_ERROR; - } - CrntCode = Pixel; - - /* If however the HashTable if full, we send a clear first and - * Clear the hash table. - */ - if (Private->RunningCode >= LZ_MAX_CODE) { - /* Time to do some clearance: */ - if (EGifCompressOutput(GifFile, Private->ClearCode) - == GIF_ERROR) { - _GifError = E_GIF_ERR_DISK_IS_FULL; - return GIF_ERROR; - } - Private->RunningCode = Private->EOFCode + 1; - Private->RunningBits = Private->BitsPerPixel + 1; - Private->MaxCode1 = 1 << Private->RunningBits; - _ClearHashTable(HashTable); - } else { - /* Put this unique key with its relative Code in hash table: */ - _InsertHashTable(HashTable, NewKey, Private->RunningCode++); - } - } - - } - - /* Preserve the current state of the compression algorithm: */ - Private->CrntCode = CrntCode; - - if (Private->PixelCount == 0) { - /* We are done - output last Code and flush output buffers: */ - if (EGifCompressOutput(GifFile, CrntCode) == GIF_ERROR) { - _GifError = E_GIF_ERR_DISK_IS_FULL; - return GIF_ERROR; - } - if (EGifCompressOutput(GifFile, Private->EOFCode) == GIF_ERROR) { - _GifError = E_GIF_ERR_DISK_IS_FULL; - return GIF_ERROR; - } - if (EGifCompressOutput(GifFile, FLUSH_OUTPUT) == GIF_ERROR) { - _GifError = E_GIF_ERR_DISK_IS_FULL; - return GIF_ERROR; - } - } - - return GIF_OK; -} - -/****************************************************************************** - * The LZ compression output routine: - * This routine is responsible for the compression of the bit stream into - * 8 bits (bytes) packets. - * Returns GIF_OK if written succesfully. - *****************************************************************************/ -static int -EGifCompressOutput(GifFileType * GifFile, - int Code) { - - GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; - int retval = GIF_OK; - - if (Code == FLUSH_OUTPUT) { - while (Private->CrntShiftState > 0) { - /* Get Rid of what is left in DWord, and flush it. */ - if (EGifBufferedOutput(GifFile, Private->Buf, - Private->CrntShiftDWord & 0xff) == GIF_ERROR) - retval = GIF_ERROR; - Private->CrntShiftDWord >>= 8; - Private->CrntShiftState -= 8; - } - Private->CrntShiftState = 0; /* For next time. */ - if (EGifBufferedOutput(GifFile, Private->Buf, - FLUSH_OUTPUT) == GIF_ERROR) - retval = GIF_ERROR; - } else { - Private->CrntShiftDWord |= ((long)Code) << Private->CrntShiftState; - Private->CrntShiftState += Private->RunningBits; - while (Private->CrntShiftState >= 8) { - /* Dump out full bytes: */ - if (EGifBufferedOutput(GifFile, Private->Buf, - Private->CrntShiftDWord & 0xff) == GIF_ERROR) - retval = GIF_ERROR; - Private->CrntShiftDWord >>= 8; - Private->CrntShiftState -= 8; - } - } - - /* If code cannt fit into RunningBits bits, must raise its size. Note */ - /* however that codes above 4095 are used for special signaling. */ - if (Private->RunningCode >= Private->MaxCode1 && Code <= 4095) { - Private->MaxCode1 = 1 << ++Private->RunningBits; - } - - return retval; -} - -/****************************************************************************** - * This routines buffers the given characters until 255 characters are ready - * to be output. If Code is equal to -1 the buffer is flushed (EOF). - * The buffer is Dumped with first byte as its size, as GIF format requires. - * Returns GIF_OK if written succesfully. - *****************************************************************************/ -static int -EGifBufferedOutput(GifFileType * GifFile, - GifByteType * Buf, - int c) { - - if (c == FLUSH_OUTPUT) { - /* Flush everything out. */ - if (Buf[0] != 0 - && WRITE(GifFile, Buf, Buf[0] + 1) != (unsigned)(Buf[0] + 1)) { - _GifError = E_GIF_ERR_WRITE_FAILED; - return GIF_ERROR; - } - /* Mark end of compressed data, by an empty block (see GIF doc): */ - Buf[0] = 0; - if (WRITE(GifFile, Buf, 1) != 1) { - _GifError = E_GIF_ERR_WRITE_FAILED; - return GIF_ERROR; - } - } else { - if (Buf[0] == 255) { - /* Dump out this buffer - it is full: */ - if (WRITE(GifFile, Buf, Buf[0] + 1) != (unsigned)(Buf[0] + 1)) { - _GifError = E_GIF_ERR_WRITE_FAILED; - return GIF_ERROR; - } - Buf[0] = 0; - } - Buf[++Buf[0]] = c; - } - - return GIF_OK; -} diff --git a/oversampling/WDL/giflib/gif_hash.c b/oversampling/WDL/giflib/gif_hash.c deleted file mode 100644 index cc99f7a..0000000 --- a/oversampling/WDL/giflib/gif_hash.c +++ /dev/null @@ -1,152 +0,0 @@ -/***************************************************************************** -* "Gif-Lib" - Yet another gif library. * -* * -* Written by: Gershon Elber IBM PC Ver 0.1, Jun. 1989 * -****************************************************************************** -* Module to support the following operations: * -* * -* 1. InitHashTable - initialize hash table. * -* 2. ClearHashTable - clear the hash table to an empty state. * -* 2. InsertHashTable - insert one item into data structure. * -* 3. ExistsHashTable - test if item exists in data structure. * -* * -* This module is used to hash the GIF codes during encoding. * -****************************************************************************** -* History: * -* 14 Jun 89 - Version 1.0 by Gershon Elber. * -*****************************************************************************/ - -#include "config.h" - -/* Find a thirty-two bit int type */ -#ifdef HAVE_STDINT_H -#include -#endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif - -#ifdef __MSDOS__ -#include -#include -#include -#else -#include -#include -#endif /* __MSDOS__ */ - -#ifdef HAVE_FCNTL_H -#include -#endif /* HAVE_FCNTL_H */ -#include -#include -#include "gif_lib.h" -#include "gif_hash.h" -#include "gif_lib_private.h" - -/* #define DEBUG_HIT_RATE Debug number of misses per hash Insert/Exists. */ - -#ifdef DEBUG_HIT_RATE -static long NumberOfTests = 0, - NumberOfMisses = 0; -#endif /* DEBUG_HIT_RATE */ - -static int KeyItem(UINT32 Item); - -/****************************************************************************** -* Initialize HashTable - allocate the memory needed and clear it. * -******************************************************************************/ -GifHashTableType *_InitHashTable(void) -{ - GifHashTableType *HashTable; - - if ((HashTable = (GifHashTableType *) malloc(sizeof(GifHashTableType))) - == NULL) - return NULL; - - _ClearHashTable(HashTable); - - return HashTable; -} - -/****************************************************************************** -* Routine to clear the HashTable to an empty state. * -* This part is a little machine depended. Use the commented part otherwise. * -******************************************************************************/ -void _ClearHashTable(GifHashTableType *HashTable) -{ - memset(HashTable -> HTable, 0xFF, HT_SIZE * sizeof(UINT32)); -} - -/****************************************************************************** -* Routine to insert a new Item into the HashTable. The data is assumed to be * -* new one. * -******************************************************************************/ -void _InsertHashTable(GifHashTableType *HashTable, UINT32 Key, int Code) -{ - int HKey = KeyItem(Key); - UINT32 *HTable = HashTable -> HTable; - -#ifdef DEBUG_HIT_RATE - NumberOfTests++; - NumberOfMisses++; -#endif /* DEBUG_HIT_RATE */ - - while (HT_GET_KEY(HTable[HKey]) != 0xFFFFFL) { -#ifdef DEBUG_HIT_RATE - NumberOfMisses++; -#endif /* DEBUG_HIT_RATE */ - HKey = (HKey + 1) & HT_KEY_MASK; - } - HTable[HKey] = HT_PUT_KEY(Key) | HT_PUT_CODE(Code); -} - -/****************************************************************************** -* Routine to test if given Key exists in HashTable and if so returns its code * -* Returns the Code if key was found, -1 if not. * -******************************************************************************/ -int _ExistsHashTable(GifHashTableType *HashTable, UINT32 Key) -{ - int HKey = KeyItem(Key); - UINT32 *HTable = HashTable -> HTable, HTKey; - -#ifdef DEBUG_HIT_RATE - NumberOfTests++; - NumberOfMisses++; -#endif /* DEBUG_HIT_RATE */ - - while ((HTKey = HT_GET_KEY(HTable[HKey])) != 0xFFFFFL) { -#ifdef DEBUG_HIT_RATE - NumberOfMisses++; -#endif /* DEBUG_HIT_RATE */ - if (Key == HTKey) return HT_GET_CODE(HTable[HKey]); - HKey = (HKey + 1) & HT_KEY_MASK; - } - - return -1; -} - -/****************************************************************************** -* Routine to generate an HKey for the hashtable out of the given unique key. * -* The given Key is assumed to be 20 bits as follows: lower 8 bits are the * -* new postfix character, while the upper 12 bits are the prefix code. * -* Because the average hit ratio is only 2 (2 hash references per entry), * -* evaluating more complex keys (such as twin prime keys) does not worth it! * -******************************************************************************/ -static int KeyItem(UINT32 Item) -{ - return ((Item >> 12) ^ Item) & HT_KEY_MASK; -} - -#ifdef DEBUG_HIT_RATE -/****************************************************************************** -* Debugging routine to print the hit ratio - number of times the hash table * -* was tested per operation. This routine was used to test the KeyItem routine * -******************************************************************************/ -void HashTablePrintHitRatio(void) -{ - printf("Hash Table Hit Ratio is %ld/%ld = %ld%%.\n", - NumberOfMisses, NumberOfTests, - NumberOfMisses * 100 / NumberOfTests); -} -#endif /* DEBUG_HIT_RATE */ diff --git a/oversampling/WDL/giflib/gif_hash.h b/oversampling/WDL/giflib/gif_hash.h deleted file mode 100644 index e7fa1e2..0000000 --- a/oversampling/WDL/giflib/gif_hash.h +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************** -* Declarations, global to other of the GIF-HASH.C module. * -* * -* Written by Gershon Elber, Jun 1989 * -******************************************************************************* -* History: * -* 14 Jun 89 - Version 1.0 by Gershon Elber. * -******************************************************************************/ - -#ifndef _GIF_HASH_H_ -#define _GIF_HASH_H_ - -#include "config.h" - -/* Find a thirty-two bit int type */ -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_STDINT_H -#include -#endif -#ifdef HAVE_BASETSD_H -#include -#endif - -#define HT_SIZE 8192 /* 12bits = 4096 or twice as big! */ -#define HT_KEY_MASK 0x1FFF /* 13bits keys */ -#define HT_KEY_NUM_BITS 13 /* 13bits keys */ -#define HT_MAX_KEY 8191 /* 13bits - 1, maximal code possible */ -#define HT_MAX_CODE 4095 /* Biggest code possible in 12 bits. */ - -/* The 32 bits of the long are divided into two parts for the key & code: */ -/* 1. The code is 12 bits as our compression algorithm is limited to 12bits */ -/* 2. The key is 12 bits Prefix code + 8 bit new char or 20 bits. */ -/* The key is the upper 20 bits. The code is the lower 12. */ -#define HT_GET_KEY(l) (l >> 12) -#define HT_GET_CODE(l) (l & 0x0FFF) -#define HT_PUT_KEY(l) (l << 12) -#define HT_PUT_CODE(l) (l & 0x0FFF) - -typedef struct GifHashTableType { - UINT32 HTable[HT_SIZE]; -} GifHashTableType; - -GifHashTableType *_InitHashTable(void); -void _ClearHashTable(GifHashTableType *HashTable); -void _InsertHashTable(GifHashTableType *HashTable, UINT32 Key, int Code); -int _ExistsHashTable(GifHashTableType *HashTable, UINT32 Key); - -#endif /* _GIF_HASH_H_ */ diff --git a/oversampling/WDL/giflib/gif_lib.h b/oversampling/WDL/giflib/gif_lib.h deleted file mode 100644 index ac9d90e..0000000 --- a/oversampling/WDL/giflib/gif_lib.h +++ /dev/null @@ -1,277 +0,0 @@ -/****************************************************************************** - * In order to make life a little bit easier when using the GIF file format, - * this library was written, and which does all the dirty work... - * - * Written by Gershon Elber, Jun. 1989 - * Hacks by Eric S. Raymond, Sep. 1992 - ****************************************************************************** - * History: - * 14 Jun 89 - Version 1.0 by Gershon Elber. - * 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names) - * 15 Sep 90 - Version 2.0 by Eric S. Raymond (Changes to suoport GIF slurp) - * 26 Jun 96 - Version 3.0 by Eric S. Raymond (Full GIF89 support) - * 17 Dec 98 - Version 4.0 by Toshio Kuratomi (Fix extension writing code) - *****************************************************************************/ - -#ifndef _GIF_LIB_H_ -#define _GIF_LIB_H_ 1 - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define GIF_LIB_VERSION " Version 4.1, " - -#define GIF_ERROR 0 -#define GIF_OK 1 - -#ifndef TRUE -#define TRUE 1 -#endif /* TRUE */ -#ifndef FALSE -#define FALSE 0 -#endif /* FALSE */ - -#ifndef NULL -#define NULL 0 -#endif /* NULL */ - -#define GIF_STAMP "GIFVER" /* First chars in file - GIF stamp. */ -#define GIF_STAMP_LEN sizeof(GIF_STAMP) - 1 -#define GIF_VERSION_POS 3 /* Version first character in stamp. */ -#define GIF87_STAMP "GIF87a" /* First chars in file - GIF stamp. */ -#define GIF89_STAMP "GIF89a" /* First chars in file - GIF stamp. */ - -#define GIF_FILE_BUFFER_SIZE 16384 /* Files uses bigger buffers than usual. */ - -typedef int GifBooleanType; -typedef unsigned char GifPixelType; -typedef unsigned char *GifRowType; -typedef unsigned char GifByteType; -#ifdef _GBA_OPTMEM - typedef unsigned short GifPrefixType; - typedef short GifWord; -#else - typedef unsigned int GifPrefixType; - typedef int GifWord; -#endif - -#define GIF_MESSAGE(Msg) -#define GIF_EXIT(Msg) - -#ifdef SYSV -#define VoidPtr char * -#else -#define VoidPtr void * -#endif /* SYSV */ - -typedef struct GifColorType { - GifByteType Red, Green, Blue; -} GifColorType; - -typedef struct ColorMapObject { - int ColorCount; - int BitsPerPixel; - GifColorType *Colors; /* on malloc(3) heap */ -} ColorMapObject; - -typedef struct GifImageDesc { - GifWord Left, Top, Width, Height, /* Current image dimensions. */ - Interlace; /* Sequential/Interlaced lines. */ - ColorMapObject *ColorMap; /* The local color map */ -} GifImageDesc; - -typedef struct GifFileType { - GifWord SWidth, SHeight, /* Screen dimensions. */ - SColorResolution, /* How many colors can we generate? */ - SBackGroundColor; /* I hope you understand this one... */ - ColorMapObject *SColorMap; /* NULL if not exists. */ - int ImageCount; /* Number of current image */ - GifImageDesc Image; /* Block describing current image */ - VoidPtr UserData; /* hook to attach user data (TVT) */ - VoidPtr Private; /* Don't mess with this! */ -} GifFileType; - -typedef enum { - UNDEFINED_RECORD_TYPE, - SCREEN_DESC_RECORD_TYPE, - IMAGE_DESC_RECORD_TYPE, /* Begin with ',' */ - EXTENSION_RECORD_TYPE, /* Begin with '!' */ - TERMINATE_RECORD_TYPE /* Begin with ';' */ -} GifRecordType; - -/* DumpScreen2Gif routine constants identify type of window/screen to dump. - * Note all values below 1000 are reserved for the IBMPC different display - * devices (it has many!) and are compatible with the numbering TC2.0 - * (Turbo C 2.0 compiler for IBM PC) gives to these devices. - */ -typedef enum { - GIF_DUMP_SGI_WINDOW = 1000, - GIF_DUMP_X_WINDOW = 1001 -} GifScreenDumpType; - -/* func type to read gif data from arbitrary sources (TVT) */ -typedef int (*InputFunc) (GifFileType *, GifByteType *, int); - -/* func type to write gif data ro arbitrary targets. - * Returns count of bytes written. (MRB) - */ -typedef int (*OutputFunc) (GifFileType *, const GifByteType *, int); - -/****************************************************************************** - * GIF89 extension function codes -******************************************************************************/ - -#define COMMENT_EXT_FUNC_CODE 0xfe /* comment */ -#define GRAPHICS_EXT_FUNC_CODE 0xf9 /* graphics control */ -#define PLAINTEXT_EXT_FUNC_CODE 0x01 /* plaintext */ -#define APPLICATION_EXT_FUNC_CODE 0xff /* application block */ - -/****************************************************************************** - * O.K., here are the routines one can access in order to encode GIF file: - * (GIF_LIB file EGIF_LIB.C). -******************************************************************************/ - -GifFileType *EGifOpenFileName(const char *GifFileName, - int GifTestExistance); -GifFileType *EGifOpenFileHandle(int GifFileHandle); -GifFileType *EGifOpen(void *userPtr, OutputFunc writeFunc); - -int EGifSpew(GifFileType * GifFile); -void EGifSetGifVersion(const char *Version); -int EGifPutScreenDesc(GifFileType * GifFile, - int GifWidth, int GifHeight, int GifColorRes, - int GifBackGround, - const ColorMapObject * GifColorMap); -int EGifPutImageDesc(GifFileType * GifFile, int GifLeft, int GifTop, - int Width, int GifHeight, int GifInterlace, - const ColorMapObject * GifColorMap); -int EGifPutLine(GifFileType * GifFile, GifPixelType * GifLine, - int GifLineLen); -int EGifPutPixel(GifFileType * GifFile, GifPixelType GifPixel); -int EGifPutComment(GifFileType * GifFile, const char *GifComment); -int EGifPutExtensionFirst(GifFileType * GifFile, int GifExtCode, - int GifExtLen, const VoidPtr GifExtension); -int EGifPutExtensionNext(GifFileType * GifFile, int GifExtCode, - int GifExtLen, const VoidPtr GifExtension); -int EGifPutExtensionLast(GifFileType * GifFile, int GifExtCode, - int GifExtLen, const VoidPtr GifExtension); -int EGifPutExtension(GifFileType * GifFile, int GifExtCode, int GifExtLen, - const VoidPtr GifExtension); -int EGifPutCode(GifFileType * GifFile, int GifCodeSize, - const GifByteType * GifCodeBlock); -int EGifPutCodeNext(GifFileType * GifFile, - const GifByteType * GifCodeBlock); -int EGifCloseFile(GifFileType * GifFile); - -#define E_GIF_ERR_OPEN_FAILED 1 /* And EGif possible errors. */ -#define E_GIF_ERR_WRITE_FAILED 2 -#define E_GIF_ERR_HAS_SCRN_DSCR 3 -#define E_GIF_ERR_HAS_IMAG_DSCR 4 -#define E_GIF_ERR_NO_COLOR_MAP 5 -#define E_GIF_ERR_DATA_TOO_BIG 6 -#define E_GIF_ERR_NOT_ENOUGH_MEM 7 -#define E_GIF_ERR_DISK_IS_FULL 8 -#define E_GIF_ERR_CLOSE_FAILED 9 -#define E_GIF_ERR_NOT_WRITEABLE 10 - -/****************************************************************************** - * O.K., here are the routines one can access in order to decode GIF file: - * (GIF_LIB file DGIF_LIB.C). - *****************************************************************************/ -#ifndef _GBA_NO_FILEIO -GifFileType *DGifOpenFileName(const char *GifFileName); -GifFileType *DGifOpenFileHandle(int GifFileHandle); -int DGifSlurp(GifFileType * GifFile); -#endif /* _GBA_NO_FILEIO */ -GifFileType *DGifOpen(void *userPtr, InputFunc readFunc); /* new one - * (TVT) */ -int DGifGetScreenDesc(GifFileType * GifFile); -int DGifGetRecordType(GifFileType * GifFile, GifRecordType * GifType); -int DGifGetImageDesc(GifFileType * GifFile); -int DGifGetLine(GifFileType * GifFile, GifPixelType * GifLine, int GifLineLen); -int DGifGetPixel(GifFileType * GifFile, GifPixelType GifPixel); -int DGifGetComment(GifFileType * GifFile, char *GifComment); -int DGifGetExtension(GifFileType * GifFile, int *GifExtCode, - GifByteType ** GifExtension); -int DGifGetExtensionNext(GifFileType * GifFile, GifByteType ** GifExtension); -int DGifGetCode(GifFileType * GifFile, int *GifCodeSize, - GifByteType ** GifCodeBlock); -int DGifGetCodeNext(GifFileType * GifFile, GifByteType ** GifCodeBlock); -int DGifGetLZCodes(GifFileType * GifFile, int *GifCode); -int DGifCloseFile(GifFileType * GifFile); - -#define D_GIF_ERR_OPEN_FAILED 101 /* And DGif possible errors. */ -#define D_GIF_ERR_READ_FAILED 102 -#define D_GIF_ERR_NOT_GIF_FILE 103 -#define D_GIF_ERR_NO_SCRN_DSCR 104 -#define D_GIF_ERR_NO_IMAG_DSCR 105 -#define D_GIF_ERR_NO_COLOR_MAP 106 -#define D_GIF_ERR_WRONG_RECORD 107 -#define D_GIF_ERR_DATA_TOO_BIG 108 -#define D_GIF_ERR_NOT_ENOUGH_MEM 109 -#define D_GIF_ERR_CLOSE_FAILED 110 -#define D_GIF_ERR_NOT_READABLE 111 -#define D_GIF_ERR_IMAGE_DEFECT 112 -#define D_GIF_ERR_EOF_TOO_SOON 113 - -/****************************************************************************** - * O.K., here are the routines from GIF_LIB file QUANTIZE.C. -******************************************************************************/ -int QuantizeBuffer(unsigned int Width, unsigned int Height, - int *ColorMapSize, GifByteType * RedInput, - GifByteType * GreenInput, GifByteType * BlueInput, - GifByteType * OutputBuffer, - GifColorType * OutputColorMap); - -/****************************************************************************** - * O.K., here are the routines from GIF_LIB file QPRINTF.C. -******************************************************************************/ -extern int GifQuietPrint; - -#ifdef HAVE_STDARG_H - extern void GifQprintf(char *Format, ...); -#elif defined (HAVE_VARARGS_H) - extern void GifQprintf(); -#endif /* HAVE_STDARG_H */ - -/****************************************************************************** - * O.K., here are the routines from GIF_LIB file GIF_ERR.C. -******************************************************************************/ -#ifndef _GBA_NO_FILEIO -extern void PrintGifError(void); -#endif /* _GBA_NO_FILEIO */ -extern int GifLastError(void); - -/****************************************************************************** - * O.K., here are the routines from GIF_LIB file DEV2GIF.C. -******************************************************************************/ -extern int DumpScreen2Gif(const char *FileName, - int ReqGraphDriver, - long ReqGraphMode1, - long ReqGraphMode2, - long ReqGraphMode3); - -/***************************************************************************** - * - * Everything below this point is new after version 1.2, supporting `slurp - * mode' for doing I/O in two big belts with all the image-bashing in core. - * - *****************************************************************************/ - -/****************************************************************************** - * Color Map handling from ALLOCGIF.C - *****************************************************************************/ - -extern ColorMapObject *MakeMapObject(int ColorCount, - const GifColorType * ColorMap); -extern void FreeMapObject(ColorMapObject * Object); -extern ColorMapObject *UnionColorMap(const ColorMapObject * ColorIn1, - const ColorMapObject * ColorIn2, - GifPixelType ColorTransIn2[]); -extern int BitSize(int n); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* _GIF_LIB_H */ diff --git a/oversampling/WDL/giflib/gif_lib_private.h b/oversampling/WDL/giflib/gif_lib_private.h deleted file mode 100644 index b31c9c5..0000000 --- a/oversampling/WDL/giflib/gif_lib_private.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _GIF_LIB_PRIVATE_H -#define _GIF_LIB_PRIVATE_H - -#include "gif_lib.h" -#include "gif_hash.h" - -#define PROGRAM_NAME "GIFLIB" - -#ifdef SYSV -#define VersionStr "Gif library module,\t\tEric S. Raymond\n\ - (C) Copyright 1997 Eric S. Raymond\n" -#else -#define VersionStr PROGRAM_NAME " IBMPC " GIF_LIB_VERSION \ - " Eric S. Raymond, " __DATE__ ", " \ - __TIME__ "\n" "(C) Copyright 1997 Eric S. Raymond\n" -#endif /* SYSV */ - -#define LZ_MAX_CODE 4095 /* Biggest code possible in 12 bits. */ -#define LZ_BITS 12 - -#define FLUSH_OUTPUT 4096 /* Impossible code, to signal flush. */ -#define FIRST_CODE 4097 /* Impossible code, to signal first. */ -#define NO_SUCH_CODE 4098 /* Impossible code, to signal empty. */ - -#define FILE_STATE_WRITE 0x01 -#define FILE_STATE_SCREEN 0x02 -#define FILE_STATE_IMAGE 0x04 -#define FILE_STATE_READ 0x08 - -#define IS_READABLE(Private) (Private->FileState & FILE_STATE_READ) -#define IS_WRITEABLE(Private) (Private->FileState & FILE_STATE_WRITE) - -typedef struct GifFilePrivateType { - GifWord FileState, FileHandle, /* Where all this data goes to! */ - BitsPerPixel, /* Bits per pixel (Codes uses at least this + 1). */ - ClearCode, /* The CLEAR LZ code. */ - EOFCode, /* The EOF LZ code. */ - RunningCode, /* The next code algorithm can generate. */ - RunningBits, /* The number of bits required to represent RunningCode. */ - MaxCode1, /* 1 bigger than max. possible code, in RunningBits bits. */ - LastCode, /* The code before the current code. */ - CrntCode, /* Current algorithm code. */ - StackPtr, /* For character stack (see below). */ - CrntShiftState; /* Number of bits in CrntShiftDWord. */ - unsigned long CrntShiftDWord; /* For bytes decomposition into codes. */ - unsigned long PixelCount; /* Number of pixels in image. */ - FILE *File; /* File as stream. */ - InputFunc Read; /* function to read gif input (TVT) */ - OutputFunc Write; /* function to write gif output (MRB) */ - GifByteType Buf[256]; /* Compressed input is buffered here. */ - GifByteType Stack[LZ_MAX_CODE]; /* Decoded pixels are stacked here. */ - GifByteType Suffix[LZ_MAX_CODE + 1]; /* So we can trace the codes. */ - GifPrefixType Prefix[LZ_MAX_CODE + 1]; - GifHashTableType *HashTable; -} GifFilePrivateType; - -extern int _GifError; - -#endif /* _GIF_LIB_PRIVATE_H */ diff --git a/oversampling/WDL/giflib/gifalloc.c b/oversampling/WDL/giflib/gifalloc.c deleted file mode 100644 index 4d6160a..0000000 --- a/oversampling/WDL/giflib/gifalloc.c +++ /dev/null @@ -1,212 +0,0 @@ -/***************************************************************************** - * "Gif-Lib" - Yet another gif library. - * - * Written by: Gershon Elber Ver 0.1, Jun. 1989 - * Extensively hacked by: Eric S. Raymond Ver 1.?, Sep 1992 - ***************************************************************************** - * GIF construction tools - ***************************************************************************** - * History: - * 15 Sep 92 - Version 1.0 by Eric Raymond. - ****************************************************************************/ - -#include "config.h" - -#include -#include -#include -#include "gif_lib.h" - -#define MAX(x, y) (((x) > (y)) ? (x) : (y)) - -/****************************************************************************** - * Miscellaneous utility functions - *****************************************************************************/ - -/* return smallest bitfield size n will fit in */ -int -BitSize(int n) { - - register int i; - - for (i = 1; i <= 8; i++) - if ((1 << i) >= n) - break; - return (i); -} - -/****************************************************************************** - * Color map object functions - *****************************************************************************/ - -/* - * Allocate a color map of given size; initialize with contents of - * ColorMap if that pointer is non-NULL. - */ -ColorMapObject * -MakeMapObject(int ColorCount, - const GifColorType * ColorMap) { - - ColorMapObject *Object; - - /*** FIXME: Our ColorCount has to be a power of two. Is it necessary to - * make the user know that or should we automatically round up instead? */ - if (ColorCount != (1 << BitSize(ColorCount))) { - return ((ColorMapObject *) NULL); - } - - Object = (ColorMapObject *)malloc(sizeof(ColorMapObject)); - if (Object == (ColorMapObject *) NULL) { - return ((ColorMapObject *) NULL); - } - - Object->Colors = (GifColorType *)calloc(ColorCount, sizeof(GifColorType)); - if (Object->Colors == (GifColorType *) NULL) { - return ((ColorMapObject *) NULL); - } - - Object->ColorCount = ColorCount; - Object->BitsPerPixel = BitSize(ColorCount); - - if (ColorMap) { - memcpy((char *)Object->Colors, - (char *)ColorMap, ColorCount * sizeof(GifColorType)); - } - - return (Object); -} - -/* - * Free a color map object - */ -void -FreeMapObject(ColorMapObject * Object) { - - if (Object != NULL) { - free(Object->Colors); - free(Object); - /*** FIXME: - * When we are willing to break API we need to make this function - * FreeMapObject(ColorMapObject **Object) - * and do this assignment to NULL here: - * *Object = NULL; - */ - } -} - -#ifdef DEBUG -void -DumpColorMap(ColorMapObject * Object, - FILE * fp) { - - if (Object) { - int i, j, Len = Object->ColorCount; - - for (i = 0; i < Len; i += 4) { - for (j = 0; j < 4 && j < Len; j++) { - fprintf(fp, "%3d: %02x %02x %02x ", i + j, - Object->Colors[i + j].Red, - Object->Colors[i + j].Green, - Object->Colors[i + j].Blue); - } - fprintf(fp, "\n"); - } - } -} -#endif /* DEBUG */ - -/* - * Compute the union of two given color maps and return it. If result can't - * fit into 256 colors, NULL is returned, the allocated union otherwise. - * ColorIn1 is copied as is to ColorUnion, while colors from ColorIn2 are - * copied iff they didn't exist before. ColorTransIn2 maps the old - * ColorIn2 into ColorUnion color map table. - */ -ColorMapObject * -UnionColorMap(const ColorMapObject * ColorIn1, - const ColorMapObject * ColorIn2, - GifPixelType ColorTransIn2[]) { - - int i, j, CrntSlot, RoundUpTo, NewBitSize; - ColorMapObject *ColorUnion; - - /* - * Allocate table which will hold the result for sure. - */ - ColorUnion = MakeMapObject(MAX(ColorIn1->ColorCount, - ColorIn2->ColorCount) * 2, NULL); - - if (ColorUnion == NULL) - return (NULL); - - /* Copy ColorIn1 to ColorUnionSize; */ - /*** FIXME: What if there are duplicate entries into the colormap to begin - * with? */ - for (i = 0; i < ColorIn1->ColorCount; i++) - ColorUnion->Colors[i] = ColorIn1->Colors[i]; - CrntSlot = ColorIn1->ColorCount; - - /* - * Potentially obnoxious hack: - * - * Back CrntSlot down past all contiguous {0, 0, 0} slots at the end - * of table 1. This is very useful if your display is limited to - * 16 colors. - */ - while (ColorIn1->Colors[CrntSlot - 1].Red == 0 - && ColorIn1->Colors[CrntSlot - 1].Green == 0 - && ColorIn1->Colors[CrntSlot - 1].Blue == 0) - CrntSlot--; - - /* Copy ColorIn2 to ColorUnionSize (use old colors if they exist): */ - for (i = 0; i < ColorIn2->ColorCount && CrntSlot <= 256; i++) { - /* Let's see if this color already exists: */ - /*** FIXME: Will it ever occur that ColorIn2 will contain duplicate - * entries? So we should search from 0 to CrntSlot rather than - * ColorIn1->ColorCount? - */ - for (j = 0; j < ColorIn1->ColorCount; j++) - if (memcmp (&ColorIn1->Colors[j], &ColorIn2->Colors[i], - sizeof(GifColorType)) == 0) - break; - - if (j < ColorIn1->ColorCount) - ColorTransIn2[i] = j; /* color exists in Color1 */ - else { - /* Color is new - copy it to a new slot: */ - ColorUnion->Colors[CrntSlot] = ColorIn2->Colors[i]; - ColorTransIn2[i] = CrntSlot++; - } - } - - if (CrntSlot > 256) { - FreeMapObject(ColorUnion); - return ((ColorMapObject *) NULL); - } - - NewBitSize = BitSize(CrntSlot); - RoundUpTo = (1 << NewBitSize); - - if (RoundUpTo != ColorUnion->ColorCount) { - register GifColorType *Map = ColorUnion->Colors; - - /* - * Zero out slots up to next power of 2. - * We know these slots exist because of the way ColorUnion's - * start dimension was computed. - */ - for (j = CrntSlot; j < RoundUpTo; j++) - Map[j].Red = Map[j].Green = Map[j].Blue = 0; - - /* perhaps we can shrink the map? */ - if (RoundUpTo < ColorUnion->ColorCount) - ColorUnion->Colors = (GifColorType *)realloc(Map, - sizeof(GifColorType) * RoundUpTo); - } - - ColorUnion->ColorCount = RoundUpTo; - ColorUnion->BitsPerPixel = NewBitSize; - - return (ColorUnion); -} - diff --git a/oversampling/WDL/has_strings.h b/oversampling/WDL/has_strings.h deleted file mode 100644 index 6e48208..0000000 --- a/oversampling/WDL/has_strings.h +++ /dev/null @@ -1,523 +0,0 @@ -#ifndef _WDL_HASSTRINGS_H_ -#define _WDL_HASSTRINGS_H_ - -#ifndef WDL_HASSTRINGS_EXPORT -#define WDL_HASSTRINGS_EXPORT -#endif - -WDL_HASSTRINGS_EXPORT const char *hasStrings_rewutf8(const char *str, const char *base) -{ - while (str > base && (*(unsigned char *)str & 0xC0) == 0x80) str--; - return str; -} -WDL_HASSTRINGS_EXPORT int hasStrings_isNonWordChar(const char *cptr) -{ - // treat non-alnum non-utf-8 as whitespace when searching for " foo " - const unsigned char c = *(const unsigned char *)cptr; - if (c < 128) - { - if ((c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') || - (c >= '0' && c <= '9')) - { - return 0; - } - - return 1; // non-alnum ascii are non-word chars - } - - // most UTF-8 characters are word characters - if (c == 0xE2) - { - // except UTF-8 apostrophes - if (((unsigned char*)cptr)[1] == 0x80 && (((unsigned char*)cptr)[2]&~1) == 0x98) return 3; - } - - return 0; -} - -#include "utf8_extended.h" - -// returns negative if does not match but more of a is available to search -// returns 0 if done searching without match -// returns >0 if matches (return bytelen of match) -// note that this assumes that b was preprocessed by WDL_makeSearchFilter and that strlen(b) >= n -WDL_HASSTRINGS_EXPORT int hasStrings_utf8cmp(const unsigned char * const a, const unsigned char *b, unsigned int n) -{ - int aidx=0; - while (n) - { - int ca=a[aidx], cb=b[0]; - // ca may be any character (including A-Z), utf8, cb will never be A-Z or NUL - WDL_ASSERT(cb != 0 && !(cb >= 'A' && cb <= 'Z')); - cb -= ca; - // if ca is A, and cb is a, cb will be 'a'-'A' - if (cb) - { - if (cb != 'a'-'A') - { - if (ca < 0xc3 || ca > 0xc5) - { - if (ca == 0xE2 && cb == ('\''-0xE2) && a[aidx+1] == 0x80 && (a[aidx+2]&~1) == 0x98) - { - aidx+=3; - ++b; - --n; - continue; - } - const int skipl = WDL_IS_UTF8_SKIPPABLE(ca,a[aidx+1]); - if (skipl) - { - aidx += skipl; - continue; - } - return -ca; - } - - const int ccf = a[++aidx]; - if (ccf < 0x80) return -ca; - - if (ca == 0xc3) - { - // latin-1 supplemental - const int cc = ccf & ~0x20; - switch (*b) - { -#define SCAN(ch, CH) case ch: if (!WDL_IS_UTF8_BYTE2_LATIN1S_##CH(cc,ccf)) return -ca; break; - SCAN('a',A) - SCAN('c',C) - SCAN('e',E) - SCAN('i',I) - SCAN('n',N) - SCAN('o',O) - SCAN('u',U) - SCAN('y',Y) - default: return -ca; break; -#undef SCAN - } - } - else - { - // latin extended A - switch (*b) - { -#define SCAN(ch, CH) case ch: if (!WDL_IS_UTF8_EXT1A_##CH(ca,ccf)) return -ca; break; - SCAN('a',A) - SCAN('c',C) - SCAN('d',D) - SCAN('e',E) - SCAN('g',G) - SCAN('h',H) - SCAN('i',I) - SCAN('j',J) - SCAN('k',K) - SCAN('l',L) - SCAN('n',N) - SCAN('o',O) - SCAN('r',R) - SCAN('s',S) - SCAN('t',T) - SCAN('u',U) - SCAN('w',W) - SCAN('y',Y) - SCAN('z',Z) - default: return -ca; break; -#undef SCAN - } - } - } - else if (ca < 'A' || ca > 'Z') return -ca; - } - ++aidx; - ++b; - --n; - } - return aidx; -} - -static const char *hasStrings_scan_for_char_match(const char *p, char v) -{ - if (v < 'a' || v > 'z') - for (;;) - { - char c = *p; - if (!c) return NULL; - if (c == v) return p; - p++; - } - - switch (v) - { - case '\'': - for (;;) { - unsigned char c = *(const unsigned char *)p; - if (!c) return NULL; - if (c == '\'') return p; - if (c == 0xE2 && ((unsigned char*)p)[1] == 0x80 && (((unsigned char*)p)[2]&~1) == 0x98) - return p; - p++; - } - -#define SCAN(ch, CH) case (ch): for (;;) { \ - unsigned char c = *(const unsigned char *)p; \ - if (!c) return NULL; \ - if ((c|0x20) == (ch)) return p; \ - if (c >= 0xc3) { \ - if (c == 0xc3) { \ - const unsigned char ccf = ((const unsigned char*)p)[1]; \ - const unsigned char cc = ccf & ~0x20; \ - if (WDL_IS_UTF8_BYTE2_LATIN1S_##CH(cc,ccf)) return p; \ - } else { \ - if (WDL_IS_UTF8_EXT1A_##CH(c, ((const unsigned char*)p)[1])) return p; \ - } \ - } \ - p++; \ - } - SCAN('a',A) - SCAN('c',C) - SCAN('e',E) - SCAN('i',I) - SCAN('n',N) - SCAN('o',O) - SCAN('u',U) - SCAN('y',Y) -#undef SCAN - - // latin extended A only -#define SCAN(ch, CH) case (ch): for (;;) { \ - unsigned char c = *(const unsigned char *)p; \ - if (!c) return NULL; \ - if ((c|0x20) == (ch)) return p; \ - if (WDL_IS_UTF8_EXT1A_##CH(c, ((const unsigned char*)p)[1])) return p; \ - p++; \ - } - - SCAN('d',D) - SCAN('g',G) - SCAN('h',H) - SCAN('j',J) - SCAN('k',K) - SCAN('l',L) - SCAN('r',R) - SCAN('s',S) - SCAN('t',T) - SCAN('w',W) - SCAN('z',Z) -#undef SCAN - - } - - for (;;) - { - char c = *p; - if (!c) return NULL; - if ((c|0x20) == v) return p; - p++; - } -} - -WDL_HASSTRINGS_EXPORT const char *hasStrings_skipSkippable(const char *cptr) -{ - int skip; - while ((skip=WDL_IS_UTF8_SKIPPABLE(((unsigned char*)cptr)[0],((unsigned char*)cptr)[1]))>0) cptr+=skip; - return cptr; -} - -WDL_HASSTRINGS_EXPORT bool WDL_hasStringsEx2(const char **name_list, int name_list_size, const LineParser *lp -#ifdef WDL_HASSTRINGS_EXTRA_PARAMETERS - WDL_HASSTRINGS_EXTRA_PARAMETERS -#endif - ) -{ - if (!lp) return true; - const int ntok = lp->getnumtokens(); - if (ntok<1) return true; - - char stack_[1024]; // &1=not bit, 0x10 = ignoring subscopes, &2= state when 0x10 set - int stacktop = 0, stacktop_v; -#define TOP_OF_STACK stacktop_v -#define PUSH_STACK(x) do { if (stacktop < (int)sizeof(stack_) - 1) stack_[stacktop++] = stacktop_v&0xff; stacktop_v = (x); } while(0) -#define POP_STACK() (stacktop_v = stack_[--stacktop]) - TOP_OF_STACK = 0; - - char matched_local=-1; // -1 = first eval for scope, 0=did not pass scope, 1=OK, 2=ignore rest of scope - for (int x = 0; x < ntok; x ++) - { - const char *n=lp->gettoken_str(x); - - if (n[0] == '(' && !n[1] && !lp->gettoken_quotingchar(x)) - { - if (!(matched_local&1)) - { - TOP_OF_STACK |= matched_local | 0x10; - matched_local=2; // ignore subscope - } - else - { - matched_local = -1; // new scope - } - - PUSH_STACK(0); - } - else if (n[0] == ')' && !n[1] && stacktop && !lp->gettoken_quotingchar(x)) - { - if (POP_STACK()&0x10) - { - // restore state - matched_local = TOP_OF_STACK&2; - } - else - { - matched_local = (matched_local != 0 ? 1 : 0) ^ (TOP_OF_STACK&1); - } - TOP_OF_STACK = 0; - } - else if (n[0] == 'O' && n[1] == 'R' && !n[2] && matched_local != 2 && !lp->gettoken_quotingchar(x)) - { - matched_local = (matched_local > 0) ? 2 : -1; - TOP_OF_STACK = 0; - } - else if (matched_local&1) // matches 1, -1 - { - int ln = (int)strlen(n); - if (ln>0) - { - // ^foo -- string starts (or follows \1 separator with) foo - // foo$ -- string ends with foo (or is immediately followed by \1 separator) - // " foo ", "foo ", " foo" include end of string/start of string has whitespace - int wc_left = 0; // 1=require \1 or start of string, 2=require space or \1 or start - int wc_right = 0; // 1=require \1 or \0, 2 = require space or \1 or \0 - // perhaps wc_left/wc_right of 2 should also match non-alnum characters in addition to space? - if (ln>1) - { - switch (*n) - { - case ' ': - if (*++n != ' ') wc_left=2; - // else { multiple characters of whitespace = literal whitespace search (two spaces requires a single space, etc) } - - ln--; - break; - case '^': - ln--; - n++; - wc_left=1; - break; - // upper case being here implies it is almost certainly NOT/AND due to postprocessing in WDL_makeSearchFilter - case 'N': - if (WDL_NORMALLY(!strcmp(n,"NOT") && !lp->gettoken_quotingchar(x))) - { - TOP_OF_STACK^=1; - continue; - } - break; - case 'A': - if (WDL_NORMALLY(!strcmp(n,"AND") && !lp->gettoken_quotingchar(x))) - { - // ignore unquoted uppercase AND - continue; - } - break; - } - } - if (ln>1) - { - switch (n[ln-1]) - { - case ' ': - if (n[--ln - 1] != ' ') wc_right=2; - // else { multiple characters of whitespace = literal whitespace search (two spaces requires a single space, etc) } - break; - case '$': - ln--; - wc_right++; - break; - } - } - - if (!wc_left && !wc_right && *n) - { - switch (lp->gettoken_quotingchar(x)) - { - case '\'': - case '"': - { // if a quoted string has no whitespace in it, treat as whole word search - const char *p = n; - while (*p && *p != ' ' && *p != '\t') p++; - if (!*p) - { - wc_left=wc_right=2; - } - } - break; - } - } - - bool matched = false; - -#ifdef WDL_HASSTRINGS_PRE_MATCH - if (!wc_left && !wc_right && WDL_HASSTRINGS_PRE_MATCH(n)) - matched = true; - else -#endif - for (int i = 0; i < name_list_size; i ++) - { - const char *name = name_list[i]; - const char *t = name; - -#define MATCH_RIGHT_CHECK_WORD(SZ) \ - (wc_right == 0 || \ - ((const unsigned char*)(t))[SZ] < 2 || \ - (wc_right > 1 && hasStrings_isNonWordChar(hasStrings_skipSkippable((t)+(SZ)))) \ - ) - -#define MATCH_LEFT_SKIP_TO_WORD() do { \ - if (*(unsigned char*)t < 2) { t++; break; } \ - if (wc_left>1) { const int l = hasStrings_isNonWordChar(t); if (l > 0) { t+=l; break; } } \ - t++; \ - } while (t[0]) - - { - const char n0 = n[0]; - if (wc_left>0) - { - for (;;) - { - t = hasStrings_scan_for_char_match(t,n0); - if (!t) break; - if (t==name || t[-1] == 1 || (wc_left>1 && hasStrings_isNonWordChar(hasStrings_rewutf8(t-1,name)))) - { - const int v = hasStrings_utf8cmp((const unsigned char *)t,(const unsigned char *)n,ln); - if (v>=0) - { - if (!v) break; - if (MATCH_RIGHT_CHECK_WORD(v)) { matched = true; break; } - } - } - t++; - } - } - else - { - for (;;) - { - t = hasStrings_scan_for_char_match(t,n0); - if (!t) break; - const int v = hasStrings_utf8cmp((const unsigned char *)t,(const unsigned char *)n,ln); - if (v>=0) - { - if (!v) break; - if (MATCH_RIGHT_CHECK_WORD(v)) { matched = true; break; } - } - t++; - } - } - } -#undef MATCH_RIGHT_CHECK_WORD -#undef MATCH_LEFT_SKIP_TO_WORD - if (matched) break; - } - - matched_local = (matched?1:0) ^ (TOP_OF_STACK&1); - TOP_OF_STACK=0; - } - } - } - while (stacktop > 0) - { - if (POP_STACK() & 0x10) matched_local=TOP_OF_STACK&2; - else matched_local = (matched_local > 0 ? 1 : 0) ^ (TOP_OF_STACK&1); - } - - return matched_local!=0; -#undef TOP_OF_STACK -#undef POP_STACK -#undef PUSH_STACK -} - -#ifndef WDL_HASSTRINGS_EXTRA_PARAMETERS -WDL_HASSTRINGS_EXPORT bool WDL_hasStringsEx(const char *name, const LineParser *lp) -{ - return WDL_hasStringsEx2(&name,1,lp); -} - -WDL_HASSTRINGS_EXPORT bool WDL_hasStrings(const char *name, const LineParser *lp) -{ - return WDL_hasStringsEx2(&name,1,lp); -} -#endif - -WDL_HASSTRINGS_EXPORT char *WDL_hasstrings_preproc_searchitem(char *wr, const char *src) -{ - while (*src) - { - unsigned char c = *(unsigned char*)src++; - if (c >= 'A' && c <= 'Z') c+='a'-'A'; - else if (c == 0xC3) - { - const unsigned char ccf = *(unsigned char*)src; - const unsigned char cc = ccf & ~0x20; - if (WDL_IS_UTF8_BYTE2_LATIN1S_A(cc,ccf)) c = 'a'; - else if (WDL_IS_UTF8_BYTE2_LATIN1S_C(cc,ccf)) c = 'c'; - else if (WDL_IS_UTF8_BYTE2_LATIN1S_E(cc,ccf)) c = 'e'; - else if (WDL_IS_UTF8_BYTE2_LATIN1S_I(cc,ccf)) c = 'i'; - else if (WDL_IS_UTF8_BYTE2_LATIN1S_N(cc,ccf)) c = 'n'; - else if (WDL_IS_UTF8_BYTE2_LATIN1S_O(cc,ccf)) c = 'o'; - else if (WDL_IS_UTF8_BYTE2_LATIN1S_U(cc,ccf)) c = 'u'; - else if (WDL_IS_UTF8_BYTE2_LATIN1S_Y(cc,ccf)) c = 'y'; - - if (c != 0xC3) src++; - } - else if (c == 0xE2) - { - // convert u+2018/2019 to ' - if (*(unsigned char*)src == 0x80 && (((unsigned char*)src)[1]&~1) == 0x98) - { - c = '\''; - src+=2; - } - } - else - { - const int skipl = WDL_IS_UTF8_SKIPPABLE(c, *(unsigned char*)src); - if (skipl > 0) - { - src += skipl-1; - continue; - } - } - - // we could also convert latin extended A characters to ascii here, but meh - *wr++ = c; - } - *wr=0; - return wr; -} - -WDL_HASSTRINGS_EXPORT bool WDL_makeSearchFilter(const char *flt, LineParser *lp) -{ - if (WDL_NOT_NORMALLY(!lp)) return false; - - if (WDL_NOT_NORMALLY(!flt)) flt=""; - -#ifdef WDL_LINEPARSER_HAS_LINEPARSERINT - if (lp->parse_ex(flt,true,false,true)) // allow unterminated quotes -#else - if (lp->parse_ex(flt,true,false)) -#endif - { - if (*flt) lp->set_one_token(flt); // failed parsing search string, search as a single token - } - for (int x = 0; x < lp->getnumtokens(); x ++) - { - char *p = (char *)lp->gettoken_str(x); - if (lp->gettoken_quotingchar(x) || (strcmp(p,"NOT") && strcmp(p,"AND") && strcmp(p,"OR"))) - { - WDL_hasstrings_preproc_searchitem(p, p); - } - } - - return lp->getnumtokens()>0; -} - -#endif diff --git a/oversampling/WDL/heapbuf.h b/oversampling/WDL/heapbuf.h deleted file mode 100644 index bf2a632..0000000 --- a/oversampling/WDL/heapbuf.h +++ /dev/null @@ -1,383 +0,0 @@ -/* - WDL - heapbuf.h - Copyright (C) 2005 and later Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - -*/ - -/* - - This file provides the interface and implementation for WDL_HeapBuf, a simple - malloc() wrapper for resizeable blocks. - - Also in this file is WDL_TypedBuf which is a templated version WDL_HeapBuf - that manages type and type-size. - -*/ - -#ifndef _WDL_HEAPBUF_H_ -#define _WDL_HEAPBUF_H_ - -#ifndef WDL_HEAPBUF_IMPL_ONLY - -#ifdef WDL_HEAPBUF_TRACE -#include -#define WDL_HEAPBUF_TRACEPARM(x) ,(x) -#else -#define WDL_HEAPBUF_TRACEPARM(x) -#endif - -#include "wdltypes.h" - -class WDL_HeapBuf -{ - public: - // interface -#ifdef WDL_HEAPBUF_INTF_ONLY - void *Resize(int newsize, bool resizedown=true); - void CopyFrom(const WDL_HeapBuf *hb, bool exactCopyOfConfig=false); -#endif - void *Get() const { return m_size?m_buf:NULL; } // returns NULL if size is 0 - void *GetFast() const { return m_buf; } // returns last buffer if size is 0 - int GetSize() const { return m_size; } - void *GetAligned(int align) const { return (void *)(((UINT_PTR)Get() + (align-1)) & ~(UINT_PTR)(align-1)); } - - void SetGranul(int granul) { m_granul = granul; } - int GetGranul() const { return m_granul; } - - void *ResizeOK(int newsize, bool resizedown = true) { void *p=Resize(newsize, resizedown); return GetSize() == newsize ? p : NULL; } - - WDL_HeapBuf(const WDL_HeapBuf &cp) - { - m_buf=0; - CopyFrom(&cp,true); - } - WDL_HeapBuf &operator=(const WDL_HeapBuf &cp) - { - CopyFrom(&cp,false); - return *this; - } - - - - #ifndef WDL_HEAPBUF_TRACE - explicit WDL_HeapBuf(int granul=4096) : m_buf(NULL), m_alloc(0), m_size(0), m_granul(granul) - { - } - ~WDL_HeapBuf() - { - free(m_buf); - } - #else - explicit WDL_HeapBuf(int granul=4096, const char *tracetype="WDL_HeapBuf" - ) : m_buf(NULL), m_alloc(0), m_size(0), m_granul(granul) - { - m_tracetype = tracetype; - wdl_log("WDL_HeapBuf: created type: %s granul=%d\n",tracetype,granul); - } - ~WDL_HeapBuf() - { - wdl_log("WDL_HeapBuf: destroying type: %s (alloc=%d, size=%d)\n",m_tracetype,m_alloc,m_size); - free(m_buf); - } - #endif - -#endif // !WDL_HEAPBUF_IMPL_ONLY - - // implementation bits -#ifndef WDL_HEAPBUF_INTF_ONLY - #ifdef WDL_HEAPBUF_IMPL_ONLY - void *WDL_HeapBuf::Resize(int newsize, bool resizedown) - #else - void *Resize(int newsize, bool resizedown=true) - #endif - { - if (newsize<0) newsize=0; - #ifdef DEBUG_TIGHT_ALLOC // horribly slow, do not use for release builds - if (newsize == m_size) return m_buf; - - int a = newsize; - if (a > m_size) a=m_size; - void *newbuf = newsize ? malloc(newsize) : 0; - if (!newbuf && newsize) - { - #ifdef WDL_HEAPBUF_ONMALLOCFAIL - WDL_HEAPBUF_ONMALLOCFAIL(newsize) - #endif - return m_buf; - } - if (newbuf&&m_buf) memcpy(newbuf,m_buf,a); - m_size=m_alloc=newsize; - free(m_buf); - return m_buf=newbuf; - #endif - - if (newsize!=m_size || (resizedown && newsize < m_alloc/2)) - { - int resizedown_under = 0; - if (resizedown && newsize < m_size) - { - // shrinking buffer: only shrink if allocation decreases to min(alloc/2, alloc-granul*4) or 0 - resizedown_under = m_alloc - (m_granul<<2); - if (resizedown_under > m_alloc/2) resizedown_under = m_alloc/2; - if (resizedown_under < 1) resizedown_under=1; - } - - if (newsize > m_alloc || newsize < resizedown_under) - { - int granul=newsize/2; - int newalloc; - if (granul < m_granul) granul=m_granul; - - if (newsize<1) newalloc=0; - else if (m_granul<4096) newalloc=newsize+granul; - else - { - granul &= ~4095; - if (granul< 4096) granul=4096; - else if (granul>4*1024*1024) granul=4*1024*1024; - newalloc = ((newsize + granul + 96)&~4095)-96; - } - - if (newalloc != m_alloc) - { - - #ifdef WDL_HEAPBUF_TRACE - wdl_log("WDL_HeapBuf: type %s realloc(%d) from %d\n",m_tracetype,newalloc,m_alloc); - #endif - if (newalloc <= 0) - { - free(m_buf); - m_buf=0; - m_alloc=0; - m_size=0; - return 0; - } - void *nbuf=realloc(m_buf,newalloc); - if (!nbuf) - { - if (!(nbuf=malloc(newalloc))) - { - #ifdef WDL_HEAPBUF_ONMALLOCFAIL - WDL_HEAPBUF_ONMALLOCFAIL(newalloc); - #endif - return m_size?m_buf:0; // failed, do not resize - } - - if (m_buf) - { - int sz=newsize0) memcpy(nbuf,m_buf,sz); - free(m_buf); - } - } - - m_buf=nbuf; - m_alloc=newalloc; - } // alloc size change - } // need size up or down - m_size=newsize; - } // size change - return m_size?m_buf:0; - } - - #ifdef WDL_HEAPBUF_IMPL_ONLY - void WDL_HeapBuf::CopyFrom(const WDL_HeapBuf *hb, bool exactCopyOfConfig) - #else - void CopyFrom(const WDL_HeapBuf *hb, bool exactCopyOfConfig=false) - #endif - { - if (exactCopyOfConfig) // copy all settings - { - free(m_buf); - - #ifdef WDL_HEAPBUF_TRACE - m_tracetype = hb->m_tracetype; - #endif - m_granul = hb->m_granul; - - m_size=m_alloc=0; - m_buf=hb->m_buf && hb->m_alloc>0 ? malloc(m_alloc = hb->m_alloc) : NULL; - #ifdef WDL_HEAPBUF_ONMALLOCFAIL - if (!m_buf && m_alloc) { WDL_HEAPBUF_ONMALLOCFAIL(m_alloc) } ; - #endif - if (m_buf) memcpy(m_buf,hb->m_buf,m_size = hb->m_size); - else m_alloc=0; - } - else // copy just the data + size - { - const int newsz=hb->GetSize(); - Resize(newsz,true); - if (GetSize()!=newsz) Resize(0); - else memcpy(Get(),hb->Get(),newsz); - } - } - -#endif // ! WDL_HEAPBUF_INTF_ONLY - -#ifndef WDL_HEAPBUF_IMPL_ONLY - - private: - void *m_buf; - int m_alloc; - int m_size; - int m_granul; - - #if defined(_WIN64) || defined(__LP64__) - public: - int ___pad; // keep size 8 byte aligned - #endif - - #ifdef WDL_HEAPBUF_TRACE - const char *m_tracetype; - #endif - -}; - -template class WDL_TypedBuf -{ - public: - PTRTYPE *Get() const { return (PTRTYPE *) m_hb.Get(); } - PTRTYPE *GetFast() const { return (PTRTYPE *) m_hb.GetFast(); } - int GetSize() const { return m_hb.GetSize()/(unsigned int)sizeof(PTRTYPE); } - int GetSizeBytes() const { return m_hb.GetSize(); } - - PTRTYPE *Resize(int newsize, bool resizedown = true) { return (PTRTYPE *)m_hb.Resize(newsize*sizeof(PTRTYPE),resizedown); } - PTRTYPE *ResizeOK(int newsize, bool resizedown = true) { return (PTRTYPE *)m_hb.ResizeOK(newsize*sizeof(PTRTYPE), resizedown); } - - void SetToZero() { memset(m_hb.Get(), 0, m_hb.GetSize()); } - - PTRTYPE *GetAligned(int align) const { return (PTRTYPE *) m_hb.GetAligned(align); } - - PTRTYPE *Add(PTRTYPE val) - { - const int sz=GetSize(); - PTRTYPE* p=ResizeOK(sz+1,false); - if (p) - { - p[sz]=val; - return p+sz; - } - return NULL; - } - PTRTYPE *Add(const PTRTYPE *buf, int bufsz) - { - if (bufsz>0) - { - const int sz=GetSize(); - PTRTYPE* p=ResizeOK(sz+bufsz,false); - if (p) - { - p+=sz; - if (buf) memcpy(p,buf,bufsz*sizeof(PTRTYPE)); - else memset((char*)p,0,bufsz*sizeof(PTRTYPE)); - return p; - } - } - return NULL; - } - PTRTYPE *Set(const PTRTYPE *buf, int bufsz) - { - if (bufsz>=0) - { - PTRTYPE* p=ResizeOK(bufsz,false); - if (p) - { - if (buf) memcpy(p,buf,bufsz*sizeof(PTRTYPE)); - else memset((char*)p,0,bufsz*sizeof(PTRTYPE)); - return p; - } - } - return NULL; - } - PTRTYPE* Insert(PTRTYPE val, int idx) - { - const int sz=GetSize(); - if (idx >= 0 && idx <= sz) - { - PTRTYPE* p=ResizeOK(sz+1,false); - if (p) - { - memmove(p+idx+1, p+idx, (sz-idx)*sizeof(PTRTYPE)); - p[idx]=val; - return p+idx; - } - } - return NULL; - } - - void Delete(int idx) - { - PTRTYPE* p=Get(); - const int sz=GetSize(); - if (idx >= 0 && idx < sz) - { - memmove(p+idx, p+idx+1, (sz-idx-1)*sizeof(PTRTYPE)); - Resize(sz-1,false); - } - } - - void SetGranul(int gran) { m_hb.SetGranul(gran); } - - int Find(PTRTYPE val) const - { - const PTRTYPE* p=Get(); - const int sz=GetSize(); - int i; - for (i=0; i < sz; ++i) if (p[i] == val) return i; - return -1; - } - -#ifndef WDL_HEAPBUF_TRACE - explicit WDL_TypedBuf(int granul=4096) : m_hb(granul) { } -#else - explicit WDL_TypedBuf(int granul=4096, const char *tracetype="WDL_TypedBuf") : m_hb(granul WDL_HEAPBUF_TRACEPARM(tracetype)) { } -#endif - ~WDL_TypedBuf() - { - } - - WDL_HeapBuf *GetHeapBuf() { return &m_hb; } - const WDL_HeapBuf *GetHeapBuf() const { return &m_hb; } - - int DeleteBatch(bool (*proc)(PTRTYPE *p, void *ctx), void *ctx=NULL) // proc returns true to delete item. returns number deleted - { - const int sz = GetSize(); - int cnt=0; - PTRTYPE *rd = Get(), *wr = rd; - for (int x = 0; x < sz; x ++) - { - if (!proc(rd,ctx)) - { - if (rd != wr) *wr=*rd; - wr++; - cnt++; - } - rd++; - } - if (cnt < sz) Resize(cnt,false); - return sz - cnt; - } - - private: - WDL_HeapBuf m_hb; -}; - -#endif // ! WDL_HEAPBUF_IMPL_ONLY - -#endif // _WDL_HEAPBUF_H_ diff --git a/oversampling/WDL/jnetlib/Makefile b/oversampling/WDL/jnetlib/Makefile deleted file mode 100644 index 10d9fe8..0000000 --- a/oversampling/WDL/jnetlib/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# freebsd3 makefile -default: jnl.a - -LDFLAGS = -pthread -CFLAGS = -s -O2 -Wall -DTHREAD_SAFE -D_THREAD_SAFE -D_REENTRANT -CC = gcc -CPP = g++ -CXX = g++ - -OBJS = asyncdns.o connection.o httpget.o httpserv.o listen.o util.o sercon.o - -jnl.a: ${OBJS} - -rm -f jnl.a - ar rcs jnl.a ${OBJS} - -test: ${OBJS} test.o - $(CC) ${CFLAGS} -o test test.o ${OBJS} ${LDFLAGS} - -clean: - -rm -f ${OBJS} test jnl.a test.o diff --git a/oversampling/WDL/jnetlib/asyncdns.cpp b/oversampling/WDL/jnetlib/asyncdns.cpp deleted file mode 100644 index dea5e77..0000000 --- a/oversampling/WDL/jnetlib/asyncdns.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2008 Cockos Inc -** Copyright (C) 2000-2001 Nullsoft, Inc. -** Author: Justin Frankel -** File: asyncdns.cpp - JNL portable asynchronous DNS implementation -** License: see jnetlib.h -*/ - -#include "netinc.h" -#include "util.h" -#include "asyncdns.h" -#ifdef _WIN32 -#include -#endif -#include "../wdlcstring.h" - -JNL_AsyncDNS::JNL_AsyncDNS(int max_cache_entries) -{ - m_thread_kill=1; - m_thread=0; - m_cache_size=max_cache_entries; - m_cache=(cache_entry *)::malloc(sizeof(cache_entry)*m_cache_size); - if (m_cache) memset(m_cache,0,sizeof(cache_entry)*m_cache_size); - else m_cache_size = 0; -} - -JNL_AsyncDNS::~JNL_AsyncDNS() -{ -#ifndef NO_DNS_SUPPORT - m_thread_kill=1; - -#ifdef _WIN32 - if (m_thread) - { - WaitForSingleObject(m_thread,INFINITE); - CloseHandle(m_thread); - } -#else - if (m_thread) - { - void *p; - pthread_join(m_thread,&p); - } -#endif//!_WIN32 -#endif//NO_DNS_SUPPORT - free(m_cache); -} - -#ifdef _WIN32 -unsigned WINAPI JNL_AsyncDNS::_threadfunc(void *_d) -#else -unsigned int JNL_AsyncDNS::_threadfunc(void *_d) -#endif -{ -#ifndef NO_DNS_SUPPORT - int nowinsock=JNL::open_socketlib(); - JNL_AsyncDNS *_this=(JNL_AsyncDNS*)_d; - int x; - for (x = 0; x < _this->m_cache_size && !_this->m_thread_kill; x ++) - { - if (_this->m_cache[x].last_used && !_this->m_cache[x].resolved) - { - if (!nowinsock) - { - if (_this->m_cache[x].mode==0) - { - struct hostent *hostentry; - hostentry=::gethostbyname(_this->m_cache[x].hostname); - if (hostentry) - { - memcpy(&_this->m_cache[x].addr,hostentry->h_addr,sizeof(int)); - } - else - _this->m_cache[x].addr=INADDR_NONE; - } - else if (_this->m_cache[x].mode==1) - { - struct hostent *ent; - ent=::gethostbyaddr((const char *)&_this->m_cache[x].addr,4,AF_INET); - lstrcpyn_safe(_this->m_cache[x].hostname,ent ? ent->h_name : "",sizeof(_this->m_cache[x].hostname)); - } - _this->m_cache[x].resolved=1; - } - else - { - if (_this->m_cache[x].mode==0) - { - _this->m_cache[x].addr=INADDR_NONE; - _this->m_cache[x].resolved=1; - } - else if (_this->m_cache[x].mode==1) - { - _this->m_cache[x].hostname[0]=0; - _this->m_cache[x].resolved=1; - } - } - } - } - if (!nowinsock) JNL::close_socketlib(); - _this->m_thread_kill=1; -#endif // NO_DNS_SUPPORT - - return 0; -} - -int JNL_AsyncDNS::resolve(const char *hostname, unsigned int *addr) -{ - // return 0 on success, 1 on wait, -1 on unresolvable - int x; - unsigned int ip=inet_addr(hostname); - if (ip != INADDR_NONE) - { - *addr=ip; - return 0; - } -#ifndef NO_DNS_SUPPORT - - for (x = 0; x < m_cache_size; x ++) - { - if (!stricmp(m_cache[x].hostname,hostname) && m_cache[x].mode==0) - { - m_cache[x].last_used=time(NULL); - if (m_cache[x].resolved) - { - if (m_cache[x].addr == INADDR_NONE) - { - return -1; - } - *addr=m_cache[x].addr; - return 0; - } - makesurethreadisrunning(); - return 1; - } - } - // add to resolve list - int oi=-1; - for (x = 0; x < m_cache_size; x ++) - { - if (!m_cache[x].last_used) - { - oi=x; - break; - } - if ((oi==-1 || m_cache[x].last_used < m_cache[oi].last_used) && m_cache[x].resolved) - { - oi=x; - } - } - if (oi == -1) - { - return -1; - } - strcpy(m_cache[oi].hostname,hostname); - m_cache[oi].mode=0; - m_cache[oi].addr=INADDR_NONE; - m_cache[oi].resolved=0; - m_cache[oi].last_used=time(NULL); - - makesurethreadisrunning(); - return 1; -#else - return -1; -#endif -} - -int JNL_AsyncDNS::reverse(unsigned int addr, char *hostname) -{ - // return 0 on success, 1 on wait, -1 on unresolvable - int x; - if (addr == INADDR_NONE) - { - return -1; - } -#ifndef NO_DNS_SUPPORT - for (x = 0; x < m_cache_size; x ++) - { - if (m_cache[x].addr==addr && m_cache[x].mode==1) - { - m_cache[x].last_used=time(NULL); - if (m_cache[x].resolved) - { - if (!m_cache[x].hostname[0]) - { - return -1; - } - lstrcpyn_safe(hostname,m_cache[x].hostname,256); - return 0; - } - makesurethreadisrunning(); - return 1; - } - } - // add to resolve list - int oi=-1; - for (x = 0; x < m_cache_size; x ++) - { - if (!m_cache[x].last_used) - { - oi=x; - break; - } - if ((oi==-1 || m_cache[x].last_used < m_cache[oi].last_used) && m_cache[x].resolved) - { - oi=x; - } - } - if (oi == -1) - { - return -1; - } - m_cache[oi].addr=addr; - m_cache[oi].hostname[0]=0; - m_cache[oi].resolved=0; - m_cache[oi].mode=1; - m_cache[oi].last_used=time(NULL); - - makesurethreadisrunning(); - return 1; -#else - return -1; -#endif -} - - -void JNL_AsyncDNS::makesurethreadisrunning(void) -{ -#ifndef NO_DNS_SUPPORT - if (m_thread_kill) - { - #ifdef _WIN32 - if (m_thread) - { - WaitForSingleObject(m_thread,INFINITE); - CloseHandle(m_thread); - } - unsigned id; - m_thread_kill=0; - m_thread=(HANDLE)_beginthreadex(NULL,0,_threadfunc,(void *)this,0,&id); - if (!m_thread) - { - #else - if (m_thread) - { - void *p; - pthread_join(m_thread,&p); - } - m_thread_kill=0; - if (pthread_create(&m_thread,NULL,(void *(*) (void *))_threadfunc,(void*)this) != 0) - { - #endif - m_thread_kill=1; - } - } -#endif//NO_DNS_SUPPORT -} diff --git a/oversampling/WDL/jnetlib/asyncdns.h b/oversampling/WDL/jnetlib/asyncdns.h deleted file mode 100644 index b9098f6..0000000 --- a/oversampling/WDL/jnetlib/asyncdns.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2008 Cockos Inc -** Copyright (C) 2000-2001 Nullsoft, Inc. -** Author: Justin Frankel -** File: asyncdns.h - JNL portable asynchronous DNS interface -** License: see jnetlib.h -** -** Usage: -** 1. Create JNL_AsyncDNS object, optionally with the number of cache entries. -** 2. call resolve() to resolve a hostname into an address. The return value of -** resolve is 0 on success (host successfully resolved), 1 on wait (meaning -** try calling resolve() with the same hostname in a few hundred milliseconds -** or so), or -1 on error (i.e. the host can't resolve). -** 3. call reverse() to do reverse dns (ala resolve()). -** 4. enjoy. -*/ - -#ifndef _ASYNCDNS_H_ -#define _ASYNCDNS_H_ - -#include - -#ifndef JNL_NO_DEFINE_INTERFACES -class JNL_IAsyncDNS -{ -public: - virtual ~JNL_IAsyncDNS() { } - virtual int resolve(const char *hostname, unsigned int *addr)=0; // return 0 on success, 1 on wait, -1 on unresolvable - virtual int reverse(unsigned int addr, char *hostname)=0; // return 0 on success, 1 on wait, -1 on unresolvable. hostname must be at least 256 bytes. -}; -#define JNL_AsyncDNS_PARENTDEF : public JNL_IAsyncDNS -#else -#define JNL_IAsyncDNS JNL_AsyncDNS -#define JNL_AsyncDNS_PARENTDEF -#endif - - -#ifndef JNL_NO_IMPLEMENTATION - -class JNL_AsyncDNS JNL_AsyncDNS_PARENTDEF -{ -public: - JNL_AsyncDNS(int max_cache_entries=64); - ~JNL_AsyncDNS(); - - int resolve(const char *hostname, unsigned int *addr); // return 0 on success, 1 on wait, -1 on unresolvable - int reverse(unsigned int addr, char *hostname); // return 0 on success, 1 on wait, -1 on unresolvable. hostname must be at least 256 bytes. - -private: - typedef struct - { - time_t last_used; // timestamp. - char resolved; - char mode; // 1=reverse - char hostname[256]; - unsigned int addr; - } - cache_entry; - - cache_entry *m_cache; - int m_cache_size; - volatile int m_thread_kill; -#ifdef _WIN32 - HANDLE m_thread; - static unsigned WINAPI _threadfunc(void *_d); -#else - pthread_t m_thread; - static unsigned int _threadfunc(void *_d); -#endif - void makesurethreadisrunning(void); - -}; -#endif // !JNL_NO_IMPLEMENTATION - -#endif //_ASYNCDNS_H_ diff --git a/oversampling/WDL/jnetlib/connection.cpp b/oversampling/WDL/jnetlib/connection.cpp deleted file mode 100644 index 710d909..0000000 --- a/oversampling/WDL/jnetlib/connection.cpp +++ /dev/null @@ -1,505 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2008 Cockos Inc -** Copyright (C) 2000-2001 Nullsoft, Inc. -** Author: Justin Frankel -** File: connection.cpp - JNL TCP connection implementation -** License: see jnetlib.h -*/ - -#include "netinc.h" -#include "util.h" -#include "connection.h" -#include "../wdlcstring.h" - - -JNL_Connection::JNL_Connection(JNL_IAsyncDNS *dns, int sendbufsize, int recvbufsize) -{ - m_errorstr=""; - if (dns == JNL_CONNECTION_AUTODNS) - { - m_dns=new JNL_AsyncDNS(); - m_dns_owned=1; - } - else - { - m_dns=dns; - m_dns_owned=0; - } - m_recv_buffer.Resize(recvbufsize); - m_send_buffer.Resize(sendbufsize); - m_socket=INVALID_SOCKET; - m_remote_port=0; - m_state=STATE_NOCONNECTION; - m_localinterfacereq=INADDR_ANY; - m_recv_len=m_recv_pos=0; - m_send_len=m_send_pos=0; - m_host[0]=0; - m_saddr = new struct sockaddr_in; - memset(m_saddr,0,sizeof(struct sockaddr_in)); -} - -void JNL_Connection::connect(SOCKET s, struct sockaddr_in *loc) -{ - close(1); - m_socket=s; - m_remote_port=0; - m_dns=NULL; - if (loc) *m_saddr=*loc; - else memset(m_saddr,0,sizeof(struct sockaddr_in)); - if (m_socket != INVALID_SOCKET) - { - SET_SOCK_DEFAULTS(m_socket); - SET_SOCK_BLOCK(m_socket,0); - m_state=STATE_CONNECTED; - } - else - { - m_errorstr="invalid socket passed to connect"; - m_state=STATE_ERROR; - } -} - -void JNL_Connection::connect(const char *hostname, int port) -{ - close(1); - m_remote_port=(short)port; - m_socket=::socket(AF_INET,SOCK_STREAM,0); - if (m_socket==INVALID_SOCKET) - { - m_errorstr="creating socket"; - m_state=STATE_ERROR; - } - else - { - if (m_localinterfacereq != INADDR_ANY) - { - sockaddr_in sa={0,}; - sa.sin_family=AF_INET; - sa.sin_addr.s_addr=m_localinterfacereq; - bind(m_socket,(struct sockaddr *)&sa,16); - } - SET_SOCK_DEFAULTS(m_socket); - SET_SOCK_BLOCK(m_socket,0); - lstrcpyn_safe(m_host,hostname,sizeof(m_host)); - memset(m_saddr,0,sizeof(struct sockaddr_in)); - if (!m_host[0]) - { - m_errorstr="empty hostname"; - m_state=STATE_ERROR; - } - else - { - m_state=STATE_RESOLVING; - m_saddr->sin_family=AF_INET; - m_saddr->sin_port=htons((unsigned short)port); - m_saddr->sin_addr.s_addr=inet_addr(hostname); - } - } -} - -JNL_Connection::~JNL_Connection() -{ - if (m_socket != INVALID_SOCKET) - { - ::shutdown(m_socket, SHUT_RDWR); - ::closesocket(m_socket); - m_socket=INVALID_SOCKET; - } - if (m_dns_owned) - { - delete m_dns; - } - delete m_saddr; -} - -void JNL_Connection::run(int max_send_bytes, int max_recv_bytes, int *bytes_sent, int *bytes_rcvd) -{ - int bytes_allowed_to_send=(max_send_bytes<0)?m_send_buffer.GetSize():max_send_bytes; - int bytes_allowed_to_recv=(max_recv_bytes<0)?m_recv_buffer.GetSize():max_recv_bytes; - - if (bytes_sent) *bytes_sent=0; - if (bytes_rcvd) *bytes_rcvd=0; - - switch (m_state) - { - case STATE_RESOLVING: - if (m_saddr->sin_addr.s_addr == INADDR_NONE) - { - int a=m_dns?m_dns->resolve(m_host,(unsigned int *)&m_saddr->sin_addr.s_addr):-1; - if (!a) { m_state=STATE_CONNECTING; } - else if (a == 1) - { - m_state=STATE_RESOLVING; - break; - } - else - { - m_errorstr="resolving hostname"; - m_state=STATE_ERROR; - return; - } - } - if (!::connect(m_socket,(struct sockaddr *)m_saddr,16)) - { - m_state=STATE_CONNECTED; - } - else if (JNL_ERRNO!=JNL_EINPROGRESS) - { - m_errorstr="connecting to host"; - m_state=STATE_ERROR; - } - else { m_state=STATE_CONNECTING; } - break; - case STATE_CONNECTING: - { -#ifdef _WIN32 - fd_set f[3]; - FD_ZERO(&f[0]); - FD_ZERO(&f[1]); - FD_ZERO(&f[2]); - FD_SET(m_socket,&f[0]); - FD_SET(m_socket,&f[1]); - FD_SET(m_socket,&f[2]); - struct timeval tv; - memset(&tv,0,sizeof(tv)); - if (select(0,&f[0],&f[1],&f[2],&tv)==-1) - { - m_errorstr="connecting to host (calling select())"; - m_state=STATE_ERROR; - } - else if (FD_ISSET(m_socket,&f[1])) - { - m_state=STATE_CONNECTED; - } - else if (FD_ISSET(m_socket,&f[2])) - { - m_errorstr="connecting to host"; - m_state=STATE_ERROR; - } -#else - struct pollfd pl = { m_socket, POLLERR|POLLHUP|POLLOUT, 0 }; - int res = poll(&pl,1,0); - if (res < 0 || (pl.revents & (POLLERR|POLLHUP))) - { - m_errorstr="connecting to host"; - m_state=STATE_ERROR; - } - else if (res>0 || (pl.revents&POLLOUT)) - m_state=STATE_CONNECTED; -#endif - } - break; - case STATE_CONNECTED: - case STATE_CLOSING: - if (m_send_len>0 && bytes_allowed_to_send>0) - { - int len=m_send_buffer.GetSize()-m_send_pos; - if (len > m_send_len) len=m_send_len; - if (len > bytes_allowed_to_send) len=bytes_allowed_to_send; - if (len > 0) - { - int res=(int)::send(m_socket,(char*)m_send_buffer.Get()+m_send_pos,len,0); - if (res==-1 && JNL_ERRNO != JNL_EWOULDBLOCK) - { -// m_state=STATE_CLOSED; -// return; - } - if (res>0) - { - bytes_allowed_to_send-=res; - if (bytes_sent) *bytes_sent+=res; - m_send_pos+=res; - m_send_len-=res; - } - } - if (m_send_pos>=m_send_buffer.GetSize()) - { - m_send_pos=0; - if (m_send_len>0) - { - len=m_send_buffer.GetSize()-m_send_pos; - if (len > m_send_len) len=m_send_len; - if (len > bytes_allowed_to_send) len=bytes_allowed_to_send; - int res=(int)::send(m_socket,(char*)m_send_buffer.Get()+m_send_pos,len,0); - if (res==-1 && JNL_ERRNO != JNL_EWOULDBLOCK) - { -// m_state=STATE_CLOSED; - } - if (res>0) - { - bytes_allowed_to_send-=res; - if (bytes_sent) *bytes_sent+=res; - m_send_pos+=res; - m_send_len-=res; - } - } - } - } - if (m_recv_len m_recv_buffer.GetSize()-m_recv_len) len=m_recv_buffer.GetSize()-m_recv_len; - if (len > bytes_allowed_to_recv) len=bytes_allowed_to_recv; - if (len>0) - { - int res=(int)::recv(m_socket,(char*)m_recv_buffer.Get()+m_recv_pos,len,0); - if (res == 0 || (res < 0 && JNL_ERRNO != JNL_EWOULDBLOCK)) - { - m_state=STATE_CLOSED; - break; - } - if (res > 0) - { - bytes_allowed_to_recv-=res; - if (bytes_rcvd) *bytes_rcvd+=res; - m_recv_pos+=res; - m_recv_len+=res; - } - } - if (m_recv_pos >= m_recv_buffer.GetSize()) - { - m_recv_pos=0; - if (m_recv_len < m_recv_buffer.GetSize()) - { - len=m_recv_buffer.GetSize()-m_recv_len; - if (len > bytes_allowed_to_recv) len=bytes_allowed_to_recv; - if (len > 0) - { - int res=(int)::recv(m_socket,(char*)m_recv_buffer.Get()+m_recv_pos,len,0); - if (res == 0 || (res < 0 && JNL_ERRNO != JNL_EWOULDBLOCK)) - { - m_state=STATE_CLOSED; - break; - } - if (res > 0) - { - bytes_allowed_to_recv-=res; - if (bytes_rcvd) *bytes_rcvd+=res; - m_recv_pos+=res; - m_recv_len+=res; - } - } - } - } - } - if (m_state == STATE_CLOSING) - { - if (m_send_len < 1) m_state = STATE_CLOSED; - } - break; - default: break; - } -} - -void JNL_Connection::close(int quick) -{ - if (quick || m_state == STATE_RESOLVING || m_state == STATE_CONNECTING) - { - m_state=STATE_CLOSED; - if (m_socket != INVALID_SOCKET) - { - ::shutdown(m_socket, SHUT_RDWR); - ::closesocket(m_socket); - } - m_socket=INVALID_SOCKET; - m_remote_port=0; - m_recv_len=m_recv_pos=0; - m_send_len=m_send_pos=0; - m_host[0]=0; - memset(m_saddr,0,sizeof(struct sockaddr_in)); - } - else - { - if (m_state == STATE_CONNECTED) m_state=STATE_CLOSING; - } -} - -int JNL_Connection::send_bytes_in_queue(void) -{ - return m_send_len; -} - -int JNL_Connection::send_bytes_available(void) -{ - return m_send_buffer.GetSize()-m_send_len; -} - -int JNL_Connection::send(const void *_data, int length) -{ - const char *data = static_cast(_data); - if (length > send_bytes_available()) - { - return -1; - } - - int write_pos=m_send_pos+m_send_len; - if (write_pos >= m_send_buffer.GetSize()) - { - write_pos-=m_send_buffer.GetSize(); - } - - int len=m_send_buffer.GetSize()-write_pos; - if (len > length) - { - len=length; - } - - memcpy(m_send_buffer.Get()+write_pos,data,len); - if (length > len) - { - memcpy(m_send_buffer.Get(),data+len,length-len); - } - m_send_len+=length; - return 0; -} - -int JNL_Connection::send_string(const char *line) -{ - return send(line,(int)strlen(line)); -} - -int JNL_Connection::recv_bytes_available(void) -{ - return m_recv_len; -} - -int JNL_Connection::peek_bytes(void *data, int maxlength) -{ - if (maxlength > m_recv_len) - { - maxlength=m_recv_len; - } - int read_pos=m_recv_pos-m_recv_len; - if (read_pos < 0) - { - read_pos += m_recv_buffer.GetSize(); - } - int len=m_recv_buffer.GetSize()-read_pos; - if (len > maxlength) - { - len=maxlength; - } - if (data != NULL) { - memcpy(data,m_recv_buffer.Get()+read_pos,len); - if (len < maxlength) - { - memcpy((char*)data+len,m_recv_buffer.Get(),maxlength-len); - } - } - - return maxlength; -} - -int JNL_Connection::recv_bytes(void *_data, int maxlength) -{ - char *data = static_cast(_data); - - int ml=peek_bytes(data,maxlength); - m_recv_len-=ml; - return ml; -} - -int JNL_Connection::getbfromrecv(int pos, int remove) -{ - int read_pos=m_recv_pos-m_recv_len + pos; - if (pos < 0 || pos > m_recv_len) return -1; - if (read_pos < 0) - { - read_pos += m_recv_buffer.GetSize(); - } - if (read_pos >= m_recv_buffer.GetSize()) - { - read_pos-=m_recv_buffer.GetSize(); - } - if (remove) m_recv_len--; - return m_recv_buffer.Get()[read_pos]; -} - -int JNL_Connection::recv_lines_available(void) -{ - int l=recv_bytes_available(); - int lcount=0; - int lastch=0; - int pos; - for (pos=0; pos < l; pos ++) - { - int t=getbfromrecv(pos,0); - if (t == -1) return lcount; - if ((t=='\r' || t=='\n') &&( - (lastch != '\r' && lastch != '\n') || lastch==t - )) lcount++; - lastch=t; - } - return lcount; -} - -int JNL_Connection::recv_get_linelen() -{ - int l = 0; - while (l < m_recv_len) - { - int t=getbfromrecv(l,0); - if (t<0) return 0; - - if (t == '\r' || t == '\n') - { - int r=getbfromrecv(++l,0); - if ((r == '\r' || r == '\n') && r != t) l++; - return l; - } - l++; - } - return 0; -} - -int JNL_Connection::recv_line(char *line, int maxlength) -{ - maxlength--; // room for trailing NUL - if (maxlength > m_recv_len) maxlength=m_recv_len; - while (maxlength-- > 0) - { - int t=getbfromrecv(0,1); - if (t == -1) - { - *line=0; - return 0; - } - if (t == '\r' || t == '\n') - { - int r=getbfromrecv(0,0); - if ((r == '\r' || r == '\n') && r != t) getbfromrecv(0,1); - *line=0; - return 0; - } - *line++=(char)t; - } - *line=0; - return 1; -} - -void JNL_Connection::set_interface(int useInterface) // call before connect if needed -{ - m_localinterfacereq = useInterface; -} - - -unsigned int JNL_Connection::get_interface(void) -{ - if (m_socket==INVALID_SOCKET) return 0; - struct sockaddr_in sin; - memset(&sin,0,sizeof(sin)); - socklen_t len=16; - if (::getsockname(m_socket,(struct sockaddr *)&sin,&len)) return 0; - return (unsigned int) sin.sin_addr.s_addr; -} - -unsigned int JNL_Connection::get_remote() -{ - return m_saddr->sin_addr.s_addr; -} - -short JNL_Connection::get_remote_port() -{ - return m_remote_port; -} diff --git a/oversampling/WDL/jnetlib/connection.h b/oversampling/WDL/jnetlib/connection.h deleted file mode 100644 index eab9ae2..0000000 --- a/oversampling/WDL/jnetlib/connection.h +++ /dev/null @@ -1,193 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2008 Cockos Inc -** Copyright (C) 2000-2001 Nullsoft, Inc. -** Author: Justin Frankel -** File: connection.h - JNL TCP connection interface -** License: see jnetlib.h -** -** Usage: -** 1. Create a JNL_Connection object, optionally specifying a JNL_IAsyncDNS -** object to use (or NULL for none, or JNL_CONNECTION_AUTODNS for auto), -** and the send and receive buffer sizes. -** 2. Call connect() to have it connect to a host/port (the hostname will be -** resolved if possible). -** 3. call run() with the maximum send/recv amounts, and optionally parameters -** so you can tell how much has been send/received. You want to do this a lot, while: -** 4. check get_state() to check the state of the connection. The states are: -** JNL_Connection::STATE_ERROR -** - an error has occured on the connection. the connection has closed, -** and you can no longer write to the socket (there still might be -** data in the receive buffer - use recv_bytes_available()). -** JNL_Connection::STATE_NOCONNECTION -** - no connection has been made yet. call connect() already! :) -** JNL_Connection::STATE_RESOLVING -** - the connection is still waiting for a JNL_AsycnDNS to resolve the -** host. -** JNL_Connection::STATE_CONNECTING -** - the asynchronous call to connect() is still running. -** JNL_Connection::STATE_CONNECTED -** - the connection has connected, all is well. -** JNL_Connection::STATE_CLOSING -** - the connection is closing. This happens after a call to close, -** without the quick parameter set. This means that the connection -** will close once the data in the send buffer is sent (data could -** still be being received when it would be closed). After it is -** closed, the state will transition to: -** JNL_Connection::STATE_CLOSED -** - the connection has closed, generally without error. There still -** might be data in the receieve buffer, use recv_bytes_available(). -** 5. Use send() and send_string() to send data. You can use -** send_bytes_in_queue() to see how much has yet to go out, or -** send_bytes_available() to see how much you can write. If you use send() -** or send_string() and not enough room is available, both functions will -** return error ( < 0) -** 6. Use recv() and recv_line() to get data. If you want to see how much data -** there is, use recv_bytes_available() and recv_lines_available(). If you -** call recv() and not enough data is available, recv() will return how much -** data was actually read. See comments at the function defs. -** -** 7. To close, call close(1) for a quick close, or close() for a close that will -** make the socket close after sending all the data sent. -** -** 8. delete ye' ol' object. -*/ - -#ifndef _CONNECTION_H_ -#define _CONNECTION_H_ - -#include "asyncdns.h" -#include "netinc.h" -#include "../heapbuf.h" - -#define JNL_CONNECTION_AUTODNS ((JNL_IAsyncDNS*)-1) - -struct sockaddr_in; - -#ifndef JNL_NO_DEFINE_INTERFACES -class JNL_IConnection -{ - public: - virtual ~JNL_IConnection() { } - virtual void connect(const char *hostname, int port)=0; - virtual void connect(SOCKET sock, struct sockaddr_in *loc=NULL)=0; // used by the listen object, usually not needed by users. - - virtual void run(int max_send_bytes=-1, int max_recv_bytes=-1, int *bytes_sent=NULL, int *bytes_rcvd=NULL)=0; - virtual int get_state()=0; - virtual const char *get_errstr()=0; - - virtual void close(int quick=0)=0; - virtual void flush_send(void)=0; - - virtual int send_bytes_in_queue(void)=0; - virtual int send_bytes_available(void)=0; - virtual int send(const void *data, int length)=0; // returns -1 if not enough room - virtual int send_bytes(const void *data, int length)=0; - virtual int send_string(const char *line)=0; // returns -1 if not enough room - - virtual int recv_bytes_available(void)=0; - virtual int recv_bytes(void *data, int maxlength)=0; // returns actual bytes read - virtual int recv_lines_available(void)=0; - virtual int recv_line(char *line, int maxlength)=0; // returns 0 if the line was terminated with a \r or \n, 1 if not. - // (i.e. if you specify maxlength=10, and the line is 12 bytes long - // it will return 1. or if there is no \r or \n and that's all the data - // the connection has.) - virtual int recv_get_linelen()=0; // length in bytes for current line (including \r and/or \n), or 0 if no newline in buffer - virtual int peek_bytes(void *data, int maxlength)=0; // returns bytes peeked - - virtual unsigned int get_interface(void)=0; // this returns the interface the connection is on - virtual unsigned int get_remote(void)=0; // remote host ip. - virtual short get_remote_port(void)=0; // this returns the remote port of connection - - virtual void set_interface(int useInterface)=0; // call before connect if needed - virtual SOCKET get_socket() const = 0; - }; - - #define JNL_Connection_PARENTDEF : public JNL_IConnection -#else - #define JNL_IConnection JNL_Connection - #define JNL_Connection_PARENTDEF -#endif - -#ifndef JNL_NO_IMPLEMENTATION - -class JNL_Connection JNL_Connection_PARENTDEF -{ - public: - typedef enum - { - STATE_ERROR, - STATE_NOCONNECTION, - STATE_RESOLVING, - STATE_CONNECTING, - STATE_CONNECTED, - STATE_CLOSING, - STATE_CLOSED - } state; - - JNL_Connection(JNL_IAsyncDNS *dns=JNL_CONNECTION_AUTODNS, int sendbufsize=8192, int recvbufsize=8192); - ~JNL_Connection(); - - void connect(const char *hostname, int port); - void connect(SOCKET sock, struct sockaddr_in *loc=NULL); // used by the listen object, usually not needed by users. - - void run(int max_send_bytes=-1, int max_recv_bytes=-1, int *bytes_sent=NULL, int *bytes_rcvd=NULL); - int get_state() { return m_state; } - const char *get_errstr() { return m_errorstr; } - - void close(int quick=0); - void flush_send(void) { m_send_len=m_send_pos=0; } - - int send_bytes_in_queue(void); - int send_bytes_available(void); - int send(const void *data, int length); // returns -1 if not enough room - inline int send_bytes(const void *data, int length) { return send(data, length); } - int send_string(const char *line); // returns -1 if not enough room - - - int recv_bytes_available(void); - int recv_bytes(void *data, int maxlength); // returns actual bytes read - int recv_lines_available(void); - int recv_line(char *line, int maxlength); // returns 0 if the line was terminated with a \r or \n, 1 if not. - // (i.e. if you specify maxlength=10, and the line is 12 bytes long - // it will return 1. or if there is no \r or \n and that's all the data - // the connection has.) - int recv_get_linelen(); // length in bytes for current line (including \r and/or \n), or 0 if no newline in buffer - int peek_bytes(void *data, int maxlength); // returns bytes peeked - - unsigned int get_interface(void); // this returns the interface the connection is on - unsigned int get_remote(void); // remote host ip. - short get_remote_port(void); // this returns the remote port of connection - - void set_interface(int useInterface); // call before connect if needed - - SOCKET get_socket() const { return m_socket; } - - protected: - SOCKET m_socket; - short m_remote_port; - WDL_TypedBuf m_recv_buffer; - WDL_TypedBuf m_send_buffer; - - int m_recv_pos; - int m_recv_len; - int m_send_pos; - int m_send_len; - - int m_localinterfacereq; - struct sockaddr_in *m_saddr; - char m_host[256]; - - JNL_IAsyncDNS *m_dns; - int m_dns_owned; - - state m_state; - const char *m_errorstr; - - int getbfromrecv(int pos, int remove); // used by recv_line* - -}; - -#endif - -#endif // _Connection_H_ diff --git a/oversampling/WDL/jnetlib/httpget.cpp b/oversampling/WDL/jnetlib/httpget.cpp deleted file mode 100644 index 8ad1c29..0000000 --- a/oversampling/WDL/jnetlib/httpget.cpp +++ /dev/null @@ -1,446 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2008 Cockos Inc -** Copyright (C) 2000-2001 Nullsoft, Inc. -** Author: Justin Frankel -** File: httpget.cpp - JNL HTTP GET implementation -** License: see jnetlib.h -*/ - -#include "netinc.h" -#include "util.h" -#include "httpget.h" - - -JNL_HTTPGet::JNL_HTTPGet(JNL_IAsyncDNS *dns, int recvbufsize, char *proxy) -{ - m_recvbufsize=recvbufsize; - m_dns=dns; - m_con=NULL; - m_http_proxylpinfo=0; - m_http_proxyhost=0; - m_http_proxyport=0; - if (proxy && *proxy) - { - char *p=(char*)malloc(strlen(proxy)+1); - if (p) - { - char *r=NULL; - strcpy(p,proxy); - do_parse_url(p,&m_http_proxyhost,&m_http_proxyport,&r,&m_http_proxylpinfo); - free(r); - free(p); - } - } - m_sendheaders=NULL; - reinit(); -} - -void JNL_HTTPGet::reinit() -{ - m_errstr=0; - m_recvheaders=NULL; - m_recvheaders_size=0; - m_http_state=0; - m_http_port=0; - m_http_url=0; - m_reply=0; - m_http_host=m_http_lpinfo=m_http_request=NULL; -} - -void JNL_HTTPGet::deinit() -{ - delete m_con; m_con = NULL; - free(m_recvheaders); - - free(m_http_url); - free(m_http_host); - free(m_http_lpinfo); - free(m_http_request); - free(m_errstr); - free(m_reply); - reinit(); -} - -JNL_HTTPGet::~JNL_HTTPGet() -{ - deinit(); - free(m_sendheaders); - free(m_http_proxylpinfo); - free(m_http_proxyhost); - -} - - -void JNL_HTTPGet::addheader(const char *header) -{ - if (strstr(header,"\r") || strstr(header,"\n")) return; - if (!m_sendheaders) - { - m_sendheaders=(char*)malloc(strlen(header)+3); - if (m_sendheaders) - { - strcpy(m_sendheaders,header); - strcat(m_sendheaders,"\r\n"); - } - } - else - { - char *t=(char*)malloc(strlen(header)+strlen(m_sendheaders)+1+2); - if (t) - { - strcpy(t,m_sendheaders); - strcat(t,header); - strcat(t,"\r\n"); - free(m_sendheaders); - m_sendheaders=t; - } - } -} - -void JNL_HTTPGet::do_encode_mimestr(char *in, char *out) -{ - char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - int shift = 0; - int accum = 0; - - while (*in) - { - if (*in) - { - accum <<= 8; - shift += 8; - accum |= *in++; - } - while ( shift >= 6 ) - { - shift -= 6; - *out++ = alphabet[(accum >> shift) & 0x3F]; - } - } - if (shift == 4) - { - *out++ = alphabet[(accum & 0xF)<<2]; - *out++='='; - } - else if (shift == 2) - { - *out++ = alphabet[(accum & 0x3)<<4]; - *out++='='; - *out++='='; - } - - *out++=0; -} - - -void JNL_HTTPGet::connect(const char *url, int ver, const char *requestmethod) -{ - deinit(); - m_http_url=(char*)malloc(strlen(url)+1); - strcpy(m_http_url,url); - do_parse_url(m_http_url,&m_http_host,&m_http_port,&m_http_request, &m_http_lpinfo); - strcpy(m_http_url,url); - if (!m_http_host || !m_http_host[0] || !m_http_port) - { - m_http_state=-1; - seterrstr("invalid URL"); - return; - } - - size_t sendbufferlen=0; - - if (!m_http_proxyhost || !m_http_proxyhost[0]) - { - sendbufferlen += strlen(requestmethod)+1 /* GET */ + strlen(m_http_request) + 9 /* HTTP/1.0 */ + 2; - } - else - { - sendbufferlen += strlen(requestmethod)+1 /* GET */ + strlen(m_http_url) + 9 /* HTTP/1.0 */ + 2; - if (m_http_proxylpinfo&&m_http_proxylpinfo[0]) - { - sendbufferlen+=58+strlen(m_http_proxylpinfo)*2; // being safe here - } - } - sendbufferlen += 5 /* Host: */ + strlen(m_http_host) + 2; - - if (m_http_lpinfo&&m_http_lpinfo[0]) - { - sendbufferlen+=46+strlen(m_http_lpinfo)*2; // being safe here - } - - if (m_sendheaders) sendbufferlen+=strlen(m_sendheaders); - - char *str=(char*)malloc(sendbufferlen+1024); - if (!str) - { - seterrstr("error allocating memory"); - m_http_state=-1; - } - - if (!m_http_proxyhost || !m_http_proxyhost[0]) - { - sprintf(str,"%s %s HTTP/1.%d\r\n",requestmethod,m_http_request,ver%10); - } - else - { - sprintf(str,"%s %s HTTP/1.%d\r\n",requestmethod, m_http_url,ver%10); - } - - sprintf(str+strlen(str),"Host:%s\r\n",m_http_host); - - if (m_http_lpinfo&&m_http_lpinfo[0]) - { - strcat(str,"Authorization: Basic "); - do_encode_mimestr(m_http_lpinfo,str+strlen(str)); - strcat(str,"\r\n"); - } - if (m_http_proxylpinfo&&m_http_proxylpinfo[0]) - { - strcat(str,"Proxy-Authorization: Basic "); - do_encode_mimestr(m_http_proxylpinfo,str+strlen(str)); - strcat(str,"\r\n"); - } - - if (m_sendheaders) strcat(str,m_sendheaders); - strcat(str,"\r\n"); - - int a=m_recvbufsize; - if (a < 4096) a=4096; - m_con=new JNL_Connection(m_dns,(int)strlen(str)+4,a); - if (m_con) - { - if (!m_http_proxyhost || !m_http_proxyhost[0]) - { - m_con->connect(m_http_host,m_http_port); - } - else - { - m_con->connect(m_http_proxyhost,m_http_proxyport); - } - m_con->send_string(str); - } - else - { - m_http_state=-1; - seterrstr("could not create connection object"); - } - free(str); - -} - -void JNL_HTTPGet::do_parse_url(char *url, char **host, int *port, char **req, char **lp) -{ - char *p,*np; - free(*host); *host=0; - free(*req); *req=0; - free(*lp); *lp=0; - - if (strstr(url,"://")) np=p=strstr(url,"://")+3; - else np=p=url; - while (*np != '/' && *np) np++; - if (*np) - { - *req=(char*)malloc(strlen(np)+1); - if (*req) strcpy(*req,np); - *np++=0; - } - else - { - *req=(char*)malloc(2); - if (*req) strcpy(*req,"/"); - } - - np=p; - while (*np != '@' && *np) np++; - if (*np) - { - *np++=0; - *lp=(char*)malloc(strlen(p)+1); - if (*lp) strcpy(*lp,p); - p=np; - } - else - { - *lp=(char*)malloc(1); - if (*lp) strcpy(*lp,""); - } - np=p; - while (*np != ':' && *np) np++; - if (*np) - { - *np++=0; - *port=atoi(np); - } else *port=80; - *host=(char*)malloc(strlen(p)+1); - if (*host) strcpy(*host,p); -} - - -const char *JNL_HTTPGet::getallheaders() -{ // double null terminated, null delimited list - if (m_recvheaders) return m_recvheaders; - else return "\0\0"; -} - -const char *JNL_HTTPGet::getheader(const char *headername) -{ - if (!headername || !m_recvheaders) return NULL; - - size_t headername_len = strlen(headername); - if (headername_len<1) return NULL; - - if (headername[headername_len - 1] == ':') headername_len--; - - const char *p=m_recvheaders; - while (*p) - { - if (!strnicmp(headername,p,headername_len) && p[headername_len] == ':') - { - p += headername_len + 1; - while (*p == ' ') p++; - return p; - } - p+=strlen(p)+1; - } - return NULL; -} - -int JNL_HTTPGet::run() -{ - int cnt=0; - if (m_http_state==-1||!m_con) return -1; // error - - -run_again: - m_con->run(); - - if (m_con->get_state()==JNL_Connection::STATE_ERROR) - { - seterrstr(m_con->get_errstr()); - return -1; - } - if (m_con->get_state()==JNL_Connection::STATE_CLOSED) return 1; - - if (m_http_state==0) // connected, waiting for reply - { - if (m_con->recv_lines_available()>0) - { - char buf[4096]; - m_con->recv_line(buf,4095); - buf[4095]=0; - m_reply=(char*)malloc(strlen(buf)+1); - strcpy(m_reply,buf); - - int code=getreplycode(); - if (code == 200 || code==206) m_http_state=2; // proceed to read headers normally - else if (code == 301 || code==302) - { - m_http_state=1; // redirect city - } - else - { - seterrstr(buf); - m_http_state=-1; - return -1; - } - cnt=0; - } - else if (!cnt++) goto run_again; - } - if (m_http_state == 1) // redirect - { - while (m_con->recv_lines_available() > 0) - { - char buf[4096]; - m_con->recv_line(buf,4096); - if (!buf[0]) - { - m_http_state=-1; - return -1; - } - if (!strnicmp(buf,"Location:",9)) - { - const char *p=buf+9; while (*p== ' ') p++; - if (*p) - { - connect(p); - return 0; - } - } - } - } - if (m_http_state==2) - { - if (!cnt++ && m_con->recv_lines_available() < 1) goto run_again; - while (m_con->recv_lines_available() > 0) - { - char buf[4096]; - m_con->recv_line(buf,4096); - if (!buf[0]) { m_http_state=3; break; } - if (!m_recvheaders) - { - m_recvheaders_size=(int)strlen(buf)+1; - m_recvheaders=(char*)malloc(m_recvheaders_size+1); - if (m_recvheaders) - { - strcpy(m_recvheaders,buf); - m_recvheaders[m_recvheaders_size]=0; - } - } - else - { - int oldsize=m_recvheaders_size; - m_recvheaders_size+=(int)strlen(buf)+1; - char *n=(char*)malloc(m_recvheaders_size+1); - if (n) - { - memcpy(n,m_recvheaders,oldsize); - strcpy(n+oldsize,buf); - n[m_recvheaders_size]=0; - free(m_recvheaders); - m_recvheaders=n; - } - } - } - } - if (m_http_state==3) - { - } - return 0; -} - -int JNL_HTTPGet::get_status() // returns 0 if connecting, 1 if reading headers, - // 2 if reading content, -1 if error. -{ - if (m_http_state < 0) return -1; - if (m_http_state < 2) return 0; - if (m_http_state == 2) return 1; - if (m_http_state == 3) return 2; - return -1; -} - -int JNL_HTTPGet::getreplycode()// returns 0 if none yet, otherwise returns http reply code. -{ - if (!m_reply) return 0; - char *p=m_reply; - while (*p && *p != ' ') p++; // skip over HTTP/x.x - if (!*p) return 0; - return atoi(++p); -} - -int JNL_HTTPGet::bytes_available() -{ - if (m_con && m_http_state==3) return m_con->recv_bytes_available(); - return 0; -} -int JNL_HTTPGet::get_bytes(char *buf, int len) -{ - if (m_con && m_http_state==3) return m_con->recv_bytes(buf,len); - return 0; -} -int JNL_HTTPGet::peek_bytes(char *buf, int len) -{ - if (m_con && m_http_state==3) return m_con->peek_bytes(buf,len); - return 0; -} diff --git a/oversampling/WDL/jnetlib/httpget.h b/oversampling/WDL/jnetlib/httpget.h deleted file mode 100644 index 43b565d..0000000 --- a/oversampling/WDL/jnetlib/httpget.h +++ /dev/null @@ -1,152 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2008 Cockos Inc -** Copyright (C) 2000-2001 Nullsoft, Inc. -** Author: Justin Frankel -** File: httpget.h - JNL interface for doing HTTP GETs. -** License: see jnetlib.h -** -** Usage: -** 1. Create a JNL_HTTPGet object, optionally specifying a JNL_AsyncDNS -** object to use (or NULL for none, or JNL_CONNECTION_AUTODNS for auto), -** and the receive buffer size, and a string specifying proxy (or NULL -** for none). See note on proxy string below. -** 2. call addheader() to add whatever headers you want. It is recommended to -** add at least the following two: -** addheader("User-Agent:MyApp (Mozilla)"); -*/// addheader("Accept:*/*"); -/* ( the comment weirdness is there so I Can do the star-slash :) -** 3. Call connect() with the URL you wish to GET (see URL string note below) -** 4. Call run() once in a while, checking to see if it returns -1 -** (if it does return -1, call geterrorstr() to see what the error is). -** (if it returns 1, no big deal, the connection has closed). -** 5. While you're at it, you can call bytes_available() to see if any data -** from the http stream is available, or getheader() to see if any headers -** are available, or getreply() to see the HTTP reply, or getallheaders() -** to get a double null terminated, null delimited list of headers returned. -** 6. If you want to read from the stream, call get_bytes (which returns how much -** was actually read). -** 7. content_length() is a helper function that uses getheader() to check the -** content-length header. -** 8. Delete ye' ol' object when done. -** -** Proxy String: -** should be in the format of host:port, or user@host:port, or -** user:password@host:port. if port is not specified, 80 is assumed. -** URL String: -** should be in the format of http://user:pass@host:port/requestwhatever -** note that user, pass, port, and /requestwhatever are all optional :) -** note that also, http:// is really not important. if you do poo:// -** or even leave out the http:// altogether, it will still work. -*/ - -#ifndef _HTTPGET_H_ -#define _HTTPGET_H_ - -#include "connection.h" - -#ifndef JNL_NO_DEFINE_INTERFACES - class JNL_IHTTPGet - { - public: - - virtual ~JNL_IHTTPGet() { } - - virtual void addheader(const char *header)=0; - - virtual void connect(const char *url, int ver=0, const char *requestmethod="GET")=0; - - virtual int run()=0; // returns: 0 if all is OK. -1 if error (call geterrorstr()). 1 if connection closed. - - virtual int get_status()=0; // returns 0 if connecting, 1 if reading headers, - // 2 if reading content, -1 if error. - - virtual const char *getallheaders()=0; // double null terminated, null delimited list - virtual const char *getheader(const char *headername)=0; - virtual const char *getreply()=0; - virtual int getreplycode()=0; // returns 0 if none yet, otherwise returns http reply code. - - virtual const char *geterrorstr()=0; - - virtual int bytes_available()=0; - virtual int get_bytes(char *buf, int len)=0; - virtual int peek_bytes(char *buf, int len)=0; - - virtual int content_length()=0; - - virtual JNL_IConnection *get_con()=0; - }; - #define JNL_HTTPGet_PARENTDEF : public JNL_IHTTPGet -#else - #define JNL_IHTTPGet JNL_HTTPGet - #define JNL_HTTPGet_PARENTDEF -#endif - -#ifndef JNL_NO_IMPLEMENTATION - -class JNL_HTTPGet JNL_HTTPGet_PARENTDEF -{ - public: - JNL_HTTPGet(JNL_IAsyncDNS *dns=JNL_CONNECTION_AUTODNS, int recvbufsize=16384, char *proxy=NULL); - ~JNL_HTTPGet(); - - void addheader(const char *header); - - void connect(const char *url, int ver=0, const char *requestmethod="GET"); - - int run(); // returns: 0 if all is OK. -1 if error (call geterrorstr()). 1 if connection closed. - - int get_status(); // returns 0 if connecting, 1 if reading headers, - // 2 if reading content, -1 if error. - - const char *getallheaders(); // double null terminated, null delimited list - const char *getheader(const char *headername); - const char *getreply() { return m_reply; } - int getreplycode(); // returns 0 if none yet, otherwise returns http reply code. - - const char *geterrorstr() { return m_errstr;} - - int bytes_available(); - int get_bytes(char *buf, int len); - int peek_bytes(char *buf, int len); - - int content_length() { const char *p=getheader("content-length"); if (p) return atoi(p); return 0; } - - JNL_IConnection *get_con() { return m_con; } - - - - static void do_parse_url(char *url, char **host, int *port, char **req, char **lp); // url gets thrashed, and host/req/lp are freed/allocated - static void do_encode_mimestr(char *in, char *out); - - protected: - void reinit(); - void deinit(); - void seterrstr(const char *str) { if (m_errstr) free(m_errstr); m_errstr=(char*)malloc(strlen(str)+1); strcpy(m_errstr,str); } - - JNL_IAsyncDNS *m_dns; - JNL_IConnection *m_con; - int m_recvbufsize; - - int m_http_state; - - int m_http_port; - char *m_http_url; - char *m_http_host; - char *m_http_lpinfo; - char *m_http_request; - - char *m_http_proxylpinfo; - char *m_http_proxyhost; - int m_http_proxyport; - - char *m_sendheaders; - char *m_recvheaders; - int m_recvheaders_size; - char *m_reply; - - char *m_errstr; -}; -#endif - -#endif // _HTTPGET_H_ diff --git a/oversampling/WDL/jnetlib/httpserv.cpp b/oversampling/WDL/jnetlib/httpserv.cpp deleted file mode 100644 index 7d5acb3..0000000 --- a/oversampling/WDL/jnetlib/httpserv.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2008 Cockos Inc -** Copyright (C) 2001 Nullsoft, Inc. -** Author: Justin Frankel -** File: httpserv.cpp - JNL HTTP GET/POST serving implementation -** License: see jnetlib.h -** -** This class just manages the http reply/sending, not where the data -** comes from, etc. -*/ - -#include "netinc.h" -#include "util.h" - -#include "httpserv.h" - -/* - States for m_state: - -1 error (connection closed, etc) - 0 not read request yet. - 1 reading headers - 2 headers read, have not sent reply - 3 sent reply - 4 closed -*/ - -JNL_HTTPServ::JNL_HTTPServ(JNL_IConnection *con) -{ - m_usechunk = false; - m_keepalive = true; - m_con=con; - m_state=0; - m_reply_ready=0; -} - -JNL_HTTPServ::~JNL_HTTPServ() -{ - delete m_con; -} - -void JNL_HTTPServ::write_bytes(const char *bytes, int length) -{ - if (m_usechunk) - { - char buf[32]; - sprintf(buf,"%x\r\n",length); - m_con->send_string(buf); - } - m_con->send(bytes,length); - if (m_usechunk) m_con->send_string("\r\n"); -} - -bool JNL_HTTPServ::want_keepalive_reset() -{ - if (m_state >= 2 && m_con && m_con->get_state() == JNL_Connection::STATE_CONNECTED) - { - m_usechunk = false; - m_state = 0; - m_reply_ready = 0; - m_errstr.Set(""); - m_reply_headers.Set(""); - m_reply_string.Set(""); - m_recvheaders.Clear(); - m_recv_request.Resize(0,false); - return true; - } - return false; -} - -int JNL_HTTPServ::run() -{ // returns: < 0 on error, 0 on connection close, 1 if reading request, 2 if reply not sent, 3 if reply sent, sending data. - int cnt=0; -run_again: - m_con->run(); - if (m_con->get_state()==JNL_Connection::STATE_ERROR) - { - seterrstr(m_con->get_errstr()); - return -1; - } - if (m_con->get_state()==JNL_Connection::STATE_CLOSED) return 4; - - if (m_state == 0) - { - int reqlen = m_con->recv_get_linelen(); - if (reqlen>0) - { - if (!m_recv_request.ResizeOK(reqlen+2,false)) - { - seterrstr("malloc fail"); - return -1; - } - - reqlen = m_con->recv_bytes(m_recv_request.Get(),reqlen); - char *buf = m_recv_request.Get() + reqlen; - *buf=0; - while (buf > m_recv_request.Get() && (buf[-1] == '\r' || buf[-1]=='\n')) *--buf=0; - const char *endptr = buf; - while (buf >= m_recv_request.Get() && *buf != ' ') buf--; - - if (buf < m_recv_request.Get() || strncmp(buf+1,"HTTP",4) || strncmp(m_recv_request.Get(),"GET ",4)) - { - seterrstr("malformed HTTP request"); - m_state=-1; - buf=m_recv_request.Get(); - buf[0]=buf[1]=0; - } - else - { - if (endptr[-1]=='0') m_keepalive = false; // old http 1.0 - m_state=1; - cnt=0; - buf[0]=buf[1]=0; - - buf=strstr(m_recv_request.Get(),"?"); - if (buf) - { - *buf++=0; // change &'s into 0s now. - char *t=buf; - int stat=1; - while (*t) - { - if (*t == '&' && !stat) { stat=1; *t=0; } - else stat=0; - t++; - } - } - } - } - else if (!cnt++) goto run_again; - } - if (m_state == 1) - { - if (!cnt++ && m_con->recv_lines_available()<1) goto run_again; - while (m_con->recv_get_linelen()>0) - { - char buf[4096]; - buf[0]=0; - m_con->recv_line(buf,4096); - if (!buf[0]) { m_state=2; break; } - - if (!strnicmp(buf,"Connection:",11)) - { - const char *p=buf+11; - while (*p && strnicmp(p,"close",5)) p++; - if (*p) m_keepalive = false; - } - - if (m_recvheaders.GetSize()) m_recvheaders.Add(NULL,-1); // remove doublenull - m_recvheaders.Add(buf,strlen(buf)+1); - m_recvheaders.Add("",1); - } - } - if (m_state == 2) - { - if (m_reply_ready) - { - // send reply - m_con->send_string((char*)(m_reply_string.GetLength()?m_reply_string.Get():"HTTP/1.1 200 OK")); - m_con->send_string("\r\n"); - if (m_reply_headers.GetLength()) m_con->send_string(m_reply_headers.Get()); - if (m_keepalive) - { - const char *p = m_reply_headers.Get(); - bool had_cl=false,had_con=false; - while (*p && (!had_cl || !had_con)) - { - if (!strnicmp(p,"Content-Length:",15)) had_cl=true; - else if (!strnicmp(p,"Connection:",11)) had_con=true; - - while (*p && *p != '\r' && *p != '\n') p++; - while (*p == '\r' || *p == '\n') p++; - } - if (!had_con) m_con->send_string("Connection: keep-alive\r\n"); - if (!had_cl) - { - m_usechunk = true; - m_con->send_string("Transfer-Encoding: chunked\r\n"); - } - } - m_con->send_string("\r\n"); - m_state=3; - } - } - if (m_state == 3) - { - // nothing. - } - - return m_state; -} - -const char *JNL_HTTPServ::get_request_file() -{ - // file portion of http request - char *t=m_recv_request.Get(); - if (!t) return NULL; - - while (*t != ' ' && *t) t++; - if (!*t) return NULL; - while (*t == ' ') t++; - return t; -} - -const char *JNL_HTTPServ::get_request_parm(const char *parmname) // parameter portion (after ?) -{ - const char *t=m_recv_request.Get(); - if (!t) return NULL; - - while (*t) t++; - t++; - while (*t) - { - while (*t == '&') t++; - if (!strnicmp(t,parmname,strlen(parmname)) && t[strlen(parmname)] == '=') - { - return t+strlen(parmname)+1; - } - t+=strlen(t)+1; - } - return NULL; -} - -const char *JNL_HTTPServ::getheader(const char *headername) -{ - const char *ret=NULL; - if (strlen(headername)<1||!m_recvheaders.Available()) return NULL; - const char *p=m_recvheaders.Get(); - const int hdrlen = (int) strlen(headername); - while (*p) - { - if (!strnicmp(headername,p,hdrlen) && p[hdrlen] == ':') - { - ret=p+hdrlen+1; - while (*ret == ' ') ret++; - break; - } - while (*p) p++; - p++; - } - return ret; -} - -void JNL_HTTPServ::set_reply_string(const char *reply_string) // should be HTTP/1.1 OK or the like -{ - m_reply_string.Set(reply_string); -} - -void JNL_HTTPServ::set_reply_size(int sz) // if set, size will also add keep-alive etc -{ - if (sz>=0) - { - char buf[512]; - sprintf(buf,"Content-length: %d",sz); - set_reply_header(buf); - } -} -void JNL_HTTPServ::set_reply_header(const char *header) // "Connection: close" for example -{ - m_reply_headers.Append(header); - m_reply_headers.Append("\r\n"); -} diff --git a/oversampling/WDL/jnetlib/httpserv.h b/oversampling/WDL/jnetlib/httpserv.h deleted file mode 100644 index 9329478..0000000 --- a/oversampling/WDL/jnetlib/httpserv.h +++ /dev/null @@ -1,118 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2008 Cockos Inc -** Copyright (C) 2001 Nullsoft, Inc. -** Author: Justin Frankel -** File: httpserv.h - JNL interface for doing HTTP GET/POST serving. -** License: see jnetlib.h -** This class just manages the http reply/sending, not where the data -** comes from, etc. -** for a mini-web server see webserver.h -*/ - -#ifndef _HTTPSERV_H_ -#define _HTTPSERV_H_ - -#include "connection.h" - -#include "../wdlstring.h" -#include "../queue.h" - -#ifndef JNL_NO_DEFINE_INTERFACES -class JNL_IHTTPServ -{ - public: - - virtual ~JNL_IHTTPServ() { } - - virtual int run()=0; // returns: < 0 on error, 0 on request not read yet, 1 if reading headers, 2 if reply not sent, 3 if reply sent, sending data. 4 on connection closed. - - virtual const char *geterrorstr()=0; - - // use these when state returned by run() is 2 - virtual const char *get_request_file()=0; // file portion of http request - virtual const char *get_request_parm(const char *parmname)=0; // parameter portion (after ?) - virtual const char *getallheaders()=0; - virtual const char *getheader(const char *headername)=0; - - virtual void set_reply_string(const char *reply_string)=0; // should be HTTP/1.1 OK or the like - virtual void set_reply_header(const char *header)=0; // i.e. "content-size: 12345" - virtual void set_reply_size(int sz)=0; // if set, size will also add keep-alive etc - - virtual void send_reply()=0; - - ////////// sending data /////////////// - virtual int bytes_inqueue()=0; - virtual int bytes_cansend()=0; - virtual void write_bytes(const char *bytes, int length)=0; - - virtual void close(int quick)=0; - - virtual JNL_IConnection *get_con()=0; - virtual JNL_IConnection *steal_con()=0; - virtual bool want_keepalive_reset()=0; - - virtual bool canKeepAlive()=0; -}; - #define JNL_HTTPServ_PARENTDEF : public JNL_IHTTPServ -#else - #define JNL_IHTTPServ JNL_HTTPServ - #define JNL_HTTPServ_PARENTDEF -#endif - - -#ifndef JNL_NO_IMPLEMENTATION - -class JNL_HTTPServ JNL_HTTPServ_PARENTDEF -{ - public: - JNL_HTTPServ(JNL_IConnection *con); - ~JNL_HTTPServ(); - - int run(); // returns: < 0 on error, 0 on request not read yet, 1 if reading headers, 2 if reply not sent, 3 if reply sent, sending data. 4 on connection closed. - - const char *geterrorstr() { return m_errstr.Get()[0] ? m_errstr.Get() : NULL; } - - // use these when state returned by run() is 2 - const char *get_request_file(); // file portion of http request - const char *get_request_parm(const char *parmname); // parameter portion (after ?) - const char *getallheaders() { return m_recvheaders.Get(); } // double null terminated, null delimited list - const char *getheader(const char *headername); - - void set_reply_string(const char *reply_string); // should be HTTP/1.1 OK or the like - void set_reply_header(const char *header); // i.e. "content-size: 12345" - void set_reply_size(int sz); // if set, size will also add keep-alive etc - - void send_reply() { m_reply_ready=1; } // send reply, state will advance to 3. - - ////////// sending data /////////////// - int bytes_inqueue() { if (m_state == 3 || m_state == -1 || m_state ==4) return m_con->send_bytes_in_queue(); else return 0; } - int bytes_cansend() { if (m_state == 3) return m_con->send_bytes_available() - (m_usechunk?16:0); else return 0; } - void write_bytes(const char *bytes, int length); - - void close(int quick) { m_con->close(quick); m_state=4; } - - JNL_IConnection *get_con() { return m_con; } - JNL_IConnection *steal_con() { JNL_IConnection *ret= m_con; m_con=0; return ret; } - bool want_keepalive_reset(); - - bool canKeepAlive() { return m_keepalive; } - - protected: - void seterrstr(const char *str) { m_errstr.Set(str); } - - int m_reply_ready; - int m_state; - bool m_keepalive, m_usechunk; - - WDL_FastString m_errstr; - WDL_FastString m_reply_headers; - WDL_FastString m_reply_string; - WDL_TypedQueue m_recvheaders; - WDL_TypedBuf m_recv_request; // either double-null terminated, or may contain parameters after first null. - JNL_IConnection *m_con; -}; - -#endif - -#endif // _HTTPSERV_H_ diff --git a/oversampling/WDL/jnetlib/irc_util.h b/oversampling/WDL/jnetlib/irc_util.h deleted file mode 100644 index 2bec8e1..0000000 --- a/oversampling/WDL/jnetlib/irc_util.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _WDL_JNL_IRC_UTIL_H_ -#define _WDL_JNL_IRC_UTIL_H_ - -#include "netinc.h" - -static void FormatIRCMessage(char *bufout, const char *fmt, ...) // bufout should be 1024 bytes to be safe -{ - va_list arglist; - va_start(arglist, fmt); - #ifdef _WIN32 - int written = _vsnprintf(bufout, 1024-16, fmt, arglist); - #else - int written = vsnprintf(bufout, 1024-16, fmt, arglist); - #endif - if (written < 0) written = 0; - else if (written > 510) written=510; - bufout[written]=0; - va_end(arglist); - - strcat(bufout,"\r\n"); -} - - -static void ParseIRCMessage(char *buf, char **prefix, char *tokens[16], int *tokensvalid, bool *lastHadColon) // destroys buf -{ - if (lastHadColon) *lastHadColon=false; - *tokensvalid=0; - if (prefix) *prefix=NULL; - if (*buf==':') - { - if (prefix) *prefix=buf; - while (*buf && *buf != ' ') buf++; - if (*buf==' ') - { - *buf++=0; - while (*buf== ' ') buf++; - } - } - - while (*buf && *tokensvalid < 16) - { - tokens[(*tokensvalid)++] = buf[0] == ':' ? buf+1 : buf; - if (buf[0] == ':' || *tokensvalid == 16) - { - if (buf[0] == ':' && lastHadColon) *lastHadColon=true; - break; - } - - // skip over parameter - while (*buf && *buf != ' ') buf++; - if (*buf == ' ') - { - *buf++=0; - while (*buf== ' ') buf++; - } - - } -} -#endif \ No newline at end of file diff --git a/oversampling/WDL/jnetlib/jnetlib.h b/oversampling/WDL/jnetlib/jnetlib.h deleted file mode 100644 index a159e9e..0000000 --- a/oversampling/WDL/jnetlib/jnetlib.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2008 Cockos Inc -** Copyright (C) 2000-2003 Nullsoft, Inc. -** Author: Justin Frankel -** File: jnetlib.h - JNL main include file (not really necessary). -** -** For documentation, look at the following files: -** Generic network initialization: netinc.h -** DNS: asyncdns.h -** TCP connections: connection.h -** HTTP GET connections: httpget.h -** TCP listen: listen.h -** -** license: -** -** This software is provided 'as-is', without any express or implied -** warranty. In no event will the authors be held liable for any damages -** arising from the use of this software. -** -** Permission is granted to anyone to use this software for any purpose, -** including commercial applications, and to alter it and redistribute it -** freely, subject to the following restrictions: -** -** 1. The origin of this software must not be misrepresented; you must not -** claim that you wrote the original software. If you use this software -** in a product, an acknowledgment in the product documentation would be -** appreciated but is not required. -** 2. Altered source versions must be plainly marked as such, and must not be -** misrepresented as being the original software. -** 3. This notice may not be removed or altered from any source distribution. -** -*/ - -#ifndef _JNETLIB_H_ -#define _JNETLIB_H_ - -#include "netinc.h" -#include "util.h" - -#include "asyncdns.h" -#include "connection.h" -#include "httpget.h" -#include "httpserv.h" -#include "listen.h" - -#endif//_JNETLIB_H_ diff --git a/oversampling/WDL/jnetlib/listen.cpp b/oversampling/WDL/jnetlib/listen.cpp deleted file mode 100644 index 683bce2..0000000 --- a/oversampling/WDL/jnetlib/listen.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2008 Cockos Inc -** Copyright (C) 2000-2001 Nullsoft, Inc. -** Author: Justin Frankel -** File: listen.cpp - JNL TCP listen implementation -** License: see jnetlib.h -*/ - -#include "netinc.h" -#include "util.h" -#include "listen.h" - -JNL_Listen::JNL_Listen(short port, unsigned int which_interface) -{ - m_port=port; - m_socket = ::socket(AF_INET,SOCK_STREAM,0); - if (m_socket == INVALID_SOCKET) - { - } - else - { - struct sockaddr_in sin; - SET_SOCK_DEFAULTS(m_socket); - SET_SOCK_BLOCK(m_socket,0); - int bflag = 1; - setsockopt(m_socket, SOL_SOCKET, SO_REUSEADDR, (char*)&bflag, sizeof(bflag)); - memset((char *) &sin, 0,sizeof(sin)); - sin.sin_family = AF_INET; - sin.sin_port = htons( (short) port ); - sin.sin_addr.s_addr = which_interface?which_interface:INADDR_ANY; - if (::bind(m_socket,(struct sockaddr *)&sin,sizeof(sin))) - { - shutdown(m_socket, SHUT_RDWR); - closesocket(m_socket); - m_socket=INVALID_SOCKET; - } - else - { - if (::listen(m_socket,8)==-1) - { - shutdown(m_socket, SHUT_RDWR); - closesocket(m_socket); - m_socket=INVALID_SOCKET; - } - } - } -} - -JNL_Listen::~JNL_Listen() -{ - if (m_socket!=INVALID_SOCKET) - { - shutdown(m_socket, SHUT_RDWR); - closesocket(m_socket); - } -} - -JNL_IConnection *JNL_Listen::get_connect(int sendbufsize, int recvbufsize) -{ - if (m_socket == INVALID_SOCKET) - { - return NULL; - } - struct sockaddr_in saddr; - socklen_t length = sizeof(struct sockaddr_in); - SOCKET s = accept(m_socket, (struct sockaddr *) &saddr, &length); - if (s != INVALID_SOCKET) - { - JNL_IConnection *c=new JNL_Connection(NULL,sendbufsize, recvbufsize); - c->connect(s,&saddr); - return c; - } - return NULL; -} diff --git a/oversampling/WDL/jnetlib/listen.h b/oversampling/WDL/jnetlib/listen.h deleted file mode 100644 index 0301fed..0000000 --- a/oversampling/WDL/jnetlib/listen.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2008 Cockos Inc -** Copyright (C) 2000-2001 Nullsoft, Inc. -** Author: Justin Frankel -** File: listen.h - JNL interface for opening a TCP listen -** License: see jnetlib.h -** -** Usage: -** 1. create a JNL_Listen object with the port and (optionally) the interface -** to listen on. -** 2. call get_connect() to get any new connections (optionally specifying what -** buffer sizes the connection should be created with) -** 3. check is_error() to see if an error has occured -** 4. call port() if you forget what port the listener is on. -** -*/ - -#ifndef _LISTEN_H_ -#define _LISTEN_H_ -#include "connection.h" - -#ifndef JNL_NO_DEFINE_INTERFACES - - class JNL_IListen - { - public: - - virtual ~JNL_IListen() { } - - virtual JNL_IConnection *get_connect(int sendbufsize=8192, int recvbufsize=8192)=0; - virtual short port(void)=0; - virtual int is_error(void)=0; - }; - - #define JNL_Listen_PARENTDEF : public JNL_IListen -#else - #define JNL_IListen JNL_Listen - #define JNL_Listen_PARENTDEF -#endif - -#ifndef JNL_NO_IMPLEMENTATION - - -class JNL_Listen JNL_Listen_PARENTDEF -{ - public: - JNL_Listen(short port, unsigned int which_interface=0); - ~JNL_Listen(); - - JNL_IConnection *get_connect(int sendbufsize=8192, int recvbufsize=8192); - short port(void) { return m_port; } - int is_error(void) { return (m_socket == INVALID_SOCKET); } - - protected: - SOCKET m_socket; - short m_port; -}; - -#endif - -#endif //_LISTEN_H_ diff --git a/oversampling/WDL/jnetlib/netinc.h b/oversampling/WDL/jnetlib/netinc.h deleted file mode 100644 index 0fc7d8e..0000000 --- a/oversampling/WDL/jnetlib/netinc.h +++ /dev/null @@ -1,90 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2000-2001 Nullsoft, Inc. -** Author: Justin Frankel -** File: netinc.h - network includes and portability defines (used internally) -** License: see jnetlib.h -*/ - -#ifndef _NETINC_H_ -#define _NETINC_H_ - -#ifdef _WIN32 - -#include -#include -#include -#define JNL_ERRNO (WSAGetLastError()) -#define SET_SOCK_BLOCK(s,block) { unsigned long __i=block?0:1; ioctlsocket(s,FIONBIO,&__i); } -#define SET_SOCK_DEFAULTS(s) do { } while (0) -#define JNL_EWOULDBLOCK WSAEWOULDBLOCK -#define JNL_EINPROGRESS WSAEWOULDBLOCK -#define JNL_ENOTCONN WSAENOTCONN - -typedef int socklen_t; - -#else - -#ifndef THREAD_SAFE -#define THREAD_SAFE -#endif -#ifndef _REENTRANT -#define _REENTRANT -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#define JNL_ERRNO ((errno)|0) -#define closesocket(s) close(s) -#define SET_SOCK_BLOCK(s,block) { int __flags; if ((__flags = fcntl(s, F_GETFL, 0)) != -1) { if (!block) __flags |= O_NONBLOCK; else __flags &= ~O_NONBLOCK; fcntl(s, F_SETFL, __flags); } } -#ifdef __APPLE__ -#define SET_SOCK_DEFAULTS(s) do { int __flags = 1; setsockopt((s), SOL_SOCKET, SO_NOSIGPIPE, &__flags, sizeof(__flags)); } while (0) -#else -#define SET_SOCK_DEFAULTS(s) do { } while (0) -#endif - -typedef int SOCKET; -#define INVALID_SOCKET (-1) - -#define JNL_EWOULDBLOCK EWOULDBLOCK -#define JNL_EINPROGRESS EINPROGRESS -#define JNL_ENOTCONN ENOTCONN - -#ifndef stricmp -#define stricmp(x,y) strcasecmp(x,y) -#endif -#ifndef strnicmp -#define strnicmp(x,y,z) strncasecmp(x,y,z) -#endif - -#endif // !_WIN32 - -#ifndef INADDR_NONE -#define INADDR_NONE 0xffffffff -#endif - -#ifndef INADDR_ANY -#define INADDR_ANY 0 -#endif - -#ifndef SHUT_RDWR -#define SHUT_RDWR 2 -#endif - -#endif //_NETINC_H_ diff --git a/oversampling/WDL/jnetlib/test.cpp b/oversampling/WDL/jnetlib/test.cpp deleted file mode 100644 index 619c20f..0000000 --- a/oversampling/WDL/jnetlib/test.cpp +++ /dev/null @@ -1,555 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2000-2001 Nullsoft, Inc. -** Author: Justin Frankel -** File: test.cpp - JNL test code -** License: see jnetlib.h -*/ - -#ifdef _WIN32 -#include -#else -#define Sleep(x) usleep((x)*1000) -#endif -#include -#include "jnetlib.h" - - -#define TEST_ASYNCDNS 0 -#define TEST_CONNECTION 0 -#define TEST_LISTEN 0 -#define TEST_TELNET_GATEWAY 0 -#define TEST_HTTPGET 0 -#define TEST_WEBSERVER 1 - -#define TEST_UDP 0 //udp is not done yet tho :) - - - -#if (TEST_WEBSERVER) -#include "webserver.h" - - -class MemPageGenerator : public IPageGenerator -{ - public: - virtual ~MemPageGenerator() { free(m_buf); } - MemPageGenerator(char *buf, int buf_len=-1) { m_buf=buf; if (buf_len >= 0) m_buf_size=buf_len; else m_buf_size=strlen(buf); m_buf_pos=0; } - virtual int GetData(char *buf, int size) // return 0 when done - { - int a=m_buf_size-m_buf_pos; - if (a < size) size=a; - memcpy(buf,m_buf+m_buf_pos,size); - m_buf_pos+=size; - return size; - } - - private: - char *m_buf; - int m_buf_size; - int m_buf_pos; -}; - -class wwwServer : public WebServerBaseClass -{ -public: - wwwServer() { } - virtual IPageGenerator *onConnection(JNL_HTTPServ *serv, int port) - { - serv->set_reply_header("Server:jnetlib_test/0.0"); - if (!strcmp(serv->get_request_file(),"/")) - { - serv->set_reply_string("HTTP/1.1 200 OK"); - serv->set_reply_header("Content-Type:text/html"); - serv->send_reply(); - - return new MemPageGenerator(strdup("Test Web Server v0.0")); - } - else - { - serv->set_reply_string("HTTP/1.1 404 NOT FOUND"); - serv->send_reply(); - return 0; // no data - } - } -}; - - -int main(int argc, char **argv) -{ - JNL::open_socketlib(); - { - wwwServer foo; - foo.addListenPort(8080); - while (1) - { - foo.run(); - Sleep(10); - } - } - JNL::close_socketlib(); - return 0; -} - -#endif - - -#if (TEST_HTTPGET) -int main(int argc, char **argv) -{ - - if (argc != 3) - { - printf("usage: httpget \n"); - exit(0); - } - - JNL_HTTPGet get; - JNL::open_socketlib(); - - get.addheader("User-Agent:PooHead (Mozilla)"); - get.addheader("Accept:*/*"); - get.connect(argv[1]); - - FILE *fp=fopen(argv[2],"wb"); - int headerstate=0; - int has_printed_headers=0; - int has_printed_reply=0; - while (1) - { - int st=get.run(); - if (st<0) - { - printf("HTTPGet error: %s\n",get.geterrorstr()); - break; - } - if (get.get_status()>0) - { - if (!has_printed_reply) - { - has_printed_reply=1; - printf("reply: %s (code:%d)\n",get.getreply(),get.getreplycode()); - } - if (get.get_status()==2) - { - int len; - if (!has_printed_headers) - { - has_printed_headers=1; - printf("headers:\n"); - char *p=get.getallheaders(); - while (p&&*p) - { - printf("%s\n",p); - p+=strlen(p)+1; - } - } - while ((len=get.bytes_available()) > 0) - { - char buf[4096]; - if (len > 4096) len=4096; - len=get.get_bytes(buf,len); - if (len>0)fwrite(buf,len,1,fp); - } - } - } - if (st==1) // 1 means connection closed - { - printf("HTTPGet done!\n"); - break; - } - } - if (fp) fclose(fp); - JNL::close_socketlib(); - return 0; -} - -#endif - - -#if (TEST_TELNET_GATEWAY) - -int main() -{ - JNL_Connection *cons[32]={0,}; - JNL_Connection *outcons[32]={0,}; - char textpos[32][256]; - int n_cons=0; - int states[32]={0,}; - - JNL::open_socketlib(); - JNL_AsyncDNS dns; - JNL_Listen l(23); - while (!l.is_error()) - { - Sleep(30); - if (n_cons<32) - { - JNL_Connection *con=l.get_connect(); - if (con) - { - int x; - for (x = 0; x < 32; x ++) - { - if (!cons[x]) - { - cons[x]=con; - outcons[x]=0; - states[x]=0; - n_cons++; - break; - } - } - } - } - int x; - for (x = 0; x < 32; x ++) - { - if (cons[x]) - { - cons[x]->run(); - if (outcons[x]) outcons[x]->run(); - - if (cons[x]->get_state() == JNL_Connection::STATE_ERROR || cons[x]->get_state()==JNL_Connection::STATE_CLOSED || - (outcons[x] && (cons[x]->get_state() == JNL_Connection::STATE_ERROR || cons[x]->get_state()==JNL_Connection::STATE_CLOSED))) - { - delete cons[x]; - if (outcons[x]) delete outcons[x]; - outcons[x]=0; - cons[x]=0; - states[x]=0; - n_cons--; - } - else - { - if (states[x]==0) - { - cons[x]->send_string("\r\nwelcome "); - states[x]++; - } - if (states[x]==1) - { - char hoststr[256]; - int ret=dns.reverse(cons[x]->get_remote(),hoststr); - if (ret==0) - { - cons[x]->send_string(hoststr); - cons[x]->send_string(". host: "); - states[x]++; - textpos[x][0]=0; - } - if (ret==-1) - { - JNL::addr_to_ipstr(cons[x]->get_remote(),hoststr,256); - cons[x]->send_string(hoststr); - cons[x]->send_string(". host: "); - states[x]++; - textpos[x][0]=0; - } - } - if (states[x]==2) - { - char b; - while (cons[x]->recv_bytes(&b,1) && states[x]==2) - { - if (b == '\r' || b == '\n') - { - if (strlen(textpos[x])) - { - char *p=strstr(textpos[x],":"); - int port=23; - if (p) - { - *p++=0; - if (atoi(p)) port=atoi(p); - } - outcons[x]=new JNL_Connection(&dns); - outcons[x]->connect(textpos[x],port); - - char str[512]; - sprintf(str,"\r\nconnecting to port %d of %s\r\n",port,textpos[x]); - cons[x]->send_string(str); - states[x]++; - } - else states[x]=0; - } - else if (b == '\b') - { - if (textpos[x][0]) - { - textpos[x][strlen(textpos[x])-1]=0; - cons[x]->send_string("\b \b"); - } - } - else - { - textpos[x][strlen(textpos[x])+1]=0; - textpos[x][strlen(textpos[x])]=b; - cons[x]->send(&b,1); - } - } - } - if (states[x]==3) - { - char buf[1024]; - outcons[x]->run(); - int l=cons[x]->recv_bytes(buf,1024); - if (l) outcons[x]->send(buf,l); - l=outcons[x]->recv_bytes(buf,1024); - if (l) cons[x]->send(buf,l); - } - } - } - } - } - JNL::close_socketlib(); - return 0; -} - - -#endif - -#if (TEST_LISTEN) - -int main() -{ - JNL_HTTPServ *cons[32]={0,}; - char *contents[32]={0,}; - int n_cons=0; - - JNL::open_socketlib(); - JNL_AsyncDNS dns; - JNL_Listen l(8000); - while (!l.is_error()) - { - Sleep(100); - if (n_cons<32) - { - JNL_Connection *con=l.get_connect(); - if (con) - { - int x; - for (x = 0; x < 32; x ++) - { - if (!cons[x]) - { - cons[x]=new JNL_HTTPServ(con); - n_cons++; - break; - } - } - } - } - int x; - for (x = 0; x < 32; x ++) - { - if (cons[x]) - { - int r=cons[x]->run(); - if (r == -1 || r == 4) - { - if (r == -1) printf("error:%s\n",cons[x]->geterrorstr()); - delete cons[x]; - cons[x]=0; - free(contents[x]); - contents[x]=0; - n_cons--; - } - if (r == 2) - { - cons[x]->set_reply_string("HTTP/1.1 200 OK"); - cons[x]->set_reply_header("Content-type:text/plain"); - cons[x]->set_reply_header("Server:JNLTest"); - contents[x]=(char*)malloc(32768); - char *poop=cons[x]->get_request_parm("poop"); - sprintf(contents[x],"test, sucka\r\n%s\r\n\r\n",poop?poop:"no poop"); - cons[x]->send_reply(); - } - if (r == 3) - { - if (contents[x] && cons[x]->bytes_cansend()>strlen(contents[x])) - { - cons[x]->write_bytes(contents[x],strlen(contents[x])); - cons[x]->close(0); - free(contents[x]); - contents[x]=0; - } - } - } - } - } - JNL::close_socketlib(); - return 0; -} - -#endif - -#if (TEST_CONNECTION) -int main() -{ - JNL::open_socketlib(); - { - JNL_AsyncDNS dns; - JNL_Connection con(&dns); - con.connect("localhost",80); - FILE *fp=fopen("c:\\hi.raw","wb"); - while (1) - { - con.run(); - if (con.get_state()==JNL_Connection::STATE_ERROR) - { - printf("error %s\n",con.get_errstr()); - } - if (con.get_state()==JNL_Connection::STATE_CLOSED) - { - } - while (con.recv_bytes_available()>0) - { - char buf[1024]; - int a=con.recv_bytes_available(); - if (a > 1024) a=1024; - con.recv_bytes(buf,a); - fwrite(buf,a,1,fp); - } - } - if (fp) fclose(fp); - } - JNL::close_socketlib(); - return 0; -} -#endif - -#if (TEST_ASYNCDNS) -int main() -{ - JNL_AsyncDNS dns; - char *hosts[]= - { - "www.firehose.net", - "gnutella.com", - "207.48.52.200", - "www.slashdot.org", - "www.google.com", - "www.winamp.com", - "www.genekan.com", - }; - char *reverses[]= - { - "64.0.160.98", - "205.188.245.120", - "207.48.52.222", - "207.48.52.200", - }; - int n=0; - int pass=0; - while (n\n"); - printf("mode: 0 for client, 1 for server\n"); - exit(0); - } - int mode=atoi(argv[1]); - - JNL::open_socketlib(); - - switch(mode) - { - case 0: // client mode - { - JNL_AsyncDNS dns; - JNL_UDPConnection con(0,&dns); // 0 chooses a random port - con.setpeer("localhost",80); - printf("Sending message...\n"); - con.send("blah",5); - while (1) - { - con.run(); - if (con.get_state()==JNL_UDPConnection::STATE_ERROR) - { - printf("error %s\n",con.get_errstr()); - } - while (con.recv_bytes_available()>0) - { - char buf[1024]; - int s=min(con.recv_bytes_available(), sizeof(buf)); - con.recv_bytes(buf,s); - printf("received message: %s\n", buf); - } - } - } - break; - case 1: // server (listening) mode - { - JNL_UDPConnection con(80); - printf("Waiting for messages...\n"); - while(1) - { - con.run(); - if (con.get_state()==JNL_UDPConnection::STATE_ERROR) - { - printf("error %s\n",con.get_errstr()); - } - while (con.recv_bytes_available()>0) - { - char buf[1024]; - int s=min(con.recv_bytes_available(), sizeof(buf)); - con.recv_bytes(buf,s); - printf("message received: %s. Replying...\n", buf); - // reply on the addr:port from sender - struct sockaddr from; - con.get_last_recv_msg_addr(&from); - con.setpeer(&from); - con.send("blorp",6); - } - } - } - break; - } - - JNL::close_socketlib(); - return 0; -} -#endif diff --git a/oversampling/WDL/jnetlib/testbnc.cpp b/oversampling/WDL/jnetlib/testbnc.cpp deleted file mode 100644 index f7019a7..0000000 --- a/oversampling/WDL/jnetlib/testbnc.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2000-2001 Nullsoft, Inc. -** Author: Justin Frankel -** File: testbnc.cpp - JNL network bounce test code -** License: see jnetlib.h -*/ - -#ifdef _WIN32 -#include -#else -#define Sleep(x) usleep((x)*1000) -#endif -#include -#include "jnetlib.h" - - -int main(int argc, char *argv[]) -{ - JNL_Connection *cons[32]={0,}; - JNL_Connection *outcons[32]={0,}; - int n_cons=0; - - if (argc != 4 || !atoi(argv[1]) || !atoi(argv[3]) || !argv[2][0]) - { - printf("usage: redir localport host remoteport\n"); - exit(1); - } - - JNL::open_socketlib(); - JNL_AsyncDNS dns; - JNL_Listen l((short)atoi(argv[1])); - printf("running...\n"); - while (!l.is_error()) - { - Sleep(10); - if (n_cons<32) - { - JNL_Connection *con=l.get_connect(); - if (con) - { - int x; - for (x = 0; x < 32; x ++) - { - if (!cons[x]) - { - outcons[x]=new JNL_Connection(); - outcons[x]->connect(argv[2],atoi(argv[3])); - cons[x]=con; - char host[256]; - JNL::addr_to_ipstr(cons[x]->get_remote(),host,sizeof(host)); - n_cons++; - printf("Connection %d (%s) opened (%d).\n",x,host,n_cons); - break; - } - } - } - } - int x; - for (x = 0; x < 32; x ++) - { - if (cons[x]) - { - cons[x]->run(); - outcons[x]->run(); - - int cerr=(cons[x]->get_state() == JNL_Connection::STATE_ERROR || cons[x]->get_state()==JNL_Connection::STATE_CLOSED); - int oerr=(outcons[x]->get_state() == JNL_Connection::STATE_ERROR || outcons[x]->get_state()==JNL_Connection::STATE_CLOSED); - - if ((!outcons[x]->send_bytes_in_queue() && !cons[x]->recv_bytes_available() && cerr) || - (!cons[x]->send_bytes_in_queue() && !outcons[x]->recv_bytes_available() && oerr) || - (cerr && oerr)) - { - char host[256]; - JNL::addr_to_ipstr(cons[x]->get_remote(),host,sizeof(host)); - delete cons[x]; - delete outcons[x]; - outcons[x]=0; - cons[x]=0; - n_cons--; - printf("Connection %d (%s) closed (%d)\n",x,host,n_cons); - } - else - { - char buf[4096]; - int l; - l=outcons[x]->send_bytes_available(); - if (l > 4096) l=4096; - if (l) l=cons[x]->recv_bytes(buf,l); - if (l) outcons[x]->send(buf,l); - - l=cons[x]->send_bytes_available(); - if (l > 4096) l=4096; - if (l) l=outcons[x]->recv_bytes(buf,l); - if (l) cons[x]->send(buf,l); - } - } - } - } - JNL::close_socketlib(); - return 0; -} diff --git a/oversampling/WDL/jnetlib/util.cpp b/oversampling/WDL/jnetlib/util.cpp deleted file mode 100644 index fedd911..0000000 --- a/oversampling/WDL/jnetlib/util.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2000-2001 Nullsoft, Inc. -** Author: Justin Frankel -** File: util.cpp - JNL implementation of basic network utilities -** License: see jnetlib.h -*/ - -#include "netinc.h" - -#include "util.h" -#include "../wdlcstring.h" - -int JNL::open_socketlib() -{ -#ifdef _WIN32 - WSADATA wsaData; - if (WSAStartup(MAKEWORD(1, 1), &wsaData)) return 1; -#endif - return 0; -} -void JNL::close_socketlib() -{ -#ifdef _WIN32 - WSACleanup(); -#endif -} -unsigned int JNL::ipstr_to_addr(const char *cp) -{ - return ::inet_addr(cp); -} - -void JNL::addr_to_ipstr(unsigned int addr, char *host, int maxhostlen) -{ - struct in_addr a; a.s_addr=addr; - char *p=::inet_ntoa(a); - lstrcpyn_safe(host,p?p:"",maxhostlen); -} diff --git a/oversampling/WDL/jnetlib/util.h b/oversampling/WDL/jnetlib/util.h deleted file mode 100644 index a817970..0000000 --- a/oversampling/WDL/jnetlib/util.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2000-2001 Nullsoft, Inc. -** Author: Justin Frankel -** File: util.h - JNL interface for basic network utilities -** License: see jnetlib.h -** -** routines you may be interested in: -** JNL::open_socketlib(); -** opens the socket library. Call this once before using any network -** code. If you create a new thread, call this again. Only really an -** issue for Win32 support, but use it anyway for portability/ -** -** JNL::close_Socketlib(); -** closes the socketlib. Call this when you're done with the network, -** after all your JNetLib objects have been destroyed. -** -** unsigned int JNL::ipstr_to_addr(const char *cp); -** gives you the integer representation of a ip address in dotted -** decimal form. -** -** JNL::addr_to_ipstr(unsigned int addr, char *host, int maxhostlen); -** gives you the dotted decimal notation of an integer ip address. -** -*/ - -#ifndef _UTIL_H_ -#define _UTIL_H_ - -class JNL -{ - public: - static int open_socketlib(); - static void close_socketlib(); - static unsigned int ipstr_to_addr(const char *cp); - static void addr_to_ipstr(unsigned int addr, char *host, int maxhostlen); -}; - -#endif //_UTIL_H_ diff --git a/oversampling/WDL/jnetlib/webserver.cpp b/oversampling/WDL/jnetlib/webserver.cpp deleted file mode 100644 index e593d65..0000000 --- a/oversampling/WDL/jnetlib/webserver.cpp +++ /dev/null @@ -1,318 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2000-2003 Nullsoft, Inc. -** Author: Justin Frankel -** File: webserver.cpp - Generic simple webserver baseclass -** License: see jnetlib.h -** see test.cpp for an example of how to use this class -*/ - -#ifdef _WIN32 -#include -#endif -#include "jnetlib.h" -#include "webserver.h" - - -WebServerBaseClass::~WebServerBaseClass() -{ - m_connections.Empty(true); - m_listeners.Empty(true); -} - -WebServerBaseClass::WebServerBaseClass() -{ - m_listener_rot=0; - m_timeout_s=30; - m_max_con=100; -} - - -void WebServerBaseClass::setMaxConnections(int max_con) -{ - m_max_con=max_con; -} - -void WebServerBaseClass::setRequestTimeout(int timeout_s) -{ - m_timeout_s=timeout_s; -} - -int WebServerBaseClass::addListenPort(int port, unsigned int which_interface) -{ - removeListenPort(port); - - JNL_IListen *p=new JNL_Listen(port,which_interface); - m_listeners.Add(p); - if (p->is_error()) return -1; - return 0; -} - -void WebServerBaseClass::removeListenPort(int port) -{ - int x; - for (x = 0; x < m_listeners.GetSize(); x ++) - { - JNL_IListen *p=m_listeners.Get(x); - if (p->port()==port) - { - m_listeners.Delete(x,true); - break; - } - } -} - -void WebServerBaseClass::removeListenIdx(int idx) -{ - m_listeners.Delete(idx,true); -} - -int WebServerBaseClass::getListenPort(int idx, int *err) -{ - JNL_IListen *p=m_listeners.Get(idx); - if (p) - { - if (err) *err=p->is_error(); - return p->port(); - } - return 0; -} - -void WebServerBaseClass::attachConnection(JNL_IConnection *con, int port) -{ - m_connections.Add(new WS_conInst(con,port)); -} - -void WebServerBaseClass::run(void) -{ - int nl; - if (m_connections.GetSize() < m_max_con && (nl=m_listeners.GetSize())) - { - JNL_IListen *l=m_listeners.Get(m_listener_rot++ % nl); - JNL_IConnection *c=l->get_connect(); - if (c) - { -// char buf[512]; -// sprintf(buf,"got new connection at %.3f",GetTickCount()/1000.0); -// OutputDebugString(buf); - attachConnection(c,l->port()); - } - } - int x; - for (x = 0; x < m_connections.GetSize(); x ++) - { - WS_conInst *ci = m_connections.Get(x); - int rv=0; - for (int y = 0; y < 4 && !(rv=run_connection(ci)); y ++); // keep latency down - - if (rv==-1) - { - if (ci->m_serv.want_keepalive_reset()) - { - time(&ci->m_connect_time); - delete ci->m_pagegen; - ci->m_pagegen=0; - continue; - } - } - - if (rv>0) - { - m_connections.Delete(x--,true); - } - } -} - -int WebServerBaseClass::run_connection(WS_conInst *con) -{ - int s=con->m_serv.run(); - if (s < 0) - { - // m_serv.geterrorstr() - return 1; - } - if (s < 2) - { - // return 1 if we timed out - return time(NULL)-con->m_connect_time > m_timeout_s; - } - if (s < 3) - { - con->m_pagegen=onConnection(&con->m_serv,con->m_port); - return 0; - } - if (s < 4) - { - if (!con->m_pagegen) - { - if (con->m_serv.canKeepAlive()) return -1; - - return !con->m_serv.bytes_inqueue(); - } - char buf[16384]; - int l=con->m_serv.bytes_cansend(); - if (l > 0) - { - if (l > (int)sizeof(buf)) l=(int)sizeof(buf); - l=con->m_pagegen->GetData(buf,l); - if (l < (con->m_pagegen->IsNonBlocking() ? 0 : 1)) // if nonblocking, this is l < 0, otherwise it's l<1 - { - if (con->m_serv.canKeepAlive()) - { - con->m_serv.write_bytes("",0); - return -1; - } - return !con->m_serv.bytes_inqueue(); - } - if (l>0) - con->m_serv.write_bytes(buf,l); - } - return l > 0 ? 0 : -2; // -2 = no more data to send, but all is well - } - if (con->m_serv.canKeepAlive()) return -1; - return 1; // we're done by this point -} - - - -void WebServerBaseClass::url_encode(const char *in, char *out, int max_out) -{ - while (*in && max_out > 4) - { - if ((*in >= 'A' && *in <= 'Z')|| - (*in >= 'a' && *in <= 'z')|| - (*in >= '0' && *in <= '9')|| *in == '.' || *in == '_' || *in == '-') - { - *out++=*in++; - max_out--; - } - else - { - int i=*in++; - *out++ = '%'; - int b=(i>>4)&15; - if (b < 10) *out++='0'+b; - else *out++='A'+b-10; - b=i&15; - if (b < 10) *out++='0'+b; - else *out++='A'+b-10; - max_out-=3; - } - } - *out=0; -} - - -void WebServerBaseClass::url_decode(const char *in, char *out, int maxlen) -{ - while (*in && maxlen>1) - { - if (*in == '+') - { - in++; - *out++=' '; - } - else if (*in == '%' && in[1] != '%' && in[1]) - { - int a=0; - int b=0; - for ( b = 0; b < 2; b ++) - { - int r=in[1+b]; - if (r>='0'&&r<='9') r-='0'; - else if (r>='a'&&r<='f') r-='a'-10; - else if (r>='A'&&r<='F') r-='A'-10; - else break; - a*=16; - a+=r; - } - if (b < 2) *out++=*in++; - else { *out++=a; in += 3;} - } - else *out++=*in++; - maxlen--; - } - *out=0; -} - - - - - -void WebServerBaseClass::base64decode(const char *src, char *dest, int destsize) -{ - int accum=0; - int nbits=0; - while (*src) - { - int x=0; - char c=*src++; - if (c >= 'A' && c <= 'Z') x=c-'A'; - else if (c >= 'a' && c <= 'z') x=c-'a' + 26; - else if (c >= '0' && c <= '9') x=c-'0' + 52; - else if (c == '+') x=62; - else if (c == '/') x=63; - else break; - - accum <<= 6; - accum |= x; - nbits += 6; - - while (nbits >= 8) - { - if (--destsize<=0) break; - nbits-=8; - *dest++ = (char)((accum>>nbits)&0xff); - } - - } - *dest=0; -} - -void WebServerBaseClass::base64encode(const char *in, char *out) -{ - char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - int shift = 0; - int accum = 0; - - while (*in) - { - if (*in) - { - accum <<= 8; - shift += 8; - accum |= *in++; - } - while ( shift >= 6 ) - { - shift -= 6; - *out++ = alphabet[(accum >> shift) & 0x3F]; - } - } - if (shift == 4) - { - *out++ = alphabet[(accum & 0xF)<<2]; - *out++='='; - } - else if (shift == 2) - { - *out++ = alphabet[(accum & 0x3)<<4]; - *out++='='; - *out++='='; - } - - *out++=0; -} - -int WebServerBaseClass::parseAuth(const char *auth_header, char *out, int out_len)//returns 0 on unknown auth, 1 on basic -{ - const char *authstr=auth_header; - *out=0; - if (!auth_header || !*auth_header) return 0; - while (*authstr == ' ') authstr++; - if (strnicmp(authstr,"basic ",6)) return 0; - authstr+=6; - while (*authstr == ' ') authstr++; - base64decode(authstr,out,out_len); - return 1; -} diff --git a/oversampling/WDL/jnetlib/webserver.h b/oversampling/WDL/jnetlib/webserver.h deleted file mode 100644 index 9254c46..0000000 --- a/oversampling/WDL/jnetlib/webserver.h +++ /dev/null @@ -1,243 +0,0 @@ -/* -** JNetLib -** Copyright (C) 2008-2014 Cockos Inc -** Copyright (C) 2003 Nullsoft, Inc. -** Author: Justin Frankel -** File: webserver.h - Generic simple webserver baseclass -** License: see jnetlib.h -** -** You can derive your object from WebServerBaseClass to do simple web serving. Example: - - class wwwServer : public WebServerBaseClass - { - public: - wwwServer() { } - virtual IPageGenerator *onConnection(JNL_HTTPServ *serv, int port) - { - serv->set_reply_header("Server:jnetlib_test/0.0"); - if (!strcmp(serv->get_request_file(),"/")) - { - serv->set_reply_string("HTTP/1.1 200 OK"); - serv->set_reply_header("Content-Type:text/html"); - serv->send_reply(); - - return new MemPageGenerator(strdup("Test Web Server v0.0")); - } - else - { - serv->set_reply_string("HTTP/1.1 404 NOT FOUND"); - serv->send_reply(); - return 0; // no data - } - } - }; - - - wwwServer foo; - foo.addListenPort(8080); - while (1) - { - foo.run(); - Sleep(10); - } - - You will also need to derive from the IPageGenerator interface to provide a data stream, here is an - example of MemPageGenerator: - - class MemPageGenerator : public IPageGenerator - { - public: - virtual ~MemPageGenerator() { free(m_buf); } - MemPageGenerator(char *buf, int buf_len=-1) { m_buf=buf; if (buf_len >= 0) m_buf_size=buf_len; else m_buf_size=strlen(buf); m_buf_pos=0; } - virtual int GetData(char *buf, int size) // return 0 when done - { - int a=m_buf_size-m_buf_pos; - if (a < size) size=a; - memcpy(buf,m_buf+m_buf_pos,size); - m_buf_pos+=size; - return size; - } - - private: - char *m_buf; - int m_buf_size; - int m_buf_pos; - }; - - -** -*/ - - -#ifndef _JNL_WEBSERVER_H_ -#define _JNL_WEBSERVER_H_ - -#include "httpserv.h" -#include "../wdlcstring.h" -#include "../ptrlist.h" - -class IPageGenerator -{ -public: - virtual ~IPageGenerator() { }; - virtual int IsNonBlocking() { return 0; } // override this and return 1 if GetData should be allowed to return 0 - virtual int GetData(char *buf, int size)=0; // return < 0 when done (or 0 if IsNonBlocking() is 1) -}; - - -class WebServerBaseClass -{ -protected: // never create one of these directly, always derive - WebServerBaseClass(); - -public: - virtual ~WebServerBaseClass(); - - // stuff for setting limits/timeouts - void setMaxConnections(int max_con); - void setRequestTimeout(int timeout_s); - - // stuff for setting listener port - int addListenPort(int port, unsigned int which_interface=0); - int getListenPort(int idx, int *err=0); - void removeListenPort(int port); - void removeListenIdx(int idx); - - // call this a lot :) - void run(void); - - // if you want to manually attach a connection, use this: - // you need to specify the port it came in on so the web server can build - // links - void attachConnection(JNL_IConnection *con, int port); - - // derived classes need to override this one =) - virtual IPageGenerator *onConnection(JNL_HTTPServ *serv, int port)=0; - - // stats getting functions - - // these can be used externally, as well as are used by the web server - static void url_encode(const char *in, char *out, int max_out); - static void url_decode(const char *in, char *out, int maxlen); - static void base64decode(const char *src, char *dest, int destsize); - static void base64encode(const char *in, char *out); - - static int parseAuth(const char *auth_header, char *out, int out_len);//returns 0 on unknown auth, 1 on basic - - -protected: - - class WS_conInst - { - public: - WS_conInst(JNL_IConnection *c, int which_port) : m_serv(c), m_pagegen(NULL), m_port(which_port) - { - time(&m_connect_time); - } - ~WS_conInst() - { - delete m_pagegen; - } - - // these will be used by WebServerBaseClass::onConnection yay - JNL_HTTPServ m_serv; - IPageGenerator *m_pagegen; - - int m_port; // port this came in on - time_t m_connect_time; - }; - - int run_connection(WS_conInst *con); - - int m_timeout_s; - int m_max_con; - - JNL_AsyncDNS m_dns; - - WDL_PtrList m_listeners; - WDL_PtrList m_connections; - int m_listener_rot; -}; - - - -#ifdef JNETLIB_WEBSERVER_WANT_UTILS - -#include "../fileread.h" -#include "../wdlstring.h" - -class JNL_FilePageGenerator : public IPageGenerator -{ - public: - JNL_FilePageGenerator(WDL_FileRead *fr) { m_file = fr; } - virtual ~JNL_FilePageGenerator() { delete m_file; } - virtual int GetData(char *buf, int size) { return m_file ? m_file->Read(buf,size) : -1; } - - private: - - WDL_FileRead *m_file; -}; -class JNL_StringPageGenerator : public IPageGenerator -{ - public: - JNL_StringPageGenerator() { m_pos=0; } - virtual ~JNL_StringPageGenerator() { } - virtual int GetData(char *buf, int size) - { - if (size > str.GetLength() - m_pos) size=str.GetLength()-m_pos; - if (size>0) - { - memcpy(buf,str.Get()+m_pos,size); - m_pos+=size; - } - return size; - } - - WDL_FastString str; // set this before sending it off - - private: - int m_pos; -}; - -static void JNL_get_mime_type_for_file(const char *fn, char *strout, int stroutsz) -{ - const char *ext = fn; - while (*ext) ext++; - while (ext > fn && *ext != '.' && *ext != '/' && *ext != '\\') ext--; - - const char *type = "application/octet-stream"; - - if (!stricmp(ext,".jpg")) type = "image/jpeg"; - else if (!stricmp(ext,".png")) type = "image/png"; - else if (!stricmp(ext,".gif")) type = "image/gif"; - else if (!stricmp(ext,".txt")) type = "text/plain"; - else if (!strnicmp(ext,".htm",4)) type = "text/html"; - else if (!stricmp(ext,".js")) type = "application/javascript"; - else if (!stricmp(ext,".css")) type = "text/css"; - else if (!stricmp(ext,".xml")) type = "text/xml"; - else if (!stricmp(ext,".svg")) type = "image/svg+xml"; - - lstrcpyn_safe(strout,type,stroutsz); -} - -static void JNL_Format_RFC1123(time_t t, char *buf) -{ - - buf[0]=0; - static const char days[] = { "SunMonTueWedThuFriSat" }; - static const char mons[] = { "JanFebMarAprMayJunJulAugSepOctNovDec" }; - - struct tm *tm = gmtime(&t); - if (!tm) return; - memcpy(buf, days + (tm->tm_wday%7)*3, 3); - strcpy(buf+3,", "); - char *p=buf+5; - strftime(p, 64, "%d xxx %Y %H:%M:%S GMT", tm); - while (*p && *p != 'x') p++; - if (*p) memcpy(p, mons + (tm->tm_mon%12)*3, 3); -} - -#endif //JNETLIB_WEBSERVER_WANT_UTILS - - -#endif//_JNL_WEBSERVER_H_ diff --git a/oversampling/WDL/jpeglib/README b/oversampling/WDL/jpeglib/README deleted file mode 100644 index 911d0e8..0000000 --- a/oversampling/WDL/jpeglib/README +++ /dev/null @@ -1,385 +0,0 @@ -The Independent JPEG Group's JPEG software -========================================== - -README for release 6b of 27-Mar-1998 -==================================== - -This distribution contains the sixth public release of the Independent JPEG -Group's free JPEG software. You are welcome to redistribute this software and -to use it for any purpose, subject to the conditions under LEGAL ISSUES, below. - -Serious users of this software (particularly those incorporating it into -larger programs) should contact IJG at jpeg-info@uunet.uu.net to be added to -our electronic mailing list. Mailing list members are notified of updates -and have a chance to participate in technical discussions, etc. - -This software is the work of Tom Lane, Philip Gladstone, Jim Boucher, -Lee Crocker, Julian Minguillon, Luis Ortiz, George Phillips, Davide Rossi, -Guido Vollbeding, Ge' Weijers, and other members of the Independent JPEG -Group. - -IJG is not affiliated with the official ISO JPEG standards committee. - - -DOCUMENTATION ROADMAP -===================== - -This file contains the following sections: - -OVERVIEW General description of JPEG and the IJG software. -LEGAL ISSUES Copyright, lack of warranty, terms of distribution. -REFERENCES Where to learn more about JPEG. -ARCHIVE LOCATIONS Where to find newer versions of this software. -RELATED SOFTWARE Other stuff you should get. -FILE FORMAT WARS Software *not* to get. -TO DO Plans for future IJG releases. - -Other documentation files in the distribution are: - -User documentation: - install.doc How to configure and install the IJG software. - usage.doc Usage instructions for cjpeg, djpeg, jpegtran, - rdjpgcom, and wrjpgcom. - *.1 Unix-style man pages for programs (same info as usage.doc). - wizard.doc Advanced usage instructions for JPEG wizards only. - change.log Version-to-version change highlights. -Programmer and internal documentation: - libjpeg.doc How to use the JPEG library in your own programs. - example.c Sample code for calling the JPEG library. - structure.doc Overview of the JPEG library's internal structure. - filelist.doc Road map of IJG files. - coderules.doc Coding style rules --- please read if you contribute code. - -Please read at least the files install.doc and usage.doc. Useful information -can also be found in the JPEG FAQ (Frequently Asked Questions) article. See -ARCHIVE LOCATIONS below to find out where to obtain the FAQ article. - -If you want to understand how the JPEG code works, we suggest reading one or -more of the REFERENCES, then looking at the documentation files (in roughly -the order listed) before diving into the code. - - -OVERVIEW -======== - -This package contains C software to implement JPEG image compression and -decompression. JPEG (pronounced "jay-peg") is a standardized compression -method for full-color and gray-scale images. JPEG is intended for compressing -"real-world" scenes; line drawings, cartoons and other non-realistic images -are not its strong suit. JPEG is lossy, meaning that the output image is not -exactly identical to the input image. Hence you must not use JPEG if you -have to have identical output bits. However, on typical photographic images, -very good compression levels can be obtained with no visible change, and -remarkably high compression levels are possible if you can tolerate a -low-quality image. For more details, see the references, or just experiment -with various compression settings. - -This software implements JPEG baseline, extended-sequential, and progressive -compression processes. Provision is made for supporting all variants of these -processes, although some uncommon parameter settings aren't implemented yet. -For legal reasons, we are not distributing code for the arithmetic-coding -variants of JPEG; see LEGAL ISSUES. We have made no provision for supporting -the hierarchical or lossless processes defined in the standard. - -We provide a set of library routines for reading and writing JPEG image files, -plus two sample applications "cjpeg" and "djpeg", which use the library to -perform conversion between JPEG and some other popular image file formats. -The library is intended to be reused in other applications. - -In order to support file conversion and viewing software, we have included -considerable functionality beyond the bare JPEG coding/decoding capability; -for example, the color quantization modules are not strictly part of JPEG -decoding, but they are essential for output to colormapped file formats or -colormapped displays. These extra functions can be compiled out of the -library if not required for a particular application. We have also included -"jpegtran", a utility for lossless transcoding between different JPEG -processes, and "rdjpgcom" and "wrjpgcom", two simple applications for -inserting and extracting textual comments in JFIF files. - -The emphasis in designing this software has been on achieving portability and -flexibility, while also making it fast enough to be useful. In particular, -the software is not intended to be read as a tutorial on JPEG. (See the -REFERENCES section for introductory material.) Rather, it is intended to -be reliable, portable, industrial-strength code. We do not claim to have -achieved that goal in every aspect of the software, but we strive for it. - -We welcome the use of this software as a component of commercial products. -No royalty is required, but we do ask for an acknowledgement in product -documentation, as described under LEGAL ISSUES. - - -LEGAL ISSUES -============ - -In plain English: - -1. We don't promise that this software works. (But if you find any bugs, - please let us know!) -2. You can use this software for whatever you want. You don't have to pay us. -3. You may not pretend that you wrote this software. If you use it in a - program, you must acknowledge somewhere in your documentation that - you've used the IJG code. - -In legalese: - -The authors make NO WARRANTY or representation, either express or implied, -with respect to this software, its quality, accuracy, merchantability, or -fitness for a particular purpose. This software is provided "AS IS", and you, -its user, assume the entire risk as to its quality and accuracy. - -This software is copyright (C) 1991-1998, Thomas G. Lane. -All Rights Reserved except as specified below. - -Permission is hereby granted to use, copy, modify, and distribute this -software (or portions thereof) for any purpose, without fee, subject to these -conditions: -(1) If any part of the source code for this software is distributed, then this -README file must be included, with this copyright and no-warranty notice -unaltered; and any additions, deletions, or changes to the original files -must be clearly indicated in accompanying documentation. -(2) If only executable code is distributed, then the accompanying -documentation must state that "this software is based in part on the work of -the Independent JPEG Group". -(3) Permission for use of this software is granted only if the user accepts -full responsibility for any undesirable consequences; the authors accept -NO LIABILITY for damages of any kind. - -These conditions apply to any software derived from or based on the IJG code, -not just to the unmodified library. If you use our work, you ought to -acknowledge us. - -Permission is NOT granted for the use of any IJG author's name or company name -in advertising or publicity relating to this software or products derived from -it. This software may be referred to only as "the Independent JPEG Group's -software". - -We specifically permit and encourage the use of this software as the basis of -commercial products, provided that all warranty or liability claims are -assumed by the product vendor. - - -ansi2knr.c is included in this distribution by permission of L. Peter Deutsch, -sole proprietor of its copyright holder, Aladdin Enterprises of Menlo Park, CA. -ansi2knr.c is NOT covered by the above copyright and conditions, but instead -by the usual distribution terms of the Free Software Foundation; principally, -that you must include source code if you redistribute it. (See the file -ansi2knr.c for full details.) However, since ansi2knr.c is not needed as part -of any program generated from the IJG code, this does not limit you more than -the foregoing paragraphs do. - -The Unix configuration script "configure" was produced with GNU Autoconf. -It is copyright by the Free Software Foundation but is freely distributable. -The same holds for its supporting scripts (config.guess, config.sub, -ltconfig, ltmain.sh). Another support script, install-sh, is copyright -by M.I.T. but is also freely distributable. - -It appears that the arithmetic coding option of the JPEG spec is covered by -patents owned by IBM, AT&T, and Mitsubishi. Hence arithmetic coding cannot -legally be used without obtaining one or more licenses. For this reason, -support for arithmetic coding has been removed from the free JPEG software. -(Since arithmetic coding provides only a marginal gain over the unpatented -Huffman mode, it is unlikely that very many implementations will support it.) -So far as we are aware, there are no patent restrictions on the remaining -code. - -The IJG distribution formerly included code to read and write GIF files. -To avoid entanglement with the Unisys LZW patent, GIF reading support has -been removed altogether, and the GIF writer has been simplified to produce -"uncompressed GIFs". This technique does not use the LZW algorithm; the -resulting GIF files are larger than usual, but are readable by all standard -GIF decoders. - -We are required to state that - "The Graphics Interchange Format(c) is the Copyright property of - CompuServe Incorporated. GIF(sm) is a Service Mark property of - CompuServe Incorporated." - - -REFERENCES -========== - -We highly recommend reading one or more of these references before trying to -understand the innards of the JPEG software. - -The best short technical introduction to the JPEG compression algorithm is - Wallace, Gregory K. "The JPEG Still Picture Compression Standard", - Communications of the ACM, April 1991 (vol. 34 no. 4), pp. 30-44. -(Adjacent articles in that issue discuss MPEG motion picture compression, -applications of JPEG, and related topics.) If you don't have the CACM issue -handy, a PostScript file containing a revised version of Wallace's article is -available at ftp://ftp.uu.net/graphics/jpeg/wallace.ps.gz. The file (actually -a preprint for an article that appeared in IEEE Trans. Consumer Electronics) -omits the sample images that appeared in CACM, but it includes corrections -and some added material. Note: the Wallace article is copyright ACM and IEEE, -and it may not be used for commercial purposes. - -A somewhat less technical, more leisurely introduction to JPEG can be found in -"The Data Compression Book" by Mark Nelson and Jean-loup Gailly, published by -M&T Books (New York), 2nd ed. 1996, ISBN 1-55851-434-1. This book provides -good explanations and example C code for a multitude of compression methods -including JPEG. It is an excellent source if you are comfortable reading C -code but don't know much about data compression in general. The book's JPEG -sample code is far from industrial-strength, but when you are ready to look -at a full implementation, you've got one here... - -The best full description of JPEG is the textbook "JPEG Still Image Data -Compression Standard" by William B. Pennebaker and Joan L. Mitchell, published -by Van Nostrand Reinhold, 1993, ISBN 0-442-01272-1. Price US$59.95, 638 pp. -The book includes the complete text of the ISO JPEG standards (DIS 10918-1 -and draft DIS 10918-2). This is by far the most complete exposition of JPEG -in existence, and we highly recommend it. - -The JPEG standard itself is not available electronically; you must order a -paper copy through ISO or ITU. (Unless you feel a need to own a certified -official copy, we recommend buying the Pennebaker and Mitchell book instead; -it's much cheaper and includes a great deal of useful explanatory material.) -In the USA, copies of the standard may be ordered from ANSI Sales at (212) -642-4900, or from Global Engineering Documents at (800) 854-7179. (ANSI -doesn't take credit card orders, but Global does.) It's not cheap: as of -1992, ANSI was charging $95 for Part 1 and $47 for Part 2, plus 7% -shipping/handling. The standard is divided into two parts, Part 1 being the -actual specification, while Part 2 covers compliance testing methods. Part 1 -is titled "Digital Compression and Coding of Continuous-tone Still Images, -Part 1: Requirements and guidelines" and has document numbers ISO/IEC IS -10918-1, ITU-T T.81. Part 2 is titled "Digital Compression and Coding of -Continuous-tone Still Images, Part 2: Compliance testing" and has document -numbers ISO/IEC IS 10918-2, ITU-T T.83. - -Some extensions to the original JPEG standard are defined in JPEG Part 3, -a newer ISO standard numbered ISO/IEC IS 10918-3 and ITU-T T.84. IJG -currently does not support any Part 3 extensions. - -The JPEG standard does not specify all details of an interchangeable file -format. For the omitted details we follow the "JFIF" conventions, revision -1.02. A copy of the JFIF spec is available from: - Literature Department - C-Cube Microsystems, Inc. - 1778 McCarthy Blvd. - Milpitas, CA 95035 - phone (408) 944-6300, fax (408) 944-6314 -A PostScript version of this document is available by FTP at -ftp://ftp.uu.net/graphics/jpeg/jfif.ps.gz. There is also a plain text -version at ftp://ftp.uu.net/graphics/jpeg/jfif.txt.gz, but it is missing -the figures. - -The TIFF 6.0 file format specification can be obtained by FTP from -ftp://ftp.sgi.com/graphics/tiff/TIFF6.ps.gz. The JPEG incorporation scheme -found in the TIFF 6.0 spec of 3-June-92 has a number of serious problems. -IJG does not recommend use of the TIFF 6.0 design (TIFF Compression tag 6). -Instead, we recommend the JPEG design proposed by TIFF Technical Note #2 -(Compression tag 7). Copies of this Note can be obtained from ftp.sgi.com or -from ftp://ftp.uu.net/graphics/jpeg/. It is expected that the next revision -of the TIFF spec will replace the 6.0 JPEG design with the Note's design. -Although IJG's own code does not support TIFF/JPEG, the free libtiff library -uses our library to implement TIFF/JPEG per the Note. libtiff is available -from ftp://ftp.sgi.com/graphics/tiff/. - - -ARCHIVE LOCATIONS -================= - -The "official" archive site for this software is ftp.uu.net (Internet -address 192.48.96.9). The most recent released version can always be found -there in directory graphics/jpeg. This particular version will be archived -as ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz. If you don't have -direct Internet access, UUNET's archives are also available via UUCP; contact -help@uunet.uu.net for information on retrieving files that way. - -Numerous Internet sites maintain copies of the UUNET files. However, only -ftp.uu.net is guaranteed to have the latest official version. - -You can also obtain this software in DOS-compatible "zip" archive format from -the SimTel archives (ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/), or -on CompuServe in the Graphics Support forum (GO CIS:GRAPHSUP), library 12 -"JPEG Tools". Again, these versions may sometimes lag behind the ftp.uu.net -release. - -The JPEG FAQ (Frequently Asked Questions) article is a useful source of -general information about JPEG. It is updated constantly and therefore is -not included in this distribution. The FAQ is posted every two weeks to -Usenet newsgroups comp.graphics.misc, news.answers, and other groups. -It is available on the World Wide Web at http://www.faqs.org/faqs/jpeg-faq/ -and other news.answers archive sites, including the official news.answers -archive at rtfm.mit.edu: ftp://rtfm.mit.edu/pub/usenet/news.answers/jpeg-faq/. -If you don't have Web or FTP access, send e-mail to mail-server@rtfm.mit.edu -with body - send usenet/news.answers/jpeg-faq/part1 - send usenet/news.answers/jpeg-faq/part2 - - -RELATED SOFTWARE -================ - -Numerous viewing and image manipulation programs now support JPEG. (Quite a -few of them use this library to do so.) The JPEG FAQ described above lists -some of the more popular free and shareware viewers, and tells where to -obtain them on Internet. - -If you are on a Unix machine, we highly recommend Jef Poskanzer's free -PBMPLUS software, which provides many useful operations on PPM-format image -files. In particular, it can convert PPM images to and from a wide range of -other formats, thus making cjpeg/djpeg considerably more useful. The latest -version is distributed by the NetPBM group, and is available from numerous -sites, notably ftp://wuarchive.wustl.edu/graphics/graphics/packages/NetPBM/. -Unfortunately PBMPLUS/NETPBM is not nearly as portable as the IJG software is; -you are likely to have difficulty making it work on any non-Unix machine. - -A different free JPEG implementation, written by the PVRG group at Stanford, -is available from ftp://havefun.stanford.edu/pub/jpeg/. This program -is designed for research and experimentation rather than production use; -it is slower, harder to use, and less portable than the IJG code, but it -is easier to read and modify. Also, the PVRG code supports lossless JPEG, -which we do not. (On the other hand, it doesn't do progressive JPEG.) - - -FILE FORMAT WARS -================ - -Some JPEG programs produce files that are not compatible with our library. -The root of the problem is that the ISO JPEG committee failed to specify a -concrete file format. Some vendors "filled in the blanks" on their own, -creating proprietary formats that no one else could read. (For example, none -of the early commercial JPEG implementations for the Macintosh were able to -exchange compressed files.) - -The file format we have adopted is called JFIF (see REFERENCES). This format -has been agreed to by a number of major commercial JPEG vendors, and it has -become the de facto standard. JFIF is a minimal or "low end" representation. -We recommend the use of TIFF/JPEG (TIFF revision 6.0 as modified by TIFF -Technical Note #2) for "high end" applications that need to record a lot of -additional data about an image. TIFF/JPEG is fairly new and not yet widely -supported, unfortunately. - -The upcoming JPEG Part 3 standard defines a file format called SPIFF. -SPIFF is interoperable with JFIF, in the sense that most JFIF decoders should -be able to read the most common variant of SPIFF. SPIFF has some technical -advantages over JFIF, but its major claim to fame is simply that it is an -official standard rather than an informal one. At this point it is unclear -whether SPIFF will supersede JFIF or whether JFIF will remain the de-facto -standard. IJG intends to support SPIFF once the standard is frozen, but we -have not decided whether it should become our default output format or not. -(In any case, our decoder will remain capable of reading JFIF indefinitely.) - -Various proprietary file formats incorporating JPEG compression also exist. -We have little or no sympathy for the existence of these formats. Indeed, -one of the original reasons for developing this free software was to help -force convergence on common, open format standards for JPEG files. Don't -use a proprietary file format! - - -TO DO -===== - -The major thrust for v7 will probably be improvement of visual quality. -The current method for scaling the quantization tables is known not to be -very good at low Q values. We also intend to investigate block boundary -smoothing, "poor man's variable quantization", and other means of improving -quality-vs-file-size performance without sacrificing compatibility. - -In future versions, we are considering supporting some of the upcoming JPEG -Part 3 extensions --- principally, variable quantization and the SPIFF file -format. - -As always, speeding things up is of great interest. - -Please send bug reports, offers of help, etc. to jpeg-info@uunet.uu.net. diff --git a/oversampling/WDL/jpeglib/example.c b/oversampling/WDL/jpeglib/example.c deleted file mode 100644 index 7fc354f..0000000 --- a/oversampling/WDL/jpeglib/example.c +++ /dev/null @@ -1,433 +0,0 @@ -/* - * example.c - * - * This file illustrates how to use the IJG code as a subroutine library - * to read or write JPEG image files. You should look at this code in - * conjunction with the documentation file libjpeg.doc. - * - * This code will not do anything useful as-is, but it may be helpful as a - * skeleton for constructing routines that call the JPEG library. - * - * We present these routines in the same coding style used in the JPEG code - * (ANSI function definitions, etc); but you are of course free to code your - * routines in a different style if you prefer. - */ - -#include - -/* - * Include file for users of JPEG library. - * You will need to have included system headers that define at least - * the typedefs FILE and size_t before you can include jpeglib.h. - * (stdio.h is sufficient on ANSI-conforming systems.) - * You may also wish to include "jerror.h". - */ - -#include "jpeglib.h" - -/* - * is used for the optional error recovery mechanism shown in - * the second part of the example. - */ - -#include - - - -/******************** JPEG COMPRESSION SAMPLE INTERFACE *******************/ - -/* This half of the example shows how to feed data into the JPEG compressor. - * We present a minimal version that does not worry about refinements such - * as error recovery (the JPEG code will just exit() if it gets an error). - */ - - -/* - * IMAGE DATA FORMATS: - * - * The standard input image format is a rectangular array of pixels, with - * each pixel having the same number of "component" values (color channels). - * Each pixel row is an array of JSAMPLEs (which typically are unsigned chars). - * If you are working with color data, then the color values for each pixel - * must be adjacent in the row; for example, R,G,B,R,G,B,R,G,B,... for 24-bit - * RGB color. - * - * For this example, we'll assume that this data structure matches the way - * our application has stored the image in memory, so we can just pass a - * pointer to our image buffer. In particular, let's say that the image is - * RGB color and is described by: - */ - -extern JSAMPLE * image_buffer; /* Points to large array of R,G,B-order data */ -extern int image_height; /* Number of rows in image */ -extern int image_width; /* Number of columns in image */ - - -/* - * Sample routine for JPEG compression. We assume that the target file name - * and a compression quality factor are passed in. - */ - -GLOBAL(void) -write_JPEG_file (char * filename, int quality) -{ - /* This struct contains the JPEG compression parameters and pointers to - * working space (which is allocated as needed by the JPEG library). - * It is possible to have several such structures, representing multiple - * compression/decompression processes, in existence at once. We refer - * to any one struct (and its associated working data) as a "JPEG object". - */ - struct jpeg_compress_struct cinfo; - /* This struct represents a JPEG error handler. It is declared separately - * because applications often want to supply a specialized error handler - * (see the second half of this file for an example). But here we just - * take the easy way out and use the standard error handler, which will - * print a message on stderr and call exit() if compression fails. - * Note that this struct must live as long as the main JPEG parameter - * struct, to avoid dangling-pointer problems. - */ - struct jpeg_error_mgr jerr; - /* More stuff */ - FILE * outfile; /* target file */ - JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ - int row_stride; /* physical row width in image buffer */ - - /* Step 1: allocate and initialize JPEG compression object */ - - /* We have to set up the error handler first, in case the initialization - * step fails. (Unlikely, but it could happen if you are out of memory.) - * This routine fills in the contents of struct jerr, and returns jerr's - * address which we place into the link field in cinfo. - */ - cinfo.err = jpeg_std_error(&jerr); - /* Now we can initialize the JPEG compression object. */ - jpeg_create_compress(&cinfo); - - /* Step 2: specify data destination (eg, a file) */ - /* Note: steps 2 and 3 can be done in either order. */ - - /* Here we use the library-supplied code to send compressed data to a - * stdio stream. You can also write your own code to do something else. - * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that - * requires it in order to write binary files. - */ - if ((outfile = fopen(filename, "wb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - exit(1); - } - jpeg_stdio_dest(&cinfo, outfile); - - /* Step 3: set parameters for compression */ - - /* First we supply a description of the input image. - * Four fields of the cinfo struct must be filled in: - */ - cinfo.image_width = image_width; /* image width and height, in pixels */ - cinfo.image_height = image_height; - cinfo.input_components = 3; /* # of color components per pixel */ - cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ - /* Now use the library's routine to set default compression parameters. - * (You must set at least cinfo.in_color_space before calling this, - * since the defaults depend on the source color space.) - */ - jpeg_set_defaults(&cinfo); - /* Now you can set any non-default parameters you wish to. - * Here we just illustrate the use of quality (quantization table) scaling: - */ - jpeg_set_quality(&cinfo, quality, TRUE /* limit to baseline-JPEG values */); - - /* Step 4: Start compressor */ - - /* TRUE ensures that we will write a complete interchange-JPEG file. - * Pass TRUE unless you are very sure of what you're doing. - */ - jpeg_start_compress(&cinfo, TRUE); - - /* Step 5: while (scan lines remain to be written) */ - /* jpeg_write_scanlines(...); */ - - /* Here we use the library's state variable cinfo.next_scanline as the - * loop counter, so that we don't have to keep track ourselves. - * To keep things simple, we pass one scanline per call; you can pass - * more if you wish, though. - */ - row_stride = image_width * 3; /* JSAMPLEs per row in image_buffer */ - - while (cinfo.next_scanline < cinfo.image_height) { - /* jpeg_write_scanlines expects an array of pointers to scanlines. - * Here the array is only one element long, but you could pass - * more than one scanline at a time if that's more convenient. - */ - row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride]; - (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); - } - - /* Step 6: Finish compression */ - - jpeg_finish_compress(&cinfo); - /* After finish_compress, we can close the output file. */ - fclose(outfile); - - /* Step 7: release JPEG compression object */ - - /* This is an important step since it will release a good deal of memory. */ - jpeg_destroy_compress(&cinfo); - - /* And we're done! */ -} - - -/* - * SOME FINE POINTS: - * - * In the above loop, we ignored the return value of jpeg_write_scanlines, - * which is the number of scanlines actually written. We could get away - * with this because we were only relying on the value of cinfo.next_scanline, - * which will be incremented correctly. If you maintain additional loop - * variables then you should be careful to increment them properly. - * Actually, for output to a stdio stream you needn't worry, because - * then jpeg_write_scanlines will write all the lines passed (or else exit - * with a fatal error). Partial writes can only occur if you use a data - * destination module that can demand suspension of the compressor. - * (If you don't know what that's for, you don't need it.) - * - * If the compressor requires full-image buffers (for entropy-coding - * optimization or a multi-scan JPEG file), it will create temporary - * files for anything that doesn't fit within the maximum-memory setting. - * (Note that temp files are NOT needed if you use the default parameters.) - * On some systems you may need to set up a signal handler to ensure that - * temporary files are deleted if the program is interrupted. See libjpeg.doc. - * - * Scanlines MUST be supplied in top-to-bottom order if you want your JPEG - * files to be compatible with everyone else's. If you cannot readily read - * your data in that order, you'll need an intermediate array to hold the - * image. See rdtarga.c or rdbmp.c for examples of handling bottom-to-top - * source data using the JPEG code's internal virtual-array mechanisms. - */ - - - -/******************** JPEG DECOMPRESSION SAMPLE INTERFACE *******************/ - -/* This half of the example shows how to read data from the JPEG decompressor. - * It's a bit more refined than the above, in that we show: - * (a) how to modify the JPEG library's standard error-reporting behavior; - * (b) how to allocate workspace using the library's memory manager. - * - * Just to make this example a little different from the first one, we'll - * assume that we do not intend to put the whole image into an in-memory - * buffer, but to send it line-by-line someplace else. We need a one- - * scanline-high JSAMPLE array as a work buffer, and we will let the JPEG - * memory manager allocate it for us. This approach is actually quite useful - * because we don't need to remember to deallocate the buffer separately: it - * will go away automatically when the JPEG object is cleaned up. - */ - - -/* - * ERROR HANDLING: - * - * The JPEG library's standard error handler (jerror.c) is divided into - * several "methods" which you can override individually. This lets you - * adjust the behavior without duplicating a lot of code, which you might - * have to update with each future release. - * - * Our example here shows how to override the "error_exit" method so that - * control is returned to the library's caller when a fatal error occurs, - * rather than calling exit() as the standard error_exit method does. - * - * We use C's setjmp/longjmp facility to return control. This means that the - * routine which calls the JPEG library must first execute a setjmp() call to - * establish the return point. We want the replacement error_exit to do a - * longjmp(). But we need to make the setjmp buffer accessible to the - * error_exit routine. To do this, we make a private extension of the - * standard JPEG error handler object. (If we were using C++, we'd say we - * were making a subclass of the regular error handler.) - * - * Here's the extended error handler struct: - */ - -struct my_error_mgr { - struct jpeg_error_mgr pub; /* "public" fields */ - - jmp_buf setjmp_buffer; /* for return to caller */ -}; - -typedef struct my_error_mgr * my_error_ptr; - -/* - * Here's the routine that will replace the standard error_exit method: - */ - -METHODDEF(void) -my_error_exit (j_common_ptr cinfo) -{ - /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ - my_error_ptr myerr = (my_error_ptr) cinfo->err; - - /* Always display the message. */ - /* We could postpone this until after returning, if we chose. */ - (*cinfo->err->output_message) (cinfo); - - /* Return control to the setjmp point */ - longjmp(myerr->setjmp_buffer, 1); -} - - -/* - * Sample routine for JPEG decompression. We assume that the source file name - * is passed in. We want to return 1 on success, 0 on error. - */ - - -GLOBAL(int) -read_JPEG_file (char * filename) -{ - /* This struct contains the JPEG decompression parameters and pointers to - * working space (which is allocated as needed by the JPEG library). - */ - struct jpeg_decompress_struct cinfo; - /* We use our private extension JPEG error handler. - * Note that this struct must live as long as the main JPEG parameter - * struct, to avoid dangling-pointer problems. - */ - struct my_error_mgr jerr; - /* More stuff */ - FILE * infile; /* source file */ - JSAMPARRAY buffer; /* Output row buffer */ - int row_stride; /* physical row width in output buffer */ - - /* In this example we want to open the input file before doing anything else, - * so that the setjmp() error recovery below can assume the file is open. - * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that - * requires it in order to read binary files. - */ - - if ((infile = fopen(filename, "rb")) == NULL) { - fprintf(stderr, "can't open %s\n", filename); - return 0; - } - - /* Step 1: allocate and initialize JPEG decompression object */ - - /* We set up the normal JPEG error routines, then override error_exit. */ - cinfo.err = jpeg_std_error(&jerr.pub); - jerr.pub.error_exit = my_error_exit; - /* Establish the setjmp return context for my_error_exit to use. */ - if (setjmp(jerr.setjmp_buffer)) { - /* If we get here, the JPEG code has signaled an error. - * We need to clean up the JPEG object, close the input file, and return. - */ - jpeg_destroy_decompress(&cinfo); - fclose(infile); - return 0; - } - /* Now we can initialize the JPEG decompression object. */ - jpeg_create_decompress(&cinfo); - - /* Step 2: specify data source (eg, a file) */ - - jpeg_stdio_src(&cinfo, infile); - - /* Step 3: read file parameters with jpeg_read_header() */ - - (void) jpeg_read_header(&cinfo, TRUE); - /* We can ignore the return value from jpeg_read_header since - * (a) suspension is not possible with the stdio data source, and - * (b) we passed TRUE to reject a tables-only JPEG file as an error. - * See libjpeg.doc for more info. - */ - - /* Step 4: set parameters for decompression */ - - /* In this example, we don't need to change any of the defaults set by - * jpeg_read_header(), so we do nothing here. - */ - - /* Step 5: Start decompressor */ - - (void) jpeg_start_decompress(&cinfo); - /* We can ignore the return value since suspension is not possible - * with the stdio data source. - */ - - /* We may need to do some setup of our own at this point before reading - * the data. After jpeg_start_decompress() we have the correct scaled - * output image dimensions available, as well as the output colormap - * if we asked for color quantization. - * In this example, we need to make an output work buffer of the right size. - */ - /* JSAMPLEs per row in output buffer */ - row_stride = cinfo.output_width * cinfo.output_components; - /* Make a one-row-high sample array that will go away when done with image */ - buffer = (*cinfo.mem->alloc_sarray) - ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); - - /* Step 6: while (scan lines remain to be read) */ - /* jpeg_read_scanlines(...); */ - - /* Here we use the library's state variable cinfo.output_scanline as the - * loop counter, so that we don't have to keep track ourselves. - */ - while (cinfo.output_scanline < cinfo.output_height) { - /* jpeg_read_scanlines expects an array of pointers to scanlines. - * Here the array is only one element long, but you could ask for - * more than one scanline at a time if that's more convenient. - */ - (void) jpeg_read_scanlines(&cinfo, buffer, 1); - /* Assume put_scanline_someplace wants a pointer and sample count. */ - put_scanline_someplace(buffer[0], row_stride); - } - - /* Step 7: Finish decompression */ - - (void) jpeg_finish_decompress(&cinfo); - /* We can ignore the return value since suspension is not possible - * with the stdio data source. - */ - - /* Step 8: Release JPEG decompression object */ - - /* This is an important step since it will release a good deal of memory. */ - jpeg_destroy_decompress(&cinfo); - - /* After finish_decompress, we can close the input file. - * Here we postpone it until after no more JPEG errors are possible, - * so as to simplify the setjmp error logic above. (Actually, I don't - * think that jpeg_destroy can do an error exit, but why assume anything...) - */ - fclose(infile); - - /* At this point you may want to check to see whether any corrupt-data - * warnings occurred (test whether jerr.pub.num_warnings is nonzero). - */ - - /* And we're done! */ - return 1; -} - - -/* - * SOME FINE POINTS: - * - * In the above code, we ignored the return value of jpeg_read_scanlines, - * which is the number of scanlines actually read. We could get away with - * this because we asked for only one line at a time and we weren't using - * a suspending data source. See libjpeg.doc for more info. - * - * We cheated a bit by calling alloc_sarray() after jpeg_start_decompress(); - * we should have done it beforehand to ensure that the space would be - * counted against the JPEG max_memory setting. In some systems the above - * code would risk an out-of-memory error. However, in general we don't - * know the output image dimensions before jpeg_start_decompress(), unless we - * call jpeg_calc_output_dimensions(). See libjpeg.doc for more about this. - * - * Scanlines are returned in the same order as they appear in the JPEG file, - * which is standardly top-to-bottom. If you must emit data bottom-to-top, - * you can use one of the virtual arrays provided by the JPEG memory manager - * to invert the data. See wrbmp.c for an example. - * - * As with compression, some operating modes may require temporary files. - * On some systems you may need to set up a signal handler to ensure that - * temporary files are deleted if the program is interrupted. See libjpeg.doc. - */ diff --git a/oversampling/WDL/jpeglib/jcapimin.c b/oversampling/WDL/jpeglib/jcapimin.c deleted file mode 100644 index 54fb8c5..0000000 --- a/oversampling/WDL/jpeglib/jcapimin.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - * jcapimin.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the compression half - * of the JPEG library. These are the "minimum" API routines that may be - * needed in either the normal full-compression case or the transcoding-only - * case. - * - * Most of the routines intended to be called directly by an application - * are in this file or in jcapistd.c. But also see jcparam.c for - * parameter-setup helper routines, jcomapi.c for routines shared by - * compression and decompression, and jctrans.c for the transcoding case. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Initialization of a JPEG compression object. - * The error manager must already be set up (in case memory manager fails). - */ - -GLOBAL(void) -jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize) -{ - int i; - - /* Guard against version mismatches between library and caller. */ - cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ - if (version != JPEG_LIB_VERSION) - ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); - if (structsize != SIZEOF(struct jpeg_compress_struct)) - ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, - (int) SIZEOF(struct jpeg_compress_struct), (int) structsize); - - /* For debugging purposes, we zero the whole master structure. - * But the application has already set the err pointer, and may have set - * client_data, so we have to save and restore those fields. - * Note: if application hasn't set client_data, tools like Purify may - * complain here. - */ - { - struct jpeg_error_mgr * err = cinfo->err; - void * client_data = cinfo->client_data; /* ignore Purify complaint here */ - MEMZERO(cinfo, SIZEOF(struct jpeg_compress_struct)); - cinfo->err = err; - cinfo->client_data = client_data; - } - cinfo->is_decompressor = FALSE; - - /* Initialize a memory manager instance for this object */ - jinit_memory_mgr((j_common_ptr) cinfo); - - /* Zero out pointers to permanent structures. */ - cinfo->progress = NULL; - cinfo->dest = NULL; - - cinfo->comp_info = NULL; - - for (i = 0; i < NUM_QUANT_TBLS; i++) - cinfo->quant_tbl_ptrs[i] = NULL; - - for (i = 0; i < NUM_HUFF_TBLS; i++) { - cinfo->dc_huff_tbl_ptrs[i] = NULL; - cinfo->ac_huff_tbl_ptrs[i] = NULL; - } - - cinfo->script_space = NULL; - - cinfo->input_gamma = 1.0; /* in case application forgets */ - - /* OK, I'm ready */ - cinfo->global_state = CSTATE_START; -} - - -/* - * Destruction of a JPEG compression object - */ - -GLOBAL(void) -jpeg_destroy_compress (j_compress_ptr cinfo) -{ - jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Abort processing of a JPEG compression operation, - * but don't destroy the object itself. - */ - -GLOBAL(void) -jpeg_abort_compress (j_compress_ptr cinfo) -{ - jpeg_abort((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Forcibly suppress or un-suppress all quantization and Huffman tables. - * Marks all currently defined tables as already written (if suppress) - * or not written (if !suppress). This will control whether they get emitted - * by a subsequent jpeg_start_compress call. - * - * This routine is exported for use by applications that want to produce - * abbreviated JPEG datastreams. It logically belongs in jcparam.c, but - * since it is called by jpeg_start_compress, we put it here --- otherwise - * jcparam.o would be linked whether the application used it or not. - */ - -GLOBAL(void) -jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress) -{ - int i; - JQUANT_TBL * qtbl; - JHUFF_TBL * htbl; - - for (i = 0; i < NUM_QUANT_TBLS; i++) { - if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL) - qtbl->sent_table = suppress; - } - - for (i = 0; i < NUM_HUFF_TBLS; i++) { - if ((htbl = cinfo->dc_huff_tbl_ptrs[i]) != NULL) - htbl->sent_table = suppress; - if ((htbl = cinfo->ac_huff_tbl_ptrs[i]) != NULL) - htbl->sent_table = suppress; - } -} - - -/* - * Finish JPEG compression. - * - * If a multipass operating mode was selected, this may do a great deal of - * work including most of the actual output. - */ - -GLOBAL(void) -jpeg_finish_compress (j_compress_ptr cinfo) -{ - JDIMENSION iMCU_row; - - if (cinfo->global_state == CSTATE_SCANNING || - cinfo->global_state == CSTATE_RAW_OK) { - /* Terminate first pass */ - if (cinfo->next_scanline < cinfo->image_height) - ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); - (*cinfo->master->finish_pass) (cinfo); - } else if (cinfo->global_state != CSTATE_WRCOEFS) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Perform any remaining passes */ - while (! cinfo->master->is_last_pass) { - (*cinfo->master->prepare_for_pass) (cinfo); - for (iMCU_row = 0; iMCU_row < cinfo->total_iMCU_rows; iMCU_row++) { - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) iMCU_row; - cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - /* We bypass the main controller and invoke coef controller directly; - * all work is being done from the coefficient buffer. - */ - if (! (*cinfo->coef->compress_data) (cinfo, (JSAMPIMAGE) NULL)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - } - (*cinfo->master->finish_pass) (cinfo); - } - /* Write EOI, do final cleanup */ - (*cinfo->marker->write_file_trailer) (cinfo); - (*cinfo->dest->term_destination) (cinfo); - /* We can use jpeg_abort to release memory and reset global_state */ - jpeg_abort((j_common_ptr) cinfo); -} - - -/* - * Write a special marker. - * This is only recommended for writing COM or APPn markers. - * Must be called after jpeg_start_compress() and before - * first call to jpeg_write_scanlines() or jpeg_write_raw_data(). - */ - -GLOBAL(void) -jpeg_write_marker (j_compress_ptr cinfo, int marker, - const JOCTET *dataptr, unsigned int datalen) -{ - JMETHOD(void, write_marker_byte, (j_compress_ptr info, int val)); - - if (cinfo->next_scanline != 0 || - (cinfo->global_state != CSTATE_SCANNING && - cinfo->global_state != CSTATE_RAW_OK && - cinfo->global_state != CSTATE_WRCOEFS)) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); - write_marker_byte = cinfo->marker->write_marker_byte; /* copy for speed */ - while (datalen--) { - (*write_marker_byte) (cinfo, *dataptr); - dataptr++; - } -} - -/* Same, but piecemeal. */ - -GLOBAL(void) -jpeg_write_m_header (j_compress_ptr cinfo, int marker, unsigned int datalen) -{ - if (cinfo->next_scanline != 0 || - (cinfo->global_state != CSTATE_SCANNING && - cinfo->global_state != CSTATE_RAW_OK && - cinfo->global_state != CSTATE_WRCOEFS)) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - (*cinfo->marker->write_marker_header) (cinfo, marker, datalen); -} - -GLOBAL(void) -jpeg_write_m_byte (j_compress_ptr cinfo, int val) -{ - (*cinfo->marker->write_marker_byte) (cinfo, val); -} - - -/* - * Alternate compression function: just write an abbreviated table file. - * Before calling this, all parameters and a data destination must be set up. - * - * To produce a pair of files containing abbreviated tables and abbreviated - * image data, one would proceed as follows: - * - * initialize JPEG object - * set JPEG parameters - * set destination to table file - * jpeg_write_tables(cinfo); - * set destination to image file - * jpeg_start_compress(cinfo, FALSE); - * write data... - * jpeg_finish_compress(cinfo); - * - * jpeg_write_tables has the side effect of marking all tables written - * (same as jpeg_suppress_tables(..., TRUE)). Thus a subsequent start_compress - * will not re-emit the tables unless it is passed write_all_tables=TRUE. - */ - -GLOBAL(void) -jpeg_write_tables (j_compress_ptr cinfo) -{ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* (Re)initialize error mgr and destination modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->dest->init_destination) (cinfo); - /* Initialize the marker writer ... bit of a crock to do it here. */ - jinit_marker_writer(cinfo); - /* Write them tables! */ - (*cinfo->marker->write_tables_only) (cinfo); - /* And clean up. */ - (*cinfo->dest->term_destination) (cinfo); - /* - * In library releases up through v6a, we called jpeg_abort() here to free - * any working memory allocated by the destination manager and marker - * writer. Some applications had a problem with that: they allocated space - * of their own from the library memory manager, and didn't want it to go - * away during write_tables. So now we do nothing. This will cause a - * memory leak if an app calls write_tables repeatedly without doing a full - * compression cycle or otherwise resetting the JPEG object. However, that - * seems less bad than unexpectedly freeing memory in the normal case. - * An app that prefers the old behavior can call jpeg_abort for itself after - * each call to jpeg_write_tables(). - */ -} diff --git a/oversampling/WDL/jpeglib/jcapistd.c b/oversampling/WDL/jpeglib/jcapistd.c deleted file mode 100644 index c0320b1..0000000 --- a/oversampling/WDL/jpeglib/jcapistd.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * jcapistd.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the compression half - * of the JPEG library. These are the "standard" API routines that are - * used in the normal full-compression case. They are not used by a - * transcoding-only application. Note that if an application links in - * jpeg_start_compress, it will end up linking in the entire compressor. - * We thus must separate this file from jcapimin.c to avoid linking the - * whole compression library into a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Compression initialization. - * Before calling this, all parameters and a data destination must be set up. - * - * We require a write_all_tables parameter as a failsafe check when writing - * multiple datastreams from the same compression object. Since prior runs - * will have left all the tables marked sent_table=TRUE, a subsequent run - * would emit an abbreviated stream (no tables) by default. This may be what - * is wanted, but for safety's sake it should not be the default behavior: - * programmers should have to make a deliberate choice to emit abbreviated - * images. Therefore the documentation and examples should encourage people - * to pass write_all_tables=TRUE; then it will take active thought to do the - * wrong thing. - */ - -GLOBAL(void) -jpeg_start_compress (j_compress_ptr cinfo, boolean write_all_tables) -{ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - if (write_all_tables) - jpeg_suppress_tables(cinfo, FALSE); /* mark all tables to be written */ - - /* (Re)initialize error mgr and destination modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->dest->init_destination) (cinfo); - /* Perform master selection of active modules */ - jinit_compress_master(cinfo); - /* Set up for the first pass */ - (*cinfo->master->prepare_for_pass) (cinfo); - /* Ready for application to drive first pass through jpeg_write_scanlines - * or jpeg_write_raw_data. - */ - cinfo->next_scanline = 0; - cinfo->global_state = (cinfo->raw_data_in ? CSTATE_RAW_OK : CSTATE_SCANNING); -} - - -/* - * Write some scanlines of data to the JPEG compressor. - * - * The return value will be the number of lines actually written. - * This should be less than the supplied num_lines only in case that - * the data destination module has requested suspension of the compressor, - * or if more than image_height scanlines are passed in. - * - * Note: we warn about excess calls to jpeg_write_scanlines() since - * this likely signals an application programmer error. However, - * excess scanlines passed in the last valid call are *silently* ignored, - * so that the application need not adjust num_lines for end-of-image - * when using a multiple-scanline buffer. - */ - -GLOBAL(JDIMENSION) -jpeg_write_scanlines (j_compress_ptr cinfo, JSAMPARRAY scanlines, - JDIMENSION num_lines) -{ - JDIMENSION row_ctr, rows_left; - - if (cinfo->global_state != CSTATE_SCANNING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->next_scanline >= cinfo->image_height) - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->next_scanline; - cinfo->progress->pass_limit = (long) cinfo->image_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Give master control module another chance if this is first call to - * jpeg_write_scanlines. This lets output of the frame/scan headers be - * delayed so that application can write COM, etc, markers between - * jpeg_start_compress and jpeg_write_scanlines. - */ - if (cinfo->master->call_pass_startup) - (*cinfo->master->pass_startup) (cinfo); - - /* Ignore any extra scanlines at bottom of image. */ - rows_left = cinfo->image_height - cinfo->next_scanline; - if (num_lines > rows_left) - num_lines = rows_left; - - row_ctr = 0; - (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, num_lines); - cinfo->next_scanline += row_ctr; - return row_ctr; -} - - -/* - * Alternate entry point to write raw data. - * Processes exactly one iMCU row per call, unless suspended. - */ - -GLOBAL(JDIMENSION) -jpeg_write_raw_data (j_compress_ptr cinfo, JSAMPIMAGE data, - JDIMENSION num_lines) -{ - JDIMENSION lines_per_iMCU_row; - - if (cinfo->global_state != CSTATE_RAW_OK) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->next_scanline >= cinfo->image_height) { - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - return 0; - } - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->next_scanline; - cinfo->progress->pass_limit = (long) cinfo->image_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Give master control module another chance if this is first call to - * jpeg_write_raw_data. This lets output of the frame/scan headers be - * delayed so that application can write COM, etc, markers between - * jpeg_start_compress and jpeg_write_raw_data. - */ - if (cinfo->master->call_pass_startup) - (*cinfo->master->pass_startup) (cinfo); - - /* Verify that at least one iMCU row has been passed. */ - lines_per_iMCU_row = cinfo->max_v_samp_factor * DCTSIZE; - if (num_lines < lines_per_iMCU_row) - ERREXIT(cinfo, JERR_BUFFER_SIZE); - - /* Directly compress the row. */ - if (! (*cinfo->coef->compress_data) (cinfo, data)) { - /* If compressor did not consume the whole row, suspend processing. */ - return 0; - } - - /* OK, we processed one iMCU row. */ - cinfo->next_scanline += lines_per_iMCU_row; - return lines_per_iMCU_row; -} diff --git a/oversampling/WDL/jpeglib/jccoefct.c b/oversampling/WDL/jpeglib/jccoefct.c deleted file mode 100644 index 1963ddb..0000000 --- a/oversampling/WDL/jpeglib/jccoefct.c +++ /dev/null @@ -1,449 +0,0 @@ -/* - * jccoefct.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the coefficient buffer controller for compression. - * This controller is the top level of the JPEG compressor proper. - * The coefficient buffer lies between forward-DCT and entropy encoding steps. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* We use a full-image coefficient buffer when doing Huffman optimization, - * and also for writing multiple-scan JPEG files. In all cases, the DCT - * step is run during the first pass, and subsequent passes need only read - * the buffered coefficients. - */ -#ifdef ENTROPY_OPT_SUPPORTED -#define FULL_COEF_BUFFER_SUPPORTED -#else -#ifdef C_MULTISCAN_FILES_SUPPORTED -#define FULL_COEF_BUFFER_SUPPORTED -#endif -#endif - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_coef_controller pub; /* public fields */ - - JDIMENSION iMCU_row_num; /* iMCU row # within image */ - JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ - int MCU_vert_offset; /* counts MCU rows within iMCU row */ - int MCU_rows_per_iMCU_row; /* number of such rows needed */ - - /* For single-pass compression, it's sufficient to buffer just one MCU - * (although this may prove a bit slow in practice). We allocate a - * workspace of C_MAX_BLOCKS_IN_MCU coefficient blocks, and reuse it for each - * MCU constructed and sent. (On 80x86, the workspace is FAR even though - * it's not really very big; this is to keep the module interfaces unchanged - * when a large coefficient buffer is necessary.) - * In multi-pass modes, this array points to the current MCU's blocks - * within the virtual arrays. - */ - JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; - - /* In multi-pass modes, we need a virtual block array for each component. */ - jvirt_barray_ptr whole_image[MAX_COMPONENTS]; -} my_coef_controller; - -typedef my_coef_controller * my_coef_ptr; - - -/* Forward declarations */ -METHODDEF(boolean) compress_data - JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); -#ifdef FULL_COEF_BUFFER_SUPPORTED -METHODDEF(boolean) compress_first_pass - JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); -METHODDEF(boolean) compress_output - JPP((j_compress_ptr cinfo, JSAMPIMAGE input_buf)); -#endif - - -LOCAL(void) -start_iMCU_row (j_compress_ptr cinfo) -/* Reset within-iMCU-row counters for a new row */ -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* In an interleaved scan, an MCU row is the same as an iMCU row. - * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. - * But at the bottom of the image, process only what's left. - */ - if (cinfo->comps_in_scan > 1) { - coef->MCU_rows_per_iMCU_row = 1; - } else { - if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; - else - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; - } - - coef->mcu_ctr = 0; - coef->MCU_vert_offset = 0; -} - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - coef->iMCU_row_num = 0; - start_iMCU_row(cinfo); - - switch (pass_mode) { - case JBUF_PASS_THRU: - if (coef->whole_image[0] != NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - coef->pub.compress_data = compress_data; - break; -#ifdef FULL_COEF_BUFFER_SUPPORTED - case JBUF_SAVE_AND_PASS: - if (coef->whole_image[0] == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - coef->pub.compress_data = compress_first_pass; - break; - case JBUF_CRANK_DEST: - if (coef->whole_image[0] == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - coef->pub.compress_data = compress_output; - break; -#endif - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } -} - - -/* - * Process some data in the single-pass case. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the image. - * Returns TRUE if the iMCU row is completed, FALSE if suspended. - * - * NB: input_buf contains a plane for each component in image, - * which we index according to the component's SOF position. - */ - -METHODDEF(boolean) -compress_data (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - int blkn, bi, ci, yindex, yoffset, blockcnt; - JDIMENSION ypos, xpos; - jpeg_component_info *compptr; - - /* Loop to write as much as one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->mcu_ctr; MCU_col_num <= last_MCU_col; - MCU_col_num++) { - /* Determine where data comes from in input_buf and do the DCT thing. - * Each call on forward_DCT processes a horizontal row of DCT blocks - * as wide as an MCU; we rely on having allocated the MCU_buffer[] blocks - * sequentially. Dummy blocks at the right or bottom edge are filled in - * specially. The data in them does not matter for image reconstruction, - * so we fill them with values that will encode to the smallest amount of - * data, viz: all zeroes in the AC entries, DC entries equal to previous - * block's DC value. (Thanks to Thomas Kinsman for this idea.) - */ - blkn = 0; - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width - : compptr->last_col_width; - xpos = MCU_col_num * compptr->MCU_sample_width; - ypos = yoffset * DCTSIZE; /* ypos == (yoffset+yindex) * DCTSIZE */ - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - if (coef->iMCU_row_num < last_iMCU_row || - yoffset+yindex < compptr->last_row_height) { - (*cinfo->fdct->forward_DCT) (cinfo, compptr, - input_buf[compptr->component_index], - coef->MCU_buffer[blkn], - ypos, xpos, (JDIMENSION) blockcnt); - if (blockcnt < compptr->MCU_width) { - /* Create some dummy blocks at the right edge of the image. */ - jzero_far((void FAR *) coef->MCU_buffer[blkn + blockcnt], - (compptr->MCU_width - blockcnt) * SIZEOF(JBLOCK)); - for (bi = blockcnt; bi < compptr->MCU_width; bi++) { - coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn+bi-1][0][0]; - } - } - } else { - /* Create a row of dummy blocks at the bottom of the image. */ - jzero_far((void FAR *) coef->MCU_buffer[blkn], - compptr->MCU_width * SIZEOF(JBLOCK)); - for (bi = 0; bi < compptr->MCU_width; bi++) { - coef->MCU_buffer[blkn+bi][0][0] = coef->MCU_buffer[blkn-1][0][0]; - } - } - blkn += compptr->MCU_width; - ypos += DCTSIZE; - } - } - /* Try to write the MCU. In event of a suspension failure, we will - * re-DCT the MCU on restart (a bit inefficient, could be fixed...) - */ - if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->mcu_ctr = MCU_col_num; - return FALSE; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->mcu_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - coef->iMCU_row_num++; - start_iMCU_row(cinfo); - return TRUE; -} - - -#ifdef FULL_COEF_BUFFER_SUPPORTED - -/* - * Process some data in the first pass of a multi-pass case. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the image. - * This amount of data is read from the source buffer, DCT'd and quantized, - * and saved into the virtual arrays. We also generate suitable dummy blocks - * as needed at the right and lower edges. (The dummy blocks are constructed - * in the virtual arrays, which have been padded appropriately.) This makes - * it possible for subsequent passes not to worry about real vs. dummy blocks. - * - * We must also emit the data to the entropy encoder. This is conveniently - * done by calling compress_output() after we've loaded the current strip - * of the virtual arrays. - * - * NB: input_buf contains a plane for each component in image. All - * components are DCT'd and loaded into the virtual arrays in this pass. - * However, it may be that only a subset of the components are emitted to - * the entropy encoder during this first pass; be careful about looking - * at the scan-dependent variables (MCU dimensions, etc). - */ - -METHODDEF(boolean) -compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - JDIMENSION blocks_across, MCUs_across, MCUindex; - int bi, ci, h_samp_factor, block_row, block_rows, ndummy; - JCOEF lastDC; - jpeg_component_info *compptr; - JBLOCKARRAY buffer; - JBLOCKROW thisblockrow, lastblockrow; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Align the virtual buffer for this component. */ - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - coef->iMCU_row_num * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, TRUE); - /* Count non-dummy DCT block rows in this iMCU row. */ - if (coef->iMCU_row_num < last_iMCU_row) - block_rows = compptr->v_samp_factor; - else { - /* NB: can't use last_row_height here, since may not be set! */ - block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (block_rows == 0) block_rows = compptr->v_samp_factor; - } - blocks_across = compptr->width_in_blocks; - h_samp_factor = compptr->h_samp_factor; - /* Count number of dummy blocks to be added at the right margin. */ - ndummy = (int) (blocks_across % h_samp_factor); - if (ndummy > 0) - ndummy = h_samp_factor - ndummy; - /* Perform DCT for all non-dummy blocks in this iMCU row. Each call - * on forward_DCT processes a complete horizontal row of DCT blocks. - */ - for (block_row = 0; block_row < block_rows; block_row++) { - thisblockrow = buffer[block_row]; - (*cinfo->fdct->forward_DCT) (cinfo, compptr, - input_buf[ci], thisblockrow, - (JDIMENSION) (block_row * DCTSIZE), - (JDIMENSION) 0, blocks_across); - if (ndummy > 0) { - /* Create dummy blocks at the right edge of the image. */ - thisblockrow += blocks_across; /* => first dummy block */ - jzero_far((void FAR *) thisblockrow, ndummy * SIZEOF(JBLOCK)); - lastDC = thisblockrow[-1][0]; - for (bi = 0; bi < ndummy; bi++) { - thisblockrow[bi][0] = lastDC; - } - } - } - /* If at end of image, create dummy block rows as needed. - * The tricky part here is that within each MCU, we want the DC values - * of the dummy blocks to match the last real block's DC value. - * This squeezes a few more bytes out of the resulting file... - */ - if (coef->iMCU_row_num == last_iMCU_row) { - blocks_across += ndummy; /* include lower right corner */ - MCUs_across = blocks_across / h_samp_factor; - for (block_row = block_rows; block_row < compptr->v_samp_factor; - block_row++) { - thisblockrow = buffer[block_row]; - lastblockrow = buffer[block_row-1]; - jzero_far((void FAR *) thisblockrow, - (size_t) (blocks_across * SIZEOF(JBLOCK))); - for (MCUindex = 0; MCUindex < MCUs_across; MCUindex++) { - lastDC = lastblockrow[h_samp_factor-1][0]; - for (bi = 0; bi < h_samp_factor; bi++) { - thisblockrow[bi][0] = lastDC; - } - thisblockrow += h_samp_factor; /* advance to next MCU in row */ - lastblockrow += h_samp_factor; - } - } - } - } - /* NB: compress_output will increment iMCU_row_num if successful. - * A suspension return will result in redoing all the work above next time. - */ - - /* Emit data to the entropy encoder, sharing code with subsequent passes */ - return compress_output(cinfo, input_buf); -} - - -/* - * Process some data in subsequent passes of a multi-pass case. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the scan. - * The data is obtained from the virtual arrays and fed to the entropy coder. - * Returns TRUE if the iMCU row is completed, FALSE if suspended. - * - * NB: input_buf is ignored; it is likely to be a NULL pointer. - */ - -METHODDEF(boolean) -compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - int blkn, ci, xindex, yindex, yoffset; - JDIMENSION start_col; - JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; - JBLOCKROW buffer_ptr; - jpeg_component_info *compptr; - - /* Align the virtual buffers for the components used in this scan. - * NB: during first pass, this is safe only because the buffers will - * already be aligned properly, so jmemmgr.c won't need to do any I/O. - */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - buffer[ci] = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], - coef->iMCU_row_num * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - - /* Loop to process one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; - MCU_col_num++) { - /* Construct list of pointers to DCT blocks belonging to this MCU */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - start_col = MCU_col_num * compptr->MCU_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - buffer_ptr = buffer[ci][yindex+yoffset] + start_col; - for (xindex = 0; xindex < compptr->MCU_width; xindex++) { - coef->MCU_buffer[blkn++] = buffer_ptr++; - } - } - } - /* Try to write the MCU. */ - if (! (*cinfo->entropy->encode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->mcu_ctr = MCU_col_num; - return FALSE; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->mcu_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - coef->iMCU_row_num++; - start_iMCU_row(cinfo); - return TRUE; -} - -#endif /* FULL_COEF_BUFFER_SUPPORTED */ - - -/* - * Initialize coefficient buffer controller. - */ - -GLOBAL(void) -jinit_c_coef_controller (j_compress_ptr cinfo, boolean need_full_buffer) -{ - my_coef_ptr coef; - - coef = (my_coef_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_coef_controller)); - cinfo->coef = (struct jpeg_c_coef_controller *) coef; - coef->pub.start_pass = start_pass_coef; - - /* Create the coefficient buffer. */ - if (need_full_buffer) { -#ifdef FULL_COEF_BUFFER_SUPPORTED - /* Allocate a full-image virtual array for each component, */ - /* padded to a multiple of samp_factor DCT blocks in each direction. */ - int ci; - jpeg_component_info *compptr; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - (JDIMENSION) jround_up((long) compptr->width_in_blocks, - (long) compptr->h_samp_factor), - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor), - (JDIMENSION) compptr->v_samp_factor); - } -#else - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif - } else { - /* We only need a single-MCU buffer. */ - JBLOCKROW buffer; - int i; - - buffer = (JBLOCKROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { - coef->MCU_buffer[i] = buffer + i; - } - coef->whole_image[0] = NULL; /* flag for no virtual arrays */ - } -} diff --git a/oversampling/WDL/jpeglib/jccolor.c b/oversampling/WDL/jpeglib/jccolor.c deleted file mode 100644 index 0a8a4b5..0000000 --- a/oversampling/WDL/jpeglib/jccolor.c +++ /dev/null @@ -1,459 +0,0 @@ -/* - * jccolor.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains input colorspace conversion routines. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private subobject */ - -typedef struct { - struct jpeg_color_converter pub; /* public fields */ - - /* Private state for RGB->YCC conversion */ - INT32 * rgb_ycc_tab; /* => table for RGB to YCbCr conversion */ -} my_color_converter; - -typedef my_color_converter * my_cconvert_ptr; - - -/**************** RGB -> YCbCr conversion: most common case **************/ - -/* - * YCbCr is defined per CCIR 601-1, except that Cb and Cr are - * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. - * The conversion equations to be implemented are therefore - * Y = 0.29900 * R + 0.58700 * G + 0.11400 * B - * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B + CENTERJSAMPLE - * Cr = 0.50000 * R - 0.41869 * G - 0.08131 * B + CENTERJSAMPLE - * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) - * Note: older versions of the IJG code used a zero offset of MAXJSAMPLE/2, - * rather than CENTERJSAMPLE, for Cb and Cr. This gave equal positive and - * negative swings for Cb/Cr, but meant that grayscale values (Cb=Cr=0) - * were not represented exactly. Now we sacrifice exact representation of - * maximum red and maximum blue in order to get exact grayscales. - * - * To avoid floating-point arithmetic, we represent the fractional constants - * as integers scaled up by 2^16 (about 4 digits precision); we have to divide - * the products by 2^16, with appropriate rounding, to get the correct answer. - * - * For even more speed, we avoid doing any multiplications in the inner loop - * by precalculating the constants times R,G,B for all possible values. - * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); - * for 12-bit samples it is still acceptable. It's not very reasonable for - * 16-bit samples, but if you want lossless storage you shouldn't be changing - * colorspace anyway. - * The CENTERJSAMPLE offsets and the rounding fudge-factor of 0.5 are included - * in the tables to save adding them separately in the inner loop. - */ - -#define SCALEBITS 16 /* speediest right-shift on some machines */ -#define CBCR_OFFSET ((INT32) CENTERJSAMPLE << SCALEBITS) -#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) -#define FIX(x) ((INT32) ((x) * (1L< Y section */ -#define G_Y_OFF (1*(MAXJSAMPLE+1)) /* offset to G => Y section */ -#define B_Y_OFF (2*(MAXJSAMPLE+1)) /* etc. */ -#define R_CB_OFF (3*(MAXJSAMPLE+1)) -#define G_CB_OFF (4*(MAXJSAMPLE+1)) -#define B_CB_OFF (5*(MAXJSAMPLE+1)) -#define R_CR_OFF B_CB_OFF /* B=>Cb, R=>Cr are the same */ -#define G_CR_OFF (6*(MAXJSAMPLE+1)) -#define B_CR_OFF (7*(MAXJSAMPLE+1)) -#define TABLE_SIZE (8*(MAXJSAMPLE+1)) - - -/* - * Initialize for RGB->YCC colorspace conversion. - */ - -METHODDEF(void) -rgb_ycc_start (j_compress_ptr cinfo) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - INT32 * rgb_ycc_tab; - INT32 i; - - /* Allocate and fill in the conversion tables. */ - cconvert->rgb_ycc_tab = rgb_ycc_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (TABLE_SIZE * SIZEOF(INT32))); - - for (i = 0; i <= MAXJSAMPLE; i++) { - rgb_ycc_tab[i+R_Y_OFF] = FIX(0.29900) * i; - rgb_ycc_tab[i+G_Y_OFF] = FIX(0.58700) * i; - rgb_ycc_tab[i+B_Y_OFF] = FIX(0.11400) * i + ONE_HALF; - rgb_ycc_tab[i+R_CB_OFF] = (-FIX(0.16874)) * i; - rgb_ycc_tab[i+G_CB_OFF] = (-FIX(0.33126)) * i; - /* We use a rounding fudge-factor of 0.5-epsilon for Cb and Cr. - * This ensures that the maximum output will round to MAXJSAMPLE - * not MAXJSAMPLE+1, and thus that we don't have to range-limit. - */ - rgb_ycc_tab[i+B_CB_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; -/* B=>Cb and R=>Cr tables are the same - rgb_ycc_tab[i+R_CR_OFF] = FIX(0.50000) * i + CBCR_OFFSET + ONE_HALF-1; -*/ - rgb_ycc_tab[i+G_CR_OFF] = (-FIX(0.41869)) * i; - rgb_ycc_tab[i+B_CR_OFF] = (-FIX(0.08131)) * i; - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * - * Note that we change from the application's interleaved-pixel format - * to our internal noninterleaved, one-plane-per-component format. - * The input buffer is therefore three times as wide as the output buffer. - * - * A starting row offset is provided only for the output buffer. The caller - * can easily adjust the passed input_buf value to accommodate any row - * offset required on that side. - */ - -METHODDEF(void) -rgb_ycc_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int r, g, b; - register INT32 * ctab = cconvert->rgb_ycc_tab; - register JSAMPROW inptr; - register JSAMPROW outptr0, outptr1, outptr2; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr0 = output_buf[0][output_row]; - outptr1 = output_buf[1][output_row]; - outptr2 = output_buf[2][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - r = GETJSAMPLE(inptr[RGB_RED]); - g = GETJSAMPLE(inptr[RGB_GREEN]); - b = GETJSAMPLE(inptr[RGB_BLUE]); - inptr += RGB_PIXELSIZE; - /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations - * must be too; we do not need an explicit range-limiting operation. - * Hence the value being shifted is never negative, and we don't - * need the general RIGHT_SHIFT macro. - */ - /* Y */ - outptr0[col] = (JSAMPLE) - ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) - >> SCALEBITS); - /* Cb */ - outptr1[col] = (JSAMPLE) - ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) - >> SCALEBITS); - /* Cr */ - outptr2[col] = (JSAMPLE) - ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) - >> SCALEBITS); - } - } -} - - -/**************** Cases other than RGB -> YCbCr **************/ - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles RGB->grayscale conversion, which is the same - * as the RGB->Y portion of RGB->YCbCr. - * We assume rgb_ycc_start has been called (we only use the Y tables). - */ - -METHODDEF(void) -rgb_gray_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int r, g, b; - register INT32 * ctab = cconvert->rgb_ycc_tab; - register JSAMPROW inptr; - register JSAMPROW outptr; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr = output_buf[0][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - r = GETJSAMPLE(inptr[RGB_RED]); - g = GETJSAMPLE(inptr[RGB_GREEN]); - b = GETJSAMPLE(inptr[RGB_BLUE]); - inptr += RGB_PIXELSIZE; - /* Y */ - outptr[col] = (JSAMPLE) - ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) - >> SCALEBITS); - } - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles Adobe-style CMYK->YCCK conversion, - * where we convert R=1-C, G=1-M, and B=1-Y to YCbCr using the same - * conversion as above, while passing K (black) unchanged. - * We assume rgb_ycc_start has been called. - */ - -METHODDEF(void) -cmyk_ycck_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int r, g, b; - register INT32 * ctab = cconvert->rgb_ycc_tab; - register JSAMPROW inptr; - register JSAMPROW outptr0, outptr1, outptr2, outptr3; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr0 = output_buf[0][output_row]; - outptr1 = output_buf[1][output_row]; - outptr2 = output_buf[2][output_row]; - outptr3 = output_buf[3][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - r = MAXJSAMPLE - GETJSAMPLE(inptr[0]); - g = MAXJSAMPLE - GETJSAMPLE(inptr[1]); - b = MAXJSAMPLE - GETJSAMPLE(inptr[2]); - /* K passes through as-is */ - outptr3[col] = inptr[3]; /* don't need GETJSAMPLE here */ - inptr += 4; - /* If the inputs are 0..MAXJSAMPLE, the outputs of these equations - * must be too; we do not need an explicit range-limiting operation. - * Hence the value being shifted is never negative, and we don't - * need the general RIGHT_SHIFT macro. - */ - /* Y */ - outptr0[col] = (JSAMPLE) - ((ctab[r+R_Y_OFF] + ctab[g+G_Y_OFF] + ctab[b+B_Y_OFF]) - >> SCALEBITS); - /* Cb */ - outptr1[col] = (JSAMPLE) - ((ctab[r+R_CB_OFF] + ctab[g+G_CB_OFF] + ctab[b+B_CB_OFF]) - >> SCALEBITS); - /* Cr */ - outptr2[col] = (JSAMPLE) - ((ctab[r+R_CR_OFF] + ctab[g+G_CR_OFF] + ctab[b+B_CR_OFF]) - >> SCALEBITS); - } - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles grayscale output with no conversion. - * The source can be either plain grayscale or YCbCr (since Y == gray). - */ - -METHODDEF(void) -grayscale_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - register JSAMPROW inptr; - register JSAMPROW outptr; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->image_width; - int instride = cinfo->input_components; - - while (--num_rows >= 0) { - inptr = *input_buf++; - outptr = output_buf[0][output_row]; - output_row++; - for (col = 0; col < num_cols; col++) { - outptr[col] = inptr[0]; /* don't need GETJSAMPLE() here */ - inptr += instride; - } - } -} - - -/* - * Convert some rows of samples to the JPEG colorspace. - * This version handles multi-component colorspaces without conversion. - * We assume input_components == num_components. - */ - -METHODDEF(void) -null_convert (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows) -{ - register JSAMPROW inptr; - register JSAMPROW outptr; - register JDIMENSION col; - register int ci; - int nc = cinfo->num_components; - JDIMENSION num_cols = cinfo->image_width; - - while (--num_rows >= 0) { - /* It seems fastest to make a separate pass for each component. */ - for (ci = 0; ci < nc; ci++) { - inptr = *input_buf; - outptr = output_buf[ci][output_row]; - for (col = 0; col < num_cols; col++) { - outptr[col] = inptr[ci]; /* don't need GETJSAMPLE() here */ - inptr += nc; - } - } - input_buf++; - output_row++; - } -} - - -/* - * Empty method for start_pass. - */ - -METHODDEF(void) -null_method (j_compress_ptr cinfo) -{ - /* no work needed */ -} - - -/* - * Module initialization routine for input colorspace conversion. - */ - -GLOBAL(void) -jinit_color_converter (j_compress_ptr cinfo) -{ - my_cconvert_ptr cconvert; - - cconvert = (my_cconvert_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_color_converter)); - cinfo->cconvert = (struct jpeg_color_converter *) cconvert; - /* set start_pass to null method until we find out differently */ - cconvert->pub.start_pass = null_method; - - /* Make sure input_components agrees with in_color_space */ - switch (cinfo->in_color_space) { - case JCS_GRAYSCALE: - if (cinfo->input_components != 1) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - - case JCS_RGB: -#if RGB_PIXELSIZE != 3 - if (cinfo->input_components != RGB_PIXELSIZE) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; -#endif /* else share code with YCbCr */ - - case JCS_YCbCr: - if (cinfo->input_components != 3) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - - case JCS_CMYK: - case JCS_YCCK: - if (cinfo->input_components != 4) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - - default: /* JCS_UNKNOWN can be anything */ - if (cinfo->input_components < 1) - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - break; - } - - /* Check num_components, set conversion method based on requested space */ - switch (cinfo->jpeg_color_space) { - case JCS_GRAYSCALE: - if (cinfo->num_components != 1) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_GRAYSCALE) - cconvert->pub.color_convert = grayscale_convert; - else if (cinfo->in_color_space == JCS_RGB) { - cconvert->pub.start_pass = rgb_ycc_start; - cconvert->pub.color_convert = rgb_gray_convert; - } else if (cinfo->in_color_space == JCS_YCbCr) - cconvert->pub.color_convert = grayscale_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_RGB: - if (cinfo->num_components != 3) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_RGB && RGB_PIXELSIZE == 3) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_YCbCr: - if (cinfo->num_components != 3) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_RGB) { - cconvert->pub.start_pass = rgb_ycc_start; - cconvert->pub.color_convert = rgb_ycc_convert; - } else if (cinfo->in_color_space == JCS_YCbCr) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_CMYK: - if (cinfo->num_components != 4) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_CMYK) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_YCCK: - if (cinfo->num_components != 4) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - if (cinfo->in_color_space == JCS_CMYK) { - cconvert->pub.start_pass = rgb_ycc_start; - cconvert->pub.color_convert = cmyk_ycck_convert; - } else if (cinfo->in_color_space == JCS_YCCK) - cconvert->pub.color_convert = null_convert; - else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - default: /* allow null conversion of JCS_UNKNOWN */ - if (cinfo->jpeg_color_space != cinfo->in_color_space || - cinfo->num_components != cinfo->input_components) - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - cconvert->pub.color_convert = null_convert; - break; - } -} diff --git a/oversampling/WDL/jpeglib/jcdctmgr.c b/oversampling/WDL/jpeglib/jcdctmgr.c deleted file mode 100644 index 61fa79b..0000000 --- a/oversampling/WDL/jpeglib/jcdctmgr.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - * jcdctmgr.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the forward-DCT management logic. - * This code selects a particular DCT implementation to be used, - * and it performs related housekeeping chores including coefficient - * quantization. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - - -/* Private subobject for this module */ - -typedef struct { - struct jpeg_forward_dct pub; /* public fields */ - - /* Pointer to the DCT routine actually in use */ - forward_DCT_method_ptr do_dct; - - /* The actual post-DCT divisors --- not identical to the quant table - * entries, because of scaling (especially for an unnormalized DCT). - * Each table is given in normal array order. - */ - DCTELEM * divisors[NUM_QUANT_TBLS]; - -#ifdef DCT_FLOAT_SUPPORTED - /* Same as above for the floating-point case. */ - float_DCT_method_ptr do_float_dct; - FAST_FLOAT * float_divisors[NUM_QUANT_TBLS]; -#endif -} my_fdct_controller; - -typedef my_fdct_controller * my_fdct_ptr; - - -/* - * Initialize for a processing pass. - * Verify that all referenced Q-tables are present, and set up - * the divisor table for each one. - * In the current implementation, DCT of all components is done during - * the first pass, even if only some components will be output in the - * first scan. Hence all components should be examined here. - */ - -METHODDEF(void) -start_pass_fdctmgr (j_compress_ptr cinfo) -{ - my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; - int ci, qtblno, i; - jpeg_component_info *compptr; - JQUANT_TBL * qtbl; - DCTELEM * dtbl; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - qtblno = compptr->quant_tbl_no; - /* Make sure specified quantization table is present */ - if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || - cinfo->quant_tbl_ptrs[qtblno] == NULL) - ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); - qtbl = cinfo->quant_tbl_ptrs[qtblno]; - /* Compute divisors for this quant table */ - /* We may do this more than once for same table, but it's not a big deal */ - switch (cinfo->dct_method) { -#ifdef DCT_ISLOW_SUPPORTED - case JDCT_ISLOW: - /* For LL&M IDCT method, divisors are equal to raw quantization - * coefficients multiplied by 8 (to counteract scaling). - */ - if (fdct->divisors[qtblno] == NULL) { - fdct->divisors[qtblno] = (DCTELEM *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - DCTSIZE2 * SIZEOF(DCTELEM)); - } - dtbl = fdct->divisors[qtblno]; - for (i = 0; i < DCTSIZE2; i++) { - dtbl[i] = ((DCTELEM) qtbl->quantval[i]) << 3; - } - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - { - /* For AA&N IDCT method, divisors are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - * We apply a further scale factor of 8. - */ -#define CONST_BITS 14 - static const INT16 aanscales[DCTSIZE2] = { - /* precomputed values scaled up by 14 bits */ - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, - 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, - 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, - 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, - 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 - }; - SHIFT_TEMPS - - if (fdct->divisors[qtblno] == NULL) { - fdct->divisors[qtblno] = (DCTELEM *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - DCTSIZE2 * SIZEOF(DCTELEM)); - } - dtbl = fdct->divisors[qtblno]; - for (i = 0; i < DCTSIZE2; i++) { - dtbl[i] = (DCTELEM) - DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], - (INT32) aanscales[i]), - CONST_BITS-3); - } - } - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - { - /* For float AA&N IDCT method, divisors are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - * We apply a further scale factor of 8. - * What's actually stored is 1/divisor so that the inner loop can - * use a multiplication rather than a division. - */ - FAST_FLOAT * fdtbl; - int row, col; - static const double aanscalefactor[DCTSIZE] = { - 1.0, 1.387039845, 1.306562965, 1.175875602, - 1.0, 0.785694958, 0.541196100, 0.275899379 - }; - - if (fdct->float_divisors[qtblno] == NULL) { - fdct->float_divisors[qtblno] = (FAST_FLOAT *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - DCTSIZE2 * SIZEOF(FAST_FLOAT)); - } - fdtbl = fdct->float_divisors[qtblno]; - i = 0; - for (row = 0; row < DCTSIZE; row++) { - for (col = 0; col < DCTSIZE; col++) { - fdtbl[i] = (FAST_FLOAT) - (1.0 / (((double) qtbl->quantval[i] * - aanscalefactor[row] * aanscalefactor[col] * 8.0))); - i++; - } - } - } - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - } -} - - -/* - * Perform forward DCT on one or more blocks of a component. - * - * The input samples are taken from the sample_data[] array starting at - * position start_row/start_col, and moving to the right for any additional - * blocks. The quantized coefficients are returned in coef_blocks[]. - */ - -METHODDEF(void) -forward_DCT (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY sample_data, JBLOCKROW coef_blocks, - JDIMENSION start_row, JDIMENSION start_col, - JDIMENSION num_blocks) -/* This version is used for integer DCT implementations. */ -{ - /* This routine is heavily used, so it's worth coding it tightly. */ - my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; - forward_DCT_method_ptr do_dct = fdct->do_dct; - DCTELEM * divisors = fdct->divisors[compptr->quant_tbl_no]; - DCTELEM workspace[DCTSIZE2]; /* work area for FDCT subroutine */ - JDIMENSION bi; - - sample_data += start_row; /* fold in the vertical offset once */ - - for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { - /* Load data into workspace, applying unsigned->signed conversion */ - { register DCTELEM *workspaceptr; - register JSAMPROW elemptr; - register int elemr; - - workspaceptr = workspace; - for (elemr = 0; elemr < DCTSIZE; elemr++) { - elemptr = sample_data[elemr] + start_col; -#if DCTSIZE == 8 /* unroll the inner loop */ - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; -#else - { register int elemc; - for (elemc = DCTSIZE; elemc > 0; elemc--) { - *workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE; - } - } -#endif - } - } - - /* Perform the DCT */ - (*do_dct) (workspace); - - /* Quantize/descale the coefficients, and store into coef_blocks[] */ - { register DCTELEM temp, qval; - register int i; - register JCOEFPTR output_ptr = coef_blocks[bi]; - - for (i = 0; i < DCTSIZE2; i++) { - qval = divisors[i]; - temp = workspace[i]; - /* Divide the coefficient value by qval, ensuring proper rounding. - * Since C does not specify the direction of rounding for negative - * quotients, we have to force the dividend positive for portability. - * - * In most files, at least half of the output values will be zero - * (at default quantization settings, more like three-quarters...) - * so we should ensure that this case is fast. On many machines, - * a comparison is enough cheaper than a divide to make a special test - * a win. Since both inputs will be nonnegative, we need only test - * for a < b to discover whether a/b is 0. - * If your machine's division is fast enough, define FAST_DIVIDE. - */ -#ifdef FAST_DIVIDE -#define DIVIDE_BY(a,b) a /= b -#else -#define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0 -#endif - if (temp < 0) { - temp = -temp; - temp += qval>>1; /* for rounding */ - DIVIDE_BY(temp, qval); - temp = -temp; - } else { - temp += qval>>1; /* for rounding */ - DIVIDE_BY(temp, qval); - } - output_ptr[i] = (JCOEF) temp; - } - } - } -} - - -#ifdef DCT_FLOAT_SUPPORTED - -METHODDEF(void) -forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY sample_data, JBLOCKROW coef_blocks, - JDIMENSION start_row, JDIMENSION start_col, - JDIMENSION num_blocks) -/* This version is used for floating-point DCT implementations. */ -{ - /* This routine is heavily used, so it's worth coding it tightly. */ - my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct; - float_DCT_method_ptr do_dct = fdct->do_float_dct; - FAST_FLOAT * divisors = fdct->float_divisors[compptr->quant_tbl_no]; - FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */ - JDIMENSION bi; - - sample_data += start_row; /* fold in the vertical offset once */ - - for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { - /* Load data into workspace, applying unsigned->signed conversion */ - { register FAST_FLOAT *workspaceptr; - register JSAMPROW elemptr; - register int elemr; - - workspaceptr = workspace; - for (elemr = 0; elemr < DCTSIZE; elemr++) { - elemptr = sample_data[elemr] + start_col; -#if DCTSIZE == 8 /* unroll the inner loop */ - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - *workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); -#else - { register int elemc; - for (elemc = DCTSIZE; elemc > 0; elemc--) { - *workspaceptr++ = (FAST_FLOAT) - (GETJSAMPLE(*elemptr++) - CENTERJSAMPLE); - } - } -#endif - } - } - - /* Perform the DCT */ - (*do_dct) (workspace); - - /* Quantize/descale the coefficients, and store into coef_blocks[] */ - { register FAST_FLOAT temp; - register int i; - register JCOEFPTR output_ptr = coef_blocks[bi]; - - for (i = 0; i < DCTSIZE2; i++) { - /* Apply the quantization and scaling factor */ - temp = workspace[i] * divisors[i]; - /* Round to nearest integer. - * Since C does not specify the direction of rounding for negative - * quotients, we have to force the dividend positive for portability. - * The maximum coefficient size is +-16K (for 12-bit data), so this - * code should work for either 16-bit or 32-bit ints. - */ - output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384); - } - } - } -} - -#endif /* DCT_FLOAT_SUPPORTED */ - - -/* - * Initialize FDCT manager. - */ - -GLOBAL(void) -jinit_forward_dct (j_compress_ptr cinfo) -{ - my_fdct_ptr fdct; - int i; - - fdct = (my_fdct_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_fdct_controller)); - cinfo->fdct = (struct jpeg_forward_dct *) fdct; - fdct->pub.start_pass = start_pass_fdctmgr; - - switch (cinfo->dct_method) { -#ifdef DCT_ISLOW_SUPPORTED - case JDCT_ISLOW: - fdct->pub.forward_DCT = forward_DCT; - fdct->do_dct = jpeg_fdct_islow; - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - fdct->pub.forward_DCT = forward_DCT; - fdct->do_dct = jpeg_fdct_ifast; - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - fdct->pub.forward_DCT = forward_DCT_float; - fdct->do_float_dct = jpeg_fdct_float; - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - - /* Mark divisor tables unallocated */ - for (i = 0; i < NUM_QUANT_TBLS; i++) { - fdct->divisors[i] = NULL; -#ifdef DCT_FLOAT_SUPPORTED - fdct->float_divisors[i] = NULL; -#endif - } -} diff --git a/oversampling/WDL/jpeglib/jchuff.c b/oversampling/WDL/jpeglib/jchuff.c deleted file mode 100644 index f235250..0000000 --- a/oversampling/WDL/jpeglib/jchuff.c +++ /dev/null @@ -1,909 +0,0 @@ -/* - * jchuff.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy encoding routines. - * - * Much of the complexity here has to do with supporting output suspension. - * If the data destination module demands suspension, we want to be able to - * back up to the start of the current MCU. To do this, we copy state - * variables into local working storage, and update them back to the - * permanent JPEG objects only upon successful completion of an MCU. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jchuff.h" /* Declarations shared with jcphuff.c */ - - -/* Expanded entropy encoder object for Huffman encoding. - * - * The savable_state subrecord contains fields that change within an MCU, - * but must not be updated permanently until we complete the MCU. - */ - -typedef struct { - INT32 put_buffer; /* current bit-accumulation buffer */ - int put_bits; /* # of bits now in it */ - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ -} savable_state; - -/* This macro is to work around compilers with missing or broken - * structure assignment. You'll need to fix this code if you have - * such a compiler and you change MAX_COMPS_IN_SCAN. - */ - -#ifndef NO_STRUCT_ASSIGN -#define ASSIGN_STATE(dest,src) ((dest) = (src)) -#else -#if MAX_COMPS_IN_SCAN == 4 -#define ASSIGN_STATE(dest,src) \ - ((dest).put_buffer = (src).put_buffer, \ - (dest).put_bits = (src).put_bits, \ - (dest).last_dc_val[0] = (src).last_dc_val[0], \ - (dest).last_dc_val[1] = (src).last_dc_val[1], \ - (dest).last_dc_val[2] = (src).last_dc_val[2], \ - (dest).last_dc_val[3] = (src).last_dc_val[3]) -#endif -#endif - - -typedef struct { - struct jpeg_entropy_encoder pub; /* public fields */ - - savable_state saved; /* Bit buffer & DC state at start of MCU */ - - /* These fields are NOT loaded into local working state. */ - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - int next_restart_num; /* next restart number to write (0-7) */ - - /* Pointers to derived tables (these workspaces have image lifespan) */ - c_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; - c_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; - -#ifdef ENTROPY_OPT_SUPPORTED /* Statistics tables for optimization */ - long * dc_count_ptrs[NUM_HUFF_TBLS]; - long * ac_count_ptrs[NUM_HUFF_TBLS]; -#endif -} huff_entropy_encoder; - -typedef huff_entropy_encoder * huff_entropy_ptr; - -/* Working state while writing an MCU. - * This struct contains all the fields that are needed by subroutines. - */ - -typedef struct { - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - savable_state cur; /* Current bit buffer & DC state */ - j_compress_ptr cinfo; /* dump_buffer needs access to this */ -} working_state; - - -/* Forward declarations */ -METHODDEF(boolean) encode_mcu_huff JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(void) finish_pass_huff JPP((j_compress_ptr cinfo)); -#ifdef ENTROPY_OPT_SUPPORTED -METHODDEF(boolean) encode_mcu_gather JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(void) finish_pass_gather JPP((j_compress_ptr cinfo)); -#endif - - -/* - * Initialize for a Huffman-compressed scan. - * If gather_statistics is TRUE, we do not output anything during the scan, - * just count the Huffman symbols used and generate Huffman code tables. - */ - -METHODDEF(void) -start_pass_huff (j_compress_ptr cinfo, boolean gather_statistics) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci, dctbl, actbl; - jpeg_component_info * compptr; - - if (gather_statistics) { -#ifdef ENTROPY_OPT_SUPPORTED - entropy->pub.encode_mcu = encode_mcu_gather; - entropy->pub.finish_pass = finish_pass_gather; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - entropy->pub.encode_mcu = encode_mcu_huff; - entropy->pub.finish_pass = finish_pass_huff; - } - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - dctbl = compptr->dc_tbl_no; - actbl = compptr->ac_tbl_no; - if (gather_statistics) { -#ifdef ENTROPY_OPT_SUPPORTED - /* Check for invalid table indexes */ - /* (make_c_derived_tbl does this in the other path) */ - if (dctbl < 0 || dctbl >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, dctbl); - if (actbl < 0 || actbl >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, actbl); - /* Allocate and zero the statistics tables */ - /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ - if (entropy->dc_count_ptrs[dctbl] == NULL) - entropy->dc_count_ptrs[dctbl] = (long *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 257 * SIZEOF(long)); - MEMZERO(entropy->dc_count_ptrs[dctbl], 257 * SIZEOF(long)); - if (entropy->ac_count_ptrs[actbl] == NULL) - entropy->ac_count_ptrs[actbl] = (long *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 257 * SIZEOF(long)); - MEMZERO(entropy->ac_count_ptrs[actbl], 257 * SIZEOF(long)); -#endif - } else { - /* Compute derived values for Huffman tables */ - /* We may do this more than once for a table, but it's not expensive */ - jpeg_make_c_derived_tbl(cinfo, TRUE, dctbl, - & entropy->dc_derived_tbls[dctbl]); - jpeg_make_c_derived_tbl(cinfo, FALSE, actbl, - & entropy->ac_derived_tbls[actbl]); - } - /* Initialize DC predictions to 0 */ - entropy->saved.last_dc_val[ci] = 0; - } - - /* Initialize bit buffer to empty */ - entropy->saved.put_buffer = 0; - entropy->saved.put_bits = 0; - - /* Initialize restart stuff */ - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num = 0; -} - - -/* - * Compute the derived values for a Huffman table. - * This routine also performs some validation checks on the table. - * - * Note this is also used by jcphuff.c. - */ - -GLOBAL(void) -jpeg_make_c_derived_tbl (j_compress_ptr cinfo, boolean isDC, int tblno, - c_derived_tbl ** pdtbl) -{ - JHUFF_TBL *htbl; - c_derived_tbl *dtbl; - int p, i, l, lastp, si, maxsymbol; - char huffsize[257]; - unsigned int huffcode[257]; - unsigned int code; - - /* Note that huffsize[] and huffcode[] are filled in code-length order, - * paralleling the order of the symbols themselves in htbl->huffval[]. - */ - - /* Find the input Huffman table */ - if (tblno < 0 || tblno >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - htbl = - isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno]; - if (htbl == NULL) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - - /* Allocate a workspace if we haven't already done so. */ - if (*pdtbl == NULL) - *pdtbl = (c_derived_tbl *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(c_derived_tbl)); - dtbl = *pdtbl; - - /* Figure C.1: make table of Huffman code length for each symbol */ - - p = 0; - for (l = 1; l <= 16; l++) { - i = (int) htbl->bits[l]; - if (i < 0 || p + i > 256) /* protect against table overrun */ - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - while (i--) - huffsize[p++] = (char) l; - } - huffsize[p] = 0; - lastp = p; - - /* Figure C.2: generate the codes themselves */ - /* We also validate that the counts represent a legal Huffman code tree. */ - - code = 0; - si = huffsize[0]; - p = 0; - while (huffsize[p]) { - while (((int) huffsize[p]) == si) { - huffcode[p++] = code; - code++; - } - /* code is now 1 more than the last code used for codelength si; but - * it must still fit in si bits, since no code is allowed to be all ones. - */ - if (((INT32) code) >= (((INT32) 1) << si)) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - code <<= 1; - si++; - } - - /* Figure C.3: generate encoding tables */ - /* These are code and size indexed by symbol value */ - - /* Set all codeless symbols to have code length 0; - * this lets us detect duplicate VAL entries here, and later - * allows emit_bits to detect any attempt to emit such symbols. - */ - MEMZERO(dtbl->ehufsi, SIZEOF(dtbl->ehufsi)); - - /* This is also a convenient place to check for out-of-range - * and duplicated VAL entries. We allow 0..255 for AC symbols - * but only 0..15 for DC. (We could constrain them further - * based on data depth and mode, but this seems enough.) - */ - maxsymbol = isDC ? 15 : 255; - - for (p = 0; p < lastp; p++) { - i = htbl->huffval[p]; - if (i < 0 || i > maxsymbol || dtbl->ehufsi[i]) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - dtbl->ehufco[i] = huffcode[p]; - dtbl->ehufsi[i] = huffsize[p]; - } -} - - -/* Outputting bytes to the file */ - -/* Emit a byte, taking 'action' if must suspend. */ -#define emit_byte(state,val,action) \ - { *(state)->next_output_byte++ = (JOCTET) (val); \ - if (--(state)->free_in_buffer == 0) \ - if (! dump_buffer(state)) \ - { action; } } - - -LOCAL(boolean) -dump_buffer (working_state * state) -/* Empty the output buffer; return TRUE if successful, FALSE if must suspend */ -{ - struct jpeg_destination_mgr * dest = state->cinfo->dest; - - if (! (*dest->empty_output_buffer) (state->cinfo)) - return FALSE; - /* After a successful buffer dump, must reset buffer pointers */ - state->next_output_byte = dest->next_output_byte; - state->free_in_buffer = dest->free_in_buffer; - return TRUE; -} - - -/* Outputting bits to the file */ - -/* Only the right 24 bits of put_buffer are used; the valid bits are - * left-justified in this part. At most 16 bits can be passed to emit_bits - * in one call, and we never retain more than 7 bits in put_buffer - * between calls, so 24 bits are sufficient. - */ - -INLINE -LOCAL(boolean) -emit_bits (working_state * state, unsigned int code, int size) -/* Emit some bits; return TRUE if successful, FALSE if must suspend */ -{ - /* This routine is heavily used, so it's worth coding tightly. */ - register INT32 put_buffer = (INT32) code; - register int put_bits = state->cur.put_bits; - - /* if size is 0, caller used an invalid Huffman table entry */ - if (size == 0) - ERREXIT(state->cinfo, JERR_HUFF_MISSING_CODE); - - put_buffer &= (((INT32) 1)<cur.put_buffer; /* and merge with old buffer contents */ - - while (put_bits >= 8) { - int c = (int) ((put_buffer >> 16) & 0xFF); - - emit_byte(state, c, return FALSE); - if (c == 0xFF) { /* need to stuff a zero byte? */ - emit_byte(state, 0, return FALSE); - } - put_buffer <<= 8; - put_bits -= 8; - } - - state->cur.put_buffer = put_buffer; /* update state variables */ - state->cur.put_bits = put_bits; - - return TRUE; -} - - -LOCAL(boolean) -flush_bits (working_state * state) -{ - if (! emit_bits(state, 0x7F, 7)) /* fill any partial byte with ones */ - return FALSE; - state->cur.put_buffer = 0; /* and reset bit-buffer to empty */ - state->cur.put_bits = 0; - return TRUE; -} - - -/* Encode a single block's worth of coefficients */ - -LOCAL(boolean) -encode_one_block (working_state * state, JCOEFPTR block, int last_dc_val, - c_derived_tbl *dctbl, c_derived_tbl *actbl) -{ - register int temp, temp2; - register int nbits; - register int k, r, i; - - /* Encode the DC coefficient difference per section F.1.2.1 */ - - temp = temp2 = block[0] - last_dc_val; - - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - /* For a negative input, want temp2 = bitwise complement of abs(input) */ - /* This code assumes we are on a two's complement machine */ - temp2--; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 0; - while (temp) { - nbits++; - temp >>= 1; - } - /* Check for out-of-range coefficient values. - * Since we're encoding a difference, the range limit is twice as much. - */ - if (nbits > MAX_COEF_BITS+1) - ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); - - /* Emit the Huffman-coded symbol for the number of bits */ - if (! emit_bits(state, dctbl->ehufco[nbits], dctbl->ehufsi[nbits])) - return FALSE; - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - if (nbits) /* emit_bits rejects calls with size 0 */ - if (! emit_bits(state, (unsigned int) temp2, nbits)) - return FALSE; - - /* Encode the AC coefficients per section F.1.2.2 */ - - r = 0; /* r = run length of zeros */ - - for (k = 1; k < DCTSIZE2; k++) { - if ((temp = block[jpeg_natural_order[k]]) == 0) { - r++; - } else { - /* if run length > 15, must emit special run-length-16 codes (0xF0) */ - while (r > 15) { - if (! emit_bits(state, actbl->ehufco[0xF0], actbl->ehufsi[0xF0])) - return FALSE; - r -= 16; - } - - temp2 = temp; - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - /* This code assumes we are on a two's complement machine */ - temp2--; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 1; /* there must be at least one 1 bit */ - while ((temp >>= 1)) - nbits++; - /* Check for out-of-range coefficient values */ - if (nbits > MAX_COEF_BITS) - ERREXIT(state->cinfo, JERR_BAD_DCT_COEF); - - /* Emit Huffman symbol for run length / number of bits */ - i = (r << 4) + nbits; - if (! emit_bits(state, actbl->ehufco[i], actbl->ehufsi[i])) - return FALSE; - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - if (! emit_bits(state, (unsigned int) temp2, nbits)) - return FALSE; - - r = 0; - } - } - - /* If the last coef(s) were zero, emit an end-of-block code */ - if (r > 0) - if (! emit_bits(state, actbl->ehufco[0], actbl->ehufsi[0])) - return FALSE; - - return TRUE; -} - - -/* - * Emit a restart marker & resynchronize predictions. - */ - -LOCAL(boolean) -emit_restart (working_state * state, int restart_num) -{ - int ci; - - if (! flush_bits(state)) - return FALSE; - - emit_byte(state, 0xFF, return FALSE); - emit_byte(state, JPEG_RST0 + restart_num, return FALSE); - - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < state->cinfo->comps_in_scan; ci++) - state->cur.last_dc_val[ci] = 0; - - /* The restart counter is not updated until we successfully write the MCU. */ - - return TRUE; -} - - -/* - * Encode and output one MCU's worth of Huffman-compressed coefficients. - */ - -METHODDEF(boolean) -encode_mcu_huff (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - working_state state; - int blkn, ci; - jpeg_component_info * compptr; - - /* Load up working state */ - state.next_output_byte = cinfo->dest->next_output_byte; - state.free_in_buffer = cinfo->dest->free_in_buffer; - ASSIGN_STATE(state.cur, entropy->saved); - state.cinfo = cinfo; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! emit_restart(&state, entropy->next_restart_num)) - return FALSE; - } - - /* Encode the MCU data blocks */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - if (! encode_one_block(&state, - MCU_data[blkn][0], state.cur.last_dc_val[ci], - entropy->dc_derived_tbls[compptr->dc_tbl_no], - entropy->ac_derived_tbls[compptr->ac_tbl_no])) - return FALSE; - /* Update last_dc_val */ - state.cur.last_dc_val[ci] = MCU_data[blkn][0][0]; - } - - /* Completed MCU, so update state */ - cinfo->dest->next_output_byte = state.next_output_byte; - cinfo->dest->free_in_buffer = state.free_in_buffer; - ASSIGN_STATE(entropy->saved, state.cur); - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * Finish up at the end of a Huffman-compressed scan. - */ - -METHODDEF(void) -finish_pass_huff (j_compress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - working_state state; - - /* Load up working state ... flush_bits needs it */ - state.next_output_byte = cinfo->dest->next_output_byte; - state.free_in_buffer = cinfo->dest->free_in_buffer; - ASSIGN_STATE(state.cur, entropy->saved); - state.cinfo = cinfo; - - /* Flush out the last data */ - if (! flush_bits(&state)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - - /* Update state */ - cinfo->dest->next_output_byte = state.next_output_byte; - cinfo->dest->free_in_buffer = state.free_in_buffer; - ASSIGN_STATE(entropy->saved, state.cur); -} - - -/* - * Huffman coding optimization. - * - * We first scan the supplied data and count the number of uses of each symbol - * that is to be Huffman-coded. (This process MUST agree with the code above.) - * Then we build a Huffman coding tree for the observed counts. - * Symbols which are not needed at all for the particular image are not - * assigned any code, which saves space in the DHT marker as well as in - * the compressed data. - */ - -#ifdef ENTROPY_OPT_SUPPORTED - - -/* Process a single block's worth of coefficients */ - -LOCAL(void) -htest_one_block (j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val, - long dc_counts[], long ac_counts[]) -{ - register int temp; - register int nbits; - register int k, r; - - /* Encode the DC coefficient difference per section F.1.2.1 */ - - temp = block[0] - last_dc_val; - if (temp < 0) - temp = -temp; - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 0; - while (temp) { - nbits++; - temp >>= 1; - } - /* Check for out-of-range coefficient values. - * Since we're encoding a difference, the range limit is twice as much. - */ - if (nbits > MAX_COEF_BITS+1) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count the Huffman symbol for the number of bits */ - dc_counts[nbits]++; - - /* Encode the AC coefficients per section F.1.2.2 */ - - r = 0; /* r = run length of zeros */ - - for (k = 1; k < DCTSIZE2; k++) { - if ((temp = block[jpeg_natural_order[k]]) == 0) { - r++; - } else { - /* if run length > 15, must emit special run-length-16 codes (0xF0) */ - while (r > 15) { - ac_counts[0xF0]++; - r -= 16; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - if (temp < 0) - temp = -temp; - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 1; /* there must be at least one 1 bit */ - while ((temp >>= 1)) - nbits++; - /* Check for out-of-range coefficient values */ - if (nbits > MAX_COEF_BITS) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count Huffman symbol for run length / number of bits */ - ac_counts[(r << 4) + nbits]++; - - r = 0; - } - } - - /* If the last coef(s) were zero, emit an end-of-block code */ - if (r > 0) - ac_counts[0]++; -} - - -/* - * Trial-encode one MCU's worth of Huffman-compressed coefficients. - * No data is actually output, so no suspension return is possible. - */ - -METHODDEF(boolean) -encode_mcu_gather (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int blkn, ci; - jpeg_component_info * compptr; - - /* Take care of restart intervals if needed */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) - entropy->saved.last_dc_val[ci] = 0; - /* Update restart state */ - entropy->restarts_to_go = cinfo->restart_interval; - } - entropy->restarts_to_go--; - } - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - htest_one_block(cinfo, MCU_data[blkn][0], entropy->saved.last_dc_val[ci], - entropy->dc_count_ptrs[compptr->dc_tbl_no], - entropy->ac_count_ptrs[compptr->ac_tbl_no]); - entropy->saved.last_dc_val[ci] = MCU_data[blkn][0][0]; - } - - return TRUE; -} - - -/* - * Generate the best Huffman code table for the given counts, fill htbl. - * Note this is also used by jcphuff.c. - * - * The JPEG standard requires that no symbol be assigned a codeword of all - * one bits (so that padding bits added at the end of a compressed segment - * can't look like a valid code). Because of the canonical ordering of - * codewords, this just means that there must be an unused slot in the - * longest codeword length category. Section K.2 of the JPEG spec suggests - * reserving such a slot by pretending that symbol 256 is a valid symbol - * with count 1. In theory that's not optimal; giving it count zero but - * including it in the symbol set anyway should give a better Huffman code. - * But the theoretically better code actually seems to come out worse in - * practice, because it produces more all-ones bytes (which incur stuffed - * zero bytes in the final file). In any case the difference is tiny. - * - * The JPEG standard requires Huffman codes to be no more than 16 bits long. - * If some symbols have a very small but nonzero probability, the Huffman tree - * must be adjusted to meet the code length restriction. We currently use - * the adjustment method suggested in JPEG section K.2. This method is *not* - * optimal; it may not choose the best possible limited-length code. But - * typically only very-low-frequency symbols will be given less-than-optimal - * lengths, so the code is almost optimal. Experimental comparisons against - * an optimal limited-length-code algorithm indicate that the difference is - * microscopic --- usually less than a hundredth of a percent of total size. - * So the extra complexity of an optimal algorithm doesn't seem worthwhile. - */ - -GLOBAL(void) -jpeg_gen_optimal_table (j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[]) -{ -#define MAX_CLEN 32 /* assumed maximum initial code length */ - UINT8 bits[MAX_CLEN+1]; /* bits[k] = # of symbols with code length k */ - int codesize[257]; /* codesize[k] = code length of symbol k */ - int others[257]; /* next symbol in current branch of tree */ - int c1, c2; - int p, i, j; - long v; - - /* This algorithm is explained in section K.2 of the JPEG standard */ - - MEMZERO(bits, SIZEOF(bits)); - MEMZERO(codesize, SIZEOF(codesize)); - for (i = 0; i < 257; i++) - others[i] = -1; /* init links to empty */ - - freq[256] = 1; /* make sure 256 has a nonzero count */ - /* Including the pseudo-symbol 256 in the Huffman procedure guarantees - * that no real symbol is given code-value of all ones, because 256 - * will be placed last in the largest codeword category. - */ - - /* Huffman's basic algorithm to assign optimal code lengths to symbols */ - - for (;;) { - /* Find the smallest nonzero frequency, set c1 = its symbol */ - /* In case of ties, take the larger symbol number */ - c1 = -1; - v = 1000000000L; - for (i = 0; i <= 256; i++) { - if (freq[i] && freq[i] <= v) { - v = freq[i]; - c1 = i; - } - } - - /* Find the next smallest nonzero frequency, set c2 = its symbol */ - /* In case of ties, take the larger symbol number */ - c2 = -1; - v = 1000000000L; - for (i = 0; i <= 256; i++) { - if (freq[i] && freq[i] <= v && i != c1) { - v = freq[i]; - c2 = i; - } - } - - /* Done if we've merged everything into one frequency */ - if (c2 < 0) - break; - - /* Else merge the two counts/trees */ - freq[c1] += freq[c2]; - freq[c2] = 0; - - /* Increment the codesize of everything in c1's tree branch */ - codesize[c1]++; - while (others[c1] >= 0) { - c1 = others[c1]; - codesize[c1]++; - } - - others[c1] = c2; /* chain c2 onto c1's tree branch */ - - /* Increment the codesize of everything in c2's tree branch */ - codesize[c2]++; - while (others[c2] >= 0) { - c2 = others[c2]; - codesize[c2]++; - } - } - - /* Now count the number of symbols of each code length */ - for (i = 0; i <= 256; i++) { - if (codesize[i]) { - /* The JPEG standard seems to think that this can't happen, */ - /* but I'm paranoid... */ - if (codesize[i] > MAX_CLEN) - ERREXIT(cinfo, JERR_HUFF_CLEN_OVERFLOW); - - bits[codesize[i]]++; - } - } - - /* JPEG doesn't allow symbols with code lengths over 16 bits, so if the pure - * Huffman procedure assigned any such lengths, we must adjust the coding. - * Here is what the JPEG spec says about how this next bit works: - * Since symbols are paired for the longest Huffman code, the symbols are - * removed from this length category two at a time. The prefix for the pair - * (which is one bit shorter) is allocated to one of the pair; then, - * skipping the BITS entry for that prefix length, a code word from the next - * shortest nonzero BITS entry is converted into a prefix for two code words - * one bit longer. - */ - - for (i = MAX_CLEN; i > 16; i--) { - while (bits[i] > 0) { - j = i - 2; /* find length of new prefix to be used */ - while (bits[j] == 0) - j--; - - bits[i] -= 2; /* remove two symbols */ - bits[i-1]++; /* one goes in this length */ - bits[j+1] += 2; /* two new symbols in this length */ - bits[j]--; /* symbol of this length is now a prefix */ - } - } - - /* Remove the count for the pseudo-symbol 256 from the largest codelength */ - while (bits[i] == 0) /* find largest codelength still in use */ - i--; - bits[i]--; - - /* Return final symbol counts (only for lengths 0..16) */ - MEMCOPY(htbl->bits, bits, SIZEOF(htbl->bits)); - - /* Return a list of the symbols sorted by code length */ - /* It's not real clear to me why we don't need to consider the codelength - * changes made above, but the JPEG spec seems to think this works. - */ - p = 0; - for (i = 1; i <= MAX_CLEN; i++) { - for (j = 0; j <= 255; j++) { - if (codesize[j] == i) { - htbl->huffval[p] = (UINT8) j; - p++; - } - } - } - - /* Set sent_table FALSE so updated table will be written to JPEG file. */ - htbl->sent_table = FALSE; -} - - -/* - * Finish up a statistics-gathering pass and create the new Huffman tables. - */ - -METHODDEF(void) -finish_pass_gather (j_compress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci, dctbl, actbl; - jpeg_component_info * compptr; - JHUFF_TBL **htblptr; - boolean did_dc[NUM_HUFF_TBLS]; - boolean did_ac[NUM_HUFF_TBLS]; - - /* It's important not to apply jpeg_gen_optimal_table more than once - * per table, because it clobbers the input frequency counts! - */ - MEMZERO(did_dc, SIZEOF(did_dc)); - MEMZERO(did_ac, SIZEOF(did_ac)); - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - dctbl = compptr->dc_tbl_no; - actbl = compptr->ac_tbl_no; - if (! did_dc[dctbl]) { - htblptr = & cinfo->dc_huff_tbl_ptrs[dctbl]; - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[dctbl]); - did_dc[dctbl] = TRUE; - } - if (! did_ac[actbl]) { - htblptr = & cinfo->ac_huff_tbl_ptrs[actbl]; - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[actbl]); - did_ac[actbl] = TRUE; - } - } -} - - -#endif /* ENTROPY_OPT_SUPPORTED */ - - -/* - * Module initialization routine for Huffman entropy encoding. - */ - -GLOBAL(void) -jinit_huff_encoder (j_compress_ptr cinfo) -{ - huff_entropy_ptr entropy; - int i; - - entropy = (huff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(huff_entropy_encoder)); - cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; - entropy->pub.start_pass = start_pass_huff; - - /* Mark tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; -#ifdef ENTROPY_OPT_SUPPORTED - entropy->dc_count_ptrs[i] = entropy->ac_count_ptrs[i] = NULL; -#endif - } -} diff --git a/oversampling/WDL/jpeglib/jchuff.h b/oversampling/WDL/jpeglib/jchuff.h deleted file mode 100644 index a9599fc..0000000 --- a/oversampling/WDL/jpeglib/jchuff.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * jchuff.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains declarations for Huffman entropy encoding routines - * that are shared between the sequential encoder (jchuff.c) and the - * progressive encoder (jcphuff.c). No other modules need to see these. - */ - -/* The legal range of a DCT coefficient is - * -1024 .. +1023 for 8-bit data; - * -16384 .. +16383 for 12-bit data. - * Hence the magnitude should always fit in 10 or 14 bits respectively. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MAX_COEF_BITS 10 -#else -#define MAX_COEF_BITS 14 -#endif - -/* Derived data constructed for each Huffman table */ - -typedef struct { - unsigned int ehufco[256]; /* code for each symbol */ - char ehufsi[256]; /* length of code for each symbol */ - /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */ -} c_derived_tbl; - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_make_c_derived_tbl jMkCDerived -#define jpeg_gen_optimal_table jGenOptTbl -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - -/* Expand a Huffman table definition into the derived format */ -EXTERN(void) jpeg_make_c_derived_tbl - JPP((j_compress_ptr cinfo, boolean isDC, int tblno, - c_derived_tbl ** pdtbl)); - -/* Generate an optimal table definition given the specified counts */ -EXTERN(void) jpeg_gen_optimal_table - JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])); diff --git a/oversampling/WDL/jpeglib/jcinit.c b/oversampling/WDL/jpeglib/jcinit.c deleted file mode 100644 index 5efffe3..0000000 --- a/oversampling/WDL/jpeglib/jcinit.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * jcinit.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains initialization logic for the JPEG compressor. - * This routine is in charge of selecting the modules to be executed and - * making an initialization call to each one. - * - * Logically, this code belongs in jcmaster.c. It's split out because - * linking this routine implies linking the entire compression library. - * For a transcoding-only application, we want to be able to use jcmaster.c - * without linking in the whole library. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Master selection of compression modules. - * This is done once at the start of processing an image. We determine - * which modules will be used and give them appropriate initialization calls. - */ - -GLOBAL(void) -jinit_compress_master (j_compress_ptr cinfo) -{ - /* Initialize master control (includes parameter checking/processing) */ - jinit_c_master_control(cinfo, FALSE /* full compression */); - - /* Preprocessing */ - if (! cinfo->raw_data_in) { - jinit_color_converter(cinfo); - jinit_downsampler(cinfo); - jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); - } - /* Forward DCT */ - jinit_forward_dct(cinfo); - /* Entropy encoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - jinit_phuff_encoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_encoder(cinfo); - } - - /* Need a full-image coefficient buffer in any multi-pass mode. */ - jinit_c_coef_controller(cinfo, - (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); - jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); - - jinit_marker_writer(cinfo); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Write the datastream header (SOI) immediately. - * Frame and scan headers are postponed till later. - * This lets application insert special markers after the SOI. - */ - (*cinfo->marker->write_file_header) (cinfo); -} diff --git a/oversampling/WDL/jpeglib/jcmainct.c b/oversampling/WDL/jpeglib/jcmainct.c deleted file mode 100644 index e0279a7..0000000 --- a/oversampling/WDL/jpeglib/jcmainct.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * jcmainct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the main buffer controller for compression. - * The main buffer lies between the pre-processor and the JPEG - * compressor proper; it holds downsampled data in the JPEG colorspace. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Note: currently, there is no operating mode in which a full-image buffer - * is needed at this step. If there were, that mode could not be used with - * "raw data" input, since this module is bypassed in that case. However, - * we've left the code here for possible use in special applications. - */ -#undef FULL_MAIN_BUFFER_SUPPORTED - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_main_controller pub; /* public fields */ - - JDIMENSION cur_iMCU_row; /* number of current iMCU row */ - JDIMENSION rowgroup_ctr; /* counts row groups received in iMCU row */ - boolean suspended; /* remember if we suspended output */ - J_BUF_MODE pass_mode; /* current operating mode */ - - /* If using just a strip buffer, this points to the entire set of buffers - * (we allocate one for each component). In the full-image case, this - * points to the currently accessible strips of the virtual arrays. - */ - JSAMPARRAY buffer[MAX_COMPONENTS]; - -#ifdef FULL_MAIN_BUFFER_SUPPORTED - /* If using full-image storage, this array holds pointers to virtual-array - * control blocks for each component. Unused if not full-image storage. - */ - jvirt_sarray_ptr whole_image[MAX_COMPONENTS]; -#endif -} my_main_controller; - -typedef my_main_controller * my_main_ptr; - - -/* Forward declarations */ -METHODDEF(void) process_data_simple_main - JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, - JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); -#ifdef FULL_MAIN_BUFFER_SUPPORTED -METHODDEF(void) process_data_buffer_main - JPP((j_compress_ptr cinfo, JSAMPARRAY input_buf, - JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)); -#endif - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_main (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - /* Do nothing in raw-data mode. */ - if (cinfo->raw_data_in) - return; - - main->cur_iMCU_row = 0; /* initialize counters */ - main->rowgroup_ctr = 0; - main->suspended = FALSE; - main->pass_mode = pass_mode; /* save mode for use by process_data */ - - switch (pass_mode) { - case JBUF_PASS_THRU: -#ifdef FULL_MAIN_BUFFER_SUPPORTED - if (main->whole_image[0] != NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif - main->pub.process_data = process_data_simple_main; - break; -#ifdef FULL_MAIN_BUFFER_SUPPORTED - case JBUF_SAVE_SOURCE: - case JBUF_CRANK_DEST: - case JBUF_SAVE_AND_PASS: - if (main->whole_image[0] == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - main->pub.process_data = process_data_buffer_main; - break; -#endif - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } -} - - -/* - * Process some data. - * This routine handles the simple pass-through mode, - * where we have only a strip buffer. - */ - -METHODDEF(void) -process_data_simple_main (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { - /* Read input data if we haven't filled the main buffer yet */ - if (main->rowgroup_ctr < DCTSIZE) - (*cinfo->prep->pre_process_data) (cinfo, - input_buf, in_row_ctr, in_rows_avail, - main->buffer, &main->rowgroup_ctr, - (JDIMENSION) DCTSIZE); - - /* If we don't have a full iMCU row buffered, return to application for - * more data. Note that preprocessor will always pad to fill the iMCU row - * at the bottom of the image. - */ - if (main->rowgroup_ctr != DCTSIZE) - return; - - /* Send the completed row to the compressor */ - if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { - /* If compressor did not consume the whole row, then we must need to - * suspend processing and return to the application. In this situation - * we pretend we didn't yet consume the last input row; otherwise, if - * it happened to be the last row of the image, the application would - * think we were done. - */ - if (! main->suspended) { - (*in_row_ctr)--; - main->suspended = TRUE; - } - return; - } - /* We did finish the row. Undo our little suspension hack if a previous - * call suspended; then mark the main buffer empty. - */ - if (main->suspended) { - (*in_row_ctr)++; - main->suspended = FALSE; - } - main->rowgroup_ctr = 0; - main->cur_iMCU_row++; - } -} - - -#ifdef FULL_MAIN_BUFFER_SUPPORTED - -/* - * Process some data. - * This routine handles all of the modes that use a full-size buffer. - */ - -METHODDEF(void) -process_data_buffer_main (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci; - jpeg_component_info *compptr; - boolean writing = (main->pass_mode != JBUF_CRANK_DEST); - - while (main->cur_iMCU_row < cinfo->total_iMCU_rows) { - /* Realign the virtual buffers if at the start of an iMCU row. */ - if (main->rowgroup_ctr == 0) { - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - main->buffer[ci] = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, main->whole_image[ci], - main->cur_iMCU_row * (compptr->v_samp_factor * DCTSIZE), - (JDIMENSION) (compptr->v_samp_factor * DCTSIZE), writing); - } - /* In a read pass, pretend we just read some source data. */ - if (! writing) { - *in_row_ctr += cinfo->max_v_samp_factor * DCTSIZE; - main->rowgroup_ctr = DCTSIZE; - } - } - - /* If a write pass, read input data until the current iMCU row is full. */ - /* Note: preprocessor will pad if necessary to fill the last iMCU row. */ - if (writing) { - (*cinfo->prep->pre_process_data) (cinfo, - input_buf, in_row_ctr, in_rows_avail, - main->buffer, &main->rowgroup_ctr, - (JDIMENSION) DCTSIZE); - /* Return to application if we need more data to fill the iMCU row. */ - if (main->rowgroup_ctr < DCTSIZE) - return; - } - - /* Emit data, unless this is a sink-only pass. */ - if (main->pass_mode != JBUF_SAVE_SOURCE) { - if (! (*cinfo->coef->compress_data) (cinfo, main->buffer)) { - /* If compressor did not consume the whole row, then we must need to - * suspend processing and return to the application. In this situation - * we pretend we didn't yet consume the last input row; otherwise, if - * it happened to be the last row of the image, the application would - * think we were done. - */ - if (! main->suspended) { - (*in_row_ctr)--; - main->suspended = TRUE; - } - return; - } - /* We did finish the row. Undo our little suspension hack if a previous - * call suspended; then mark the main buffer empty. - */ - if (main->suspended) { - (*in_row_ctr)++; - main->suspended = FALSE; - } - } - - /* If get here, we are done with this iMCU row. Mark buffer empty. */ - main->rowgroup_ctr = 0; - main->cur_iMCU_row++; - } -} - -#endif /* FULL_MAIN_BUFFER_SUPPORTED */ - - -/* - * Initialize main buffer controller. - */ - -GLOBAL(void) -jinit_c_main_controller (j_compress_ptr cinfo, boolean need_full_buffer) -{ - my_main_ptr main; - int ci; - jpeg_component_info *compptr; - - main = (my_main_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_main_controller)); - cinfo->main = (struct jpeg_c_main_controller *) main; - main->pub.start_pass = start_pass_main; - - /* We don't need to create a buffer in raw-data mode. */ - if (cinfo->raw_data_in) - return; - - /* Create the buffer. It holds downsampled data, so each component - * may be of a different size. - */ - if (need_full_buffer) { -#ifdef FULL_MAIN_BUFFER_SUPPORTED - /* Allocate a full-image virtual array for each component */ - /* Note we pad the bottom to a multiple of the iMCU height */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - main->whole_image[ci] = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - compptr->width_in_blocks * DCTSIZE, - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor) * DCTSIZE, - (JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); - } -#else - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif - } else { -#ifdef FULL_MAIN_BUFFER_SUPPORTED - main->whole_image[0] = NULL; /* flag for no virtual arrays */ -#endif - /* Allocate a strip buffer for each component */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - main->buffer[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - compptr->width_in_blocks * DCTSIZE, - (JDIMENSION) (compptr->v_samp_factor * DCTSIZE)); - } - } -} diff --git a/oversampling/WDL/jpeglib/jcmarker.c b/oversampling/WDL/jpeglib/jcmarker.c deleted file mode 100644 index 3d1e6c6..0000000 --- a/oversampling/WDL/jpeglib/jcmarker.c +++ /dev/null @@ -1,664 +0,0 @@ -/* - * jcmarker.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to write JPEG datastream markers. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -typedef enum { /* JPEG marker codes */ - M_SOF0 = 0xc0, - M_SOF1 = 0xc1, - M_SOF2 = 0xc2, - M_SOF3 = 0xc3, - - M_SOF5 = 0xc5, - M_SOF6 = 0xc6, - M_SOF7 = 0xc7, - - M_JPG = 0xc8, - M_SOF9 = 0xc9, - M_SOF10 = 0xca, - M_SOF11 = 0xcb, - - M_SOF13 = 0xcd, - M_SOF14 = 0xce, - M_SOF15 = 0xcf, - - M_DHT = 0xc4, - - M_DAC = 0xcc, - - M_RST0 = 0xd0, - M_RST1 = 0xd1, - M_RST2 = 0xd2, - M_RST3 = 0xd3, - M_RST4 = 0xd4, - M_RST5 = 0xd5, - M_RST6 = 0xd6, - M_RST7 = 0xd7, - - M_SOI = 0xd8, - M_EOI = 0xd9, - M_SOS = 0xda, - M_DQT = 0xdb, - M_DNL = 0xdc, - M_DRI = 0xdd, - M_DHP = 0xde, - M_EXP = 0xdf, - - M_APP0 = 0xe0, - M_APP1 = 0xe1, - M_APP2 = 0xe2, - M_APP3 = 0xe3, - M_APP4 = 0xe4, - M_APP5 = 0xe5, - M_APP6 = 0xe6, - M_APP7 = 0xe7, - M_APP8 = 0xe8, - M_APP9 = 0xe9, - M_APP10 = 0xea, - M_APP11 = 0xeb, - M_APP12 = 0xec, - M_APP13 = 0xed, - M_APP14 = 0xee, - M_APP15 = 0xef, - - M_JPG0 = 0xf0, - M_JPG13 = 0xfd, - M_COM = 0xfe, - - M_TEM = 0x01, - - M_ERROR = 0x100 -} JPEG_MARKER; - - -/* Private state */ - -typedef struct { - struct jpeg_marker_writer pub; /* public fields */ - - unsigned int last_restart_interval; /* last DRI value emitted; 0 after SOI */ -} my_marker_writer; - -typedef my_marker_writer * my_marker_ptr; - - -/* - * Basic output routines. - * - * Note that we do not support suspension while writing a marker. - * Therefore, an application using suspension must ensure that there is - * enough buffer space for the initial markers (typ. 600-700 bytes) before - * calling jpeg_start_compress, and enough space to write the trailing EOI - * (a few bytes) before calling jpeg_finish_compress. Multipass compression - * modes are not supported at all with suspension, so those two are the only - * points where markers will be written. - */ - -LOCAL(void) -emit_byte (j_compress_ptr cinfo, int val) -/* Emit a byte */ -{ - struct jpeg_destination_mgr * dest = cinfo->dest; - - *(dest->next_output_byte)++ = (JOCTET) val; - if (--dest->free_in_buffer == 0) { - if (! (*dest->empty_output_buffer) (cinfo)) - ERREXIT(cinfo, JERR_CANT_SUSPEND); - } -} - - -LOCAL(void) -emit_marker (j_compress_ptr cinfo, JPEG_MARKER mark) -/* Emit a marker code */ -{ - emit_byte(cinfo, 0xFF); - emit_byte(cinfo, (int) mark); -} - - -LOCAL(void) -emit_2bytes (j_compress_ptr cinfo, int value) -/* Emit a 2-byte integer; these are always MSB first in JPEG files */ -{ - emit_byte(cinfo, (value >> 8) & 0xFF); - emit_byte(cinfo, value & 0xFF); -} - - -/* - * Routines to write specific marker types. - */ - -LOCAL(int) -emit_dqt (j_compress_ptr cinfo, int index) -/* Emit a DQT marker */ -/* Returns the precision used (0 = 8bits, 1 = 16bits) for baseline checking */ -{ - JQUANT_TBL * qtbl = cinfo->quant_tbl_ptrs[index]; - int prec; - int i; - - if (qtbl == NULL) - ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, index); - - prec = 0; - for (i = 0; i < DCTSIZE2; i++) { - if (qtbl->quantval[i] > 255) - prec = 1; - } - - if (! qtbl->sent_table) { - emit_marker(cinfo, M_DQT); - - emit_2bytes(cinfo, prec ? DCTSIZE2*2 + 1 + 2 : DCTSIZE2 + 1 + 2); - - emit_byte(cinfo, index + (prec<<4)); - - for (i = 0; i < DCTSIZE2; i++) { - /* The table entries must be emitted in zigzag order. */ - unsigned int qval = qtbl->quantval[jpeg_natural_order[i]]; - if (prec) - emit_byte(cinfo, (int) (qval >> 8)); - emit_byte(cinfo, (int) (qval & 0xFF)); - } - - qtbl->sent_table = TRUE; - } - - return prec; -} - - -LOCAL(void) -emit_dht (j_compress_ptr cinfo, int index, boolean is_ac) -/* Emit a DHT marker */ -{ - JHUFF_TBL * htbl; - int length, i; - - if (is_ac) { - htbl = cinfo->ac_huff_tbl_ptrs[index]; - index += 0x10; /* output index has AC bit set */ - } else { - htbl = cinfo->dc_huff_tbl_ptrs[index]; - } - - if (htbl == NULL) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, index); - - if (! htbl->sent_table) { - emit_marker(cinfo, M_DHT); - - length = 0; - for (i = 1; i <= 16; i++) - length += htbl->bits[i]; - - emit_2bytes(cinfo, length + 2 + 1 + 16); - emit_byte(cinfo, index); - - for (i = 1; i <= 16; i++) - emit_byte(cinfo, htbl->bits[i]); - - for (i = 0; i < length; i++) - emit_byte(cinfo, htbl->huffval[i]); - - htbl->sent_table = TRUE; - } -} - - -LOCAL(void) -emit_dac (j_compress_ptr cinfo) -/* Emit a DAC marker */ -/* Since the useful info is so small, we want to emit all the tables in */ -/* one DAC marker. Therefore this routine does its own scan of the table. */ -{ -#ifdef C_ARITH_CODING_SUPPORTED - char dc_in_use[NUM_ARITH_TBLS]; - char ac_in_use[NUM_ARITH_TBLS]; - int length, i; - jpeg_component_info *compptr; - - for (i = 0; i < NUM_ARITH_TBLS; i++) - dc_in_use[i] = ac_in_use[i] = 0; - - for (i = 0; i < cinfo->comps_in_scan; i++) { - compptr = cinfo->cur_comp_info[i]; - dc_in_use[compptr->dc_tbl_no] = 1; - ac_in_use[compptr->ac_tbl_no] = 1; - } - - length = 0; - for (i = 0; i < NUM_ARITH_TBLS; i++) - length += dc_in_use[i] + ac_in_use[i]; - - emit_marker(cinfo, M_DAC); - - emit_2bytes(cinfo, length*2 + 2); - - for (i = 0; i < NUM_ARITH_TBLS; i++) { - if (dc_in_use[i]) { - emit_byte(cinfo, i); - emit_byte(cinfo, cinfo->arith_dc_L[i] + (cinfo->arith_dc_U[i]<<4)); - } - if (ac_in_use[i]) { - emit_byte(cinfo, i + 0x10); - emit_byte(cinfo, cinfo->arith_ac_K[i]); - } - } -#endif /* C_ARITH_CODING_SUPPORTED */ -} - - -LOCAL(void) -emit_dri (j_compress_ptr cinfo) -/* Emit a DRI marker */ -{ - emit_marker(cinfo, M_DRI); - - emit_2bytes(cinfo, 4); /* fixed length */ - - emit_2bytes(cinfo, (int) cinfo->restart_interval); -} - - -LOCAL(void) -emit_sof (j_compress_ptr cinfo, JPEG_MARKER code) -/* Emit a SOF marker */ -{ - int ci; - jpeg_component_info *compptr; - - emit_marker(cinfo, code); - - emit_2bytes(cinfo, 3 * cinfo->num_components + 2 + 5 + 1); /* length */ - - /* Make sure image isn't bigger than SOF field can handle */ - if ((long) cinfo->image_height > 65535L || - (long) cinfo->image_width > 65535L) - ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) 65535); - - emit_byte(cinfo, cinfo->data_precision); - emit_2bytes(cinfo, (int) cinfo->image_height); - emit_2bytes(cinfo, (int) cinfo->image_width); - - emit_byte(cinfo, cinfo->num_components); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - emit_byte(cinfo, compptr->component_id); - emit_byte(cinfo, (compptr->h_samp_factor << 4) + compptr->v_samp_factor); - emit_byte(cinfo, compptr->quant_tbl_no); - } -} - - -LOCAL(void) -emit_sos (j_compress_ptr cinfo) -/* Emit a SOS marker */ -{ - int i, td, ta; - jpeg_component_info *compptr; - - emit_marker(cinfo, M_SOS); - - emit_2bytes(cinfo, 2 * cinfo->comps_in_scan + 2 + 1 + 3); /* length */ - - emit_byte(cinfo, cinfo->comps_in_scan); - - for (i = 0; i < cinfo->comps_in_scan; i++) { - compptr = cinfo->cur_comp_info[i]; - emit_byte(cinfo, compptr->component_id); - td = compptr->dc_tbl_no; - ta = compptr->ac_tbl_no; - if (cinfo->progressive_mode) { - /* Progressive mode: only DC or only AC tables are used in one scan; - * furthermore, Huffman coding of DC refinement uses no table at all. - * We emit 0 for unused field(s); this is recommended by the P&M text - * but does not seem to be specified in the standard. - */ - if (cinfo->Ss == 0) { - ta = 0; /* DC scan */ - if (cinfo->Ah != 0 && !cinfo->arith_code) - td = 0; /* no DC table either */ - } else { - td = 0; /* AC scan */ - } - } - emit_byte(cinfo, (td << 4) + ta); - } - - emit_byte(cinfo, cinfo->Ss); - emit_byte(cinfo, cinfo->Se); - emit_byte(cinfo, (cinfo->Ah << 4) + cinfo->Al); -} - - -LOCAL(void) -emit_jfif_app0 (j_compress_ptr cinfo) -/* Emit a JFIF-compliant APP0 marker */ -{ - /* - * Length of APP0 block (2 bytes) - * Block ID (4 bytes - ASCII "JFIF") - * Zero byte (1 byte to terminate the ID string) - * Version Major, Minor (2 bytes - major first) - * Units (1 byte - 0x00 = none, 0x01 = inch, 0x02 = cm) - * Xdpu (2 bytes - dots per unit horizontal) - * Ydpu (2 bytes - dots per unit vertical) - * Thumbnail X size (1 byte) - * Thumbnail Y size (1 byte) - */ - - emit_marker(cinfo, M_APP0); - - emit_2bytes(cinfo, 2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); /* length */ - - emit_byte(cinfo, 0x4A); /* Identifier: ASCII "JFIF" */ - emit_byte(cinfo, 0x46); - emit_byte(cinfo, 0x49); - emit_byte(cinfo, 0x46); - emit_byte(cinfo, 0); - emit_byte(cinfo, cinfo->JFIF_major_version); /* Version fields */ - emit_byte(cinfo, cinfo->JFIF_minor_version); - emit_byte(cinfo, cinfo->density_unit); /* Pixel size information */ - emit_2bytes(cinfo, (int) cinfo->X_density); - emit_2bytes(cinfo, (int) cinfo->Y_density); - emit_byte(cinfo, 0); /* No thumbnail image */ - emit_byte(cinfo, 0); -} - - -LOCAL(void) -emit_adobe_app14 (j_compress_ptr cinfo) -/* Emit an Adobe APP14 marker */ -{ - /* - * Length of APP14 block (2 bytes) - * Block ID (5 bytes - ASCII "Adobe") - * Version Number (2 bytes - currently 100) - * Flags0 (2 bytes - currently 0) - * Flags1 (2 bytes - currently 0) - * Color transform (1 byte) - * - * Although Adobe TN 5116 mentions Version = 101, all the Adobe files - * now in circulation seem to use Version = 100, so that's what we write. - * - * We write the color transform byte as 1 if the JPEG color space is - * YCbCr, 2 if it's YCCK, 0 otherwise. Adobe's definition has to do with - * whether the encoder performed a transformation, which is pretty useless. - */ - - emit_marker(cinfo, M_APP14); - - emit_2bytes(cinfo, 2 + 5 + 2 + 2 + 2 + 1); /* length */ - - emit_byte(cinfo, 0x41); /* Identifier: ASCII "Adobe" */ - emit_byte(cinfo, 0x64); - emit_byte(cinfo, 0x6F); - emit_byte(cinfo, 0x62); - emit_byte(cinfo, 0x65); - emit_2bytes(cinfo, 100); /* Version */ - emit_2bytes(cinfo, 0); /* Flags0 */ - emit_2bytes(cinfo, 0); /* Flags1 */ - switch (cinfo->jpeg_color_space) { - case JCS_YCbCr: - emit_byte(cinfo, 1); /* Color transform = 1 */ - break; - case JCS_YCCK: - emit_byte(cinfo, 2); /* Color transform = 2 */ - break; - default: - emit_byte(cinfo, 0); /* Color transform = 0 */ - break; - } -} - - -/* - * These routines allow writing an arbitrary marker with parameters. - * The only intended use is to emit COM or APPn markers after calling - * write_file_header and before calling write_frame_header. - * Other uses are not guaranteed to produce desirable results. - * Counting the parameter bytes properly is the caller's responsibility. - */ - -METHODDEF(void) -write_marker_header (j_compress_ptr cinfo, int marker, unsigned int datalen) -/* Emit an arbitrary marker header */ -{ - if (datalen > (unsigned int) 65533) /* safety check */ - ERREXIT(cinfo, JERR_BAD_LENGTH); - - emit_marker(cinfo, (JPEG_MARKER) marker); - - emit_2bytes(cinfo, (int) (datalen + 2)); /* total length */ -} - -METHODDEF(void) -write_marker_byte (j_compress_ptr cinfo, int val) -/* Emit one byte of marker parameters following write_marker_header */ -{ - emit_byte(cinfo, val); -} - - -/* - * Write datastream header. - * This consists of an SOI and optional APPn markers. - * We recommend use of the JFIF marker, but not the Adobe marker, - * when using YCbCr or grayscale data. The JFIF marker should NOT - * be used for any other JPEG colorspace. The Adobe marker is helpful - * to distinguish RGB, CMYK, and YCCK colorspaces. - * Note that an application can write additional header markers after - * jpeg_start_compress returns. - */ - -METHODDEF(void) -write_file_header (j_compress_ptr cinfo) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - - emit_marker(cinfo, M_SOI); /* first the SOI */ - - /* SOI is defined to reset restart interval to 0 */ - marker->last_restart_interval = 0; - - if (cinfo->write_JFIF_header) /* next an optional JFIF APP0 */ - emit_jfif_app0(cinfo); - if (cinfo->write_Adobe_marker) /* next an optional Adobe APP14 */ - emit_adobe_app14(cinfo); -} - - -/* - * Write frame header. - * This consists of DQT and SOFn markers. - * Note that we do not emit the SOF until we have emitted the DQT(s). - * This avoids compatibility problems with incorrect implementations that - * try to error-check the quant table numbers as soon as they see the SOF. - */ - -METHODDEF(void) -write_frame_header (j_compress_ptr cinfo) -{ - int ci, prec; - boolean is_baseline; - jpeg_component_info *compptr; - - /* Emit DQT for each quantization table. - * Note that emit_dqt() suppresses any duplicate tables. - */ - prec = 0; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - prec += emit_dqt(cinfo, compptr->quant_tbl_no); - } - /* now prec is nonzero iff there are any 16-bit quant tables. */ - - /* Check for a non-baseline specification. - * Note we assume that Huffman table numbers won't be changed later. - */ - if (cinfo->arith_code || cinfo->progressive_mode || - cinfo->data_precision != 8) { - is_baseline = FALSE; - } else { - is_baseline = TRUE; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->dc_tbl_no > 1 || compptr->ac_tbl_no > 1) - is_baseline = FALSE; - } - if (prec && is_baseline) { - is_baseline = FALSE; - /* If it's baseline except for quantizer size, warn the user */ - TRACEMS(cinfo, 0, JTRC_16BIT_TABLES); - } - } - - /* Emit the proper SOF marker */ - if (cinfo->arith_code) { - emit_sof(cinfo, M_SOF9); /* SOF code for arithmetic coding */ - } else { - if (cinfo->progressive_mode) - emit_sof(cinfo, M_SOF2); /* SOF code for progressive Huffman */ - else if (is_baseline) - emit_sof(cinfo, M_SOF0); /* SOF code for baseline implementation */ - else - emit_sof(cinfo, M_SOF1); /* SOF code for non-baseline Huffman file */ - } -} - - -/* - * Write scan header. - * This consists of DHT or DAC markers, optional DRI, and SOS. - * Compressed data will be written following the SOS. - */ - -METHODDEF(void) -write_scan_header (j_compress_ptr cinfo) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - int i; - jpeg_component_info *compptr; - - if (cinfo->arith_code) { - /* Emit arith conditioning info. We may have some duplication - * if the file has multiple scans, but it's so small it's hardly - * worth worrying about. - */ - emit_dac(cinfo); - } else { - /* Emit Huffman tables. - * Note that emit_dht() suppresses any duplicate tables. - */ - for (i = 0; i < cinfo->comps_in_scan; i++) { - compptr = cinfo->cur_comp_info[i]; - if (cinfo->progressive_mode) { - /* Progressive mode: only DC or only AC tables are used in one scan */ - if (cinfo->Ss == 0) { - if (cinfo->Ah == 0) /* DC needs no table for refinement scan */ - emit_dht(cinfo, compptr->dc_tbl_no, FALSE); - } else { - emit_dht(cinfo, compptr->ac_tbl_no, TRUE); - } - } else { - /* Sequential mode: need both DC and AC tables */ - emit_dht(cinfo, compptr->dc_tbl_no, FALSE); - emit_dht(cinfo, compptr->ac_tbl_no, TRUE); - } - } - } - - /* Emit DRI if required --- note that DRI value could change for each scan. - * We avoid wasting space with unnecessary DRIs, however. - */ - if (cinfo->restart_interval != marker->last_restart_interval) { - emit_dri(cinfo); - marker->last_restart_interval = cinfo->restart_interval; - } - - emit_sos(cinfo); -} - - -/* - * Write datastream trailer. - */ - -METHODDEF(void) -write_file_trailer (j_compress_ptr cinfo) -{ - emit_marker(cinfo, M_EOI); -} - - -/* - * Write an abbreviated table-specification datastream. - * This consists of SOI, DQT and DHT tables, and EOI. - * Any table that is defined and not marked sent_table = TRUE will be - * emitted. Note that all tables will be marked sent_table = TRUE at exit. - */ - -METHODDEF(void) -write_tables_only (j_compress_ptr cinfo) -{ - int i; - - emit_marker(cinfo, M_SOI); - - for (i = 0; i < NUM_QUANT_TBLS; i++) { - if (cinfo->quant_tbl_ptrs[i] != NULL) - (void) emit_dqt(cinfo, i); - } - - if (! cinfo->arith_code) { - for (i = 0; i < NUM_HUFF_TBLS; i++) { - if (cinfo->dc_huff_tbl_ptrs[i] != NULL) - emit_dht(cinfo, i, FALSE); - if (cinfo->ac_huff_tbl_ptrs[i] != NULL) - emit_dht(cinfo, i, TRUE); - } - } - - emit_marker(cinfo, M_EOI); -} - - -/* - * Initialize the marker writer module. - */ - -GLOBAL(void) -jinit_marker_writer (j_compress_ptr cinfo) -{ - my_marker_ptr marker; - - /* Create the subobject */ - marker = (my_marker_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_marker_writer)); - cinfo->marker = (struct jpeg_marker_writer *) marker; - /* Initialize method pointers */ - marker->pub.write_file_header = write_file_header; - marker->pub.write_frame_header = write_frame_header; - marker->pub.write_scan_header = write_scan_header; - marker->pub.write_file_trailer = write_file_trailer; - marker->pub.write_tables_only = write_tables_only; - marker->pub.write_marker_header = write_marker_header; - marker->pub.write_marker_byte = write_marker_byte; - /* Initialize private state */ - marker->last_restart_interval = 0; -} diff --git a/oversampling/WDL/jpeglib/jcmaster.c b/oversampling/WDL/jpeglib/jcmaster.c deleted file mode 100644 index aab4020..0000000 --- a/oversampling/WDL/jpeglib/jcmaster.c +++ /dev/null @@ -1,590 +0,0 @@ -/* - * jcmaster.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains master control logic for the JPEG compressor. - * These routines are concerned with parameter validation, initial setup, - * and inter-pass control (determining the number of passes and the work - * to be done in each pass). - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private state */ - -typedef enum { - main_pass, /* input data, also do first output step */ - huff_opt_pass, /* Huffman code optimization pass */ - output_pass /* data output pass */ -} c_pass_type; - -typedef struct { - struct jpeg_comp_master pub; /* public fields */ - - c_pass_type pass_type; /* the type of the current pass */ - - int pass_number; /* # of passes completed */ - int total_passes; /* total # of passes needed */ - - int scan_number; /* current index in scan_info[] */ -} my_comp_master; - -typedef my_comp_master * my_master_ptr; - - -/* - * Support routines that do various essential calculations. - */ - -LOCAL(void) -initial_setup (j_compress_ptr cinfo) -/* Do computations that are needed before master selection phase */ -{ - int ci; - jpeg_component_info *compptr; - long samplesperrow; - JDIMENSION jd_samplesperrow; - - /* Sanity check on image dimensions */ - if (cinfo->image_height <= 0 || cinfo->image_width <= 0 - || cinfo->num_components <= 0 || cinfo->input_components <= 0) - ERREXIT(cinfo, JERR_EMPTY_IMAGE); - - /* Make sure image isn't bigger than I can handle */ - if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || - (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) - ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); - - /* Width of an input scanline must be representable as JDIMENSION. */ - samplesperrow = (long) cinfo->image_width * (long) cinfo->input_components; - jd_samplesperrow = (JDIMENSION) samplesperrow; - if ((long) jd_samplesperrow != samplesperrow) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - - /* For now, precision must match compiled-in value... */ - if (cinfo->data_precision != BITS_IN_JSAMPLE) - ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); - - /* Check that number of components won't exceed internal array sizes */ - if (cinfo->num_components > MAX_COMPONENTS) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPONENTS); - - /* Compute maximum sampling factors; check factor validity */ - cinfo->max_h_samp_factor = 1; - cinfo->max_v_samp_factor = 1; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || - compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) - ERREXIT(cinfo, JERR_BAD_SAMPLING); - cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, - compptr->h_samp_factor); - cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, - compptr->v_samp_factor); - } - - /* Compute dimensions of components */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Fill in the correct component_index value; don't rely on application */ - compptr->component_index = ci; - /* For compression, we never do DCT scaling. */ - compptr->DCT_scaled_size = DCTSIZE; - /* Size in DCT blocks */ - compptr->width_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) (cinfo->max_h_samp_factor * DCTSIZE)); - compptr->height_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) (cinfo->max_v_samp_factor * DCTSIZE)); - /* Size in samples */ - compptr->downsampled_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) cinfo->max_h_samp_factor); - compptr->downsampled_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) cinfo->max_v_samp_factor); - /* Mark component needed (this flag isn't actually used for compression) */ - compptr->component_needed = TRUE; - } - - /* Compute number of fully interleaved MCU rows (number of times that - * main controller will call coefficient controller). - */ - cinfo->total_iMCU_rows = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); -} - - -#ifdef C_MULTISCAN_FILES_SUPPORTED - -LOCAL(void) -validate_script (j_compress_ptr cinfo) -/* Verify that the scan script in cinfo->scan_info[] is valid; also - * determine whether it uses progressive JPEG, and set cinfo->progressive_mode. - */ -{ - const jpeg_scan_info * scanptr; - int scanno, ncomps, ci, coefi, thisi; - int Ss, Se, Ah, Al; - boolean component_sent[MAX_COMPONENTS]; -#ifdef C_PROGRESSIVE_SUPPORTED - int * last_bitpos_ptr; - int last_bitpos[MAX_COMPONENTS][DCTSIZE2]; - /* -1 until that coefficient has been seen; then last Al for it */ -#endif - - if (cinfo->num_scans <= 0) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0); - - /* For sequential JPEG, all scans must have Ss=0, Se=DCTSIZE2-1; - * for progressive JPEG, no scan can have this. - */ - scanptr = cinfo->scan_info; - if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2-1) { -#ifdef C_PROGRESSIVE_SUPPORTED - cinfo->progressive_mode = TRUE; - last_bitpos_ptr = & last_bitpos[0][0]; - for (ci = 0; ci < cinfo->num_components; ci++) - for (coefi = 0; coefi < DCTSIZE2; coefi++) - *last_bitpos_ptr++ = -1; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - cinfo->progressive_mode = FALSE; - for (ci = 0; ci < cinfo->num_components; ci++) - component_sent[ci] = FALSE; - } - - for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) { - /* Validate component indexes */ - ncomps = scanptr->comps_in_scan; - if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, ncomps, MAX_COMPS_IN_SCAN); - for (ci = 0; ci < ncomps; ci++) { - thisi = scanptr->component_index[ci]; - if (thisi < 0 || thisi >= cinfo->num_components) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); - /* Components must appear in SOF order within each scan */ - if (ci > 0 && thisi <= scanptr->component_index[ci-1]) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); - } - /* Validate progression parameters */ - Ss = scanptr->Ss; - Se = scanptr->Se; - Ah = scanptr->Ah; - Al = scanptr->Al; - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - /* The JPEG spec simply gives the ranges 0..13 for Ah and Al, but that - * seems wrong: the upper bound ought to depend on data precision. - * Perhaps they really meant 0..N+1 for N-bit precision. - * Here we allow 0..10 for 8-bit data; Al larger than 10 results in - * out-of-range reconstructed DC values during the first DC scan, - * which might cause problems for some decoders. - */ -#if BITS_IN_JSAMPLE == 8 -#define MAX_AH_AL 10 -#else -#define MAX_AH_AL 13 -#endif - if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 || - Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - if (Ss == 0) { - if (Se != 0) /* DC and AC together not OK */ - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } else { - if (ncomps != 1) /* AC scans must be for only one component */ - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } - for (ci = 0; ci < ncomps; ci++) { - last_bitpos_ptr = & last_bitpos[scanptr->component_index[ci]][0]; - if (Ss != 0 && last_bitpos_ptr[0] < 0) /* AC without prior DC scan */ - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - for (coefi = Ss; coefi <= Se; coefi++) { - if (last_bitpos_ptr[coefi] < 0) { - /* first scan of this coefficient */ - if (Ah != 0) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } else { - /* not first scan */ - if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - } - last_bitpos_ptr[coefi] = Al; - } - } -#endif - } else { - /* For sequential JPEG, all progression parameters must be these: */ - if (Ss != 0 || Se != DCTSIZE2-1 || Ah != 0 || Al != 0) - ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno); - /* Make sure components are not sent twice */ - for (ci = 0; ci < ncomps; ci++) { - thisi = scanptr->component_index[ci]; - if (component_sent[thisi]) - ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); - component_sent[thisi] = TRUE; - } - } - } - - /* Now verify that everything got sent. */ - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - /* For progressive mode, we only check that at least some DC data - * got sent for each component; the spec does not require that all bits - * of all coefficients be transmitted. Would it be wiser to enforce - * transmission of all coefficient bits?? - */ - for (ci = 0; ci < cinfo->num_components; ci++) { - if (last_bitpos[ci][0] < 0) - ERREXIT(cinfo, JERR_MISSING_DATA); - } -#endif - } else { - for (ci = 0; ci < cinfo->num_components; ci++) { - if (! component_sent[ci]) - ERREXIT(cinfo, JERR_MISSING_DATA); - } - } -} - -#endif /* C_MULTISCAN_FILES_SUPPORTED */ - - -LOCAL(void) -select_scan_parameters (j_compress_ptr cinfo) -/* Set up the scan parameters for the current scan */ -{ - int ci; - -#ifdef C_MULTISCAN_FILES_SUPPORTED - if (cinfo->scan_info != NULL) { - /* Prepare for current scan --- the script is already validated */ - my_master_ptr master = (my_master_ptr) cinfo->master; - const jpeg_scan_info * scanptr = cinfo->scan_info + master->scan_number; - - cinfo->comps_in_scan = scanptr->comps_in_scan; - for (ci = 0; ci < scanptr->comps_in_scan; ci++) { - cinfo->cur_comp_info[ci] = - &cinfo->comp_info[scanptr->component_index[ci]]; - } - cinfo->Ss = scanptr->Ss; - cinfo->Se = scanptr->Se; - cinfo->Ah = scanptr->Ah; - cinfo->Al = scanptr->Al; - } - else -#endif - { - /* Prepare for single sequential-JPEG scan containing all components */ - if (cinfo->num_components > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPS_IN_SCAN); - cinfo->comps_in_scan = cinfo->num_components; - for (ci = 0; ci < cinfo->num_components; ci++) { - cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci]; - } - cinfo->Ss = 0; - cinfo->Se = DCTSIZE2-1; - cinfo->Ah = 0; - cinfo->Al = 0; - } -} - - -LOCAL(void) -per_scan_setup (j_compress_ptr cinfo) -/* Do computations that are needed before processing a JPEG scan */ -/* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */ -{ - int ci, mcublks, tmp; - jpeg_component_info *compptr; - - if (cinfo->comps_in_scan == 1) { - - /* Noninterleaved (single-component) scan */ - compptr = cinfo->cur_comp_info[0]; - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = compptr->width_in_blocks; - cinfo->MCU_rows_in_scan = compptr->height_in_blocks; - - /* For noninterleaved scan, always one block per MCU */ - compptr->MCU_width = 1; - compptr->MCU_height = 1; - compptr->MCU_blocks = 1; - compptr->MCU_sample_width = DCTSIZE; - compptr->last_col_width = 1; - /* For noninterleaved scans, it is convenient to define last_row_height - * as the number of block rows present in the last iMCU row. - */ - tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (tmp == 0) tmp = compptr->v_samp_factor; - compptr->last_row_height = tmp; - - /* Prepare array describing MCU composition */ - cinfo->blocks_in_MCU = 1; - cinfo->MCU_membership[0] = 0; - - } else { - - /* Interleaved (multi-component) scan */ - if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, - MAX_COMPS_IN_SCAN); - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, - (long) (cinfo->max_h_samp_factor*DCTSIZE)); - cinfo->MCU_rows_in_scan = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); - - cinfo->blocks_in_MCU = 0; - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Sampling factors give # of blocks of component in each MCU */ - compptr->MCU_width = compptr->h_samp_factor; - compptr->MCU_height = compptr->v_samp_factor; - compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; - compptr->MCU_sample_width = compptr->MCU_width * DCTSIZE; - /* Figure number of non-dummy blocks in last MCU column & row */ - tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); - if (tmp == 0) tmp = compptr->MCU_width; - compptr->last_col_width = tmp; - tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); - if (tmp == 0) tmp = compptr->MCU_height; - compptr->last_row_height = tmp; - /* Prepare array describing MCU composition */ - mcublks = compptr->MCU_blocks; - if (cinfo->blocks_in_MCU + mcublks > C_MAX_BLOCKS_IN_MCU) - ERREXIT(cinfo, JERR_BAD_MCU_SIZE); - while (mcublks-- > 0) { - cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; - } - } - - } - - /* Convert restart specified in rows to actual MCU count. */ - /* Note that count must fit in 16 bits, so we provide limiting. */ - if (cinfo->restart_in_rows > 0) { - long nominal = (long) cinfo->restart_in_rows * (long) cinfo->MCUs_per_row; - cinfo->restart_interval = (unsigned int) MIN(nominal, 65535L); - } -} - - -/* - * Per-pass setup. - * This is called at the beginning of each pass. We determine which modules - * will be active during this pass and give them appropriate start_pass calls. - * We also set is_last_pass to indicate whether any more passes will be - * required. - */ - -METHODDEF(void) -prepare_for_pass (j_compress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - switch (master->pass_type) { - case main_pass: - /* Initial pass: will collect input data, and do either Huffman - * optimization or data output for the first scan. - */ - select_scan_parameters(cinfo); - per_scan_setup(cinfo); - if (! cinfo->raw_data_in) { - (*cinfo->cconvert->start_pass) (cinfo); - (*cinfo->downsample->start_pass) (cinfo); - (*cinfo->prep->start_pass) (cinfo, JBUF_PASS_THRU); - } - (*cinfo->fdct->start_pass) (cinfo); - (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding); - (*cinfo->coef->start_pass) (cinfo, - (master->total_passes > 1 ? - JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); - (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); - if (cinfo->optimize_coding) { - /* No immediate data output; postpone writing frame/scan headers */ - master->pub.call_pass_startup = FALSE; - } else { - /* Will write frame/scan headers at first jpeg_write_scanlines call */ - master->pub.call_pass_startup = TRUE; - } - break; -#ifdef ENTROPY_OPT_SUPPORTED - case huff_opt_pass: - /* Do Huffman optimization for a scan after the first one. */ - select_scan_parameters(cinfo); - per_scan_setup(cinfo); - if (cinfo->Ss != 0 || cinfo->Ah == 0 || cinfo->arith_code) { - (*cinfo->entropy->start_pass) (cinfo, TRUE); - (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); - master->pub.call_pass_startup = FALSE; - break; - } - /* Special case: Huffman DC refinement scans need no Huffman table - * and therefore we can skip the optimization pass for them. - */ - master->pass_type = output_pass; - master->pass_number++; - /*FALLTHROUGH*/ -#endif - case output_pass: - /* Do a data-output pass. */ - /* We need not repeat per-scan setup if prior optimization pass did it. */ - if (! cinfo->optimize_coding) { - select_scan_parameters(cinfo); - per_scan_setup(cinfo); - } - (*cinfo->entropy->start_pass) (cinfo, FALSE); - (*cinfo->coef->start_pass) (cinfo, JBUF_CRANK_DEST); - /* We emit frame/scan headers now */ - if (master->scan_number == 0) - (*cinfo->marker->write_frame_header) (cinfo); - (*cinfo->marker->write_scan_header) (cinfo); - master->pub.call_pass_startup = FALSE; - break; - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - } - - master->pub.is_last_pass = (master->pass_number == master->total_passes-1); - - /* Set up progress monitor's pass info if present */ - if (cinfo->progress != NULL) { - cinfo->progress->completed_passes = master->pass_number; - cinfo->progress->total_passes = master->total_passes; - } -} - - -/* - * Special start-of-pass hook. - * This is called by jpeg_write_scanlines if call_pass_startup is TRUE. - * In single-pass processing, we need this hook because we don't want to - * write frame/scan headers during jpeg_start_compress; we want to let the - * application write COM markers etc. between jpeg_start_compress and the - * jpeg_write_scanlines loop. - * In multi-pass processing, this routine is not used. - */ - -METHODDEF(void) -pass_startup (j_compress_ptr cinfo) -{ - cinfo->master->call_pass_startup = FALSE; /* reset flag so call only once */ - - (*cinfo->marker->write_frame_header) (cinfo); - (*cinfo->marker->write_scan_header) (cinfo); -} - - -/* - * Finish up at end of pass. - */ - -METHODDEF(void) -finish_pass_master (j_compress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - /* The entropy coder always needs an end-of-pass call, - * either to analyze statistics or to flush its output buffer. - */ - (*cinfo->entropy->finish_pass) (cinfo); - - /* Update state for next pass */ - switch (master->pass_type) { - case main_pass: - /* next pass is either output of scan 0 (after optimization) - * or output of scan 1 (if no optimization). - */ - master->pass_type = output_pass; - if (! cinfo->optimize_coding) - master->scan_number++; - break; - case huff_opt_pass: - /* next pass is always output of current scan */ - master->pass_type = output_pass; - break; - case output_pass: - /* next pass is either optimization or output of next scan */ - if (cinfo->optimize_coding) - master->pass_type = huff_opt_pass; - master->scan_number++; - break; - } - - master->pass_number++; -} - - -/* - * Initialize master compression control. - */ - -GLOBAL(void) -jinit_c_master_control (j_compress_ptr cinfo, boolean transcode_only) -{ - my_master_ptr master; - - master = (my_master_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_comp_master)); - cinfo->master = (struct jpeg_comp_master *) master; - master->pub.prepare_for_pass = prepare_for_pass; - master->pub.pass_startup = pass_startup; - master->pub.finish_pass = finish_pass_master; - master->pub.is_last_pass = FALSE; - - /* Validate parameters, determine derived values */ - initial_setup(cinfo); - - if (cinfo->scan_info != NULL) { -#ifdef C_MULTISCAN_FILES_SUPPORTED - validate_script(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - cinfo->progressive_mode = FALSE; - cinfo->num_scans = 1; - } - - if (cinfo->progressive_mode) /* TEMPORARY HACK ??? */ - cinfo->optimize_coding = TRUE; /* assume default tables no good for progressive mode */ - - /* Initialize my private state */ - if (transcode_only) { - /* no main pass in transcoding */ - if (cinfo->optimize_coding) - master->pass_type = huff_opt_pass; - else - master->pass_type = output_pass; - } else { - /* for normal compression, first pass is always this type: */ - master->pass_type = main_pass; - } - master->scan_number = 0; - master->pass_number = 0; - if (cinfo->optimize_coding) - master->total_passes = cinfo->num_scans * 2; - else - master->total_passes = cinfo->num_scans; -} diff --git a/oversampling/WDL/jpeglib/jcomapi.c b/oversampling/WDL/jpeglib/jcomapi.c deleted file mode 100644 index 9b1fa75..0000000 --- a/oversampling/WDL/jpeglib/jcomapi.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * jcomapi.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface routines that are used for both - * compression and decompression. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Abort processing of a JPEG compression or decompression operation, - * but don't destroy the object itself. - * - * For this, we merely clean up all the nonpermanent memory pools. - * Note that temp files (virtual arrays) are not allowed to belong to - * the permanent pool, so we will be able to close all temp files here. - * Closing a data source or destination, if necessary, is the application's - * responsibility. - */ - -GLOBAL(void) -jpeg_abort (j_common_ptr cinfo) -{ - int pool; - - /* Do nothing if called on a not-initialized or destroyed JPEG object. */ - if (cinfo->mem == NULL) - return; - - /* Releasing pools in reverse order might help avoid fragmentation - * with some (brain-damaged) malloc libraries. - */ - for (pool = JPOOL_NUMPOOLS-1; pool > JPOOL_PERMANENT; pool--) { - (*cinfo->mem->free_pool) (cinfo, pool); - } - - /* Reset overall state for possible reuse of object */ - if (cinfo->is_decompressor) { - cinfo->global_state = DSTATE_START; - /* Try to keep application from accessing now-deleted marker list. - * A bit kludgy to do it here, but this is the most central place. - */ - ((j_decompress_ptr) cinfo)->marker_list = NULL; - } else { - cinfo->global_state = CSTATE_START; - } -} - - -/* - * Destruction of a JPEG object. - * - * Everything gets deallocated except the master jpeg_compress_struct itself - * and the error manager struct. Both of these are supplied by the application - * and must be freed, if necessary, by the application. (Often they are on - * the stack and so don't need to be freed anyway.) - * Closing a data source or destination, if necessary, is the application's - * responsibility. - */ - -GLOBAL(void) -jpeg_destroy (j_common_ptr cinfo) -{ - /* We need only tell the memory manager to release everything. */ - /* NB: mem pointer is NULL if memory mgr failed to initialize. */ - if (cinfo->mem != NULL) - (*cinfo->mem->self_destruct) (cinfo); - cinfo->mem = NULL; /* be safe if jpeg_destroy is called twice */ - cinfo->global_state = 0; /* mark it destroyed */ -} - - -/* - * Convenience routines for allocating quantization and Huffman tables. - * (Would jutils.c be a more reasonable place to put these?) - */ - -GLOBAL(JQUANT_TBL *) -jpeg_alloc_quant_table (j_common_ptr cinfo) -{ - JQUANT_TBL *tbl; - - tbl = (JQUANT_TBL *) - (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JQUANT_TBL)); - tbl->sent_table = FALSE; /* make sure this is false in any new table */ - return tbl; -} - - -GLOBAL(JHUFF_TBL *) -jpeg_alloc_huff_table (j_common_ptr cinfo) -{ - JHUFF_TBL *tbl; - - tbl = (JHUFF_TBL *) - (*cinfo->mem->alloc_small) (cinfo, JPOOL_PERMANENT, SIZEOF(JHUFF_TBL)); - tbl->sent_table = FALSE; /* make sure this is false in any new table */ - return tbl; -} diff --git a/oversampling/WDL/jpeglib/jconfig.h b/oversampling/WDL/jpeglib/jconfig.h deleted file mode 100644 index 1d1d6fd..0000000 --- a/oversampling/WDL/jpeglib/jconfig.h +++ /dev/null @@ -1,15 +0,0 @@ -#define HAVE_PROTOTYPES -#define HAVE_STDLIB_H -#define HAVE_UNSIGNED_SHORT -#define HAVE_UNSIGNED_CHAR -#ifndef _WIN32 -#define NEED_SYS_TYPES_H -#define HAVE_STDDEF_H -#else -#include -#define XMD_H -#undef FAR -#define HAVE_BOOLEAN -typedef short INT16; -#endif - diff --git a/oversampling/WDL/jpeglib/jcparam.c b/oversampling/WDL/jpeglib/jcparam.c deleted file mode 100644 index 6fc48f5..0000000 --- a/oversampling/WDL/jpeglib/jcparam.c +++ /dev/null @@ -1,610 +0,0 @@ -/* - * jcparam.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains optional default-setting code for the JPEG compressor. - * Applications do not have to use this file, but those that don't use it - * must know a lot more about the innards of the JPEG code. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Quantization table setup routines - */ - -GLOBAL(void) -jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, - const unsigned int *basic_table, - int scale_factor, boolean force_baseline) -/* Define a quantization table equal to the basic_table times - * a scale factor (given as a percentage). - * If force_baseline is TRUE, the computed quantization table entries - * are limited to 1..255 for JPEG baseline compatibility. - */ -{ - JQUANT_TBL ** qtblptr; - int i; - long temp; - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - if (which_tbl < 0 || which_tbl >= NUM_QUANT_TBLS) - ERREXIT1(cinfo, JERR_DQT_INDEX, which_tbl); - - qtblptr = & cinfo->quant_tbl_ptrs[which_tbl]; - - if (*qtblptr == NULL) - *qtblptr = jpeg_alloc_quant_table((j_common_ptr) cinfo); - - for (i = 0; i < DCTSIZE2; i++) { - temp = ((long) basic_table[i] * scale_factor + 50L) / 100L; - /* limit the values to the valid range */ - if (temp <= 0L) temp = 1L; - if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */ - if (force_baseline && temp > 255L) - temp = 255L; /* limit to baseline range if requested */ - (*qtblptr)->quantval[i] = (UINT16) temp; - } - - /* Initialize sent_table FALSE so table will be written to JPEG file. */ - (*qtblptr)->sent_table = FALSE; -} - - -GLOBAL(void) -jpeg_set_linear_quality (j_compress_ptr cinfo, int scale_factor, - boolean force_baseline) -/* Set or change the 'quality' (quantization) setting, using default tables - * and a straight percentage-scaling quality scale. In most cases it's better - * to use jpeg_set_quality (below); this entry point is provided for - * applications that insist on a linear percentage scaling. - */ -{ - /* These are the sample quantization tables given in JPEG spec section K.1. - * The spec says that the values given produce "good" quality, and - * when divided by 2, "very good" quality. - */ - static const unsigned int std_luminance_quant_tbl[DCTSIZE2] = { - 16, 11, 10, 16, 24, 40, 51, 61, - 12, 12, 14, 19, 26, 58, 60, 55, - 14, 13, 16, 24, 40, 57, 69, 56, - 14, 17, 22, 29, 51, 87, 80, 62, - 18, 22, 37, 56, 68, 109, 103, 77, - 24, 35, 55, 64, 81, 104, 113, 92, - 49, 64, 78, 87, 103, 121, 120, 101, - 72, 92, 95, 98, 112, 100, 103, 99 - }; - static const unsigned int std_chrominance_quant_tbl[DCTSIZE2] = { - 17, 18, 24, 47, 99, 99, 99, 99, - 18, 21, 26, 66, 99, 99, 99, 99, - 24, 26, 56, 99, 99, 99, 99, 99, - 47, 66, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99 - }; - - /* Set up two quantization tables using the specified scaling */ - jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl, - scale_factor, force_baseline); - jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl, - scale_factor, force_baseline); -} - - -GLOBAL(int) -jpeg_quality_scaling (int quality) -/* Convert a user-specified quality rating to a percentage scaling factor - * for an underlying quantization table, using our recommended scaling curve. - * The input 'quality' factor should be 0 (terrible) to 100 (very good). - */ -{ - /* Safety limit on quality factor. Convert 0 to 1 to avoid zero divide. */ - if (quality <= 0) quality = 1; - if (quality > 100) quality = 100; - - /* The basic table is used as-is (scaling 100) for a quality of 50. - * Qualities 50..100 are converted to scaling percentage 200 - 2*Q; - * note that at Q=100 the scaling is 0, which will cause jpeg_add_quant_table - * to make all the table entries 1 (hence, minimum quantization loss). - * Qualities 1..50 are converted to scaling percentage 5000/Q. - */ - if (quality < 50) - quality = 5000 / quality; - else - quality = 200 - quality*2; - - return quality; -} - - -GLOBAL(void) -jpeg_set_quality (j_compress_ptr cinfo, int quality, boolean force_baseline) -/* Set or change the 'quality' (quantization) setting, using default tables. - * This is the standard quality-adjusting entry point for typical user - * interfaces; only those who want detailed control over quantization tables - * would use the preceding three routines directly. - */ -{ - /* Convert user 0-100 rating to percentage scaling */ - quality = jpeg_quality_scaling(quality); - - /* Set up standard quality tables */ - jpeg_set_linear_quality(cinfo, quality, force_baseline); -} - - -/* - * Huffman table setup routines - */ - -LOCAL(void) -add_huff_table (j_compress_ptr cinfo, - JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val) -/* Define a Huffman table */ -{ - int nsymbols, len; - - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - - /* Copy the number-of-symbols-of-each-code-length counts */ - MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); - - /* Validate the counts. We do this here mainly so we can copy the right - * number of symbols from the val[] array, without risking marching off - * the end of memory. jchuff.c will do a more thorough test later. - */ - nsymbols = 0; - for (len = 1; len <= 16; len++) - nsymbols += bits[len]; - if (nsymbols < 1 || nsymbols > 256) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - - MEMCOPY((*htblptr)->huffval, val, nsymbols * SIZEOF(UINT8)); - - /* Initialize sent_table FALSE so table will be written to JPEG file. */ - (*htblptr)->sent_table = FALSE; -} - - -LOCAL(void) -std_huff_tables (j_compress_ptr cinfo) -/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */ -/* IMPORTANT: these are only valid for 8-bit data precision! */ -{ - static const UINT8 bits_dc_luminance[17] = - { /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; - static const UINT8 val_dc_luminance[] = - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; - - static const UINT8 bits_dc_chrominance[17] = - { /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; - static const UINT8 val_dc_chrominance[] = - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; - - static const UINT8 bits_ac_luminance[17] = - { /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; - static const UINT8 val_ac_luminance[] = - { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, - 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, - 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, - 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, - 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, - 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, - 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, - 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, - 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, - 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, - 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, - 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, - 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, - 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, - 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, - 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, - 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, - 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, - 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; - - static const UINT8 bits_ac_chrominance[17] = - { /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; - static const UINT8 val_ac_chrominance[] = - { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, - 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, - 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, - 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, - 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, - 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, - 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, - 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, - 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, - 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, - 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, - 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, - 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, - 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, - 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, - 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, - 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, - 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, - 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; - - add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[0], - bits_dc_luminance, val_dc_luminance); - add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[0], - bits_ac_luminance, val_ac_luminance); - add_huff_table(cinfo, &cinfo->dc_huff_tbl_ptrs[1], - bits_dc_chrominance, val_dc_chrominance); - add_huff_table(cinfo, &cinfo->ac_huff_tbl_ptrs[1], - bits_ac_chrominance, val_ac_chrominance); -} - - -/* - * Default parameter setup for compression. - * - * Applications that don't choose to use this routine must do their - * own setup of all these parameters. Alternately, you can call this - * to establish defaults and then alter parameters selectively. This - * is the recommended approach since, if we add any new parameters, - * your code will still work (they'll be set to reasonable defaults). - */ - -GLOBAL(void) -jpeg_set_defaults (j_compress_ptr cinfo) -{ - int i; - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* Allocate comp_info array large enough for maximum component count. - * Array is made permanent in case application wants to compress - * multiple images at same param settings. - */ - if (cinfo->comp_info == NULL) - cinfo->comp_info = (jpeg_component_info *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - MAX_COMPONENTS * SIZEOF(jpeg_component_info)); - - /* Initialize everything not dependent on the color space */ - - cinfo->data_precision = BITS_IN_JSAMPLE; - /* Set up two quantization tables using default quality of 75 */ - jpeg_set_quality(cinfo, 75, TRUE); - /* Set up two Huffman tables */ - std_huff_tables(cinfo); - - /* Initialize default arithmetic coding conditioning */ - for (i = 0; i < NUM_ARITH_TBLS; i++) { - cinfo->arith_dc_L[i] = 0; - cinfo->arith_dc_U[i] = 1; - cinfo->arith_ac_K[i] = 5; - } - - /* Default is no multiple-scan output */ - cinfo->scan_info = NULL; - cinfo->num_scans = 0; - - /* Expect normal source image, not raw downsampled data */ - cinfo->raw_data_in = FALSE; - - /* Use Huffman coding, not arithmetic coding, by default */ - cinfo->arith_code = FALSE; - - /* By default, don't do extra passes to optimize entropy coding */ - cinfo->optimize_coding = FALSE; - /* The standard Huffman tables are only valid for 8-bit data precision. - * If the precision is higher, force optimization on so that usable - * tables will be computed. This test can be removed if default tables - * are supplied that are valid for the desired precision. - */ - if (cinfo->data_precision > 8) - cinfo->optimize_coding = TRUE; - - /* By default, use the simpler non-cosited sampling alignment */ - cinfo->CCIR601_sampling = FALSE; - - /* No input smoothing */ - cinfo->smoothing_factor = 0; - - /* DCT algorithm preference */ - cinfo->dct_method = JDCT_DEFAULT; - - /* No restart markers */ - cinfo->restart_interval = 0; - cinfo->restart_in_rows = 0; - - /* Fill in default JFIF marker parameters. Note that whether the marker - * will actually be written is determined by jpeg_set_colorspace. - * - * By default, the library emits JFIF version code 1.01. - * An application that wants to emit JFIF 1.02 extension markers should set - * JFIF_minor_version to 2. We could probably get away with just defaulting - * to 1.02, but there may still be some decoders in use that will complain - * about that; saying 1.01 should minimize compatibility problems. - */ - cinfo->JFIF_major_version = 1; /* Default JFIF version = 1.01 */ - cinfo->JFIF_minor_version = 1; - cinfo->density_unit = 0; /* Pixel size is unknown by default */ - cinfo->X_density = 1; /* Pixel aspect ratio is square by default */ - cinfo->Y_density = 1; - - /* Choose JPEG colorspace based on input space, set defaults accordingly */ - - jpeg_default_colorspace(cinfo); -} - - -/* - * Select an appropriate JPEG colorspace for in_color_space. - */ - -GLOBAL(void) -jpeg_default_colorspace (j_compress_ptr cinfo) -{ - switch (cinfo->in_color_space) { - case JCS_GRAYSCALE: - jpeg_set_colorspace(cinfo, JCS_GRAYSCALE); - break; - case JCS_RGB: - jpeg_set_colorspace(cinfo, JCS_YCbCr); - break; - case JCS_YCbCr: - jpeg_set_colorspace(cinfo, JCS_YCbCr); - break; - case JCS_CMYK: - jpeg_set_colorspace(cinfo, JCS_CMYK); /* By default, no translation */ - break; - case JCS_YCCK: - jpeg_set_colorspace(cinfo, JCS_YCCK); - break; - case JCS_UNKNOWN: - jpeg_set_colorspace(cinfo, JCS_UNKNOWN); - break; - default: - ERREXIT(cinfo, JERR_BAD_IN_COLORSPACE); - } -} - - -/* - * Set the JPEG colorspace, and choose colorspace-dependent default values. - */ - -GLOBAL(void) -jpeg_set_colorspace (j_compress_ptr cinfo, J_COLOR_SPACE colorspace) -{ - jpeg_component_info * compptr; - int ci; - -#define SET_COMP(index,id,hsamp,vsamp,quant,dctbl,actbl) \ - (compptr = &cinfo->comp_info[index], \ - compptr->component_id = (id), \ - compptr->h_samp_factor = (hsamp), \ - compptr->v_samp_factor = (vsamp), \ - compptr->quant_tbl_no = (quant), \ - compptr->dc_tbl_no = (dctbl), \ - compptr->ac_tbl_no = (actbl) ) - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* For all colorspaces, we use Q and Huff tables 0 for luminance components, - * tables 1 for chrominance components. - */ - - cinfo->jpeg_color_space = colorspace; - - cinfo->write_JFIF_header = FALSE; /* No marker for non-JFIF colorspaces */ - cinfo->write_Adobe_marker = FALSE; /* write no Adobe marker by default */ - - switch (colorspace) { - case JCS_GRAYSCALE: - cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ - cinfo->num_components = 1; - /* JFIF specifies component ID 1 */ - SET_COMP(0, 1, 1,1, 0, 0,0); - break; - case JCS_RGB: - cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag RGB */ - cinfo->num_components = 3; - SET_COMP(0, 0x52 /* 'R' */, 1,1, 0, 0,0); - SET_COMP(1, 0x47 /* 'G' */, 1,1, 0, 0,0); - SET_COMP(2, 0x42 /* 'B' */, 1,1, 0, 0,0); - break; - case JCS_YCbCr: - cinfo->write_JFIF_header = TRUE; /* Write a JFIF marker */ - cinfo->num_components = 3; - /* JFIF specifies component IDs 1,2,3 */ - /* We default to 2x2 subsamples of chrominance */ - SET_COMP(0, 1, 2,2, 0, 0,0); - SET_COMP(1, 2, 1,1, 1, 1,1); - SET_COMP(2, 3, 1,1, 1, 1,1); - break; - case JCS_CMYK: - cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag CMYK */ - cinfo->num_components = 4; - SET_COMP(0, 0x43 /* 'C' */, 1,1, 0, 0,0); - SET_COMP(1, 0x4D /* 'M' */, 1,1, 0, 0,0); - SET_COMP(2, 0x59 /* 'Y' */, 1,1, 0, 0,0); - SET_COMP(3, 0x4B /* 'K' */, 1,1, 0, 0,0); - break; - case JCS_YCCK: - cinfo->write_Adobe_marker = TRUE; /* write Adobe marker to flag YCCK */ - cinfo->num_components = 4; - SET_COMP(0, 1, 2,2, 0, 0,0); - SET_COMP(1, 2, 1,1, 1, 1,1); - SET_COMP(2, 3, 1,1, 1, 1,1); - SET_COMP(3, 4, 2,2, 0, 0,0); - break; - case JCS_UNKNOWN: - cinfo->num_components = cinfo->input_components; - if (cinfo->num_components < 1 || cinfo->num_components > MAX_COMPONENTS) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPONENTS); - for (ci = 0; ci < cinfo->num_components; ci++) { - SET_COMP(ci, ci, 1,1, 0, 0,0); - } - break; - default: - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - } -} - - -#ifdef C_PROGRESSIVE_SUPPORTED - -LOCAL(jpeg_scan_info *) -fill_a_scan (jpeg_scan_info * scanptr, int ci, - int Ss, int Se, int Ah, int Al) -/* Support routine: generate one scan for specified component */ -{ - scanptr->comps_in_scan = 1; - scanptr->component_index[0] = ci; - scanptr->Ss = Ss; - scanptr->Se = Se; - scanptr->Ah = Ah; - scanptr->Al = Al; - scanptr++; - return scanptr; -} - -LOCAL(jpeg_scan_info *) -fill_scans (jpeg_scan_info * scanptr, int ncomps, - int Ss, int Se, int Ah, int Al) -/* Support routine: generate one scan for each component */ -{ - int ci; - - for (ci = 0; ci < ncomps; ci++) { - scanptr->comps_in_scan = 1; - scanptr->component_index[0] = ci; - scanptr->Ss = Ss; - scanptr->Se = Se; - scanptr->Ah = Ah; - scanptr->Al = Al; - scanptr++; - } - return scanptr; -} - -LOCAL(jpeg_scan_info *) -fill_dc_scans (jpeg_scan_info * scanptr, int ncomps, int Ah, int Al) -/* Support routine: generate interleaved DC scan if possible, else N scans */ -{ - int ci; - - if (ncomps <= MAX_COMPS_IN_SCAN) { - /* Single interleaved DC scan */ - scanptr->comps_in_scan = ncomps; - for (ci = 0; ci < ncomps; ci++) - scanptr->component_index[ci] = ci; - scanptr->Ss = scanptr->Se = 0; - scanptr->Ah = Ah; - scanptr->Al = Al; - scanptr++; - } else { - /* Noninterleaved DC scan for each component */ - scanptr = fill_scans(scanptr, ncomps, 0, 0, Ah, Al); - } - return scanptr; -} - - -/* - * Create a recommended progressive-JPEG script. - * cinfo->num_components and cinfo->jpeg_color_space must be correct. - */ - -GLOBAL(void) -jpeg_simple_progression (j_compress_ptr cinfo) -{ - int ncomps = cinfo->num_components; - int nscans; - jpeg_scan_info * scanptr; - - /* Safety check to ensure start_compress not called yet. */ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - /* Figure space needed for script. Calculation must match code below! */ - if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { - /* Custom script for YCbCr color images. */ - nscans = 10; - } else { - /* All-purpose script for other color spaces. */ - if (ncomps > MAX_COMPS_IN_SCAN) - nscans = 6 * ncomps; /* 2 DC + 4 AC scans per component */ - else - nscans = 2 + 4 * ncomps; /* 2 DC scans; 4 AC scans per component */ - } - - /* Allocate space for script. - * We need to put it in the permanent pool in case the application performs - * multiple compressions without changing the settings. To avoid a memory - * leak if jpeg_simple_progression is called repeatedly for the same JPEG - * object, we try to re-use previously allocated space, and we allocate - * enough space to handle YCbCr even if initially asked for grayscale. - */ - if (cinfo->script_space == NULL || cinfo->script_space_size < nscans) { - cinfo->script_space_size = MAX(nscans, 10); - cinfo->script_space = (jpeg_scan_info *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - cinfo->script_space_size * SIZEOF(jpeg_scan_info)); - } - scanptr = cinfo->script_space; - cinfo->scan_info = scanptr; - cinfo->num_scans = nscans; - - if (ncomps == 3 && cinfo->jpeg_color_space == JCS_YCbCr) { - /* Custom script for YCbCr color images. */ - /* Initial DC scan */ - scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); - /* Initial AC scan: get some luma data out in a hurry */ - scanptr = fill_a_scan(scanptr, 0, 1, 5, 0, 2); - /* Chroma data is too small to be worth expending many scans on */ - scanptr = fill_a_scan(scanptr, 2, 1, 63, 0, 1); - scanptr = fill_a_scan(scanptr, 1, 1, 63, 0, 1); - /* Complete spectral selection for luma AC */ - scanptr = fill_a_scan(scanptr, 0, 6, 63, 0, 2); - /* Refine next bit of luma AC */ - scanptr = fill_a_scan(scanptr, 0, 1, 63, 2, 1); - /* Finish DC successive approximation */ - scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); - /* Finish AC successive approximation */ - scanptr = fill_a_scan(scanptr, 2, 1, 63, 1, 0); - scanptr = fill_a_scan(scanptr, 1, 1, 63, 1, 0); - /* Luma bottom bit comes last since it's usually largest scan */ - scanptr = fill_a_scan(scanptr, 0, 1, 63, 1, 0); - } else { - /* All-purpose script for other color spaces. */ - /* Successive approximation first pass */ - scanptr = fill_dc_scans(scanptr, ncomps, 0, 1); - scanptr = fill_scans(scanptr, ncomps, 1, 5, 0, 2); - scanptr = fill_scans(scanptr, ncomps, 6, 63, 0, 2); - /* Successive approximation second pass */ - scanptr = fill_scans(scanptr, ncomps, 1, 63, 2, 1); - /* Successive approximation final pass */ - scanptr = fill_dc_scans(scanptr, ncomps, 1, 0); - scanptr = fill_scans(scanptr, ncomps, 1, 63, 1, 0); - } -} - -#endif /* C_PROGRESSIVE_SUPPORTED */ diff --git a/oversampling/WDL/jpeglib/jcphuff.c b/oversampling/WDL/jpeglib/jcphuff.c deleted file mode 100644 index 07f9178..0000000 --- a/oversampling/WDL/jpeglib/jcphuff.c +++ /dev/null @@ -1,833 +0,0 @@ -/* - * jcphuff.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy encoding routines for progressive JPEG. - * - * We do not support output suspension in this module, since the library - * currently does not allow multiple-scan files to be written with output - * suspension. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jchuff.h" /* Declarations shared with jchuff.c */ - -#ifdef C_PROGRESSIVE_SUPPORTED - -/* Expanded entropy encoder object for progressive Huffman encoding. */ - -typedef struct { - struct jpeg_entropy_encoder pub; /* public fields */ - - /* Mode flag: TRUE for optimization, FALSE for actual data output */ - boolean gather_statistics; - - /* Bit-level coding status. - * next_output_byte/free_in_buffer are local copies of cinfo->dest fields. - */ - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - INT32 put_buffer; /* current bit-accumulation buffer */ - int put_bits; /* # of bits now in it */ - j_compress_ptr cinfo; /* link to cinfo (needed for dump_buffer) */ - - /* Coding status for DC components */ - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ - - /* Coding status for AC components */ - int ac_tbl_no; /* the table number of the single component */ - unsigned int EOBRUN; /* run length of EOBs */ - unsigned int BE; /* # of buffered correction bits before MCU */ - char * bit_buffer; /* buffer for correction bits (1 per char) */ - /* packing correction bits tightly would save some space but cost time... */ - - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - int next_restart_num; /* next restart number to write (0-7) */ - - /* Pointers to derived tables (these workspaces have image lifespan). - * Since any one scan codes only DC or only AC, we only need one set - * of tables, not one for DC and one for AC. - */ - c_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; - - /* Statistics tables for optimization; again, one set is enough */ - long * count_ptrs[NUM_HUFF_TBLS]; -} phuff_entropy_encoder; - -typedef phuff_entropy_encoder * phuff_entropy_ptr; - -/* MAX_CORR_BITS is the number of bits the AC refinement correction-bit - * buffer can hold. Larger sizes may slightly improve compression, but - * 1000 is already well into the realm of overkill. - * The minimum safe size is 64 bits. - */ - -#define MAX_CORR_BITS 1000 /* Max # of correction bits I can buffer */ - -/* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32. - * We assume that int right shift is unsigned if INT32 right shift is, - * which should be safe. - */ - -#ifdef RIGHT_SHIFT_IS_UNSIGNED -#define ISHIFT_TEMPS int ishift_temp; -#define IRIGHT_SHIFT(x,shft) \ - ((ishift_temp = (x)) < 0 ? \ - (ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \ - (ishift_temp >> (shft))) -#else -#define ISHIFT_TEMPS -#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) -#endif - -/* Forward declarations */ -METHODDEF(boolean) encode_mcu_DC_first JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) encode_mcu_AC_first JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) encode_mcu_DC_refine JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) encode_mcu_AC_refine JPP((j_compress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(void) finish_pass_phuff JPP((j_compress_ptr cinfo)); -METHODDEF(void) finish_pass_gather_phuff JPP((j_compress_ptr cinfo)); - - -/* - * Initialize for a Huffman-compressed scan using progressive JPEG. - */ - -METHODDEF(void) -start_pass_phuff (j_compress_ptr cinfo, boolean gather_statistics) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - boolean is_DC_band; - int ci, tbl; - jpeg_component_info * compptr; - - entropy->cinfo = cinfo; - entropy->gather_statistics = gather_statistics; - - is_DC_band = (cinfo->Ss == 0); - - /* We assume jcmaster.c already validated the scan parameters. */ - - /* Select execution routines */ - if (cinfo->Ah == 0) { - if (is_DC_band) - entropy->pub.encode_mcu = encode_mcu_DC_first; - else - entropy->pub.encode_mcu = encode_mcu_AC_first; - } else { - if (is_DC_band) - entropy->pub.encode_mcu = encode_mcu_DC_refine; - else { - entropy->pub.encode_mcu = encode_mcu_AC_refine; - /* AC refinement needs a correction bit buffer */ - if (entropy->bit_buffer == NULL) - entropy->bit_buffer = (char *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - MAX_CORR_BITS * SIZEOF(char)); - } - } - if (gather_statistics) - entropy->pub.finish_pass = finish_pass_gather_phuff; - else - entropy->pub.finish_pass = finish_pass_phuff; - - /* Only DC coefficients may be interleaved, so cinfo->comps_in_scan = 1 - * for AC coefficients. - */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Initialize DC predictions to 0 */ - entropy->last_dc_val[ci] = 0; - /* Get table index */ - if (is_DC_band) { - if (cinfo->Ah != 0) /* DC refinement needs no table */ - continue; - tbl = compptr->dc_tbl_no; - } else { - entropy->ac_tbl_no = tbl = compptr->ac_tbl_no; - } - if (gather_statistics) { - /* Check for invalid table index */ - /* (make_c_derived_tbl does this in the other path) */ - if (tbl < 0 || tbl >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl); - /* Allocate and zero the statistics tables */ - /* Note that jpeg_gen_optimal_table expects 257 entries in each table! */ - if (entropy->count_ptrs[tbl] == NULL) - entropy->count_ptrs[tbl] = (long *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 257 * SIZEOF(long)); - MEMZERO(entropy->count_ptrs[tbl], 257 * SIZEOF(long)); - } else { - /* Compute derived values for Huffman table */ - /* We may do this more than once for a table, but it's not expensive */ - jpeg_make_c_derived_tbl(cinfo, is_DC_band, tbl, - & entropy->derived_tbls[tbl]); - } - } - - /* Initialize AC stuff */ - entropy->EOBRUN = 0; - entropy->BE = 0; - - /* Initialize bit buffer to empty */ - entropy->put_buffer = 0; - entropy->put_bits = 0; - - /* Initialize restart stuff */ - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num = 0; -} - - -/* Outputting bytes to the file. - * NB: these must be called only when actually outputting, - * that is, entropy->gather_statistics == FALSE. - */ - -/* Emit a byte */ -#define emit_byte(entropy,val) \ - { *(entropy)->next_output_byte++ = (JOCTET) (val); \ - if (--(entropy)->free_in_buffer == 0) \ - dump_buffer(entropy); } - - -LOCAL(void) -dump_buffer (phuff_entropy_ptr entropy) -/* Empty the output buffer; we do not support suspension in this module. */ -{ - struct jpeg_destination_mgr * dest = entropy->cinfo->dest; - - if (! (*dest->empty_output_buffer) (entropy->cinfo)) - ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND); - /* After a successful buffer dump, must reset buffer pointers */ - entropy->next_output_byte = dest->next_output_byte; - entropy->free_in_buffer = dest->free_in_buffer; -} - - -/* Outputting bits to the file */ - -/* Only the right 24 bits of put_buffer are used; the valid bits are - * left-justified in this part. At most 16 bits can be passed to emit_bits - * in one call, and we never retain more than 7 bits in put_buffer - * between calls, so 24 bits are sufficient. - */ - -INLINE -LOCAL(void) -emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size) -/* Emit some bits, unless we are in gather mode */ -{ - /* This routine is heavily used, so it's worth coding tightly. */ - register INT32 put_buffer = (INT32) code; - register int put_bits = entropy->put_bits; - - /* if size is 0, caller used an invalid Huffman table entry */ - if (size == 0) - ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); - - if (entropy->gather_statistics) - return; /* do nothing if we're only getting stats */ - - put_buffer &= (((INT32) 1)<put_buffer; /* and merge with old buffer contents */ - - while (put_bits >= 8) { - int c = (int) ((put_buffer >> 16) & 0xFF); - - emit_byte(entropy, c); - if (c == 0xFF) { /* need to stuff a zero byte? */ - emit_byte(entropy, 0); - } - put_buffer <<= 8; - put_bits -= 8; - } - - entropy->put_buffer = put_buffer; /* update variables */ - entropy->put_bits = put_bits; -} - - -LOCAL(void) -flush_bits (phuff_entropy_ptr entropy) -{ - emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */ - entropy->put_buffer = 0; /* and reset bit-buffer to empty */ - entropy->put_bits = 0; -} - - -/* - * Emit (or just count) a Huffman symbol. - */ - -INLINE -LOCAL(void) -emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol) -{ - if (entropy->gather_statistics) - entropy->count_ptrs[tbl_no][symbol]++; - else { - c_derived_tbl * tbl = entropy->derived_tbls[tbl_no]; - emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]); - } -} - - -/* - * Emit bits from a correction bit buffer. - */ - -LOCAL(void) -emit_buffered_bits (phuff_entropy_ptr entropy, char * bufstart, - unsigned int nbits) -{ - if (entropy->gather_statistics) - return; /* no real work */ - - while (nbits > 0) { - emit_bits(entropy, (unsigned int) (*bufstart), 1); - bufstart++; - nbits--; - } -} - - -/* - * Emit any pending EOBRUN symbol. - */ - -LOCAL(void) -emit_eobrun (phuff_entropy_ptr entropy) -{ - register int temp, nbits; - - if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */ - temp = entropy->EOBRUN; - nbits = 0; - while ((temp >>= 1)) - nbits++; - /* safety check: shouldn't happen given limited correction-bit buffer */ - if (nbits > 14) - ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); - - emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4); - if (nbits) - emit_bits(entropy, entropy->EOBRUN, nbits); - - entropy->EOBRUN = 0; - - /* Emit any buffered correction bits */ - emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE); - entropy->BE = 0; - } -} - - -/* - * Emit a restart marker & resynchronize predictions. - */ - -LOCAL(void) -emit_restart (phuff_entropy_ptr entropy, int restart_num) -{ - int ci; - - emit_eobrun(entropy); - - if (! entropy->gather_statistics) { - flush_bits(entropy); - emit_byte(entropy, 0xFF); - emit_byte(entropy, JPEG_RST0 + restart_num); - } - - if (entropy->cinfo->Ss == 0) { - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++) - entropy->last_dc_val[ci] = 0; - } else { - /* Re-initialize all AC-related fields to 0 */ - entropy->EOBRUN = 0; - entropy->BE = 0; - } -} - - -/* - * MCU encoding for DC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -encode_mcu_DC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp, temp2; - register int nbits; - int blkn, ci; - int Al = cinfo->Al; - JBLOCKROW block; - jpeg_component_info * compptr; - ISHIFT_TEMPS - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data blocks */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - - /* Compute the DC value after the required point transform by Al. - * This is simply an arithmetic right shift. - */ - temp2 = IRIGHT_SHIFT((int) ((*block)[0]), Al); - - /* DC differences are figured on the point-transformed values. */ - temp = temp2 - entropy->last_dc_val[ci]; - entropy->last_dc_val[ci] = temp2; - - /* Encode the DC coefficient difference per section G.1.2.1 */ - temp2 = temp; - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - /* For a negative input, want temp2 = bitwise complement of abs(input) */ - /* This code assumes we are on a two's complement machine */ - temp2--; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 0; - while (temp) { - nbits++; - temp >>= 1; - } - /* Check for out-of-range coefficient values. - * Since we're encoding a difference, the range limit is twice as much. - */ - if (nbits > MAX_COEF_BITS+1) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count/emit the Huffman-coded symbol for the number of bits */ - emit_symbol(entropy, compptr->dc_tbl_no, nbits); - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - if (nbits) /* emit_bits rejects calls with size 0 */ - emit_bits(entropy, (unsigned int) temp2, nbits); - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * MCU encoding for AC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -encode_mcu_AC_first (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp, temp2; - register int nbits; - register int r, k; - int Se = cinfo->Se; - int Al = cinfo->Al; - JBLOCKROW block; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data block */ - block = MCU_data[0]; - - /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */ - - r = 0; /* r = run length of zeros */ - - for (k = cinfo->Ss; k <= Se; k++) { - if ((temp = (*block)[jpeg_natural_order[k]]) == 0) { - r++; - continue; - } - /* We must apply the point transform by Al. For AC coefficients this - * is an integer division with rounding towards 0. To do this portably - * in C, we shift after obtaining the absolute value; so the code is - * interwoven with finding the abs value (temp) and output bits (temp2). - */ - if (temp < 0) { - temp = -temp; /* temp is abs value of input */ - temp >>= Al; /* apply the point transform */ - /* For a negative coef, want temp2 = bitwise complement of abs(coef) */ - temp2 = ~temp; - } else { - temp >>= Al; /* apply the point transform */ - temp2 = temp; - } - /* Watch out for case that nonzero coef is zero after point transform */ - if (temp == 0) { - r++; - continue; - } - - /* Emit any pending EOBRUN */ - if (entropy->EOBRUN > 0) - emit_eobrun(entropy); - /* if run length > 15, must emit special run-length-16 codes (0xF0) */ - while (r > 15) { - emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); - r -= 16; - } - - /* Find the number of bits needed for the magnitude of the coefficient */ - nbits = 1; /* there must be at least one 1 bit */ - while ((temp >>= 1)) - nbits++; - /* Check for out-of-range coefficient values */ - if (nbits > MAX_COEF_BITS) - ERREXIT(cinfo, JERR_BAD_DCT_COEF); - - /* Count/emit Huffman symbol for run length / number of bits */ - emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); - - /* Emit that number of bits of the value, if positive, */ - /* or the complement of its magnitude, if negative. */ - emit_bits(entropy, (unsigned int) temp2, nbits); - - r = 0; /* reset zero run length */ - } - - if (r > 0) { /* If there are trailing zeroes, */ - entropy->EOBRUN++; /* count an EOB */ - if (entropy->EOBRUN == 0x7FFF) - emit_eobrun(entropy); /* force it out to avoid overflow */ - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * MCU encoding for DC successive approximation refinement scan. - * Note: we assume such scans can be multi-component, although the spec - * is not very clear on the point. - */ - -METHODDEF(boolean) -encode_mcu_DC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp; - int blkn; - int Al = cinfo->Al; - JBLOCKROW block; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data blocks */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - - /* We simply emit the Al'th bit of the DC coefficient value. */ - temp = (*block)[0]; - emit_bits(entropy, (unsigned int) (temp >> Al), 1); - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * MCU encoding for AC successive approximation refinement scan. - */ - -METHODDEF(boolean) -encode_mcu_AC_refine (j_compress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - register int temp; - register int r, k; - int EOB; - char *BR_buffer; - unsigned int BR; - int Se = cinfo->Se; - int Al = cinfo->Al; - JBLOCKROW block; - int absvalues[DCTSIZE2]; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Emit restart marker if needed */ - if (cinfo->restart_interval) - if (entropy->restarts_to_go == 0) - emit_restart(entropy, entropy->next_restart_num); - - /* Encode the MCU data block */ - block = MCU_data[0]; - - /* It is convenient to make a pre-pass to determine the transformed - * coefficients' absolute values and the EOB position. - */ - EOB = 0; - for (k = cinfo->Ss; k <= Se; k++) { - temp = (*block)[jpeg_natural_order[k]]; - /* We must apply the point transform by Al. For AC coefficients this - * is an integer division with rounding towards 0. To do this portably - * in C, we shift after obtaining the absolute value. - */ - if (temp < 0) - temp = -temp; /* temp is abs value of input */ - temp >>= Al; /* apply the point transform */ - absvalues[k] = temp; /* save abs value for main pass */ - if (temp == 1) - EOB = k; /* EOB = index of last newly-nonzero coef */ - } - - /* Encode the AC coefficients per section G.1.2.3, fig. G.7 */ - - r = 0; /* r = run length of zeros */ - BR = 0; /* BR = count of buffered bits added now */ - BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */ - - for (k = cinfo->Ss; k <= Se; k++) { - if ((temp = absvalues[k]) == 0) { - r++; - continue; - } - - /* Emit any required ZRLs, but not if they can be folded into EOB */ - while (r > 15 && k <= EOB) { - /* emit any pending EOBRUN and the BE correction bits */ - emit_eobrun(entropy); - /* Emit ZRL */ - emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); - r -= 16; - /* Emit buffered correction bits that must be associated with ZRL */ - emit_buffered_bits(entropy, BR_buffer, BR); - BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ - BR = 0; - } - - /* If the coef was previously nonzero, it only needs a correction bit. - * NOTE: a straight translation of the spec's figure G.7 would suggest - * that we also need to test r > 15. But if r > 15, we can only get here - * if k > EOB, which implies that this coefficient is not 1. - */ - if (temp > 1) { - /* The correction bit is the next bit of the absolute value. */ - BR_buffer[BR++] = (char) (temp & 1); - continue; - } - - /* Emit any pending EOBRUN and the BE correction bits */ - emit_eobrun(entropy); - - /* Count/emit Huffman symbol for run length / number of bits */ - emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); - - /* Emit output bit for newly-nonzero coef */ - temp = ((*block)[jpeg_natural_order[k]] < 0) ? 0 : 1; - emit_bits(entropy, (unsigned int) temp, 1); - - /* Emit buffered correction bits that must be associated with this code */ - emit_buffered_bits(entropy, BR_buffer, BR); - BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ - BR = 0; - r = 0; /* reset zero run length */ - } - - if (r > 0 || BR > 0) { /* If there are trailing zeroes, */ - entropy->EOBRUN++; /* count an EOB */ - entropy->BE += BR; /* concat my correction bits to older ones */ - /* We force out the EOB if we risk either: - * 1. overflow of the EOB counter; - * 2. overflow of the correction bit buffer during the next MCU. - */ - if (entropy->EOBRUN == 0x7FFF || entropy->BE > (MAX_CORR_BITS-DCTSIZE2+1)) - emit_eobrun(entropy); - } - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; - - /* Update restart-interval state too */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) { - entropy->restarts_to_go = cinfo->restart_interval; - entropy->next_restart_num++; - entropy->next_restart_num &= 7; - } - entropy->restarts_to_go--; - } - - return TRUE; -} - - -/* - * Finish up at the end of a Huffman-compressed progressive scan. - */ - -METHODDEF(void) -finish_pass_phuff (j_compress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - - entropy->next_output_byte = cinfo->dest->next_output_byte; - entropy->free_in_buffer = cinfo->dest->free_in_buffer; - - /* Flush out any buffered data */ - emit_eobrun(entropy); - flush_bits(entropy); - - cinfo->dest->next_output_byte = entropy->next_output_byte; - cinfo->dest->free_in_buffer = entropy->free_in_buffer; -} - - -/* - * Finish up a statistics-gathering pass and create the new Huffman tables. - */ - -METHODDEF(void) -finish_pass_gather_phuff (j_compress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - boolean is_DC_band; - int ci, tbl; - jpeg_component_info * compptr; - JHUFF_TBL **htblptr; - boolean did[NUM_HUFF_TBLS]; - - /* Flush out buffered data (all we care about is counting the EOB symbol) */ - emit_eobrun(entropy); - - is_DC_band = (cinfo->Ss == 0); - - /* It's important not to apply jpeg_gen_optimal_table more than once - * per table, because it clobbers the input frequency counts! - */ - MEMZERO(did, SIZEOF(did)); - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - if (is_DC_band) { - if (cinfo->Ah != 0) /* DC refinement needs no table */ - continue; - tbl = compptr->dc_tbl_no; - } else { - tbl = compptr->ac_tbl_no; - } - if (! did[tbl]) { - if (is_DC_band) - htblptr = & cinfo->dc_huff_tbl_ptrs[tbl]; - else - htblptr = & cinfo->ac_huff_tbl_ptrs[tbl]; - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]); - did[tbl] = TRUE; - } - } -} - - -/* - * Module initialization routine for progressive Huffman entropy encoding. - */ - -GLOBAL(void) -jinit_phuff_encoder (j_compress_ptr cinfo) -{ - phuff_entropy_ptr entropy; - int i; - - entropy = (phuff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(phuff_entropy_encoder)); - cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; - entropy->pub.start_pass = start_pass_phuff; - - /* Mark tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->derived_tbls[i] = NULL; - entropy->count_ptrs[i] = NULL; - } - entropy->bit_buffer = NULL; /* needed only in AC refinement scan */ -} - -#endif /* C_PROGRESSIVE_SUPPORTED */ diff --git a/oversampling/WDL/jpeglib/jcprepct.c b/oversampling/WDL/jpeglib/jcprepct.c deleted file mode 100644 index fa93333..0000000 --- a/oversampling/WDL/jpeglib/jcprepct.c +++ /dev/null @@ -1,354 +0,0 @@ -/* - * jcprepct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the compression preprocessing controller. - * This controller manages the color conversion, downsampling, - * and edge expansion steps. - * - * Most of the complexity here is associated with buffering input rows - * as required by the downsampler. See the comments at the head of - * jcsample.c for the downsampler's needs. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* At present, jcsample.c can request context rows only for smoothing. - * In the future, we might also need context rows for CCIR601 sampling - * or other more-complex downsampling procedures. The code to support - * context rows should be compiled only if needed. - */ -#ifdef INPUT_SMOOTHING_SUPPORTED -#define CONTEXT_ROWS_SUPPORTED -#endif - - -/* - * For the simple (no-context-row) case, we just need to buffer one - * row group's worth of pixels for the downsampling step. At the bottom of - * the image, we pad to a full row group by replicating the last pixel row. - * The downsampler's last output row is then replicated if needed to pad - * out to a full iMCU row. - * - * When providing context rows, we must buffer three row groups' worth of - * pixels. Three row groups are physically allocated, but the row pointer - * arrays are made five row groups high, with the extra pointers above and - * below "wrapping around" to point to the last and first real row groups. - * This allows the downsampler to access the proper context rows. - * At the top and bottom of the image, we create dummy context rows by - * copying the first or last real pixel row. This copying could be avoided - * by pointer hacking as is done in jdmainct.c, but it doesn't seem worth the - * trouble on the compression side. - */ - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_prep_controller pub; /* public fields */ - - /* Downsampling input buffer. This buffer holds color-converted data - * until we have enough to do a downsample step. - */ - JSAMPARRAY color_buf[MAX_COMPONENTS]; - - JDIMENSION rows_to_go; /* counts rows remaining in source image */ - int next_buf_row; /* index of next row to store in color_buf */ - -#ifdef CONTEXT_ROWS_SUPPORTED /* only needed for context case */ - int this_row_group; /* starting row index of group to process */ - int next_buf_stop; /* downsample when we reach this index */ -#endif -} my_prep_controller; - -typedef my_prep_controller * my_prep_ptr; - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_prep (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - - if (pass_mode != JBUF_PASS_THRU) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - /* Initialize total-height counter for detecting bottom of image */ - prep->rows_to_go = cinfo->image_height; - /* Mark the conversion buffer empty */ - prep->next_buf_row = 0; -#ifdef CONTEXT_ROWS_SUPPORTED - /* Preset additional state variables for context mode. - * These aren't used in non-context mode, so we needn't test which mode. - */ - prep->this_row_group = 0; - /* Set next_buf_stop to stop after two row groups have been read in. */ - prep->next_buf_stop = 2 * cinfo->max_v_samp_factor; -#endif -} - - -/* - * Expand an image vertically from height input_rows to height output_rows, - * by duplicating the bottom row. - */ - -LOCAL(void) -expand_bottom_edge (JSAMPARRAY image_data, JDIMENSION num_cols, - int input_rows, int output_rows) -{ - register int row; - - for (row = input_rows; row < output_rows; row++) { - jcopy_sample_rows(image_data, input_rows-1, image_data, row, - 1, num_cols); - } -} - - -/* - * Process some data in the simple no-context case. - * - * Preprocessor output data is counted in "row groups". A row group - * is defined to be v_samp_factor sample rows of each component. - * Downsampling will produce this much data from each max_v_samp_factor - * input rows. - */ - -METHODDEF(void) -pre_process_data (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail, - JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, - JDIMENSION out_row_groups_avail) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - int numrows, ci; - JDIMENSION inrows; - jpeg_component_info * compptr; - - while (*in_row_ctr < in_rows_avail && - *out_row_group_ctr < out_row_groups_avail) { - /* Do color conversion to fill the conversion buffer. */ - inrows = in_rows_avail - *in_row_ctr; - numrows = cinfo->max_v_samp_factor - prep->next_buf_row; - numrows = (int) MIN((JDIMENSION) numrows, inrows); - (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, - prep->color_buf, - (JDIMENSION) prep->next_buf_row, - numrows); - *in_row_ctr += numrows; - prep->next_buf_row += numrows; - prep->rows_to_go -= numrows; - /* If at bottom of image, pad to fill the conversion buffer. */ - if (prep->rows_to_go == 0 && - prep->next_buf_row < cinfo->max_v_samp_factor) { - for (ci = 0; ci < cinfo->num_components; ci++) { - expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, - prep->next_buf_row, cinfo->max_v_samp_factor); - } - prep->next_buf_row = cinfo->max_v_samp_factor; - } - /* If we've filled the conversion buffer, empty it. */ - if (prep->next_buf_row == cinfo->max_v_samp_factor) { - (*cinfo->downsample->downsample) (cinfo, - prep->color_buf, (JDIMENSION) 0, - output_buf, *out_row_group_ctr); - prep->next_buf_row = 0; - (*out_row_group_ctr)++; - } - /* If at bottom of image, pad the output to a full iMCU height. - * Note we assume the caller is providing a one-iMCU-height output buffer! - */ - if (prep->rows_to_go == 0 && - *out_row_group_ctr < out_row_groups_avail) { - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - expand_bottom_edge(output_buf[ci], - compptr->width_in_blocks * DCTSIZE, - (int) (*out_row_group_ctr * compptr->v_samp_factor), - (int) (out_row_groups_avail * compptr->v_samp_factor)); - } - *out_row_group_ctr = out_row_groups_avail; - break; /* can exit outer loop without test */ - } - } -} - - -#ifdef CONTEXT_ROWS_SUPPORTED - -/* - * Process some data in the context case. - */ - -METHODDEF(void) -pre_process_context (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail, - JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr, - JDIMENSION out_row_groups_avail) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - int numrows, ci; - int buf_height = cinfo->max_v_samp_factor * 3; - JDIMENSION inrows; - - while (*out_row_group_ctr < out_row_groups_avail) { - if (*in_row_ctr < in_rows_avail) { - /* Do color conversion to fill the conversion buffer. */ - inrows = in_rows_avail - *in_row_ctr; - numrows = prep->next_buf_stop - prep->next_buf_row; - numrows = (int) MIN((JDIMENSION) numrows, inrows); - (*cinfo->cconvert->color_convert) (cinfo, input_buf + *in_row_ctr, - prep->color_buf, - (JDIMENSION) prep->next_buf_row, - numrows); - /* Pad at top of image, if first time through */ - if (prep->rows_to_go == cinfo->image_height) { - for (ci = 0; ci < cinfo->num_components; ci++) { - int row; - for (row = 1; row <= cinfo->max_v_samp_factor; row++) { - jcopy_sample_rows(prep->color_buf[ci], 0, - prep->color_buf[ci], -row, - 1, cinfo->image_width); - } - } - } - *in_row_ctr += numrows; - prep->next_buf_row += numrows; - prep->rows_to_go -= numrows; - } else { - /* Return for more data, unless we are at the bottom of the image. */ - if (prep->rows_to_go != 0) - break; - /* When at bottom of image, pad to fill the conversion buffer. */ - if (prep->next_buf_row < prep->next_buf_stop) { - for (ci = 0; ci < cinfo->num_components; ci++) { - expand_bottom_edge(prep->color_buf[ci], cinfo->image_width, - prep->next_buf_row, prep->next_buf_stop); - } - prep->next_buf_row = prep->next_buf_stop; - } - } - /* If we've gotten enough data, downsample a row group. */ - if (prep->next_buf_row == prep->next_buf_stop) { - (*cinfo->downsample->downsample) (cinfo, - prep->color_buf, - (JDIMENSION) prep->this_row_group, - output_buf, *out_row_group_ctr); - (*out_row_group_ctr)++; - /* Advance pointers with wraparound as necessary. */ - prep->this_row_group += cinfo->max_v_samp_factor; - if (prep->this_row_group >= buf_height) - prep->this_row_group = 0; - if (prep->next_buf_row >= buf_height) - prep->next_buf_row = 0; - prep->next_buf_stop = prep->next_buf_row + cinfo->max_v_samp_factor; - } - } -} - - -/* - * Create the wrapped-around downsampling input buffer needed for context mode. - */ - -LOCAL(void) -create_context_buffer (j_compress_ptr cinfo) -{ - my_prep_ptr prep = (my_prep_ptr) cinfo->prep; - int rgroup_height = cinfo->max_v_samp_factor; - int ci, i; - jpeg_component_info * compptr; - JSAMPARRAY true_buffer, fake_buffer; - - /* Grab enough space for fake row pointers for all the components; - * we need five row groups' worth of pointers for each component. - */ - fake_buffer = (JSAMPARRAY) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (cinfo->num_components * 5 * rgroup_height) * - SIZEOF(JSAMPROW)); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Allocate the actual buffer space (3 row groups) for this component. - * We make the buffer wide enough to allow the downsampler to edge-expand - * horizontally within the buffer, if it so chooses. - */ - true_buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * - cinfo->max_h_samp_factor) / compptr->h_samp_factor), - (JDIMENSION) (3 * rgroup_height)); - /* Copy true buffer row pointers into the middle of the fake row array */ - MEMCOPY(fake_buffer + rgroup_height, true_buffer, - 3 * rgroup_height * SIZEOF(JSAMPROW)); - /* Fill in the above and below wraparound pointers */ - for (i = 0; i < rgroup_height; i++) { - fake_buffer[i] = true_buffer[2 * rgroup_height + i]; - fake_buffer[4 * rgroup_height + i] = true_buffer[i]; - } - prep->color_buf[ci] = fake_buffer + rgroup_height; - fake_buffer += 5 * rgroup_height; /* point to space for next component */ - } -} - -#endif /* CONTEXT_ROWS_SUPPORTED */ - - -/* - * Initialize preprocessing controller. - */ - -GLOBAL(void) -jinit_c_prep_controller (j_compress_ptr cinfo, boolean need_full_buffer) -{ - my_prep_ptr prep; - int ci; - jpeg_component_info * compptr; - - if (need_full_buffer) /* safety check */ - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - prep = (my_prep_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_prep_controller)); - cinfo->prep = (struct jpeg_c_prep_controller *) prep; - prep->pub.start_pass = start_pass_prep; - - /* Allocate the color conversion buffer. - * We make the buffer wide enough to allow the downsampler to edge-expand - * horizontally within the buffer, if it so chooses. - */ - if (cinfo->downsample->need_context_rows) { - /* Set up to provide context rows */ -#ifdef CONTEXT_ROWS_SUPPORTED - prep->pub.pre_process_data = pre_process_context; - create_context_buffer(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - /* No context, just make it tall enough for one row group */ - prep->pub.pre_process_data = pre_process_data; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - prep->color_buf[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (((long) compptr->width_in_blocks * DCTSIZE * - cinfo->max_h_samp_factor) / compptr->h_samp_factor), - (JDIMENSION) cinfo->max_v_samp_factor); - } - } -} diff --git a/oversampling/WDL/jpeglib/jcsample.c b/oversampling/WDL/jpeglib/jcsample.c deleted file mode 100644 index 212ec87..0000000 --- a/oversampling/WDL/jpeglib/jcsample.c +++ /dev/null @@ -1,519 +0,0 @@ -/* - * jcsample.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains downsampling routines. - * - * Downsampling input data is counted in "row groups". A row group - * is defined to be max_v_samp_factor pixel rows of each component, - * from which the downsampler produces v_samp_factor sample rows. - * A single row group is processed in each call to the downsampler module. - * - * The downsampler is responsible for edge-expansion of its output data - * to fill an integral number of DCT blocks horizontally. The source buffer - * may be modified if it is helpful for this purpose (the source buffer is - * allocated wide enough to correspond to the desired output width). - * The caller (the prep controller) is responsible for vertical padding. - * - * The downsampler may request "context rows" by setting need_context_rows - * during startup. In this case, the input arrays will contain at least - * one row group's worth of pixels above and below the passed-in data; - * the caller will create dummy rows at image top and bottom by replicating - * the first or last real pixel row. - * - * An excellent reference for image resampling is - * Digital Image Warping, George Wolberg, 1990. - * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. - * - * The downsampling algorithm used here is a simple average of the source - * pixels covered by the output pixel. The hi-falutin sampling literature - * refers to this as a "box filter". In general the characteristics of a box - * filter are not very good, but for the specific cases we normally use (1:1 - * and 2:1 ratios) the box is equivalent to a "triangle filter" which is not - * nearly so bad. If you intend to use other sampling ratios, you'd be well - * advised to improve this code. - * - * A simple input-smoothing capability is provided. This is mainly intended - * for cleaning up color-dithered GIF input files (if you find it inadequate, - * we suggest using an external filtering program such as pnmconvol). When - * enabled, each input pixel P is replaced by a weighted sum of itself and its - * eight neighbors. P's weight is 1-8*SF and each neighbor's weight is SF, - * where SF = (smoothing_factor / 1024). - * Currently, smoothing is only supported for 2h2v sampling factors. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Pointer to routine to downsample a single component */ -typedef JMETHOD(void, downsample1_ptr, - (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data)); - -/* Private subobject */ - -typedef struct { - struct jpeg_downsampler pub; /* public fields */ - - /* Downsampling method pointers, one per component */ - downsample1_ptr methods[MAX_COMPONENTS]; -} my_downsampler; - -typedef my_downsampler * my_downsample_ptr; - - -/* - * Initialize for a downsampling pass. - */ - -METHODDEF(void) -start_pass_downsample (j_compress_ptr cinfo) -{ - /* no work for now */ -} - - -/* - * Expand a component horizontally from width input_cols to width output_cols, - * by duplicating the rightmost samples. - */ - -LOCAL(void) -expand_right_edge (JSAMPARRAY image_data, int num_rows, - JDIMENSION input_cols, JDIMENSION output_cols) -{ - register JSAMPROW ptr; - register JSAMPLE pixval; - register int count; - int row; - int numcols = (int) (output_cols - input_cols); - - if (numcols > 0) { - for (row = 0; row < num_rows; row++) { - ptr = image_data[row] + input_cols; - pixval = ptr[-1]; /* don't need GETJSAMPLE() here */ - for (count = numcols; count > 0; count--) - *ptr++ = pixval; - } - } -} - - -/* - * Do downsampling for a whole row group (all components). - * - * In this version we simply downsample each component independently. - */ - -METHODDEF(void) -sep_downsample (j_compress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_index, - JSAMPIMAGE output_buf, JDIMENSION out_row_group_index) -{ - my_downsample_ptr downsample = (my_downsample_ptr) cinfo->downsample; - int ci; - jpeg_component_info * compptr; - JSAMPARRAY in_ptr, out_ptr; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - in_ptr = input_buf[ci] + in_row_index; - out_ptr = output_buf[ci] + (out_row_group_index * compptr->v_samp_factor); - (*downsample->methods[ci]) (cinfo, compptr, in_ptr, out_ptr); - } -} - - -/* - * Downsample pixel values of a single component. - * One row group is processed per call. - * This version handles arbitrary integral sampling ratios, without smoothing. - * Note that this version is not actually used for customary sampling ratios. - */ - -METHODDEF(void) -int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int inrow, outrow, h_expand, v_expand, numpix, numpix2, h, v; - JDIMENSION outcol, outcol_h; /* outcol_h == outcol*h_expand */ - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - JSAMPROW inptr, outptr; - INT32 outvalue; - - h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor; - v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor; - numpix = h_expand * v_expand; - numpix2 = numpix/2; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data, cinfo->max_v_samp_factor, - cinfo->image_width, output_cols * h_expand); - - inrow = 0; - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - for (outcol = 0, outcol_h = 0; outcol < output_cols; - outcol++, outcol_h += h_expand) { - outvalue = 0; - for (v = 0; v < v_expand; v++) { - inptr = input_data[inrow+v] + outcol_h; - for (h = 0; h < h_expand; h++) { - outvalue += (INT32) GETJSAMPLE(*inptr++); - } - } - *outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix); - } - inrow += v_expand; - } -} - - -/* - * Downsample pixel values of a single component. - * This version handles the special case of a full-size component, - * without smoothing. - */ - -METHODDEF(void) -fullsize_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - /* Copy the data */ - jcopy_sample_rows(input_data, 0, output_data, 0, - cinfo->max_v_samp_factor, cinfo->image_width); - /* Edge-expand */ - expand_right_edge(output_data, cinfo->max_v_samp_factor, - cinfo->image_width, compptr->width_in_blocks * DCTSIZE); -} - - -/* - * Downsample pixel values of a single component. - * This version handles the common case of 2:1 horizontal and 1:1 vertical, - * without smoothing. - * - * A note about the "bias" calculations: when rounding fractional values to - * integer, we do not want to always round 0.5 up to the next integer. - * If we did that, we'd introduce a noticeable bias towards larger values. - * Instead, this code is arranged so that 0.5 will be rounded up or down at - * alternate pixel locations (a simple ordered dither pattern). - */ - -METHODDEF(void) -h2v1_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int outrow; - JDIMENSION outcol; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr, outptr; - register int bias; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data, cinfo->max_v_samp_factor, - cinfo->image_width, output_cols * 2); - - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr = input_data[outrow]; - bias = 0; /* bias = 0,1,0,1,... for successive samples */ - for (outcol = 0; outcol < output_cols; outcol++) { - *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr) + GETJSAMPLE(inptr[1]) - + bias) >> 1); - bias ^= 1; /* 0=>1, 1=>0 */ - inptr += 2; - } - } -} - - -/* - * Downsample pixel values of a single component. - * This version handles the standard case of 2:1 horizontal and 2:1 vertical, - * without smoothing. - */ - -METHODDEF(void) -h2v2_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int inrow, outrow; - JDIMENSION outcol; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr0, inptr1, outptr; - register int bias; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data, cinfo->max_v_samp_factor, - cinfo->image_width, output_cols * 2); - - inrow = 0; - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr0 = input_data[inrow]; - inptr1 = input_data[inrow+1]; - bias = 1; /* bias = 1,2,1,2,... for successive samples */ - for (outcol = 0; outcol < output_cols; outcol++) { - *outptr++ = (JSAMPLE) ((GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]) - + bias) >> 2); - bias ^= 3; /* 1=>2, 2=>1 */ - inptr0 += 2; inptr1 += 2; - } - inrow += 2; - } -} - - -#ifdef INPUT_SMOOTHING_SUPPORTED - -/* - * Downsample pixel values of a single component. - * This version handles the standard case of 2:1 horizontal and 2:1 vertical, - * with smoothing. One row of context is required. - */ - -METHODDEF(void) -h2v2_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int inrow, outrow; - JDIMENSION colctr; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr0, inptr1, above_ptr, below_ptr, outptr; - INT32 membersum, neighsum, memberscale, neighscale; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, - cinfo->image_width, output_cols * 2); - - /* We don't bother to form the individual "smoothed" input pixel values; - * we can directly compute the output which is the average of the four - * smoothed values. Each of the four member pixels contributes a fraction - * (1-8*SF) to its own smoothed image and a fraction SF to each of the three - * other smoothed pixels, therefore a total fraction (1-5*SF)/4 to the final - * output. The four corner-adjacent neighbor pixels contribute a fraction - * SF to just one smoothed pixel, or SF/4 to the final output; while the - * eight edge-adjacent neighbors contribute SF to each of two smoothed - * pixels, or SF/2 overall. In order to use integer arithmetic, these - * factors are scaled by 2^16 = 65536. - * Also recall that SF = smoothing_factor / 1024. - */ - - memberscale = 16384 - cinfo->smoothing_factor * 80; /* scaled (1-5*SF)/4 */ - neighscale = cinfo->smoothing_factor * 16; /* scaled SF/4 */ - - inrow = 0; - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr0 = input_data[inrow]; - inptr1 = input_data[inrow+1]; - above_ptr = input_data[inrow-1]; - below_ptr = input_data[inrow+2]; - - /* Special case for first column: pretend column -1 is same as column 0 */ - membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); - neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + - GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[2]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[2]); - neighsum += neighsum; - neighsum += GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[2]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[2]); - membersum = membersum * memberscale + neighsum * neighscale; - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; - - for (colctr = output_cols - 2; colctr > 0; colctr--) { - /* sum of pixels directly mapped to this output element */ - membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); - /* sum of edge-neighbor pixels */ - neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + - GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[2]) + - GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[2]); - /* The edge-neighbors count twice as much as corner-neighbors */ - neighsum += neighsum; - /* Add in the corner-neighbors */ - neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[2]) + - GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[2]); - /* form final output scaled up by 2^16 */ - membersum = membersum * memberscale + neighsum * neighscale; - /* round, descale and output it */ - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - inptr0 += 2; inptr1 += 2; above_ptr += 2; below_ptr += 2; - } - - /* Special case for last column */ - membersum = GETJSAMPLE(*inptr0) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(*inptr1) + GETJSAMPLE(inptr1[1]); - neighsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(*below_ptr) + GETJSAMPLE(below_ptr[1]) + - GETJSAMPLE(inptr0[-1]) + GETJSAMPLE(inptr0[1]) + - GETJSAMPLE(inptr1[-1]) + GETJSAMPLE(inptr1[1]); - neighsum += neighsum; - neighsum += GETJSAMPLE(above_ptr[-1]) + GETJSAMPLE(above_ptr[1]) + - GETJSAMPLE(below_ptr[-1]) + GETJSAMPLE(below_ptr[1]); - membersum = membersum * memberscale + neighsum * neighscale; - *outptr = (JSAMPLE) ((membersum + 32768) >> 16); - - inrow += 2; - } -} - - -/* - * Downsample pixel values of a single component. - * This version handles the special case of a full-size component, - * with smoothing. One row of context is required. - */ - -METHODDEF(void) -fullsize_smooth_downsample (j_compress_ptr cinfo, jpeg_component_info *compptr, - JSAMPARRAY input_data, JSAMPARRAY output_data) -{ - int outrow; - JDIMENSION colctr; - JDIMENSION output_cols = compptr->width_in_blocks * DCTSIZE; - register JSAMPROW inptr, above_ptr, below_ptr, outptr; - INT32 membersum, neighsum, memberscale, neighscale; - int colsum, lastcolsum, nextcolsum; - - /* Expand input data enough to let all the output samples be generated - * by the standard loop. Special-casing padded output would be more - * efficient. - */ - expand_right_edge(input_data - 1, cinfo->max_v_samp_factor + 2, - cinfo->image_width, output_cols); - - /* Each of the eight neighbor pixels contributes a fraction SF to the - * smoothed pixel, while the main pixel contributes (1-8*SF). In order - * to use integer arithmetic, these factors are multiplied by 2^16 = 65536. - * Also recall that SF = smoothing_factor / 1024. - */ - - memberscale = 65536L - cinfo->smoothing_factor * 512L; /* scaled 1-8*SF */ - neighscale = cinfo->smoothing_factor * 64; /* scaled SF */ - - for (outrow = 0; outrow < compptr->v_samp_factor; outrow++) { - outptr = output_data[outrow]; - inptr = input_data[outrow]; - above_ptr = input_data[outrow-1]; - below_ptr = input_data[outrow+1]; - - /* Special case for first column */ - colsum = GETJSAMPLE(*above_ptr++) + GETJSAMPLE(*below_ptr++) + - GETJSAMPLE(*inptr); - membersum = GETJSAMPLE(*inptr++); - nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + - GETJSAMPLE(*inptr); - neighsum = colsum + (colsum - membersum) + nextcolsum; - membersum = membersum * memberscale + neighsum * neighscale; - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - lastcolsum = colsum; colsum = nextcolsum; - - for (colctr = output_cols - 2; colctr > 0; colctr--) { - membersum = GETJSAMPLE(*inptr++); - above_ptr++; below_ptr++; - nextcolsum = GETJSAMPLE(*above_ptr) + GETJSAMPLE(*below_ptr) + - GETJSAMPLE(*inptr); - neighsum = lastcolsum + (colsum - membersum) + nextcolsum; - membersum = membersum * memberscale + neighsum * neighscale; - *outptr++ = (JSAMPLE) ((membersum + 32768) >> 16); - lastcolsum = colsum; colsum = nextcolsum; - } - - /* Special case for last column */ - membersum = GETJSAMPLE(*inptr); - neighsum = lastcolsum + (colsum - membersum) + colsum; - membersum = membersum * memberscale + neighsum * neighscale; - *outptr = (JSAMPLE) ((membersum + 32768) >> 16); - - } -} - -#endif /* INPUT_SMOOTHING_SUPPORTED */ - - -/* - * Module initialization routine for downsampling. - * Note that we must select a routine for each component. - */ - -GLOBAL(void) -jinit_downsampler (j_compress_ptr cinfo) -{ - my_downsample_ptr downsample; - int ci; - jpeg_component_info * compptr; - boolean smoothok = TRUE; - - downsample = (my_downsample_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_downsampler)); - cinfo->downsample = (struct jpeg_downsampler *) downsample; - downsample->pub.start_pass = start_pass_downsample; - downsample->pub.downsample = sep_downsample; - downsample->pub.need_context_rows = FALSE; - - if (cinfo->CCIR601_sampling) - ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); - - /* Verify we can handle the sampling factors, and set up method pointers */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->h_samp_factor == cinfo->max_h_samp_factor && - compptr->v_samp_factor == cinfo->max_v_samp_factor) { -#ifdef INPUT_SMOOTHING_SUPPORTED - if (cinfo->smoothing_factor) { - downsample->methods[ci] = fullsize_smooth_downsample; - downsample->pub.need_context_rows = TRUE; - } else -#endif - downsample->methods[ci] = fullsize_downsample; - } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && - compptr->v_samp_factor == cinfo->max_v_samp_factor) { - smoothok = FALSE; - downsample->methods[ci] = h2v1_downsample; - } else if (compptr->h_samp_factor * 2 == cinfo->max_h_samp_factor && - compptr->v_samp_factor * 2 == cinfo->max_v_samp_factor) { -#ifdef INPUT_SMOOTHING_SUPPORTED - if (cinfo->smoothing_factor) { - downsample->methods[ci] = h2v2_smooth_downsample; - downsample->pub.need_context_rows = TRUE; - } else -#endif - downsample->methods[ci] = h2v2_downsample; - } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 && - (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) { - smoothok = FALSE; - downsample->methods[ci] = int_downsample; - } else - ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); - } - -#ifdef INPUT_SMOOTHING_SUPPORTED - if (cinfo->smoothing_factor && !smoothok) - TRACEMS(cinfo, 0, JTRC_SMOOTH_NOTIMPL); -#endif -} diff --git a/oversampling/WDL/jpeglib/jctrans.c b/oversampling/WDL/jpeglib/jctrans.c deleted file mode 100644 index 0e6d707..0000000 --- a/oversampling/WDL/jpeglib/jctrans.c +++ /dev/null @@ -1,388 +0,0 @@ -/* - * jctrans.c - * - * Copyright (C) 1995-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains library routines for transcoding compression, - * that is, writing raw DCT coefficient arrays to an output JPEG file. - * The routines in jcapimin.c will also be needed by a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Forward declarations */ -LOCAL(void) transencode_master_selection - JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); -LOCAL(void) transencode_coef_controller - JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays)); - - -/* - * Compression initialization for writing raw-coefficient data. - * Before calling this, all parameters and a data destination must be set up. - * Call jpeg_finish_compress() to actually write the data. - * - * The number of passed virtual arrays must match cinfo->num_components. - * Note that the virtual arrays need not be filled or even realized at - * the time write_coefficients is called; indeed, if the virtual arrays - * were requested from this compression object's memory manager, they - * typically will be realized during this routine and filled afterwards. - */ - -GLOBAL(void) -jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays) -{ - if (cinfo->global_state != CSTATE_START) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Mark all tables to be written */ - jpeg_suppress_tables(cinfo, FALSE); - /* (Re)initialize error mgr and destination modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->dest->init_destination) (cinfo); - /* Perform master selection of active modules */ - transencode_master_selection(cinfo, coef_arrays); - /* Wait for jpeg_finish_compress() call */ - cinfo->next_scanline = 0; /* so jpeg_write_marker works */ - cinfo->global_state = CSTATE_WRCOEFS; -} - - -/* - * Initialize the compression object with default parameters, - * then copy from the source object all parameters needed for lossless - * transcoding. Parameters that can be varied without loss (such as - * scan script and Huffman optimization) are left in their default states. - */ - -GLOBAL(void) -jpeg_copy_critical_parameters (j_decompress_ptr srcinfo, - j_compress_ptr dstinfo) -{ - JQUANT_TBL ** qtblptr; - jpeg_component_info *incomp, *outcomp; - JQUANT_TBL *c_quant, *slot_quant; - int tblno, ci, coefi; - - /* Safety check to ensure start_compress not called yet. */ - if (dstinfo->global_state != CSTATE_START) - ERREXIT1(dstinfo, JERR_BAD_STATE, dstinfo->global_state); - /* Copy fundamental image dimensions */ - dstinfo->image_width = srcinfo->image_width; - dstinfo->image_height = srcinfo->image_height; - dstinfo->input_components = srcinfo->num_components; - dstinfo->in_color_space = srcinfo->jpeg_color_space; - /* Initialize all parameters to default values */ - jpeg_set_defaults(dstinfo); - /* jpeg_set_defaults may choose wrong colorspace, eg YCbCr if input is RGB. - * Fix it to get the right header markers for the image colorspace. - */ - jpeg_set_colorspace(dstinfo, srcinfo->jpeg_color_space); - dstinfo->data_precision = srcinfo->data_precision; - dstinfo->CCIR601_sampling = srcinfo->CCIR601_sampling; - /* Copy the source's quantization tables. */ - for (tblno = 0; tblno < NUM_QUANT_TBLS; tblno++) { - if (srcinfo->quant_tbl_ptrs[tblno] != NULL) { - qtblptr = & dstinfo->quant_tbl_ptrs[tblno]; - if (*qtblptr == NULL) - *qtblptr = jpeg_alloc_quant_table((j_common_ptr) dstinfo); - MEMCOPY((*qtblptr)->quantval, - srcinfo->quant_tbl_ptrs[tblno]->quantval, - SIZEOF((*qtblptr)->quantval)); - (*qtblptr)->sent_table = FALSE; - } - } - /* Copy the source's per-component info. - * Note we assume jpeg_set_defaults has allocated the dest comp_info array. - */ - dstinfo->num_components = srcinfo->num_components; - if (dstinfo->num_components < 1 || dstinfo->num_components > MAX_COMPONENTS) - ERREXIT2(dstinfo, JERR_COMPONENT_COUNT, dstinfo->num_components, - MAX_COMPONENTS); - for (ci = 0, incomp = srcinfo->comp_info, outcomp = dstinfo->comp_info; - ci < dstinfo->num_components; ci++, incomp++, outcomp++) { - outcomp->component_id = incomp->component_id; - outcomp->h_samp_factor = incomp->h_samp_factor; - outcomp->v_samp_factor = incomp->v_samp_factor; - outcomp->quant_tbl_no = incomp->quant_tbl_no; - /* Make sure saved quantization table for component matches the qtable - * slot. If not, the input file re-used this qtable slot. - * IJG encoder currently cannot duplicate this. - */ - tblno = outcomp->quant_tbl_no; - if (tblno < 0 || tblno >= NUM_QUANT_TBLS || - srcinfo->quant_tbl_ptrs[tblno] == NULL) - ERREXIT1(dstinfo, JERR_NO_QUANT_TABLE, tblno); - slot_quant = srcinfo->quant_tbl_ptrs[tblno]; - c_quant = incomp->quant_table; - if (c_quant != NULL) { - for (coefi = 0; coefi < DCTSIZE2; coefi++) { - if (c_quant->quantval[coefi] != slot_quant->quantval[coefi]) - ERREXIT1(dstinfo, JERR_MISMATCHED_QUANT_TABLE, tblno); - } - } - /* Note: we do not copy the source's Huffman table assignments; - * instead we rely on jpeg_set_colorspace to have made a suitable choice. - */ - } - /* Also copy JFIF version and resolution information, if available. - * Strictly speaking this isn't "critical" info, but it's nearly - * always appropriate to copy it if available. In particular, - * if the application chooses to copy JFIF 1.02 extension markers from - * the source file, we need to copy the version to make sure we don't - * emit a file that has 1.02 extensions but a claimed version of 1.01. - * We will *not*, however, copy version info from mislabeled "2.01" files. - */ - if (srcinfo->saw_JFIF_marker) { - if (srcinfo->JFIF_major_version == 1) { - dstinfo->JFIF_major_version = srcinfo->JFIF_major_version; - dstinfo->JFIF_minor_version = srcinfo->JFIF_minor_version; - } - dstinfo->density_unit = srcinfo->density_unit; - dstinfo->X_density = srcinfo->X_density; - dstinfo->Y_density = srcinfo->Y_density; - } -} - - -/* - * Master selection of compression modules for transcoding. - * This substitutes for jcinit.c's initialization of the full compressor. - */ - -LOCAL(void) -transencode_master_selection (j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays) -{ - /* Although we don't actually use input_components for transcoding, - * jcmaster.c's initial_setup will complain if input_components is 0. - */ - cinfo->input_components = 1; - /* Initialize master control (includes parameter checking/processing) */ - jinit_c_master_control(cinfo, TRUE /* transcode only */); - - /* Entropy encoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef C_PROGRESSIVE_SUPPORTED - jinit_phuff_encoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_encoder(cinfo); - } - - /* We need a special coefficient buffer controller. */ - transencode_coef_controller(cinfo, coef_arrays); - - jinit_marker_writer(cinfo); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Write the datastream header (SOI, JFIF) immediately. - * Frame and scan headers are postponed till later. - * This lets application insert special markers after the SOI. - */ - (*cinfo->marker->write_file_header) (cinfo); -} - - -/* - * The rest of this file is a special implementation of the coefficient - * buffer controller. This is similar to jccoefct.c, but it handles only - * output from presupplied virtual arrays. Furthermore, we generate any - * dummy padding blocks on-the-fly rather than expecting them to be present - * in the arrays. - */ - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_c_coef_controller pub; /* public fields */ - - JDIMENSION iMCU_row_num; /* iMCU row # within image */ - JDIMENSION mcu_ctr; /* counts MCUs processed in current row */ - int MCU_vert_offset; /* counts MCU rows within iMCU row */ - int MCU_rows_per_iMCU_row; /* number of such rows needed */ - - /* Virtual block array for each component. */ - jvirt_barray_ptr * whole_image; - - /* Workspace for constructing dummy blocks at right/bottom edges. */ - JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU]; -} my_coef_controller; - -typedef my_coef_controller * my_coef_ptr; - - -LOCAL(void) -start_iMCU_row (j_compress_ptr cinfo) -/* Reset within-iMCU-row counters for a new row */ -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* In an interleaved scan, an MCU row is the same as an iMCU row. - * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. - * But at the bottom of the image, process only what's left. - */ - if (cinfo->comps_in_scan > 1) { - coef->MCU_rows_per_iMCU_row = 1; - } else { - if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1)) - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; - else - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; - } - - coef->mcu_ctr = 0; - coef->MCU_vert_offset = 0; -} - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - if (pass_mode != JBUF_CRANK_DEST) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - coef->iMCU_row_num = 0; - start_iMCU_row(cinfo); -} - - -/* - * Process some data. - * We process the equivalent of one fully interleaved MCU row ("iMCU" row) - * per call, ie, v_samp_factor block rows for each component in the scan. - * The data is obtained from the virtual arrays and fed to the entropy coder. - * Returns TRUE if the iMCU row is completed, FALSE if suspended. - * - * NB: input_buf is ignored; it is likely to be a NULL pointer. - */ - -METHODDEF(boolean) -compress_output (j_compress_ptr cinfo, JSAMPIMAGE input_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - int blkn, ci, xindex, yindex, yoffset, blockcnt; - JDIMENSION start_col; - JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; - JBLOCKROW MCU_buffer[C_MAX_BLOCKS_IN_MCU]; - JBLOCKROW buffer_ptr; - jpeg_component_info *compptr; - - /* Align the virtual buffers for the components used in this scan. */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - buffer[ci] = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], - coef->iMCU_row_num * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - } - - /* Loop to process one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->mcu_ctr; MCU_col_num < cinfo->MCUs_per_row; - MCU_col_num++) { - /* Construct list of pointers to DCT blocks belonging to this MCU */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - start_col = MCU_col_num * compptr->MCU_width; - blockcnt = (MCU_col_num < last_MCU_col) ? compptr->MCU_width - : compptr->last_col_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - if (coef->iMCU_row_num < last_iMCU_row || - yindex+yoffset < compptr->last_row_height) { - /* Fill in pointers to real blocks in this row */ - buffer_ptr = buffer[ci][yindex+yoffset] + start_col; - for (xindex = 0; xindex < blockcnt; xindex++) - MCU_buffer[blkn++] = buffer_ptr++; - } else { - /* At bottom of image, need a whole row of dummy blocks */ - xindex = 0; - } - /* Fill in any dummy blocks needed in this row. - * Dummy blocks are filled in the same way as in jccoefct.c: - * all zeroes in the AC entries, DC entries equal to previous - * block's DC value. The init routine has already zeroed the - * AC entries, so we need only set the DC entries correctly. - */ - for (; xindex < compptr->MCU_width; xindex++) { - MCU_buffer[blkn] = coef->dummy_buffer[blkn]; - MCU_buffer[blkn][0][0] = MCU_buffer[blkn-1][0][0]; - blkn++; - } - } - } - /* Try to write the MCU. */ - if (! (*cinfo->entropy->encode_mcu) (cinfo, MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->mcu_ctr = MCU_col_num; - return FALSE; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->mcu_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - coef->iMCU_row_num++; - start_iMCU_row(cinfo); - return TRUE; -} - - -/* - * Initialize coefficient buffer controller. - * - * Each passed coefficient array must be the right size for that - * coefficient: width_in_blocks wide and height_in_blocks high, - * with unitheight at least v_samp_factor. - */ - -LOCAL(void) -transencode_coef_controller (j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays) -{ - my_coef_ptr coef; - JBLOCKROW buffer; - int i; - - coef = (my_coef_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_coef_controller)); - cinfo->coef = (struct jpeg_c_coef_controller *) coef; - coef->pub.start_pass = start_pass_coef; - coef->pub.compress_data = compress_output; - - /* Save pointer to virtual arrays */ - coef->whole_image = coef_arrays; - - /* Allocate and pre-zero space for dummy DCT blocks. */ - buffer = (JBLOCKROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) { - coef->dummy_buffer[i] = buffer + i; - } -} diff --git a/oversampling/WDL/jpeglib/jdapimin.c b/oversampling/WDL/jpeglib/jdapimin.c deleted file mode 100644 index cadb59f..0000000 --- a/oversampling/WDL/jpeglib/jdapimin.c +++ /dev/null @@ -1,395 +0,0 @@ -/* - * jdapimin.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the decompression half - * of the JPEG library. These are the "minimum" API routines that may be - * needed in either the normal full-decompression case or the - * transcoding-only case. - * - * Most of the routines intended to be called directly by an application - * are in this file or in jdapistd.c. But also see jcomapi.c for routines - * shared by compression and decompression, and jdtrans.c for the transcoding - * case. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * Initialization of a JPEG decompression object. - * The error manager must already be set up (in case memory manager fails). - */ - -GLOBAL(void) -jpeg_CreateDecompress (j_decompress_ptr cinfo, int version, size_t structsize) -{ - int i; - - /* Guard against version mismatches between library and caller. */ - cinfo->mem = NULL; /* so jpeg_destroy knows mem mgr not called */ - if (version != JPEG_LIB_VERSION) - ERREXIT2(cinfo, JERR_BAD_LIB_VERSION, JPEG_LIB_VERSION, version); - if (structsize != SIZEOF(struct jpeg_decompress_struct)) - ERREXIT2(cinfo, JERR_BAD_STRUCT_SIZE, - (int) SIZEOF(struct jpeg_decompress_struct), (int) structsize); - - /* For debugging purposes, we zero the whole master structure. - * But the application has already set the err pointer, and may have set - * client_data, so we have to save and restore those fields. - * Note: if application hasn't set client_data, tools like Purify may - * complain here. - */ - { - struct jpeg_error_mgr * err = cinfo->err; - void * client_data = cinfo->client_data; /* ignore Purify complaint here */ - MEMZERO(cinfo, SIZEOF(struct jpeg_decompress_struct)); - cinfo->err = err; - cinfo->client_data = client_data; - } - cinfo->is_decompressor = TRUE; - - /* Initialize a memory manager instance for this object */ - jinit_memory_mgr((j_common_ptr) cinfo); - - /* Zero out pointers to permanent structures. */ - cinfo->progress = NULL; - cinfo->src = NULL; - - for (i = 0; i < NUM_QUANT_TBLS; i++) - cinfo->quant_tbl_ptrs[i] = NULL; - - for (i = 0; i < NUM_HUFF_TBLS; i++) { - cinfo->dc_huff_tbl_ptrs[i] = NULL; - cinfo->ac_huff_tbl_ptrs[i] = NULL; - } - - /* Initialize marker processor so application can override methods - * for COM, APPn markers before calling jpeg_read_header. - */ - cinfo->marker_list = NULL; - jinit_marker_reader(cinfo); - - /* And initialize the overall input controller. */ - jinit_input_controller(cinfo); - - /* OK, I'm ready */ - cinfo->global_state = DSTATE_START; -} - - -/* - * Destruction of a JPEG decompression object - */ - -GLOBAL(void) -jpeg_destroy_decompress (j_decompress_ptr cinfo) -{ - jpeg_destroy((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Abort processing of a JPEG decompression operation, - * but don't destroy the object itself. - */ - -GLOBAL(void) -jpeg_abort_decompress (j_decompress_ptr cinfo) -{ - jpeg_abort((j_common_ptr) cinfo); /* use common routine */ -} - - -/* - * Set default decompression parameters. - */ - -LOCAL(void) -default_decompress_parms (j_decompress_ptr cinfo) -{ - /* Guess the input colorspace, and set output colorspace accordingly. */ - /* (Wish JPEG committee had provided a real way to specify this...) */ - /* Note application may override our guesses. */ - switch (cinfo->num_components) { - case 1: - cinfo->jpeg_color_space = JCS_GRAYSCALE; - cinfo->out_color_space = JCS_GRAYSCALE; - break; - - case 3: - if (cinfo->saw_JFIF_marker) { - cinfo->jpeg_color_space = JCS_YCbCr; /* JFIF implies YCbCr */ - } else if (cinfo->saw_Adobe_marker) { - switch (cinfo->Adobe_transform) { - case 0: - cinfo->jpeg_color_space = JCS_RGB; - break; - case 1: - cinfo->jpeg_color_space = JCS_YCbCr; - break; - default: - WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); - cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ - break; - } - } else { - /* Saw no special markers, try to guess from the component IDs */ - int cid0 = cinfo->comp_info[0].component_id; - int cid1 = cinfo->comp_info[1].component_id; - int cid2 = cinfo->comp_info[2].component_id; - - if (cid0 == 1 && cid1 == 2 && cid2 == 3) - cinfo->jpeg_color_space = JCS_YCbCr; /* assume JFIF w/out marker */ - else if (cid0 == 82 && cid1 == 71 && cid2 == 66) - cinfo->jpeg_color_space = JCS_RGB; /* ASCII 'R', 'G', 'B' */ - else { - TRACEMS3(cinfo, 1, JTRC_UNKNOWN_IDS, cid0, cid1, cid2); - cinfo->jpeg_color_space = JCS_YCbCr; /* assume it's YCbCr */ - } - } - /* Always guess RGB is proper output colorspace. */ - cinfo->out_color_space = JCS_RGB; - break; - - case 4: - if (cinfo->saw_Adobe_marker) { - switch (cinfo->Adobe_transform) { - case 0: - cinfo->jpeg_color_space = JCS_CMYK; - break; - case 2: - cinfo->jpeg_color_space = JCS_YCCK; - break; - default: - WARNMS1(cinfo, JWRN_ADOBE_XFORM, cinfo->Adobe_transform); - cinfo->jpeg_color_space = JCS_YCCK; /* assume it's YCCK */ - break; - } - } else { - /* No special markers, assume straight CMYK. */ - cinfo->jpeg_color_space = JCS_CMYK; - } - cinfo->out_color_space = JCS_CMYK; - break; - - default: - cinfo->jpeg_color_space = JCS_UNKNOWN; - cinfo->out_color_space = JCS_UNKNOWN; - break; - } - - /* Set defaults for other decompression parameters. */ - cinfo->scale_num = 1; /* 1:1 scaling */ - cinfo->scale_denom = 1; - cinfo->output_gamma = 1.0; - cinfo->buffered_image = FALSE; - cinfo->raw_data_out = FALSE; - cinfo->dct_method = JDCT_DEFAULT; - cinfo->do_fancy_upsampling = TRUE; - cinfo->do_block_smoothing = TRUE; - cinfo->quantize_colors = FALSE; - /* We set these in case application only sets quantize_colors. */ - cinfo->dither_mode = JDITHER_FS; -#ifdef QUANT_2PASS_SUPPORTED - cinfo->two_pass_quantize = TRUE; -#else - cinfo->two_pass_quantize = FALSE; -#endif - cinfo->desired_number_of_colors = 256; - cinfo->colormap = NULL; - /* Initialize for no mode change in buffered-image mode. */ - cinfo->enable_1pass_quant = FALSE; - cinfo->enable_external_quant = FALSE; - cinfo->enable_2pass_quant = FALSE; -} - - -/* - * Decompression startup: read start of JPEG datastream to see what's there. - * Need only initialize JPEG object and supply a data source before calling. - * - * This routine will read as far as the first SOS marker (ie, actual start of - * compressed data), and will save all tables and parameters in the JPEG - * object. It will also initialize the decompression parameters to default - * values, and finally return JPEG_HEADER_OK. On return, the application may - * adjust the decompression parameters and then call jpeg_start_decompress. - * (Or, if the application only wanted to determine the image parameters, - * the data need not be decompressed. In that case, call jpeg_abort or - * jpeg_destroy to release any temporary space.) - * If an abbreviated (tables only) datastream is presented, the routine will - * return JPEG_HEADER_TABLES_ONLY upon reaching EOI. The application may then - * re-use the JPEG object to read the abbreviated image datastream(s). - * It is unnecessary (but OK) to call jpeg_abort in this case. - * The JPEG_SUSPENDED return code only occurs if the data source module - * requests suspension of the decompressor. In this case the application - * should load more source data and then re-call jpeg_read_header to resume - * processing. - * If a non-suspending data source is used and require_image is TRUE, then the - * return code need not be inspected since only JPEG_HEADER_OK is possible. - * - * This routine is now just a front end to jpeg_consume_input, with some - * extra error checking. - */ - -GLOBAL(int) -jpeg_read_header (j_decompress_ptr cinfo, boolean require_image) -{ - int retcode; - - if (cinfo->global_state != DSTATE_START && - cinfo->global_state != DSTATE_INHEADER) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - retcode = jpeg_consume_input(cinfo); - - switch (retcode) { - case JPEG_REACHED_SOS: - retcode = JPEG_HEADER_OK; - break; - case JPEG_REACHED_EOI: - if (require_image) /* Complain if application wanted an image */ - ERREXIT(cinfo, JERR_NO_IMAGE); - /* Reset to start state; it would be safer to require the application to - * call jpeg_abort, but we can't change it now for compatibility reasons. - * A side effect is to free any temporary memory (there shouldn't be any). - */ - jpeg_abort((j_common_ptr) cinfo); /* sets state = DSTATE_START */ - retcode = JPEG_HEADER_TABLES_ONLY; - break; - case JPEG_SUSPENDED: - /* no work */ - break; - } - - return retcode; -} - - -/* - * Consume data in advance of what the decompressor requires. - * This can be called at any time once the decompressor object has - * been created and a data source has been set up. - * - * This routine is essentially a state machine that handles a couple - * of critical state-transition actions, namely initial setup and - * transition from header scanning to ready-for-start_decompress. - * All the actual input is done via the input controller's consume_input - * method. - */ - -GLOBAL(int) -jpeg_consume_input (j_decompress_ptr cinfo) -{ - int retcode = JPEG_SUSPENDED; - - /* NB: every possible DSTATE value should be listed in this switch */ - switch (cinfo->global_state) { - case DSTATE_START: - /* Start-of-datastream actions: reset appropriate modules */ - (*cinfo->inputctl->reset_input_controller) (cinfo); - /* Initialize application's data source module */ - (*cinfo->src->init_source) (cinfo); - cinfo->global_state = DSTATE_INHEADER; - /*FALLTHROUGH*/ - case DSTATE_INHEADER: - retcode = (*cinfo->inputctl->consume_input) (cinfo); - if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */ - /* Set up default parameters based on header data */ - default_decompress_parms(cinfo); - /* Set global state: ready for start_decompress */ - cinfo->global_state = DSTATE_READY; - } - break; - case DSTATE_READY: - /* Can't advance past first SOS until start_decompress is called */ - retcode = JPEG_REACHED_SOS; - break; - case DSTATE_PRELOAD: - case DSTATE_PRESCAN: - case DSTATE_SCANNING: - case DSTATE_RAW_OK: - case DSTATE_BUFIMAGE: - case DSTATE_BUFPOST: - case DSTATE_STOPPING: - retcode = (*cinfo->inputctl->consume_input) (cinfo); - break; - default: - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - } - return retcode; -} - - -/* - * Have we finished reading the input file? - */ - -GLOBAL(boolean) -jpeg_input_complete (j_decompress_ptr cinfo) -{ - /* Check for valid jpeg object */ - if (cinfo->global_state < DSTATE_START || - cinfo->global_state > DSTATE_STOPPING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - return cinfo->inputctl->eoi_reached; -} - - -/* - * Is there more than one scan? - */ - -GLOBAL(boolean) -jpeg_has_multiple_scans (j_decompress_ptr cinfo) -{ - /* Only valid after jpeg_read_header completes */ - if (cinfo->global_state < DSTATE_READY || - cinfo->global_state > DSTATE_STOPPING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - return cinfo->inputctl->has_multiple_scans; -} - - -/* - * Finish JPEG decompression. - * - * This will normally just verify the file trailer and release temp storage. - * - * Returns FALSE if suspended. The return value need be inspected only if - * a suspending data source is used. - */ - -GLOBAL(boolean) -jpeg_finish_decompress (j_decompress_ptr cinfo) -{ - if ((cinfo->global_state == DSTATE_SCANNING || - cinfo->global_state == DSTATE_RAW_OK) && ! cinfo->buffered_image) { - /* Terminate final pass of non-buffered mode */ - if (cinfo->output_scanline < cinfo->output_height) - ERREXIT(cinfo, JERR_TOO_LITTLE_DATA); - (*cinfo->master->finish_output_pass) (cinfo); - cinfo->global_state = DSTATE_STOPPING; - } else if (cinfo->global_state == DSTATE_BUFIMAGE) { - /* Finishing after a buffered-image operation */ - cinfo->global_state = DSTATE_STOPPING; - } else if (cinfo->global_state != DSTATE_STOPPING) { - /* STOPPING = repeat call after a suspension, anything else is error */ - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - } - /* Read until EOI */ - while (! cinfo->inputctl->eoi_reached) { - if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) - return FALSE; /* Suspend, come back later */ - } - /* Do final cleanup */ - (*cinfo->src->term_source) (cinfo); - /* We can use jpeg_abort to release memory and reset global_state */ - jpeg_abort((j_common_ptr) cinfo); - return TRUE; -} diff --git a/oversampling/WDL/jpeglib/jdapistd.c b/oversampling/WDL/jpeglib/jdapistd.c deleted file mode 100644 index c8e3fa0..0000000 --- a/oversampling/WDL/jpeglib/jdapistd.c +++ /dev/null @@ -1,275 +0,0 @@ -/* - * jdapistd.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains application interface code for the decompression half - * of the JPEG library. These are the "standard" API routines that are - * used in the normal full-decompression case. They are not used by a - * transcoding-only application. Note that if an application links in - * jpeg_start_decompress, it will end up linking in the entire decompressor. - * We thus must separate this file from jdapimin.c to avoid linking the - * whole decompression library into a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Forward declarations */ -LOCAL(boolean) output_pass_setup JPP((j_decompress_ptr cinfo)); - - -/* - * Decompression initialization. - * jpeg_read_header must be completed before calling this. - * - * If a multipass operating mode was selected, this will do all but the - * last pass, and thus may take a great deal of time. - * - * Returns FALSE if suspended. The return value need be inspected only if - * a suspending data source is used. - */ - -GLOBAL(boolean) -jpeg_start_decompress (j_decompress_ptr cinfo) -{ - if (cinfo->global_state == DSTATE_READY) { - /* First call: initialize master control, select active modules */ - jinit_master_decompress(cinfo); - if (cinfo->buffered_image) { - /* No more work here; expecting jpeg_start_output next */ - cinfo->global_state = DSTATE_BUFIMAGE; - return TRUE; - } - cinfo->global_state = DSTATE_PRELOAD; - } - if (cinfo->global_state == DSTATE_PRELOAD) { - /* If file has multiple scans, absorb them all into the coef buffer */ - if (cinfo->inputctl->has_multiple_scans) { -#ifdef D_MULTISCAN_FILES_SUPPORTED - for (;;) { - int retcode; - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - /* Absorb some more input */ - retcode = (*cinfo->inputctl->consume_input) (cinfo); - if (retcode == JPEG_SUSPENDED) - return FALSE; - if (retcode == JPEG_REACHED_EOI) - break; - /* Advance progress counter if appropriate */ - if (cinfo->progress != NULL && - (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { - if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { - /* jdmaster underestimated number of scans; ratchet up one scan */ - cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; - } - } - } -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif /* D_MULTISCAN_FILES_SUPPORTED */ - } - cinfo->output_scan_number = cinfo->input_scan_number; - } else if (cinfo->global_state != DSTATE_PRESCAN) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Perform any dummy output passes, and set up for the final pass */ - return output_pass_setup(cinfo); -} - - -/* - * Set up for an output pass, and perform any dummy pass(es) needed. - * Common subroutine for jpeg_start_decompress and jpeg_start_output. - * Entry: global_state = DSTATE_PRESCAN only if previously suspended. - * Exit: If done, returns TRUE and sets global_state for proper output mode. - * If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN. - */ - -LOCAL(boolean) -output_pass_setup (j_decompress_ptr cinfo) -{ - if (cinfo->global_state != DSTATE_PRESCAN) { - /* First call: do pass setup */ - (*cinfo->master->prepare_for_output_pass) (cinfo); - cinfo->output_scanline = 0; - cinfo->global_state = DSTATE_PRESCAN; - } - /* Loop over any required dummy passes */ - while (cinfo->master->is_dummy_pass) { -#ifdef QUANT_2PASS_SUPPORTED - /* Crank through the dummy pass */ - while (cinfo->output_scanline < cinfo->output_height) { - JDIMENSION last_scanline; - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->output_scanline; - cinfo->progress->pass_limit = (long) cinfo->output_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - /* Process some data */ - last_scanline = cinfo->output_scanline; - (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL, - &cinfo->output_scanline, (JDIMENSION) 0); - if (cinfo->output_scanline == last_scanline) - return FALSE; /* No progress made, must suspend */ - } - /* Finish up dummy pass, and set up for another one */ - (*cinfo->master->finish_output_pass) (cinfo); - (*cinfo->master->prepare_for_output_pass) (cinfo); - cinfo->output_scanline = 0; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif /* QUANT_2PASS_SUPPORTED */ - } - /* Ready for application to drive output pass through - * jpeg_read_scanlines or jpeg_read_raw_data. - */ - cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING; - return TRUE; -} - - -/* - * Read some scanlines of data from the JPEG decompressor. - * - * The return value will be the number of lines actually read. - * This may be less than the number requested in several cases, - * including bottom of image, data source suspension, and operating - * modes that emit multiple scanlines at a time. - * - * Note: we warn about excess calls to jpeg_read_scanlines() since - * this likely signals an application programmer error. However, - * an oversize buffer (max_lines > scanlines remaining) is not an error. - */ - -GLOBAL(JDIMENSION) -jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines, - JDIMENSION max_lines) -{ - JDIMENSION row_ctr; - - if (cinfo->global_state != DSTATE_SCANNING) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->output_scanline >= cinfo->output_height) { - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - return 0; - } - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->output_scanline; - cinfo->progress->pass_limit = (long) cinfo->output_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Process some data */ - row_ctr = 0; - (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines); - cinfo->output_scanline += row_ctr; - return row_ctr; -} - - -/* - * Alternate entry point to read raw data. - * Processes exactly one iMCU row per call, unless suspended. - */ - -GLOBAL(JDIMENSION) -jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data, - JDIMENSION max_lines) -{ - JDIMENSION lines_per_iMCU_row; - - if (cinfo->global_state != DSTATE_RAW_OK) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - if (cinfo->output_scanline >= cinfo->output_height) { - WARNMS(cinfo, JWRN_TOO_MUCH_DATA); - return 0; - } - - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) { - cinfo->progress->pass_counter = (long) cinfo->output_scanline; - cinfo->progress->pass_limit = (long) cinfo->output_height; - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - } - - /* Verify that at least one iMCU row can be returned. */ - lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size; - if (max_lines < lines_per_iMCU_row) - ERREXIT(cinfo, JERR_BUFFER_SIZE); - - /* Decompress directly into user's buffer. */ - if (! (*cinfo->coef->decompress_data) (cinfo, data)) - return 0; /* suspension forced, can do nothing more */ - - /* OK, we processed one iMCU row. */ - cinfo->output_scanline += lines_per_iMCU_row; - return lines_per_iMCU_row; -} - - -/* Additional entry points for buffered-image mode. */ - -#ifdef D_MULTISCAN_FILES_SUPPORTED - -/* - * Initialize for an output pass in buffered-image mode. - */ - -GLOBAL(boolean) -jpeg_start_output (j_decompress_ptr cinfo, int scan_number) -{ - if (cinfo->global_state != DSTATE_BUFIMAGE && - cinfo->global_state != DSTATE_PRESCAN) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - /* Limit scan number to valid range */ - if (scan_number <= 0) - scan_number = 1; - if (cinfo->inputctl->eoi_reached && - scan_number > cinfo->input_scan_number) - scan_number = cinfo->input_scan_number; - cinfo->output_scan_number = scan_number; - /* Perform any dummy output passes, and set up for the real pass */ - return output_pass_setup(cinfo); -} - - -/* - * Finish up after an output pass in buffered-image mode. - * - * Returns FALSE if suspended. The return value need be inspected only if - * a suspending data source is used. - */ - -GLOBAL(boolean) -jpeg_finish_output (j_decompress_ptr cinfo) -{ - if ((cinfo->global_state == DSTATE_SCANNING || - cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) { - /* Terminate this pass. */ - /* We do not require the whole pass to have been completed. */ - (*cinfo->master->finish_output_pass) (cinfo); - cinfo->global_state = DSTATE_BUFPOST; - } else if (cinfo->global_state != DSTATE_BUFPOST) { - /* BUFPOST = repeat call after a suspension, anything else is error */ - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - } - /* Read markers looking for SOS or EOI */ - while (cinfo->input_scan_number <= cinfo->output_scan_number && - ! cinfo->inputctl->eoi_reached) { - if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED) - return FALSE; /* Suspend, come back later */ - } - cinfo->global_state = DSTATE_BUFIMAGE; - return TRUE; -} - -#endif /* D_MULTISCAN_FILES_SUPPORTED */ diff --git a/oversampling/WDL/jpeglib/jdatadst.c b/oversampling/WDL/jpeglib/jdatadst.c deleted file mode 100644 index a8f6fb0..0000000 --- a/oversampling/WDL/jpeglib/jdatadst.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * jdatadst.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains compression data destination routines for the case of - * emitting JPEG data to a file (or any stdio stream). While these routines - * are sufficient for most applications, some will want to use a different - * destination manager. - * IMPORTANT: we assume that fwrite() will correctly transcribe an array of - * JOCTETs into 8-bit-wide elements on external storage. If char is wider - * than 8 bits on your machine, you may need to do some tweaking. - */ - -/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jerror.h" - - -/* Expanded data destination object for stdio output */ - -typedef struct { - struct jpeg_destination_mgr pub; /* public fields */ - - FILE * outfile; /* target stream */ - JOCTET * buffer; /* start of buffer */ -} my_destination_mgr; - -typedef my_destination_mgr * my_dest_ptr; - -#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */ - - -/* - * Initialize destination --- called by jpeg_start_compress - * before any data is actually written. - */ - -METHODDEF(void) -init_destination (j_compress_ptr cinfo) -{ - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - - /* Allocate the output buffer --- it will be released when done with image */ - dest->buffer = (JOCTET *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - OUTPUT_BUF_SIZE * SIZEOF(JOCTET)); - - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; -} - - -/* - * Empty the output buffer --- called whenever buffer fills up. - * - * In typical applications, this should write the entire output buffer - * (ignoring the current state of next_output_byte & free_in_buffer), - * reset the pointer & count to the start of the buffer, and return TRUE - * indicating that the buffer has been dumped. - * - * In applications that need to be able to suspend compression due to output - * overrun, a FALSE return indicates that the buffer cannot be emptied now. - * In this situation, the compressor will return to its caller (possibly with - * an indication that it has not accepted all the supplied scanlines). The - * application should resume compression after it has made more room in the - * output buffer. Note that there are substantial restrictions on the use of - * suspension --- see the documentation. - * - * When suspending, the compressor will back up to a convenient restart point - * (typically the start of the current MCU). next_output_byte & free_in_buffer - * indicate where the restart point will be if the current call returns FALSE. - * Data beyond this point will be regenerated after resumption, so do not - * write it out when emptying the buffer externally. - */ - -METHODDEF(boolean) -empty_output_buffer (j_compress_ptr cinfo) -{ - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - - if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) != - (size_t) OUTPUT_BUF_SIZE) - ERREXIT(cinfo, JERR_FILE_WRITE); - - dest->pub.next_output_byte = dest->buffer; - dest->pub.free_in_buffer = OUTPUT_BUF_SIZE; - - return TRUE; -} - - -/* - * Terminate destination --- called by jpeg_finish_compress - * after all data has been written. Usually needs to flush buffer. - * - * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding - * application must deal with any cleanup that should happen even - * for error exit. - */ - -METHODDEF(void) -term_destination (j_compress_ptr cinfo) -{ - my_dest_ptr dest = (my_dest_ptr) cinfo->dest; - size_t datacount = OUTPUT_BUF_SIZE - dest->pub.free_in_buffer; - - /* Write any data remaining in the buffer */ - if (datacount > 0) { - if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount) - ERREXIT(cinfo, JERR_FILE_WRITE); - } - fflush(dest->outfile); - /* Make sure we wrote the output file OK */ - if (ferror(dest->outfile)) - ERREXIT(cinfo, JERR_FILE_WRITE); -} - - -/* - * Prepare for output to a stdio stream. - * The caller must have already opened the stream, and is responsible - * for closing it after finishing compression. - */ - -GLOBAL(void) -jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile) -{ - my_dest_ptr dest; - - /* The destination object is made permanent so that multiple JPEG images - * can be written to the same file without re-executing jpeg_stdio_dest. - * This makes it dangerous to use this manager and a different destination - * manager serially with the same JPEG object, because their private object - * sizes may be different. Caveat programmer. - */ - if (cinfo->dest == NULL) { /* first time for this JPEG object? */ - cinfo->dest = (struct jpeg_destination_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_destination_mgr)); - } - - dest = (my_dest_ptr) cinfo->dest; - dest->pub.init_destination = init_destination; - dest->pub.empty_output_buffer = empty_output_buffer; - dest->pub.term_destination = term_destination; - dest->outfile = outfile; -} diff --git a/oversampling/WDL/jpeglib/jdatasrc.c b/oversampling/WDL/jpeglib/jdatasrc.c deleted file mode 100644 index 2c1d71a..0000000 --- a/oversampling/WDL/jpeglib/jdatasrc.c +++ /dev/null @@ -1,273 +0,0 @@ -/* - * jdatasrc.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains decompression data source routines for the case of - * reading JPEG data from a file (or any stdio stream). While these routines - * are sufficient for most applications, some will want to use a different - * source manager. - * IMPORTANT: we assume that fread() will correctly transcribe an array of - * JOCTETs from 8-bit-wide elements on external storage. If char is wider - * than 8 bits on your machine, you may need to do some tweaking. - */ - -/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jerror.h" - - -/* Expanded data source object for stdio input */ - -typedef struct { - struct jpeg_source_mgr pub; /* public fields */ - - FILE * infile; /* source stream */ - JOCTET * buffer; /* start of buffer */ - boolean start_of_file; /* have we gotten any data yet? */ -} my_source_mgr; - -typedef my_source_mgr * my_src_ptr; - -#define INPUT_BUF_SIZE 4096 /* choose an efficiently fread'able size */ - - -/* - * Initialize source --- called by jpeg_read_header - * before any data is actually read. - */ - -METHODDEF(void) -init_source (j_decompress_ptr cinfo) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - - /* We reset the empty-input-file flag for each image, - * but we don't clear the input buffer. - * This is correct behavior for reading a series of images from one source. - */ - src->start_of_file = TRUE; -} - -METHODDEF(void) -init_mem_source (j_decompress_ptr cinfo) -{ - /* no work necessary here */ -} - - -/* - * Fill the input buffer --- called whenever buffer is emptied. - * - * In typical applications, this should read fresh data into the buffer - * (ignoring the current state of next_input_byte & bytes_in_buffer), - * reset the pointer & count to the start of the buffer, and return TRUE - * indicating that the buffer has been reloaded. It is not necessary to - * fill the buffer entirely, only to obtain at least one more byte. - * - * There is no such thing as an EOF return. If the end of the file has been - * reached, the routine has a choice of ERREXIT() or inserting fake data into - * the buffer. In most cases, generating a warning message and inserting a - * fake EOI marker is the best course of action --- this will allow the - * decompressor to output however much of the image is there. However, - * the resulting error message is misleading if the real problem is an empty - * input file, so we handle that case specially. - * - * In applications that need to be able to suspend compression due to input - * not being available yet, a FALSE return indicates that no more data can be - * obtained right now, but more may be forthcoming later. In this situation, - * the decompressor will return to its caller (with an indication of the - * number of scanlines it has read, if any). The application should resume - * decompression after it has loaded more data into the input buffer. Note - * that there are substantial restrictions on the use of suspension --- see - * the documentation. - * - * When suspending, the decompressor will back up to a convenient restart point - * (typically the start of the current MCU). next_input_byte & bytes_in_buffer - * indicate where the restart point will be if the current call returns FALSE. - * Data beyond this point must be rescanned after resumption, so move it to - * the front of the buffer rather than discarding it. - */ - -METHODDEF(boolean) -fill_input_buffer (j_decompress_ptr cinfo) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - size_t nbytes; - - nbytes = JFREAD(src->infile, src->buffer, INPUT_BUF_SIZE); - - if (nbytes <= 0) { - if (src->start_of_file) /* Treat empty input file as fatal error */ - ERREXIT(cinfo, JERR_INPUT_EMPTY); - WARNMS(cinfo, JWRN_JPEG_EOF); - /* Insert a fake EOI marker */ - src->buffer[0] = (JOCTET) 0xFF; - src->buffer[1] = (JOCTET) JPEG_EOI; - nbytes = 2; - } - - src->pub.next_input_byte = src->buffer; - src->pub.bytes_in_buffer = nbytes; - src->start_of_file = FALSE; - - return TRUE; -} - -METHODDEF(boolean) -fill_mem_input_buffer (j_decompress_ptr cinfo) -{ - static const JOCTET mybuffer[4] = { - (JOCTET) 0xFF, (JOCTET) JPEG_EOI, 0, 0 - }; - - /* The whole JPEG data is expected to reside in the supplied memory - * buffer, so any request for more data beyond the given buffer size - * is treated as an error. - */ - WARNMS(cinfo, JWRN_JPEG_EOF); - - /* Insert a fake EOI marker */ - - cinfo->src->next_input_byte = mybuffer; - cinfo->src->bytes_in_buffer = 2; - - return TRUE; -} - -/* - * Skip data --- used to skip over a potentially large amount of - * uninteresting data (such as an APPn marker). - * - * Writers of suspendable-input applications must note that skip_input_data - * is not granted the right to give a suspension return. If the skip extends - * beyond the data currently in the buffer, the buffer can be marked empty so - * that the next read will cause a fill_input_buffer call that can suspend. - * Arranging for additional bytes to be discarded before reloading the input - * buffer is the application writer's problem. - */ - -METHODDEF(void) -skip_input_data (j_decompress_ptr cinfo, long num_bytes) -{ - my_src_ptr src = (my_src_ptr) cinfo->src; - - /* Just a dumb implementation for now. Could use fseek() except - * it doesn't work on pipes. Not clear that being smart is worth - * any trouble anyway --- large skips are infrequent. - */ - if (num_bytes > 0) { - while (num_bytes > (long) src->pub.bytes_in_buffer) { - num_bytes -= (long) src->pub.bytes_in_buffer; - (void) fill_input_buffer(cinfo); - /* note we assume that fill_input_buffer will never return FALSE, - * so suspension need not be handled. - */ - } - src->pub.next_input_byte += (size_t) num_bytes; - src->pub.bytes_in_buffer -= (size_t) num_bytes; - } -} - - -/* - * An additional method that can be provided by data source modules is the - * resync_to_restart method for error recovery in the presence of RST markers. - * For the moment, this source module just uses the default resync method - * provided by the JPEG library. That method assumes that no backtracking - * is possible. - */ - - -/* - * Terminate source --- called by jpeg_finish_decompress - * after all data has been read. Often a no-op. - * - * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding - * application must deal with any cleanup that should happen even - * for error exit. - */ - -METHODDEF(void) -term_source (j_decompress_ptr cinfo) -{ - /* no work necessary here */ -} - - -/* - * Prepare for input from a stdio stream. - * The caller must have already opened the stream, and is responsible - * for closing it after finishing decompression. - */ - -GLOBAL(void) -jpeg_stdio_src (j_decompress_ptr cinfo, FILE * infile) -{ - my_src_ptr src; - - /* The source object and input buffer are made permanent so that a series - * of JPEG images can be read from the same file by calling jpeg_stdio_src - * only before the first one. (If we discarded the buffer at the end of - * one image, we'd likely lose the start of the next one.) - * This makes it unsafe to use this manager and a different source - * manager serially with the same JPEG object. Caveat programmer. - */ - if (cinfo->src == NULL) { /* first time for this JPEG object? */ - cinfo->src = (struct jpeg_source_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_source_mgr)); - src = (my_src_ptr) cinfo->src; - src->buffer = (JOCTET *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - INPUT_BUF_SIZE * SIZEOF(JOCTET)); - } - - src = (my_src_ptr) cinfo->src; - src->pub.init_source = init_source; - src->pub.fill_input_buffer = fill_input_buffer; - src->pub.skip_input_data = skip_input_data; - src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ - src->pub.term_source = term_source; - src->infile = infile; - src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ - src->pub.next_input_byte = NULL; /* until buffer loaded */ -} - - -/* - * Prepare for input from a supplied memory buffer. - * The buffer must contain the whole JPEG data. - */ - -GLOBAL(void) -jpeg_mem_src (j_decompress_ptr cinfo, - unsigned char * inbuffer, unsigned long insize) -{ - struct jpeg_source_mgr * src; - - if (inbuffer == NULL || insize == 0) /* Treat empty input as fatal error */ - ERREXIT(cinfo, JERR_INPUT_EMPTY); - - /* The source object is made permanent so that a series of JPEG images - * can be read from the same buffer by calling jpeg_mem_src only before - * the first one. - */ - if (cinfo->src == NULL) { /* first time for this JPEG object? */ - cinfo->src = (struct jpeg_source_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(struct jpeg_source_mgr)); - } - - src = cinfo->src; - src->init_source = init_mem_source; - src->fill_input_buffer = fill_mem_input_buffer; - src->skip_input_data = skip_input_data; - src->resync_to_restart = jpeg_resync_to_restart; /* use default method */ - src->term_source = term_source; - src->bytes_in_buffer = (size_t) insize; - src->next_input_byte = (JOCTET *) inbuffer; -} diff --git a/oversampling/WDL/jpeglib/jdcoefct.c b/oversampling/WDL/jpeglib/jdcoefct.c deleted file mode 100644 index 4938d20..0000000 --- a/oversampling/WDL/jpeglib/jdcoefct.c +++ /dev/null @@ -1,736 +0,0 @@ -/* - * jdcoefct.c - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the coefficient buffer controller for decompression. - * This controller is the top level of the JPEG decompressor proper. - * The coefficient buffer lies between entropy decoding and inverse-DCT steps. - * - * In buffered-image mode, this controller is the interface between - * input-oriented processing and output-oriented processing. - * Also, the input side (only) is used when reading a file for transcoding. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -/* Block smoothing is only applicable for progressive JPEG, so: */ -#ifndef D_PROGRESSIVE_SUPPORTED -#undef BLOCK_SMOOTHING_SUPPORTED -#endif - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_d_coef_controller pub; /* public fields */ - - /* These variables keep track of the current location of the input side. */ - /* cinfo->input_iMCU_row is also used for this. */ - JDIMENSION MCU_ctr; /* counts MCUs processed in current row */ - int MCU_vert_offset; /* counts MCU rows within iMCU row */ - int MCU_rows_per_iMCU_row; /* number of such rows needed */ - - /* The output side's location is represented by cinfo->output_iMCU_row. */ - - /* In single-pass modes, it's sufficient to buffer just one MCU. - * We allocate a workspace of D_MAX_BLOCKS_IN_MCU coefficient blocks, - * and let the entropy decoder write into that workspace each time. - * (On 80x86, the workspace is FAR even though it's not really very big; - * this is to keep the module interfaces unchanged when a large coefficient - * buffer is necessary.) - * In multi-pass modes, this array points to the current MCU's blocks - * within the virtual arrays; it is used only by the input side. - */ - JBLOCKROW MCU_buffer[D_MAX_BLOCKS_IN_MCU]; - -#ifdef D_MULTISCAN_FILES_SUPPORTED - /* In multi-pass modes, we need a virtual block array for each component. */ - jvirt_barray_ptr whole_image[MAX_COMPONENTS]; -#endif - -#ifdef BLOCK_SMOOTHING_SUPPORTED - /* When doing block smoothing, we latch coefficient Al values here */ - int * coef_bits_latch; -#define SAVED_COEFS 6 /* we save coef_bits[0..5] */ -#endif -} my_coef_controller; - -typedef my_coef_controller * my_coef_ptr; - -/* Forward declarations */ -METHODDEF(int) decompress_onepass - JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); -#ifdef D_MULTISCAN_FILES_SUPPORTED -METHODDEF(int) decompress_data - JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); -#endif -#ifdef BLOCK_SMOOTHING_SUPPORTED -LOCAL(boolean) smoothing_ok JPP((j_decompress_ptr cinfo)); -METHODDEF(int) decompress_smooth_data - JPP((j_decompress_ptr cinfo, JSAMPIMAGE output_buf)); -#endif - - -LOCAL(void) -start_iMCU_row (j_decompress_ptr cinfo) -/* Reset within-iMCU-row counters for a new row (input side) */ -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* In an interleaved scan, an MCU row is the same as an iMCU row. - * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows. - * But at the bottom of the image, process only what's left. - */ - if (cinfo->comps_in_scan > 1) { - coef->MCU_rows_per_iMCU_row = 1; - } else { - if (cinfo->input_iMCU_row < (cinfo->total_iMCU_rows-1)) - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor; - else - coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height; - } - - coef->MCU_ctr = 0; - coef->MCU_vert_offset = 0; -} - - -/* - * Initialize for an input processing pass. - */ - -METHODDEF(void) -start_input_pass (j_decompress_ptr cinfo) -{ - cinfo->input_iMCU_row = 0; - start_iMCU_row(cinfo); -} - - -/* - * Initialize for an output processing pass. - */ - -METHODDEF(void) -start_output_pass (j_decompress_ptr cinfo) -{ -#ifdef BLOCK_SMOOTHING_SUPPORTED - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - - /* If multipass, check to see whether to use block smoothing on this pass */ - if (coef->pub.coef_arrays != NULL) { - if (cinfo->do_block_smoothing && smoothing_ok(cinfo)) - coef->pub.decompress_data = decompress_smooth_data; - else - coef->pub.decompress_data = decompress_data; - } -#endif - cinfo->output_iMCU_row = 0; -} - - -/* - * Decompress and return some data in the single-pass case. - * Always attempts to emit one fully interleaved MCU row ("iMCU" row). - * Input and output must run in lockstep since we have only a one-MCU buffer. - * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. - * - * NB: output_buf contains a plane for each component in image, - * which we index according to the component's SOF position. - */ - -METHODDEF(int) -decompress_onepass (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - int blkn, ci, xindex, yindex, yoffset, useful_width; - JSAMPARRAY output_ptr; - JDIMENSION start_col, output_col; - jpeg_component_info *compptr; - inverse_DCT_method_ptr inverse_DCT; - - /* Loop to process as much as one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col; - MCU_col_num++) { - /* Try to fetch an MCU. Entropy decoder expects buffer to be zeroed. */ - jzero_far((void FAR *) coef->MCU_buffer[0], - (size_t) (cinfo->blocks_in_MCU * SIZEOF(JBLOCK))); - if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->MCU_ctr = MCU_col_num; - return JPEG_SUSPENDED; - } - /* Determine where data should go in output_buf and do the IDCT thing. - * We skip dummy blocks at the right and bottom edges (but blkn gets - * incremented past them!). Note the inner loop relies on having - * allocated the MCU_buffer[] blocks sequentially. - */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Don't bother to IDCT an uninteresting component. */ - if (! compptr->component_needed) { - blkn += compptr->MCU_blocks; - continue; - } - inverse_DCT = cinfo->idct->inverse_DCT[compptr->component_index]; - useful_width = (MCU_col_num < last_MCU_col) ? compptr->MCU_width - : compptr->last_col_width; - output_ptr = output_buf[compptr->component_index] + - yoffset * compptr->DCT_scaled_size; - start_col = MCU_col_num * compptr->MCU_sample_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - if (cinfo->input_iMCU_row < last_iMCU_row || - yoffset+yindex < compptr->last_row_height) { - output_col = start_col; - for (xindex = 0; xindex < useful_width; xindex++) { - (*inverse_DCT) (cinfo, compptr, - (JCOEFPTR) coef->MCU_buffer[blkn+xindex], - output_ptr, output_col); - output_col += compptr->DCT_scaled_size; - } - } - blkn += compptr->MCU_width; - output_ptr += compptr->DCT_scaled_size; - } - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->MCU_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - cinfo->output_iMCU_row++; - if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { - start_iMCU_row(cinfo); - return JPEG_ROW_COMPLETED; - } - /* Completed the scan */ - (*cinfo->inputctl->finish_input_pass) (cinfo); - return JPEG_SCAN_COMPLETED; -} - - -/* - * Dummy consume-input routine for single-pass operation. - */ - -METHODDEF(int) -dummy_consume_data (j_decompress_ptr cinfo) -{ - return JPEG_SUSPENDED; /* Always indicate nothing was done */ -} - - -#ifdef D_MULTISCAN_FILES_SUPPORTED - -/* - * Consume input data and store it in the full-image coefficient buffer. - * We read as much as one fully interleaved MCU row ("iMCU" row) per call, - * ie, v_samp_factor block rows for each component in the scan. - * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. - */ - -METHODDEF(int) -consume_data (j_decompress_ptr cinfo) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION MCU_col_num; /* index of current MCU within row */ - int blkn, ci, xindex, yindex, yoffset; - JDIMENSION start_col; - JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN]; - JBLOCKROW buffer_ptr; - jpeg_component_info *compptr; - - /* Align the virtual buffers for the components used in this scan. */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - buffer[ci] = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[compptr->component_index], - cinfo->input_iMCU_row * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, TRUE); - /* Note: entropy decoder expects buffer to be zeroed, - * but this is handled automatically by the memory manager - * because we requested a pre-zeroed array. - */ - } - - /* Loop to process one whole iMCU row */ - for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row; - yoffset++) { - for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row; - MCU_col_num++) { - /* Construct list of pointers to DCT blocks belonging to this MCU */ - blkn = 0; /* index of current DCT block within MCU */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - start_col = MCU_col_num * compptr->MCU_width; - for (yindex = 0; yindex < compptr->MCU_height; yindex++) { - buffer_ptr = buffer[ci][yindex+yoffset] + start_col; - for (xindex = 0; xindex < compptr->MCU_width; xindex++) { - coef->MCU_buffer[blkn++] = buffer_ptr++; - } - } - } - /* Try to fetch the MCU. */ - if (! (*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) { - /* Suspension forced; update state counters and exit */ - coef->MCU_vert_offset = yoffset; - coef->MCU_ctr = MCU_col_num; - return JPEG_SUSPENDED; - } - } - /* Completed an MCU row, but perhaps not an iMCU row */ - coef->MCU_ctr = 0; - } - /* Completed the iMCU row, advance counters for next one */ - if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { - start_iMCU_row(cinfo); - return JPEG_ROW_COMPLETED; - } - /* Completed the scan */ - (*cinfo->inputctl->finish_input_pass) (cinfo); - return JPEG_SCAN_COMPLETED; -} - - -/* - * Decompress and return some data in the multi-pass case. - * Always attempts to emit one fully interleaved MCU row ("iMCU" row). - * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED. - * - * NB: output_buf contains a plane for each component in image. - */ - -METHODDEF(int) -decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - JDIMENSION block_num; - int ci, block_row, block_rows; - JBLOCKARRAY buffer; - JBLOCKROW buffer_ptr; - JSAMPARRAY output_ptr; - JDIMENSION output_col; - jpeg_component_info *compptr; - inverse_DCT_method_ptr inverse_DCT; - - /* Force some input to be done if we are getting ahead of the input. */ - while (cinfo->input_scan_number < cinfo->output_scan_number || - (cinfo->input_scan_number == cinfo->output_scan_number && - cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) { - if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) - return JPEG_SUSPENDED; - } - - /* OK, output from the virtual arrays. */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Don't bother to IDCT an uninteresting component. */ - if (! compptr->component_needed) - continue; - /* Align the virtual buffer for this component. */ - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - cinfo->output_iMCU_row * compptr->v_samp_factor, - (JDIMENSION) compptr->v_samp_factor, FALSE); - /* Count non-dummy DCT block rows in this iMCU row. */ - if (cinfo->output_iMCU_row < last_iMCU_row) - block_rows = compptr->v_samp_factor; - else { - /* NB: can't use last_row_height here; it is input-side-dependent! */ - block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (block_rows == 0) block_rows = compptr->v_samp_factor; - } - inverse_DCT = cinfo->idct->inverse_DCT[ci]; - output_ptr = output_buf[ci]; - /* Loop over all DCT blocks to be processed. */ - for (block_row = 0; block_row < block_rows; block_row++) { - buffer_ptr = buffer[block_row]; - output_col = 0; - for (block_num = 0; block_num < compptr->width_in_blocks; block_num++) { - (*inverse_DCT) (cinfo, compptr, (JCOEFPTR) buffer_ptr, - output_ptr, output_col); - buffer_ptr++; - output_col += compptr->DCT_scaled_size; - } - output_ptr += compptr->DCT_scaled_size; - } - } - - if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) - return JPEG_ROW_COMPLETED; - return JPEG_SCAN_COMPLETED; -} - -#endif /* D_MULTISCAN_FILES_SUPPORTED */ - - -#ifdef BLOCK_SMOOTHING_SUPPORTED - -/* - * This code applies interblock smoothing as described by section K.8 - * of the JPEG standard: the first 5 AC coefficients are estimated from - * the DC values of a DCT block and its 8 neighboring blocks. - * We apply smoothing only for progressive JPEG decoding, and only if - * the coefficients it can estimate are not yet known to full precision. - */ - -/* Natural-order array positions of the first 5 zigzag-order coefficients */ -#define Q01_POS 1 -#define Q10_POS 8 -#define Q20_POS 16 -#define Q11_POS 9 -#define Q02_POS 2 - -/* - * Determine whether block smoothing is applicable and safe. - * We also latch the current states of the coef_bits[] entries for the - * AC coefficients; otherwise, if the input side of the decompressor - * advances into a new scan, we might think the coefficients are known - * more accurately than they really are. - */ - -LOCAL(boolean) -smoothing_ok (j_decompress_ptr cinfo) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - boolean smoothing_useful = FALSE; - int ci, coefi; - jpeg_component_info *compptr; - JQUANT_TBL * qtable; - int * coef_bits; - int * coef_bits_latch; - - if (! cinfo->progressive_mode || cinfo->coef_bits == NULL) - return FALSE; - - /* Allocate latch area if not already done */ - if (coef->coef_bits_latch == NULL) - coef->coef_bits_latch = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components * - (SAVED_COEFS * SIZEOF(int))); - coef_bits_latch = coef->coef_bits_latch; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* All components' quantization values must already be latched. */ - if ((qtable = compptr->quant_table) == NULL) - return FALSE; - /* Verify DC & first 5 AC quantizers are nonzero to avoid zero-divide. */ - if (qtable->quantval[0] == 0 || - qtable->quantval[Q01_POS] == 0 || - qtable->quantval[Q10_POS] == 0 || - qtable->quantval[Q20_POS] == 0 || - qtable->quantval[Q11_POS] == 0 || - qtable->quantval[Q02_POS] == 0) - return FALSE; - /* DC values must be at least partly known for all components. */ - coef_bits = cinfo->coef_bits[ci]; - if (coef_bits[0] < 0) - return FALSE; - /* Block smoothing is helpful if some AC coefficients remain inaccurate. */ - for (coefi = 1; coefi <= 5; coefi++) { - coef_bits_latch[coefi] = coef_bits[coefi]; - if (coef_bits[coefi] != 0) - smoothing_useful = TRUE; - } - coef_bits_latch += SAVED_COEFS; - } - - return smoothing_useful; -} - - -/* - * Variant of decompress_data for use when doing block smoothing. - */ - -METHODDEF(int) -decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) -{ - my_coef_ptr coef = (my_coef_ptr) cinfo->coef; - JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; - JDIMENSION block_num, last_block_column; - int ci, block_row, block_rows, access_rows; - JBLOCKARRAY buffer; - JBLOCKROW buffer_ptr, prev_block_row, next_block_row; - JSAMPARRAY output_ptr; - JDIMENSION output_col; - jpeg_component_info *compptr; - inverse_DCT_method_ptr inverse_DCT; - boolean first_row, last_row; - JBLOCK workspace; - int *coef_bits; - JQUANT_TBL *quanttbl; - INT32 Q00,Q01,Q02,Q10,Q11,Q20, num; - int DC1,DC2,DC3,DC4,DC5,DC6,DC7,DC8,DC9; - int Al, pred; - - /* Force some input to be done if we are getting ahead of the input. */ - while (cinfo->input_scan_number <= cinfo->output_scan_number && - ! cinfo->inputctl->eoi_reached) { - if (cinfo->input_scan_number == cinfo->output_scan_number) { - /* If input is working on current scan, we ordinarily want it to - * have completed the current row. But if input scan is DC, - * we want it to keep one row ahead so that next block row's DC - * values are up to date. - */ - JDIMENSION delta = (cinfo->Ss == 0) ? 1 : 0; - if (cinfo->input_iMCU_row > cinfo->output_iMCU_row+delta) - break; - } - if ((*cinfo->inputctl->consume_input)(cinfo) == JPEG_SUSPENDED) - return JPEG_SUSPENDED; - } - - /* OK, output from the virtual arrays. */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Don't bother to IDCT an uninteresting component. */ - if (! compptr->component_needed) - continue; - /* Count non-dummy DCT block rows in this iMCU row. */ - if (cinfo->output_iMCU_row < last_iMCU_row) { - block_rows = compptr->v_samp_factor; - access_rows = block_rows * 2; /* this and next iMCU row */ - last_row = FALSE; - } else { - /* NB: can't use last_row_height here; it is input-side-dependent! */ - block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (block_rows == 0) block_rows = compptr->v_samp_factor; - access_rows = block_rows; /* this iMCU row only */ - last_row = TRUE; - } - /* Align the virtual buffer for this component. */ - if (cinfo->output_iMCU_row > 0) { - access_rows += compptr->v_samp_factor; /* prior iMCU row too */ - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor, - (JDIMENSION) access_rows, FALSE); - buffer += compptr->v_samp_factor; /* point to current iMCU row */ - first_row = FALSE; - } else { - buffer = (*cinfo->mem->access_virt_barray) - ((j_common_ptr) cinfo, coef->whole_image[ci], - (JDIMENSION) 0, (JDIMENSION) access_rows, FALSE); - first_row = TRUE; - } - /* Fetch component-dependent info */ - coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS); - quanttbl = compptr->quant_table; - Q00 = quanttbl->quantval[0]; - Q01 = quanttbl->quantval[Q01_POS]; - Q10 = quanttbl->quantval[Q10_POS]; - Q20 = quanttbl->quantval[Q20_POS]; - Q11 = quanttbl->quantval[Q11_POS]; - Q02 = quanttbl->quantval[Q02_POS]; - inverse_DCT = cinfo->idct->inverse_DCT[ci]; - output_ptr = output_buf[ci]; - /* Loop over all DCT blocks to be processed. */ - for (block_row = 0; block_row < block_rows; block_row++) { - buffer_ptr = buffer[block_row]; - if (first_row && block_row == 0) - prev_block_row = buffer_ptr; - else - prev_block_row = buffer[block_row-1]; - if (last_row && block_row == block_rows-1) - next_block_row = buffer_ptr; - else - next_block_row = buffer[block_row+1]; - /* We fetch the surrounding DC values using a sliding-register approach. - * Initialize all nine here so as to do the right thing on narrow pics. - */ - DC1 = DC2 = DC3 = (int) prev_block_row[0][0]; - DC4 = DC5 = DC6 = (int) buffer_ptr[0][0]; - DC7 = DC8 = DC9 = (int) next_block_row[0][0]; - output_col = 0; - last_block_column = compptr->width_in_blocks - 1; - for (block_num = 0; block_num <= last_block_column; block_num++) { - /* Fetch current DCT block into workspace so we can modify it. */ - jcopy_block_row(buffer_ptr, (JBLOCKROW) workspace, (JDIMENSION) 1); - /* Update DC values */ - if (block_num < last_block_column) { - DC3 = (int) prev_block_row[1][0]; - DC6 = (int) buffer_ptr[1][0]; - DC9 = (int) next_block_row[1][0]; - } - /* Compute coefficient estimates per K.8. - * An estimate is applied only if coefficient is still zero, - * and is not known to be fully accurate. - */ - /* AC01 */ - if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) { - num = 36 * Q00 * (DC4 - DC6); - if (num >= 0) { - pred = (int) (((Q01<<7) + num) / (Q01<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { - pred = (int) (((Q10<<7) + num) / (Q10<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { - pred = (int) (((Q20<<7) + num) / (Q20<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { - pred = (int) (((Q11<<7) + num) / (Q11<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<= 0) { - pred = (int) (((Q02<<7) + num) / (Q02<<8)); - if (Al > 0 && pred >= (1< 0 && pred >= (1<DCT_scaled_size; - } - output_ptr += compptr->DCT_scaled_size; - } - } - - if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows) - return JPEG_ROW_COMPLETED; - return JPEG_SCAN_COMPLETED; -} - -#endif /* BLOCK_SMOOTHING_SUPPORTED */ - - -/* - * Initialize coefficient buffer controller. - */ - -GLOBAL(void) -jinit_d_coef_controller (j_decompress_ptr cinfo, boolean need_full_buffer) -{ - my_coef_ptr coef; - - coef = (my_coef_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_coef_controller)); - cinfo->coef = (struct jpeg_d_coef_controller *) coef; - coef->pub.start_input_pass = start_input_pass; - coef->pub.start_output_pass = start_output_pass; -#ifdef BLOCK_SMOOTHING_SUPPORTED - coef->coef_bits_latch = NULL; -#endif - - /* Create the coefficient buffer. */ - if (need_full_buffer) { -#ifdef D_MULTISCAN_FILES_SUPPORTED - /* Allocate a full-image virtual array for each component, */ - /* padded to a multiple of samp_factor DCT blocks in each direction. */ - /* Note we ask for a pre-zeroed array. */ - int ci, access_rows; - jpeg_component_info *compptr; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - access_rows = compptr->v_samp_factor; -#ifdef BLOCK_SMOOTHING_SUPPORTED - /* If block smoothing could be used, need a bigger window */ - if (cinfo->progressive_mode) - access_rows *= 3; -#endif - coef->whole_image[ci] = (*cinfo->mem->request_virt_barray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, TRUE, - (JDIMENSION) jround_up((long) compptr->width_in_blocks, - (long) compptr->h_samp_factor), - (JDIMENSION) jround_up((long) compptr->height_in_blocks, - (long) compptr->v_samp_factor), - (JDIMENSION) access_rows); - } - coef->pub.consume_data = consume_data; - coef->pub.decompress_data = decompress_data; - coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */ -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - /* We only need a single-MCU buffer. */ - JBLOCKROW buffer; - int i; - - buffer = (JBLOCKROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - D_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK)); - for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) { - coef->MCU_buffer[i] = buffer + i; - } - coef->pub.consume_data = dummy_consume_data; - coef->pub.decompress_data = decompress_onepass; - coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */ - } -} diff --git a/oversampling/WDL/jpeglib/jdcolor.c b/oversampling/WDL/jpeglib/jdcolor.c deleted file mode 100644 index 6c04dfe..0000000 --- a/oversampling/WDL/jpeglib/jdcolor.c +++ /dev/null @@ -1,396 +0,0 @@ -/* - * jdcolor.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains output colorspace conversion routines. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private subobject */ - -typedef struct { - struct jpeg_color_deconverter pub; /* public fields */ - - /* Private state for YCC->RGB conversion */ - int * Cr_r_tab; /* => table for Cr to R conversion */ - int * Cb_b_tab; /* => table for Cb to B conversion */ - INT32 * Cr_g_tab; /* => table for Cr to G conversion */ - INT32 * Cb_g_tab; /* => table for Cb to G conversion */ -} my_color_deconverter; - -typedef my_color_deconverter * my_cconvert_ptr; - - -/**************** YCbCr -> RGB conversion: most common case **************/ - -/* - * YCbCr is defined per CCIR 601-1, except that Cb and Cr are - * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5. - * The conversion equations to be implemented are therefore - * R = Y + 1.40200 * Cr - * G = Y - 0.34414 * Cb - 0.71414 * Cr - * B = Y + 1.77200 * Cb - * where Cb and Cr represent the incoming values less CENTERJSAMPLE. - * (These numbers are derived from TIFF 6.0 section 21, dated 3-June-92.) - * - * To avoid floating-point arithmetic, we represent the fractional constants - * as integers scaled up by 2^16 (about 4 digits precision); we have to divide - * the products by 2^16, with appropriate rounding, to get the correct answer. - * Notice that Y, being an integral input, does not contribute any fraction - * so it need not participate in the rounding. - * - * For even more speed, we avoid doing any multiplications in the inner loop - * by precalculating the constants times Cb and Cr for all possible values. - * For 8-bit JSAMPLEs this is very reasonable (only 256 entries per table); - * for 12-bit samples it is still acceptable. It's not very reasonable for - * 16-bit samples, but if you want lossless storage you shouldn't be changing - * colorspace anyway. - * The Cr=>R and Cb=>B values can be rounded to integers in advance; the - * values for the G calculation are left scaled up, since we must add them - * together before rounding. - */ - -#define SCALEBITS 16 /* speediest right-shift on some machines */ -#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) -#define FIX(x) ((INT32) ((x) * (1L<RGB colorspace conversion. - */ - -LOCAL(void) -build_ycc_rgb_table (j_decompress_ptr cinfo) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - int i; - INT32 x; - SHIFT_TEMPS - - cconvert->Cr_r_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - cconvert->Cb_b_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - cconvert->Cr_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - cconvert->Cb_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - - for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { - /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ - /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ - /* Cr=>R value is nearest int to 1.40200 * x */ - cconvert->Cr_r_tab[i] = (int) - RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); - /* Cb=>B value is nearest int to 1.77200 * x */ - cconvert->Cb_b_tab[i] = (int) - RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); - /* Cr=>G value is scaled-up -0.71414 * x */ - cconvert->Cr_g_tab[i] = (- FIX(0.71414)) * x; - /* Cb=>G value is scaled-up -0.34414 * x */ - /* We also add in ONE_HALF so that need not do it in inner loop */ - cconvert->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; - } -} - - -/* - * Convert some rows of samples to the output colorspace. - * - * Note that we change from noninterleaved, one-plane-per-component format - * to interleaved-pixel format. The output buffer is therefore three times - * as wide as the input buffer. - * A starting row offset is provided only for the input buffer. The caller - * can easily adjust the passed output_buf value to accommodate any row - * offset required on that side. - */ - -METHODDEF(void) -ycc_rgb_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int y, cb, cr; - register JSAMPROW outptr; - register JSAMPROW inptr0, inptr1, inptr2; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - register int * Crrtab = cconvert->Cr_r_tab; - register int * Cbbtab = cconvert->Cb_b_tab; - register INT32 * Crgtab = cconvert->Cr_g_tab; - register INT32 * Cbgtab = cconvert->Cb_g_tab; - SHIFT_TEMPS - - while (--num_rows >= 0) { - inptr0 = input_buf[0][input_row]; - inptr1 = input_buf[1][input_row]; - inptr2 = input_buf[2][input_row]; - input_row++; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - y = GETJSAMPLE(inptr0[col]); - cb = GETJSAMPLE(inptr1[col]); - cr = GETJSAMPLE(inptr2[col]); - /* Range-limiting is essential due to noise introduced by DCT losses. */ - outptr[RGB_RED] = range_limit[y + Crrtab[cr]]; - outptr[RGB_GREEN] = range_limit[y + - ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], - SCALEBITS))]; - outptr[RGB_BLUE] = range_limit[y + Cbbtab[cb]]; - outptr += RGB_PIXELSIZE; - } - } -} - - -/**************** Cases other than YCbCr -> RGB **************/ - - -/* - * Color conversion for no colorspace change: just copy the data, - * converting from separate-planes to interleaved representation. - */ - -METHODDEF(void) -null_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - register JSAMPROW inptr, outptr; - register JDIMENSION count; - register int num_components = cinfo->num_components; - JDIMENSION num_cols = cinfo->output_width; - int ci; - - while (--num_rows >= 0) { - for (ci = 0; ci < num_components; ci++) { - inptr = input_buf[ci][input_row]; - outptr = output_buf[0] + ci; - for (count = num_cols; count > 0; count--) { - *outptr = *inptr++; /* needn't bother with GETJSAMPLE() here */ - outptr += num_components; - } - } - input_row++; - output_buf++; - } -} - - -/* - * Color conversion for grayscale: just copy the data. - * This also works for YCbCr -> grayscale conversion, in which - * we just copy the Y (luminance) component and ignore chrominance. - */ - -METHODDEF(void) -grayscale_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - jcopy_sample_rows(input_buf[0], (int) input_row, output_buf, 0, - num_rows, cinfo->output_width); -} - - -/* - * Convert grayscale to RGB: just duplicate the graylevel three times. - * This is provided to support applications that don't want to cope - * with grayscale as a separate case. - */ - -METHODDEF(void) -gray_rgb_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - register JSAMPROW inptr, outptr; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - - while (--num_rows >= 0) { - inptr = input_buf[0][input_row++]; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - /* We can dispense with GETJSAMPLE() here */ - outptr[RGB_RED] = outptr[RGB_GREEN] = outptr[RGB_BLUE] = inptr[col]; - outptr += RGB_PIXELSIZE; - } - } -} - - -/* - * Adobe-style YCCK->CMYK conversion. - * We convert YCbCr to R=1-C, G=1-M, and B=1-Y using the same - * conversion as above, while passing K (black) unchanged. - * We assume build_ycc_rgb_table has been called. - */ - -METHODDEF(void) -ycck_cmyk_convert (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows) -{ - my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert; - register int y, cb, cr; - register JSAMPROW outptr; - register JSAMPROW inptr0, inptr1, inptr2, inptr3; - register JDIMENSION col; - JDIMENSION num_cols = cinfo->output_width; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - register int * Crrtab = cconvert->Cr_r_tab; - register int * Cbbtab = cconvert->Cb_b_tab; - register INT32 * Crgtab = cconvert->Cr_g_tab; - register INT32 * Cbgtab = cconvert->Cb_g_tab; - SHIFT_TEMPS - - while (--num_rows >= 0) { - inptr0 = input_buf[0][input_row]; - inptr1 = input_buf[1][input_row]; - inptr2 = input_buf[2][input_row]; - inptr3 = input_buf[3][input_row]; - input_row++; - outptr = *output_buf++; - for (col = 0; col < num_cols; col++) { - y = GETJSAMPLE(inptr0[col]); - cb = GETJSAMPLE(inptr1[col]); - cr = GETJSAMPLE(inptr2[col]); - /* Range-limiting is essential due to noise introduced by DCT losses. */ - outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])]; /* red */ - outptr[1] = range_limit[MAXJSAMPLE - (y + /* green */ - ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], - SCALEBITS)))]; - outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])]; /* blue */ - /* K passes through unchanged */ - outptr[3] = inptr3[col]; /* don't need GETJSAMPLE here */ - outptr += 4; - } - } -} - - -/* - * Empty method for start_pass. - */ - -METHODDEF(void) -start_pass_dcolor (j_decompress_ptr cinfo) -{ - /* no work needed */ -} - - -/* - * Module initialization routine for output colorspace conversion. - */ - -GLOBAL(void) -jinit_color_deconverter (j_decompress_ptr cinfo) -{ - my_cconvert_ptr cconvert; - int ci; - - cconvert = (my_cconvert_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_color_deconverter)); - cinfo->cconvert = (struct jpeg_color_deconverter *) cconvert; - cconvert->pub.start_pass = start_pass_dcolor; - - /* Make sure num_components agrees with jpeg_color_space */ - switch (cinfo->jpeg_color_space) { - case JCS_GRAYSCALE: - if (cinfo->num_components != 1) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - - case JCS_RGB: - case JCS_YCbCr: - if (cinfo->num_components != 3) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - - case JCS_CMYK: - case JCS_YCCK: - if (cinfo->num_components != 4) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - - default: /* JCS_UNKNOWN can be anything */ - if (cinfo->num_components < 1) - ERREXIT(cinfo, JERR_BAD_J_COLORSPACE); - break; - } - - /* Set out_color_components and conversion method based on requested space. - * Also clear the component_needed flags for any unused components, - * so that earlier pipeline stages can avoid useless computation. - */ - - switch (cinfo->out_color_space) { - case JCS_GRAYSCALE: - cinfo->out_color_components = 1; - if (cinfo->jpeg_color_space == JCS_GRAYSCALE || - cinfo->jpeg_color_space == JCS_YCbCr) { - cconvert->pub.color_convert = grayscale_convert; - /* For color->grayscale conversion, only the Y (0) component is needed */ - for (ci = 1; ci < cinfo->num_components; ci++) - cinfo->comp_info[ci].component_needed = FALSE; - } else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_RGB: - cinfo->out_color_components = RGB_PIXELSIZE; - if (cinfo->jpeg_color_space == JCS_YCbCr) { - cconvert->pub.color_convert = ycc_rgb_convert; - build_ycc_rgb_table(cinfo); - } else if (cinfo->jpeg_color_space == JCS_GRAYSCALE) { - cconvert->pub.color_convert = gray_rgb_convert; - } else if (cinfo->jpeg_color_space == JCS_RGB && RGB_PIXELSIZE == 3) { - cconvert->pub.color_convert = null_convert; - } else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - case JCS_CMYK: - cinfo->out_color_components = 4; - if (cinfo->jpeg_color_space == JCS_YCCK) { - cconvert->pub.color_convert = ycck_cmyk_convert; - build_ycc_rgb_table(cinfo); - } else if (cinfo->jpeg_color_space == JCS_CMYK) { - cconvert->pub.color_convert = null_convert; - } else - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - - default: - /* Permit null conversion to same output space */ - if (cinfo->out_color_space == cinfo->jpeg_color_space) { - cinfo->out_color_components = cinfo->num_components; - cconvert->pub.color_convert = null_convert; - } else /* unsupported non-null conversion */ - ERREXIT(cinfo, JERR_CONVERSION_NOTIMPL); - break; - } - - if (cinfo->quantize_colors) - cinfo->output_components = 1; /* single colormapped output component */ - else - cinfo->output_components = cinfo->out_color_components; -} diff --git a/oversampling/WDL/jpeglib/jdct.h b/oversampling/WDL/jpeglib/jdct.h deleted file mode 100644 index 04192a2..0000000 --- a/oversampling/WDL/jpeglib/jdct.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - * jdct.h - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This include file contains common declarations for the forward and - * inverse DCT modules. These declarations are private to the DCT managers - * (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms. - * The individual DCT algorithms are kept in separate files to ease - * machine-dependent tuning (e.g., assembly coding). - */ - - -/* - * A forward DCT routine is given a pointer to a work area of type DCTELEM[]; - * the DCT is to be performed in-place in that buffer. Type DCTELEM is int - * for 8-bit samples, INT32 for 12-bit samples. (NOTE: Floating-point DCT - * implementations use an array of type FAST_FLOAT, instead.) - * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE). - * The DCT outputs are returned scaled up by a factor of 8; they therefore - * have a range of +-8K for 8-bit data, +-128K for 12-bit data. This - * convention improves accuracy in integer implementations and saves some - * work in floating-point ones. - * Quantization of the output coefficients is done by jcdctmgr.c. - */ - -#if BITS_IN_JSAMPLE == 8 -typedef int DCTELEM; /* 16 or 32 bits is fine */ -#else -typedef INT32 DCTELEM; /* must have 32 bits */ -#endif - -typedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data)); -typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data)); - - -/* - * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer - * to an output sample array. The routine must dequantize the input data as - * well as perform the IDCT; for dequantization, it uses the multiplier table - * pointed to by compptr->dct_table. The output data is to be placed into the - * sample array starting at a specified column. (Any row offset needed will - * be applied to the array pointer before it is passed to the IDCT code.) - * Note that the number of samples emitted by the IDCT routine is - * DCT_scaled_size * DCT_scaled_size. - */ - -/* typedef inverse_DCT_method_ptr is declared in jpegint.h */ - -/* - * Each IDCT routine has its own ideas about the best dct_table element type. - */ - -typedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */ -#if BITS_IN_JSAMPLE == 8 -typedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */ -#define IFAST_SCALE_BITS 2 /* fractional bits in scale factors */ -#else -typedef INT32 IFAST_MULT_TYPE; /* need 32 bits for scaled quantizers */ -#define IFAST_SCALE_BITS 13 /* fractional bits in scale factors */ -#endif -typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */ - - -/* - * Each IDCT routine is responsible for range-limiting its results and - * converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could - * be quite far out of range if the input data is corrupt, so a bulletproof - * range-limiting step is required. We use a mask-and-table-lookup method - * to do the combined operations quickly. See the comments with - * prepare_range_limit_table (in jdmaster.c) for more info. - */ - -#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit + CENTERJSAMPLE) - -#define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */ - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_fdct_islow jFDislow -#define jpeg_fdct_ifast jFDifast -#define jpeg_fdct_float jFDfloat -#define jpeg_idct_islow jRDislow -#define jpeg_idct_ifast jRDifast -#define jpeg_idct_float jRDfloat -#define jpeg_idct_4x4 jRD4x4 -#define jpeg_idct_2x2 jRD2x2 -#define jpeg_idct_1x1 jRD1x1 -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - -/* Extern declarations for the forward and inverse DCT routines. */ - -EXTERN(void) jpeg_fdct_islow JPP((DCTELEM * data)); -EXTERN(void) jpeg_fdct_ifast JPP((DCTELEM * data)); -EXTERN(void) jpeg_fdct_float JPP((FAST_FLOAT * data)); - -EXTERN(void) jpeg_idct_islow - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_ifast - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_float - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_4x4 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_2x2 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); -EXTERN(void) jpeg_idct_1x1 - JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)); - - -/* - * Macros for handling fixed-point arithmetic; these are used by many - * but not all of the DCT/IDCT modules. - * - * All values are expected to be of type INT32. - * Fractional constants are scaled left by CONST_BITS bits. - * CONST_BITS is defined within each module using these macros, - * and may differ from one module to the next. - */ - -#define ONE ((INT32) 1) -#define CONST_SCALE (ONE << CONST_BITS) - -/* Convert a positive real constant to an integer scaled by CONST_SCALE. - * Caution: some C compilers fail to reduce "FIX(constant)" at compile time, - * thus causing a lot of useless floating-point operations at run time. - */ - -#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5)) - -/* Descale and correctly round an INT32 value that's scaled by N bits. - * We assume RIGHT_SHIFT rounds towards minus infinity, so adding - * the fudge factor is correct for either sign of X. - */ - -#define DESCALE(x,n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n) - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * This macro is used only when the two inputs will actually be no more than - * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a - * full 32x32 multiply. This provides a useful speedup on many machines. - * Unfortunately there is no way to specify a 16x16->32 multiply portably - * in C, but some C compilers will do the right thing if you provide the - * correct combination of casts. - */ - -#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ -#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT16) (const))) -#endif -#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */ -#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT32) (const))) -#endif - -#ifndef MULTIPLY16C16 /* default definition */ -#define MULTIPLY16C16(var,const) ((var) * (const)) -#endif - -/* Same except both inputs are variables. */ - -#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */ -#define MULTIPLY16V16(var1,var2) (((INT16) (var1)) * ((INT16) (var2))) -#endif - -#ifndef MULTIPLY16V16 /* default definition */ -#define MULTIPLY16V16(var1,var2) ((var1) * (var2)) -#endif diff --git a/oversampling/WDL/jpeglib/jddctmgr.c b/oversampling/WDL/jpeglib/jddctmgr.c deleted file mode 100644 index bbf8d0e..0000000 --- a/oversampling/WDL/jpeglib/jddctmgr.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * jddctmgr.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the inverse-DCT management logic. - * This code selects a particular IDCT implementation to be used, - * and it performs related housekeeping chores. No code in this file - * is executed per IDCT step, only during output pass setup. - * - * Note that the IDCT routines are responsible for performing coefficient - * dequantization as well as the IDCT proper. This module sets up the - * dequantization multiplier table needed by the IDCT routine. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - - -/* - * The decompressor input side (jdinput.c) saves away the appropriate - * quantization table for each component at the start of the first scan - * involving that component. (This is necessary in order to correctly - * decode files that reuse Q-table slots.) - * When we are ready to make an output pass, the saved Q-table is converted - * to a multiplier table that will actually be used by the IDCT routine. - * The multiplier table contents are IDCT-method-dependent. To support - * application changes in IDCT method between scans, we can remake the - * multiplier tables if necessary. - * In buffered-image mode, the first output pass may occur before any data - * has been seen for some components, and thus before their Q-tables have - * been saved away. To handle this case, multiplier tables are preset - * to zeroes; the result of the IDCT will be a neutral gray level. - */ - - -/* Private subobject for this module */ - -typedef struct { - struct jpeg_inverse_dct pub; /* public fields */ - - /* This array contains the IDCT method code that each multiplier table - * is currently set up for, or -1 if it's not yet set up. - * The actual multiplier tables are pointed to by dct_table in the - * per-component comp_info structures. - */ - int cur_method[MAX_COMPONENTS]; -} my_idct_controller; - -typedef my_idct_controller * my_idct_ptr; - - -/* Allocated multiplier tables: big enough for any supported variant */ - -typedef union { - ISLOW_MULT_TYPE islow_array[DCTSIZE2]; -#ifdef DCT_IFAST_SUPPORTED - IFAST_MULT_TYPE ifast_array[DCTSIZE2]; -#endif -#ifdef DCT_FLOAT_SUPPORTED - FLOAT_MULT_TYPE float_array[DCTSIZE2]; -#endif -} multiplier_table; - - -/* The current scaled-IDCT routines require ISLOW-style multiplier tables, - * so be sure to compile that code if either ISLOW or SCALING is requested. - */ -#ifdef DCT_ISLOW_SUPPORTED -#define PROVIDE_ISLOW_TABLES -#else -#ifdef IDCT_SCALING_SUPPORTED -#define PROVIDE_ISLOW_TABLES -#endif -#endif - - -/* - * Prepare for an output pass. - * Here we select the proper IDCT routine for each component and build - * a matching multiplier table. - */ - -METHODDEF(void) -start_pass (j_decompress_ptr cinfo) -{ - my_idct_ptr idct = (my_idct_ptr) cinfo->idct; - int ci, i; - jpeg_component_info *compptr; - int method = 0; - inverse_DCT_method_ptr method_ptr = NULL; - JQUANT_TBL * qtbl; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Select the proper IDCT routine for this component's scaling */ - switch (compptr->DCT_scaled_size) { -#ifdef IDCT_SCALING_SUPPORTED - case 1: - method_ptr = jpeg_idct_1x1; - method = JDCT_ISLOW; /* jidctred uses islow-style table */ - break; - case 2: - method_ptr = jpeg_idct_2x2; - method = JDCT_ISLOW; /* jidctred uses islow-style table */ - break; - case 4: - method_ptr = jpeg_idct_4x4; - method = JDCT_ISLOW; /* jidctred uses islow-style table */ - break; -#endif - case DCTSIZE: - switch (cinfo->dct_method) { -#ifdef DCT_ISLOW_SUPPORTED - case JDCT_ISLOW: - method_ptr = jpeg_idct_islow; - method = JDCT_ISLOW; - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - method_ptr = jpeg_idct_ifast; - method = JDCT_IFAST; - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - method_ptr = jpeg_idct_float; - method = JDCT_FLOAT; - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - break; - default: - ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->DCT_scaled_size); - break; - } - idct->pub.inverse_DCT[ci] = method_ptr; - /* Create multiplier table from quant table. - * However, we can skip this if the component is uninteresting - * or if we already built the table. Also, if no quant table - * has yet been saved for the component, we leave the - * multiplier table all-zero; we'll be reading zeroes from the - * coefficient controller's buffer anyway. - */ - if (! compptr->component_needed || idct->cur_method[ci] == method) - continue; - qtbl = compptr->quant_table; - if (qtbl == NULL) /* happens if no data yet for component */ - continue; - idct->cur_method[ci] = method; - switch (method) { -#ifdef PROVIDE_ISLOW_TABLES - case JDCT_ISLOW: - { - /* For LL&M IDCT method, multipliers are equal to raw quantization - * coefficients, but are stored as ints to ensure access efficiency. - */ - ISLOW_MULT_TYPE * ismtbl = (ISLOW_MULT_TYPE *) compptr->dct_table; - for (i = 0; i < DCTSIZE2; i++) { - ismtbl[i] = (ISLOW_MULT_TYPE) qtbl->quantval[i]; - } - } - break; -#endif -#ifdef DCT_IFAST_SUPPORTED - case JDCT_IFAST: - { - /* For AA&N IDCT method, multipliers are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - * For integer operation, the multiplier table is to be scaled by - * IFAST_SCALE_BITS. - */ - IFAST_MULT_TYPE * ifmtbl = (IFAST_MULT_TYPE *) compptr->dct_table; -#define CONST_BITS 14 - static const INT16 aanscales[DCTSIZE2] = { - /* precomputed values scaled up by 14 bits */ - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, - 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, - 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, - 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, - 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, - 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, - 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 - }; - SHIFT_TEMPS - - for (i = 0; i < DCTSIZE2; i++) { - ifmtbl[i] = (IFAST_MULT_TYPE) - DESCALE(MULTIPLY16V16((INT32) qtbl->quantval[i], - (INT32) aanscales[i]), - CONST_BITS-IFAST_SCALE_BITS); - } - } - break; -#endif -#ifdef DCT_FLOAT_SUPPORTED - case JDCT_FLOAT: - { - /* For float AA&N IDCT method, multipliers are equal to quantization - * coefficients scaled by scalefactor[row]*scalefactor[col], where - * scalefactor[0] = 1 - * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 - */ - FLOAT_MULT_TYPE * fmtbl = (FLOAT_MULT_TYPE *) compptr->dct_table; - int row, col; - static const double aanscalefactor[DCTSIZE] = { - 1.0, 1.387039845, 1.306562965, 1.175875602, - 1.0, 0.785694958, 0.541196100, 0.275899379 - }; - - i = 0; - for (row = 0; row < DCTSIZE; row++) { - for (col = 0; col < DCTSIZE; col++) { - fmtbl[i] = (FLOAT_MULT_TYPE) - ((double) qtbl->quantval[i] * - aanscalefactor[row] * aanscalefactor[col]); - i++; - } - } - } - break; -#endif - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } - } -} - - -/* - * Initialize IDCT manager. - */ - -GLOBAL(void) -jinit_inverse_dct (j_decompress_ptr cinfo) -{ - my_idct_ptr idct; - int ci; - jpeg_component_info *compptr; - - idct = (my_idct_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_idct_controller)); - cinfo->idct = (struct jpeg_inverse_dct *) idct; - idct->pub.start_pass = start_pass; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Allocate and pre-zero a multiplier table for each component */ - compptr->dct_table = - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(multiplier_table)); - MEMZERO(compptr->dct_table, SIZEOF(multiplier_table)); - /* Mark multiplier table not yet set up for any method */ - idct->cur_method[ci] = -1; - } -} diff --git a/oversampling/WDL/jpeglib/jdhuff.c b/oversampling/WDL/jpeglib/jdhuff.c deleted file mode 100644 index b5ba39f..0000000 --- a/oversampling/WDL/jpeglib/jdhuff.c +++ /dev/null @@ -1,651 +0,0 @@ -/* - * jdhuff.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy decoding routines. - * - * Much of the complexity here has to do with supporting input suspension. - * If the data source module demands suspension, we want to be able to back - * up to the start of the current MCU. To do this, we copy state variables - * into local working storage, and update them back to the permanent - * storage only upon successful completion of an MCU. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdhuff.h" /* Declarations shared with jdphuff.c */ - - -/* - * Expanded entropy decoder object for Huffman decoding. - * - * The savable_state subrecord contains fields that change within an MCU, - * but must not be updated permanently until we complete the MCU. - */ - -typedef struct { - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ -} savable_state; - -/* This macro is to work around compilers with missing or broken - * structure assignment. You'll need to fix this code if you have - * such a compiler and you change MAX_COMPS_IN_SCAN. - */ - -#ifndef NO_STRUCT_ASSIGN -#define ASSIGN_STATE(dest,src) ((dest) = (src)) -#else -#if MAX_COMPS_IN_SCAN == 4 -#define ASSIGN_STATE(dest,src) \ - ((dest).last_dc_val[0] = (src).last_dc_val[0], \ - (dest).last_dc_val[1] = (src).last_dc_val[1], \ - (dest).last_dc_val[2] = (src).last_dc_val[2], \ - (dest).last_dc_val[3] = (src).last_dc_val[3]) -#endif -#endif - - -typedef struct { - struct jpeg_entropy_decoder pub; /* public fields */ - - /* These fields are loaded into local variables at start of each MCU. - * In case of suspension, we exit WITHOUT updating them. - */ - bitread_perm_state bitstate; /* Bit buffer at start of MCU */ - savable_state saved; /* Other state at start of MCU */ - - /* These fields are NOT loaded into local working state. */ - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - - /* Pointers to derived tables (these workspaces have image lifespan) */ - d_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]; - d_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]; - - /* Precalculated info set up by start_pass for use in decode_mcu: */ - - /* Pointers to derived tables to be used for each block within an MCU */ - d_derived_tbl * dc_cur_tbls[D_MAX_BLOCKS_IN_MCU]; - d_derived_tbl * ac_cur_tbls[D_MAX_BLOCKS_IN_MCU]; - /* Whether we care about the DC and AC coefficient values for each block */ - boolean dc_needed[D_MAX_BLOCKS_IN_MCU]; - boolean ac_needed[D_MAX_BLOCKS_IN_MCU]; -} huff_entropy_decoder; - -typedef huff_entropy_decoder * huff_entropy_ptr; - - -/* - * Initialize for a Huffman-compressed scan. - */ - -METHODDEF(void) -start_pass_huff_decoder (j_decompress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci, blkn, dctbl, actbl; - jpeg_component_info * compptr; - - /* Check that the scan parameters Ss, Se, Ah/Al are OK for sequential JPEG. - * This ought to be an error condition, but we make it a warning because - * there are some baseline files out there with all zeroes in these bytes. - */ - if (cinfo->Ss != 0 || cinfo->Se != DCTSIZE2-1 || - cinfo->Ah != 0 || cinfo->Al != 0) - WARNMS(cinfo, JWRN_NOT_SEQUENTIAL); - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - dctbl = compptr->dc_tbl_no; - actbl = compptr->ac_tbl_no; - /* Compute derived values for Huffman tables */ - /* We may do this more than once for a table, but it's not expensive */ - jpeg_make_d_derived_tbl(cinfo, TRUE, dctbl, - & entropy->dc_derived_tbls[dctbl]); - jpeg_make_d_derived_tbl(cinfo, FALSE, actbl, - & entropy->ac_derived_tbls[actbl]); - /* Initialize DC predictions to 0 */ - entropy->saved.last_dc_val[ci] = 0; - } - - /* Precalculate decoding info for each block in an MCU of this scan */ - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - /* Precalculate which table to use for each block */ - entropy->dc_cur_tbls[blkn] = entropy->dc_derived_tbls[compptr->dc_tbl_no]; - entropy->ac_cur_tbls[blkn] = entropy->ac_derived_tbls[compptr->ac_tbl_no]; - /* Decide whether we really care about the coefficient values */ - if (compptr->component_needed) { - entropy->dc_needed[blkn] = TRUE; - /* we don't need the ACs if producing a 1/8th-size image */ - entropy->ac_needed[blkn] = (compptr->DCT_scaled_size > 1); - } else { - entropy->dc_needed[blkn] = entropy->ac_needed[blkn] = FALSE; - } - } - - /* Initialize bitread state variables */ - entropy->bitstate.bits_left = 0; - entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ - entropy->pub.insufficient_data = FALSE; - - /* Initialize restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; -} - - -/* - * Compute the derived values for a Huffman table. - * This routine also performs some validation checks on the table. - * - * Note this is also used by jdphuff.c. - */ - -GLOBAL(void) -jpeg_make_d_derived_tbl (j_decompress_ptr cinfo, boolean isDC, int tblno, - d_derived_tbl ** pdtbl) -{ - JHUFF_TBL *htbl; - d_derived_tbl *dtbl; - int p, i, l, si, numsymbols; - int lookbits, ctr; - char huffsize[257]; - unsigned int huffcode[257]; - unsigned int code; - - /* Note that huffsize[] and huffcode[] are filled in code-length order, - * paralleling the order of the symbols themselves in htbl->huffval[]. - */ - - /* Find the input Huffman table */ - if (tblno < 0 || tblno >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - htbl = - isDC ? cinfo->dc_huff_tbl_ptrs[tblno] : cinfo->ac_huff_tbl_ptrs[tblno]; - if (htbl == NULL) - ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tblno); - - /* Allocate a workspace if we haven't already done so. */ - if (*pdtbl == NULL) - *pdtbl = (d_derived_tbl *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(d_derived_tbl)); - dtbl = *pdtbl; - dtbl->pub = htbl; /* fill in back link */ - - /* Figure C.1: make table of Huffman code length for each symbol */ - - p = 0; - for (l = 1; l <= 16; l++) { - i = (int) htbl->bits[l]; - if (i < 0 || p + i > 256) /* protect against table overrun */ - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - while (i--) - huffsize[p++] = (char) l; - } - huffsize[p] = 0; - numsymbols = p; - - /* Figure C.2: generate the codes themselves */ - /* We also validate that the counts represent a legal Huffman code tree. */ - - code = 0; - si = huffsize[0]; - p = 0; - while (huffsize[p]) { - while (((int) huffsize[p]) == si) { - huffcode[p++] = code; - code++; - } - /* code is now 1 more than the last code used for codelength si; but - * it must still fit in si bits, since no code is allowed to be all ones. - */ - if (((INT32) code) >= (((INT32) 1) << si)) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - code <<= 1; - si++; - } - - /* Figure F.15: generate decoding tables for bit-sequential decoding */ - - p = 0; - for (l = 1; l <= 16; l++) { - if (htbl->bits[l]) { - /* valoffset[l] = huffval[] index of 1st symbol of code length l, - * minus the minimum code of length l - */ - dtbl->valoffset[l] = (INT32) p - (INT32) huffcode[p]; - p += htbl->bits[l]; - dtbl->maxcode[l] = huffcode[p-1]; /* maximum code of length l */ - } else { - dtbl->maxcode[l] = -1; /* -1 if no codes of this length */ - } - } - dtbl->maxcode[17] = 0xFFFFFL; /* ensures jpeg_huff_decode terminates */ - - /* Compute lookahead tables to speed up decoding. - * First we set all the table entries to 0, indicating "too long"; - * then we iterate through the Huffman codes that are short enough and - * fill in all the entries that correspond to bit sequences starting - * with that code. - */ - - MEMZERO(dtbl->look_nbits, SIZEOF(dtbl->look_nbits)); - - p = 0; - for (l = 1; l <= HUFF_LOOKAHEAD; l++) { - for (i = 1; i <= (int) htbl->bits[l]; i++, p++) { - /* l = current code's length, p = its index in huffcode[] & huffval[]. */ - /* Generate left-justified code followed by all possible bit sequences */ - lookbits = huffcode[p] << (HUFF_LOOKAHEAD-l); - for (ctr = 1 << (HUFF_LOOKAHEAD-l); ctr > 0; ctr--) { - dtbl->look_nbits[lookbits] = l; - dtbl->look_sym[lookbits] = htbl->huffval[p]; - lookbits++; - } - } - } - - /* Validate symbols as being reasonable. - * For AC tables, we make no check, but accept all byte values 0..255. - * For DC tables, we require the symbols to be in range 0..15. - * (Tighter bounds could be applied depending on the data depth and mode, - * but this is sufficient to ensure safe decoding.) - */ - if (isDC) { - for (i = 0; i < numsymbols; i++) { - int sym = htbl->huffval[i]; - if (sym < 0 || sym > 15) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - } - } -} - - -/* - * Out-of-line code for bit fetching (shared with jdphuff.c). - * See jdhuff.h for info about usage. - * Note: current values of get_buffer and bits_left are passed as parameters, - * but are returned in the corresponding fields of the state struct. - * - * On most machines MIN_GET_BITS should be 25 to allow the full 32-bit width - * of get_buffer to be used. (On machines with wider words, an even larger - * buffer could be used.) However, on some machines 32-bit shifts are - * quite slow and take time proportional to the number of places shifted. - * (This is true with most PC compilers, for instance.) In this case it may - * be a win to set MIN_GET_BITS to the minimum value of 15. This reduces the - * average shift distance at the cost of more calls to jpeg_fill_bit_buffer. - */ - -#ifdef SLOW_SHIFT_32 -#define MIN_GET_BITS 15 /* minimum allowable value */ -#else -#define MIN_GET_BITS (BIT_BUF_SIZE-7) -#endif - - -GLOBAL(boolean) -jpeg_fill_bit_buffer (bitread_working_state * state, - register bit_buf_type get_buffer, register int bits_left, - int nbits) -/* Load up the bit buffer to a depth of at least nbits */ -{ - /* Copy heavily used state fields into locals (hopefully registers) */ - register const JOCTET * next_input_byte = state->next_input_byte; - register size_t bytes_in_buffer = state->bytes_in_buffer; - j_decompress_ptr cinfo = state->cinfo; - - /* Attempt to load at least MIN_GET_BITS bits into get_buffer. */ - /* (It is assumed that no request will be for more than that many bits.) */ - /* We fail to do so only if we hit a marker or are forced to suspend. */ - - if (cinfo->unread_marker == 0) { /* cannot advance past a marker */ - while (bits_left < MIN_GET_BITS) { - register int c; - - /* Attempt to read a byte */ - if (bytes_in_buffer == 0) { - if (! (*cinfo->src->fill_input_buffer) (cinfo)) - return FALSE; - next_input_byte = cinfo->src->next_input_byte; - bytes_in_buffer = cinfo->src->bytes_in_buffer; - } - bytes_in_buffer--; - c = GETJOCTET(*next_input_byte++); - - /* If it's 0xFF, check and discard stuffed zero byte */ - if (c == 0xFF) { - /* Loop here to discard any padding FF's on terminating marker, - * so that we can save a valid unread_marker value. NOTE: we will - * accept multiple FF's followed by a 0 as meaning a single FF data - * byte. This data pattern is not valid according to the standard. - */ - do { - if (bytes_in_buffer == 0) { - if (! (*cinfo->src->fill_input_buffer) (cinfo)) - return FALSE; - next_input_byte = cinfo->src->next_input_byte; - bytes_in_buffer = cinfo->src->bytes_in_buffer; - } - bytes_in_buffer--; - c = GETJOCTET(*next_input_byte++); - } while (c == 0xFF); - - if (c == 0) { - /* Found FF/00, which represents an FF data byte */ - c = 0xFF; - } else { - /* Oops, it's actually a marker indicating end of compressed data. - * Save the marker code for later use. - * Fine point: it might appear that we should save the marker into - * bitread working state, not straight into permanent state. But - * once we have hit a marker, we cannot need to suspend within the - * current MCU, because we will read no more bytes from the data - * source. So it is OK to update permanent state right away. - */ - cinfo->unread_marker = c; - /* See if we need to insert some fake zero bits. */ - goto no_more_bytes; - } - } - - /* OK, load c into get_buffer */ - get_buffer = (get_buffer << 8) | c; - bits_left += 8; - } /* end while */ - } else { - no_more_bytes: - /* We get here if we've read the marker that terminates the compressed - * data segment. There should be enough bits in the buffer register - * to satisfy the request; if so, no problem. - */ - if (nbits > bits_left) { - /* Uh-oh. Report corrupted data to user and stuff zeroes into - * the data stream, so that we can produce some kind of image. - * We use a nonvolatile flag to ensure that only one warning message - * appears per data segment. - */ - if (! cinfo->entropy->insufficient_data) { - WARNMS(cinfo, JWRN_HIT_MARKER); - cinfo->entropy->insufficient_data = TRUE; - } - /* Fill the buffer with zero bits */ - get_buffer <<= MIN_GET_BITS - bits_left; - bits_left = MIN_GET_BITS; - } - } - - /* Unload the local registers */ - state->next_input_byte = next_input_byte; - state->bytes_in_buffer = bytes_in_buffer; - state->get_buffer = get_buffer; - state->bits_left = bits_left; - - return TRUE; -} - - -/* - * Out-of-line code for Huffman code decoding. - * See jdhuff.h for info about usage. - */ - -GLOBAL(int) -jpeg_huff_decode (bitread_working_state * state, - register bit_buf_type get_buffer, register int bits_left, - d_derived_tbl * htbl, int min_bits) -{ - register int l = min_bits; - register INT32 code; - - /* HUFF_DECODE has determined that the code is at least min_bits */ - /* bits long, so fetch that many bits in one swoop. */ - - CHECK_BIT_BUFFER(*state, l, return -1); - code = GET_BITS(l); - - /* Collect the rest of the Huffman code one bit at a time. */ - /* This is per Figure F.16 in the JPEG spec. */ - - while (code > htbl->maxcode[l]) { - code <<= 1; - CHECK_BIT_BUFFER(*state, 1, return -1); - code |= GET_BITS(1); - l++; - } - - /* Unload the local registers */ - state->get_buffer = get_buffer; - state->bits_left = bits_left; - - /* With garbage input we may reach the sentinel value l = 17. */ - - if (l > 16) { - WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE); - return 0; /* fake a zero as the safest result */ - } - - return htbl->pub->huffval[ (int) (code + htbl->valoffset[l]) ]; -} - - -/* - * Figure F.12: extend sign bit. - * On some machines, a shift and add will be faster than a table lookup. - */ - -#ifdef AVOID_TABLES - -#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) - -#else - -#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) - -static const int extend_test[16] = /* entry n is 2**(n-1) */ - { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, - 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; - -static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ - { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, - ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, - ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, - ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; - -#endif /* AVOID_TABLES */ - - -/* - * Check for a restart marker & resynchronize decoder. - * Returns FALSE if must suspend. - */ - -LOCAL(boolean) -process_restart (j_decompress_ptr cinfo) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int ci; - - /* Throw away any unused bits remaining in bit buffer; */ - /* include any full bytes in next_marker's count of discarded bytes */ - cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; - entropy->bitstate.bits_left = 0; - - /* Advance past the RSTn marker */ - if (! (*cinfo->marker->read_restart_marker) (cinfo)) - return FALSE; - - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) - entropy->saved.last_dc_val[ci] = 0; - - /* Reset restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; - - /* Reset out-of-data flag, unless read_restart_marker left us smack up - * against a marker. In that case we will end up treating the next data - * segment as empty, and we can avoid producing bogus output pixels by - * leaving the flag set. - */ - if (cinfo->unread_marker == 0) - entropy->pub.insufficient_data = FALSE; - - return TRUE; -} - - -/* - * Decode and return one MCU's worth of Huffman-compressed coefficients. - * The coefficients are reordered from zigzag order into natural array order, - * but are not dequantized. - * - * The i'th block of the MCU is stored into the block pointed to by - * MCU_data[i]. WE ASSUME THIS AREA HAS BEEN ZEROED BY THE CALLER. - * (Wholesale zeroing is usually a little faster than retail...) - * - * Returns FALSE if data source requested suspension. In that case no - * changes have been made to permanent state. (Exception: some output - * coefficients may already have been assigned. This is harmless for - * this module, since we'll just re-assign them on the next call.) - */ - -METHODDEF(boolean) -decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; - int blkn; - BITREAD_STATE_VARS; - savable_state state; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, just leave the MCU set to zeroes. - * This way, we return uniform gray for the remainder of the segment. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(state, entropy->saved); - - /* Outer loop handles each block in the MCU */ - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - JBLOCKROW block = MCU_data[blkn]; - d_derived_tbl * dctbl = entropy->dc_cur_tbls[blkn]; - d_derived_tbl * actbl = entropy->ac_cur_tbls[blkn]; - register int s, k, r; - - /* Decode a single block's worth of coefficients */ - - /* Section F.2.2.1: decode the DC coefficient difference */ - HUFF_DECODE(s, br_state, dctbl, return FALSE, label1); - if (s) { - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - } - - if (entropy->dc_needed[blkn]) { - /* Convert DC difference to actual value, update last_dc_val */ - int ci = cinfo->MCU_membership[blkn]; - s += state.last_dc_val[ci]; - state.last_dc_val[ci] = s; - /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */ - (*block)[0] = (JCOEF) s; - } - - if (entropy->ac_needed[blkn]) { - - /* Section F.2.2.2: decode the AC coefficients */ - /* Since zeroes are skipped, output area must be cleared beforehand */ - for (k = 1; k < DCTSIZE2; k++) { - HUFF_DECODE(s, br_state, actbl, return FALSE, label2); - - r = s >> 4; - s &= 15; - - if (s) { - k += r; - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - /* Output coefficient in natural (dezigzagged) order. - * Note: the extra entries in jpeg_natural_order[] will save us - * if k >= DCTSIZE2, which could happen if the data is corrupted. - */ - (*block)[jpeg_natural_order[k]] = (JCOEF) s; - } else { - if (r != 15) - break; - k += 15; - } - } - - } else { - - /* Section F.2.2.2: decode the AC coefficients */ - /* In this path we just discard the values */ - for (k = 1; k < DCTSIZE2; k++) { - HUFF_DECODE(s, br_state, actbl, return FALSE, label3); - - r = s >> 4; - s &= 15; - - if (s) { - k += r; - CHECK_BIT_BUFFER(br_state, s, return FALSE); - DROP_BITS(s); - } else { - if (r != 15) - break; - k += 15; - } - } - - } - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(entropy->saved, state); - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * Module initialization routine for Huffman entropy decoding. - */ - -GLOBAL(void) -jinit_huff_decoder (j_decompress_ptr cinfo) -{ - huff_entropy_ptr entropy; - int i; - - entropy = (huff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(huff_entropy_decoder)); - cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; - entropy->pub.start_pass = start_pass_huff_decoder; - entropy->pub.decode_mcu = decode_mcu; - - /* Mark tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; - } -} diff --git a/oversampling/WDL/jpeglib/jdhuff.h b/oversampling/WDL/jpeglib/jdhuff.h deleted file mode 100644 index ae19b6c..0000000 --- a/oversampling/WDL/jpeglib/jdhuff.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * jdhuff.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains declarations for Huffman entropy decoding routines - * that are shared between the sequential decoder (jdhuff.c) and the - * progressive decoder (jdphuff.c). No other modules need to see these. - */ - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_make_d_derived_tbl jMkDDerived -#define jpeg_fill_bit_buffer jFilBitBuf -#define jpeg_huff_decode jHufDecode -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Derived data constructed for each Huffman table */ - -#define HUFF_LOOKAHEAD 8 /* # of bits of lookahead */ - -typedef struct { - /* Basic tables: (element [0] of each array is unused) */ - INT32 maxcode[18]; /* largest code of length k (-1 if none) */ - /* (maxcode[17] is a sentinel to ensure jpeg_huff_decode terminates) */ - INT32 valoffset[17]; /* huffval[] offset for codes of length k */ - /* valoffset[k] = huffval[] index of 1st symbol of code length k, less - * the smallest code of length k; so given a code of length k, the - * corresponding symbol is huffval[code + valoffset[k]] - */ - - /* Link to public Huffman table (needed only in jpeg_huff_decode) */ - JHUFF_TBL *pub; - - /* Lookahead tables: indexed by the next HUFF_LOOKAHEAD bits of - * the input data stream. If the next Huffman code is no more - * than HUFF_LOOKAHEAD bits long, we can obtain its length and - * the corresponding symbol directly from these tables. - */ - int look_nbits[1< 32 bits on your machine, and shifting/masking longs is - * reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE - * appropriately should be a win. Unfortunately we can't define the size - * with something like #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8) - * because not all machines measure sizeof in 8-bit bytes. - */ - -typedef struct { /* Bitreading state saved across MCUs */ - bit_buf_type get_buffer; /* current bit-extraction buffer */ - int bits_left; /* # of unused bits in it */ -} bitread_perm_state; - -typedef struct { /* Bitreading working state within an MCU */ - /* Current data source location */ - /* We need a copy, rather than munging the original, in case of suspension */ - const JOCTET * next_input_byte; /* => next byte to read from source */ - size_t bytes_in_buffer; /* # of bytes remaining in source buffer */ - /* Bit input buffer --- note these values are kept in register variables, - * not in this struct, inside the inner loops. - */ - bit_buf_type get_buffer; /* current bit-extraction buffer */ - int bits_left; /* # of unused bits in it */ - /* Pointer needed by jpeg_fill_bit_buffer. */ - j_decompress_ptr cinfo; /* back link to decompress master record */ -} bitread_working_state; - -/* Macros to declare and load/save bitread local variables. */ -#define BITREAD_STATE_VARS \ - register bit_buf_type get_buffer; \ - register int bits_left; \ - bitread_working_state br_state - -#define BITREAD_LOAD_STATE(cinfop,permstate) \ - br_state.cinfo = cinfop; \ - br_state.next_input_byte = cinfop->src->next_input_byte; \ - br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \ - get_buffer = permstate.get_buffer; \ - bits_left = permstate.bits_left; - -#define BITREAD_SAVE_STATE(cinfop,permstate) \ - cinfop->src->next_input_byte = br_state.next_input_byte; \ - cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \ - permstate.get_buffer = get_buffer; \ - permstate.bits_left = bits_left - -/* - * These macros provide the in-line portion of bit fetching. - * Use CHECK_BIT_BUFFER to ensure there are N bits in get_buffer - * before using GET_BITS, PEEK_BITS, or DROP_BITS. - * The variables get_buffer and bits_left are assumed to be locals, - * but the state struct might not be (jpeg_huff_decode needs this). - * CHECK_BIT_BUFFER(state,n,action); - * Ensure there are N bits in get_buffer; if suspend, take action. - * val = GET_BITS(n); - * Fetch next N bits. - * val = PEEK_BITS(n); - * Fetch next N bits without removing them from the buffer. - * DROP_BITS(n); - * Discard next N bits. - * The value N should be a simple variable, not an expression, because it - * is evaluated multiple times. - */ - -#define CHECK_BIT_BUFFER(state,nbits,action) \ - { if (bits_left < (nbits)) { \ - if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \ - { action; } \ - get_buffer = (state).get_buffer; bits_left = (state).bits_left; } } - -#define GET_BITS(nbits) \ - (((int) (get_buffer >> (bits_left -= (nbits)))) & ((1<<(nbits))-1)) - -#define PEEK_BITS(nbits) \ - (((int) (get_buffer >> (bits_left - (nbits)))) & ((1<<(nbits))-1)) - -#define DROP_BITS(nbits) \ - (bits_left -= (nbits)) - -/* Load up the bit buffer to a depth of at least nbits */ -EXTERN(boolean) jpeg_fill_bit_buffer - JPP((bitread_working_state * state, register bit_buf_type get_buffer, - register int bits_left, int nbits)); - - -/* - * Code for extracting next Huffman-coded symbol from input bit stream. - * Again, this is time-critical and we make the main paths be macros. - * - * We use a lookahead table to process codes of up to HUFF_LOOKAHEAD bits - * without looping. Usually, more than 95% of the Huffman codes will be 8 - * or fewer bits long. The few overlength codes are handled with a loop, - * which need not be inline code. - * - * Notes about the HUFF_DECODE macro: - * 1. Near the end of the data segment, we may fail to get enough bits - * for a lookahead. In that case, we do it the hard way. - * 2. If the lookahead table contains no entry, the next code must be - * more than HUFF_LOOKAHEAD bits long. - * 3. jpeg_huff_decode returns -1 if forced to suspend. - */ - -#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \ -{ register int nb, look; \ - if (bits_left < HUFF_LOOKAHEAD) { \ - if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \ - get_buffer = state.get_buffer; bits_left = state.bits_left; \ - if (bits_left < HUFF_LOOKAHEAD) { \ - nb = 1; goto slowlabel; \ - } \ - } \ - look = PEEK_BITS(HUFF_LOOKAHEAD); \ - if ((nb = htbl->look_nbits[look]) != 0) { \ - DROP_BITS(nb); \ - result = htbl->look_sym[look]; \ - } else { \ - nb = HUFF_LOOKAHEAD+1; \ -slowlabel: \ - if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \ - { failaction; } \ - get_buffer = state.get_buffer; bits_left = state.bits_left; \ - } \ -} - -/* Out-of-line case for Huffman code fetching */ -EXTERN(int) jpeg_huff_decode - JPP((bitread_working_state * state, register bit_buf_type get_buffer, - register int bits_left, d_derived_tbl * htbl, int min_bits)); diff --git a/oversampling/WDL/jpeglib/jdinput.c b/oversampling/WDL/jpeglib/jdinput.c deleted file mode 100644 index 0c2ac8f..0000000 --- a/oversampling/WDL/jpeglib/jdinput.c +++ /dev/null @@ -1,381 +0,0 @@ -/* - * jdinput.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains input control logic for the JPEG decompressor. - * These routines are concerned with controlling the decompressor's input - * processing (marker reading and coefficient decoding). The actual input - * reading is done in jdmarker.c, jdhuff.c, and jdphuff.c. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private state */ - -typedef struct { - struct jpeg_input_controller pub; /* public fields */ - - boolean inheaders; /* TRUE until first SOS is reached */ -} my_input_controller; - -typedef my_input_controller * my_inputctl_ptr; - - -/* Forward declarations */ -METHODDEF(int) consume_markers JPP((j_decompress_ptr cinfo)); - - -/* - * Routines to calculate various quantities related to the size of the image. - */ - -LOCAL(void) -initial_setup (j_decompress_ptr cinfo) -/* Called once, when first SOS marker is reached */ -{ - int ci; - jpeg_component_info *compptr; - - /* Make sure image isn't bigger than I can handle */ - if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || - (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) - ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); - - /* For now, precision must match compiled-in value... */ - if (cinfo->data_precision != BITS_IN_JSAMPLE) - ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); - - /* Check that number of components won't exceed internal array sizes */ - if (cinfo->num_components > MAX_COMPONENTS) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, - MAX_COMPONENTS); - - /* Compute maximum sampling factors; check factor validity */ - cinfo->max_h_samp_factor = 1; - cinfo->max_v_samp_factor = 1; - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || - compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) - ERREXIT(cinfo, JERR_BAD_SAMPLING); - cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, - compptr->h_samp_factor); - cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, - compptr->v_samp_factor); - } - - /* We initialize DCT_scaled_size and min_DCT_scaled_size to DCTSIZE. - * In the full decompressor, this will be overridden by jdmaster.c; - * but in the transcoder, jdmaster.c is not used, so we must do it here. - */ - cinfo->min_DCT_scaled_size = DCTSIZE; - - /* Compute dimensions of components */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - compptr->DCT_scaled_size = DCTSIZE; - /* Size in DCT blocks */ - compptr->width_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) (cinfo->max_h_samp_factor * DCTSIZE)); - compptr->height_in_blocks = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) (cinfo->max_v_samp_factor * DCTSIZE)); - /* downsampled_width and downsampled_height will also be overridden by - * jdmaster.c if we are doing full decompression. The transcoder library - * doesn't use these values, but the calling application might. - */ - /* Size in samples */ - compptr->downsampled_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor, - (long) cinfo->max_h_samp_factor); - compptr->downsampled_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor, - (long) cinfo->max_v_samp_factor); - /* Mark component needed, until color conversion says otherwise */ - compptr->component_needed = TRUE; - /* Mark no quantization table yet saved for component */ - compptr->quant_table = NULL; - } - - /* Compute number of fully interleaved MCU rows. */ - cinfo->total_iMCU_rows = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); - - /* Decide whether file contains multiple scans */ - if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode) - cinfo->inputctl->has_multiple_scans = TRUE; - else - cinfo->inputctl->has_multiple_scans = FALSE; -} - - -LOCAL(void) -per_scan_setup (j_decompress_ptr cinfo) -/* Do computations that are needed before processing a JPEG scan */ -/* cinfo->comps_in_scan and cinfo->cur_comp_info[] were set from SOS marker */ -{ - int ci, mcublks, tmp; - jpeg_component_info *compptr; - - if (cinfo->comps_in_scan == 1) { - - /* Noninterleaved (single-component) scan */ - compptr = cinfo->cur_comp_info[0]; - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = compptr->width_in_blocks; - cinfo->MCU_rows_in_scan = compptr->height_in_blocks; - - /* For noninterleaved scan, always one block per MCU */ - compptr->MCU_width = 1; - compptr->MCU_height = 1; - compptr->MCU_blocks = 1; - compptr->MCU_sample_width = compptr->DCT_scaled_size; - compptr->last_col_width = 1; - /* For noninterleaved scans, it is convenient to define last_row_height - * as the number of block rows present in the last iMCU row. - */ - tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor); - if (tmp == 0) tmp = compptr->v_samp_factor; - compptr->last_row_height = tmp; - - /* Prepare array describing MCU composition */ - cinfo->blocks_in_MCU = 1; - cinfo->MCU_membership[0] = 0; - - } else { - - /* Interleaved (multi-component) scan */ - if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) - ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, - MAX_COMPS_IN_SCAN); - - /* Overall image size in MCUs */ - cinfo->MCUs_per_row = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, - (long) (cinfo->max_h_samp_factor*DCTSIZE)); - cinfo->MCU_rows_in_scan = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, - (long) (cinfo->max_v_samp_factor*DCTSIZE)); - - cinfo->blocks_in_MCU = 0; - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Sampling factors give # of blocks of component in each MCU */ - compptr->MCU_width = compptr->h_samp_factor; - compptr->MCU_height = compptr->v_samp_factor; - compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height; - compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_scaled_size; - /* Figure number of non-dummy blocks in last MCU column & row */ - tmp = (int) (compptr->width_in_blocks % compptr->MCU_width); - if (tmp == 0) tmp = compptr->MCU_width; - compptr->last_col_width = tmp; - tmp = (int) (compptr->height_in_blocks % compptr->MCU_height); - if (tmp == 0) tmp = compptr->MCU_height; - compptr->last_row_height = tmp; - /* Prepare array describing MCU composition */ - mcublks = compptr->MCU_blocks; - if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU) - ERREXIT(cinfo, JERR_BAD_MCU_SIZE); - while (mcublks-- > 0) { - cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci; - } - } - - } -} - - -/* - * Save away a copy of the Q-table referenced by each component present - * in the current scan, unless already saved during a prior scan. - * - * In a multiple-scan JPEG file, the encoder could assign different components - * the same Q-table slot number, but change table definitions between scans - * so that each component uses a different Q-table. (The IJG encoder is not - * currently capable of doing this, but other encoders might.) Since we want - * to be able to dequantize all the components at the end of the file, this - * means that we have to save away the table actually used for each component. - * We do this by copying the table at the start of the first scan containing - * the component. - * The JPEG spec prohibits the encoder from changing the contents of a Q-table - * slot between scans of a component using that slot. If the encoder does so - * anyway, this decoder will simply use the Q-table values that were current - * at the start of the first scan for the component. - * - * The decompressor output side looks only at the saved quant tables, - * not at the current Q-table slots. - */ - -LOCAL(void) -latch_quant_tables (j_decompress_ptr cinfo) -{ - int ci, qtblno; - jpeg_component_info *compptr; - JQUANT_TBL * qtbl; - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* No work if we already saved Q-table for this component */ - if (compptr->quant_table != NULL) - continue; - /* Make sure specified quantization table is present */ - qtblno = compptr->quant_tbl_no; - if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || - cinfo->quant_tbl_ptrs[qtblno] == NULL) - ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); - /* OK, save away the quantization table */ - qtbl = (JQUANT_TBL *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(JQUANT_TBL)); - MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL)); - compptr->quant_table = qtbl; - } -} - - -/* - * Initialize the input modules to read a scan of compressed data. - * The first call to this is done by jdmaster.c after initializing - * the entire decompressor (during jpeg_start_decompress). - * Subsequent calls come from consume_markers, below. - */ - -METHODDEF(void) -start_input_pass (j_decompress_ptr cinfo) -{ - per_scan_setup(cinfo); - latch_quant_tables(cinfo); - (*cinfo->entropy->start_pass) (cinfo); - (*cinfo->coef->start_input_pass) (cinfo); - cinfo->inputctl->consume_input = cinfo->coef->consume_data; -} - - -/* - * Finish up after inputting a compressed-data scan. - * This is called by the coefficient controller after it's read all - * the expected data of the scan. - */ - -METHODDEF(void) -finish_input_pass (j_decompress_ptr cinfo) -{ - cinfo->inputctl->consume_input = consume_markers; -} - - -/* - * Read JPEG markers before, between, or after compressed-data scans. - * Change state as necessary when a new scan is reached. - * Return value is JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. - * - * The consume_input method pointer points either here or to the - * coefficient controller's consume_data routine, depending on whether - * we are reading a compressed data segment or inter-segment markers. - */ - -METHODDEF(int) -consume_markers (j_decompress_ptr cinfo) -{ - my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; - int val; - - if (inputctl->pub.eoi_reached) /* After hitting EOI, read no further */ - return JPEG_REACHED_EOI; - - val = (*cinfo->marker->read_markers) (cinfo); - - switch (val) { - case JPEG_REACHED_SOS: /* Found SOS */ - if (inputctl->inheaders) { /* 1st SOS */ - initial_setup(cinfo); - inputctl->inheaders = FALSE; - /* Note: start_input_pass must be called by jdmaster.c - * before any more input can be consumed. jdapimin.c is - * responsible for enforcing this sequencing. - */ - } else { /* 2nd or later SOS marker */ - if (! inputctl->pub.has_multiple_scans) - ERREXIT(cinfo, JERR_EOI_EXPECTED); /* Oops, I wasn't expecting this! */ - start_input_pass(cinfo); - } - break; - case JPEG_REACHED_EOI: /* Found EOI */ - inputctl->pub.eoi_reached = TRUE; - if (inputctl->inheaders) { /* Tables-only datastream, apparently */ - if (cinfo->marker->saw_SOF) - ERREXIT(cinfo, JERR_SOF_NO_SOS); - } else { - /* Prevent infinite loop in coef ctlr's decompress_data routine - * if user set output_scan_number larger than number of scans. - */ - if (cinfo->output_scan_number > cinfo->input_scan_number) - cinfo->output_scan_number = cinfo->input_scan_number; - } - break; - case JPEG_SUSPENDED: - break; - } - - return val; -} - - -/* - * Reset state to begin a fresh datastream. - */ - -METHODDEF(void) -reset_input_controller (j_decompress_ptr cinfo) -{ - my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl; - - inputctl->pub.consume_input = consume_markers; - inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ - inputctl->pub.eoi_reached = FALSE; - inputctl->inheaders = TRUE; - /* Reset other modules */ - (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); - (*cinfo->marker->reset_marker_reader) (cinfo); - /* Reset progression state -- would be cleaner if entropy decoder did this */ - cinfo->coef_bits = NULL; -} - - -/* - * Initialize the input controller module. - * This is called only once, when the decompression object is created. - */ - -GLOBAL(void) -jinit_input_controller (j_decompress_ptr cinfo) -{ - my_inputctl_ptr inputctl; - - /* Create subobject in permanent pool */ - inputctl = (my_inputctl_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_input_controller)); - cinfo->inputctl = (struct jpeg_input_controller *) inputctl; - /* Initialize method pointers */ - inputctl->pub.consume_input = consume_markers; - inputctl->pub.reset_input_controller = reset_input_controller; - inputctl->pub.start_input_pass = start_input_pass; - inputctl->pub.finish_input_pass = finish_input_pass; - /* Initialize state: can't use reset_input_controller since we don't - * want to try to reset other modules yet. - */ - inputctl->pub.has_multiple_scans = FALSE; /* "unknown" would be better */ - inputctl->pub.eoi_reached = FALSE; - inputctl->inheaders = TRUE; -} diff --git a/oversampling/WDL/jpeglib/jdmainct.c b/oversampling/WDL/jpeglib/jdmainct.c deleted file mode 100644 index 13c956f..0000000 --- a/oversampling/WDL/jpeglib/jdmainct.c +++ /dev/null @@ -1,512 +0,0 @@ -/* - * jdmainct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the main buffer controller for decompression. - * The main buffer lies between the JPEG decompressor proper and the - * post-processor; it holds downsampled data in the JPEG colorspace. - * - * Note that this code is bypassed in raw-data mode, since the application - * supplies the equivalent of the main buffer in that case. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * In the current system design, the main buffer need never be a full-image - * buffer; any full-height buffers will be found inside the coefficient or - * postprocessing controllers. Nonetheless, the main controller is not - * trivial. Its responsibility is to provide context rows for upsampling/ - * rescaling, and doing this in an efficient fashion is a bit tricky. - * - * Postprocessor input data is counted in "row groups". A row group - * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) - * sample rows of each component. (We require DCT_scaled_size values to be - * chosen such that these numbers are integers. In practice DCT_scaled_size - * values will likely be powers of two, so we actually have the stronger - * condition that DCT_scaled_size / min_DCT_scaled_size is an integer.) - * Upsampling will typically produce max_v_samp_factor pixel rows from each - * row group (times any additional scale factor that the upsampler is - * applying). - * - * The coefficient controller will deliver data to us one iMCU row at a time; - * each iMCU row contains v_samp_factor * DCT_scaled_size sample rows, or - * exactly min_DCT_scaled_size row groups. (This amount of data corresponds - * to one row of MCUs when the image is fully interleaved.) Note that the - * number of sample rows varies across components, but the number of row - * groups does not. Some garbage sample rows may be included in the last iMCU - * row at the bottom of the image. - * - * Depending on the vertical scaling algorithm used, the upsampler may need - * access to the sample row(s) above and below its current input row group. - * The upsampler is required to set need_context_rows TRUE at global selection - * time if so. When need_context_rows is FALSE, this controller can simply - * obtain one iMCU row at a time from the coefficient controller and dole it - * out as row groups to the postprocessor. - * - * When need_context_rows is TRUE, this controller guarantees that the buffer - * passed to postprocessing contains at least one row group's worth of samples - * above and below the row group(s) being processed. Note that the context - * rows "above" the first passed row group appear at negative row offsets in - * the passed buffer. At the top and bottom of the image, the required - * context rows are manufactured by duplicating the first or last real sample - * row; this avoids having special cases in the upsampling inner loops. - * - * The amount of context is fixed at one row group just because that's a - * convenient number for this controller to work with. The existing - * upsamplers really only need one sample row of context. An upsampler - * supporting arbitrary output rescaling might wish for more than one row - * group of context when shrinking the image; tough, we don't handle that. - * (This is justified by the assumption that downsizing will be handled mostly - * by adjusting the DCT_scaled_size values, so that the actual scale factor at - * the upsample step needn't be much less than one.) - * - * To provide the desired context, we have to retain the last two row groups - * of one iMCU row while reading in the next iMCU row. (The last row group - * can't be processed until we have another row group for its below-context, - * and so we have to save the next-to-last group too for its above-context.) - * We could do this most simply by copying data around in our buffer, but - * that'd be very slow. We can avoid copying any data by creating a rather - * strange pointer structure. Here's how it works. We allocate a workspace - * consisting of M+2 row groups (where M = min_DCT_scaled_size is the number - * of row groups per iMCU row). We create two sets of redundant pointers to - * the workspace. Labeling the physical row groups 0 to M+1, the synthesized - * pointer lists look like this: - * M+1 M-1 - * master pointer --> 0 master pointer --> 0 - * 1 1 - * ... ... - * M-3 M-3 - * M-2 M - * M-1 M+1 - * M M-2 - * M+1 M-1 - * 0 0 - * We read alternate iMCU rows using each master pointer; thus the last two - * row groups of the previous iMCU row remain un-overwritten in the workspace. - * The pointer lists are set up so that the required context rows appear to - * be adjacent to the proper places when we pass the pointer lists to the - * upsampler. - * - * The above pictures describe the normal state of the pointer lists. - * At top and bottom of the image, we diddle the pointer lists to duplicate - * the first or last sample row as necessary (this is cheaper than copying - * sample rows around). - * - * This scheme breaks down if M < 2, ie, min_DCT_scaled_size is 1. In that - * situation each iMCU row provides only one row group so the buffering logic - * must be different (eg, we must read two iMCU rows before we can emit the - * first row group). For now, we simply do not support providing context - * rows when min_DCT_scaled_size is 1. That combination seems unlikely to - * be worth providing --- if someone wants a 1/8th-size preview, they probably - * want it quick and dirty, so a context-free upsampler is sufficient. - */ - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_d_main_controller pub; /* public fields */ - - /* Pointer to allocated workspace (M or M+2 row groups). */ - JSAMPARRAY buffer[MAX_COMPONENTS]; - - boolean buffer_full; /* Have we gotten an iMCU row from decoder? */ - JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */ - - /* Remaining fields are only used in the context case. */ - - /* These are the master pointers to the funny-order pointer lists. */ - JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */ - - int whichptr; /* indicates which pointer set is now in use */ - int context_state; /* process_data state machine status */ - JDIMENSION rowgroups_avail; /* row groups available to postprocessor */ - JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */ -} my_main_controller; - -typedef my_main_controller * my_main_ptr; - -/* context_state values: */ -#define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */ -#define CTX_PROCESS_IMCU 1 /* feeding iMCU to postprocessor */ -#define CTX_POSTPONED_ROW 2 /* feeding postponed row group */ - - -/* Forward declarations */ -METHODDEF(void) process_data_simple_main - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); -METHODDEF(void) process_data_context_main - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); -#ifdef QUANT_2PASS_SUPPORTED -METHODDEF(void) process_data_crank_post - JPP((j_decompress_ptr cinfo, JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, JDIMENSION out_rows_avail)); -#endif - - -LOCAL(void) -alloc_funny_pointers (j_decompress_ptr cinfo) -/* Allocate space for the funny pointer lists. - * This is done only once, not once per pass. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, rgroup; - int M = cinfo->min_DCT_scaled_size; - jpeg_component_info *compptr; - JSAMPARRAY xbuf; - - /* Get top-level space for component array pointers. - * We alloc both arrays with one call to save a few cycles. - */ - main->xbuffer[0] = (JSAMPIMAGE) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components * 2 * SIZEOF(JSAMPARRAY)); - main->xbuffer[1] = main->xbuffer[0] + cinfo->num_components; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - /* Get space for pointer lists --- M+4 row groups in each list. - * We alloc both pointer lists with one call to save a few cycles. - */ - xbuf = (JSAMPARRAY) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - 2 * (rgroup * (M + 4)) * SIZEOF(JSAMPROW)); - xbuf += rgroup; /* want one row group at negative offsets */ - main->xbuffer[0][ci] = xbuf; - xbuf += rgroup * (M + 4); - main->xbuffer[1][ci] = xbuf; - } -} - - -LOCAL(void) -make_funny_pointers (j_decompress_ptr cinfo) -/* Create the funny pointer lists discussed in the comments above. - * The actual workspace is already allocated (in main->buffer), - * and the space for the pointer lists is allocated too. - * This routine just fills in the curiously ordered lists. - * This will be repeated at the beginning of each pass. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, i, rgroup; - int M = cinfo->min_DCT_scaled_size; - jpeg_component_info *compptr; - JSAMPARRAY buf, xbuf0, xbuf1; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - xbuf0 = main->xbuffer[0][ci]; - xbuf1 = main->xbuffer[1][ci]; - /* First copy the workspace pointers as-is */ - buf = main->buffer[ci]; - for (i = 0; i < rgroup * (M + 2); i++) { - xbuf0[i] = xbuf1[i] = buf[i]; - } - /* In the second list, put the last four row groups in swapped order */ - for (i = 0; i < rgroup * 2; i++) { - xbuf1[rgroup*(M-2) + i] = buf[rgroup*M + i]; - xbuf1[rgroup*M + i] = buf[rgroup*(M-2) + i]; - } - /* The wraparound pointers at top and bottom will be filled later - * (see set_wraparound_pointers, below). Initially we want the "above" - * pointers to duplicate the first actual data line. This only needs - * to happen in xbuffer[0]. - */ - for (i = 0; i < rgroup; i++) { - xbuf0[i - rgroup] = xbuf0[0]; - } - } -} - - -LOCAL(void) -set_wraparound_pointers (j_decompress_ptr cinfo) -/* Set up the "wraparound" pointers at top and bottom of the pointer lists. - * This changes the pointer list state from top-of-image to the normal state. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, i, rgroup; - int M = cinfo->min_DCT_scaled_size; - jpeg_component_info *compptr; - JSAMPARRAY xbuf0, xbuf1; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - xbuf0 = main->xbuffer[0][ci]; - xbuf1 = main->xbuffer[1][ci]; - for (i = 0; i < rgroup; i++) { - xbuf0[i - rgroup] = xbuf0[rgroup*(M+1) + i]; - xbuf1[i - rgroup] = xbuf1[rgroup*(M+1) + i]; - xbuf0[rgroup*(M+2) + i] = xbuf0[i]; - xbuf1[rgroup*(M+2) + i] = xbuf1[i]; - } - } -} - - -LOCAL(void) -set_bottom_pointers (j_decompress_ptr cinfo) -/* Change the pointer lists to duplicate the last sample row at the bottom - * of the image. whichptr indicates which xbuffer holds the final iMCU row. - * Also sets rowgroups_avail to indicate number of nondummy row groups in row. - */ -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - int ci, i, rgroup, iMCUheight, rows_left; - jpeg_component_info *compptr; - JSAMPARRAY xbuf; - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Count sample rows in one iMCU row and in one row group */ - iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size; - rgroup = iMCUheight / cinfo->min_DCT_scaled_size; - /* Count nondummy sample rows remaining for this component */ - rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight); - if (rows_left == 0) rows_left = iMCUheight; - /* Count nondummy row groups. Should get same answer for each component, - * so we need only do it once. - */ - if (ci == 0) { - main->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1); - } - /* Duplicate the last real sample row rgroup*2 times; this pads out the - * last partial rowgroup and ensures at least one full rowgroup of context. - */ - xbuf = main->xbuffer[main->whichptr][ci]; - for (i = 0; i < rgroup * 2; i++) { - xbuf[rows_left + i] = xbuf[rows_left-1]; - } - } -} - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - switch (pass_mode) { - case JBUF_PASS_THRU: - if (cinfo->upsample->need_context_rows) { - main->pub.process_data = process_data_context_main; - make_funny_pointers(cinfo); /* Create the xbuffer[] lists */ - main->whichptr = 0; /* Read first iMCU row into xbuffer[0] */ - main->context_state = CTX_PREPARE_FOR_IMCU; - main->iMCU_row_ctr = 0; - } else { - /* Simple case with no context needed */ - main->pub.process_data = process_data_simple_main; - } - main->buffer_full = FALSE; /* Mark buffer empty */ - main->rowgroup_ctr = 0; - break; -#ifdef QUANT_2PASS_SUPPORTED - case JBUF_CRANK_DEST: - /* For last pass of 2-pass quantization, just crank the postprocessor */ - main->pub.process_data = process_data_crank_post; - break; -#endif - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } -} - - -/* - * Process some data. - * This handles the simple case where no context is required. - */ - -METHODDEF(void) -process_data_simple_main (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - JDIMENSION rowgroups_avail; - - /* Read input data if we haven't filled the main buffer yet */ - if (! main->buffer_full) { - if (! (*cinfo->coef->decompress_data) (cinfo, main->buffer)) - return; /* suspension forced, can do nothing more */ - main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ - } - - /* There are always min_DCT_scaled_size row groups in an iMCU row. */ - rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size; - /* Note: at the bottom of the image, we may pass extra garbage row groups - * to the postprocessor. The postprocessor has to check for bottom - * of image anyway (at row resolution), so no point in us doing it too. - */ - - /* Feed the postprocessor */ - (*cinfo->post->post_process_data) (cinfo, main->buffer, - &main->rowgroup_ctr, rowgroups_avail, - output_buf, out_row_ctr, out_rows_avail); - - /* Has postprocessor consumed all the data yet? If so, mark buffer empty */ - if (main->rowgroup_ctr >= rowgroups_avail) { - main->buffer_full = FALSE; - main->rowgroup_ctr = 0; - } -} - - -/* - * Process some data. - * This handles the case where context rows must be provided. - */ - -METHODDEF(void) -process_data_context_main (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_main_ptr main = (my_main_ptr) cinfo->main; - - /* Read input data if we haven't filled the main buffer yet */ - if (! main->buffer_full) { - if (! (*cinfo->coef->decompress_data) (cinfo, - main->xbuffer[main->whichptr])) - return; /* suspension forced, can do nothing more */ - main->buffer_full = TRUE; /* OK, we have an iMCU row to work with */ - main->iMCU_row_ctr++; /* count rows received */ - } - - /* Postprocessor typically will not swallow all the input data it is handed - * in one call (due to filling the output buffer first). Must be prepared - * to exit and restart. This switch lets us keep track of how far we got. - * Note that each case falls through to the next on successful completion. - */ - switch (main->context_state) { - case CTX_POSTPONED_ROW: - /* Call postprocessor using previously set pointers for postponed row */ - (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], - &main->rowgroup_ctr, main->rowgroups_avail, - output_buf, out_row_ctr, out_rows_avail); - if (main->rowgroup_ctr < main->rowgroups_avail) - return; /* Need to suspend */ - main->context_state = CTX_PREPARE_FOR_IMCU; - if (*out_row_ctr >= out_rows_avail) - return; /* Postprocessor exactly filled output buf */ - /*FALLTHROUGH*/ - case CTX_PREPARE_FOR_IMCU: - /* Prepare to process first M-1 row groups of this iMCU row */ - main->rowgroup_ctr = 0; - main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1); - /* Check for bottom of image: if so, tweak pointers to "duplicate" - * the last sample row, and adjust rowgroups_avail to ignore padding rows. - */ - if (main->iMCU_row_ctr == cinfo->total_iMCU_rows) - set_bottom_pointers(cinfo); - main->context_state = CTX_PROCESS_IMCU; - /*FALLTHROUGH*/ - case CTX_PROCESS_IMCU: - /* Call postprocessor using previously set pointers */ - (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr], - &main->rowgroup_ctr, main->rowgroups_avail, - output_buf, out_row_ctr, out_rows_avail); - if (main->rowgroup_ctr < main->rowgroups_avail) - return; /* Need to suspend */ - /* After the first iMCU, change wraparound pointers to normal state */ - if (main->iMCU_row_ctr == 1) - set_wraparound_pointers(cinfo); - /* Prepare to load new iMCU row using other xbuffer list */ - main->whichptr ^= 1; /* 0=>1 or 1=>0 */ - main->buffer_full = FALSE; - /* Still need to process last row group of this iMCU row, */ - /* which is saved at index M+1 of the other xbuffer */ - main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1); - main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2); - main->context_state = CTX_POSTPONED_ROW; - } -} - - -/* - * Process some data. - * Final pass of two-pass quantization: just call the postprocessor. - * Source data will be the postprocessor controller's internal buffer. - */ - -#ifdef QUANT_2PASS_SUPPORTED - -METHODDEF(void) -process_data_crank_post (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - (*cinfo->post->post_process_data) (cinfo, (JSAMPIMAGE) NULL, - (JDIMENSION *) NULL, (JDIMENSION) 0, - output_buf, out_row_ctr, out_rows_avail); -} - -#endif /* QUANT_2PASS_SUPPORTED */ - - -/* - * Initialize main buffer controller. - */ - -GLOBAL(void) -jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer) -{ - my_main_ptr main; - int ci, rgroup, ngroups; - jpeg_component_info *compptr; - - main = (my_main_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_main_controller)); - cinfo->main = (struct jpeg_d_main_controller *) main; - main->pub.start_pass = start_pass_main; - - if (need_full_buffer) /* shouldn't happen */ - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - - /* Allocate the workspace. - * ngroups is the number of row groups we need. - */ - if (cinfo->upsample->need_context_rows) { - if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */ - ERREXIT(cinfo, JERR_NOTIMPL); - alloc_funny_pointers(cinfo); /* Alloc space for xbuffer[] lists */ - ngroups = cinfo->min_DCT_scaled_size + 2; - } else { - ngroups = cinfo->min_DCT_scaled_size; - } - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ - main->buffer[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - compptr->width_in_blocks * compptr->DCT_scaled_size, - (JDIMENSION) (rgroup * ngroups)); - } -} diff --git a/oversampling/WDL/jpeglib/jdmarker.c b/oversampling/WDL/jpeglib/jdmarker.c deleted file mode 100644 index f4cca8c..0000000 --- a/oversampling/WDL/jpeglib/jdmarker.c +++ /dev/null @@ -1,1360 +0,0 @@ -/* - * jdmarker.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains routines to decode JPEG datastream markers. - * Most of the complexity arises from our desire to support input - * suspension: if not all of the data for a marker is available, - * we must exit back to the application. On resumption, we reprocess - * the marker. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -typedef enum { /* JPEG marker codes */ - M_SOF0 = 0xc0, - M_SOF1 = 0xc1, - M_SOF2 = 0xc2, - M_SOF3 = 0xc3, - - M_SOF5 = 0xc5, - M_SOF6 = 0xc6, - M_SOF7 = 0xc7, - - M_JPG = 0xc8, - M_SOF9 = 0xc9, - M_SOF10 = 0xca, - M_SOF11 = 0xcb, - - M_SOF13 = 0xcd, - M_SOF14 = 0xce, - M_SOF15 = 0xcf, - - M_DHT = 0xc4, - - M_DAC = 0xcc, - - M_RST0 = 0xd0, - M_RST1 = 0xd1, - M_RST2 = 0xd2, - M_RST3 = 0xd3, - M_RST4 = 0xd4, - M_RST5 = 0xd5, - M_RST6 = 0xd6, - M_RST7 = 0xd7, - - M_SOI = 0xd8, - M_EOI = 0xd9, - M_SOS = 0xda, - M_DQT = 0xdb, - M_DNL = 0xdc, - M_DRI = 0xdd, - M_DHP = 0xde, - M_EXP = 0xdf, - - M_APP0 = 0xe0, - M_APP1 = 0xe1, - M_APP2 = 0xe2, - M_APP3 = 0xe3, - M_APP4 = 0xe4, - M_APP5 = 0xe5, - M_APP6 = 0xe6, - M_APP7 = 0xe7, - M_APP8 = 0xe8, - M_APP9 = 0xe9, - M_APP10 = 0xea, - M_APP11 = 0xeb, - M_APP12 = 0xec, - M_APP13 = 0xed, - M_APP14 = 0xee, - M_APP15 = 0xef, - - M_JPG0 = 0xf0, - M_JPG13 = 0xfd, - M_COM = 0xfe, - - M_TEM = 0x01, - - M_ERROR = 0x100 -} JPEG_MARKER; - - -/* Private state */ - -typedef struct { - struct jpeg_marker_reader pub; /* public fields */ - - /* Application-overridable marker processing methods */ - jpeg_marker_parser_method process_COM; - jpeg_marker_parser_method process_APPn[16]; - - /* Limit on marker data length to save for each marker type */ - unsigned int length_limit_COM; - unsigned int length_limit_APPn[16]; - - /* Status of COM/APPn marker saving */ - jpeg_saved_marker_ptr cur_marker; /* NULL if not processing a marker */ - unsigned int bytes_read; /* data bytes read so far in marker */ - /* Note: cur_marker is not linked into marker_list until it's all read. */ -} my_marker_reader; - -typedef my_marker_reader * my_marker_ptr; - - -/* - * Macros for fetching data from the data source module. - * - * At all times, cinfo->src->next_input_byte and ->bytes_in_buffer reflect - * the current restart point; we update them only when we have reached a - * suitable place to restart if a suspension occurs. - */ - -/* Declare and initialize local copies of input pointer/count */ -#define INPUT_VARS(cinfo) \ - struct jpeg_source_mgr * datasrc = (cinfo)->src; \ - const JOCTET * next_input_byte = datasrc->next_input_byte; \ - size_t bytes_in_buffer = datasrc->bytes_in_buffer - -/* Unload the local copies --- do this only at a restart boundary */ -#define INPUT_SYNC(cinfo) \ - ( datasrc->next_input_byte = next_input_byte, \ - datasrc->bytes_in_buffer = bytes_in_buffer ) - -/* Reload the local copies --- used only in MAKE_BYTE_AVAIL */ -#define INPUT_RELOAD(cinfo) \ - ( next_input_byte = datasrc->next_input_byte, \ - bytes_in_buffer = datasrc->bytes_in_buffer ) - -/* Internal macro for INPUT_BYTE and INPUT_2BYTES: make a byte available. - * Note we do *not* do INPUT_SYNC before calling fill_input_buffer, - * but we must reload the local copies after a successful fill. - */ -#define MAKE_BYTE_AVAIL(cinfo,action) \ - if (bytes_in_buffer == 0) { \ - if (! (*datasrc->fill_input_buffer) (cinfo)) \ - { action; } \ - INPUT_RELOAD(cinfo); \ - } - -/* Read a byte into variable V. - * If must suspend, take the specified action (typically "return FALSE"). - */ -#define INPUT_BYTE(cinfo,V,action) \ - MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ - bytes_in_buffer--; \ - V = GETJOCTET(*next_input_byte++); ) - -/* As above, but read two bytes interpreted as an unsigned 16-bit integer. - * V should be declared unsigned int or perhaps INT32. - */ -#define INPUT_2BYTES(cinfo,V,action) \ - MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ - bytes_in_buffer--; \ - V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \ - MAKE_BYTE_AVAIL(cinfo,action); \ - bytes_in_buffer--; \ - V += GETJOCTET(*next_input_byte++); ) - - -/* - * Routines to process JPEG markers. - * - * Entry condition: JPEG marker itself has been read and its code saved - * in cinfo->unread_marker; input restart point is just after the marker. - * - * Exit: if return TRUE, have read and processed any parameters, and have - * updated the restart point to point after the parameters. - * If return FALSE, was forced to suspend before reaching end of - * marker parameters; restart point has not been moved. Same routine - * will be called again after application supplies more input data. - * - * This approach to suspension assumes that all of a marker's parameters - * can fit into a single input bufferload. This should hold for "normal" - * markers. Some COM/APPn markers might have large parameter segments - * that might not fit. If we are simply dropping such a marker, we use - * skip_input_data to get past it, and thereby put the problem on the - * source manager's shoulders. If we are saving the marker's contents - * into memory, we use a slightly different convention: when forced to - * suspend, the marker processor updates the restart point to the end of - * what it's consumed (ie, the end of the buffer) before returning FALSE. - * On resumption, cinfo->unread_marker still contains the marker code, - * but the data source will point to the next chunk of marker data. - * The marker processor must retain internal state to deal with this. - * - * Note that we don't bother to avoid duplicate trace messages if a - * suspension occurs within marker parameters. Other side effects - * require more care. - */ - - -LOCAL(boolean) -get_soi (j_decompress_ptr cinfo) -/* Process an SOI marker */ -{ - int i; - - TRACEMS(cinfo, 1, JTRC_SOI); - - if (cinfo->marker->saw_SOI) - ERREXIT(cinfo, JERR_SOI_DUPLICATE); - - /* Reset all parameters that are defined to be reset by SOI */ - - for (i = 0; i < NUM_ARITH_TBLS; i++) { - cinfo->arith_dc_L[i] = 0; - cinfo->arith_dc_U[i] = 1; - cinfo->arith_ac_K[i] = 5; - } - cinfo->restart_interval = 0; - - /* Set initial assumptions for colorspace etc */ - - cinfo->jpeg_color_space = JCS_UNKNOWN; - cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */ - - cinfo->saw_JFIF_marker = FALSE; - cinfo->JFIF_major_version = 1; /* set default JFIF APP0 values */ - cinfo->JFIF_minor_version = 1; - cinfo->density_unit = 0; - cinfo->X_density = 1; - cinfo->Y_density = 1; - cinfo->saw_Adobe_marker = FALSE; - cinfo->Adobe_transform = 0; - - cinfo->marker->saw_SOI = TRUE; - - return TRUE; -} - - -LOCAL(boolean) -get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith) -/* Process a SOFn marker */ -{ - INT32 length; - int c, ci; - jpeg_component_info * compptr; - INPUT_VARS(cinfo); - - cinfo->progressive_mode = is_prog; - cinfo->arith_code = is_arith; - - INPUT_2BYTES(cinfo, length, return FALSE); - - INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE); - INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE); - INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE); - INPUT_BYTE(cinfo, cinfo->num_components, return FALSE); - - length -= 8; - - TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker, - (int) cinfo->image_width, (int) cinfo->image_height, - cinfo->num_components); - - if (cinfo->marker->saw_SOF) - ERREXIT(cinfo, JERR_SOF_DUPLICATE); - - /* We don't support files in which the image height is initially specified */ - /* as 0 and is later redefined by DNL. As long as we have to check that, */ - /* might as well have a general sanity check. */ - if (cinfo->image_height <= 0 || cinfo->image_width <= 0 - || cinfo->num_components <= 0) - ERREXIT(cinfo, JERR_EMPTY_IMAGE); - - if (length != (cinfo->num_components * 3)) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - if (cinfo->comp_info == NULL) /* do only once, even if suspend */ - cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components * SIZEOF(jpeg_component_info)); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - compptr->component_index = ci; - INPUT_BYTE(cinfo, compptr->component_id, return FALSE); - INPUT_BYTE(cinfo, c, return FALSE); - compptr->h_samp_factor = (c >> 4) & 15; - compptr->v_samp_factor = (c ) & 15; - INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE); - - TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT, - compptr->component_id, compptr->h_samp_factor, - compptr->v_samp_factor, compptr->quant_tbl_no); - } - - cinfo->marker->saw_SOF = TRUE; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -get_sos (j_decompress_ptr cinfo) -/* Process a SOS marker */ -{ - INT32 length; - int i, ci, n, c, cc; - jpeg_component_info * compptr; - INPUT_VARS(cinfo); - - if (! cinfo->marker->saw_SOF) - ERREXIT(cinfo, JERR_SOS_NO_SOF); - - INPUT_2BYTES(cinfo, length, return FALSE); - - INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */ - - TRACEMS1(cinfo, 1, JTRC_SOS, n); - - if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - cinfo->comps_in_scan = n; - - /* Collect the component-spec parameters */ - - for (i = 0; i < n; i++) { - INPUT_BYTE(cinfo, cc, return FALSE); - INPUT_BYTE(cinfo, c, return FALSE); - - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - if (cc == compptr->component_id) - goto id_found; - } - - ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc); - - id_found: - - cinfo->cur_comp_info[i] = compptr; - compptr->dc_tbl_no = (c >> 4) & 15; - compptr->ac_tbl_no = (c ) & 15; - - TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc, - compptr->dc_tbl_no, compptr->ac_tbl_no); - } - - /* Collect the additional scan parameters Ss, Se, Ah/Al. */ - INPUT_BYTE(cinfo, c, return FALSE); - cinfo->Ss = c; - INPUT_BYTE(cinfo, c, return FALSE); - cinfo->Se = c; - INPUT_BYTE(cinfo, c, return FALSE); - cinfo->Ah = (c >> 4) & 15; - cinfo->Al = (c ) & 15; - - TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se, - cinfo->Ah, cinfo->Al); - - /* Prepare to scan data & restart markers */ - cinfo->marker->next_restart_num = 0; - - /* Count another SOS marker */ - cinfo->input_scan_number++; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -#ifdef D_ARITH_CODING_SUPPORTED - -LOCAL(boolean) -get_dac (j_decompress_ptr cinfo) -/* Process a DAC marker */ -{ - INT32 length; - int index, val; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - while (length > 0) { - INPUT_BYTE(cinfo, index, return FALSE); - INPUT_BYTE(cinfo, val, return FALSE); - - length -= 2; - - TRACEMS2(cinfo, 1, JTRC_DAC, index, val); - - if (index < 0 || index >= (2*NUM_ARITH_TBLS)) - ERREXIT1(cinfo, JERR_DAC_INDEX, index); - - if (index >= NUM_ARITH_TBLS) { /* define AC table */ - cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val; - } else { /* define DC table */ - cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F); - cinfo->arith_dc_U[index] = (UINT8) (val >> 4); - if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index]) - ERREXIT1(cinfo, JERR_DAC_VALUE, val); - } - } - - if (length != 0) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_SYNC(cinfo); - return TRUE; -} - -#else /* ! D_ARITH_CODING_SUPPORTED */ - -#define get_dac(cinfo) skip_variable(cinfo) - -#endif /* D_ARITH_CODING_SUPPORTED */ - - -LOCAL(boolean) -get_dht (j_decompress_ptr cinfo) -/* Process a DHT marker */ -{ - INT32 length; - UINT8 bits[17]; - UINT8 huffval[256]; - int i, index, count; - JHUFF_TBL **htblptr; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - while (length > 16) { - INPUT_BYTE(cinfo, index, return FALSE); - - TRACEMS1(cinfo, 1, JTRC_DHT, index); - - bits[0] = 0; - count = 0; - for (i = 1; i <= 16; i++) { - INPUT_BYTE(cinfo, bits[i], return FALSE); - count += bits[i]; - } - - length -= 1 + 16; - - TRACEMS8(cinfo, 2, JTRC_HUFFBITS, - bits[1], bits[2], bits[3], bits[4], - bits[5], bits[6], bits[7], bits[8]); - TRACEMS8(cinfo, 2, JTRC_HUFFBITS, - bits[9], bits[10], bits[11], bits[12], - bits[13], bits[14], bits[15], bits[16]); - - /* Here we just do minimal validation of the counts to avoid walking - * off the end of our table space. jdhuff.c will check more carefully. - */ - if (count > 256 || ((INT32) count) > length) - ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); - - for (i = 0; i < count; i++) - INPUT_BYTE(cinfo, huffval[i], return FALSE); - - length -= count; - - if (index & 0x10) { /* AC table definition */ - index -= 0x10; - htblptr = &cinfo->ac_huff_tbl_ptrs[index]; - } else { /* DC table definition */ - htblptr = &cinfo->dc_huff_tbl_ptrs[index]; - } - - if (index < 0 || index >= NUM_HUFF_TBLS) - ERREXIT1(cinfo, JERR_DHT_INDEX, index); - - if (*htblptr == NULL) - *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo); - - MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits)); - MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval)); - } - - if (length != 0) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -get_dqt (j_decompress_ptr cinfo) -/* Process a DQT marker */ -{ - INT32 length; - int n, i, prec; - unsigned int tmp; - JQUANT_TBL *quant_ptr; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - while (length > 0) { - INPUT_BYTE(cinfo, n, return FALSE); - prec = n >> 4; - n &= 0x0F; - - TRACEMS2(cinfo, 1, JTRC_DQT, n, prec); - - if (n >= NUM_QUANT_TBLS) - ERREXIT1(cinfo, JERR_DQT_INDEX, n); - - if (cinfo->quant_tbl_ptrs[n] == NULL) - cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo); - quant_ptr = cinfo->quant_tbl_ptrs[n]; - - for (i = 0; i < DCTSIZE2; i++) { - if (prec) - INPUT_2BYTES(cinfo, tmp, return FALSE); - else - INPUT_BYTE(cinfo, tmp, return FALSE); - /* We convert the zigzag-order table to natural array order. */ - quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16) tmp; - } - - if (cinfo->err->trace_level >= 2) { - for (i = 0; i < DCTSIZE2; i += 8) { - TRACEMS8(cinfo, 2, JTRC_QUANTVALS, - quant_ptr->quantval[i], quant_ptr->quantval[i+1], - quant_ptr->quantval[i+2], quant_ptr->quantval[i+3], - quant_ptr->quantval[i+4], quant_ptr->quantval[i+5], - quant_ptr->quantval[i+6], quant_ptr->quantval[i+7]); - } - } - - length -= DCTSIZE2+1; - if (prec) length -= DCTSIZE2; - } - - if (length != 0) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -get_dri (j_decompress_ptr cinfo) -/* Process a DRI marker */ -{ - INT32 length; - unsigned int tmp; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - - if (length != 4) - ERREXIT(cinfo, JERR_BAD_LENGTH); - - INPUT_2BYTES(cinfo, tmp, return FALSE); - - TRACEMS1(cinfo, 1, JTRC_DRI, tmp); - - cinfo->restart_interval = tmp; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -/* - * Routines for processing APPn and COM markers. - * These are either saved in memory or discarded, per application request. - * APP0 and APP14 are specially checked to see if they are - * JFIF and Adobe markers, respectively. - */ - -#define APP0_DATA_LEN 14 /* Length of interesting data in APP0 */ -#define APP14_DATA_LEN 12 /* Length of interesting data in APP14 */ -#define APPN_DATA_LEN 14 /* Must be the largest of the above!! */ - - -LOCAL(void) -examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data, - unsigned int datalen, INT32 remaining) -/* Examine first few bytes from an APP0. - * Take appropriate action if it is a JFIF marker. - * datalen is # of bytes at data[], remaining is length of rest of marker data. - */ -{ - INT32 totallen = (INT32) datalen + remaining; - - if (datalen >= APP0_DATA_LEN && - GETJOCTET(data[0]) == 0x4A && - GETJOCTET(data[1]) == 0x46 && - GETJOCTET(data[2]) == 0x49 && - GETJOCTET(data[3]) == 0x46 && - GETJOCTET(data[4]) == 0) { - /* Found JFIF APP0 marker: save info */ - cinfo->saw_JFIF_marker = TRUE; - cinfo->JFIF_major_version = GETJOCTET(data[5]); - cinfo->JFIF_minor_version = GETJOCTET(data[6]); - cinfo->density_unit = GETJOCTET(data[7]); - cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]); - cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]); - /* Check version. - * Major version must be 1, anything else signals an incompatible change. - * (We used to treat this as an error, but now it's a nonfatal warning, - * because some bozo at Hijaak couldn't read the spec.) - * Minor version should be 0..2, but process anyway if newer. - */ - if (cinfo->JFIF_major_version != 1) - WARNMS2(cinfo, JWRN_JFIF_MAJOR, - cinfo->JFIF_major_version, cinfo->JFIF_minor_version); - /* Generate trace messages */ - TRACEMS5(cinfo, 1, JTRC_JFIF, - cinfo->JFIF_major_version, cinfo->JFIF_minor_version, - cinfo->X_density, cinfo->Y_density, cinfo->density_unit); - /* Validate thumbnail dimensions and issue appropriate messages */ - if (GETJOCTET(data[12]) | GETJOCTET(data[13])) - TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, - GETJOCTET(data[12]), GETJOCTET(data[13])); - totallen -= APP0_DATA_LEN; - if (totallen != - ((INT32)GETJOCTET(data[12]) * (INT32)GETJOCTET(data[13]) * (INT32) 3)) - TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) totallen); - } else if (datalen >= 6 && - GETJOCTET(data[0]) == 0x4A && - GETJOCTET(data[1]) == 0x46 && - GETJOCTET(data[2]) == 0x58 && - GETJOCTET(data[3]) == 0x58 && - GETJOCTET(data[4]) == 0) { - /* Found JFIF "JFXX" extension APP0 marker */ - /* The library doesn't actually do anything with these, - * but we try to produce a helpful trace message. - */ - switch (GETJOCTET(data[5])) { - case 0x10: - TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int) totallen); - break; - case 0x11: - TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int) totallen); - break; - case 0x13: - TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int) totallen); - break; - default: - TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION, - GETJOCTET(data[5]), (int) totallen); - break; - } - } else { - /* Start of APP0 does not match "JFIF" or "JFXX", or too short */ - TRACEMS1(cinfo, 1, JTRC_APP0, (int) totallen); - } -} - - -LOCAL(void) -examine_app14 (j_decompress_ptr cinfo, JOCTET FAR * data, - unsigned int datalen, INT32 remaining) -/* Examine first few bytes from an APP14. - * Take appropriate action if it is an Adobe marker. - * datalen is # of bytes at data[], remaining is length of rest of marker data. - */ -{ - unsigned int version, flags0, flags1, transform; - - if (datalen >= APP14_DATA_LEN && - GETJOCTET(data[0]) == 0x41 && - GETJOCTET(data[1]) == 0x64 && - GETJOCTET(data[2]) == 0x6F && - GETJOCTET(data[3]) == 0x62 && - GETJOCTET(data[4]) == 0x65) { - /* Found Adobe APP14 marker */ - version = (GETJOCTET(data[5]) << 8) + GETJOCTET(data[6]); - flags0 = (GETJOCTET(data[7]) << 8) + GETJOCTET(data[8]); - flags1 = (GETJOCTET(data[9]) << 8) + GETJOCTET(data[10]); - transform = GETJOCTET(data[11]); - TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform); - cinfo->saw_Adobe_marker = TRUE; - cinfo->Adobe_transform = (UINT8) transform; - } else { - /* Start of APP14 does not match "Adobe", or too short */ - TRACEMS1(cinfo, 1, JTRC_APP14, (int) (datalen + remaining)); - } -} - - -METHODDEF(boolean) -get_interesting_appn (j_decompress_ptr cinfo) -/* Process an APP0 or APP14 marker without saving it */ -{ - INT32 length; - JOCTET b[APPN_DATA_LEN]; - unsigned int i, numtoread; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - /* get the interesting part of the marker data */ - if (length >= APPN_DATA_LEN) - numtoread = APPN_DATA_LEN; - else if (length > 0) - numtoread = (unsigned int) length; - else - numtoread = 0; - for (i = 0; i < numtoread; i++) - INPUT_BYTE(cinfo, b[i], return FALSE); - length -= numtoread; - - /* process it */ - switch (cinfo->unread_marker) { - case M_APP0: - examine_app0(cinfo, (JOCTET FAR *) b, numtoread, length); - break; - case M_APP14: - examine_app14(cinfo, (JOCTET FAR *) b, numtoread, length); - break; - default: - /* can't get here unless jpeg_save_markers chooses wrong processor */ - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); - break; - } - - /* skip any remaining data -- could be lots */ - INPUT_SYNC(cinfo); - if (length > 0) - (*cinfo->src->skip_input_data) (cinfo, (long) length); - - return TRUE; -} - - -#ifdef SAVE_MARKERS_SUPPORTED - -METHODDEF(boolean) -save_marker (j_decompress_ptr cinfo) -/* Save an APPn or COM marker into the marker list */ -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - jpeg_saved_marker_ptr cur_marker = marker->cur_marker; - unsigned int bytes_read, data_length; - JOCTET FAR * data; - INT32 length = 0; - INPUT_VARS(cinfo); - - if (cur_marker == NULL) { - /* begin reading a marker */ - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - if (length >= 0) { /* watch out for bogus length word */ - /* figure out how much we want to save */ - unsigned int limit; - if (cinfo->unread_marker == (int) M_COM) - limit = marker->length_limit_COM; - else - limit = marker->length_limit_APPn[cinfo->unread_marker - (int) M_APP0]; - if ((unsigned int) length < limit) - limit = (unsigned int) length; - /* allocate and initialize the marker item */ - cur_marker = (jpeg_saved_marker_ptr) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(struct jpeg_marker_struct) + limit); - cur_marker->next = NULL; - cur_marker->marker = (UINT8) cinfo->unread_marker; - cur_marker->original_length = (unsigned int) length; - cur_marker->data_length = limit; - /* data area is just beyond the jpeg_marker_struct */ - data = cur_marker->data = (JOCTET FAR *) (cur_marker + 1); - marker->cur_marker = cur_marker; - marker->bytes_read = 0; - bytes_read = 0; - data_length = limit; - } else { - /* deal with bogus length word */ - bytes_read = data_length = 0; - data = NULL; - } - } else { - /* resume reading a marker */ - bytes_read = marker->bytes_read; - data_length = cur_marker->data_length; - data = cur_marker->data + bytes_read; - } - - while (bytes_read < data_length) { - INPUT_SYNC(cinfo); /* move the restart point to here */ - marker->bytes_read = bytes_read; - /* If there's not at least one byte in buffer, suspend */ - MAKE_BYTE_AVAIL(cinfo, return FALSE); - /* Copy bytes with reasonable rapidity */ - while (bytes_read < data_length && bytes_in_buffer > 0) { - *data++ = *next_input_byte++; - bytes_in_buffer--; - bytes_read++; - } - } - - /* Done reading what we want to read */ - if (cur_marker != NULL) { /* will be NULL if bogus length word */ - /* Add new marker to end of list */ - if (cinfo->marker_list == NULL) { - cinfo->marker_list = cur_marker; - } else { - jpeg_saved_marker_ptr prev = cinfo->marker_list; - while (prev->next != NULL) - prev = prev->next; - prev->next = cur_marker; - } - /* Reset pointer & calc remaining data length */ - data = cur_marker->data; - length = cur_marker->original_length - data_length; - } - /* Reset to initial state for next marker */ - marker->cur_marker = NULL; - - /* Process the marker if interesting; else just make a generic trace msg */ - switch (cinfo->unread_marker) { - case M_APP0: - examine_app0(cinfo, data, data_length, length); - break; - case M_APP14: - examine_app14(cinfo, data, data_length, length); - break; - default: - TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, - (int) (data_length + length)); - break; - } - - /* skip any remaining data -- could be lots */ - INPUT_SYNC(cinfo); /* do before skip_input_data */ - if (length > 0) - (*cinfo->src->skip_input_data) (cinfo, (long) length); - - return TRUE; -} - -#endif /* SAVE_MARKERS_SUPPORTED */ - - -METHODDEF(boolean) -skip_variable (j_decompress_ptr cinfo) -/* Skip over an unknown or uninteresting variable-length marker */ -{ - INT32 length; - INPUT_VARS(cinfo); - - INPUT_2BYTES(cinfo, length, return FALSE); - length -= 2; - - TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length); - - INPUT_SYNC(cinfo); /* do before skip_input_data */ - if (length > 0) - (*cinfo->src->skip_input_data) (cinfo, (long) length); - - return TRUE; -} - - -/* - * Find the next JPEG marker, save it in cinfo->unread_marker. - * Returns FALSE if had to suspend before reaching a marker; - * in that case cinfo->unread_marker is unchanged. - * - * Note that the result might not be a valid marker code, - * but it will never be 0 or FF. - */ - -LOCAL(boolean) -next_marker (j_decompress_ptr cinfo) -{ - int c; - INPUT_VARS(cinfo); - - for (;;) { - INPUT_BYTE(cinfo, c, return FALSE); - /* Skip any non-FF bytes. - * This may look a bit inefficient, but it will not occur in a valid file. - * We sync after each discarded byte so that a suspending data source - * can discard the byte from its buffer. - */ - while (c != 0xFF) { - cinfo->marker->discarded_bytes++; - INPUT_SYNC(cinfo); - INPUT_BYTE(cinfo, c, return FALSE); - } - /* This loop swallows any duplicate FF bytes. Extra FFs are legal as - * pad bytes, so don't count them in discarded_bytes. We assume there - * will not be so many consecutive FF bytes as to overflow a suspending - * data source's input buffer. - */ - do { - INPUT_BYTE(cinfo, c, return FALSE); - } while (c == 0xFF); - if (c != 0) - break; /* found a valid marker, exit loop */ - /* Reach here if we found a stuffed-zero data sequence (FF/00). - * Discard it and loop back to try again. - */ - cinfo->marker->discarded_bytes += 2; - INPUT_SYNC(cinfo); - } - - if (cinfo->marker->discarded_bytes != 0) { - WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c); - cinfo->marker->discarded_bytes = 0; - } - - cinfo->unread_marker = c; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -LOCAL(boolean) -first_marker (j_decompress_ptr cinfo) -/* Like next_marker, but used to obtain the initial SOI marker. */ -/* For this marker, we do not allow preceding garbage or fill; otherwise, - * we might well scan an entire input file before realizing it ain't JPEG. - * If an application wants to process non-JFIF files, it must seek to the - * SOI before calling the JPEG library. - */ -{ - int c, c2; - INPUT_VARS(cinfo); - - INPUT_BYTE(cinfo, c, return FALSE); - INPUT_BYTE(cinfo, c2, return FALSE); - if (c != 0xFF || c2 != (int) M_SOI) - ERREXIT2(cinfo, JERR_NO_SOI, c, c2); - - cinfo->unread_marker = c2; - - INPUT_SYNC(cinfo); - return TRUE; -} - - -/* - * Read markers until SOS or EOI. - * - * Returns same codes as are defined for jpeg_consume_input: - * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. - */ - -METHODDEF(int) -read_markers (j_decompress_ptr cinfo) -{ - /* Outer loop repeats once for each marker. */ - for (;;) { - /* Collect the marker proper, unless we already did. */ - /* NB: first_marker() enforces the requirement that SOI appear first. */ - if (cinfo->unread_marker == 0) { - if (! cinfo->marker->saw_SOI) { - if (! first_marker(cinfo)) - return JPEG_SUSPENDED; - } else { - if (! next_marker(cinfo)) - return JPEG_SUSPENDED; - } - } - /* At this point cinfo->unread_marker contains the marker code and the - * input point is just past the marker proper, but before any parameters. - * A suspension will cause us to return with this state still true. - */ - switch (cinfo->unread_marker) { - case M_SOI: - if (! get_soi(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_SOF0: /* Baseline */ - case M_SOF1: /* Extended sequential, Huffman */ - if (! get_sof(cinfo, FALSE, FALSE)) - return JPEG_SUSPENDED; - break; - - case M_SOF2: /* Progressive, Huffman */ - if (! get_sof(cinfo, TRUE, FALSE)) - return JPEG_SUSPENDED; - break; - - case M_SOF9: /* Extended sequential, arithmetic */ - if (! get_sof(cinfo, FALSE, TRUE)) - return JPEG_SUSPENDED; - break; - - case M_SOF10: /* Progressive, arithmetic */ - if (! get_sof(cinfo, TRUE, TRUE)) - return JPEG_SUSPENDED; - break; - - /* Currently unsupported SOFn types */ - case M_SOF3: /* Lossless, Huffman */ - case M_SOF5: /* Differential sequential, Huffman */ - case M_SOF6: /* Differential progressive, Huffman */ - case M_SOF7: /* Differential lossless, Huffman */ - case M_JPG: /* Reserved for JPEG extensions */ - case M_SOF11: /* Lossless, arithmetic */ - case M_SOF13: /* Differential sequential, arithmetic */ - case M_SOF14: /* Differential progressive, arithmetic */ - case M_SOF15: /* Differential lossless, arithmetic */ - ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker); - break; - - case M_SOS: - if (! get_sos(cinfo)) - return JPEG_SUSPENDED; - cinfo->unread_marker = 0; /* processed the marker */ - return JPEG_REACHED_SOS; - - case M_EOI: - TRACEMS(cinfo, 1, JTRC_EOI); - cinfo->unread_marker = 0; /* processed the marker */ - return JPEG_REACHED_EOI; - - case M_DAC: - if (! get_dac(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_DHT: - if (! get_dht(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_DQT: - if (! get_dqt(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_DRI: - if (! get_dri(cinfo)) - return JPEG_SUSPENDED; - break; - - case M_APP0: - case M_APP1: - case M_APP2: - case M_APP3: - case M_APP4: - case M_APP5: - case M_APP6: - case M_APP7: - case M_APP8: - case M_APP9: - case M_APP10: - case M_APP11: - case M_APP12: - case M_APP13: - case M_APP14: - case M_APP15: - if (! (*((my_marker_ptr) cinfo->marker)->process_APPn[ - cinfo->unread_marker - (int) M_APP0]) (cinfo)) - return JPEG_SUSPENDED; - break; - - case M_COM: - if (! (*((my_marker_ptr) cinfo->marker)->process_COM) (cinfo)) - return JPEG_SUSPENDED; - break; - - case M_RST0: /* these are all parameterless */ - case M_RST1: - case M_RST2: - case M_RST3: - case M_RST4: - case M_RST5: - case M_RST6: - case M_RST7: - case M_TEM: - TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker); - break; - - case M_DNL: /* Ignore DNL ... perhaps the wrong thing */ - if (! skip_variable(cinfo)) - return JPEG_SUSPENDED; - break; - - default: /* must be DHP, EXP, JPGn, or RESn */ - /* For now, we treat the reserved markers as fatal errors since they are - * likely to be used to signal incompatible JPEG Part 3 extensions. - * Once the JPEG 3 version-number marker is well defined, this code - * ought to change! - */ - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker); - break; - } - /* Successfully processed marker, so reset state variable */ - cinfo->unread_marker = 0; - } /* end loop */ -} - - -/* - * Read a restart marker, which is expected to appear next in the datastream; - * if the marker is not there, take appropriate recovery action. - * Returns FALSE if suspension is required. - * - * This is called by the entropy decoder after it has read an appropriate - * number of MCUs. cinfo->unread_marker may be nonzero if the entropy decoder - * has already read a marker from the data source. Under normal conditions - * cinfo->unread_marker will be reset to 0 before returning; if not reset, - * it holds a marker which the decoder will be unable to read past. - */ - -METHODDEF(boolean) -read_restart_marker (j_decompress_ptr cinfo) -{ - /* Obtain a marker unless we already did. */ - /* Note that next_marker will complain if it skips any data. */ - if (cinfo->unread_marker == 0) { - if (! next_marker(cinfo)) - return FALSE; - } - - if (cinfo->unread_marker == - ((int) M_RST0 + cinfo->marker->next_restart_num)) { - /* Normal case --- swallow the marker and let entropy decoder continue */ - TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num); - cinfo->unread_marker = 0; - } else { - /* Uh-oh, the restart markers have been messed up. */ - /* Let the data source manager determine how to resync. */ - if (! (*cinfo->src->resync_to_restart) (cinfo, - cinfo->marker->next_restart_num)) - return FALSE; - } - - /* Update next-restart state */ - cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7; - - return TRUE; -} - - -/* - * This is the default resync_to_restart method for data source managers - * to use if they don't have any better approach. Some data source managers - * may be able to back up, or may have additional knowledge about the data - * which permits a more intelligent recovery strategy; such managers would - * presumably supply their own resync method. - * - * read_restart_marker calls resync_to_restart if it finds a marker other than - * the restart marker it was expecting. (This code is *not* used unless - * a nonzero restart interval has been declared.) cinfo->unread_marker is - * the marker code actually found (might be anything, except 0 or FF). - * The desired restart marker number (0..7) is passed as a parameter. - * This routine is supposed to apply whatever error recovery strategy seems - * appropriate in order to position the input stream to the next data segment. - * Note that cinfo->unread_marker is treated as a marker appearing before - * the current data-source input point; usually it should be reset to zero - * before returning. - * Returns FALSE if suspension is required. - * - * This implementation is substantially constrained by wanting to treat the - * input as a data stream; this means we can't back up. Therefore, we have - * only the following actions to work with: - * 1. Simply discard the marker and let the entropy decoder resume at next - * byte of file. - * 2. Read forward until we find another marker, discarding intervening - * data. (In theory we could look ahead within the current bufferload, - * without having to discard data if we don't find the desired marker. - * This idea is not implemented here, in part because it makes behavior - * dependent on buffer size and chance buffer-boundary positions.) - * 3. Leave the marker unread (by failing to zero cinfo->unread_marker). - * This will cause the entropy decoder to process an empty data segment, - * inserting dummy zeroes, and then we will reprocess the marker. - * - * #2 is appropriate if we think the desired marker lies ahead, while #3 is - * appropriate if the found marker is a future restart marker (indicating - * that we have missed the desired restart marker, probably because it got - * corrupted). - * We apply #2 or #3 if the found marker is a restart marker no more than - * two counts behind or ahead of the expected one. We also apply #2 if the - * found marker is not a legal JPEG marker code (it's certainly bogus data). - * If the found marker is a restart marker more than 2 counts away, we do #1 - * (too much risk that the marker is erroneous; with luck we will be able to - * resync at some future point). - * For any valid non-restart JPEG marker, we apply #3. This keeps us from - * overrunning the end of a scan. An implementation limited to single-scan - * files might find it better to apply #2 for markers other than EOI, since - * any other marker would have to be bogus data in that case. - */ - -GLOBAL(boolean) -jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired) -{ - int marker = cinfo->unread_marker; - int action = 1; - - /* Always put up a warning. */ - WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired); - - /* Outer loop handles repeated decision after scanning forward. */ - for (;;) { - if (marker < (int) M_SOF0) - action = 2; /* invalid marker */ - else if (marker < (int) M_RST0 || marker > (int) M_RST7) - action = 3; /* valid non-restart marker */ - else { - if (marker == ((int) M_RST0 + ((desired+1) & 7)) || - marker == ((int) M_RST0 + ((desired+2) & 7))) - action = 3; /* one of the next two expected restarts */ - else if (marker == ((int) M_RST0 + ((desired-1) & 7)) || - marker == ((int) M_RST0 + ((desired-2) & 7))) - action = 2; /* a prior restart, so advance */ - else - action = 1; /* desired restart or too far away */ - } - TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action); - switch (action) { - case 1: - /* Discard marker and let entropy decoder resume processing. */ - cinfo->unread_marker = 0; - return TRUE; - case 2: - /* Scan to the next marker, and repeat the decision loop. */ - if (! next_marker(cinfo)) - return FALSE; - marker = cinfo->unread_marker; - break; - case 3: - /* Return without advancing past this marker. */ - /* Entropy decoder will be forced to process an empty segment. */ - return TRUE; - } - } /* end loop */ -} - - -/* - * Reset marker processing state to begin a fresh datastream. - */ - -METHODDEF(void) -reset_marker_reader (j_decompress_ptr cinfo) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - - cinfo->comp_info = NULL; /* until allocated by get_sof */ - cinfo->input_scan_number = 0; /* no SOS seen yet */ - cinfo->unread_marker = 0; /* no pending marker */ - marker->pub.saw_SOI = FALSE; /* set internal state too */ - marker->pub.saw_SOF = FALSE; - marker->pub.discarded_bytes = 0; - marker->cur_marker = NULL; -} - - -/* - * Initialize the marker reader module. - * This is called only once, when the decompression object is created. - */ - -GLOBAL(void) -jinit_marker_reader (j_decompress_ptr cinfo) -{ - my_marker_ptr marker; - int i; - - /* Create subobject in permanent pool */ - marker = (my_marker_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - SIZEOF(my_marker_reader)); - cinfo->marker = (struct jpeg_marker_reader *) marker; - /* Initialize public method pointers */ - marker->pub.reset_marker_reader = reset_marker_reader; - marker->pub.read_markers = read_markers; - marker->pub.read_restart_marker = read_restart_marker; - /* Initialize COM/APPn processing. - * By default, we examine and then discard APP0 and APP14, - * but simply discard COM and all other APPn. - */ - marker->process_COM = skip_variable; - marker->length_limit_COM = 0; - for (i = 0; i < 16; i++) { - marker->process_APPn[i] = skip_variable; - marker->length_limit_APPn[i] = 0; - } - marker->process_APPn[0] = get_interesting_appn; - marker->process_APPn[14] = get_interesting_appn; - /* Reset marker processing state */ - reset_marker_reader(cinfo); -} - - -/* - * Control saving of COM and APPn markers into marker_list. - */ - -#ifdef SAVE_MARKERS_SUPPORTED - -GLOBAL(void) -jpeg_save_markers (j_decompress_ptr cinfo, int marker_code, - unsigned int length_limit) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - long maxlength; - jpeg_marker_parser_method processor; - - /* Length limit mustn't be larger than what we can allocate - * (should only be a concern in a 16-bit environment). - */ - maxlength = cinfo->mem->max_alloc_chunk - SIZEOF(struct jpeg_marker_struct); - if (((long) length_limit) > maxlength) - length_limit = (unsigned int) maxlength; - - /* Choose processor routine to use. - * APP0/APP14 have special requirements. - */ - if (length_limit) { - processor = save_marker; - /* If saving APP0/APP14, save at least enough for our internal use. */ - if (marker_code == (int) M_APP0 && length_limit < APP0_DATA_LEN) - length_limit = APP0_DATA_LEN; - else if (marker_code == (int) M_APP14 && length_limit < APP14_DATA_LEN) - length_limit = APP14_DATA_LEN; - } else { - processor = skip_variable; - /* If discarding APP0/APP14, use our regular on-the-fly processor. */ - if (marker_code == (int) M_APP0 || marker_code == (int) M_APP14) - processor = get_interesting_appn; - } - - if (marker_code == (int) M_COM) { - marker->process_COM = processor; - marker->length_limit_COM = length_limit; - } else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) { - marker->process_APPn[marker_code - (int) M_APP0] = processor; - marker->length_limit_APPn[marker_code - (int) M_APP0] = length_limit; - } else - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); -} - -#endif /* SAVE_MARKERS_SUPPORTED */ - - -/* - * Install a special processing method for COM or APPn markers. - */ - -GLOBAL(void) -jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code, - jpeg_marker_parser_method routine) -{ - my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - - if (marker_code == (int) M_COM) - marker->process_COM = routine; - else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) - marker->process_APPn[marker_code - (int) M_APP0] = routine; - else - ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); -} diff --git a/oversampling/WDL/jpeglib/jdmaster.c b/oversampling/WDL/jpeglib/jdmaster.c deleted file mode 100644 index 2802c5b..0000000 --- a/oversampling/WDL/jpeglib/jdmaster.c +++ /dev/null @@ -1,557 +0,0 @@ -/* - * jdmaster.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains master control logic for the JPEG decompressor. - * These routines are concerned with selecting the modules to be executed - * and with determining the number of passes and the work to be done in each - * pass. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private state */ - -typedef struct { - struct jpeg_decomp_master pub; /* public fields */ - - int pass_number; /* # of passes completed */ - - boolean using_merged_upsample; /* TRUE if using merged upsample/cconvert */ - - /* Saved references to initialized quantizer modules, - * in case we need to switch modes. - */ - struct jpeg_color_quantizer * quantizer_1pass; - struct jpeg_color_quantizer * quantizer_2pass; -} my_decomp_master; - -typedef my_decomp_master * my_master_ptr; - - -/* - * Determine whether merged upsample/color conversion should be used. - * CRUCIAL: this must match the actual capabilities of jdmerge.c! - */ - -LOCAL(boolean) -use_merged_upsample (j_decompress_ptr cinfo) -{ -#ifdef UPSAMPLE_MERGING_SUPPORTED - /* Merging is the equivalent of plain box-filter upsampling */ - if (cinfo->do_fancy_upsampling || cinfo->CCIR601_sampling) - return FALSE; - /* jdmerge.c only supports YCC=>RGB color conversion */ - if (cinfo->jpeg_color_space != JCS_YCbCr || cinfo->num_components != 3 || - cinfo->out_color_space != JCS_RGB || - cinfo->out_color_components != RGB_PIXELSIZE) - return FALSE; - /* and it only handles 2h1v or 2h2v sampling ratios */ - if (cinfo->comp_info[0].h_samp_factor != 2 || - cinfo->comp_info[1].h_samp_factor != 1 || - cinfo->comp_info[2].h_samp_factor != 1 || - cinfo->comp_info[0].v_samp_factor > 2 || - cinfo->comp_info[1].v_samp_factor != 1 || - cinfo->comp_info[2].v_samp_factor != 1) - return FALSE; - /* furthermore, it doesn't work if we've scaled the IDCTs differently */ - if (cinfo->comp_info[0].DCT_scaled_size != cinfo->min_DCT_scaled_size || - cinfo->comp_info[1].DCT_scaled_size != cinfo->min_DCT_scaled_size || - cinfo->comp_info[2].DCT_scaled_size != cinfo->min_DCT_scaled_size) - return FALSE; - /* ??? also need to test for upsample-time rescaling, when & if supported */ - return TRUE; /* by golly, it'll work... */ -#else - return FALSE; -#endif -} - - -/* - * Compute output image dimensions and related values. - * NOTE: this is exported for possible use by application. - * Hence it mustn't do anything that can't be done twice. - * Also note that it may be called before the master module is initialized! - */ - -GLOBAL(void) -jpeg_calc_output_dimensions (j_decompress_ptr cinfo) -/* Do computations that are needed before master selection phase */ -{ -#ifdef IDCT_SCALING_SUPPORTED - int ci; - jpeg_component_info *compptr; -#endif - - /* Prevent application from calling me at wrong times */ - if (cinfo->global_state != DSTATE_READY) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - -#ifdef IDCT_SCALING_SUPPORTED - - /* Compute actual output image dimensions and DCT scaling choices. */ - if (cinfo->scale_num * 8 <= cinfo->scale_denom) { - /* Provide 1/8 scaling */ - cinfo->output_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, 8L); - cinfo->output_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, 8L); - cinfo->min_DCT_scaled_size = 1; - } else if (cinfo->scale_num * 4 <= cinfo->scale_denom) { - /* Provide 1/4 scaling */ - cinfo->output_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, 4L); - cinfo->output_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, 4L); - cinfo->min_DCT_scaled_size = 2; - } else if (cinfo->scale_num * 2 <= cinfo->scale_denom) { - /* Provide 1/2 scaling */ - cinfo->output_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width, 2L); - cinfo->output_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height, 2L); - cinfo->min_DCT_scaled_size = 4; - } else { - /* Provide 1/1 scaling */ - cinfo->output_width = cinfo->image_width; - cinfo->output_height = cinfo->image_height; - cinfo->min_DCT_scaled_size = DCTSIZE; - } - /* In selecting the actual DCT scaling for each component, we try to - * scale up the chroma components via IDCT scaling rather than upsampling. - * This saves time if the upsampler gets to use 1:1 scaling. - * Note this code assumes that the supported DCT scalings are powers of 2. - */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - int ssize = cinfo->min_DCT_scaled_size; - while (ssize < DCTSIZE && - (compptr->h_samp_factor * ssize * 2 <= - cinfo->max_h_samp_factor * cinfo->min_DCT_scaled_size) && - (compptr->v_samp_factor * ssize * 2 <= - cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size)) { - ssize = ssize * 2; - } - compptr->DCT_scaled_size = ssize; - } - - /* Recompute downsampled dimensions of components; - * application needs to know these if using raw downsampled data. - */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Size in samples, after IDCT scaling */ - compptr->downsampled_width = (JDIMENSION) - jdiv_round_up((long) cinfo->image_width * - (long) (compptr->h_samp_factor * compptr->DCT_scaled_size), - (long) (cinfo->max_h_samp_factor * DCTSIZE)); - compptr->downsampled_height = (JDIMENSION) - jdiv_round_up((long) cinfo->image_height * - (long) (compptr->v_samp_factor * compptr->DCT_scaled_size), - (long) (cinfo->max_v_samp_factor * DCTSIZE)); - } - -#else /* !IDCT_SCALING_SUPPORTED */ - - /* Hardwire it to "no scaling" */ - cinfo->output_width = cinfo->image_width; - cinfo->output_height = cinfo->image_height; - /* jdinput.c has already initialized DCT_scaled_size to DCTSIZE, - * and has computed unscaled downsampled_width and downsampled_height. - */ - -#endif /* IDCT_SCALING_SUPPORTED */ - - /* Report number of components in selected colorspace. */ - /* Probably this should be in the color conversion module... */ - switch (cinfo->out_color_space) { - case JCS_GRAYSCALE: - cinfo->out_color_components = 1; - break; - case JCS_RGB: -#if RGB_PIXELSIZE != 3 - cinfo->out_color_components = RGB_PIXELSIZE; - break; -#endif /* else share code with YCbCr */ - case JCS_YCbCr: - cinfo->out_color_components = 3; - break; - case JCS_CMYK: - case JCS_YCCK: - cinfo->out_color_components = 4; - break; - default: /* else must be same colorspace as in file */ - cinfo->out_color_components = cinfo->num_components; - break; - } - cinfo->output_components = (cinfo->quantize_colors ? 1 : - cinfo->out_color_components); - - /* See if upsampler will want to emit more than one row at a time */ - if (use_merged_upsample(cinfo)) - cinfo->rec_outbuf_height = cinfo->max_v_samp_factor; - else - cinfo->rec_outbuf_height = 1; -} - - -/* - * Several decompression processes need to range-limit values to the range - * 0..MAXJSAMPLE; the input value may fall somewhat outside this range - * due to noise introduced by quantization, roundoff error, etc. These - * processes are inner loops and need to be as fast as possible. On most - * machines, particularly CPUs with pipelines or instruction prefetch, - * a (subscript-check-less) C table lookup - * x = sample_range_limit[x]; - * is faster than explicit tests - * if (x < 0) x = 0; - * else if (x > MAXJSAMPLE) x = MAXJSAMPLE; - * These processes all use a common table prepared by the routine below. - * - * For most steps we can mathematically guarantee that the initial value - * of x is within MAXJSAMPLE+1 of the legal range, so a table running from - * -(MAXJSAMPLE+1) to 2*MAXJSAMPLE+1 is sufficient. But for the initial - * limiting step (just after the IDCT), a wildly out-of-range value is - * possible if the input data is corrupt. To avoid any chance of indexing - * off the end of memory and getting a bad-pointer trap, we perform the - * post-IDCT limiting thus: - * x = range_limit[x & MASK]; - * where MASK is 2 bits wider than legal sample data, ie 10 bits for 8-bit - * samples. Under normal circumstances this is more than enough range and - * a correct output will be generated; with bogus input data the mask will - * cause wraparound, and we will safely generate a bogus-but-in-range output. - * For the post-IDCT step, we want to convert the data from signed to unsigned - * representation by adding CENTERJSAMPLE at the same time that we limit it. - * So the post-IDCT limiting table ends up looking like this: - * CENTERJSAMPLE,CENTERJSAMPLE+1,...,MAXJSAMPLE, - * MAXJSAMPLE (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), - * 0 (repeat 2*(MAXJSAMPLE+1)-CENTERJSAMPLE times), - * 0,1,...,CENTERJSAMPLE-1 - * Negative inputs select values from the upper half of the table after - * masking. - * - * We can save some space by overlapping the start of the post-IDCT table - * with the simpler range limiting table. The post-IDCT table begins at - * sample_range_limit + CENTERJSAMPLE. - * - * Note that the table is allocated in near data space on PCs; it's small - * enough and used often enough to justify this. - */ - -LOCAL(void) -prepare_range_limit_table (j_decompress_ptr cinfo) -/* Allocate and fill in the sample_range_limit table */ -{ - JSAMPLE * table; - int i; - - table = (JSAMPLE *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (5 * (MAXJSAMPLE+1) + CENTERJSAMPLE) * SIZEOF(JSAMPLE)); - table += (MAXJSAMPLE+1); /* allow negative subscripts of simple table */ - cinfo->sample_range_limit = table; - /* First segment of "simple" table: limit[x] = 0 for x < 0 */ - MEMZERO(table - (MAXJSAMPLE+1), (MAXJSAMPLE+1) * SIZEOF(JSAMPLE)); - /* Main part of "simple" table: limit[x] = x */ - for (i = 0; i <= MAXJSAMPLE; i++) - table[i] = (JSAMPLE) i; - table += CENTERJSAMPLE; /* Point to where post-IDCT table starts */ - /* End of simple table, rest of first half of post-IDCT table */ - for (i = CENTERJSAMPLE; i < 2*(MAXJSAMPLE+1); i++) - table[i] = MAXJSAMPLE; - /* Second half of post-IDCT table */ - MEMZERO(table + (2 * (MAXJSAMPLE+1)), - (2 * (MAXJSAMPLE+1) - CENTERJSAMPLE) * SIZEOF(JSAMPLE)); - MEMCOPY(table + (4 * (MAXJSAMPLE+1) - CENTERJSAMPLE), - cinfo->sample_range_limit, CENTERJSAMPLE * SIZEOF(JSAMPLE)); -} - - -/* - * Master selection of decompression modules. - * This is done once at jpeg_start_decompress time. We determine - * which modules will be used and give them appropriate initialization calls. - * We also initialize the decompressor input side to begin consuming data. - * - * Since jpeg_read_header has finished, we know what is in the SOF - * and (first) SOS markers. We also have all the application parameter - * settings. - */ - -LOCAL(void) -master_selection (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - boolean use_c_buffer; - long samplesperrow; - JDIMENSION jd_samplesperrow; - - /* Initialize dimensions and other stuff */ - jpeg_calc_output_dimensions(cinfo); - prepare_range_limit_table(cinfo); - - /* Width of an output scanline must be representable as JDIMENSION. */ - samplesperrow = (long) cinfo->output_width * (long) cinfo->out_color_components; - jd_samplesperrow = (JDIMENSION) samplesperrow; - if ((long) jd_samplesperrow != samplesperrow) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - - /* Initialize my private state */ - master->pass_number = 0; - master->using_merged_upsample = use_merged_upsample(cinfo); - - /* Color quantizer selection */ - master->quantizer_1pass = NULL; - master->quantizer_2pass = NULL; - /* No mode changes if not using buffered-image mode. */ - if (! cinfo->quantize_colors || ! cinfo->buffered_image) { - cinfo->enable_1pass_quant = FALSE; - cinfo->enable_external_quant = FALSE; - cinfo->enable_2pass_quant = FALSE; - } - if (cinfo->quantize_colors) { - if (cinfo->raw_data_out) - ERREXIT(cinfo, JERR_NOTIMPL); - /* 2-pass quantizer only works in 3-component color space. */ - if (cinfo->out_color_components != 3) { - cinfo->enable_1pass_quant = TRUE; - cinfo->enable_external_quant = FALSE; - cinfo->enable_2pass_quant = FALSE; - cinfo->colormap = NULL; - } else if (cinfo->colormap != NULL) { - cinfo->enable_external_quant = TRUE; - } else if (cinfo->two_pass_quantize) { - cinfo->enable_2pass_quant = TRUE; - } else { - cinfo->enable_1pass_quant = TRUE; - } - - if (cinfo->enable_1pass_quant) { -#ifdef QUANT_1PASS_SUPPORTED - jinit_1pass_quantizer(cinfo); - master->quantizer_1pass = cinfo->cquantize; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } - - /* We use the 2-pass code to map to external colormaps. */ - if (cinfo->enable_2pass_quant || cinfo->enable_external_quant) { -#ifdef QUANT_2PASS_SUPPORTED - jinit_2pass_quantizer(cinfo); - master->quantizer_2pass = cinfo->cquantize; -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } - /* If both quantizers are initialized, the 2-pass one is left active; - * this is necessary for starting with quantization to an external map. - */ - } - - /* Post-processing: in particular, color conversion first */ - if (! cinfo->raw_data_out) { - if (master->using_merged_upsample) { -#ifdef UPSAMPLE_MERGING_SUPPORTED - jinit_merged_upsampler(cinfo); /* does color conversion too */ -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else { - jinit_color_deconverter(cinfo); - jinit_upsampler(cinfo); - } - jinit_d_post_controller(cinfo, cinfo->enable_2pass_quant); - } - /* Inverse DCT */ - jinit_inverse_dct(cinfo); - /* Entropy decoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef D_PROGRESSIVE_SUPPORTED - jinit_phuff_decoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_decoder(cinfo); - } - - /* Initialize principal buffer controllers. */ - use_c_buffer = cinfo->inputctl->has_multiple_scans || cinfo->buffered_image; - jinit_d_coef_controller(cinfo, use_c_buffer); - - if (! cinfo->raw_data_out) - jinit_d_main_controller(cinfo, FALSE /* never need full buffer here */); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Initialize input side of decompressor to consume first scan. */ - (*cinfo->inputctl->start_input_pass) (cinfo); - -#ifdef D_MULTISCAN_FILES_SUPPORTED - /* If jpeg_start_decompress will read the whole file, initialize - * progress monitoring appropriately. The input step is counted - * as one pass. - */ - if (cinfo->progress != NULL && ! cinfo->buffered_image && - cinfo->inputctl->has_multiple_scans) { - int nscans; - /* Estimate number of scans to set pass_limit. */ - if (cinfo->progressive_mode) { - /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ - nscans = 2 + 3 * cinfo->num_components; - } else { - /* For a nonprogressive multiscan file, estimate 1 scan per component. */ - nscans = cinfo->num_components; - } - cinfo->progress->pass_counter = 0L; - cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; - cinfo->progress->completed_passes = 0; - cinfo->progress->total_passes = (cinfo->enable_2pass_quant ? 3 : 2); - /* Count the input pass as done */ - master->pass_number++; - } -#endif /* D_MULTISCAN_FILES_SUPPORTED */ -} - - -/* - * Per-pass setup. - * This is called at the beginning of each output pass. We determine which - * modules will be active during this pass and give them appropriate - * start_pass calls. We also set is_dummy_pass to indicate whether this - * is a "real" output pass or a dummy pass for color quantization. - * (In the latter case, jdapistd.c will crank the pass to completion.) - */ - -METHODDEF(void) -prepare_for_output_pass (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - if (master->pub.is_dummy_pass) { -#ifdef QUANT_2PASS_SUPPORTED - /* Final pass of 2-pass quantization */ - master->pub.is_dummy_pass = FALSE; - (*cinfo->cquantize->start_pass) (cinfo, FALSE); - (*cinfo->post->start_pass) (cinfo, JBUF_CRANK_DEST); - (*cinfo->main->start_pass) (cinfo, JBUF_CRANK_DEST); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif /* QUANT_2PASS_SUPPORTED */ - } else { - if (cinfo->quantize_colors && cinfo->colormap == NULL) { - /* Select new quantization method */ - if (cinfo->two_pass_quantize && cinfo->enable_2pass_quant) { - cinfo->cquantize = master->quantizer_2pass; - master->pub.is_dummy_pass = TRUE; - } else if (cinfo->enable_1pass_quant) { - cinfo->cquantize = master->quantizer_1pass; - } else { - ERREXIT(cinfo, JERR_MODE_CHANGE); - } - } - (*cinfo->idct->start_pass) (cinfo); - (*cinfo->coef->start_output_pass) (cinfo); - if (! cinfo->raw_data_out) { - if (! master->using_merged_upsample) - (*cinfo->cconvert->start_pass) (cinfo); - (*cinfo->upsample->start_pass) (cinfo); - if (cinfo->quantize_colors) - (*cinfo->cquantize->start_pass) (cinfo, master->pub.is_dummy_pass); - (*cinfo->post->start_pass) (cinfo, - (master->pub.is_dummy_pass ? JBUF_SAVE_AND_PASS : JBUF_PASS_THRU)); - (*cinfo->main->start_pass) (cinfo, JBUF_PASS_THRU); - } - } - - /* Set up progress monitor's pass info if present */ - if (cinfo->progress != NULL) { - cinfo->progress->completed_passes = master->pass_number; - cinfo->progress->total_passes = master->pass_number + - (master->pub.is_dummy_pass ? 2 : 1); - /* In buffered-image mode, we assume one more output pass if EOI not - * yet reached, but no more passes if EOI has been reached. - */ - if (cinfo->buffered_image && ! cinfo->inputctl->eoi_reached) { - cinfo->progress->total_passes += (cinfo->enable_2pass_quant ? 2 : 1); - } - } -} - - -/* - * Finish up at end of an output pass. - */ - -METHODDEF(void) -finish_output_pass (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - if (cinfo->quantize_colors) - (*cinfo->cquantize->finish_pass) (cinfo); - master->pass_number++; -} - - -#ifdef D_MULTISCAN_FILES_SUPPORTED - -/* - * Switch to a new external colormap between output passes. - */ - -GLOBAL(void) -jpeg_new_colormap (j_decompress_ptr cinfo) -{ - my_master_ptr master = (my_master_ptr) cinfo->master; - - /* Prevent application from calling me at wrong times */ - if (cinfo->global_state != DSTATE_BUFIMAGE) - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - - if (cinfo->quantize_colors && cinfo->enable_external_quant && - cinfo->colormap != NULL) { - /* Select 2-pass quantizer for external colormap use */ - cinfo->cquantize = master->quantizer_2pass; - /* Notify quantizer of colormap change */ - (*cinfo->cquantize->new_color_map) (cinfo); - master->pub.is_dummy_pass = FALSE; /* just in case */ - } else - ERREXIT(cinfo, JERR_MODE_CHANGE); -} - -#endif /* D_MULTISCAN_FILES_SUPPORTED */ - - -/* - * Initialize master decompression control and select active modules. - * This is performed at the start of jpeg_start_decompress. - */ - -GLOBAL(void) -jinit_master_decompress (j_decompress_ptr cinfo) -{ - my_master_ptr master; - - master = (my_master_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_decomp_master)); - cinfo->master = (struct jpeg_decomp_master *) master; - master->pub.prepare_for_output_pass = prepare_for_output_pass; - master->pub.finish_output_pass = finish_output_pass; - - master->pub.is_dummy_pass = FALSE; - - master_selection(cinfo); -} diff --git a/oversampling/WDL/jpeglib/jdmerge.c b/oversampling/WDL/jpeglib/jdmerge.c deleted file mode 100644 index 3744446..0000000 --- a/oversampling/WDL/jpeglib/jdmerge.c +++ /dev/null @@ -1,400 +0,0 @@ -/* - * jdmerge.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains code for merged upsampling/color conversion. - * - * This file combines functions from jdsample.c and jdcolor.c; - * read those files first to understand what's going on. - * - * When the chroma components are to be upsampled by simple replication - * (ie, box filtering), we can save some work in color conversion by - * calculating all the output pixels corresponding to a pair of chroma - * samples at one time. In the conversion equations - * R = Y + K1 * Cr - * G = Y + K2 * Cb + K3 * Cr - * B = Y + K4 * Cb - * only the Y term varies among the group of pixels corresponding to a pair - * of chroma samples, so the rest of the terms can be calculated just once. - * At typical sampling ratios, this eliminates half or three-quarters of the - * multiplications needed for color conversion. - * - * This file currently provides implementations for the following cases: - * YCbCr => RGB color conversion only. - * Sampling ratios of 2h1v or 2h2v. - * No scaling needed at upsample time. - * Corner-aligned (non-CCIR601) sampling alignment. - * Other special cases could be added, but in most applications these are - * the only common cases. (For uncommon cases we fall back on the more - * general code in jdsample.c and jdcolor.c.) - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -#ifdef UPSAMPLE_MERGING_SUPPORTED - - -/* Private subobject */ - -typedef struct { - struct jpeg_upsampler pub; /* public fields */ - - /* Pointer to routine to do actual upsampling/conversion of one row group */ - JMETHOD(void, upmethod, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, - JSAMPARRAY output_buf)); - - /* Private state for YCC->RGB conversion */ - int * Cr_r_tab; /* => table for Cr to R conversion */ - int * Cb_b_tab; /* => table for Cb to B conversion */ - INT32 * Cr_g_tab; /* => table for Cr to G conversion */ - INT32 * Cb_g_tab; /* => table for Cb to G conversion */ - - /* For 2:1 vertical sampling, we produce two output rows at a time. - * We need a "spare" row buffer to hold the second output row if the - * application provides just a one-row buffer; we also use the spare - * to discard the dummy last row if the image height is odd. - */ - JSAMPROW spare_row; - boolean spare_full; /* T if spare buffer is occupied */ - - JDIMENSION out_row_width; /* samples per output row */ - JDIMENSION rows_to_go; /* counts rows remaining in image */ -} my_upsampler; - -typedef my_upsampler * my_upsample_ptr; - -#define SCALEBITS 16 /* speediest right-shift on some machines */ -#define ONE_HALF ((INT32) 1 << (SCALEBITS-1)) -#define FIX(x) ((INT32) ((x) * (1L<RGB colorspace conversion. - * This is taken directly from jdcolor.c; see that file for more info. - */ - -LOCAL(void) -build_ycc_rgb_table (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - int i; - INT32 x; - SHIFT_TEMPS - - upsample->Cr_r_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - upsample->Cb_b_tab = (int *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(int)); - upsample->Cr_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - upsample->Cb_g_tab = (INT32 *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (MAXJSAMPLE+1) * SIZEOF(INT32)); - - for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { - /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ - /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ - /* Cr=>R value is nearest int to 1.40200 * x */ - upsample->Cr_r_tab[i] = (int) - RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); - /* Cb=>B value is nearest int to 1.77200 * x */ - upsample->Cb_b_tab[i] = (int) - RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); - /* Cr=>G value is scaled-up -0.71414 * x */ - upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x; - /* Cb=>G value is scaled-up -0.34414 * x */ - /* We also add in ONE_HALF so that need not do it in inner loop */ - upsample->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; - } -} - - -/* - * Initialize for an upsampling pass. - */ - -METHODDEF(void) -start_pass_merged_upsample (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - - /* Mark the spare buffer empty */ - upsample->spare_full = FALSE; - /* Initialize total-height counter for detecting bottom of image */ - upsample->rows_to_go = cinfo->output_height; -} - - -/* - * Control routine to do upsampling (and color conversion). - * - * The control routine just handles the row buffering considerations. - */ - -METHODDEF(void) -merged_2v_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -/* 2:1 vertical sampling case: may need a spare row. */ -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - JSAMPROW work_ptrs[2]; - JDIMENSION num_rows; /* number of rows returned to caller */ - - if (upsample->spare_full) { - /* If we have a spare row saved from a previous cycle, just return it. */ - jcopy_sample_rows(& upsample->spare_row, 0, output_buf + *out_row_ctr, 0, - 1, upsample->out_row_width); - num_rows = 1; - upsample->spare_full = FALSE; - } else { - /* Figure number of rows to return to caller. */ - num_rows = 2; - /* Not more than the distance to the end of the image. */ - if (num_rows > upsample->rows_to_go) - num_rows = upsample->rows_to_go; - /* And not more than what the client can accept: */ - out_rows_avail -= *out_row_ctr; - if (num_rows > out_rows_avail) - num_rows = out_rows_avail; - /* Create output pointer array for upsampler. */ - work_ptrs[0] = output_buf[*out_row_ctr]; - if (num_rows > 1) { - work_ptrs[1] = output_buf[*out_row_ctr + 1]; - } else { - work_ptrs[1] = upsample->spare_row; - upsample->spare_full = TRUE; - } - /* Now do the upsampling. */ - (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, work_ptrs); - } - - /* Adjust counts */ - *out_row_ctr += num_rows; - upsample->rows_to_go -= num_rows; - /* When the buffer is emptied, declare this input row group consumed */ - if (! upsample->spare_full) - (*in_row_group_ctr)++; -} - - -METHODDEF(void) -merged_1v_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -/* 1:1 vertical sampling case: much easier, never need a spare row. */ -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - - /* Just do the upsampling. */ - (*upsample->upmethod) (cinfo, input_buf, *in_row_group_ctr, - output_buf + *out_row_ctr); - /* Adjust counts */ - (*out_row_ctr)++; - (*in_row_group_ctr)++; -} - - -/* - * These are the routines invoked by the control routines to do - * the actual upsampling/conversion. One row group is processed per call. - * - * Note: since we may be writing directly into application-supplied buffers, - * we have to be honest about the output width; we can't assume the buffer - * has been rounded up to an even width. - */ - - -/* - * Upsample and color convert for the case of 2:1 horizontal and 1:1 vertical. - */ - -METHODDEF(void) -h2v1_merged_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, - JSAMPARRAY output_buf) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - register int y, cred, cgreen, cblue; - int cb, cr; - register JSAMPROW outptr; - JSAMPROW inptr0, inptr1, inptr2; - JDIMENSION col; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - int * Crrtab = upsample->Cr_r_tab; - int * Cbbtab = upsample->Cb_b_tab; - INT32 * Crgtab = upsample->Cr_g_tab; - INT32 * Cbgtab = upsample->Cb_g_tab; - SHIFT_TEMPS - - inptr0 = input_buf[0][in_row_group_ctr]; - inptr1 = input_buf[1][in_row_group_ctr]; - inptr2 = input_buf[2][in_row_group_ctr]; - outptr = output_buf[0]; - /* Loop for each pair of output pixels */ - for (col = cinfo->output_width >> 1; col > 0; col--) { - /* Do the chroma part of the calculation */ - cb = GETJSAMPLE(*inptr1++); - cr = GETJSAMPLE(*inptr2++); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - /* Fetch 2 Y values and emit 2 pixels */ - y = GETJSAMPLE(*inptr0++); - outptr[RGB_RED] = range_limit[y + cred]; - outptr[RGB_GREEN] = range_limit[y + cgreen]; - outptr[RGB_BLUE] = range_limit[y + cblue]; - outptr += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr0++); - outptr[RGB_RED] = range_limit[y + cred]; - outptr[RGB_GREEN] = range_limit[y + cgreen]; - outptr[RGB_BLUE] = range_limit[y + cblue]; - outptr += RGB_PIXELSIZE; - } - /* If image width is odd, do the last output column separately */ - if (cinfo->output_width & 1) { - cb = GETJSAMPLE(*inptr1); - cr = GETJSAMPLE(*inptr2); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - y = GETJSAMPLE(*inptr0); - outptr[RGB_RED] = range_limit[y + cred]; - outptr[RGB_GREEN] = range_limit[y + cgreen]; - outptr[RGB_BLUE] = range_limit[y + cblue]; - } -} - - -/* - * Upsample and color convert for the case of 2:1 horizontal and 2:1 vertical. - */ - -METHODDEF(void) -h2v2_merged_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_group_ctr, - JSAMPARRAY output_buf) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - register int y, cred, cgreen, cblue; - int cb, cr; - register JSAMPROW outptr0, outptr1; - JSAMPROW inptr00, inptr01, inptr1, inptr2; - JDIMENSION col; - /* copy these pointers into registers if possible */ - register JSAMPLE * range_limit = cinfo->sample_range_limit; - int * Crrtab = upsample->Cr_r_tab; - int * Cbbtab = upsample->Cb_b_tab; - INT32 * Crgtab = upsample->Cr_g_tab; - INT32 * Cbgtab = upsample->Cb_g_tab; - SHIFT_TEMPS - - inptr00 = input_buf[0][in_row_group_ctr*2]; - inptr01 = input_buf[0][in_row_group_ctr*2 + 1]; - inptr1 = input_buf[1][in_row_group_ctr]; - inptr2 = input_buf[2][in_row_group_ctr]; - outptr0 = output_buf[0]; - outptr1 = output_buf[1]; - /* Loop for each group of output pixels */ - for (col = cinfo->output_width >> 1; col > 0; col--) { - /* Do the chroma part of the calculation */ - cb = GETJSAMPLE(*inptr1++); - cr = GETJSAMPLE(*inptr2++); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - /* Fetch 4 Y values and emit 4 pixels */ - y = GETJSAMPLE(*inptr00++); - outptr0[RGB_RED] = range_limit[y + cred]; - outptr0[RGB_GREEN] = range_limit[y + cgreen]; - outptr0[RGB_BLUE] = range_limit[y + cblue]; - outptr0 += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr00++); - outptr0[RGB_RED] = range_limit[y + cred]; - outptr0[RGB_GREEN] = range_limit[y + cgreen]; - outptr0[RGB_BLUE] = range_limit[y + cblue]; - outptr0 += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr01++); - outptr1[RGB_RED] = range_limit[y + cred]; - outptr1[RGB_GREEN] = range_limit[y + cgreen]; - outptr1[RGB_BLUE] = range_limit[y + cblue]; - outptr1 += RGB_PIXELSIZE; - y = GETJSAMPLE(*inptr01++); - outptr1[RGB_RED] = range_limit[y + cred]; - outptr1[RGB_GREEN] = range_limit[y + cgreen]; - outptr1[RGB_BLUE] = range_limit[y + cblue]; - outptr1 += RGB_PIXELSIZE; - } - /* If image width is odd, do the last output column separately */ - if (cinfo->output_width & 1) { - cb = GETJSAMPLE(*inptr1); - cr = GETJSAMPLE(*inptr2); - cred = Crrtab[cr]; - cgreen = (int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr], SCALEBITS); - cblue = Cbbtab[cb]; - y = GETJSAMPLE(*inptr00); - outptr0[RGB_RED] = range_limit[y + cred]; - outptr0[RGB_GREEN] = range_limit[y + cgreen]; - outptr0[RGB_BLUE] = range_limit[y + cblue]; - y = GETJSAMPLE(*inptr01); - outptr1[RGB_RED] = range_limit[y + cred]; - outptr1[RGB_GREEN] = range_limit[y + cgreen]; - outptr1[RGB_BLUE] = range_limit[y + cblue]; - } -} - - -/* - * Module initialization routine for merged upsampling/color conversion. - * - * NB: this is called under the conditions determined by use_merged_upsample() - * in jdmaster.c. That routine MUST correspond to the actual capabilities - * of this module; no safety checks are made here. - */ - -GLOBAL(void) -jinit_merged_upsampler (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample; - - upsample = (my_upsample_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_upsampler)); - cinfo->upsample = (struct jpeg_upsampler *) upsample; - upsample->pub.start_pass = start_pass_merged_upsample; - upsample->pub.need_context_rows = FALSE; - - upsample->out_row_width = cinfo->output_width * cinfo->out_color_components; - - if (cinfo->max_v_samp_factor == 2) { - upsample->pub.upsample = merged_2v_upsample; - upsample->upmethod = h2v2_merged_upsample; - /* Allocate a spare row buffer */ - upsample->spare_row = (JSAMPROW) - (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE, - (size_t) (upsample->out_row_width * SIZEOF(JSAMPLE))); - } else { - upsample->pub.upsample = merged_1v_upsample; - upsample->upmethod = h2v1_merged_upsample; - /* No spare row needed */ - upsample->spare_row = NULL; - } - - build_ycc_rgb_table(cinfo); -} - -#endif /* UPSAMPLE_MERGING_SUPPORTED */ diff --git a/oversampling/WDL/jpeglib/jdphuff.c b/oversampling/WDL/jpeglib/jdphuff.c deleted file mode 100644 index 2267809..0000000 --- a/oversampling/WDL/jpeglib/jdphuff.c +++ /dev/null @@ -1,668 +0,0 @@ -/* - * jdphuff.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains Huffman entropy decoding routines for progressive JPEG. - * - * Much of the complexity here has to do with supporting input suspension. - * If the data source module demands suspension, we want to be able to back - * up to the start of the current MCU. To do this, we copy state variables - * into local working storage, and update them back to the permanent - * storage only upon successful completion of an MCU. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdhuff.h" /* Declarations shared with jdhuff.c */ - - -#ifdef D_PROGRESSIVE_SUPPORTED - -/* - * Expanded entropy decoder object for progressive Huffman decoding. - * - * The savable_state subrecord contains fields that change within an MCU, - * but must not be updated permanently until we complete the MCU. - */ - -typedef struct { - unsigned int EOBRUN; /* remaining EOBs in EOBRUN */ - int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */ -} savable_state; - -/* This macro is to work around compilers with missing or broken - * structure assignment. You'll need to fix this code if you have - * such a compiler and you change MAX_COMPS_IN_SCAN. - */ - -#ifndef NO_STRUCT_ASSIGN -#define ASSIGN_STATE(dest,src) ((dest) = (src)) -#else -#if MAX_COMPS_IN_SCAN == 4 -#define ASSIGN_STATE(dest,src) \ - ((dest).EOBRUN = (src).EOBRUN, \ - (dest).last_dc_val[0] = (src).last_dc_val[0], \ - (dest).last_dc_val[1] = (src).last_dc_val[1], \ - (dest).last_dc_val[2] = (src).last_dc_val[2], \ - (dest).last_dc_val[3] = (src).last_dc_val[3]) -#endif -#endif - - -typedef struct { - struct jpeg_entropy_decoder pub; /* public fields */ - - /* These fields are loaded into local variables at start of each MCU. - * In case of suspension, we exit WITHOUT updating them. - */ - bitread_perm_state bitstate; /* Bit buffer at start of MCU */ - savable_state saved; /* Other state at start of MCU */ - - /* These fields are NOT loaded into local working state. */ - unsigned int restarts_to_go; /* MCUs left in this restart interval */ - - /* Pointers to derived tables (these workspaces have image lifespan) */ - d_derived_tbl * derived_tbls[NUM_HUFF_TBLS]; - - d_derived_tbl * ac_derived_tbl; /* active table during an AC scan */ -} phuff_entropy_decoder; - -typedef phuff_entropy_decoder * phuff_entropy_ptr; - -/* Forward declarations */ -METHODDEF(boolean) decode_mcu_DC_first JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) decode_mcu_AC_first JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) decode_mcu_DC_refine JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); -METHODDEF(boolean) decode_mcu_AC_refine JPP((j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); - - -/* - * Initialize for a Huffman-compressed scan. - */ - -METHODDEF(void) -start_pass_phuff_decoder (j_decompress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - boolean is_DC_band, bad; - int ci, coefi, tbl; - int *coef_bit_ptr; - jpeg_component_info * compptr; - - is_DC_band = (cinfo->Ss == 0); - - /* Validate scan parameters */ - bad = FALSE; - if (is_DC_band) { - if (cinfo->Se != 0) - bad = TRUE; - } else { - /* need not check Ss/Se < 0 since they came from unsigned bytes */ - if (cinfo->Ss > cinfo->Se || cinfo->Se >= DCTSIZE2) - bad = TRUE; - /* AC scans may have only one component */ - if (cinfo->comps_in_scan != 1) - bad = TRUE; - } - if (cinfo->Ah != 0) { - /* Successive approximation refinement scan: must have Al = Ah-1. */ - if (cinfo->Al != cinfo->Ah-1) - bad = TRUE; - } - if (cinfo->Al > 13) /* need not check for < 0 */ - bad = TRUE; - /* Arguably the maximum Al value should be less than 13 for 8-bit precision, - * but the spec doesn't say so, and we try to be liberal about what we - * accept. Note: large Al values could result in out-of-range DC - * coefficients during early scans, leading to bizarre displays due to - * overflows in the IDCT math. But we won't crash. - */ - if (bad) - ERREXIT4(cinfo, JERR_BAD_PROGRESSION, - cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al); - /* Update progression status, and verify that scan order is legal. - * Note that inter-scan inconsistencies are treated as warnings - * not fatal errors ... not clear if this is right way to behave. - */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - int cindex = cinfo->cur_comp_info[ci]->component_index; - coef_bit_ptr = & cinfo->coef_bits[cindex][0]; - if (!is_DC_band && coef_bit_ptr[0] < 0) /* AC without prior DC scan */ - WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0); - for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) { - int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi]; - if (cinfo->Ah != expected) - WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi); - coef_bit_ptr[coefi] = cinfo->Al; - } - } - - /* Select MCU decoding routine */ - if (cinfo->Ah == 0) { - if (is_DC_band) - entropy->pub.decode_mcu = decode_mcu_DC_first; - else - entropy->pub.decode_mcu = decode_mcu_AC_first; - } else { - if (is_DC_band) - entropy->pub.decode_mcu = decode_mcu_DC_refine; - else - entropy->pub.decode_mcu = decode_mcu_AC_refine; - } - - for (ci = 0; ci < cinfo->comps_in_scan; ci++) { - compptr = cinfo->cur_comp_info[ci]; - /* Make sure requested tables are present, and compute derived tables. - * We may build same derived table more than once, but it's not expensive. - */ - if (is_DC_band) { - if (cinfo->Ah == 0) { /* DC refinement needs no table */ - tbl = compptr->dc_tbl_no; - jpeg_make_d_derived_tbl(cinfo, TRUE, tbl, - & entropy->derived_tbls[tbl]); - } - } else { - tbl = compptr->ac_tbl_no; - jpeg_make_d_derived_tbl(cinfo, FALSE, tbl, - & entropy->derived_tbls[tbl]); - /* remember the single active table */ - entropy->ac_derived_tbl = entropy->derived_tbls[tbl]; - } - /* Initialize DC predictions to 0 */ - entropy->saved.last_dc_val[ci] = 0; - } - - /* Initialize bitread state variables */ - entropy->bitstate.bits_left = 0; - entropy->bitstate.get_buffer = 0; /* unnecessary, but keeps Purify quiet */ - entropy->pub.insufficient_data = FALSE; - - /* Initialize private state variables */ - entropy->saved.EOBRUN = 0; - - /* Initialize restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; -} - - -/* - * Figure F.12: extend sign bit. - * On some machines, a shift and add will be faster than a table lookup. - */ - -#ifdef AVOID_TABLES - -#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) - -#else - -#define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) - -static const int extend_test[16] = /* entry n is 2**(n-1) */ - { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080, - 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 }; - -static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ - { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1, - ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1, - ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1, - ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 }; - -#endif /* AVOID_TABLES */ - - -/* - * Check for a restart marker & resynchronize decoder. - * Returns FALSE if must suspend. - */ - -LOCAL(boolean) -process_restart (j_decompress_ptr cinfo) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int ci; - - /* Throw away any unused bits remaining in bit buffer; */ - /* include any full bytes in next_marker's count of discarded bytes */ - cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8; - entropy->bitstate.bits_left = 0; - - /* Advance past the RSTn marker */ - if (! (*cinfo->marker->read_restart_marker) (cinfo)) - return FALSE; - - /* Re-initialize DC predictions to 0 */ - for (ci = 0; ci < cinfo->comps_in_scan; ci++) - entropy->saved.last_dc_val[ci] = 0; - /* Re-init EOB run count, too */ - entropy->saved.EOBRUN = 0; - - /* Reset restart counter */ - entropy->restarts_to_go = cinfo->restart_interval; - - /* Reset out-of-data flag, unless read_restart_marker left us smack up - * against a marker. In that case we will end up treating the next data - * segment as empty, and we can avoid producing bogus output pixels by - * leaving the flag set. - */ - if (cinfo->unread_marker == 0) - entropy->pub.insufficient_data = FALSE; - - return TRUE; -} - - -/* - * Huffman MCU decoding. - * Each of these routines decodes and returns one MCU's worth of - * Huffman-compressed coefficients. - * The coefficients are reordered from zigzag order into natural array order, - * but are not dequantized. - * - * The i'th block of the MCU is stored into the block pointed to by - * MCU_data[i]. WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER. - * - * We return FALSE if data source requested suspension. In that case no - * changes have been made to permanent state. (Exception: some output - * coefficients may already have been assigned. This is harmless for - * spectral selection, since we'll just re-assign them on the next call. - * Successive approximation AC refinement has to be more careful, however.) - */ - -/* - * MCU decoding for DC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int Al = cinfo->Al; - register int s, r; - int blkn, ci; - JBLOCKROW block; - BITREAD_STATE_VARS; - savable_state state; - d_derived_tbl * tbl; - jpeg_component_info * compptr; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, just leave the MCU set to zeroes. - * This way, we return uniform gray for the remainder of the segment. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(state, entropy->saved); - - /* Outer loop handles each block in the MCU */ - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - ci = cinfo->MCU_membership[blkn]; - compptr = cinfo->cur_comp_info[ci]; - tbl = entropy->derived_tbls[compptr->dc_tbl_no]; - - /* Decode a single block's worth of coefficients */ - - /* Section F.2.2.1: decode the DC coefficient difference */ - HUFF_DECODE(s, br_state, tbl, return FALSE, label1); - if (s) { - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - } - - /* Convert DC difference to actual value, update last_dc_val */ - s += state.last_dc_val[ci]; - state.last_dc_val[ci] = s; - /* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */ - (*block)[0] = (JCOEF) (s << Al); - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - ASSIGN_STATE(entropy->saved, state); - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * MCU decoding for AC initial scan (either spectral selection, - * or first pass of successive approximation). - */ - -METHODDEF(boolean) -decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int Se = cinfo->Se; - int Al = cinfo->Al; - register int s, k, r; - unsigned int EOBRUN; - JBLOCKROW block; - BITREAD_STATE_VARS; - d_derived_tbl * tbl; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, just leave the MCU set to zeroes. - * This way, we return uniform gray for the remainder of the segment. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state. - * We can avoid loading/saving bitread state if in an EOB run. - */ - EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ - - /* There is always only one block per MCU */ - - if (EOBRUN > 0) /* if it's a band of zeroes... */ - EOBRUN--; /* ...process it now (we do nothing) */ - else { - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - block = MCU_data[0]; - tbl = entropy->ac_derived_tbl; - - for (k = cinfo->Ss; k <= Se; k++) { - HUFF_DECODE(s, br_state, tbl, return FALSE, label2); - r = s >> 4; - s &= 15; - if (s) { - k += r; - CHECK_BIT_BUFFER(br_state, s, return FALSE); - r = GET_BITS(s); - s = HUFF_EXTEND(r, s); - /* Scale and output coefficient in natural (dezigzagged) order */ - (*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al); - } else { - if (r == 15) { /* ZRL */ - k += 15; /* skip 15 zeroes in band */ - } else { /* EOBr, run length is 2^r + appended bits */ - EOBRUN = 1 << r; - if (r) { /* EOBr, r > 0 */ - CHECK_BIT_BUFFER(br_state, r, return FALSE); - r = GET_BITS(r); - EOBRUN += r; - } - EOBRUN--; /* this band is processed at this moment */ - break; /* force end-of-band */ - } - } - } - - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - } - - /* Completed MCU, so update state */ - entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * MCU decoding for DC successive approximation refinement scan. - * Note: we assume such scans can be multi-component, although the spec - * is not very clear on the point. - */ - -METHODDEF(boolean) -decode_mcu_DC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ - int blkn; - JBLOCKROW block; - BITREAD_STATE_VARS; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* Not worth the cycles to check insufficient_data here, - * since we will not change the data anyway if we read zeroes. - */ - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - - /* Outer loop handles each block in the MCU */ - - for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { - block = MCU_data[blkn]; - - /* Encoded data is simply the next bit of the two's-complement DC value */ - CHECK_BIT_BUFFER(br_state, 1, return FALSE); - if (GET_BITS(1)) - (*block)[0] |= p1; - /* Note: since we use |=, repeating the assignment later is safe */ - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; -} - - -/* - * MCU decoding for AC successive approximation refinement scan. - */ - -METHODDEF(boolean) -decode_mcu_AC_refine (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) -{ - phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; - int Se = cinfo->Se; - int p1 = 1 << cinfo->Al; /* 1 in the bit position being coded */ - int m1 = (-1) << cinfo->Al; /* -1 in the bit position being coded */ - register int s, k, r; - unsigned int EOBRUN; - JBLOCKROW block; - JCOEFPTR thiscoef; - BITREAD_STATE_VARS; - d_derived_tbl * tbl; - int num_newnz; - int newnz_pos[DCTSIZE2]; - - /* Process restart marker if needed; may have to suspend */ - if (cinfo->restart_interval) { - if (entropy->restarts_to_go == 0) - if (! process_restart(cinfo)) - return FALSE; - } - - /* If we've run out of data, don't modify the MCU. - */ - if (! entropy->pub.insufficient_data) { - - /* Load up working state */ - BITREAD_LOAD_STATE(cinfo,entropy->bitstate); - EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ - - /* There is always only one block per MCU */ - block = MCU_data[0]; - tbl = entropy->ac_derived_tbl; - - /* If we are forced to suspend, we must undo the assignments to any newly - * nonzero coefficients in the block, because otherwise we'd get confused - * next time about which coefficients were already nonzero. - * But we need not undo addition of bits to already-nonzero coefficients; - * instead, we can test the current bit to see if we already did it. - */ - num_newnz = 0; - - /* initialize coefficient loop counter to start of band */ - k = cinfo->Ss; - - if (EOBRUN == 0) { - for (; k <= Se; k++) { - HUFF_DECODE(s, br_state, tbl, goto undoit, label3); - r = s >> 4; - s &= 15; - if (s) { - if (s != 1) /* size of new coef should always be 1 */ - WARNMS(cinfo, JWRN_HUFF_BAD_CODE); - CHECK_BIT_BUFFER(br_state, 1, goto undoit); - if (GET_BITS(1)) - s = p1; /* newly nonzero coef is positive */ - else - s = m1; /* newly nonzero coef is negative */ - } else { - if (r != 15) { - EOBRUN = 1 << r; /* EOBr, run length is 2^r + appended bits */ - if (r) { - CHECK_BIT_BUFFER(br_state, r, goto undoit); - r = GET_BITS(r); - EOBRUN += r; - } - break; /* rest of block is handled by EOB logic */ - } - /* note s = 0 for processing ZRL */ - } - /* Advance over already-nonzero coefs and r still-zero coefs, - * appending correction bits to the nonzeroes. A correction bit is 1 - * if the absolute value of the coefficient must be increased. - */ - do { - thiscoef = *block + jpeg_natural_order[k]; - if (*thiscoef != 0) { - CHECK_BIT_BUFFER(br_state, 1, goto undoit); - if (GET_BITS(1)) { - if ((*thiscoef & p1) == 0) { /* do nothing if already set it */ - if (*thiscoef >= 0) - *thiscoef += p1; - else - *thiscoef += m1; - } - } - } else { - if (--r < 0) - break; /* reached target zero coefficient */ - } - k++; - } while (k <= Se); - if (s) { - int pos = jpeg_natural_order[k]; - /* Output newly nonzero coefficient */ - (*block)[pos] = (JCOEF) s; - /* Remember its position in case we have to suspend */ - newnz_pos[num_newnz++] = pos; - } - } - } - - if (EOBRUN > 0) { - /* Scan any remaining coefficient positions after the end-of-band - * (the last newly nonzero coefficient, if any). Append a correction - * bit to each already-nonzero coefficient. A correction bit is 1 - * if the absolute value of the coefficient must be increased. - */ - for (; k <= Se; k++) { - thiscoef = *block + jpeg_natural_order[k]; - if (*thiscoef != 0) { - CHECK_BIT_BUFFER(br_state, 1, goto undoit); - if (GET_BITS(1)) { - if ((*thiscoef & p1) == 0) { /* do nothing if already changed it */ - if (*thiscoef >= 0) - *thiscoef += p1; - else - *thiscoef += m1; - } - } - } - } - /* Count one block completed in EOB run */ - EOBRUN--; - } - - /* Completed MCU, so update state */ - BITREAD_SAVE_STATE(cinfo,entropy->bitstate); - entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ - } - - /* Account for restart interval (no-op if not using restarts) */ - entropy->restarts_to_go--; - - return TRUE; - -undoit: - /* Re-zero any output coefficients that we made newly nonzero */ - while (num_newnz > 0) - (*block)[newnz_pos[--num_newnz]] = 0; - - return FALSE; -} - - -/* - * Module initialization routine for progressive Huffman entropy decoding. - */ - -GLOBAL(void) -jinit_phuff_decoder (j_decompress_ptr cinfo) -{ - phuff_entropy_ptr entropy; - int *coef_bit_ptr; - int ci, i; - - entropy = (phuff_entropy_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(phuff_entropy_decoder)); - cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; - entropy->pub.start_pass = start_pass_phuff_decoder; - - /* Mark derived tables unallocated */ - for (i = 0; i < NUM_HUFF_TBLS; i++) { - entropy->derived_tbls[i] = NULL; - } - - /* Create progression status table */ - cinfo->coef_bits = (int (*)[DCTSIZE2]) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->num_components*DCTSIZE2*SIZEOF(int)); - coef_bit_ptr = & cinfo->coef_bits[0][0]; - for (ci = 0; ci < cinfo->num_components; ci++) - for (i = 0; i < DCTSIZE2; i++) - *coef_bit_ptr++ = -1; -} - -#endif /* D_PROGRESSIVE_SUPPORTED */ diff --git a/oversampling/WDL/jpeglib/jdpostct.c b/oversampling/WDL/jpeglib/jdpostct.c deleted file mode 100644 index 571563d..0000000 --- a/oversampling/WDL/jpeglib/jdpostct.c +++ /dev/null @@ -1,290 +0,0 @@ -/* - * jdpostct.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the decompression postprocessing controller. - * This controller manages the upsampling, color conversion, and color - * quantization/reduction steps; specifically, it controls the buffering - * between upsample/color conversion and color quantization/reduction. - * - * If no color quantization/reduction is required, then this module has no - * work to do, and it just hands off to the upsample/color conversion code. - * An integrated upsample/convert/quantize process would replace this module - * entirely. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Private buffer controller object */ - -typedef struct { - struct jpeg_d_post_controller pub; /* public fields */ - - /* Color quantization source buffer: this holds output data from - * the upsample/color conversion step to be passed to the quantizer. - * For two-pass color quantization, we need a full-image buffer; - * for one-pass operation, a strip buffer is sufficient. - */ - jvirt_sarray_ptr whole_image; /* virtual array, or NULL if one-pass */ - JSAMPARRAY buffer; /* strip buffer, or current strip of virtual */ - JDIMENSION strip_height; /* buffer size in rows */ - /* for two-pass mode only: */ - JDIMENSION starting_row; /* row # of first row in current strip */ - JDIMENSION next_row; /* index of next row to fill/empty in strip */ -} my_post_controller; - -typedef my_post_controller * my_post_ptr; - - -/* Forward declarations */ -METHODDEF(void) post_process_1pass - JPP((j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -#ifdef QUANT_2PASS_SUPPORTED -METHODDEF(void) post_process_prepass - JPP((j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -METHODDEF(void) post_process_2pass - JPP((j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -#endif - - -/* - * Initialize for a processing pass. - */ - -METHODDEF(void) -start_pass_dpost (j_decompress_ptr cinfo, J_BUF_MODE pass_mode) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - - switch (pass_mode) { - case JBUF_PASS_THRU: - if (cinfo->quantize_colors) { - /* Single-pass processing with color quantization. */ - post->pub.post_process_data = post_process_1pass; - /* We could be doing buffered-image output before starting a 2-pass - * color quantization; in that case, jinit_d_post_controller did not - * allocate a strip buffer. Use the virtual-array buffer as workspace. - */ - if (post->buffer == NULL) { - post->buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, post->whole_image, - (JDIMENSION) 0, post->strip_height, TRUE); - } - } else { - /* For single-pass processing without color quantization, - * I have no work to do; just call the upsampler directly. - */ - post->pub.post_process_data = cinfo->upsample->upsample; - } - break; -#ifdef QUANT_2PASS_SUPPORTED - case JBUF_SAVE_AND_PASS: - /* First pass of 2-pass quantization */ - if (post->whole_image == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - post->pub.post_process_data = post_process_prepass; - break; - case JBUF_CRANK_DEST: - /* Second pass of 2-pass quantization */ - if (post->whole_image == NULL) - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - post->pub.post_process_data = post_process_2pass; - break; -#endif /* QUANT_2PASS_SUPPORTED */ - default: - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); - break; - } - post->starting_row = post->next_row = 0; -} - - -/* - * Process some data in the one-pass (strip buffer) case. - * This is used for color precision reduction as well as one-pass quantization. - */ - -METHODDEF(void) -post_process_1pass (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - JDIMENSION num_rows, max_rows; - - /* Fill the buffer, but not more than what we can dump out in one go. */ - /* Note we rely on the upsampler to detect bottom of image. */ - max_rows = out_rows_avail - *out_row_ctr; - if (max_rows > post->strip_height) - max_rows = post->strip_height; - num_rows = 0; - (*cinfo->upsample->upsample) (cinfo, - input_buf, in_row_group_ctr, in_row_groups_avail, - post->buffer, &num_rows, max_rows); - /* Quantize and emit data. */ - (*cinfo->cquantize->color_quantize) (cinfo, - post->buffer, output_buf + *out_row_ctr, (int) num_rows); - *out_row_ctr += num_rows; -} - - -#ifdef QUANT_2PASS_SUPPORTED - -/* - * Process some data in the first pass of 2-pass quantization. - */ - -METHODDEF(void) -post_process_prepass (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - JDIMENSION old_next_row, num_rows; - - /* Reposition virtual buffer if at start of strip. */ - if (post->next_row == 0) { - post->buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, post->whole_image, - post->starting_row, post->strip_height, TRUE); - } - - /* Upsample some data (up to a strip height's worth). */ - old_next_row = post->next_row; - (*cinfo->upsample->upsample) (cinfo, - input_buf, in_row_group_ctr, in_row_groups_avail, - post->buffer, &post->next_row, post->strip_height); - - /* Allow quantizer to scan new data. No data is emitted, */ - /* but we advance out_row_ctr so outer loop can tell when we're done. */ - if (post->next_row > old_next_row) { - num_rows = post->next_row - old_next_row; - (*cinfo->cquantize->color_quantize) (cinfo, post->buffer + old_next_row, - (JSAMPARRAY) NULL, (int) num_rows); - *out_row_ctr += num_rows; - } - - /* Advance if we filled the strip. */ - if (post->next_row >= post->strip_height) { - post->starting_row += post->strip_height; - post->next_row = 0; - } -} - - -/* - * Process some data in the second pass of 2-pass quantization. - */ - -METHODDEF(void) -post_process_2pass (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_post_ptr post = (my_post_ptr) cinfo->post; - JDIMENSION num_rows, max_rows; - - /* Reposition virtual buffer if at start of strip. */ - if (post->next_row == 0) { - post->buffer = (*cinfo->mem->access_virt_sarray) - ((j_common_ptr) cinfo, post->whole_image, - post->starting_row, post->strip_height, FALSE); - } - - /* Determine number of rows to emit. */ - num_rows = post->strip_height - post->next_row; /* available in strip */ - max_rows = out_rows_avail - *out_row_ctr; /* available in output area */ - if (num_rows > max_rows) - num_rows = max_rows; - /* We have to check bottom of image here, can't depend on upsampler. */ - max_rows = cinfo->output_height - post->starting_row; - if (num_rows > max_rows) - num_rows = max_rows; - - /* Quantize and emit data. */ - (*cinfo->cquantize->color_quantize) (cinfo, - post->buffer + post->next_row, output_buf + *out_row_ctr, - (int) num_rows); - *out_row_ctr += num_rows; - - /* Advance if we filled the strip. */ - post->next_row += num_rows; - if (post->next_row >= post->strip_height) { - post->starting_row += post->strip_height; - post->next_row = 0; - } -} - -#endif /* QUANT_2PASS_SUPPORTED */ - - -/* - * Initialize postprocessing controller. - */ - -GLOBAL(void) -jinit_d_post_controller (j_decompress_ptr cinfo, boolean need_full_buffer) -{ - my_post_ptr post; - - post = (my_post_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_post_controller)); - cinfo->post = (struct jpeg_d_post_controller *) post; - post->pub.start_pass = start_pass_dpost; - post->whole_image = NULL; /* flag for no virtual arrays */ - post->buffer = NULL; /* flag for no strip buffer */ - - /* Create the quantization buffer, if needed */ - if (cinfo->quantize_colors) { - /* The buffer strip height is max_v_samp_factor, which is typically - * an efficient number of rows for upsampling to return. - * (In the presence of output rescaling, we might want to be smarter?) - */ - post->strip_height = (JDIMENSION) cinfo->max_v_samp_factor; - if (need_full_buffer) { - /* Two-pass color quantization: need full-image storage. */ - /* We round up the number of rows to a multiple of the strip height. */ -#ifdef QUANT_2PASS_SUPPORTED - post->whole_image = (*cinfo->mem->request_virt_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, FALSE, - cinfo->output_width * cinfo->out_color_components, - (JDIMENSION) jround_up((long) cinfo->output_height, - (long) post->strip_height), - post->strip_height); -#else - ERREXIT(cinfo, JERR_BAD_BUFFER_MODE); -#endif /* QUANT_2PASS_SUPPORTED */ - } else { - /* One-pass color quantization: just make a strip buffer. */ - post->buffer = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - cinfo->output_width * cinfo->out_color_components, - post->strip_height); - } - } -} diff --git a/oversampling/WDL/jpeglib/jdsample.c b/oversampling/WDL/jpeglib/jdsample.c deleted file mode 100644 index 80ffefb..0000000 --- a/oversampling/WDL/jpeglib/jdsample.c +++ /dev/null @@ -1,478 +0,0 @@ -/* - * jdsample.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains upsampling routines. - * - * Upsampling input data is counted in "row groups". A row group - * is defined to be (v_samp_factor * DCT_scaled_size / min_DCT_scaled_size) - * sample rows of each component. Upsampling will normally produce - * max_v_samp_factor pixel rows from each row group (but this could vary - * if the upsampler is applying a scale factor of its own). - * - * An excellent reference for image resampling is - * Digital Image Warping, George Wolberg, 1990. - * Pub. by IEEE Computer Society Press, Los Alamitos, CA. ISBN 0-8186-8944-7. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Pointer to routine to upsample a single component */ -typedef JMETHOD(void, upsample1_ptr, - (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr)); - -/* Private subobject */ - -typedef struct { - struct jpeg_upsampler pub; /* public fields */ - - /* Color conversion buffer. When using separate upsampling and color - * conversion steps, this buffer holds one upsampled row group until it - * has been color converted and output. - * Note: we do not allocate any storage for component(s) which are full-size, - * ie do not need rescaling. The corresponding entry of color_buf[] is - * simply set to point to the input data array, thereby avoiding copying. - */ - JSAMPARRAY color_buf[MAX_COMPONENTS]; - - /* Per-component upsampling method pointers */ - upsample1_ptr methods[MAX_COMPONENTS]; - - int next_row_out; /* counts rows emitted from color_buf */ - JDIMENSION rows_to_go; /* counts rows remaining in image */ - - /* Height of an input row group for each component. */ - int rowgroup_height[MAX_COMPONENTS]; - - /* These arrays save pixel expansion factors so that int_expand need not - * recompute them each time. They are unused for other upsampling methods. - */ - UINT8 h_expand[MAX_COMPONENTS]; - UINT8 v_expand[MAX_COMPONENTS]; -} my_upsampler; - -typedef my_upsampler * my_upsample_ptr; - - -/* - * Initialize for an upsampling pass. - */ - -METHODDEF(void) -start_pass_upsample (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - - /* Mark the conversion buffer empty */ - upsample->next_row_out = cinfo->max_v_samp_factor; - /* Initialize total-height counter for detecting bottom of image */ - upsample->rows_to_go = cinfo->output_height; -} - - -/* - * Control routine to do upsampling (and color conversion). - * - * In this version we upsample each component independently. - * We upsample one row group into the conversion buffer, then apply - * color conversion a row at a time. - */ - -METHODDEF(void) -sep_upsample (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - int ci; - jpeg_component_info * compptr; - JDIMENSION num_rows; - - /* Fill the conversion buffer, if it's empty */ - if (upsample->next_row_out >= cinfo->max_v_samp_factor) { - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Invoke per-component upsample method. Notice we pass a POINTER - * to color_buf[ci], so that fullsize_upsample can change it. - */ - (*upsample->methods[ci]) (cinfo, compptr, - input_buf[ci] + (*in_row_group_ctr * upsample->rowgroup_height[ci]), - upsample->color_buf + ci); - } - upsample->next_row_out = 0; - } - - /* Color-convert and emit rows */ - - /* How many we have in the buffer: */ - num_rows = (JDIMENSION) (cinfo->max_v_samp_factor - upsample->next_row_out); - /* Not more than the distance to the end of the image. Need this test - * in case the image height is not a multiple of max_v_samp_factor: - */ - if (num_rows > upsample->rows_to_go) - num_rows = upsample->rows_to_go; - /* And not more than what the client can accept: */ - out_rows_avail -= *out_row_ctr; - if (num_rows > out_rows_avail) - num_rows = out_rows_avail; - - (*cinfo->cconvert->color_convert) (cinfo, upsample->color_buf, - (JDIMENSION) upsample->next_row_out, - output_buf + *out_row_ctr, - (int) num_rows); - - /* Adjust counts */ - *out_row_ctr += num_rows; - upsample->rows_to_go -= num_rows; - upsample->next_row_out += num_rows; - /* When the buffer is emptied, declare this input row group consumed */ - if (upsample->next_row_out >= cinfo->max_v_samp_factor) - (*in_row_group_ctr)++; -} - - -/* - * These are the routines invoked by sep_upsample to upsample pixel values - * of a single component. One row group is processed per call. - */ - - -/* - * For full-size components, we just make color_buf[ci] point at the - * input buffer, and thus avoid copying any data. Note that this is - * safe only because sep_upsample doesn't declare the input row group - * "consumed" until we are done color converting and emitting it. - */ - -METHODDEF(void) -fullsize_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - *output_data_ptr = input_data; -} - - -/* - * This is a no-op version used for "uninteresting" components. - * These components will not be referenced by color conversion. - */ - -METHODDEF(void) -noop_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - *output_data_ptr = NULL; /* safety check */ -} - - -/* - * This version handles any integral sampling ratios. - * This is not used for typical JPEG files, so it need not be fast. - * Nor, for that matter, is it particularly accurate: the algorithm is - * simple replication of the input pixel onto the corresponding output - * pixels. The hi-falutin sampling literature refers to this as a - * "box filter". A box filter tends to introduce visible artifacts, - * so if you are actually going to use 3:1 or 4:1 sampling ratios - * you would be well advised to improve this code. - */ - -METHODDEF(void) -int_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register JSAMPLE invalue; - register int h; - JSAMPROW outend; - int h_expand, v_expand; - int inrow, outrow; - - h_expand = upsample->h_expand[compptr->component_index]; - v_expand = upsample->v_expand[compptr->component_index]; - - inrow = outrow = 0; - while (outrow < cinfo->max_v_samp_factor) { - /* Generate one output row with proper horizontal expansion */ - inptr = input_data[inrow]; - outptr = output_data[outrow]; - outend = outptr + cinfo->output_width; - while (outptr < outend) { - invalue = *inptr++; /* don't need GETJSAMPLE() here */ - for (h = h_expand; h > 0; h--) { - *outptr++ = invalue; - } - } - /* Generate any additional output rows by duplicating the first one */ - if (v_expand > 1) { - jcopy_sample_rows(output_data, outrow, output_data, outrow+1, - v_expand-1, cinfo->output_width); - } - inrow++; - outrow += v_expand; - } -} - - -/* - * Fast processing for the common case of 2:1 horizontal and 1:1 vertical. - * It's still a box filter. - */ - -METHODDEF(void) -h2v1_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register JSAMPLE invalue; - JSAMPROW outend; - int inrow; - - for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { - inptr = input_data[inrow]; - outptr = output_data[inrow]; - outend = outptr + cinfo->output_width; - while (outptr < outend) { - invalue = *inptr++; /* don't need GETJSAMPLE() here */ - *outptr++ = invalue; - *outptr++ = invalue; - } - } -} - - -/* - * Fast processing for the common case of 2:1 horizontal and 2:1 vertical. - * It's still a box filter. - */ - -METHODDEF(void) -h2v2_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register JSAMPLE invalue; - JSAMPROW outend; - int inrow, outrow; - - inrow = outrow = 0; - while (outrow < cinfo->max_v_samp_factor) { - inptr = input_data[inrow]; - outptr = output_data[outrow]; - outend = outptr + cinfo->output_width; - while (outptr < outend) { - invalue = *inptr++; /* don't need GETJSAMPLE() here */ - *outptr++ = invalue; - *outptr++ = invalue; - } - jcopy_sample_rows(output_data, outrow, output_data, outrow+1, - 1, cinfo->output_width); - inrow++; - outrow += 2; - } -} - - -/* - * Fancy processing for the common case of 2:1 horizontal and 1:1 vertical. - * - * The upsampling algorithm is linear interpolation between pixel centers, - * also known as a "triangle filter". This is a good compromise between - * speed and visual quality. The centers of the output pixels are 1/4 and 3/4 - * of the way between input pixel centers. - * - * A note about the "bias" calculations: when rounding fractional values to - * integer, we do not want to always round 0.5 up to the next integer. - * If we did that, we'd introduce a noticeable bias towards larger values. - * Instead, this code is arranged so that 0.5 will be rounded up or down at - * alternate pixel locations (a simple ordered dither pattern). - */ - -METHODDEF(void) -h2v1_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr, outptr; - register int invalue; - register JDIMENSION colctr; - int inrow; - - for (inrow = 0; inrow < cinfo->max_v_samp_factor; inrow++) { - inptr = input_data[inrow]; - outptr = output_data[inrow]; - /* Special case for first column */ - invalue = GETJSAMPLE(*inptr++); - *outptr++ = (JSAMPLE) invalue; - *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(*inptr) + 2) >> 2); - - for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { - /* General case: 3/4 * nearer pixel + 1/4 * further pixel */ - invalue = GETJSAMPLE(*inptr++) * 3; - *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(inptr[-2]) + 1) >> 2); - *outptr++ = (JSAMPLE) ((invalue + GETJSAMPLE(*inptr) + 2) >> 2); - } - - /* Special case for last column */ - invalue = GETJSAMPLE(*inptr); - *outptr++ = (JSAMPLE) ((invalue * 3 + GETJSAMPLE(inptr[-1]) + 1) >> 2); - *outptr++ = (JSAMPLE) invalue; - } -} - - -/* - * Fancy processing for the common case of 2:1 horizontal and 2:1 vertical. - * Again a triangle filter; see comments for h2v1 case, above. - * - * It is OK for us to reference the adjacent input rows because we demanded - * context from the main buffer controller (see initialization code). - */ - -METHODDEF(void) -h2v2_fancy_upsample (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JSAMPARRAY input_data, JSAMPARRAY * output_data_ptr) -{ - JSAMPARRAY output_data = *output_data_ptr; - register JSAMPROW inptr0, inptr1, outptr; -#if BITS_IN_JSAMPLE == 8 - register int thiscolsum, lastcolsum, nextcolsum; -#else - register INT32 thiscolsum, lastcolsum, nextcolsum; -#endif - register JDIMENSION colctr; - int inrow, outrow, v; - - inrow = outrow = 0; - while (outrow < cinfo->max_v_samp_factor) { - for (v = 0; v < 2; v++) { - /* inptr0 points to nearest input row, inptr1 points to next nearest */ - inptr0 = input_data[inrow]; - if (v == 0) /* next nearest is row above */ - inptr1 = input_data[inrow-1]; - else /* next nearest is row below */ - inptr1 = input_data[inrow+1]; - outptr = output_data[outrow++]; - - /* Special case for first column */ - thiscolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); - nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); - *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 8) >> 4); - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4); - lastcolsum = thiscolsum; thiscolsum = nextcolsum; - - for (colctr = compptr->downsampled_width - 2; colctr > 0; colctr--) { - /* General case: 3/4 * nearer pixel + 1/4 * further pixel in each */ - /* dimension, thus 9/16, 3/16, 3/16, 1/16 overall */ - nextcolsum = GETJSAMPLE(*inptr0++) * 3 + GETJSAMPLE(*inptr1++); - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4); - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + nextcolsum + 7) >> 4); - lastcolsum = thiscolsum; thiscolsum = nextcolsum; - } - - /* Special case for last column */ - *outptr++ = (JSAMPLE) ((thiscolsum * 3 + lastcolsum + 8) >> 4); - *outptr++ = (JSAMPLE) ((thiscolsum * 4 + 7) >> 4); - } - inrow++; - } -} - - -/* - * Module initialization routine for upsampling. - */ - -GLOBAL(void) -jinit_upsampler (j_decompress_ptr cinfo) -{ - my_upsample_ptr upsample; - int ci; - jpeg_component_info * compptr; - boolean need_buffer, do_fancy; - int h_in_group, v_in_group, h_out_group, v_out_group; - - upsample = (my_upsample_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_upsampler)); - cinfo->upsample = (struct jpeg_upsampler *) upsample; - upsample->pub.start_pass = start_pass_upsample; - upsample->pub.upsample = sep_upsample; - upsample->pub.need_context_rows = FALSE; /* until we find out differently */ - - if (cinfo->CCIR601_sampling) /* this isn't supported */ - ERREXIT(cinfo, JERR_CCIR601_NOTIMPL); - - /* jdmainct.c doesn't support context rows when min_DCT_scaled_size = 1, - * so don't ask for it. - */ - do_fancy = cinfo->do_fancy_upsampling && cinfo->min_DCT_scaled_size > 1; - - /* Verify we can handle the sampling factors, select per-component methods, - * and create storage as needed. - */ - for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; - ci++, compptr++) { - /* Compute size of an "input group" after IDCT scaling. This many samples - * are to be converted to max_h_samp_factor * max_v_samp_factor pixels. - */ - h_in_group = (compptr->h_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; - v_in_group = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; - h_out_group = cinfo->max_h_samp_factor; - v_out_group = cinfo->max_v_samp_factor; - upsample->rowgroup_height[ci] = v_in_group; /* save for use later */ - need_buffer = TRUE; - if (! compptr->component_needed) { - /* Don't bother to upsample an uninteresting component. */ - upsample->methods[ci] = noop_upsample; - need_buffer = FALSE; - } else if (h_in_group == h_out_group && v_in_group == v_out_group) { - /* Fullsize components can be processed without any work. */ - upsample->methods[ci] = fullsize_upsample; - need_buffer = FALSE; - } else if (h_in_group * 2 == h_out_group && - v_in_group == v_out_group) { - /* Special cases for 2h1v upsampling */ - if (do_fancy && compptr->downsampled_width > 2) - upsample->methods[ci] = h2v1_fancy_upsample; - else - upsample->methods[ci] = h2v1_upsample; - } else if (h_in_group * 2 == h_out_group && - v_in_group * 2 == v_out_group) { - /* Special cases for 2h2v upsampling */ - if (do_fancy && compptr->downsampled_width > 2) { - upsample->methods[ci] = h2v2_fancy_upsample; - upsample->pub.need_context_rows = TRUE; - } else - upsample->methods[ci] = h2v2_upsample; - } else if ((h_out_group % h_in_group) == 0 && - (v_out_group % v_in_group) == 0) { - /* Generic integral-factors upsampling method */ - upsample->methods[ci] = int_upsample; - upsample->h_expand[ci] = (UINT8) (h_out_group / h_in_group); - upsample->v_expand[ci] = (UINT8) (v_out_group / v_in_group); - } else - ERREXIT(cinfo, JERR_FRACT_SAMPLE_NOTIMPL); - if (need_buffer) { - upsample->color_buf[ci] = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) jround_up((long) cinfo->output_width, - (long) cinfo->max_h_samp_factor), - (JDIMENSION) cinfo->max_v_samp_factor); - } - } -} diff --git a/oversampling/WDL/jpeglib/jdtrans.c b/oversampling/WDL/jpeglib/jdtrans.c deleted file mode 100644 index 6c0ab71..0000000 --- a/oversampling/WDL/jpeglib/jdtrans.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * jdtrans.c - * - * Copyright (C) 1995-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains library routines for transcoding decompression, - * that is, reading raw DCT coefficient arrays from an input JPEG file. - * The routines in jdapimin.c will also be needed by a transcoder. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* Forward declarations */ -LOCAL(void) transdecode_master_selection JPP((j_decompress_ptr cinfo)); - - -/* - * Read the coefficient arrays from a JPEG file. - * jpeg_read_header must be completed before calling this. - * - * The entire image is read into a set of virtual coefficient-block arrays, - * one per component. The return value is a pointer to the array of - * virtual-array descriptors. These can be manipulated directly via the - * JPEG memory manager, or handed off to jpeg_write_coefficients(). - * To release the memory occupied by the virtual arrays, call - * jpeg_finish_decompress() when done with the data. - * - * An alternative usage is to simply obtain access to the coefficient arrays - * during a buffered-image-mode decompression operation. This is allowed - * after any jpeg_finish_output() call. The arrays can be accessed until - * jpeg_finish_decompress() is called. (Note that any call to the library - * may reposition the arrays, so don't rely on access_virt_barray() results - * to stay valid across library calls.) - * - * Returns NULL if suspended. This case need be checked only if - * a suspending data source is used. - */ - -GLOBAL(jvirt_barray_ptr *) -jpeg_read_coefficients (j_decompress_ptr cinfo) -{ - if (cinfo->global_state == DSTATE_READY) { - /* First call: initialize active modules */ - transdecode_master_selection(cinfo); - cinfo->global_state = DSTATE_RDCOEFS; - } - if (cinfo->global_state == DSTATE_RDCOEFS) { - /* Absorb whole file into the coef buffer */ - for (;;) { - int retcode; - /* Call progress monitor hook if present */ - if (cinfo->progress != NULL) - (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo); - /* Absorb some more input */ - retcode = (*cinfo->inputctl->consume_input) (cinfo); - if (retcode == JPEG_SUSPENDED) - return NULL; - if (retcode == JPEG_REACHED_EOI) - break; - /* Advance progress counter if appropriate */ - if (cinfo->progress != NULL && - (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { - if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { - /* startup underestimated number of scans; ratchet up one scan */ - cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows; - } - } - } - /* Set state so that jpeg_finish_decompress does the right thing */ - cinfo->global_state = DSTATE_STOPPING; - } - /* At this point we should be in state DSTATE_STOPPING if being used - * standalone, or in state DSTATE_BUFIMAGE if being invoked to get access - * to the coefficients during a full buffered-image-mode decompression. - */ - if ((cinfo->global_state == DSTATE_STOPPING || - cinfo->global_state == DSTATE_BUFIMAGE) && cinfo->buffered_image) { - return cinfo->coef->coef_arrays; - } - /* Oops, improper usage */ - ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state); - return NULL; /* keep compiler happy */ -} - - -/* - * Master selection of decompression modules for transcoding. - * This substitutes for jdmaster.c's initialization of the full decompressor. - */ - -LOCAL(void) -transdecode_master_selection (j_decompress_ptr cinfo) -{ - /* This is effectively a buffered-image operation. */ - cinfo->buffered_image = TRUE; - - /* Entropy decoding: either Huffman or arithmetic coding. */ - if (cinfo->arith_code) { - ERREXIT(cinfo, JERR_ARITH_NOTIMPL); - } else { - if (cinfo->progressive_mode) { -#ifdef D_PROGRESSIVE_SUPPORTED - jinit_phuff_decoder(cinfo); -#else - ERREXIT(cinfo, JERR_NOT_COMPILED); -#endif - } else - jinit_huff_decoder(cinfo); - } - - /* Always get a full-image coefficient buffer. */ - jinit_d_coef_controller(cinfo, TRUE); - - /* We can now tell the memory manager to allocate virtual arrays. */ - (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); - - /* Initialize input side of decompressor to consume first scan. */ - (*cinfo->inputctl->start_input_pass) (cinfo); - - /* Initialize progress monitoring. */ - if (cinfo->progress != NULL) { - int nscans; - /* Estimate number of scans to set pass_limit. */ - if (cinfo->progressive_mode) { - /* Arbitrarily estimate 2 interleaved DC scans + 3 AC scans/component. */ - nscans = 2 + 3 * cinfo->num_components; - } else if (cinfo->inputctl->has_multiple_scans) { - /* For a nonprogressive multiscan file, estimate 1 scan per component. */ - nscans = cinfo->num_components; - } else { - nscans = 1; - } - cinfo->progress->pass_counter = 0L; - cinfo->progress->pass_limit = (long) cinfo->total_iMCU_rows * nscans; - cinfo->progress->completed_passes = 0; - cinfo->progress->total_passes = 1; - } -} diff --git a/oversampling/WDL/jpeglib/jerror.c b/oversampling/WDL/jpeglib/jerror.c deleted file mode 100644 index 3da7be8..0000000 --- a/oversampling/WDL/jpeglib/jerror.c +++ /dev/null @@ -1,252 +0,0 @@ -/* - * jerror.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains simple error-reporting and trace-message routines. - * These are suitable for Unix-like systems and others where writing to - * stderr is the right thing to do. Many applications will want to replace - * some or all of these routines. - * - * If you define USE_WINDOWS_MESSAGEBOX in jconfig.h or in the makefile, - * you get a Windows-specific hack to display error messages in a dialog box. - * It ain't much, but it beats dropping error messages into the bit bucket, - * which is what happens to output to stderr under most Windows C compilers. - * - * These routines are used by both the compression and decompression code. - */ - -/* this is not a core library module, so it doesn't define JPEG_INTERNALS */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jversion.h" -#include "jerror.h" - -#ifdef USE_WINDOWS_MESSAGEBOX -#include -#endif - -#ifndef EXIT_FAILURE /* define exit() codes if not provided */ -#define EXIT_FAILURE 1 -#endif - - -/* - * Create the message string table. - * We do this from the master message list in jerror.h by re-reading - * jerror.h with a suitable definition for macro JMESSAGE. - * The message table is made an external symbol just in case any applications - * want to refer to it directly. - */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_std_message_table jMsgTable -#endif - -#define JMESSAGE(code,string) string , - -const char * const jpeg_std_message_table[] = { -#include "jerror.h" - NULL -}; - - -/* - * Error exit handler: must not return to caller. - * - * Applications may override this if they want to get control back after - * an error. Typically one would longjmp somewhere instead of exiting. - * The setjmp buffer can be made a private field within an expanded error - * handler object. Note that the info needed to generate an error message - * is stored in the error object, so you can generate the message now or - * later, at your convenience. - * You should make sure that the JPEG object is cleaned up (with jpeg_abort - * or jpeg_destroy) at some point. - */ - -METHODDEF(void) -error_exit (j_common_ptr cinfo) -{ - /* Always display the message */ - (*cinfo->err->output_message) (cinfo); - - /* Let the memory manager delete any temp files before we die */ - jpeg_destroy(cinfo); - - exit(EXIT_FAILURE); -} - - -/* - * Actual output of an error or trace message. - * Applications may override this method to send JPEG messages somewhere - * other than stderr. - * - * On Windows, printing to stderr is generally completely useless, - * so we provide optional code to produce an error-dialog popup. - * Most Windows applications will still prefer to override this routine, - * but if they don't, it'll do something at least marginally useful. - * - * NOTE: to use the library in an environment that doesn't support the - * C stdio library, you may have to delete the call to fprintf() entirely, - * not just not use this routine. - */ - -METHODDEF(void) -output_message (j_common_ptr cinfo) -{ - char buffer[JMSG_LENGTH_MAX]; - - /* Create the message */ - (*cinfo->err->format_message) (cinfo, buffer); - -#ifdef USE_WINDOWS_MESSAGEBOX - /* Display it in a message dialog box */ - MessageBox(GetActiveWindow(), buffer, "JPEG Library Error", - MB_OK | MB_ICONERROR); -#else - /* Send it to stderr, adding a newline */ - fprintf(stderr, "%s\n", buffer); -#endif -} - - -/* - * Decide whether to emit a trace or warning message. - * msg_level is one of: - * -1: recoverable corrupt-data warning, may want to abort. - * 0: important advisory messages (always display to user). - * 1: first level of tracing detail. - * 2,3,...: successively more detailed tracing messages. - * An application might override this method if it wanted to abort on warnings - * or change the policy about which messages to display. - */ - -METHODDEF(void) -emit_message (j_common_ptr cinfo, int msg_level) -{ - struct jpeg_error_mgr * err = cinfo->err; - - if (msg_level < 0) { - /* It's a warning message. Since corrupt files may generate many warnings, - * the policy implemented here is to show only the first warning, - * unless trace_level >= 3. - */ - if (err->num_warnings == 0 || err->trace_level >= 3) - (*err->output_message) (cinfo); - /* Always count warnings in num_warnings. */ - err->num_warnings++; - } else { - /* It's a trace message. Show it if trace_level >= msg_level. */ - if (err->trace_level >= msg_level) - (*err->output_message) (cinfo); - } -} - - -/* - * Format a message string for the most recent JPEG error or message. - * The message is stored into buffer, which should be at least JMSG_LENGTH_MAX - * characters. Note that no '\n' character is added to the string. - * Few applications should need to override this method. - */ - -METHODDEF(void) -format_message (j_common_ptr cinfo, char * buffer) -{ - struct jpeg_error_mgr * err = cinfo->err; - int msg_code = err->msg_code; - const char * msgtext = NULL; - const char * msgptr; - char ch; - boolean isstring; - - /* Look up message string in proper table */ - if (msg_code > 0 && msg_code <= err->last_jpeg_message) { - msgtext = err->jpeg_message_table[msg_code]; - } else if (err->addon_message_table != NULL && - msg_code >= err->first_addon_message && - msg_code <= err->last_addon_message) { - msgtext = err->addon_message_table[msg_code - err->first_addon_message]; - } - - /* Defend against bogus message number */ - if (msgtext == NULL) { - err->msg_parm.i[0] = msg_code; - msgtext = err->jpeg_message_table[0]; - } - - /* Check for string parameter, as indicated by %s in the message text */ - isstring = FALSE; - msgptr = msgtext; - while ((ch = *msgptr++) != '\0') { - if (ch == '%') { - if (*msgptr == 's') isstring = TRUE; - break; - } - } - - /* Format the message into the passed buffer */ - if (isstring) - sprintf(buffer, msgtext, err->msg_parm.s); - else - sprintf(buffer, msgtext, - err->msg_parm.i[0], err->msg_parm.i[1], - err->msg_parm.i[2], err->msg_parm.i[3], - err->msg_parm.i[4], err->msg_parm.i[5], - err->msg_parm.i[6], err->msg_parm.i[7]); -} - - -/* - * Reset error state variables at start of a new image. - * This is called during compression startup to reset trace/error - * processing to default state, without losing any application-specific - * method pointers. An application might possibly want to override - * this method if it has additional error processing state. - */ - -METHODDEF(void) -reset_error_mgr (j_common_ptr cinfo) -{ - cinfo->err->num_warnings = 0; - /* trace_level is not reset since it is an application-supplied parameter */ - cinfo->err->msg_code = 0; /* may be useful as a flag for "no error" */ -} - - -/* - * Fill in the standard error-handling methods in a jpeg_error_mgr object. - * Typical call is: - * struct jpeg_compress_struct cinfo; - * struct jpeg_error_mgr err; - * - * cinfo.err = jpeg_std_error(&err); - * after which the application may override some of the methods. - */ - -GLOBAL(struct jpeg_error_mgr *) -jpeg_std_error (struct jpeg_error_mgr * err) -{ - err->error_exit = error_exit; - err->emit_message = emit_message; - err->output_message = output_message; - err->format_message = format_message; - err->reset_error_mgr = reset_error_mgr; - - err->trace_level = 0; /* default = no tracing */ - err->num_warnings = 0; /* no warnings emitted yet */ - err->msg_code = 0; /* may be useful as a flag for "no error" */ - - /* Initialize message table pointers */ - err->jpeg_message_table = jpeg_std_message_table; - err->last_jpeg_message = (int) JMSG_LASTMSGCODE - 1; - - err->addon_message_table = NULL; - err->first_addon_message = 0; /* for safety */ - err->last_addon_message = 0; - - return err; -} diff --git a/oversampling/WDL/jpeglib/jerror.h b/oversampling/WDL/jpeglib/jerror.h deleted file mode 100644 index fc2fffe..0000000 --- a/oversampling/WDL/jpeglib/jerror.h +++ /dev/null @@ -1,291 +0,0 @@ -/* - * jerror.h - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the error and message codes for the JPEG library. - * Edit this file to add new codes, or to translate the message strings to - * some other language. - * A set of error-reporting macros are defined too. Some applications using - * the JPEG library may wish to include this file to get the error codes - * and/or the macros. - */ - -/* - * To define the enum list of message codes, include this file without - * defining macro JMESSAGE. To create a message string table, include it - * again with a suitable JMESSAGE definition (see jerror.c for an example). - */ -#ifndef JMESSAGE -#ifndef JERROR_H -/* First time through, define the enum list */ -#define JMAKE_ENUM_LIST -#else -/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ -#define JMESSAGE(code,string) -#endif /* JERROR_H */ -#endif /* JMESSAGE */ - -#ifdef JMAKE_ENUM_LIST - -typedef enum { - -#define JMESSAGE(code,string) code , - -#endif /* JMAKE_ENUM_LIST */ - -JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */ - -/* For maintenance convenience, list is alphabetical by message code name */ -JMESSAGE(JERR_ARITH_NOTIMPL, - "Sorry, there are legal restrictions on arithmetic coding") -JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix") -JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") -JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") -JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") -JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") -JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported") -JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") -JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace") -JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace") -JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length") -JMESSAGE(JERR_BAD_LIB_VERSION, - "Wrong JPEG library version: library is %d, caller expects %d") -JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan") -JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d") -JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d") -JMESSAGE(JERR_BAD_PROGRESSION, - "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d") -JMESSAGE(JERR_BAD_PROG_SCRIPT, - "Invalid progressive parameters at scan script entry %d") -JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors") -JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d") -JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d") -JMESSAGE(JERR_BAD_STRUCT_SIZE, - "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u") -JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access") -JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small") -JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here") -JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet") -JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d") -JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request") -JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d") -JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x") -JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d") -JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d") -JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)") -JMESSAGE(JERR_EMS_READ, "Read from EMS failed") -JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed") -JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan") -JMESSAGE(JERR_FILE_READ, "Input file read error") -JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?") -JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet") -JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow") -JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry") -JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels") -JMESSAGE(JERR_INPUT_EMPTY, "Empty input file") -JMESSAGE(JERR_INPUT_EOF, "Premature end of input file") -JMESSAGE(JERR_MISMATCHED_QUANT_TABLE, - "Cannot transcode due to multiple use of quantization table %d") -JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data") -JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change") -JMESSAGE(JERR_NOTIMPL, "Not implemented yet") -JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time") -JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported") -JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined") -JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image") -JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined") -JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x") -JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)") -JMESSAGE(JERR_QUANT_COMPONENTS, - "Cannot quantize more than %d color components") -JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors") -JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors") -JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers") -JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker") -JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x") -JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers") -JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF") -JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s") -JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file") -JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file") -JMESSAGE(JERR_TFILE_WRITE, - "Write failed on temporary file --- out of disk space?") -JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines") -JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x") -JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up") -JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation") -JMESSAGE(JERR_XMS_READ, "Read from XMS failed") -JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed") -JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT) -JMESSAGE(JMSG_VERSION, JVERSION) -JMESSAGE(JTRC_16BIT_TABLES, - "Caution: quantization tables are too coarse for baseline JPEG") -JMESSAGE(JTRC_ADOBE, - "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d") -JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u") -JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u") -JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x") -JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x") -JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d") -JMESSAGE(JTRC_DRI, "Define Restart Interval %u") -JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u") -JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u") -JMESSAGE(JTRC_EOI, "End Of Image") -JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d") -JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d") -JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE, - "Warning: thumbnail image size does not match data length %u") -JMESSAGE(JTRC_JFIF_EXTENSION, - "JFIF extension marker: type 0x%02x, length %u") -JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image") -JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u") -JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x") -JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u") -JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors") -JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors") -JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization") -JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d") -JMESSAGE(JTRC_RST, "RST%d") -JMESSAGE(JTRC_SMOOTH_NOTIMPL, - "Smoothing not supported with nonstandard sampling ratios") -JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d") -JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d") -JMESSAGE(JTRC_SOI, "Start of Image") -JMESSAGE(JTRC_SOS, "Start Of Scan: %d components") -JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d") -JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d") -JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s") -JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s") -JMESSAGE(JTRC_THUMB_JPEG, - "JFIF extension marker: JPEG-compressed thumbnail image, length %u") -JMESSAGE(JTRC_THUMB_PALETTE, - "JFIF extension marker: palette thumbnail image, length %u") -JMESSAGE(JTRC_THUMB_RGB, - "JFIF extension marker: RGB thumbnail image, length %u") -JMESSAGE(JTRC_UNKNOWN_IDS, - "Unrecognized component IDs %d %d %d, assuming YCbCr") -JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u") -JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u") -JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d") -JMESSAGE(JWRN_BOGUS_PROGRESSION, - "Inconsistent progression sequence for component %d coefficient %d") -JMESSAGE(JWRN_EXTRANEOUS_DATA, - "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x") -JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment") -JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code") -JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d") -JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file") -JMESSAGE(JWRN_MUST_RESYNC, - "Corrupt JPEG data: found marker 0x%02x instead of RST%d") -JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG") -JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines") - -#ifdef JMAKE_ENUM_LIST - - JMSG_LASTMSGCODE -} J_MESSAGE_CODE; - -#undef JMAKE_ENUM_LIST -#endif /* JMAKE_ENUM_LIST */ - -/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ -#undef JMESSAGE - - -#ifndef JERROR_H -#define JERROR_H - -/* Macros to simplify using the error and trace message stuff */ -/* The first parameter is either type of cinfo pointer */ - -/* Fatal errors (print message and exit) */ -#define ERREXIT(cinfo,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT1(cinfo,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT2(cinfo,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT3(cinfo,code,p1,p2,p3) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (cinfo)->err->msg_parm.i[3] = (p4), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXITS(cinfo,code,str) \ - ((cinfo)->err->msg_code = (code), \ - strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) - -#define MAKESTMT(stuff) do { stuff } while (0) - -/* Nonfatal errors (we can keep going, but the data is probably corrupt) */ -#define WARNMS(cinfo,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) -#define WARNMS1(cinfo,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) -#define WARNMS2(cinfo,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) - -/* Informational/debugging messages */ -#define TRACEMS(cinfo,lvl,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS1(cinfo,lvl,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS2(cinfo,lvl,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - _mp[4] = (p5); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMSS(cinfo,lvl,code,str) \ - ((cinfo)->err->msg_code = (code), \ - strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) - -#endif /* JERROR_H */ diff --git a/oversampling/WDL/jpeglib/jfdctflt.c b/oversampling/WDL/jpeglib/jfdctflt.c deleted file mode 100644 index 79d7a00..0000000 --- a/oversampling/WDL/jpeglib/jfdctflt.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - * jfdctflt.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a floating-point implementation of the - * forward DCT (Discrete Cosine Transform). - * - * This implementation should be more accurate than either of the integer - * DCT implementations. However, it may not give the same results on all - * machines because of differences in roundoff behavior. Speed will depend - * on the hardware's floating point capacity. - * - * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT - * on each column. Direct algorithms are also available, but they are - * much more complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with a fixed-point - * implementation, accuracy is lost due to imprecise representation of the - * scaled quantization values. However, that problem does not arise if - * we use floating point arithmetic. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_FLOAT_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -jpeg_fdct_float (FAST_FLOAT * data) -{ - FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - FAST_FLOAT tmp10, tmp11, tmp12, tmp13; - FAST_FLOAT z1, z2, z3, z4, z5, z11, z13; - FAST_FLOAT *dataptr; - int ctr; - - /* Pass 1: process rows. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = tmp10 + tmp11; /* phase 3 */ - dataptr[4] = tmp10 - tmp11; - - z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ - dataptr[2] = tmp13 + z1; /* phase 5 */ - dataptr[6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ - z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ - z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ - z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[5] = z13 + z2; /* phase 6 */ - dataptr[3] = z13 - z2; - dataptr[1] = z11 + z4; - dataptr[7] = z11 - z4; - - dataptr += DCTSIZE; /* advance pointer to next row */ - } - - /* Pass 2: process columns. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; - tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; - tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; - tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; - tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; - tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ - dataptr[DCTSIZE*4] = tmp10 - tmp11; - - z1 = (tmp12 + tmp13) * ((FAST_FLOAT) 0.707106781); /* c4 */ - dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ - dataptr[DCTSIZE*6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = (tmp10 - tmp12) * ((FAST_FLOAT) 0.382683433); /* c6 */ - z2 = ((FAST_FLOAT) 0.541196100) * tmp10 + z5; /* c2-c6 */ - z4 = ((FAST_FLOAT) 1.306562965) * tmp12 + z5; /* c2+c6 */ - z3 = tmp11 * ((FAST_FLOAT) 0.707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ - dataptr[DCTSIZE*3] = z13 - z2; - dataptr[DCTSIZE*1] = z11 + z4; - dataptr[DCTSIZE*7] = z11 - z4; - - dataptr++; /* advance pointer to next column */ - } -} - -#endif /* DCT_FLOAT_SUPPORTED */ diff --git a/oversampling/WDL/jpeglib/jfdctfst.c b/oversampling/WDL/jpeglib/jfdctfst.c deleted file mode 100644 index ccb378a..0000000 --- a/oversampling/WDL/jpeglib/jfdctfst.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - * jfdctfst.c - * - * Copyright (C) 1994-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a fast, not so accurate integer implementation of the - * forward DCT (Discrete Cosine Transform). - * - * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT - * on each column. Direct algorithms are also available, but they are - * much more complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with fixed-point math, - * accuracy is lost due to imprecise representation of the scaled - * quantization values. The smaller the quantization table entry, the less - * precise the scaled value, so this implementation does worse with high- - * quality-setting files than with low-quality ones. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_IFAST_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Scaling decisions are generally the same as in the LL&M algorithm; - * see jfdctint.c for more details. However, we choose to descale - * (right shift) multiplication products as soon as they are formed, - * rather than carrying additional fractional bits into subsequent additions. - * This compromises accuracy slightly, but it lets us save a few shifts. - * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) - * everywhere except in the multiplications proper; this saves a good deal - * of work on 16-bit-int machines. - * - * Again to save a few shifts, the intermediate results between pass 1 and - * pass 2 are not upscaled, but are represented only to integral precision. - * - * A final compromise is to represent the multiplicative constants to only - * 8 fractional bits, rather than 13. This saves some shifting work on some - * machines, and may also reduce the cost of multiplication (since there - * are fewer one-bits in the constants). - */ - -#define CONST_BITS 8 - - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 8 -#define FIX_0_382683433 ((INT32) 98) /* FIX(0.382683433) */ -#define FIX_0_541196100 ((INT32) 139) /* FIX(0.541196100) */ -#define FIX_0_707106781 ((INT32) 181) /* FIX(0.707106781) */ -#define FIX_1_306562965 ((INT32) 334) /* FIX(1.306562965) */ -#else -#define FIX_0_382683433 FIX(0.382683433) -#define FIX_0_541196100 FIX(0.541196100) -#define FIX_0_707106781 FIX(0.707106781) -#define FIX_1_306562965 FIX(1.306562965) -#endif - - -/* We can gain a little more speed, with a further compromise in accuracy, - * by omitting the addition in a descaling shift. This yields an incorrectly - * rounded result half the time... - */ - -#ifndef USE_ACCURATE_ROUNDING -#undef DESCALE -#define DESCALE(x,n) RIGHT_SHIFT(x, n) -#endif - - -/* Multiply a DCTELEM variable by an INT32 constant, and immediately - * descale to yield a DCTELEM result. - */ - -#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -jpeg_fdct_ifast (DCTELEM * data) -{ - DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - DCTELEM tmp10, tmp11, tmp12, tmp13; - DCTELEM z1, z2, z3, z4, z5, z11, z13; - DCTELEM *dataptr; - int ctr; - SHIFT_TEMPS - - /* Pass 1: process rows. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = tmp10 + tmp11; /* phase 3 */ - dataptr[4] = tmp10 - tmp11; - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ - dataptr[2] = tmp13 + z1; /* phase 5 */ - dataptr[6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ - z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ - z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ - z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[5] = z13 + z2; /* phase 6 */ - dataptr[3] = z13 - z2; - dataptr[1] = z11 + z4; - dataptr[7] = z11 - z4; - - dataptr += DCTSIZE; /* advance pointer to next row */ - } - - /* Pass 2: process columns. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; - tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; - tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; - tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; - tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; - tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; - - /* Even part */ - - tmp10 = tmp0 + tmp3; /* phase 2 */ - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[DCTSIZE*0] = tmp10 + tmp11; /* phase 3 */ - dataptr[DCTSIZE*4] = tmp10 - tmp11; - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_707106781); /* c4 */ - dataptr[DCTSIZE*2] = tmp13 + z1; /* phase 5 */ - dataptr[DCTSIZE*6] = tmp13 - z1; - - /* Odd part */ - - tmp10 = tmp4 + tmp5; /* phase 2 */ - tmp11 = tmp5 + tmp6; - tmp12 = tmp6 + tmp7; - - /* The rotator is modified from fig 4-8 to avoid extra negations. */ - z5 = MULTIPLY(tmp10 - tmp12, FIX_0_382683433); /* c6 */ - z2 = MULTIPLY(tmp10, FIX_0_541196100) + z5; /* c2-c6 */ - z4 = MULTIPLY(tmp12, FIX_1_306562965) + z5; /* c2+c6 */ - z3 = MULTIPLY(tmp11, FIX_0_707106781); /* c4 */ - - z11 = tmp7 + z3; /* phase 5 */ - z13 = tmp7 - z3; - - dataptr[DCTSIZE*5] = z13 + z2; /* phase 6 */ - dataptr[DCTSIZE*3] = z13 - z2; - dataptr[DCTSIZE*1] = z11 + z4; - dataptr[DCTSIZE*7] = z11 - z4; - - dataptr++; /* advance pointer to next column */ - } -} - -#endif /* DCT_IFAST_SUPPORTED */ diff --git a/oversampling/WDL/jpeglib/jfdctint.c b/oversampling/WDL/jpeglib/jfdctint.c deleted file mode 100644 index 0a78b64..0000000 --- a/oversampling/WDL/jpeglib/jfdctint.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * jfdctint.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a slow-but-accurate integer implementation of the - * forward DCT (Discrete Cosine Transform). - * - * A 2-D DCT can be done by 1-D DCT on each row followed by 1-D DCT - * on each column. Direct algorithms are also available, but they are - * much more complex and seem not to be any faster when reduced to code. - * - * This implementation is based on an algorithm described in - * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT - * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, - * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. - * The primary algorithm described there uses 11 multiplies and 29 adds. - * We use their alternate method with 12 multiplies and 32 adds. - * The advantage of this method is that no data path contains more than one - * multiplication; this allows a very simple and accurate implementation in - * scaled fixed-point arithmetic, with a minimal number of shifts. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_ISLOW_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* - * The poop on this scaling stuff is as follows: - * - * Each 1-D DCT step produces outputs which are a factor of sqrt(N) - * larger than the true DCT outputs. The final outputs are therefore - * a factor of N larger than desired; since N=8 this can be cured by - * a simple right shift at the end of the algorithm. The advantage of - * this arrangement is that we save two multiplications per 1-D DCT, - * because the y0 and y4 outputs need not be divided by sqrt(N). - * In the IJG code, this factor of 8 is removed by the quantization step - * (in jcdctmgr.c), NOT in this module. - * - * We have to do addition and subtraction of the integer inputs, which - * is no problem, and multiplication by fractional constants, which is - * a problem to do in integer arithmetic. We multiply all the constants - * by CONST_SCALE and convert them to integer constants (thus retaining - * CONST_BITS bits of precision in the constants). After doing a - * multiplication we have to divide the product by CONST_SCALE, with proper - * rounding, to produce the correct output. This division can be done - * cheaply as a right shift of CONST_BITS bits. We postpone shifting - * as long as possible so that partial sums can be added together with - * full fractional precision. - * - * The outputs of the first pass are scaled up by PASS1_BITS bits so that - * they are represented to better-than-integral precision. These outputs - * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word - * with the recommended scaling. (For 12-bit sample data, the intermediate - * array is INT32 anyway.) - * - * To avoid overflow of the 32-bit intermediate results in pass 2, we must - * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis - * shows that the values given below are the most effective. - */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 13 -#define PASS1_BITS 2 -#else -#define CONST_BITS 13 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 13 -#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ -#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ -#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ -#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ -#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ -#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ -#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ -#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ -#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ -#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ -#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ -#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ -#else -#define FIX_0_298631336 FIX(0.298631336) -#define FIX_0_390180644 FIX(0.390180644) -#define FIX_0_541196100 FIX(0.541196100) -#define FIX_0_765366865 FIX(0.765366865) -#define FIX_0_899976223 FIX(0.899976223) -#define FIX_1_175875602 FIX(1.175875602) -#define FIX_1_501321110 FIX(1.501321110) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_1_961570560 FIX(1.961570560) -#define FIX_2_053119869 FIX(2.053119869) -#define FIX_2_562915447 FIX(2.562915447) -#define FIX_3_072711026 FIX(3.072711026) -#endif - - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * For 8-bit samples with the recommended scaling, all the variable - * and constant values involved are no more than 16 bits wide, so a - * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. - * For 12-bit samples, a full 32-bit multiplication will be needed. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MULTIPLY(var,const) MULTIPLY16C16(var,const) -#else -#define MULTIPLY(var,const) ((var) * (const)) -#endif - - -/* - * Perform the forward DCT on one block of samples. - */ - -GLOBAL(void) -jpeg_fdct_islow (DCTELEM * data) -{ - INT32 tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - INT32 tmp10, tmp11, tmp12, tmp13; - INT32 z1, z2, z3, z4, z5; - DCTELEM *dataptr; - int ctr; - SHIFT_TEMPS - - /* Pass 1: process rows. */ - /* Note results are scaled up by sqrt(8) compared to a true DCT; */ - /* furthermore, we scale the results by 2**PASS1_BITS. */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[0] + dataptr[7]; - tmp7 = dataptr[0] - dataptr[7]; - tmp1 = dataptr[1] + dataptr[6]; - tmp6 = dataptr[1] - dataptr[6]; - tmp2 = dataptr[2] + dataptr[5]; - tmp5 = dataptr[2] - dataptr[5]; - tmp3 = dataptr[3] + dataptr[4]; - tmp4 = dataptr[3] - dataptr[4]; - - /* Even part per LL&M figure 1 --- note that published figure is faulty; - * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". - */ - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[0] = (DCTELEM) ((tmp10 + tmp11) << PASS1_BITS); - dataptr[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS); - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); - dataptr[2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), - CONST_BITS-PASS1_BITS); - dataptr[6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), - CONST_BITS-PASS1_BITS); - - /* Odd part per figure 8 --- note paper omits factor of sqrt(2). - * cK represents cos(K*pi/16). - * i0..i3 in the paper are tmp4..tmp7 here. - */ - - z1 = tmp4 + tmp7; - z2 = tmp5 + tmp6; - z3 = tmp4 + tmp6; - z4 = tmp5 + tmp7; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - dataptr[7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, CONST_BITS-PASS1_BITS); - dataptr[5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, CONST_BITS-PASS1_BITS); - dataptr[3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, CONST_BITS-PASS1_BITS); - dataptr[1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, CONST_BITS-PASS1_BITS); - - dataptr += DCTSIZE; /* advance pointer to next row */ - } - - /* Pass 2: process columns. - * We remove the PASS1_BITS scaling, but leave the results scaled up - * by an overall factor of 8. - */ - - dataptr = data; - for (ctr = DCTSIZE-1; ctr >= 0; ctr--) { - tmp0 = dataptr[DCTSIZE*0] + dataptr[DCTSIZE*7]; - tmp7 = dataptr[DCTSIZE*0] - dataptr[DCTSIZE*7]; - tmp1 = dataptr[DCTSIZE*1] + dataptr[DCTSIZE*6]; - tmp6 = dataptr[DCTSIZE*1] - dataptr[DCTSIZE*6]; - tmp2 = dataptr[DCTSIZE*2] + dataptr[DCTSIZE*5]; - tmp5 = dataptr[DCTSIZE*2] - dataptr[DCTSIZE*5]; - tmp3 = dataptr[DCTSIZE*3] + dataptr[DCTSIZE*4]; - tmp4 = dataptr[DCTSIZE*3] - dataptr[DCTSIZE*4]; - - /* Even part per LL&M figure 1 --- note that published figure is faulty; - * rotator "sqrt(2)*c1" should be "sqrt(2)*c6". - */ - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - dataptr[DCTSIZE*0] = (DCTELEM) DESCALE(tmp10 + tmp11, PASS1_BITS); - dataptr[DCTSIZE*4] = (DCTELEM) DESCALE(tmp10 - tmp11, PASS1_BITS); - - z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100); - dataptr[DCTSIZE*2] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp13, FIX_0_765366865), - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*6] = (DCTELEM) DESCALE(z1 + MULTIPLY(tmp12, - FIX_1_847759065), - CONST_BITS+PASS1_BITS); - - /* Odd part per figure 8 --- note paper omits factor of sqrt(2). - * cK represents cos(K*pi/16). - * i0..i3 in the paper are tmp4..tmp7 here. - */ - - z1 = tmp4 + tmp7; - z2 = tmp5 + tmp6; - z3 = tmp4 + tmp6; - z4 = tmp5 + tmp7; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp4 = MULTIPLY(tmp4, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp5 = MULTIPLY(tmp5, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp6 = MULTIPLY(tmp6, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp7 = MULTIPLY(tmp7, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - dataptr[DCTSIZE*7] = (DCTELEM) DESCALE(tmp4 + z1 + z3, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*5] = (DCTELEM) DESCALE(tmp5 + z2 + z4, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*3] = (DCTELEM) DESCALE(tmp6 + z2 + z3, - CONST_BITS+PASS1_BITS); - dataptr[DCTSIZE*1] = (DCTELEM) DESCALE(tmp7 + z1 + z4, - CONST_BITS+PASS1_BITS); - - dataptr++; /* advance pointer to next column */ - } -} - -#endif /* DCT_ISLOW_SUPPORTED */ diff --git a/oversampling/WDL/jpeglib/jidctflt.c b/oversampling/WDL/jpeglib/jidctflt.c deleted file mode 100644 index 0188ce3..0000000 --- a/oversampling/WDL/jpeglib/jidctflt.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * jidctflt.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a floating-point implementation of the - * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine - * must also perform dequantization of the input coefficients. - * - * This implementation should be more accurate than either of the integer - * IDCT implementations. However, it may not give the same results on all - * machines because of differences in roundoff behavior. Speed will depend - * on the hardware's floating point capacity. - * - * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT - * on each row (or vice versa, but it's more convenient to emit a row at - * a time). Direct algorithms are also available, but they are much more - * complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with a fixed-point - * implementation, accuracy is lost due to imprecise representation of the - * scaled quantization values. However, that problem does not arise if - * we use floating point arithmetic. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_FLOAT_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce a float result. - */ - -#define DEQUANTIZE(coef,quantval) (((FAST_FLOAT) (coef)) * (quantval)) - - -/* - * Perform dequantization and inverse DCT on one block of coefficients. - */ - -GLOBAL(void) -jpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - FAST_FLOAT tmp10, tmp11, tmp12, tmp13; - FAST_FLOAT z5, z10, z11, z12, z13; - JCOEFPTR inptr; - FLOAT_MULT_TYPE * quantptr; - FAST_FLOAT * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (FLOAT_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; ctr--) { - /* Due to quantization, we will usually find that many of the input - * coefficients are zero, especially the AC terms. We can exploit this - * by short-circuiting the IDCT calculation for any column in which all - * the AC terms are zero. In that case each output is equal to the - * DC coefficient (with scale factor as needed). - * With typical images and quantization tables, half or more of the - * column DCT calculations can be simplified this way. - */ - - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && - inptr[DCTSIZE*7] == 0) { - /* AC terms all zero */ - FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - wsptr[DCTSIZE*4] = dcval; - wsptr[DCTSIZE*5] = dcval; - wsptr[DCTSIZE*6] = dcval; - wsptr[DCTSIZE*7] = dcval; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - continue; - } - - /* Even part */ - - tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); - tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - tmp10 = tmp0 + tmp2; /* phase 3 */ - tmp11 = tmp0 - tmp2; - - tmp13 = tmp1 + tmp3; /* phases 5-3 */ - tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */ - - tmp0 = tmp10 + tmp13; /* phase 2 */ - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - - z13 = tmp6 + tmp5; /* phase 6 */ - z10 = tmp6 - tmp5; - z11 = tmp4 + tmp7; - z12 = tmp4 - tmp7; - - tmp7 = z11 + z13; /* phase 5 */ - tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */ - - z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ - tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ - tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; /* phase 2 */ - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - wsptr[DCTSIZE*0] = tmp0 + tmp7; - wsptr[DCTSIZE*7] = tmp0 - tmp7; - wsptr[DCTSIZE*1] = tmp1 + tmp6; - wsptr[DCTSIZE*6] = tmp1 - tmp6; - wsptr[DCTSIZE*2] = tmp2 + tmp5; - wsptr[DCTSIZE*5] = tmp2 - tmp5; - wsptr[DCTSIZE*4] = tmp3 + tmp4; - wsptr[DCTSIZE*3] = tmp3 - tmp4; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - } - - /* Pass 2: process rows from work array, store into output array. */ - /* Note that we must descale the results by a factor of 8 == 2**3. */ - - wsptr = workspace; - for (ctr = 0; ctr < DCTSIZE; ctr++) { - outptr = output_buf[ctr] + output_col; - /* Rows of zeroes can be exploited in the same way as we did with columns. - * However, the column calculation has created many nonzero AC terms, so - * the simplification applies less often (typically 5% to 10% of the time). - * And testing floats for zero is relatively expensive, so we don't bother. - */ - - /* Even part */ - - tmp10 = wsptr[0] + wsptr[4]; - tmp11 = wsptr[0] - wsptr[4]; - - tmp13 = wsptr[2] + wsptr[6]; - tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13; - - tmp0 = tmp10 + tmp13; - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - z13 = wsptr[5] + wsptr[3]; - z10 = wsptr[5] - wsptr[3]; - z11 = wsptr[1] + wsptr[7]; - z12 = wsptr[1] - wsptr[7]; - - tmp7 = z11 + z13; - tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); - - z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */ - tmp10 = ((FAST_FLOAT) 1.082392200) * z12 - z5; /* 2*(c2-c6) */ - tmp12 = ((FAST_FLOAT) -2.613125930) * z10 + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - /* Final output stage: scale down by a factor of 8 and range-limit */ - - outptr[0] = range_limit[(int) DESCALE((INT32) (tmp0 + tmp7), 3) - & RANGE_MASK]; - outptr[7] = range_limit[(int) DESCALE((INT32) (tmp0 - tmp7), 3) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE((INT32) (tmp1 + tmp6), 3) - & RANGE_MASK]; - outptr[6] = range_limit[(int) DESCALE((INT32) (tmp1 - tmp6), 3) - & RANGE_MASK]; - outptr[2] = range_limit[(int) DESCALE((INT32) (tmp2 + tmp5), 3) - & RANGE_MASK]; - outptr[5] = range_limit[(int) DESCALE((INT32) (tmp2 - tmp5), 3) - & RANGE_MASK]; - outptr[4] = range_limit[(int) DESCALE((INT32) (tmp3 + tmp4), 3) - & RANGE_MASK]; - outptr[3] = range_limit[(int) DESCALE((INT32) (tmp3 - tmp4), 3) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - -#endif /* DCT_FLOAT_SUPPORTED */ diff --git a/oversampling/WDL/jpeglib/jidctfst.c b/oversampling/WDL/jpeglib/jidctfst.c deleted file mode 100644 index dba4216..0000000 --- a/oversampling/WDL/jpeglib/jidctfst.c +++ /dev/null @@ -1,368 +0,0 @@ -/* - * jidctfst.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a fast, not so accurate integer implementation of the - * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine - * must also perform dequantization of the input coefficients. - * - * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT - * on each row (or vice versa, but it's more convenient to emit a row at - * a time). Direct algorithms are also available, but they are much more - * complex and seem not to be any faster when reduced to code. - * - * This implementation is based on Arai, Agui, and Nakajima's algorithm for - * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in - * Japanese, but the algorithm is described in the Pennebaker & Mitchell - * JPEG textbook (see REFERENCES section in file README). The following code - * is based directly on figure 4-8 in P&M. - * While an 8-point DCT cannot be done in less than 11 multiplies, it is - * possible to arrange the computation so that many of the multiplies are - * simple scalings of the final outputs. These multiplies can then be - * folded into the multiplications or divisions by the JPEG quantization - * table entries. The AA&N method leaves only 5 multiplies and 29 adds - * to be done in the DCT itself. - * The primary disadvantage of this method is that with fixed-point math, - * accuracy is lost due to imprecise representation of the scaled - * quantization values. The smaller the quantization table entry, the less - * precise the scaled value, so this implementation does worse with high- - * quality-setting files than with low-quality ones. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_IFAST_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Scaling decisions are generally the same as in the LL&M algorithm; - * see jidctint.c for more details. However, we choose to descale - * (right shift) multiplication products as soon as they are formed, - * rather than carrying additional fractional bits into subsequent additions. - * This compromises accuracy slightly, but it lets us save a few shifts. - * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples) - * everywhere except in the multiplications proper; this saves a good deal - * of work on 16-bit-int machines. - * - * The dequantized coefficients are not integers because the AA&N scaling - * factors have been incorporated. We represent them scaled up by PASS1_BITS, - * so that the first and second IDCT rounds have the same input scaling. - * For 8-bit JSAMPLEs, we choose IFAST_SCALE_BITS = PASS1_BITS so as to - * avoid a descaling shift; this compromises accuracy rather drastically - * for small quantization table entries, but it saves a lot of shifts. - * For 12-bit JSAMPLEs, there's no hope of using 16x16 multiplies anyway, - * so we use a much larger scaling factor to preserve accuracy. - * - * A final compromise is to represent the multiplicative constants to only - * 8 fractional bits, rather than 13. This saves some shifting work on some - * machines, and may also reduce the cost of multiplication (since there - * are fewer one-bits in the constants). - */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 8 -#define PASS1_BITS 2 -#else -#define CONST_BITS 8 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 8 -#define FIX_1_082392200 ((INT32) 277) /* FIX(1.082392200) */ -#define FIX_1_414213562 ((INT32) 362) /* FIX(1.414213562) */ -#define FIX_1_847759065 ((INT32) 473) /* FIX(1.847759065) */ -#define FIX_2_613125930 ((INT32) 669) /* FIX(2.613125930) */ -#else -#define FIX_1_082392200 FIX(1.082392200) -#define FIX_1_414213562 FIX(1.414213562) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_2_613125930 FIX(2.613125930) -#endif - - -/* We can gain a little more speed, with a further compromise in accuracy, - * by omitting the addition in a descaling shift. This yields an incorrectly - * rounded result half the time... - */ - -#ifndef USE_ACCURATE_ROUNDING -#undef DESCALE -#define DESCALE(x,n) RIGHT_SHIFT(x, n) -#endif - - -/* Multiply a DCTELEM variable by an INT32 constant, and immediately - * descale to yield a DCTELEM result. - */ - -#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS)) - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce a DCTELEM result. For 8-bit data a 16x16->16 - * multiplication will do. For 12-bit data, the multiplier table is - * declared INT32, so a 32-bit multiply will be used. - */ - -#if BITS_IN_JSAMPLE == 8 -#define DEQUANTIZE(coef,quantval) (((IFAST_MULT_TYPE) (coef)) * (quantval)) -#else -#define DEQUANTIZE(coef,quantval) \ - DESCALE((coef)*(quantval), IFAST_SCALE_BITS-PASS1_BITS) -#endif - - -/* Like DESCALE, but applies to a DCTELEM and produces an int. - * We assume that int right shift is unsigned if INT32 right shift is. - */ - -#ifdef RIGHT_SHIFT_IS_UNSIGNED -#define ISHIFT_TEMPS DCTELEM ishift_temp; -#if BITS_IN_JSAMPLE == 8 -#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */ -#else -#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */ -#endif -#define IRIGHT_SHIFT(x,shft) \ - ((ishift_temp = (x)) < 0 ? \ - (ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \ - (ishift_temp >> (shft))) -#else -#define ISHIFT_TEMPS -#define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) -#endif - -#ifdef USE_ACCURATE_ROUNDING -#define IDESCALE(x,n) ((int) IRIGHT_SHIFT((x) + (1 << ((n)-1)), n)) -#else -#define IDESCALE(x,n) ((int) IRIGHT_SHIFT(x, n)) -#endif - - -/* - * Perform dequantization and inverse DCT on one block of coefficients. - */ - -GLOBAL(void) -jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; - DCTELEM tmp10, tmp11, tmp12, tmp13; - DCTELEM z5, z10, z11, z12, z13; - JCOEFPTR inptr; - IFAST_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE2]; /* buffers data between passes */ - SHIFT_TEMPS /* for DESCALE */ - ISHIFT_TEMPS /* for IDESCALE */ - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (IFAST_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; ctr--) { - /* Due to quantization, we will usually find that many of the input - * coefficients are zero, especially the AC terms. We can exploit this - * by short-circuiting the IDCT calculation for any column in which all - * the AC terms are zero. In that case each output is equal to the - * DC coefficient (with scale factor as needed). - * With typical images and quantization tables, half or more of the - * column DCT calculations can be simplified this way. - */ - - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && - inptr[DCTSIZE*7] == 0) { - /* AC terms all zero */ - int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - wsptr[DCTSIZE*4] = dcval; - wsptr[DCTSIZE*5] = dcval; - wsptr[DCTSIZE*6] = dcval; - wsptr[DCTSIZE*7] = dcval; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - continue; - } - - /* Even part */ - - tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); - tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - tmp10 = tmp0 + tmp2; /* phase 3 */ - tmp11 = tmp0 - tmp2; - - tmp13 = tmp1 + tmp3; /* phases 5-3 */ - tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */ - - tmp0 = tmp10 + tmp13; /* phase 2 */ - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - - z13 = tmp6 + tmp5; /* phase 6 */ - z10 = tmp6 - tmp5; - z11 = tmp4 + tmp7; - z12 = tmp4 - tmp7; - - tmp7 = z11 + z13; /* phase 5 */ - tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ - - z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ - tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ - tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; /* phase 2 */ - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7); - wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7); - wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6); - wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6); - wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5); - wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5); - wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4); - wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4); - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - } - - /* Pass 2: process rows from work array, store into output array. */ - /* Note that we must descale the results by a factor of 8 == 2**3, */ - /* and also undo the PASS1_BITS scaling. */ - - wsptr = workspace; - for (ctr = 0; ctr < DCTSIZE; ctr++) { - outptr = output_buf[ctr] + output_col; - /* Rows of zeroes can be exploited in the same way as we did with columns. - * However, the column calculation has created many nonzero AC terms, so - * the simplification applies less often (typically 5% to 10% of the time). - * On machines with very fast multiplication, it's possible that the - * test takes more time than it's worth. In that case this section - * may be commented out. - */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && - wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - outptr[2] = dcval; - outptr[3] = dcval; - outptr[4] = dcval; - outptr[5] = dcval; - outptr[6] = dcval; - outptr[7] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part */ - - tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]); - tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]); - - tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]); - tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562) - - tmp13; - - tmp0 = tmp10 + tmp13; - tmp3 = tmp10 - tmp13; - tmp1 = tmp11 + tmp12; - tmp2 = tmp11 - tmp12; - - /* Odd part */ - - z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3]; - z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3]; - z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7]; - z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7]; - - tmp7 = z11 + z13; /* phase 5 */ - tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */ - - z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */ - tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */ - tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */ - - tmp6 = tmp12 - tmp7; /* phase 2 */ - tmp5 = tmp11 - tmp6; - tmp4 = tmp10 + tmp5; - - /* Final output stage: scale down by a factor of 8 and range-limit */ - - outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3) - & RANGE_MASK]; - outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3) - & RANGE_MASK]; - outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3) - & RANGE_MASK]; - outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3) - & RANGE_MASK]; - outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3) - & RANGE_MASK]; - outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3) - & RANGE_MASK]; - outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3) - & RANGE_MASK]; - outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - -#endif /* DCT_IFAST_SUPPORTED */ diff --git a/oversampling/WDL/jpeglib/jidctint.c b/oversampling/WDL/jpeglib/jidctint.c deleted file mode 100644 index a72b320..0000000 --- a/oversampling/WDL/jpeglib/jidctint.c +++ /dev/null @@ -1,389 +0,0 @@ -/* - * jidctint.c - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains a slow-but-accurate integer implementation of the - * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine - * must also perform dequantization of the input coefficients. - * - * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT - * on each row (or vice versa, but it's more convenient to emit a row at - * a time). Direct algorithms are also available, but they are much more - * complex and seem not to be any faster when reduced to code. - * - * This implementation is based on an algorithm described in - * C. Loeffler, A. Ligtenberg and G. Moschytz, "Practical Fast 1-D DCT - * Algorithms with 11 Multiplications", Proc. Int'l. Conf. on Acoustics, - * Speech, and Signal Processing 1989 (ICASSP '89), pp. 988-991. - * The primary algorithm described there uses 11 multiplies and 29 adds. - * We use their alternate method with 12 multiplies and 32 adds. - * The advantage of this method is that no data path contains more than one - * multiplication; this allows a very simple and accurate implementation in - * scaled fixed-point arithmetic, with a minimal number of shifts. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef DCT_ISLOW_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* - * The poop on this scaling stuff is as follows: - * - * Each 1-D IDCT step produces outputs which are a factor of sqrt(N) - * larger than the true IDCT outputs. The final outputs are therefore - * a factor of N larger than desired; since N=8 this can be cured by - * a simple right shift at the end of the algorithm. The advantage of - * this arrangement is that we save two multiplications per 1-D IDCT, - * because the y0 and y4 inputs need not be divided by sqrt(N). - * - * We have to do addition and subtraction of the integer inputs, which - * is no problem, and multiplication by fractional constants, which is - * a problem to do in integer arithmetic. We multiply all the constants - * by CONST_SCALE and convert them to integer constants (thus retaining - * CONST_BITS bits of precision in the constants). After doing a - * multiplication we have to divide the product by CONST_SCALE, with proper - * rounding, to produce the correct output. This division can be done - * cheaply as a right shift of CONST_BITS bits. We postpone shifting - * as long as possible so that partial sums can be added together with - * full fractional precision. - * - * The outputs of the first pass are scaled up by PASS1_BITS bits so that - * they are represented to better-than-integral precision. These outputs - * require BITS_IN_JSAMPLE + PASS1_BITS + 3 bits; this fits in a 16-bit word - * with the recommended scaling. (To scale up 12-bit sample data further, an - * intermediate INT32 array would be needed.) - * - * To avoid overflow of the 32-bit intermediate results in pass 2, we must - * have BITS_IN_JSAMPLE + CONST_BITS + PASS1_BITS <= 26. Error analysis - * shows that the values given below are the most effective. - */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 13 -#define PASS1_BITS 2 -#else -#define CONST_BITS 13 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 13 -#define FIX_0_298631336 ((INT32) 2446) /* FIX(0.298631336) */ -#define FIX_0_390180644 ((INT32) 3196) /* FIX(0.390180644) */ -#define FIX_0_541196100 ((INT32) 4433) /* FIX(0.541196100) */ -#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ -#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ -#define FIX_1_175875602 ((INT32) 9633) /* FIX(1.175875602) */ -#define FIX_1_501321110 ((INT32) 12299) /* FIX(1.501321110) */ -#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ -#define FIX_1_961570560 ((INT32) 16069) /* FIX(1.961570560) */ -#define FIX_2_053119869 ((INT32) 16819) /* FIX(2.053119869) */ -#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ -#define FIX_3_072711026 ((INT32) 25172) /* FIX(3.072711026) */ -#else -#define FIX_0_298631336 FIX(0.298631336) -#define FIX_0_390180644 FIX(0.390180644) -#define FIX_0_541196100 FIX(0.541196100) -#define FIX_0_765366865 FIX(0.765366865) -#define FIX_0_899976223 FIX(0.899976223) -#define FIX_1_175875602 FIX(1.175875602) -#define FIX_1_501321110 FIX(1.501321110) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_1_961570560 FIX(1.961570560) -#define FIX_2_053119869 FIX(2.053119869) -#define FIX_2_562915447 FIX(2.562915447) -#define FIX_3_072711026 FIX(3.072711026) -#endif - - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * For 8-bit samples with the recommended scaling, all the variable - * and constant values involved are no more than 16 bits wide, so a - * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. - * For 12-bit samples, a full 32-bit multiplication will be needed. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MULTIPLY(var,const) MULTIPLY16C16(var,const) -#else -#define MULTIPLY(var,const) ((var) * (const)) -#endif - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce an int result. In this module, both inputs and result - * are 16 bits or less, so either int or short multiply will work. - */ - -#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) - - -/* - * Perform dequantization and inverse DCT on one block of coefficients. - */ - -GLOBAL(void) -jpeg_idct_islow (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - INT32 tmp0, tmp1, tmp2, tmp3; - INT32 tmp10, tmp11, tmp12, tmp13; - INT32 z1, z2, z3, z4, z5; - JCOEFPTR inptr; - ISLOW_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE2]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - /* Note results are scaled up by sqrt(8) compared to a true IDCT; */ - /* furthermore, we scale the results by 2**PASS1_BITS. */ - - inptr = coef_block; - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; ctr--) { - /* Due to quantization, we will usually find that many of the input - * coefficients are zero, especially the AC terms. We can exploit this - * by short-circuiting the IDCT calculation for any column in which all - * the AC terms are zero. In that case each output is equal to the - * DC coefficient (with scale factor as needed). - * With typical images and quantization tables, half or more of the - * column DCT calculations can be simplified this way. - */ - - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 && - inptr[DCTSIZE*7] == 0) { - /* AC terms all zero */ - int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - wsptr[DCTSIZE*4] = dcval; - wsptr[DCTSIZE*5] = dcval; - wsptr[DCTSIZE*6] = dcval; - wsptr[DCTSIZE*7] = dcval; - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - continue; - } - - /* Even part: reverse the even part of the forward DCT. */ - /* The rotator is sqrt(2)*c(-6). */ - - z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - z1 = MULTIPLY(z2 + z3, FIX_0_541196100); - tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); - tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); - - z2 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - z3 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]); - - tmp0 = (z2 + z3) << CONST_BITS; - tmp1 = (z2 - z3) << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - /* Odd part per figure 8; the matrix is unitary and hence its - * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. - */ - - tmp0 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - tmp1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp2 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp3 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - - z1 = tmp0 + tmp3; - z2 = tmp1 + tmp2; - z3 = tmp0 + tmp2; - z4 = tmp1 + tmp3; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - tmp0 += z1 + z3; - tmp1 += z2 + z4; - tmp2 += z2 + z3; - tmp3 += z1 + z4; - - /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ - - wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp3, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*7] = (int) DESCALE(tmp10 - tmp3, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*1] = (int) DESCALE(tmp11 + tmp2, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*6] = (int) DESCALE(tmp11 - tmp2, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 + tmp1, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*5] = (int) DESCALE(tmp12 - tmp1, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*3] = (int) DESCALE(tmp13 + tmp0, CONST_BITS-PASS1_BITS); - wsptr[DCTSIZE*4] = (int) DESCALE(tmp13 - tmp0, CONST_BITS-PASS1_BITS); - - inptr++; /* advance pointers to next column */ - quantptr++; - wsptr++; - } - - /* Pass 2: process rows from work array, store into output array. */ - /* Note that we must descale the results by a factor of 8 == 2**3, */ - /* and also undo the PASS1_BITS scaling. */ - - wsptr = workspace; - for (ctr = 0; ctr < DCTSIZE; ctr++) { - outptr = output_buf[ctr] + output_col; - /* Rows of zeroes can be exploited in the same way as we did with columns. - * However, the column calculation has created many nonzero AC terms, so - * the simplification applies less often (typically 5% to 10% of the time). - * On machines with very fast multiplication, it's possible that the - * test takes more time than it's worth. In that case this section - * may be commented out. - */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && - wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - outptr[2] = dcval; - outptr[3] = dcval; - outptr[4] = dcval; - outptr[5] = dcval; - outptr[6] = dcval; - outptr[7] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part: reverse the even part of the forward DCT. */ - /* The rotator is sqrt(2)*c(-6). */ - - z2 = (INT32) wsptr[2]; - z3 = (INT32) wsptr[6]; - - z1 = MULTIPLY(z2 + z3, FIX_0_541196100); - tmp2 = z1 + MULTIPLY(z3, - FIX_1_847759065); - tmp3 = z1 + MULTIPLY(z2, FIX_0_765366865); - - tmp0 = ((INT32) wsptr[0] + (INT32) wsptr[4]) << CONST_BITS; - tmp1 = ((INT32) wsptr[0] - (INT32) wsptr[4]) << CONST_BITS; - - tmp10 = tmp0 + tmp3; - tmp13 = tmp0 - tmp3; - tmp11 = tmp1 + tmp2; - tmp12 = tmp1 - tmp2; - - /* Odd part per figure 8; the matrix is unitary and hence its - * transpose is its inverse. i0..i3 are y7,y5,y3,y1 respectively. - */ - - tmp0 = (INT32) wsptr[7]; - tmp1 = (INT32) wsptr[5]; - tmp2 = (INT32) wsptr[3]; - tmp3 = (INT32) wsptr[1]; - - z1 = tmp0 + tmp3; - z2 = tmp1 + tmp2; - z3 = tmp0 + tmp2; - z4 = tmp1 + tmp3; - z5 = MULTIPLY(z3 + z4, FIX_1_175875602); /* sqrt(2) * c3 */ - - tmp0 = MULTIPLY(tmp0, FIX_0_298631336); /* sqrt(2) * (-c1+c3+c5-c7) */ - tmp1 = MULTIPLY(tmp1, FIX_2_053119869); /* sqrt(2) * ( c1+c3-c5+c7) */ - tmp2 = MULTIPLY(tmp2, FIX_3_072711026); /* sqrt(2) * ( c1+c3+c5-c7) */ - tmp3 = MULTIPLY(tmp3, FIX_1_501321110); /* sqrt(2) * ( c1+c3-c5-c7) */ - z1 = MULTIPLY(z1, - FIX_0_899976223); /* sqrt(2) * (c7-c3) */ - z2 = MULTIPLY(z2, - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */ - z3 = MULTIPLY(z3, - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */ - z4 = MULTIPLY(z4, - FIX_0_390180644); /* sqrt(2) * (c5-c3) */ - - z3 += z5; - z4 += z5; - - tmp0 += z1 + z3; - tmp1 += z2 + z4; - tmp2 += z2 + z3; - tmp3 += z1 + z4; - - /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */ - - outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp3, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[7] = range_limit[(int) DESCALE(tmp10 - tmp3, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE(tmp11 + tmp2, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[6] = range_limit[(int) DESCALE(tmp11 - tmp2, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[2] = range_limit[(int) DESCALE(tmp12 + tmp1, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[5] = range_limit[(int) DESCALE(tmp12 - tmp1, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[3] = range_limit[(int) DESCALE(tmp13 + tmp0, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - outptr[4] = range_limit[(int) DESCALE(tmp13 - tmp0, - CONST_BITS+PASS1_BITS+3) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - -#endif /* DCT_ISLOW_SUPPORTED */ diff --git a/oversampling/WDL/jpeglib/jidctred.c b/oversampling/WDL/jpeglib/jidctred.c deleted file mode 100644 index 421f3c7..0000000 --- a/oversampling/WDL/jpeglib/jidctred.c +++ /dev/null @@ -1,398 +0,0 @@ -/* - * jidctred.c - * - * Copyright (C) 1994-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains inverse-DCT routines that produce reduced-size output: - * either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block. - * - * The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M) - * algorithm used in jidctint.c. We simply replace each 8-to-8 1-D IDCT step - * with an 8-to-4 step that produces the four averages of two adjacent outputs - * (or an 8-to-2 step producing two averages of four outputs, for 2x2 output). - * These steps were derived by computing the corresponding values at the end - * of the normal LL&M code, then simplifying as much as possible. - * - * 1x1 is trivial: just take the DC coefficient divided by 8. - * - * See jidctint.c for additional comments. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jdct.h" /* Private declarations for DCT subsystem */ - -#ifdef IDCT_SCALING_SUPPORTED - - -/* - * This module is specialized to the case DCTSIZE = 8. - */ - -#if DCTSIZE != 8 - Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ -#endif - - -/* Scaling is the same as in jidctint.c. */ - -#if BITS_IN_JSAMPLE == 8 -#define CONST_BITS 13 -#define PASS1_BITS 2 -#else -#define CONST_BITS 13 -#define PASS1_BITS 1 /* lose a little precision to avoid overflow */ -#endif - -/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus - * causing a lot of useless floating-point operations at run time. - * To get around this we use the following pre-calculated constants. - * If you change CONST_BITS you may want to add appropriate values. - * (With a reasonable C compiler, you can just rely on the FIX() macro...) - */ - -#if CONST_BITS == 13 -#define FIX_0_211164243 ((INT32) 1730) /* FIX(0.211164243) */ -#define FIX_0_509795579 ((INT32) 4176) /* FIX(0.509795579) */ -#define FIX_0_601344887 ((INT32) 4926) /* FIX(0.601344887) */ -#define FIX_0_720959822 ((INT32) 5906) /* FIX(0.720959822) */ -#define FIX_0_765366865 ((INT32) 6270) /* FIX(0.765366865) */ -#define FIX_0_850430095 ((INT32) 6967) /* FIX(0.850430095) */ -#define FIX_0_899976223 ((INT32) 7373) /* FIX(0.899976223) */ -#define FIX_1_061594337 ((INT32) 8697) /* FIX(1.061594337) */ -#define FIX_1_272758580 ((INT32) 10426) /* FIX(1.272758580) */ -#define FIX_1_451774981 ((INT32) 11893) /* FIX(1.451774981) */ -#define FIX_1_847759065 ((INT32) 15137) /* FIX(1.847759065) */ -#define FIX_2_172734803 ((INT32) 17799) /* FIX(2.172734803) */ -#define FIX_2_562915447 ((INT32) 20995) /* FIX(2.562915447) */ -#define FIX_3_624509785 ((INT32) 29692) /* FIX(3.624509785) */ -#else -#define FIX_0_211164243 FIX(0.211164243) -#define FIX_0_509795579 FIX(0.509795579) -#define FIX_0_601344887 FIX(0.601344887) -#define FIX_0_720959822 FIX(0.720959822) -#define FIX_0_765366865 FIX(0.765366865) -#define FIX_0_850430095 FIX(0.850430095) -#define FIX_0_899976223 FIX(0.899976223) -#define FIX_1_061594337 FIX(1.061594337) -#define FIX_1_272758580 FIX(1.272758580) -#define FIX_1_451774981 FIX(1.451774981) -#define FIX_1_847759065 FIX(1.847759065) -#define FIX_2_172734803 FIX(2.172734803) -#define FIX_2_562915447 FIX(2.562915447) -#define FIX_3_624509785 FIX(3.624509785) -#endif - - -/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result. - * For 8-bit samples with the recommended scaling, all the variable - * and constant values involved are no more than 16 bits wide, so a - * 16x16->32 bit multiply can be used instead of a full 32x32 multiply. - * For 12-bit samples, a full 32-bit multiplication will be needed. - */ - -#if BITS_IN_JSAMPLE == 8 -#define MULTIPLY(var,const) MULTIPLY16C16(var,const) -#else -#define MULTIPLY(var,const) ((var) * (const)) -#endif - - -/* Dequantize a coefficient by multiplying it by the multiplier-table - * entry; produce an int result. In this module, both inputs and result - * are 16 bits or less, so either int or short multiply will work. - */ - -#define DEQUANTIZE(coef,quantval) (((ISLOW_MULT_TYPE) (coef)) * (quantval)) - - -/* - * Perform dequantization and inverse DCT on one block of coefficients, - * producing a reduced-size 4x4 output block. - */ - -GLOBAL(void) -jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - INT32 tmp0, tmp2, tmp10, tmp12; - INT32 z1, z2, z3, z4; - JCOEFPTR inptr; - ISLOW_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE*4]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { - /* Don't bother to process column 4, because second pass won't use it */ - if (ctr == DCTSIZE-4) - continue; - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 && - inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*5] == 0 && - inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*7] == 0) { - /* AC terms all zero; we need not examine term 4 for 4x4 output */ - int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - wsptr[DCTSIZE*2] = dcval; - wsptr[DCTSIZE*3] = dcval; - - continue; - } - - /* Even part */ - - tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp0 <<= (CONST_BITS+1); - - z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]); - z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]); - - tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865); - - tmp10 = tmp0 + tmp2; - tmp12 = tmp0 - tmp2; - - /* Odd part */ - - z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - z2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - z4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - - tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ - + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ - + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ - + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ - - tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ - + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ - + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ - + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ - - /* Final output stage */ - - wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1); - wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1); - wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1); - wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1); - } - - /* Pass 2: process 4 rows from work array, store into output array. */ - - wsptr = workspace; - for (ctr = 0; ctr < 4; ctr++) { - outptr = output_buf[ctr] + output_col; - /* It's not clear whether a zero row test is worthwhile here ... */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && - wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - outptr[2] = dcval; - outptr[3] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part */ - - tmp0 = ((INT32) wsptr[0]) << (CONST_BITS+1); - - tmp2 = MULTIPLY((INT32) wsptr[2], FIX_1_847759065) - + MULTIPLY((INT32) wsptr[6], - FIX_0_765366865); - - tmp10 = tmp0 + tmp2; - tmp12 = tmp0 - tmp2; - - /* Odd part */ - - z1 = (INT32) wsptr[7]; - z2 = (INT32) wsptr[5]; - z3 = (INT32) wsptr[3]; - z4 = (INT32) wsptr[1]; - - tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */ - + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */ - + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */ - + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */ - - tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */ - + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */ - + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */ - + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */ - - /* Final output stage */ - - outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0, - CONST_BITS+PASS1_BITS+3+1) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - - -/* - * Perform dequantization and inverse DCT on one block of coefficients, - * producing a reduced-size 2x2 output block. - */ - -GLOBAL(void) -jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - INT32 tmp0, tmp10, z1; - JCOEFPTR inptr; - ISLOW_MULT_TYPE * quantptr; - int * wsptr; - JSAMPROW outptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - int ctr; - int workspace[DCTSIZE*2]; /* buffers data between passes */ - SHIFT_TEMPS - - /* Pass 1: process columns from input, store into work array. */ - - inptr = coef_block; - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - wsptr = workspace; - for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) { - /* Don't bother to process columns 2,4,6 */ - if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6) - continue; - if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 && - inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) { - /* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */ - int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS; - - wsptr[DCTSIZE*0] = dcval; - wsptr[DCTSIZE*1] = dcval; - - continue; - } - - /* Even part */ - - z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]); - tmp10 = z1 << (CONST_BITS+2); - - /* Odd part */ - - z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]); - tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */ - z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]); - tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */ - z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]); - tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */ - z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]); - tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ - - /* Final output stage */ - - wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2); - wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2); - } - - /* Pass 2: process 2 rows from work array, store into output array. */ - - wsptr = workspace; - for (ctr = 0; ctr < 2; ctr++) { - outptr = output_buf[ctr] + output_col; - /* It's not clear whether a zero row test is worthwhile here ... */ - -#ifndef NO_ZERO_ROW_TEST - if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) { - /* AC terms all zero */ - JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3) - & RANGE_MASK]; - - outptr[0] = dcval; - outptr[1] = dcval; - - wsptr += DCTSIZE; /* advance pointer to next row */ - continue; - } -#endif - - /* Even part */ - - tmp10 = ((INT32) wsptr[0]) << (CONST_BITS+2); - - /* Odd part */ - - tmp0 = MULTIPLY((INT32) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3-c1) */ - + MULTIPLY((INT32) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c7) */ - + MULTIPLY((INT32) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5-c7) */ - + MULTIPLY((INT32) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */ - - /* Final output stage */ - - outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0, - CONST_BITS+PASS1_BITS+3+2) - & RANGE_MASK]; - outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0, - CONST_BITS+PASS1_BITS+3+2) - & RANGE_MASK]; - - wsptr += DCTSIZE; /* advance pointer to next row */ - } -} - - -/* - * Perform dequantization and inverse DCT on one block of coefficients, - * producing a reduced-size 1x1 output block. - */ - -GLOBAL(void) -jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col) -{ - int dcval; - ISLOW_MULT_TYPE * quantptr; - JSAMPLE *range_limit = IDCT_range_limit(cinfo); - SHIFT_TEMPS - - /* We hardly need an inverse DCT routine for this: just take the - * average pixel value, which is one-eighth of the DC coefficient. - */ - quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table; - dcval = DEQUANTIZE(coef_block[0], quantptr[0]); - dcval = (int) DESCALE((INT32) dcval, 3); - - output_buf[0][output_col] = range_limit[dcval & RANGE_MASK]; -} - -#endif /* IDCT_SCALING_SUPPORTED */ diff --git a/oversampling/WDL/jpeglib/jinclude.h b/oversampling/WDL/jpeglib/jinclude.h deleted file mode 100644 index 0a4f151..0000000 --- a/oversampling/WDL/jpeglib/jinclude.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * jinclude.h - * - * Copyright (C) 1991-1994, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file exists to provide a single place to fix any problems with - * including the wrong system include files. (Common problems are taken - * care of by the standard jconfig symbols, but on really weird systems - * you may have to edit this file.) - * - * NOTE: this file is NOT intended to be included by applications using the - * JPEG library. Most applications need only include jpeglib.h. - */ - - -/* Include auto-config file to find out which system include files we need. */ - -#include "jconfig.h" /* auto configuration options */ -#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ - -/* - * We need the NULL macro and size_t typedef. - * On an ANSI-conforming system it is sufficient to include . - * Otherwise, we get them from or ; we may have to - * pull in as well. - * Note that the core JPEG library does not require ; - * only the default error handler and data source/destination modules do. - * But we must pull it in because of the references to FILE in jpeglib.h. - * You can remove those references if you want to compile without . - */ - -#ifdef HAVE_STDDEF_H -#include -#endif - -#ifdef HAVE_STDLIB_H -#include -#endif - -#ifdef NEED_SYS_TYPES_H -#include -#endif - -#include - -/* - * We need memory copying and zeroing functions, plus strncpy(). - * ANSI and System V implementations declare these in . - * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). - * Some systems may declare memset and memcpy in . - * - * NOTE: we assume the size parameters to these functions are of type size_t. - * Change the casts in these macros if not! - */ - -#ifdef NEED_BSD_STRINGS - -#include -#define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) -#define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) - -#else /* not BSD, assume ANSI/SysV string lib */ - -#include -#define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) -#define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) - -#endif - -/* - * In ANSI C, and indeed any rational implementation, size_t is also the - * type returned by sizeof(). However, it seems there are some irrational - * implementations out there, in which sizeof() returns an int even though - * size_t is defined as long or unsigned long. To ensure consistent results - * we always use this SIZEOF() macro in place of using sizeof() directly. - */ - -#define SIZEOF(object) ((size_t) sizeof(object)) - -/* - * The modules that use fread() and fwrite() always invoke them through - * these macros. On some systems you may need to twiddle the argument casts. - * CAUTION: argument order is different from underlying functions! - */ - -#define JFREAD(file,buf,sizeofbuf) \ - ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) -#define JFWRITE(file,buf,sizeofbuf) \ - ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) diff --git a/oversampling/WDL/jpeglib/jmemmgr.c b/oversampling/WDL/jpeglib/jmemmgr.c deleted file mode 100644 index d801b32..0000000 --- a/oversampling/WDL/jpeglib/jmemmgr.c +++ /dev/null @@ -1,1118 +0,0 @@ -/* - * jmemmgr.c - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains the JPEG system-independent memory management - * routines. This code is usable across a wide variety of machines; most - * of the system dependencies have been isolated in a separate file. - * The major functions provided here are: - * * pool-based allocation and freeing of memory; - * * policy decisions about how to divide available memory among the - * virtual arrays; - * * control logic for swapping virtual arrays between main memory and - * backing storage. - * The separate system-dependent file provides the actual backing-storage - * access code, and it contains the policy decision about how much total - * main memory to use. - * This file is system-dependent in the sense that some of its functions - * are unnecessary in some systems. For example, if there is enough virtual - * memory so that backing storage will never be used, much of the virtual - * array control logic could be removed. (Of course, if you have that much - * memory then you shouldn't care about a little bit of unused code...) - */ - -#define JPEG_INTERNALS -#define AM_MEMORY_MANAGER /* we define jvirt_Xarray_control structs */ -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef NO_GETENV -#ifndef HAVE_STDLIB_H /* should declare getenv() */ -extern char * getenv JPP((const char * name)); -#endif -#endif - - -/* - * Some important notes: - * The allocation routines provided here must never return NULL. - * They should exit to error_exit if unsuccessful. - * - * It's not a good idea to try to merge the sarray and barray routines, - * even though they are textually almost the same, because samples are - * usually stored as bytes while coefficients are shorts or ints. Thus, - * in machines where byte pointers have a different representation from - * word pointers, the resulting machine code could not be the same. - */ - - -/* - * Many machines require storage alignment: longs must start on 4-byte - * boundaries, doubles on 8-byte boundaries, etc. On such machines, malloc() - * always returns pointers that are multiples of the worst-case alignment - * requirement, and we had better do so too. - * There isn't any really portable way to determine the worst-case alignment - * requirement. This module assumes that the alignment requirement is - * multiples of sizeof(ALIGN_TYPE). - * By default, we define ALIGN_TYPE as double. This is necessary on some - * workstations (where doubles really do need 8-byte alignment) and will work - * fine on nearly everything. If your machine has lesser alignment needs, - * you can save a few bytes by making ALIGN_TYPE smaller. - * The only place I know of where this will NOT work is certain Macintosh - * 680x0 compilers that define double as a 10-byte IEEE extended float. - * Doing 10-byte alignment is counterproductive because longwords won't be - * aligned well. Put "#define ALIGN_TYPE long" in jconfig.h if you have - * such a compiler. - */ - -#ifndef ALIGN_TYPE /* so can override from jconfig.h */ -#define ALIGN_TYPE double -#endif - - -/* - * We allocate objects from "pools", where each pool is gotten with a single - * request to jpeg_get_small() or jpeg_get_large(). There is no per-object - * overhead within a pool, except for alignment padding. Each pool has a - * header with a link to the next pool of the same class. - * Small and large pool headers are identical except that the latter's - * link pointer must be FAR on 80x86 machines. - * Notice that the "real" header fields are union'ed with a dummy ALIGN_TYPE - * field. This forces the compiler to make SIZEOF(small_pool_hdr) a multiple - * of the alignment requirement of ALIGN_TYPE. - */ - -typedef union small_pool_struct * small_pool_ptr; - -typedef union small_pool_struct { - struct { - small_pool_ptr next; /* next in list of pools */ - size_t bytes_used; /* how many bytes already used within pool */ - size_t bytes_left; /* bytes still available in this pool */ - } hdr; - ALIGN_TYPE dummy; /* included in union to ensure alignment */ -} small_pool_hdr; - -typedef union large_pool_struct FAR * large_pool_ptr; - -typedef union large_pool_struct { - struct { - large_pool_ptr next; /* next in list of pools */ - size_t bytes_used; /* how many bytes already used within pool */ - size_t bytes_left; /* bytes still available in this pool */ - } hdr; - ALIGN_TYPE dummy; /* included in union to ensure alignment */ -} large_pool_hdr; - - -/* - * Here is the full definition of a memory manager object. - */ - -typedef struct { - struct jpeg_memory_mgr pub; /* public fields */ - - /* Each pool identifier (lifetime class) names a linked list of pools. */ - small_pool_ptr small_list[JPOOL_NUMPOOLS]; - large_pool_ptr large_list[JPOOL_NUMPOOLS]; - - /* Since we only have one lifetime class of virtual arrays, only one - * linked list is necessary (for each datatype). Note that the virtual - * array control blocks being linked together are actually stored somewhere - * in the small-pool list. - */ - jvirt_sarray_ptr virt_sarray_list; - jvirt_barray_ptr virt_barray_list; - - /* This counts total space obtained from jpeg_get_small/large */ - long total_space_allocated; - - /* alloc_sarray and alloc_barray set this value for use by virtual - * array routines. - */ - JDIMENSION last_rowsperchunk; /* from most recent alloc_sarray/barray */ -} my_memory_mgr; - -typedef my_memory_mgr * my_mem_ptr; - - -/* - * The control blocks for virtual arrays. - * Note that these blocks are allocated in the "small" pool area. - * System-dependent info for the associated backing store (if any) is hidden - * inside the backing_store_info struct. - */ - -struct jvirt_sarray_control { - JSAMPARRAY mem_buffer; /* => the in-memory buffer */ - JDIMENSION rows_in_array; /* total virtual array height */ - JDIMENSION samplesperrow; /* width of array (and of memory buffer) */ - JDIMENSION maxaccess; /* max rows accessed by access_virt_sarray */ - JDIMENSION rows_in_mem; /* height of memory buffer */ - JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ - JDIMENSION cur_start_row; /* first logical row # in the buffer */ - JDIMENSION first_undef_row; /* row # of first uninitialized row */ - boolean pre_zero; /* pre-zero mode requested? */ - boolean dirty; /* do current buffer contents need written? */ - boolean b_s_open; /* is backing-store data valid? */ - jvirt_sarray_ptr next; /* link to next virtual sarray control block */ - backing_store_info b_s_info; /* System-dependent control info */ -}; - -struct jvirt_barray_control { - JBLOCKARRAY mem_buffer; /* => the in-memory buffer */ - JDIMENSION rows_in_array; /* total virtual array height */ - JDIMENSION blocksperrow; /* width of array (and of memory buffer) */ - JDIMENSION maxaccess; /* max rows accessed by access_virt_barray */ - JDIMENSION rows_in_mem; /* height of memory buffer */ - JDIMENSION rowsperchunk; /* allocation chunk size in mem_buffer */ - JDIMENSION cur_start_row; /* first logical row # in the buffer */ - JDIMENSION first_undef_row; /* row # of first uninitialized row */ - boolean pre_zero; /* pre-zero mode requested? */ - boolean dirty; /* do current buffer contents need written? */ - boolean b_s_open; /* is backing-store data valid? */ - jvirt_barray_ptr next; /* link to next virtual barray control block */ - backing_store_info b_s_info; /* System-dependent control info */ -}; - - -#ifdef MEM_STATS /* optional extra stuff for statistics */ - -LOCAL(void) -print_mem_stats (j_common_ptr cinfo, int pool_id) -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - small_pool_ptr shdr_ptr; - large_pool_ptr lhdr_ptr; - - /* Since this is only a debugging stub, we can cheat a little by using - * fprintf directly rather than going through the trace message code. - * This is helpful because message parm array can't handle longs. - */ - fprintf(stderr, "Freeing pool %d, total space = %ld\n", - pool_id, mem->total_space_allocated); - - for (lhdr_ptr = mem->large_list[pool_id]; lhdr_ptr != NULL; - lhdr_ptr = lhdr_ptr->hdr.next) { - fprintf(stderr, " Large chunk used %ld\n", - (long) lhdr_ptr->hdr.bytes_used); - } - - for (shdr_ptr = mem->small_list[pool_id]; shdr_ptr != NULL; - shdr_ptr = shdr_ptr->hdr.next) { - fprintf(stderr, " Small chunk used %ld free %ld\n", - (long) shdr_ptr->hdr.bytes_used, - (long) shdr_ptr->hdr.bytes_left); - } -} - -#endif /* MEM_STATS */ - - -LOCAL(void) -out_of_memory (j_common_ptr cinfo, int which) -/* Report an out-of-memory error and stop execution */ -/* If we compiled MEM_STATS support, report alloc requests before dying */ -{ -#ifdef MEM_STATS - cinfo->err->trace_level = 2; /* force self_destruct to report stats */ -#endif - ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, which); -} - - -/* - * Allocation of "small" objects. - * - * For these, we use pooled storage. When a new pool must be created, - * we try to get enough space for the current request plus a "slop" factor, - * where the slop will be the amount of leftover space in the new pool. - * The speed vs. space tradeoff is largely determined by the slop values. - * A different slop value is provided for each pool class (lifetime), - * and we also distinguish the first pool of a class from later ones. - * NOTE: the values given work fairly well on both 16- and 32-bit-int - * machines, but may be too small if longs are 64 bits or more. - */ - -static const size_t first_pool_slop[JPOOL_NUMPOOLS] = -{ - 1600, /* first PERMANENT pool */ - 16000 /* first IMAGE pool */ -}; - -static const size_t extra_pool_slop[JPOOL_NUMPOOLS] = -{ - 0, /* additional PERMANENT pools */ - 5000 /* additional IMAGE pools */ -}; - -#define MIN_SLOP 50 /* greater than 0 to avoid futile looping */ - - -METHODDEF(void *) -alloc_small (j_common_ptr cinfo, int pool_id, size_t sizeofobject) -/* Allocate a "small" object */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - small_pool_ptr hdr_ptr, prev_hdr_ptr; - char * data_ptr; - size_t odd_bytes, min_request, slop; - - /* Check for unsatisfiable request (do now to ensure no overflow below) */ - if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(small_pool_hdr))) - out_of_memory(cinfo, 1); /* request exceeds malloc's ability */ - - /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ - odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); - if (odd_bytes > 0) - sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; - - /* See if space is available in any existing pool */ - if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - prev_hdr_ptr = NULL; - hdr_ptr = mem->small_list[pool_id]; - while (hdr_ptr != NULL) { - if (hdr_ptr->hdr.bytes_left >= sizeofobject) - break; /* found pool with enough space */ - prev_hdr_ptr = hdr_ptr; - hdr_ptr = hdr_ptr->hdr.next; - } - - /* Time to make a new pool? */ - if (hdr_ptr == NULL) { - /* min_request is what we need now, slop is what will be leftover */ - min_request = sizeofobject + SIZEOF(small_pool_hdr); - if (prev_hdr_ptr == NULL) /* first pool in class? */ - slop = first_pool_slop[pool_id]; - else - slop = extra_pool_slop[pool_id]; - /* Don't ask for more than MAX_ALLOC_CHUNK */ - if (slop > (size_t) (MAX_ALLOC_CHUNK-min_request)) - slop = (size_t) (MAX_ALLOC_CHUNK-min_request); - /* Try to get space, if fail reduce slop and try again */ - for (;;) { - hdr_ptr = (small_pool_ptr) jpeg_get_small(cinfo, min_request + slop); - if (hdr_ptr != NULL) - break; - slop /= 2; - if (slop < MIN_SLOP) /* give up when it gets real small */ - out_of_memory(cinfo, 2); /* jpeg_get_small failed */ - } - mem->total_space_allocated += min_request + slop; - /* Success, initialize the new pool header and add to end of list */ - hdr_ptr->hdr.next = NULL; - hdr_ptr->hdr.bytes_used = 0; - hdr_ptr->hdr.bytes_left = sizeofobject + slop; - if (prev_hdr_ptr == NULL) /* first pool in class? */ - mem->small_list[pool_id] = hdr_ptr; - else - prev_hdr_ptr->hdr.next = hdr_ptr; - } - - /* OK, allocate the object from the current pool */ - data_ptr = (char *) (hdr_ptr + 1); /* point to first data byte in pool */ - data_ptr += hdr_ptr->hdr.bytes_used; /* point to place for object */ - hdr_ptr->hdr.bytes_used += sizeofobject; - hdr_ptr->hdr.bytes_left -= sizeofobject; - - return (void *) data_ptr; -} - - -/* - * Allocation of "large" objects. - * - * The external semantics of these are the same as "small" objects, - * except that FAR pointers are used on 80x86. However the pool - * management heuristics are quite different. We assume that each - * request is large enough that it may as well be passed directly to - * jpeg_get_large; the pool management just links everything together - * so that we can free it all on demand. - * Note: the major use of "large" objects is in JSAMPARRAY and JBLOCKARRAY - * structures. The routines that create these structures (see below) - * deliberately bunch rows together to ensure a large request size. - */ - -METHODDEF(void FAR *) -alloc_large (j_common_ptr cinfo, int pool_id, size_t sizeofobject) -/* Allocate a "large" object */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - large_pool_ptr hdr_ptr; - size_t odd_bytes; - - /* Check for unsatisfiable request (do now to ensure no overflow below) */ - if (sizeofobject > (size_t) (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr))) - out_of_memory(cinfo, 3); /* request exceeds malloc's ability */ - - /* Round up the requested size to a multiple of SIZEOF(ALIGN_TYPE) */ - odd_bytes = sizeofobject % SIZEOF(ALIGN_TYPE); - if (odd_bytes > 0) - sizeofobject += SIZEOF(ALIGN_TYPE) - odd_bytes; - - /* Always make a new pool */ - if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - - hdr_ptr = (large_pool_ptr) jpeg_get_large(cinfo, sizeofobject + - SIZEOF(large_pool_hdr)); - if (hdr_ptr == NULL) - out_of_memory(cinfo, 4); /* jpeg_get_large failed */ - mem->total_space_allocated += sizeofobject + SIZEOF(large_pool_hdr); - - /* Success, initialize the new pool header and add to list */ - hdr_ptr->hdr.next = mem->large_list[pool_id]; - /* We maintain space counts in each pool header for statistical purposes, - * even though they are not needed for allocation. - */ - hdr_ptr->hdr.bytes_used = sizeofobject; - hdr_ptr->hdr.bytes_left = 0; - mem->large_list[pool_id] = hdr_ptr; - - return (void FAR *) (hdr_ptr + 1); /* point to first data byte in pool */ -} - - -/* - * Creation of 2-D sample arrays. - * The pointers are in near heap, the samples themselves in FAR heap. - * - * To minimize allocation overhead and to allow I/O of large contiguous - * blocks, we allocate the sample rows in groups of as many rows as possible - * without exceeding MAX_ALLOC_CHUNK total bytes per allocation request. - * NB: the virtual array control routines, later in this file, know about - * this chunking of rows. The rowsperchunk value is left in the mem manager - * object so that it can be saved away if this sarray is the workspace for - * a virtual array. - */ - -METHODDEF(JSAMPARRAY) -alloc_sarray (j_common_ptr cinfo, int pool_id, - JDIMENSION samplesperrow, JDIMENSION numrows) -/* Allocate a 2-D sample array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - JSAMPARRAY result; - JSAMPROW workspace; - JDIMENSION rowsperchunk, currow, i; - long ltemp; - - /* Calculate max # of rows allowed in one allocation chunk */ - ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / - ((long) samplesperrow * SIZEOF(JSAMPLE)); - if (ltemp <= 0) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - if (ltemp < (long) numrows) - rowsperchunk = (JDIMENSION) ltemp; - else - rowsperchunk = numrows; - mem->last_rowsperchunk = rowsperchunk; - - /* Get space for row pointers (small object) */ - result = (JSAMPARRAY) alloc_small(cinfo, pool_id, - (size_t) (numrows * SIZEOF(JSAMPROW))); - - /* Get the rows themselves (large objects) */ - currow = 0; - while (currow < numrows) { - rowsperchunk = MIN(rowsperchunk, numrows - currow); - workspace = (JSAMPROW) alloc_large(cinfo, pool_id, - (size_t) ((size_t) rowsperchunk * (size_t) samplesperrow - * SIZEOF(JSAMPLE))); - for (i = rowsperchunk; i > 0; i--) { - result[currow++] = workspace; - workspace += samplesperrow; - } - } - - return result; -} - - -/* - * Creation of 2-D coefficient-block arrays. - * This is essentially the same as the code for sample arrays, above. - */ - -METHODDEF(JBLOCKARRAY) -alloc_barray (j_common_ptr cinfo, int pool_id, - JDIMENSION blocksperrow, JDIMENSION numrows) -/* Allocate a 2-D coefficient-block array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - JBLOCKARRAY result; - JBLOCKROW workspace; - JDIMENSION rowsperchunk, currow, i; - long ltemp; - - /* Calculate max # of rows allowed in one allocation chunk */ - ltemp = (MAX_ALLOC_CHUNK-SIZEOF(large_pool_hdr)) / - ((long) blocksperrow * SIZEOF(JBLOCK)); - if (ltemp <= 0) - ERREXIT(cinfo, JERR_WIDTH_OVERFLOW); - if (ltemp < (long) numrows) - rowsperchunk = (JDIMENSION) ltemp; - else - rowsperchunk = numrows; - mem->last_rowsperchunk = rowsperchunk; - - /* Get space for row pointers (small object) */ - result = (JBLOCKARRAY) alloc_small(cinfo, pool_id, - (size_t) (numrows * SIZEOF(JBLOCKROW))); - - /* Get the rows themselves (large objects) */ - currow = 0; - while (currow < numrows) { - rowsperchunk = MIN(rowsperchunk, numrows - currow); - workspace = (JBLOCKROW) alloc_large(cinfo, pool_id, - (size_t) ((size_t) rowsperchunk * (size_t) blocksperrow - * SIZEOF(JBLOCK))); - for (i = rowsperchunk; i > 0; i--) { - result[currow++] = workspace; - workspace += blocksperrow; - } - } - - return result; -} - - -/* - * About virtual array management: - * - * The above "normal" array routines are only used to allocate strip buffers - * (as wide as the image, but just a few rows high). Full-image-sized buffers - * are handled as "virtual" arrays. The array is still accessed a strip at a - * time, but the memory manager must save the whole array for repeated - * accesses. The intended implementation is that there is a strip buffer in - * memory (as high as is possible given the desired memory limit), plus a - * backing file that holds the rest of the array. - * - * The request_virt_array routines are told the total size of the image and - * the maximum number of rows that will be accessed at once. The in-memory - * buffer must be at least as large as the maxaccess value. - * - * The request routines create control blocks but not the in-memory buffers. - * That is postponed until realize_virt_arrays is called. At that time the - * total amount of space needed is known (approximately, anyway), so free - * memory can be divided up fairly. - * - * The access_virt_array routines are responsible for making a specific strip - * area accessible (after reading or writing the backing file, if necessary). - * Note that the access routines are told whether the caller intends to modify - * the accessed strip; during a read-only pass this saves having to rewrite - * data to disk. The access routines are also responsible for pre-zeroing - * any newly accessed rows, if pre-zeroing was requested. - * - * In current usage, the access requests are usually for nonoverlapping - * strips; that is, successive access start_row numbers differ by exactly - * num_rows = maxaccess. This means we can get good performance with simple - * buffer dump/reload logic, by making the in-memory buffer be a multiple - * of the access height; then there will never be accesses across bufferload - * boundaries. The code will still work with overlapping access requests, - * but it doesn't handle bufferload overlaps very efficiently. - */ - - -METHODDEF(jvirt_sarray_ptr) -request_virt_sarray (j_common_ptr cinfo, int pool_id, boolean pre_zero, - JDIMENSION samplesperrow, JDIMENSION numrows, - JDIMENSION maxaccess) -/* Request a virtual 2-D sample array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - jvirt_sarray_ptr result; - - /* Only IMAGE-lifetime virtual arrays are currently supported */ - if (pool_id != JPOOL_IMAGE) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - - /* get control block */ - result = (jvirt_sarray_ptr) alloc_small(cinfo, pool_id, - SIZEOF(struct jvirt_sarray_control)); - - result->mem_buffer = NULL; /* marks array not yet realized */ - result->rows_in_array = numrows; - result->samplesperrow = samplesperrow; - result->maxaccess = maxaccess; - result->pre_zero = pre_zero; - result->b_s_open = FALSE; /* no associated backing-store object */ - result->next = mem->virt_sarray_list; /* add to list of virtual arrays */ - mem->virt_sarray_list = result; - - return result; -} - - -METHODDEF(jvirt_barray_ptr) -request_virt_barray (j_common_ptr cinfo, int pool_id, boolean pre_zero, - JDIMENSION blocksperrow, JDIMENSION numrows, - JDIMENSION maxaccess) -/* Request a virtual 2-D coefficient-block array */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - jvirt_barray_ptr result; - - /* Only IMAGE-lifetime virtual arrays are currently supported */ - if (pool_id != JPOOL_IMAGE) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - - /* get control block */ - result = (jvirt_barray_ptr) alloc_small(cinfo, pool_id, - SIZEOF(struct jvirt_barray_control)); - - result->mem_buffer = NULL; /* marks array not yet realized */ - result->rows_in_array = numrows; - result->blocksperrow = blocksperrow; - result->maxaccess = maxaccess; - result->pre_zero = pre_zero; - result->b_s_open = FALSE; /* no associated backing-store object */ - result->next = mem->virt_barray_list; /* add to list of virtual arrays */ - mem->virt_barray_list = result; - - return result; -} - - -METHODDEF(void) -realize_virt_arrays (j_common_ptr cinfo) -/* Allocate the in-memory buffers for any unrealized virtual arrays */ -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - long space_per_minheight, maximum_space, avail_mem; - long minheights, max_minheights; - jvirt_sarray_ptr sptr; - jvirt_barray_ptr bptr; - - /* Compute the minimum space needed (maxaccess rows in each buffer) - * and the maximum space needed (full image height in each buffer). - * These may be of use to the system-dependent jpeg_mem_available routine. - */ - space_per_minheight = 0; - maximum_space = 0; - for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { - if (sptr->mem_buffer == NULL) { /* if not realized yet */ - space_per_minheight += (long) sptr->maxaccess * - (long) sptr->samplesperrow * SIZEOF(JSAMPLE); - maximum_space += (long) sptr->rows_in_array * - (long) sptr->samplesperrow * SIZEOF(JSAMPLE); - } - } - for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { - if (bptr->mem_buffer == NULL) { /* if not realized yet */ - space_per_minheight += (long) bptr->maxaccess * - (long) bptr->blocksperrow * SIZEOF(JBLOCK); - maximum_space += (long) bptr->rows_in_array * - (long) bptr->blocksperrow * SIZEOF(JBLOCK); - } - } - - if (space_per_minheight <= 0) - return; /* no unrealized arrays, no work */ - - /* Determine amount of memory to actually use; this is system-dependent. */ - avail_mem = jpeg_mem_available(cinfo, space_per_minheight, maximum_space, - mem->total_space_allocated); - - /* If the maximum space needed is available, make all the buffers full - * height; otherwise parcel it out with the same number of minheights - * in each buffer. - */ - if (avail_mem >= maximum_space) - max_minheights = 1000000000L; - else { - max_minheights = avail_mem / space_per_minheight; - /* If there doesn't seem to be enough space, try to get the minimum - * anyway. This allows a "stub" implementation of jpeg_mem_available(). - */ - if (max_minheights <= 0) - max_minheights = 1; - } - - /* Allocate the in-memory buffers and initialize backing store as needed. */ - - for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { - if (sptr->mem_buffer == NULL) { /* if not realized yet */ - minheights = ((long) sptr->rows_in_array - 1L) / sptr->maxaccess + 1L; - if (minheights <= max_minheights) { - /* This buffer fits in memory */ - sptr->rows_in_mem = sptr->rows_in_array; - } else { - /* It doesn't fit in memory, create backing store. */ - sptr->rows_in_mem = (JDIMENSION) (max_minheights * sptr->maxaccess); - jpeg_open_backing_store(cinfo, & sptr->b_s_info, - (long) sptr->rows_in_array * - (long) sptr->samplesperrow * - (long) SIZEOF(JSAMPLE)); - sptr->b_s_open = TRUE; - } - sptr->mem_buffer = alloc_sarray(cinfo, JPOOL_IMAGE, - sptr->samplesperrow, sptr->rows_in_mem); - sptr->rowsperchunk = mem->last_rowsperchunk; - sptr->cur_start_row = 0; - sptr->first_undef_row = 0; - sptr->dirty = FALSE; - } - } - - for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { - if (bptr->mem_buffer == NULL) { /* if not realized yet */ - minheights = ((long) bptr->rows_in_array - 1L) / bptr->maxaccess + 1L; - if (minheights <= max_minheights) { - /* This buffer fits in memory */ - bptr->rows_in_mem = bptr->rows_in_array; - } else { - /* It doesn't fit in memory, create backing store. */ - bptr->rows_in_mem = (JDIMENSION) (max_minheights * bptr->maxaccess); - jpeg_open_backing_store(cinfo, & bptr->b_s_info, - (long) bptr->rows_in_array * - (long) bptr->blocksperrow * - (long) SIZEOF(JBLOCK)); - bptr->b_s_open = TRUE; - } - bptr->mem_buffer = alloc_barray(cinfo, JPOOL_IMAGE, - bptr->blocksperrow, bptr->rows_in_mem); - bptr->rowsperchunk = mem->last_rowsperchunk; - bptr->cur_start_row = 0; - bptr->first_undef_row = 0; - bptr->dirty = FALSE; - } - } -} - - -LOCAL(void) -do_sarray_io (j_common_ptr cinfo, jvirt_sarray_ptr ptr, boolean writing) -/* Do backing store read or write of a virtual sample array */ -{ - long bytesperrow, file_offset, byte_count, rows, thisrow, i; - - bytesperrow = (long) ptr->samplesperrow * SIZEOF(JSAMPLE); - file_offset = ptr->cur_start_row * bytesperrow; - /* Loop to read or write each allocation chunk in mem_buffer */ - for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { - /* One chunk, but check for short chunk at end of buffer */ - rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); - /* Transfer no more than is currently defined */ - thisrow = (long) ptr->cur_start_row + i; - rows = MIN(rows, (long) ptr->first_undef_row - thisrow); - /* Transfer no more than fits in file */ - rows = MIN(rows, (long) ptr->rows_in_array - thisrow); - if (rows <= 0) /* this chunk might be past end of file! */ - break; - byte_count = rows * bytesperrow; - if (writing) - (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - else - (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - file_offset += byte_count; - } -} - - -LOCAL(void) -do_barray_io (j_common_ptr cinfo, jvirt_barray_ptr ptr, boolean writing) -/* Do backing store read or write of a virtual coefficient-block array */ -{ - long bytesperrow, file_offset, byte_count, rows, thisrow, i; - - bytesperrow = (long) ptr->blocksperrow * SIZEOF(JBLOCK); - file_offset = ptr->cur_start_row * bytesperrow; - /* Loop to read or write each allocation chunk in mem_buffer */ - for (i = 0; i < (long) ptr->rows_in_mem; i += ptr->rowsperchunk) { - /* One chunk, but check for short chunk at end of buffer */ - rows = MIN((long) ptr->rowsperchunk, (long) ptr->rows_in_mem - i); - /* Transfer no more than is currently defined */ - thisrow = (long) ptr->cur_start_row + i; - rows = MIN(rows, (long) ptr->first_undef_row - thisrow); - /* Transfer no more than fits in file */ - rows = MIN(rows, (long) ptr->rows_in_array - thisrow); - if (rows <= 0) /* this chunk might be past end of file! */ - break; - byte_count = rows * bytesperrow; - if (writing) - (*ptr->b_s_info.write_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - else - (*ptr->b_s_info.read_backing_store) (cinfo, & ptr->b_s_info, - (void FAR *) ptr->mem_buffer[i], - file_offset, byte_count); - file_offset += byte_count; - } -} - - -METHODDEF(JSAMPARRAY) -access_virt_sarray (j_common_ptr cinfo, jvirt_sarray_ptr ptr, - JDIMENSION start_row, JDIMENSION num_rows, - boolean writable) -/* Access the part of a virtual sample array starting at start_row */ -/* and extending for num_rows rows. writable is true if */ -/* caller intends to modify the accessed area. */ -{ - JDIMENSION end_row = start_row + num_rows; - JDIMENSION undef_row; - - /* debugging check */ - if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || - ptr->mem_buffer == NULL) - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - - /* Make the desired part of the virtual array accessible */ - if (start_row < ptr->cur_start_row || - end_row > ptr->cur_start_row+ptr->rows_in_mem) { - if (! ptr->b_s_open) - ERREXIT(cinfo, JERR_VIRTUAL_BUG); - /* Flush old buffer contents if necessary */ - if (ptr->dirty) { - do_sarray_io(cinfo, ptr, TRUE); - ptr->dirty = FALSE; - } - /* Decide what part of virtual array to access. - * Algorithm: if target address > current window, assume forward scan, - * load starting at target address. If target address < current window, - * assume backward scan, load so that target area is top of window. - * Note that when switching from forward write to forward read, will have - * start_row = 0, so the limiting case applies and we load from 0 anyway. - */ - if (start_row > ptr->cur_start_row) { - ptr->cur_start_row = start_row; - } else { - /* use long arithmetic here to avoid overflow & unsigned problems */ - long ltemp; - - ltemp = (long) end_row - (long) ptr->rows_in_mem; - if (ltemp < 0) - ltemp = 0; /* don't fall off front end of file */ - ptr->cur_start_row = (JDIMENSION) ltemp; - } - /* Read in the selected part of the array. - * During the initial write pass, we will do no actual read - * because the selected part is all undefined. - */ - do_sarray_io(cinfo, ptr, FALSE); - } - /* Ensure the accessed part of the array is defined; prezero if needed. - * To improve locality of access, we only prezero the part of the array - * that the caller is about to access, not the entire in-memory array. - */ - if (ptr->first_undef_row < end_row) { - if (ptr->first_undef_row < start_row) { - if (writable) /* writer skipped over a section of array */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - undef_row = start_row; /* but reader is allowed to read ahead */ - } else { - undef_row = ptr->first_undef_row; - } - if (writable) - ptr->first_undef_row = end_row; - if (ptr->pre_zero) { - size_t bytesperrow = (size_t) ptr->samplesperrow * SIZEOF(JSAMPLE); - undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ - end_row -= ptr->cur_start_row; - while (undef_row < end_row) { - jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); - undef_row++; - } - } else { - if (! writable) /* reader looking at undefined data */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - } - } - /* Flag the buffer dirty if caller will write in it */ - if (writable) - ptr->dirty = TRUE; - /* Return address of proper part of the buffer */ - return ptr->mem_buffer + (start_row - ptr->cur_start_row); -} - - -METHODDEF(JBLOCKARRAY) -access_virt_barray (j_common_ptr cinfo, jvirt_barray_ptr ptr, - JDIMENSION start_row, JDIMENSION num_rows, - boolean writable) -/* Access the part of a virtual block array starting at start_row */ -/* and extending for num_rows rows. writable is true if */ -/* caller intends to modify the accessed area. */ -{ - JDIMENSION end_row = start_row + num_rows; - JDIMENSION undef_row; - - /* debugging check */ - if (end_row > ptr->rows_in_array || num_rows > ptr->maxaccess || - ptr->mem_buffer == NULL) - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - - /* Make the desired part of the virtual array accessible */ - if (start_row < ptr->cur_start_row || - end_row > ptr->cur_start_row+ptr->rows_in_mem) { - if (! ptr->b_s_open) - ERREXIT(cinfo, JERR_VIRTUAL_BUG); - /* Flush old buffer contents if necessary */ - if (ptr->dirty) { - do_barray_io(cinfo, ptr, TRUE); - ptr->dirty = FALSE; - } - /* Decide what part of virtual array to access. - * Algorithm: if target address > current window, assume forward scan, - * load starting at target address. If target address < current window, - * assume backward scan, load so that target area is top of window. - * Note that when switching from forward write to forward read, will have - * start_row = 0, so the limiting case applies and we load from 0 anyway. - */ - if (start_row > ptr->cur_start_row) { - ptr->cur_start_row = start_row; - } else { - /* use long arithmetic here to avoid overflow & unsigned problems */ - long ltemp; - - ltemp = (long) end_row - (long) ptr->rows_in_mem; - if (ltemp < 0) - ltemp = 0; /* don't fall off front end of file */ - ptr->cur_start_row = (JDIMENSION) ltemp; - } - /* Read in the selected part of the array. - * During the initial write pass, we will do no actual read - * because the selected part is all undefined. - */ - do_barray_io(cinfo, ptr, FALSE); - } - /* Ensure the accessed part of the array is defined; prezero if needed. - * To improve locality of access, we only prezero the part of the array - * that the caller is about to access, not the entire in-memory array. - */ - if (ptr->first_undef_row < end_row) { - if (ptr->first_undef_row < start_row) { - if (writable) /* writer skipped over a section of array */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - undef_row = start_row; /* but reader is allowed to read ahead */ - } else { - undef_row = ptr->first_undef_row; - } - if (writable) - ptr->first_undef_row = end_row; - if (ptr->pre_zero) { - size_t bytesperrow = (size_t) ptr->blocksperrow * SIZEOF(JBLOCK); - undef_row -= ptr->cur_start_row; /* make indexes relative to buffer */ - end_row -= ptr->cur_start_row; - while (undef_row < end_row) { - jzero_far((void FAR *) ptr->mem_buffer[undef_row], bytesperrow); - undef_row++; - } - } else { - if (! writable) /* reader looking at undefined data */ - ERREXIT(cinfo, JERR_BAD_VIRTUAL_ACCESS); - } - } - /* Flag the buffer dirty if caller will write in it */ - if (writable) - ptr->dirty = TRUE; - /* Return address of proper part of the buffer */ - return ptr->mem_buffer + (start_row - ptr->cur_start_row); -} - - -/* - * Release all objects belonging to a specified pool. - */ - -METHODDEF(void) -free_pool (j_common_ptr cinfo, int pool_id) -{ - my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - small_pool_ptr shdr_ptr; - large_pool_ptr lhdr_ptr; - size_t space_freed; - - if (pool_id < 0 || pool_id >= JPOOL_NUMPOOLS) - ERREXIT1(cinfo, JERR_BAD_POOL_ID, pool_id); /* safety check */ - -#ifdef MEM_STATS - if (cinfo->err->trace_level > 1) - print_mem_stats(cinfo, pool_id); /* print pool's memory usage statistics */ -#endif - - /* If freeing IMAGE pool, close any virtual arrays first */ - if (pool_id == JPOOL_IMAGE) { - jvirt_sarray_ptr sptr; - jvirt_barray_ptr bptr; - - for (sptr = mem->virt_sarray_list; sptr != NULL; sptr = sptr->next) { - if (sptr->b_s_open) { /* there may be no backing store */ - sptr->b_s_open = FALSE; /* prevent recursive close if error */ - (*sptr->b_s_info.close_backing_store) (cinfo, & sptr->b_s_info); - } - } - mem->virt_sarray_list = NULL; - for (bptr = mem->virt_barray_list; bptr != NULL; bptr = bptr->next) { - if (bptr->b_s_open) { /* there may be no backing store */ - bptr->b_s_open = FALSE; /* prevent recursive close if error */ - (*bptr->b_s_info.close_backing_store) (cinfo, & bptr->b_s_info); - } - } - mem->virt_barray_list = NULL; - } - - /* Release large objects */ - lhdr_ptr = mem->large_list[pool_id]; - mem->large_list[pool_id] = NULL; - - while (lhdr_ptr != NULL) { - large_pool_ptr next_lhdr_ptr = lhdr_ptr->hdr.next; - space_freed = lhdr_ptr->hdr.bytes_used + - lhdr_ptr->hdr.bytes_left + - SIZEOF(large_pool_hdr); - jpeg_free_large(cinfo, (void FAR *) lhdr_ptr, space_freed); - mem->total_space_allocated -= space_freed; - lhdr_ptr = next_lhdr_ptr; - } - - /* Release small objects */ - shdr_ptr = mem->small_list[pool_id]; - mem->small_list[pool_id] = NULL; - - while (shdr_ptr != NULL) { - small_pool_ptr next_shdr_ptr = shdr_ptr->hdr.next; - space_freed = shdr_ptr->hdr.bytes_used + - shdr_ptr->hdr.bytes_left + - SIZEOF(small_pool_hdr); - jpeg_free_small(cinfo, (void *) shdr_ptr, space_freed); - mem->total_space_allocated -= space_freed; - shdr_ptr = next_shdr_ptr; - } -} - - -/* - * Close up shop entirely. - * Note that this cannot be called unless cinfo->mem is non-NULL. - */ - -METHODDEF(void) -self_destruct (j_common_ptr cinfo) -{ - int pool; - - /* Close all backing store, release all memory. - * Releasing pools in reverse order might help avoid fragmentation - * with some (brain-damaged) malloc libraries. - */ - for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { - free_pool(cinfo, pool); - } - - /* Release the memory manager control block too. */ - jpeg_free_small(cinfo, (void *) cinfo->mem, SIZEOF(my_memory_mgr)); - cinfo->mem = NULL; /* ensures I will be called only once */ - - jpeg_mem_term(cinfo); /* system-dependent cleanup */ -} - - -/* - * Memory manager initialization. - * When this is called, only the error manager pointer is valid in cinfo! - */ - -GLOBAL(void) -jinit_memory_mgr (j_common_ptr cinfo) -{ - my_mem_ptr mem; - long max_to_use; - int pool; - size_t test_mac; - - cinfo->mem = NULL; /* for safety if init fails */ - - /* Check for configuration errors. - * SIZEOF(ALIGN_TYPE) should be a power of 2; otherwise, it probably - * doesn't reflect any real hardware alignment requirement. - * The test is a little tricky: for X>0, X and X-1 have no one-bits - * in common if and only if X is a power of 2, ie has only one one-bit. - * Some compilers may give an "unreachable code" warning here; ignore it. - */ - if ((SIZEOF(ALIGN_TYPE) & (SIZEOF(ALIGN_TYPE)-1)) != 0) - ERREXIT(cinfo, JERR_BAD_ALIGN_TYPE); - /* MAX_ALLOC_CHUNK must be representable as type size_t, and must be - * a multiple of SIZEOF(ALIGN_TYPE). - * Again, an "unreachable code" warning may be ignored here. - * But a "constant too large" warning means you need to fix MAX_ALLOC_CHUNK. - */ - test_mac = (size_t) MAX_ALLOC_CHUNK; - if ((long) test_mac != MAX_ALLOC_CHUNK || - (MAX_ALLOC_CHUNK % SIZEOF(ALIGN_TYPE)) != 0) - ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK); - - max_to_use = jpeg_mem_init(cinfo); /* system-dependent initialization */ - - /* Attempt to allocate memory manager's control block */ - mem = (my_mem_ptr) jpeg_get_small(cinfo, SIZEOF(my_memory_mgr)); - - if (mem == NULL) { - jpeg_mem_term(cinfo); /* system-dependent cleanup */ - ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 0); - } - - /* OK, fill in the method pointers */ - mem->pub.alloc_small = alloc_small; - mem->pub.alloc_large = alloc_large; - mem->pub.alloc_sarray = alloc_sarray; - mem->pub.alloc_barray = alloc_barray; - mem->pub.request_virt_sarray = request_virt_sarray; - mem->pub.request_virt_barray = request_virt_barray; - mem->pub.realize_virt_arrays = realize_virt_arrays; - mem->pub.access_virt_sarray = access_virt_sarray; - mem->pub.access_virt_barray = access_virt_barray; - mem->pub.free_pool = free_pool; - mem->pub.self_destruct = self_destruct; - - /* Make MAX_ALLOC_CHUNK accessible to other modules */ - mem->pub.max_alloc_chunk = MAX_ALLOC_CHUNK; - - /* Initialize working state */ - mem->pub.max_memory_to_use = max_to_use; - - for (pool = JPOOL_NUMPOOLS-1; pool >= JPOOL_PERMANENT; pool--) { - mem->small_list[pool] = NULL; - mem->large_list[pool] = NULL; - } - mem->virt_sarray_list = NULL; - mem->virt_barray_list = NULL; - - mem->total_space_allocated = SIZEOF(my_memory_mgr); - - /* Declare ourselves open for business */ - cinfo->mem = & mem->pub; - - /* Check for an environment variable JPEGMEM; if found, override the - * default max_memory setting from jpeg_mem_init. Note that the - * surrounding application may again override this value. - * If your system doesn't support getenv(), define NO_GETENV to disable - * this feature. - */ -#ifndef NO_GETENV - { char * memenv; - - if ((memenv = getenv("JPEGMEM")) != NULL) { - char ch = 'x'; - - if (sscanf(memenv, "%ld%c", &max_to_use, &ch) > 0) { - if (ch == 'm' || ch == 'M') - max_to_use *= 1000L; - mem->pub.max_memory_to_use = max_to_use * 1000L; - } - } - } -#endif - -} diff --git a/oversampling/WDL/jpeglib/jmemnobs.c b/oversampling/WDL/jpeglib/jmemnobs.c deleted file mode 100644 index eb8c337..0000000 --- a/oversampling/WDL/jpeglib/jmemnobs.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * jmemnobs.c - * - * Copyright (C) 1992-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides a really simple implementation of the system- - * dependent portion of the JPEG memory manager. This implementation - * assumes that no backing-store files are needed: all required space - * can be obtained from malloc(). - * This is very portable in the sense that it'll compile on almost anything, - * but you'd better have lots of main memory (or virtual memory) if you want - * to process big images. - * Note that the max_memory_to_use option is ignored by this implementation. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" -#include "jmemsys.h" /* import the system-dependent declarations */ - -#ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ -extern void * malloc JPP((size_t size)); -extern void free JPP((void *ptr)); -#endif - - -/* - * Memory allocation and freeing are controlled by the regular library - * routines malloc() and free(). - */ - -GLOBAL(void *) -jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * "Large" objects are treated the same as "small" ones. - * NB: although we include FAR keywords in the routine declarations, - * this file won't actually work in 80x86 small/medium model; at least, - * you probably won't be able to process useful-size images in only 64KB. - */ - -GLOBAL(void FAR *) -jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) -{ - return (void FAR *) malloc(sizeofobject); -} - -GLOBAL(void) -jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) -{ - free(object); -} - - -/* - * This routine computes the total memory space available for allocation. - * Here we always say, "we got all you want bud!" - */ - -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) -{ - return max_bytes_needed; -} - - -/* - * Backing store (temporary file) management. - * Since jpeg_mem_available always promised the moon, - * this should never be called and we can just error out. - */ - -GLOBAL(void) -jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, - long total_bytes_needed) -{ - ERREXIT(cinfo, JERR_NO_BACKING_STORE); -} - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. Here, there isn't any. - */ - -GLOBAL(long) -jpeg_mem_init (j_common_ptr cinfo) -{ - return 0; /* just set max_memory_to_use to 0 */ -} - -GLOBAL(void) -jpeg_mem_term (j_common_ptr cinfo) -{ - /* no work */ -} diff --git a/oversampling/WDL/jpeglib/jmemsys.h b/oversampling/WDL/jpeglib/jmemsys.h deleted file mode 100644 index 6c3c6d3..0000000 --- a/oversampling/WDL/jpeglib/jmemsys.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - * jmemsys.h - * - * Copyright (C) 1992-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This include file defines the interface between the system-independent - * and system-dependent portions of the JPEG memory manager. No other - * modules need include it. (The system-independent portion is jmemmgr.c; - * there are several different versions of the system-dependent portion.) - * - * This file works as-is for the system-dependent memory managers supplied - * in the IJG distribution. You may need to modify it if you write a - * custom memory manager. If system-dependent changes are needed in - * this file, the best method is to #ifdef them based on a configuration - * symbol supplied in jconfig.h, as we have done with USE_MSDOS_MEMMGR - * and USE_MAC_MEMMGR. - */ - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_get_small jGetSmall -#define jpeg_free_small jFreeSmall -#define jpeg_get_large jGetLarge -#define jpeg_free_large jFreeLarge -#define jpeg_mem_available jMemAvail -#define jpeg_open_backing_store jOpenBackStore -#define jpeg_mem_init jMemInit -#define jpeg_mem_term jMemTerm -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* - * These two functions are used to allocate and release small chunks of - * memory. (Typically the total amount requested through jpeg_get_small is - * no more than 20K or so; this will be requested in chunks of a few K each.) - * Behavior should be the same as for the standard library functions malloc - * and free; in particular, jpeg_get_small must return NULL on failure. - * On most systems, these ARE malloc and free. jpeg_free_small is passed the - * size of the object being freed, just in case it's needed. - * On an 80x86 machine using small-data memory model, these manage near heap. - */ - -EXTERN(void *) jpeg_get_small JPP((j_common_ptr cinfo, size_t sizeofobject)); -EXTERN(void) jpeg_free_small JPP((j_common_ptr cinfo, void * object, - size_t sizeofobject)); - -/* - * These two functions are used to allocate and release large chunks of - * memory (up to the total free space designated by jpeg_mem_available). - * The interface is the same as above, except that on an 80x86 machine, - * far pointers are used. On most other machines these are identical to - * the jpeg_get/free_small routines; but we keep them separate anyway, - * in case a different allocation strategy is desirable for large chunks. - */ - -EXTERN(void FAR *) jpeg_get_large JPP((j_common_ptr cinfo, - size_t sizeofobject)); -EXTERN(void) jpeg_free_large JPP((j_common_ptr cinfo, void FAR * object, - size_t sizeofobject)); - -/* - * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may - * be requested in a single call to jpeg_get_large (and jpeg_get_small for that - * matter, but that case should never come into play). This macro is needed - * to model the 64Kb-segment-size limit of far addressing on 80x86 machines. - * On those machines, we expect that jconfig.h will provide a proper value. - * On machines with 32-bit flat address spaces, any large constant may be used. - * - * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type - * size_t and will be a multiple of sizeof(align_type). - */ - -#ifndef MAX_ALLOC_CHUNK /* may be overridden in jconfig.h */ -#define MAX_ALLOC_CHUNK 1000000000L -#endif - -/* - * This routine computes the total space still available for allocation by - * jpeg_get_large. If more space than this is needed, backing store will be - * used. NOTE: any memory already allocated must not be counted. - * - * There is a minimum space requirement, corresponding to the minimum - * feasible buffer sizes; jmemmgr.c will request that much space even if - * jpeg_mem_available returns zero. The maximum space needed, enough to hold - * all working storage in memory, is also passed in case it is useful. - * Finally, the total space already allocated is passed. If no better - * method is available, cinfo->mem->max_memory_to_use - already_allocated - * is often a suitable calculation. - * - * It is OK for jpeg_mem_available to underestimate the space available - * (that'll just lead to more backing-store access than is really necessary). - * However, an overestimate will lead to failure. Hence it's wise to subtract - * a slop factor from the true available space. 5% should be enough. - * - * On machines with lots of virtual memory, any large constant may be returned. - * Conversely, zero may be returned to always use the minimum amount of memory. - */ - -EXTERN(long) jpeg_mem_available JPP((j_common_ptr cinfo, - long min_bytes_needed, - long max_bytes_needed, - long already_allocated)); - - -/* - * This structure holds whatever state is needed to access a single - * backing-store object. The read/write/close method pointers are called - * by jmemmgr.c to manipulate the backing-store object; all other fields - * are private to the system-dependent backing store routines. - */ - -#define TEMP_NAME_LENGTH 64 /* max length of a temporary file's name */ - - -#ifdef USE_MSDOS_MEMMGR /* DOS-specific junk */ - -typedef unsigned short XMSH; /* type of extended-memory handles */ -typedef unsigned short EMSH; /* type of expanded-memory handles */ - -typedef union { - short file_handle; /* DOS file handle if it's a temp file */ - XMSH xms_handle; /* handle if it's a chunk of XMS */ - EMSH ems_handle; /* handle if it's a chunk of EMS */ -} handle_union; - -#endif /* USE_MSDOS_MEMMGR */ - -#ifdef USE_MAC_MEMMGR /* Mac-specific junk */ -#include -#endif /* USE_MAC_MEMMGR */ - - -typedef struct backing_store_struct * backing_store_ptr; - -typedef struct backing_store_struct { - /* Methods for reading/writing/closing this backing-store object */ - JMETHOD(void, read_backing_store, (j_common_ptr cinfo, - backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count)); - JMETHOD(void, write_backing_store, (j_common_ptr cinfo, - backing_store_ptr info, - void FAR * buffer_address, - long file_offset, long byte_count)); - JMETHOD(void, close_backing_store, (j_common_ptr cinfo, - backing_store_ptr info)); - - /* Private fields for system-dependent backing-store management */ -#ifdef USE_MSDOS_MEMMGR - /* For the MS-DOS manager (jmemdos.c), we need: */ - handle_union handle; /* reference to backing-store storage object */ - char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ -#else -#ifdef USE_MAC_MEMMGR - /* For the Mac manager (jmemmac.c), we need: */ - short temp_file; /* file reference number to temp file */ - FSSpec tempSpec; /* the FSSpec for the temp file */ - char temp_name[TEMP_NAME_LENGTH]; /* name if it's a file */ -#else - /* For a typical implementation with temp files, we need: */ - FILE * temp_file; /* stdio reference to temp file */ - char temp_name[TEMP_NAME_LENGTH]; /* name of temp file */ -#endif -#endif -} backing_store_info; - - -/* - * Initial opening of a backing-store object. This must fill in the - * read/write/close pointers in the object. The read/write routines - * may take an error exit if the specified maximum file size is exceeded. - * (If jpeg_mem_available always returns a large value, this routine can - * just take an error exit.) - */ - -EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo, - backing_store_ptr info, - long total_bytes_needed)); - - -/* - * These routines take care of any system-dependent initialization and - * cleanup required. jpeg_mem_init will be called before anything is - * allocated (and, therefore, nothing in cinfo is of use except the error - * manager pointer). It should return a suitable default value for - * max_memory_to_use; this may subsequently be overridden by the surrounding - * application. (Note that max_memory_to_use is only important if - * jpeg_mem_available chooses to consult it ... no one else will.) - * jpeg_mem_term may assume that all requested memory has been freed and that - * all opened backing-store objects have been closed. - */ - -EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo)); -EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo)); diff --git a/oversampling/WDL/jpeglib/jmorecfg.h b/oversampling/WDL/jpeglib/jmorecfg.h deleted file mode 100644 index 54a7d1c..0000000 --- a/oversampling/WDL/jpeglib/jmorecfg.h +++ /dev/null @@ -1,363 +0,0 @@ -/* - * jmorecfg.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains additional configuration options that customize the - * JPEG software for special applications or support machine-dependent - * optimizations. Most users will not need to touch this file. - */ - - -/* - * Define BITS_IN_JSAMPLE as either - * 8 for 8-bit sample values (the usual setting) - * 12 for 12-bit sample values - * Only 8 and 12 are legal data precisions for lossy JPEG according to the - * JPEG standard, and the IJG code does not support anything else! - * We do not support run-time selection of data precision, sorry. - */ - -#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ - - -/* - * Maximum number of components (color channels) allowed in JPEG image. - * To meet the letter of the JPEG spec, set this to 255. However, darn - * few applications need more than 4 channels (maybe 5 for CMYK + alpha - * mask). We recommend 10 as a reasonable compromise; use 4 if you are - * really short on memory. (Each allowed component costs a hundred or so - * bytes of storage, whether actually used in an image or not.) - */ - -#define MAX_COMPONENTS 10 /* maximum number of image components */ - - -/* - * Basic data types. - * You may need to change these if you have a machine with unusual data - * type sizes; for example, "char" not 8 bits, "short" not 16 bits, - * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, - * but it had better be at least 16. - */ - -/* Representation of a single sample (pixel element value). - * We frequently allocate large arrays of these, so it's important to keep - * them small. But if you have memory to burn and access to char or short - * arrays is very slow on your hardware, you might want to change these. - */ - -#if BITS_IN_JSAMPLE == 8 -/* JSAMPLE should be the smallest type that will hold the values 0..255. - * You can use a signed char by having GETJSAMPLE mask it with 0xFF. - */ - -#ifdef HAVE_UNSIGNED_CHAR - -typedef unsigned char JSAMPLE; -#define GETJSAMPLE(value) ((int) (value)) - -#else /* not HAVE_UNSIGNED_CHAR */ - -typedef char JSAMPLE; -#ifdef CHAR_IS_UNSIGNED -#define GETJSAMPLE(value) ((int) (value)) -#else -#define GETJSAMPLE(value) ((int) (value) & 0xFF) -#endif /* CHAR_IS_UNSIGNED */ - -#endif /* HAVE_UNSIGNED_CHAR */ - -#define MAXJSAMPLE 255 -#define CENTERJSAMPLE 128 - -#endif /* BITS_IN_JSAMPLE == 8 */ - - -#if BITS_IN_JSAMPLE == 12 -/* JSAMPLE should be the smallest type that will hold the values 0..4095. - * On nearly all machines "short" will do nicely. - */ - -typedef short JSAMPLE; -#define GETJSAMPLE(value) ((int) (value)) - -#define MAXJSAMPLE 4095 -#define CENTERJSAMPLE 2048 - -#endif /* BITS_IN_JSAMPLE == 12 */ - - -/* Representation of a DCT frequency coefficient. - * This should be a signed value of at least 16 bits; "short" is usually OK. - * Again, we allocate large arrays of these, but you can change to int - * if you have memory to burn and "short" is really slow. - */ - -typedef short JCOEF; - - -/* Compressed datastreams are represented as arrays of JOCTET. - * These must be EXACTLY 8 bits wide, at least once they are written to - * external storage. Note that when using the stdio data source/destination - * managers, this is also the data type passed to fread/fwrite. - */ - -#ifdef HAVE_UNSIGNED_CHAR - -typedef unsigned char JOCTET; -#define GETJOCTET(value) (value) - -#else /* not HAVE_UNSIGNED_CHAR */ - -typedef char JOCTET; -#ifdef CHAR_IS_UNSIGNED -#define GETJOCTET(value) (value) -#else -#define GETJOCTET(value) ((value) & 0xFF) -#endif /* CHAR_IS_UNSIGNED */ - -#endif /* HAVE_UNSIGNED_CHAR */ - - -/* These typedefs are used for various table entries and so forth. - * They must be at least as wide as specified; but making them too big - * won't cost a huge amount of memory, so we don't provide special - * extraction code like we did for JSAMPLE. (In other words, these - * typedefs live at a different point on the speed/space tradeoff curve.) - */ - -/* UINT8 must hold at least the values 0..255. */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char UINT8; -#else /* not HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char UINT8; -#else /* not CHAR_IS_UNSIGNED */ -typedef short UINT8; -#endif /* CHAR_IS_UNSIGNED */ -#endif /* HAVE_UNSIGNED_CHAR */ - -/* UINT16 must hold at least the values 0..65535. */ - -#ifdef HAVE_UNSIGNED_SHORT -typedef unsigned short UINT16; -#else /* not HAVE_UNSIGNED_SHORT */ -typedef unsigned int UINT16; -#endif /* HAVE_UNSIGNED_SHORT */ - -/* INT16 must hold at least the values -32768..32767. */ - -#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ -typedef short INT16; -#endif - -/* INT32 must hold at least signed 32-bit values. */ - -#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ -typedef long INT32; -#endif - -/* Datatype used for image dimensions. The JPEG standard only supports - * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore - * "unsigned int" is sufficient on all machines. However, if you need to - * handle larger images and you don't mind deviating from the spec, you - * can change this datatype. - */ - -typedef unsigned int JDIMENSION; - -#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ - - -/* These macros are used in all function definitions and extern declarations. - * You could modify them if you need to change function linkage conventions; - * in particular, you'll need to do that to make the library a Windows DLL. - * Another application is to make all functions global for use with debuggers - * or code profilers that require it. - */ - -/* a function called through method pointers: */ -#define METHODDEF(type) static type -/* a function used only in its module: */ -#define LOCAL(type) static type -/* a function referenced thru EXTERNs: */ -#define GLOBAL(type) type -/* a reference to a GLOBAL function: */ -#define EXTERN(type) extern type - - -/* This macro is used to declare a "method", that is, a function pointer. - * We want to supply prototype parameters if the compiler can cope. - * Note that the arglist parameter must be parenthesized! - * Again, you can customize this if you need special linkage keywords. - */ - -#ifdef HAVE_PROTOTYPES -#define JMETHOD(type,methodname,arglist) type (*methodname) arglist -#else -#define JMETHOD(type,methodname,arglist) type (*methodname) () -#endif - - -/* Here is the pseudo-keyword for declaring pointers that must be "far" - * on 80x86 machines. Most of the specialized coding for 80x86 is handled - * by just saying "FAR *" where such a pointer is needed. In a few places - * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. - */ - -#ifdef NEED_FAR_POINTERS -#define FAR far -#else -#define FAR -#endif - - -/* - * On a few systems, type boolean and/or its values FALSE, TRUE may appear - * in standard header files. Or you may have conflicts with application- - * specific header files that you want to include together with these files. - * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. - */ - -#ifndef HAVE_BOOLEAN -typedef int boolean; -#endif -#ifndef FALSE /* in case these macros already exist */ -#define FALSE 0 /* values of boolean */ -#endif -#ifndef TRUE -#define TRUE 1 -#endif - - -/* - * The remaining options affect code selection within the JPEG library, - * but they don't need to be visible to most applications using the library. - * To minimize application namespace pollution, the symbols won't be - * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. - */ - -#ifdef JPEG_INTERNALS -#define JPEG_INTERNAL_OPTIONS -#endif - -#ifdef JPEG_INTERNAL_OPTIONS - - -/* - * These defines indicate whether to include various optional functions. - * Undefining some of these symbols will produce a smaller but less capable - * library. Note that you can leave certain source files out of the - * compilation/linking process if you've #undef'd the corresponding symbols. - * (You may HAVE to do that if your compiler doesn't like null source files.) - */ - -/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ - -/* Capability options common to encoder and decoder: */ - -#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ -#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ -#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ - -/* Encoder capability options: */ - -#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ -#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ -#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ -#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ -/* Note: if you selected 12-bit data precision, it is dangerous to turn off - * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit - * precision, so jchuff.c normally uses entropy optimization to compute - * usable tables for higher precision. If you don't want to do optimization, - * you'll have to supply different default Huffman tables. - * The exact same statements apply for progressive JPEG: the default tables - * don't work for progressive mode. (This may get fixed, however.) - */ -#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ - -/* Decoder capability options: */ - -#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ -#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ -#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ -#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ -#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ -#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ -#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ -#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ -#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ -#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ - -/* more capability options later, no doubt */ - - -/* - * Ordering of RGB data in scanlines passed to or from the application. - * If your application wants to deal with data in the order B,G,R, just - * change these macros. You can also deal with formats such as R,G,B,X - * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing - * the offsets will also change the order in which colormap data is organized. - * RESTRICTIONS: - * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. - * 2. These macros only affect RGB<=>YCbCr color conversion, so they are not - * useful if you are using JPEG color spaces other than YCbCr or grayscale. - * 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE - * is not 3 (they don't understand about dummy color components!). So you - * can't use color quantization if you change that value. - */ - -#define RGB_RED 0 /* Offset of Red in an RGB scanline element */ -#define RGB_GREEN 1 /* Offset of Green */ -#define RGB_BLUE 2 /* Offset of Blue */ -#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ - - -/* Definitions for speed-related optimizations. */ - - -/* If your compiler supports inline functions, define INLINE - * as the inline keyword; otherwise define it as empty. - */ - -#ifndef INLINE -#ifdef __GNUC__ /* for instance, GNU C knows about inline */ -#define INLINE __inline__ -#endif -#ifndef INLINE -#define INLINE /* default is to define it as empty */ -#endif -#endif - - -/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying - * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER - * as short on such a machine. MULTIPLIER must be at least 16 bits wide. - */ - -#ifndef MULTIPLIER -#define MULTIPLIER int /* type for fastest integer multiply */ -#endif - - -/* FAST_FLOAT should be either float or double, whichever is done faster - * by your compiler. (Note that this type is only used in the floating point - * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) - * Typically, float is faster in ANSI C compilers, while double is faster in - * pre-ANSI compilers (because they insist on converting to double anyway). - * The code below therefore chooses float if we have ANSI-style prototypes. - */ - -#ifndef FAST_FLOAT -#ifdef HAVE_PROTOTYPES -#define FAST_FLOAT float -#else -#define FAST_FLOAT double -#endif -#endif - -#endif /* JPEG_INTERNAL_OPTIONS */ diff --git a/oversampling/WDL/jpeglib/jpegint.h b/oversampling/WDL/jpeglib/jpegint.h deleted file mode 100644 index 95b00d4..0000000 --- a/oversampling/WDL/jpeglib/jpegint.h +++ /dev/null @@ -1,392 +0,0 @@ -/* - * jpegint.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file provides common declarations for the various JPEG modules. - * These declarations are considered internal to the JPEG library; most - * applications using the library shouldn't need to include this file. - */ - - -/* Declarations for both compression & decompression */ - -typedef enum { /* Operating modes for buffer controllers */ - JBUF_PASS_THRU, /* Plain stripwise operation */ - /* Remaining modes require a full-image buffer to have been created */ - JBUF_SAVE_SOURCE, /* Run source subobject only, save output */ - JBUF_CRANK_DEST, /* Run dest subobject only, using saved data */ - JBUF_SAVE_AND_PASS /* Run both subobjects, save output */ -} J_BUF_MODE; - -/* Values of global_state field (jdapi.c has some dependencies on ordering!) */ -#define CSTATE_START 100 /* after create_compress */ -#define CSTATE_SCANNING 101 /* start_compress done, write_scanlines OK */ -#define CSTATE_RAW_OK 102 /* start_compress done, write_raw_data OK */ -#define CSTATE_WRCOEFS 103 /* jpeg_write_coefficients done */ -#define DSTATE_START 200 /* after create_decompress */ -#define DSTATE_INHEADER 201 /* reading header markers, no SOS yet */ -#define DSTATE_READY 202 /* found SOS, ready for start_decompress */ -#define DSTATE_PRELOAD 203 /* reading multiscan file in start_decompress*/ -#define DSTATE_PRESCAN 204 /* performing dummy pass for 2-pass quant */ -#define DSTATE_SCANNING 205 /* start_decompress done, read_scanlines OK */ -#define DSTATE_RAW_OK 206 /* start_decompress done, read_raw_data OK */ -#define DSTATE_BUFIMAGE 207 /* expecting jpeg_start_output */ -#define DSTATE_BUFPOST 208 /* looking for SOS/EOI in jpeg_finish_output */ -#define DSTATE_RDCOEFS 209 /* reading file in jpeg_read_coefficients */ -#define DSTATE_STOPPING 210 /* looking for EOI in jpeg_finish_decompress */ - - -/* Declarations for compression modules */ - -/* Master control module */ -struct jpeg_comp_master { - JMETHOD(void, prepare_for_pass, (j_compress_ptr cinfo)); - JMETHOD(void, pass_startup, (j_compress_ptr cinfo)); - JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean call_pass_startup; /* True if pass_startup must be called */ - boolean is_last_pass; /* True during last pass */ -}; - -/* Main buffer control (downsampled-data buffer) */ -struct jpeg_c_main_controller { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, process_data, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail)); -}; - -/* Compression preprocessing (downsampling input buffer control) */ -struct jpeg_c_prep_controller { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, pre_process_data, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, - JDIMENSION *in_row_ctr, - JDIMENSION in_rows_avail, - JSAMPIMAGE output_buf, - JDIMENSION *out_row_group_ctr, - JDIMENSION out_row_groups_avail)); -}; - -/* Coefficient buffer control */ -struct jpeg_c_coef_controller { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(boolean, compress_data, (j_compress_ptr cinfo, - JSAMPIMAGE input_buf)); -}; - -/* Colorspace conversion */ -struct jpeg_color_converter { - JMETHOD(void, start_pass, (j_compress_ptr cinfo)); - JMETHOD(void, color_convert, (j_compress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPIMAGE output_buf, - JDIMENSION output_row, int num_rows)); -}; - -/* Downsampling */ -struct jpeg_downsampler { - JMETHOD(void, start_pass, (j_compress_ptr cinfo)); - JMETHOD(void, downsample, (j_compress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION in_row_index, - JSAMPIMAGE output_buf, - JDIMENSION out_row_group_index)); - - boolean need_context_rows; /* TRUE if need rows above & below */ -}; - -/* Forward DCT (also controls coefficient quantization) */ -struct jpeg_forward_dct { - JMETHOD(void, start_pass, (j_compress_ptr cinfo)); - /* perhaps this should be an array??? */ - JMETHOD(void, forward_DCT, (j_compress_ptr cinfo, - jpeg_component_info * compptr, - JSAMPARRAY sample_data, JBLOCKROW coef_blocks, - JDIMENSION start_row, JDIMENSION start_col, - JDIMENSION num_blocks)); -}; - -/* Entropy encoding */ -struct jpeg_entropy_encoder { - JMETHOD(void, start_pass, (j_compress_ptr cinfo, boolean gather_statistics)); - JMETHOD(boolean, encode_mcu, (j_compress_ptr cinfo, JBLOCKROW *MCU_data)); - JMETHOD(void, finish_pass, (j_compress_ptr cinfo)); -}; - -/* Marker writing */ -struct jpeg_marker_writer { - JMETHOD(void, write_file_header, (j_compress_ptr cinfo)); - JMETHOD(void, write_frame_header, (j_compress_ptr cinfo)); - JMETHOD(void, write_scan_header, (j_compress_ptr cinfo)); - JMETHOD(void, write_file_trailer, (j_compress_ptr cinfo)); - JMETHOD(void, write_tables_only, (j_compress_ptr cinfo)); - /* These routines are exported to allow insertion of extra markers */ - /* Probably only COM and APPn markers should be written this way */ - JMETHOD(void, write_marker_header, (j_compress_ptr cinfo, int marker, - unsigned int datalen)); - JMETHOD(void, write_marker_byte, (j_compress_ptr cinfo, int val)); -}; - - -/* Declarations for decompression modules */ - -/* Master control module */ -struct jpeg_decomp_master { - JMETHOD(void, prepare_for_output_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, finish_output_pass, (j_decompress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean is_dummy_pass; /* True during 1st pass for 2-pass quant */ -}; - -/* Input control module */ -struct jpeg_input_controller { - JMETHOD(int, consume_input, (j_decompress_ptr cinfo)); - JMETHOD(void, reset_input_controller, (j_decompress_ptr cinfo)); - JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, finish_input_pass, (j_decompress_ptr cinfo)); - - /* State variables made visible to other modules */ - boolean has_multiple_scans; /* True if file has multiple scans */ - boolean eoi_reached; /* True when EOI has been consumed */ -}; - -/* Main buffer control (downsampled-data buffer) */ -struct jpeg_d_main_controller { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, process_data, (j_decompress_ptr cinfo, - JSAMPARRAY output_buf, JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -}; - -/* Coefficient buffer control */ -struct jpeg_d_coef_controller { - JMETHOD(void, start_input_pass, (j_decompress_ptr cinfo)); - JMETHOD(int, consume_data, (j_decompress_ptr cinfo)); - JMETHOD(void, start_output_pass, (j_decompress_ptr cinfo)); - JMETHOD(int, decompress_data, (j_decompress_ptr cinfo, - JSAMPIMAGE output_buf)); - /* Pointer to array of coefficient virtual arrays, or NULL if none */ - jvirt_barray_ptr *coef_arrays; -}; - -/* Decompression postprocessing (color quantization buffer control) */ -struct jpeg_d_post_controller { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo, J_BUF_MODE pass_mode)); - JMETHOD(void, post_process_data, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, - JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); -}; - -/* Marker reading & parsing */ -struct jpeg_marker_reader { - JMETHOD(void, reset_marker_reader, (j_decompress_ptr cinfo)); - /* Read markers until SOS or EOI. - * Returns same codes as are defined for jpeg_consume_input: - * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI. - */ - JMETHOD(int, read_markers, (j_decompress_ptr cinfo)); - /* Read a restart marker --- exported for use by entropy decoder only */ - jpeg_marker_parser_method read_restart_marker; - - /* State of marker reader --- nominally internal, but applications - * supplying COM or APPn handlers might like to know the state. - */ - boolean saw_SOI; /* found SOI? */ - boolean saw_SOF; /* found SOF? */ - int next_restart_num; /* next restart number expected (0-7) */ - unsigned int discarded_bytes; /* # of bytes skipped looking for a marker */ -}; - -/* Entropy decoding */ -struct jpeg_entropy_decoder { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - JMETHOD(boolean, decode_mcu, (j_decompress_ptr cinfo, - JBLOCKROW *MCU_data)); - - /* This is here to share code between baseline and progressive decoders; */ - /* other modules probably should not use it */ - boolean insufficient_data; /* set TRUE after emitting warning */ -}; - -/* Inverse DCT (also performs dequantization) */ -typedef JMETHOD(void, inverse_DCT_method_ptr, - (j_decompress_ptr cinfo, jpeg_component_info * compptr, - JCOEFPTR coef_block, - JSAMPARRAY output_buf, JDIMENSION output_col)); - -struct jpeg_inverse_dct { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - /* It is useful to allow each component to have a separate IDCT method. */ - inverse_DCT_method_ptr inverse_DCT[MAX_COMPONENTS]; -}; - -/* Upsampling (note that upsampler must also call color converter) */ -struct jpeg_upsampler { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, upsample, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, - JDIMENSION *in_row_group_ctr, - JDIMENSION in_row_groups_avail, - JSAMPARRAY output_buf, - JDIMENSION *out_row_ctr, - JDIMENSION out_rows_avail)); - - boolean need_context_rows; /* TRUE if need rows above & below */ -}; - -/* Colorspace conversion */ -struct jpeg_color_deconverter { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, color_convert, (j_decompress_ptr cinfo, - JSAMPIMAGE input_buf, JDIMENSION input_row, - JSAMPARRAY output_buf, int num_rows)); -}; - -/* Color quantization or color precision reduction */ -struct jpeg_color_quantizer { - JMETHOD(void, start_pass, (j_decompress_ptr cinfo, boolean is_pre_scan)); - JMETHOD(void, color_quantize, (j_decompress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPARRAY output_buf, - int num_rows)); - JMETHOD(void, finish_pass, (j_decompress_ptr cinfo)); - JMETHOD(void, new_color_map, (j_decompress_ptr cinfo)); -}; - - -/* Miscellaneous useful macros */ - -#undef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#undef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) - - -/* We assume that right shift corresponds to signed division by 2 with - * rounding towards minus infinity. This is correct for typical "arithmetic - * shift" instructions that shift in copies of the sign bit. But some - * C compilers implement >> with an unsigned shift. For these machines you - * must define RIGHT_SHIFT_IS_UNSIGNED. - * RIGHT_SHIFT provides a proper signed right shift of an INT32 quantity. - * It is only applied with constant shift counts. SHIFT_TEMPS must be - * included in the variables of any routine using RIGHT_SHIFT. - */ - -#ifdef RIGHT_SHIFT_IS_UNSIGNED -#define SHIFT_TEMPS INT32 shift_temp; -#define RIGHT_SHIFT(x,shft) \ - ((shift_temp = (x)) < 0 ? \ - (shift_temp >> (shft)) | ((~((INT32) 0)) << (32-(shft))) : \ - (shift_temp >> (shft))) -#else -#define SHIFT_TEMPS -#define RIGHT_SHIFT(x,shft) ((x) >> (shft)) -#endif - - -/* Short forms of external names for systems with brain-damaged linkers. */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jinit_compress_master jICompress -#define jinit_c_master_control jICMaster -#define jinit_c_main_controller jICMainC -#define jinit_c_prep_controller jICPrepC -#define jinit_c_coef_controller jICCoefC -#define jinit_color_converter jICColor -#define jinit_downsampler jIDownsampler -#define jinit_forward_dct jIFDCT -#define jinit_huff_encoder jIHEncoder -#define jinit_phuff_encoder jIPHEncoder -#define jinit_marker_writer jIMWriter -#define jinit_master_decompress jIDMaster -#define jinit_d_main_controller jIDMainC -#define jinit_d_coef_controller jIDCoefC -#define jinit_d_post_controller jIDPostC -#define jinit_input_controller jIInCtlr -#define jinit_marker_reader jIMReader -#define jinit_huff_decoder jIHDecoder -#define jinit_phuff_decoder jIPHDecoder -#define jinit_inverse_dct jIIDCT -#define jinit_upsampler jIUpsampler -#define jinit_color_deconverter jIDColor -#define jinit_1pass_quantizer jI1Quant -#define jinit_2pass_quantizer jI2Quant -#define jinit_merged_upsampler jIMUpsampler -#define jinit_memory_mgr jIMemMgr -#define jdiv_round_up jDivRound -#define jround_up jRound -#define jcopy_sample_rows jCopySamples -#define jcopy_block_row jCopyBlocks -#define jzero_far jZeroFar -#define jpeg_zigzag_order jZIGTable -#define jpeg_natural_order jZAGTable -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Compression module initialization routines */ -EXTERN(void) jinit_compress_master JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_c_master_control JPP((j_compress_ptr cinfo, - boolean transcode_only)); -EXTERN(void) jinit_c_main_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_c_prep_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_c_coef_controller JPP((j_compress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_color_converter JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_downsampler JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_forward_dct JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_huff_encoder JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_phuff_encoder JPP((j_compress_ptr cinfo)); -EXTERN(void) jinit_marker_writer JPP((j_compress_ptr cinfo)); -/* Decompression module initialization routines */ -EXTERN(void) jinit_master_decompress JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_d_main_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_d_coef_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_d_post_controller JPP((j_decompress_ptr cinfo, - boolean need_full_buffer)); -EXTERN(void) jinit_input_controller JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_marker_reader JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_huff_decoder JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_phuff_decoder JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_inverse_dct JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_upsampler JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_color_deconverter JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_1pass_quantizer JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_2pass_quantizer JPP((j_decompress_ptr cinfo)); -EXTERN(void) jinit_merged_upsampler JPP((j_decompress_ptr cinfo)); -/* Memory manager initialization */ -EXTERN(void) jinit_memory_mgr JPP((j_common_ptr cinfo)); - -/* Utility routines in jutils.c */ -EXTERN(long) jdiv_round_up JPP((long a, long b)); -EXTERN(long) jround_up JPP((long a, long b)); -EXTERN(void) jcopy_sample_rows JPP((JSAMPARRAY input_array, int source_row, - JSAMPARRAY output_array, int dest_row, - int num_rows, JDIMENSION num_cols)); -EXTERN(void) jcopy_block_row JPP((JBLOCKROW input_row, JBLOCKROW output_row, - JDIMENSION num_blocks)); -EXTERN(void) jzero_far JPP((void FAR * target, size_t bytestozero)); -/* Constant tables in jutils.c */ -#if 0 /* This table is not actually needed in v6a */ -extern const int jpeg_zigzag_order[]; /* natural coef order to zigzag order */ -#endif -extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */ - -/* Suppress undefined-structure complaints if necessary. */ - -#ifdef INCOMPLETE_TYPES_BROKEN -#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */ -struct jvirt_sarray_control { long dummy; }; -struct jvirt_barray_control { long dummy; }; -#endif -#endif /* INCOMPLETE_TYPES_BROKEN */ diff --git a/oversampling/WDL/jpeglib/jpeglib.h b/oversampling/WDL/jpeglib/jpeglib.h deleted file mode 100644 index c7d9e21..0000000 --- a/oversampling/WDL/jpeglib/jpeglib.h +++ /dev/null @@ -1,1100 +0,0 @@ -/* - * jpeglib.h - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the application interface for the JPEG library. - * Most applications using the library need only include this file, - * and perhaps jerror.h if they want to know the exact error codes. - */ - -#ifndef JPEGLIB_H -#define JPEGLIB_H - -/* - * First we include the configuration files that record how this - * installation of the JPEG library is set up. jconfig.h can be - * generated automatically for many systems. jmorecfg.h contains - * manual configuration options that most people need not worry about. - */ - -#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ -#include "jconfig.h" /* widely used configuration options */ -#endif -#include "jmorecfg.h" /* seldom changed options */ - - -/* Version ID for the JPEG library. - * Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". - */ - -#define JPEG_LIB_VERSION 62 /* Version 6b */ - - -/* Various constants determining the sizes of things. - * All of these are specified by the JPEG standard, so don't change them - * if you want to be compatible. - */ - -#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */ -#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ -#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ -#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ -#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ -#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ -#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ -/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; - * the PostScript DCT filter can emit files with many more than 10 blocks/MCU. - * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU - * to handle it. We even let you do this from the jconfig.h file. However, - * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe - * sometimes emits noncompliant files doesn't mean you should too. - */ -#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ -#ifndef D_MAX_BLOCKS_IN_MCU -#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ -#endif - - -/* Data structures for images (arrays of samples and of DCT coefficients). - * On 80x86 machines, the image arrays are too big for near pointers, - * but the pointer arrays can fit in near memory. - */ - -typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ -typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ -typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ - -typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ -typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ -typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ -typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ - -typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ - - -/* Types for JPEG compression parameters and working tables. */ - - -/* DCT coefficient quantization tables. */ - -typedef struct { - /* This array gives the coefficient quantizers in natural array order - * (not the zigzag order in which they are stored in a JPEG DQT marker). - * CAUTION: IJG versions prior to v6a kept this array in zigzag order. - */ - UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ - /* This field is used only during compression. It's initialized FALSE when - * the table is created, and set TRUE when it's been output to the file. - * You could suppress output of a table by setting this to TRUE. - * (See jpeg_suppress_tables for an example.) - */ - boolean sent_table; /* TRUE when table has been output */ -} JQUANT_TBL; - - -/* Huffman coding tables. */ - -typedef struct { - /* These two fields directly represent the contents of a JPEG DHT marker */ - UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ - /* length k bits; bits[0] is unused */ - UINT8 huffval[256]; /* The symbols, in order of incr code length */ - /* This field is used only during compression. It's initialized FALSE when - * the table is created, and set TRUE when it's been output to the file. - * You could suppress output of a table by setting this to TRUE. - * (See jpeg_suppress_tables for an example.) - */ - boolean sent_table; /* TRUE when table has been output */ -} JHUFF_TBL; - - -/* Basic info about one component (color channel). */ - -typedef struct { - /* These values are fixed over the whole image. */ - /* For compression, they must be supplied by parameter setup; */ - /* for decompression, they are read from the SOF marker. */ - int component_id; /* identifier for this component (0..255) */ - int component_index; /* its index in SOF or cinfo->comp_info[] */ - int h_samp_factor; /* horizontal sampling factor (1..4) */ - int v_samp_factor; /* vertical sampling factor (1..4) */ - int quant_tbl_no; /* quantization table selector (0..3) */ - /* These values may vary between scans. */ - /* For compression, they must be supplied by parameter setup; */ - /* for decompression, they are read from the SOS marker. */ - /* The decompressor output side may not use these variables. */ - int dc_tbl_no; /* DC entropy table selector (0..3) */ - int ac_tbl_no; /* AC entropy table selector (0..3) */ - - /* Remaining fields should be treated as private by applications. */ - - /* These values are computed during compression or decompression startup: */ - /* Component's size in DCT blocks. - * Any dummy blocks added to complete an MCU are not counted; therefore - * these values do not depend on whether a scan is interleaved or not. - */ - JDIMENSION width_in_blocks; - JDIMENSION height_in_blocks; - /* Size of a DCT block in samples. Always DCTSIZE for compression. - * For decompression this is the size of the output from one DCT block, - * reflecting any scaling we choose to apply during the IDCT step. - * Values of 1,2,4,8 are likely to be supported. Note that different - * components may receive different IDCT scalings. - */ - int DCT_scaled_size; - /* The downsampled dimensions are the component's actual, unpadded number - * of samples at the main buffer (preprocessing/compression interface), thus - * downsampled_width = ceil(image_width * Hi/Hmax) - * and similarly for height. For decompression, IDCT scaling is included, so - * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) - */ - JDIMENSION downsampled_width; /* actual width in samples */ - JDIMENSION downsampled_height; /* actual height in samples */ - /* This flag is used only for decompression. In cases where some of the - * components will be ignored (eg grayscale output from YCbCr image), - * we can skip most computations for the unused components. - */ - boolean component_needed; /* do we need the value of this component? */ - - /* These values are computed before starting a scan of the component. */ - /* The decompressor output side may not use these variables. */ - int MCU_width; /* number of blocks per MCU, horizontally */ - int MCU_height; /* number of blocks per MCU, vertically */ - int MCU_blocks; /* MCU_width * MCU_height */ - int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ - int last_col_width; /* # of non-dummy blocks across in last MCU */ - int last_row_height; /* # of non-dummy blocks down in last MCU */ - - /* Saved quantization table for component; NULL if none yet saved. - * See jdinput.c comments about the need for this information. - * This field is currently used only for decompression. - */ - JQUANT_TBL * quant_table; - - /* Private per-component storage for DCT or IDCT subsystem. */ - void * dct_table; -} jpeg_component_info; - - -/* The script for encoding a multiple-scan file is an array of these: */ - -typedef struct { - int comps_in_scan; /* number of components encoded in this scan */ - int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ - int Ss, Se; /* progressive JPEG spectral selection parms */ - int Ah, Al; /* progressive JPEG successive approx. parms */ -} jpeg_scan_info; - -/* The decompressor can save APPn and COM markers in a list of these: */ - -typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; - -struct jpeg_marker_struct { - jpeg_saved_marker_ptr next; /* next in list, or NULL */ - UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ - unsigned int original_length; /* # bytes of data in the file */ - unsigned int data_length; /* # bytes of data saved at data[] */ - JOCTET FAR * data; /* the data contained in the marker */ - /* the marker length word is not counted in data_length or original_length */ -}; - -/* Known color spaces. */ - -typedef enum { - JCS_UNKNOWN, /* error/unspecified */ - JCS_GRAYSCALE, /* monochrome */ - JCS_RGB, /* red/green/blue */ - JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ - JCS_CMYK, /* C/M/Y/K */ - JCS_YCCK /* Y/Cb/Cr/K */ -} J_COLOR_SPACE; - -/* DCT/IDCT algorithm options. */ - -typedef enum { - JDCT_ISLOW, /* slow but accurate integer algorithm */ - JDCT_IFAST, /* faster, less accurate integer method */ - JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ -} J_DCT_METHOD; - -#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ -#define JDCT_DEFAULT JDCT_ISLOW -#endif -#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ -#define JDCT_FASTEST JDCT_IFAST -#endif - -/* Dithering options for decompression. */ - -typedef enum { - JDITHER_NONE, /* no dithering */ - JDITHER_ORDERED, /* simple ordered dither */ - JDITHER_FS /* Floyd-Steinberg error diffusion dither */ -} J_DITHER_MODE; - - -/* Common fields between JPEG compression and decompression master structs. */ - -#define jpeg_common_fields \ - struct jpeg_error_mgr * err; /* Error handler module */\ - struct jpeg_memory_mgr * mem; /* Memory manager module */\ - struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ - void * client_data; /* Available for use by application */\ - boolean is_decompressor; /* So common code can tell which is which */\ - int global_state /* For checking call sequence validity */ - -/* Routines that are to be used by both halves of the library are declared - * to receive a pointer to this structure. There are no actual instances of - * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. - */ -struct jpeg_common_struct { - jpeg_common_fields; /* Fields common to both master struct types */ - /* Additional fields follow in an actual jpeg_compress_struct or - * jpeg_decompress_struct. All three structs must agree on these - * initial fields! (This would be a lot cleaner in C++.) - */ -}; - -typedef struct jpeg_common_struct * j_common_ptr; -typedef struct jpeg_compress_struct * j_compress_ptr; -typedef struct jpeg_decompress_struct * j_decompress_ptr; - - -/* Master record for a compression instance */ - -struct jpeg_compress_struct { - jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ - - /* Destination for compressed data */ - struct jpeg_destination_mgr * dest; - - /* Description of source image --- these fields must be filled in by - * outer application before starting compression. in_color_space must - * be correct before you can even call jpeg_set_defaults(). - */ - - JDIMENSION image_width; /* input image width */ - JDIMENSION image_height; /* input image height */ - int input_components; /* # of color components in input image */ - J_COLOR_SPACE in_color_space; /* colorspace of input image */ - - double input_gamma; /* image gamma of input image */ - - /* Compression parameters --- these fields must be set before calling - * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to - * initialize everything to reasonable defaults, then changing anything - * the application specifically wants to change. That way you won't get - * burnt when new parameters are added. Also note that there are several - * helper routines to simplify changing parameters. - */ - - int data_precision; /* bits of precision in image data */ - - int num_components; /* # of color components in JPEG image */ - J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ - - jpeg_component_info * comp_info; - /* comp_info[i] describes component that appears i'th in SOF */ - - JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; - /* ptrs to coefficient quantization tables, or NULL if not defined */ - - JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; - JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; - /* ptrs to Huffman coding tables, or NULL if not defined */ - - UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ - UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ - UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ - - int num_scans; /* # of entries in scan_info array */ - const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ - /* The default value of scan_info is NULL, which causes a single-scan - * sequential JPEG file to be emitted. To create a multi-scan file, - * set num_scans and scan_info to point to an array of scan definitions. - */ - - boolean raw_data_in; /* TRUE=caller supplies downsampled data */ - boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ - boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ - boolean CCIR601_sampling; /* TRUE=first samples are cosited */ - int smoothing_factor; /* 1..100, or 0 for no input smoothing */ - J_DCT_METHOD dct_method; /* DCT algorithm selector */ - - /* The restart interval can be specified in absolute MCUs by setting - * restart_interval, or in MCU rows by setting restart_in_rows - * (in which case the correct restart_interval will be figured - * for each scan). - */ - unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ - int restart_in_rows; /* if > 0, MCU rows per restart interval */ - - /* Parameters controlling emission of special markers. */ - - boolean write_JFIF_header; /* should a JFIF marker be written? */ - UINT8 JFIF_major_version; /* What to write for the JFIF version number */ - UINT8 JFIF_minor_version; - /* These three values are not used by the JPEG code, merely copied */ - /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ - /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ - /* ratio is defined by X_density/Y_density even when density_unit=0. */ - UINT8 density_unit; /* JFIF code for pixel size units */ - UINT16 X_density; /* Horizontal pixel density */ - UINT16 Y_density; /* Vertical pixel density */ - boolean write_Adobe_marker; /* should an Adobe marker be written? */ - - /* State variable: index of next scanline to be written to - * jpeg_write_scanlines(). Application may use this to control its - * processing loop, e.g., "while (next_scanline < image_height)". - */ - - JDIMENSION next_scanline; /* 0 .. image_height-1 */ - - /* Remaining fields are known throughout compressor, but generally - * should not be touched by a surrounding application. - */ - - /* - * These fields are computed during compression startup - */ - boolean progressive_mode; /* TRUE if scan script uses progressive mode */ - int max_h_samp_factor; /* largest h_samp_factor */ - int max_v_samp_factor; /* largest v_samp_factor */ - - JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ - /* The coefficient controller receives data in units of MCU rows as defined - * for fully interleaved scans (whether the JPEG file is interleaved or not). - * There are v_samp_factor * DCTSIZE sample rows of each component in an - * "iMCU" (interleaved MCU) row. - */ - - /* - * These fields are valid during any one scan. - * They describe the components and MCUs actually appearing in the scan. - */ - int comps_in_scan; /* # of JPEG components in this scan */ - jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; - /* *cur_comp_info[i] describes component that appears i'th in SOS */ - - JDIMENSION MCUs_per_row; /* # of MCUs across the image */ - JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ - - int blocks_in_MCU; /* # of DCT blocks per MCU */ - int MCU_membership[C_MAX_BLOCKS_IN_MCU]; - /* MCU_membership[i] is index in cur_comp_info of component owning */ - /* i'th block in an MCU */ - - int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ - - /* - * Links to compression subobjects (methods and private variables of modules) - */ - struct jpeg_comp_master * master; - struct jpeg_c_main_controller * main; - struct jpeg_c_prep_controller * prep; - struct jpeg_c_coef_controller * coef; - struct jpeg_marker_writer * marker; - struct jpeg_color_converter * cconvert; - struct jpeg_downsampler * downsample; - struct jpeg_forward_dct * fdct; - struct jpeg_entropy_encoder * entropy; - jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */ - int script_space_size; -}; - - -/* Master record for a decompression instance */ - -struct jpeg_decompress_struct { - jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ - - /* Source of compressed data */ - struct jpeg_source_mgr * src; - - /* Basic description of image --- filled in by jpeg_read_header(). */ - /* Application may inspect these values to decide how to process image. */ - - JDIMENSION image_width; /* nominal image width (from SOF marker) */ - JDIMENSION image_height; /* nominal image height */ - int num_components; /* # of color components in JPEG image */ - J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ - - /* Decompression processing parameters --- these fields must be set before - * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes - * them to default values. - */ - - J_COLOR_SPACE out_color_space; /* colorspace for output */ - - unsigned int scale_num, scale_denom; /* fraction by which to scale image */ - - double output_gamma; /* image gamma wanted in output */ - - boolean buffered_image; /* TRUE=multiple output passes */ - boolean raw_data_out; /* TRUE=downsampled data wanted */ - - J_DCT_METHOD dct_method; /* IDCT algorithm selector */ - boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ - boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ - - boolean quantize_colors; /* TRUE=colormapped output wanted */ - /* the following are ignored if not quantize_colors: */ - J_DITHER_MODE dither_mode; /* type of color dithering to use */ - boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ - int desired_number_of_colors; /* max # colors to use in created colormap */ - /* these are significant only in buffered-image mode: */ - boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ - boolean enable_external_quant;/* enable future use of external colormap */ - boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ - - /* Description of actual output image that will be returned to application. - * These fields are computed by jpeg_start_decompress(). - * You can also use jpeg_calc_output_dimensions() to determine these values - * in advance of calling jpeg_start_decompress(). - */ - - JDIMENSION output_width; /* scaled image width */ - JDIMENSION output_height; /* scaled image height */ - int out_color_components; /* # of color components in out_color_space */ - int output_components; /* # of color components returned */ - /* output_components is 1 (a colormap index) when quantizing colors; - * otherwise it equals out_color_components. - */ - int rec_outbuf_height; /* min recommended height of scanline buffer */ - /* If the buffer passed to jpeg_read_scanlines() is less than this many rows - * high, space and time will be wasted due to unnecessary data copying. - * Usually rec_outbuf_height will be 1 or 2, at most 4. - */ - - /* When quantizing colors, the output colormap is described by these fields. - * The application can supply a colormap by setting colormap non-NULL before - * calling jpeg_start_decompress; otherwise a colormap is created during - * jpeg_start_decompress or jpeg_start_output. - * The map has out_color_components rows and actual_number_of_colors columns. - */ - int actual_number_of_colors; /* number of entries in use */ - JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ - - /* State variables: these variables indicate the progress of decompression. - * The application may examine these but must not modify them. - */ - - /* Row index of next scanline to be read from jpeg_read_scanlines(). - * Application may use this to control its processing loop, e.g., - * "while (output_scanline < output_height)". - */ - JDIMENSION output_scanline; /* 0 .. output_height-1 */ - - /* Current input scan number and number of iMCU rows completed in scan. - * These indicate the progress of the decompressor input side. - */ - int input_scan_number; /* Number of SOS markers seen so far */ - JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ - - /* The "output scan number" is the notional scan being displayed by the - * output side. The decompressor will not allow output scan/row number - * to get ahead of input scan/row, but it can fall arbitrarily far behind. - */ - int output_scan_number; /* Nominal scan number being displayed */ - JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ - - /* Current progression status. coef_bits[c][i] indicates the precision - * with which component c's DCT coefficient i (in zigzag order) is known. - * It is -1 when no data has yet been received, otherwise it is the point - * transform (shift) value for the most recent scan of the coefficient - * (thus, 0 at completion of the progression). - * This pointer is NULL when reading a non-progressive file. - */ - int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ - - /* Internal JPEG parameters --- the application usually need not look at - * these fields. Note that the decompressor output side may not use - * any parameters that can change between scans. - */ - - /* Quantization and Huffman tables are carried forward across input - * datastreams when processing abbreviated JPEG datastreams. - */ - - JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; - /* ptrs to coefficient quantization tables, or NULL if not defined */ - - JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; - JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; - /* ptrs to Huffman coding tables, or NULL if not defined */ - - /* These parameters are never carried across datastreams, since they - * are given in SOF/SOS markers or defined to be reset by SOI. - */ - - int data_precision; /* bits of precision in image data */ - - jpeg_component_info * comp_info; - /* comp_info[i] describes component that appears i'th in SOF */ - - boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ - boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ - - UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ - UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ - UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ - - unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ - - /* These fields record data obtained from optional markers recognized by - * the JPEG library. - */ - boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */ - /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */ - UINT8 JFIF_major_version; /* JFIF version number */ - UINT8 JFIF_minor_version; - UINT8 density_unit; /* JFIF code for pixel size units */ - UINT16 X_density; /* Horizontal pixel density */ - UINT16 Y_density; /* Vertical pixel density */ - boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ - UINT8 Adobe_transform; /* Color transform code from Adobe marker */ - - boolean CCIR601_sampling; /* TRUE=first samples are cosited */ - - /* Aside from the specific data retained from APPn markers known to the - * library, the uninterpreted contents of any or all APPn and COM markers - * can be saved in a list for examination by the application. - */ - jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */ - - /* Remaining fields are known throughout decompressor, but generally - * should not be touched by a surrounding application. - */ - - /* - * These fields are computed during decompression startup - */ - int max_h_samp_factor; /* largest h_samp_factor */ - int max_v_samp_factor; /* largest v_samp_factor */ - - int min_DCT_scaled_size; /* smallest DCT_scaled_size of any component */ - - JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ - /* The coefficient controller's input and output progress is measured in - * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows - * in fully interleaved JPEG scans, but are used whether the scan is - * interleaved or not. We define an iMCU row as v_samp_factor DCT block - * rows of each component. Therefore, the IDCT output contains - * v_samp_factor*DCT_scaled_size sample rows of a component per iMCU row. - */ - - JSAMPLE * sample_range_limit; /* table for fast range-limiting */ - - /* - * These fields are valid during any one scan. - * They describe the components and MCUs actually appearing in the scan. - * Note that the decompressor output side must not use these fields. - */ - int comps_in_scan; /* # of JPEG components in this scan */ - jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; - /* *cur_comp_info[i] describes component that appears i'th in SOS */ - - JDIMENSION MCUs_per_row; /* # of MCUs across the image */ - JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ - - int blocks_in_MCU; /* # of DCT blocks per MCU */ - int MCU_membership[D_MAX_BLOCKS_IN_MCU]; - /* MCU_membership[i] is index in cur_comp_info of component owning */ - /* i'th block in an MCU */ - - int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ - - /* This field is shared between entropy decoder and marker parser. - * It is either zero or the code of a JPEG marker that has been - * read from the data source, but has not yet been processed. - */ - int unread_marker; - - /* - * Links to decompression subobjects (methods, private variables of modules) - */ - struct jpeg_decomp_master * master; - struct jpeg_d_main_controller * main; - struct jpeg_d_coef_controller * coef; - struct jpeg_d_post_controller * post; - struct jpeg_input_controller * inputctl; - struct jpeg_marker_reader * marker; - struct jpeg_entropy_decoder * entropy; - struct jpeg_inverse_dct * idct; - struct jpeg_upsampler * upsample; - struct jpeg_color_deconverter * cconvert; - struct jpeg_color_quantizer * cquantize; -}; - - -/* "Object" declarations for JPEG modules that may be supplied or called - * directly by the surrounding application. - * As with all objects in the JPEG library, these structs only define the - * publicly visible methods and state variables of a module. Additional - * private fields may exist after the public ones. - */ - - -/* Error handler object */ - -struct jpeg_error_mgr { - /* Error exit handler: does not return to caller */ - JMETHOD(void, error_exit, (j_common_ptr cinfo)); - /* Conditionally emit a trace or warning message */ - JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); - /* Routine that actually outputs a trace or error message */ - JMETHOD(void, output_message, (j_common_ptr cinfo)); - /* Format a message string for the most recent JPEG error or message */ - JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer)); -#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ - /* Reset error state variables at start of a new image */ - JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); - - /* The message ID code and any parameters are saved here. - * A message can have one string parameter or up to 8 int parameters. - */ - int msg_code; -#define JMSG_STR_PARM_MAX 80 - union { - int i[8]; - char s[JMSG_STR_PARM_MAX]; - } msg_parm; - - /* Standard state variables for error facility */ - - int trace_level; /* max msg_level that will be displayed */ - - /* For recoverable corrupt-data errors, we emit a warning message, - * but keep going unless emit_message chooses to abort. emit_message - * should count warnings in num_warnings. The surrounding application - * can check for bad data by seeing if num_warnings is nonzero at the - * end of processing. - */ - long num_warnings; /* number of corrupt-data warnings */ - - /* These fields point to the table(s) of error message strings. - * An application can change the table pointer to switch to a different - * message list (typically, to change the language in which errors are - * reported). Some applications may wish to add additional error codes - * that will be handled by the JPEG library error mechanism; the second - * table pointer is used for this purpose. - * - * First table includes all errors generated by JPEG library itself. - * Error code 0 is reserved for a "no such error string" message. - */ - const char * const * jpeg_message_table; /* Library errors */ - int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ - /* Second table can be added by application (see cjpeg/djpeg for example). - * It contains strings numbered first_addon_message..last_addon_message. - */ - const char * const * addon_message_table; /* Non-library errors */ - int first_addon_message; /* code for first string in addon table */ - int last_addon_message; /* code for last string in addon table */ -}; - - -/* Progress monitor object */ - -struct jpeg_progress_mgr { - JMETHOD(void, progress_monitor, (j_common_ptr cinfo)); - - long pass_counter; /* work units completed in this pass */ - long pass_limit; /* total number of work units in this pass */ - int completed_passes; /* passes completed so far */ - int total_passes; /* total number of passes expected */ -}; - - -/* Data destination object for compression */ - -struct jpeg_destination_mgr { - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - - JMETHOD(void, init_destination, (j_compress_ptr cinfo)); - JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); - JMETHOD(void, term_destination, (j_compress_ptr cinfo)); -}; - - -/* Data source object for decompression */ - -struct jpeg_source_mgr { - const JOCTET * next_input_byte; /* => next byte to read from buffer */ - size_t bytes_in_buffer; /* # of bytes remaining in buffer */ - - JMETHOD(void, init_source, (j_decompress_ptr cinfo)); - JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); - JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); - JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); - JMETHOD(void, term_source, (j_decompress_ptr cinfo)); -}; - - -/* Memory manager object. - * Allocates "small" objects (a few K total), "large" objects (tens of K), - * and "really big" objects (virtual arrays with backing store if needed). - * The memory manager does not allow individual objects to be freed; rather, - * each created object is assigned to a pool, and whole pools can be freed - * at once. This is faster and more convenient than remembering exactly what - * to free, especially where malloc()/free() are not too speedy. - * NB: alloc routines never return NULL. They exit to error_exit if not - * successful. - */ - -#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */ -#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */ -#define JPOOL_NUMPOOLS 2 - -typedef struct jvirt_sarray_control * jvirt_sarray_ptr; -typedef struct jvirt_barray_control * jvirt_barray_ptr; - - -struct jpeg_memory_mgr { - /* Method pointers */ - JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, - size_t sizeofobject)); - JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, - size_t sizeofobject)); - JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, - JDIMENSION samplesperrow, - JDIMENSION numrows)); - JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, - JDIMENSION blocksperrow, - JDIMENSION numrows)); - JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, - int pool_id, - boolean pre_zero, - JDIMENSION samplesperrow, - JDIMENSION numrows, - JDIMENSION maxaccess)); - JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, - int pool_id, - boolean pre_zero, - JDIMENSION blocksperrow, - JDIMENSION numrows, - JDIMENSION maxaccess)); - JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); - JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, - jvirt_sarray_ptr ptr, - JDIMENSION start_row, - JDIMENSION num_rows, - boolean writable)); - JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, - jvirt_barray_ptr ptr, - JDIMENSION start_row, - JDIMENSION num_rows, - boolean writable)); - JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); - JMETHOD(void, self_destruct, (j_common_ptr cinfo)); - - /* Limit on memory allocation for this JPEG object. (Note that this is - * merely advisory, not a guaranteed maximum; it only affects the space - * used for virtual-array buffers.) May be changed by outer application - * after creating the JPEG object. - */ - long max_memory_to_use; - - /* Maximum allocation request accepted by alloc_large. */ - long max_alloc_chunk; -}; - - -/* Routine signature for application-supplied marker processing methods. - * Need not pass marker code since it is stored in cinfo->unread_marker. - */ -typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); - - -/* Declarations for routines called by application. - * The JPP macro hides prototype parameters from compilers that can't cope. - * Note JPP requires double parentheses. - */ - -#ifdef HAVE_PROTOTYPES -#define JPP(arglist) arglist -#else -#define JPP(arglist) () -#endif - - -/* Short forms of external names for systems with brain-damaged linkers. - * We shorten external names to be unique in the first six letters, which - * is good enough for all known systems. - * (If your compiler itself needs names to be unique in less than 15 - * characters, you are out of luck. Get a better compiler.) - */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_std_error jStdError -#define jpeg_CreateCompress jCreaCompress -#define jpeg_CreateDecompress jCreaDecompress -#define jpeg_destroy_compress jDestCompress -#define jpeg_destroy_decompress jDestDecompress -#define jpeg_stdio_dest jStdDest -#define jpeg_stdio_src jStdSrc -#define jpeg_set_defaults jSetDefaults -#define jpeg_set_colorspace jSetColorspace -#define jpeg_default_colorspace jDefColorspace -#define jpeg_set_quality jSetQuality -#define jpeg_set_linear_quality jSetLQuality -#define jpeg_add_quant_table jAddQuantTable -#define jpeg_quality_scaling jQualityScaling -#define jpeg_simple_progression jSimProgress -#define jpeg_suppress_tables jSuppressTables -#define jpeg_alloc_quant_table jAlcQTable -#define jpeg_alloc_huff_table jAlcHTable -#define jpeg_start_compress jStrtCompress -#define jpeg_write_scanlines jWrtScanlines -#define jpeg_finish_compress jFinCompress -#define jpeg_write_raw_data jWrtRawData -#define jpeg_write_marker jWrtMarker -#define jpeg_write_m_header jWrtMHeader -#define jpeg_write_m_byte jWrtMByte -#define jpeg_write_tables jWrtTables -#define jpeg_read_header jReadHeader -#define jpeg_start_decompress jStrtDecompress -#define jpeg_read_scanlines jReadScanlines -#define jpeg_finish_decompress jFinDecompress -#define jpeg_read_raw_data jReadRawData -#define jpeg_has_multiple_scans jHasMultScn -#define jpeg_start_output jStrtOutput -#define jpeg_finish_output jFinOutput -#define jpeg_input_complete jInComplete -#define jpeg_new_colormap jNewCMap -#define jpeg_consume_input jConsumeInput -#define jpeg_calc_output_dimensions jCalcDimensions -#define jpeg_save_markers jSaveMarkers -#define jpeg_set_marker_processor jSetMarker -#define jpeg_read_coefficients jReadCoefs -#define jpeg_write_coefficients jWrtCoefs -#define jpeg_copy_critical_parameters jCopyCrit -#define jpeg_abort_compress jAbrtCompress -#define jpeg_abort_decompress jAbrtDecompress -#define jpeg_abort jAbort -#define jpeg_destroy jDestroy -#define jpeg_resync_to_restart jResyncRestart -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Default error-management setup */ -EXTERN(struct jpeg_error_mgr *) jpeg_std_error - JPP((struct jpeg_error_mgr * err)); - -/* Initialization of JPEG compression objects. - * jpeg_create_compress() and jpeg_create_decompress() are the exported - * names that applications should call. These expand to calls on - * jpeg_CreateCompress and jpeg_CreateDecompress with additional information - * passed for version mismatch checking. - * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. - */ -#define jpeg_create_compress(cinfo) \ - jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \ - (size_t) sizeof(struct jpeg_compress_struct)) -#define jpeg_create_decompress(cinfo) \ - jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \ - (size_t) sizeof(struct jpeg_decompress_struct)) -EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, - int version, size_t structsize)); -EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, - int version, size_t structsize)); -/* Destruction of JPEG compression objects */ -EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); - -/* Standard data source and destination managers: stdio streams. */ -/* Caller is responsible for opening the file before and closing after. */ -EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); -EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); - -EXTERN(void) jpeg_mem_src JPP((j_decompress_ptr cinfo, - unsigned char * inbuffer, - unsigned long insize)); - -/* Default parameter setup for compression */ -EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); -/* Compression parameter setup aids */ -EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo, - J_COLOR_SPACE colorspace)); -EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, - boolean force_baseline)); -EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, - int scale_factor, - boolean force_baseline)); -EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, - const unsigned int *basic_table, - int scale_factor, - boolean force_baseline)); -EXTERN(int) jpeg_quality_scaling JPP((int quality)); -EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo, - boolean suppress)); -EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); -EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); - -/* Main entry points for compression */ -EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, - boolean write_all_tables)); -EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, - JSAMPARRAY scanlines, - JDIMENSION num_lines)); -EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); - -/* Replaces jpeg_write_scanlines when writing raw downsampled data. */ -EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, - JSAMPIMAGE data, - JDIMENSION num_lines)); - -/* Write a special marker. See libjpeg.doc concerning safe usage. */ -EXTERN(void) jpeg_write_marker - JPP((j_compress_ptr cinfo, int marker, - const JOCTET * dataptr, unsigned int datalen)); -/* Same, but piecemeal. */ -EXTERN(void) jpeg_write_m_header - JPP((j_compress_ptr cinfo, int marker, unsigned int datalen)); -EXTERN(void) jpeg_write_m_byte - JPP((j_compress_ptr cinfo, int val)); - -/* Alternate compression function: just write an abbreviated table file */ -EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo)); - -/* Decompression startup: read start of JPEG datastream to see what's there */ -EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo, - boolean require_image)); -/* Return value is one of: */ -#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */ -#define JPEG_HEADER_OK 1 /* Found valid image datastream */ -#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */ -/* If you pass require_image = TRUE (normal case), you need not check for - * a TABLES_ONLY return code; an abbreviated file will cause an error exit. - * JPEG_SUSPENDED is only possible if you use a data source module that can - * give a suspension return (the stdio source module doesn't). - */ - -/* Main entry points for decompression */ -EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo)); -EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo, - JSAMPARRAY scanlines, - JDIMENSION max_lines)); -EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo)); - -/* Replaces jpeg_read_scanlines when reading raw downsampled data. */ -EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo, - JSAMPIMAGE data, - JDIMENSION max_lines)); - -/* Additional entry points for buffered-image mode. */ -EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo)); -EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo, - int scan_number)); -EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo)); -EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); -EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); -/* Return value is one of: */ -/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ -#define JPEG_REACHED_SOS 1 /* Reached start of new scan */ -#define JPEG_REACHED_EOI 2 /* Reached end of image */ -#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ -#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ - -/* Precalculate output dimensions for current decompression parameters. */ -EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); - -/* Control saving of COM and APPn markers into marker_list. */ -EXTERN(void) jpeg_save_markers - JPP((j_decompress_ptr cinfo, int marker_code, - unsigned int length_limit)); - -/* Install a special processing method for COM or APPn markers. */ -EXTERN(void) jpeg_set_marker_processor - JPP((j_decompress_ptr cinfo, int marker_code, - jpeg_marker_parser_method routine)); - -/* Read or write raw DCT coefficients --- useful for lossless transcoding. */ -EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays)); -EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo, - j_compress_ptr dstinfo)); - -/* If you choose to abort compression or decompression before completing - * jpeg_finish_(de)compress, then you need to clean up to release memory, - * temporary files, etc. You can just call jpeg_destroy_(de)compress - * if you're done with the JPEG object, but if you want to clean it up and - * reuse it, call this: - */ -EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo)); - -/* Generic versions of jpeg_abort and jpeg_destroy that work on either - * flavor of JPEG object. These may be more convenient in some places. - */ -EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); -EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); - -/* Default restart-marker-resync procedure for use by data source modules */ -EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, - int desired)); - - -/* These marker codes are exported since applications and data source modules - * are likely to want to use them. - */ - -#define JPEG_RST0 0xD0 /* RST0 marker code */ -#define JPEG_EOI 0xD9 /* EOI marker code */ -#define JPEG_APP0 0xE0 /* APP0 marker code */ -#define JPEG_COM 0xFE /* COM marker code */ - - -/* If we have a brain-damaged compiler that emits warnings (or worse, errors) - * for structure definitions that are never filled in, keep it quiet by - * supplying dummy definitions for the various substructures. - */ - -#ifdef INCOMPLETE_TYPES_BROKEN -#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */ -struct jvirt_sarray_control { long dummy; }; -struct jvirt_barray_control { long dummy; }; -struct jpeg_comp_master { long dummy; }; -struct jpeg_c_main_controller { long dummy; }; -struct jpeg_c_prep_controller { long dummy; }; -struct jpeg_c_coef_controller { long dummy; }; -struct jpeg_marker_writer { long dummy; }; -struct jpeg_color_converter { long dummy; }; -struct jpeg_downsampler { long dummy; }; -struct jpeg_forward_dct { long dummy; }; -struct jpeg_entropy_encoder { long dummy; }; -struct jpeg_decomp_master { long dummy; }; -struct jpeg_d_main_controller { long dummy; }; -struct jpeg_d_coef_controller { long dummy; }; -struct jpeg_d_post_controller { long dummy; }; -struct jpeg_input_controller { long dummy; }; -struct jpeg_marker_reader { long dummy; }; -struct jpeg_entropy_decoder { long dummy; }; -struct jpeg_inverse_dct { long dummy; }; -struct jpeg_upsampler { long dummy; }; -struct jpeg_color_deconverter { long dummy; }; -struct jpeg_color_quantizer { long dummy; }; -#endif /* JPEG_INTERNALS */ -#endif /* INCOMPLETE_TYPES_BROKEN */ - - -/* - * The JPEG library modules define JPEG_INTERNALS before including this file. - * The internal structure declarations are read only when that is true. - * Applications using the library should not include jpegint.h, but may wish - * to include jerror.h. - */ - -#ifdef JPEG_INTERNALS -#include "jpegint.h" /* fetch private declarations */ -#include "jerror.h" /* fetch error codes too */ -#endif - -#endif /* JPEGLIB_H */ diff --git a/oversampling/WDL/jpeglib/jquant1.c b/oversampling/WDL/jpeglib/jquant1.c deleted file mode 100644 index b2f96aa..0000000 --- a/oversampling/WDL/jpeglib/jquant1.c +++ /dev/null @@ -1,856 +0,0 @@ -/* - * jquant1.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains 1-pass color quantization (color mapping) routines. - * These routines provide mapping to a fixed color map using equally spaced - * color values. Optional Floyd-Steinberg or ordered dithering is available. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -#ifdef QUANT_1PASS_SUPPORTED - - -/* - * The main purpose of 1-pass quantization is to provide a fast, if not very - * high quality, colormapped output capability. A 2-pass quantizer usually - * gives better visual quality; however, for quantized grayscale output this - * quantizer is perfectly adequate. Dithering is highly recommended with this - * quantizer, though you can turn it off if you really want to. - * - * In 1-pass quantization the colormap must be chosen in advance of seeing the - * image. We use a map consisting of all combinations of Ncolors[i] color - * values for the i'th component. The Ncolors[] values are chosen so that - * their product, the total number of colors, is no more than that requested. - * (In most cases, the product will be somewhat less.) - * - * Since the colormap is orthogonal, the representative value for each color - * component can be determined without considering the other components; - * then these indexes can be combined into a colormap index by a standard - * N-dimensional-array-subscript calculation. Most of the arithmetic involved - * can be precalculated and stored in the lookup table colorindex[]. - * colorindex[i][j] maps pixel value j in component i to the nearest - * representative value (grid plane) for that component; this index is - * multiplied by the array stride for component i, so that the - * index of the colormap entry closest to a given pixel value is just - * sum( colorindex[component-number][pixel-component-value] ) - * Aside from being fast, this scheme allows for variable spacing between - * representative values with no additional lookup cost. - * - * If gamma correction has been applied in color conversion, it might be wise - * to adjust the color grid spacing so that the representative colors are - * equidistant in linear space. At this writing, gamma correction is not - * implemented by jdcolor, so nothing is done here. - */ - - -/* Declarations for ordered dithering. - * - * We use a standard 16x16 ordered dither array. The basic concept of ordered - * dithering is described in many references, for instance Dale Schumacher's - * chapter II.2 of Graphics Gems II (James Arvo, ed. Academic Press, 1991). - * In place of Schumacher's comparisons against a "threshold" value, we add a - * "dither" value to the input pixel and then round the result to the nearest - * output value. The dither value is equivalent to (0.5 - threshold) times - * the distance between output values. For ordered dithering, we assume that - * the output colors are equally spaced; if not, results will probably be - * worse, since the dither may be too much or too little at a given point. - * - * The normal calculation would be to form pixel value + dither, range-limit - * this to 0..MAXJSAMPLE, and then index into the colorindex table as usual. - * We can skip the separate range-limiting step by extending the colorindex - * table in both directions. - */ - -#define ODITHER_SIZE 16 /* dimension of dither matrix */ -/* NB: if ODITHER_SIZE is not a power of 2, ODITHER_MASK uses will break */ -#define ODITHER_CELLS (ODITHER_SIZE*ODITHER_SIZE) /* # cells in matrix */ -#define ODITHER_MASK (ODITHER_SIZE-1) /* mask for wrapping around counters */ - -typedef int ODITHER_MATRIX[ODITHER_SIZE][ODITHER_SIZE]; -typedef int (*ODITHER_MATRIX_PTR)[ODITHER_SIZE]; - -static const UINT8 base_dither_matrix[ODITHER_SIZE][ODITHER_SIZE] = { - /* Bayer's order-4 dither array. Generated by the code given in - * Stephen Hawley's article "Ordered Dithering" in Graphics Gems I. - * The values in this array must range from 0 to ODITHER_CELLS-1. - */ - { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 }, - { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 }, - { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 }, - { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 }, - { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 }, - { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 }, - { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 }, - { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 }, - { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 }, - { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 }, - { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 }, - { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 }, - { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 }, - { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 }, - { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 }, - { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 } -}; - - -/* Declarations for Floyd-Steinberg dithering. - * - * Errors are accumulated into the array fserrors[], at a resolution of - * 1/16th of a pixel count. The error at a given pixel is propagated - * to its not-yet-processed neighbors using the standard F-S fractions, - * ... (here) 7/16 - * 3/16 5/16 1/16 - * We work left-to-right on even rows, right-to-left on odd rows. - * - * We can get away with a single array (holding one row's worth of errors) - * by using it to store the current row's errors at pixel columns not yet - * processed, but the next row's errors at columns already processed. We - * need only a few extra variables to hold the errors immediately around the - * current column. (If we are lucky, those variables are in registers, but - * even if not, they're probably cheaper to access than array elements are.) - * - * The fserrors[] array is indexed [component#][position]. - * We provide (#columns + 2) entries per component; the extra entry at each - * end saves us from special-casing the first and last pixels. - * - * Note: on a wide image, we might not have enough room in a PC's near data - * segment to hold the error array; so it is allocated with alloc_large. - */ - -#if BITS_IN_JSAMPLE == 8 -typedef INT16 FSERROR; /* 16 bits should be enough */ -typedef int LOCFSERROR; /* use 'int' for calculation temps */ -#else -typedef INT32 FSERROR; /* may need more than 16 bits */ -typedef INT32 LOCFSERROR; /* be sure calculation temps are big enough */ -#endif - -typedef FSERROR FAR *FSERRPTR; /* pointer to error array (in FAR storage!) */ - - -/* Private subobject */ - -#define MAX_Q_COMPS 4 /* max components I can handle */ - -typedef struct { - struct jpeg_color_quantizer pub; /* public fields */ - - /* Initially allocated colormap is saved here */ - JSAMPARRAY sv_colormap; /* The color map as a 2-D pixel array */ - int sv_actual; /* number of entries in use */ - - JSAMPARRAY colorindex; /* Precomputed mapping for speed */ - /* colorindex[i][j] = index of color closest to pixel value j in component i, - * premultiplied as described above. Since colormap indexes must fit into - * JSAMPLEs, the entries of this array will too. - */ - boolean is_padded; /* is the colorindex padded for odither? */ - - int Ncolors[MAX_Q_COMPS]; /* # of values alloced to each component */ - - /* Variables for ordered dithering */ - int row_index; /* cur row's vertical index in dither matrix */ - ODITHER_MATRIX_PTR odither[MAX_Q_COMPS]; /* one dither array per component */ - - /* Variables for Floyd-Steinberg dithering */ - FSERRPTR fserrors[MAX_Q_COMPS]; /* accumulated errors */ - boolean on_odd_row; /* flag to remember which row we are on */ -} my_cquantizer; - -typedef my_cquantizer * my_cquantize_ptr; - - -/* - * Policy-making subroutines for create_colormap and create_colorindex. - * These routines determine the colormap to be used. The rest of the module - * only assumes that the colormap is orthogonal. - * - * * select_ncolors decides how to divvy up the available colors - * among the components. - * * output_value defines the set of representative values for a component. - * * largest_input_value defines the mapping from input values to - * representative values for a component. - * Note that the latter two routines may impose different policies for - * different components, though this is not currently done. - */ - - -LOCAL(int) -select_ncolors (j_decompress_ptr cinfo, int Ncolors[]) -/* Determine allocation of desired colors to components, */ -/* and fill in Ncolors[] array to indicate choice. */ -/* Return value is total number of colors (product of Ncolors[] values). */ -{ - int nc = cinfo->out_color_components; /* number of color components */ - int max_colors = cinfo->desired_number_of_colors; - int total_colors, iroot, i, j; - boolean changed; - long temp; - static const int RGB_order[3] = { RGB_GREEN, RGB_RED, RGB_BLUE }; - - /* We can allocate at least the nc'th root of max_colors per component. */ - /* Compute floor(nc'th root of max_colors). */ - iroot = 1; - do { - iroot++; - temp = iroot; /* set temp = iroot ** nc */ - for (i = 1; i < nc; i++) - temp *= iroot; - } while (temp <= (long) max_colors); /* repeat till iroot exceeds root */ - iroot--; /* now iroot = floor(root) */ - - /* Must have at least 2 color values per component */ - if (iroot < 2) - ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, (int) temp); - - /* Initialize to iroot color values for each component */ - total_colors = 1; - for (i = 0; i < nc; i++) { - Ncolors[i] = iroot; - total_colors *= iroot; - } - /* We may be able to increment the count for one or more components without - * exceeding max_colors, though we know not all can be incremented. - * Sometimes, the first component can be incremented more than once! - * (Example: for 16 colors, we start at 2*2*2, go to 3*2*2, then 4*2*2.) - * In RGB colorspace, try to increment G first, then R, then B. - */ - do { - changed = FALSE; - for (i = 0; i < nc; i++) { - j = (cinfo->out_color_space == JCS_RGB ? RGB_order[i] : i); - /* calculate new total_colors if Ncolors[j] is incremented */ - temp = total_colors / Ncolors[j]; - temp *= Ncolors[j]+1; /* done in long arith to avoid oflo */ - if (temp > (long) max_colors) - break; /* won't fit, done with this pass */ - Ncolors[j]++; /* OK, apply the increment */ - total_colors = (int) temp; - changed = TRUE; - } - } while (changed); - - return total_colors; -} - - -LOCAL(int) -output_value (j_decompress_ptr cinfo, int ci, int j, int maxj) -/* Return j'th output value, where j will range from 0 to maxj */ -/* The output values must fall in 0..MAXJSAMPLE in increasing order */ -{ - /* We always provide values 0 and MAXJSAMPLE for each component; - * any additional values are equally spaced between these limits. - * (Forcing the upper and lower values to the limits ensures that - * dithering can't produce a color outside the selected gamut.) - */ - return (int) (((INT32) j * MAXJSAMPLE + maxj/2) / maxj); -} - - -LOCAL(int) -largest_input_value (j_decompress_ptr cinfo, int ci, int j, int maxj) -/* Return largest input value that should map to j'th output value */ -/* Must have largest(j=0) >= 0, and largest(j=maxj) >= MAXJSAMPLE */ -{ - /* Breakpoints are halfway between values returned by output_value */ - return (int) (((INT32) (2*j + 1) * MAXJSAMPLE + maxj) / (2*maxj)); -} - - -/* - * Create the colormap. - */ - -LOCAL(void) -create_colormap (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - JSAMPARRAY colormap; /* Created colormap */ - int total_colors; /* Number of distinct output colors */ - int i,j,k, nci, blksize, blkdist, ptr, val; - - /* Select number of colors for each component */ - total_colors = select_ncolors(cinfo, cquantize->Ncolors); - - /* Report selected color counts */ - if (cinfo->out_color_components == 3) - TRACEMS4(cinfo, 1, JTRC_QUANT_3_NCOLORS, - total_colors, cquantize->Ncolors[0], - cquantize->Ncolors[1], cquantize->Ncolors[2]); - else - TRACEMS1(cinfo, 1, JTRC_QUANT_NCOLORS, total_colors); - - /* Allocate and fill in the colormap. */ - /* The colors are ordered in the map in standard row-major order, */ - /* i.e. rightmost (highest-indexed) color changes most rapidly. */ - - colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) total_colors, (JDIMENSION) cinfo->out_color_components); - - /* blksize is number of adjacent repeated entries for a component */ - /* blkdist is distance between groups of identical entries for a component */ - blkdist = total_colors; - - for (i = 0; i < cinfo->out_color_components; i++) { - /* fill in colormap entries for i'th color component */ - nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ - blksize = blkdist / nci; - for (j = 0; j < nci; j++) { - /* Compute j'th output value (out of nci) for component */ - val = output_value(cinfo, i, j, nci-1); - /* Fill in all colormap entries that have this value of this component */ - for (ptr = j * blksize; ptr < total_colors; ptr += blkdist) { - /* fill in blksize entries beginning at ptr */ - for (k = 0; k < blksize; k++) - colormap[i][ptr+k] = (JSAMPLE) val; - } - } - blkdist = blksize; /* blksize of this color is blkdist of next */ - } - - /* Save the colormap in private storage, - * where it will survive color quantization mode changes. - */ - cquantize->sv_colormap = colormap; - cquantize->sv_actual = total_colors; -} - - -/* - * Create the color index table. - */ - -LOCAL(void) -create_colorindex (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - JSAMPROW indexptr; - int i,j,k, nci, blksize, val, pad; - - /* For ordered dither, we pad the color index tables by MAXJSAMPLE in - * each direction (input index values can be -MAXJSAMPLE .. 2*MAXJSAMPLE). - * This is not necessary in the other dithering modes. However, we - * flag whether it was done in case user changes dithering mode. - */ - if (cinfo->dither_mode == JDITHER_ORDERED) { - pad = MAXJSAMPLE*2; - cquantize->is_padded = TRUE; - } else { - pad = 0; - cquantize->is_padded = FALSE; - } - - cquantize->colorindex = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (JDIMENSION) (MAXJSAMPLE+1 + pad), - (JDIMENSION) cinfo->out_color_components); - - /* blksize is number of adjacent repeated entries for a component */ - blksize = cquantize->sv_actual; - - for (i = 0; i < cinfo->out_color_components; i++) { - /* fill in colorindex entries for i'th color component */ - nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ - blksize = blksize / nci; - - /* adjust colorindex pointers to provide padding at negative indexes. */ - if (pad) - cquantize->colorindex[i] += MAXJSAMPLE; - - /* in loop, val = index of current output value, */ - /* and k = largest j that maps to current val */ - indexptr = cquantize->colorindex[i]; - val = 0; - k = largest_input_value(cinfo, i, 0, nci-1); - for (j = 0; j <= MAXJSAMPLE; j++) { - while (j > k) /* advance val if past boundary */ - k = largest_input_value(cinfo, i, ++val, nci-1); - /* premultiply so that no multiplication needed in main processing */ - indexptr[j] = (JSAMPLE) (val * blksize); - } - /* Pad at both ends if necessary */ - if (pad) - for (j = 1; j <= MAXJSAMPLE; j++) { - indexptr[-j] = indexptr[0]; - indexptr[MAXJSAMPLE+j] = indexptr[MAXJSAMPLE]; - } - } -} - - -/* - * Create an ordered-dither array for a component having ncolors - * distinct output values. - */ - -LOCAL(ODITHER_MATRIX_PTR) -make_odither_array (j_decompress_ptr cinfo, int ncolors) -{ - ODITHER_MATRIX_PTR odither; - int j,k; - INT32 num,den; - - odither = (ODITHER_MATRIX_PTR) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(ODITHER_MATRIX)); - /* The inter-value distance for this color is MAXJSAMPLE/(ncolors-1). - * Hence the dither value for the matrix cell with fill order f - * (f=0..N-1) should be (N-1-2*f)/(2*N) * MAXJSAMPLE/(ncolors-1). - * On 16-bit-int machine, be careful to avoid overflow. - */ - den = 2 * ODITHER_CELLS * ((INT32) (ncolors - 1)); - for (j = 0; j < ODITHER_SIZE; j++) { - for (k = 0; k < ODITHER_SIZE; k++) { - num = ((INT32) (ODITHER_CELLS-1 - 2*((int)base_dither_matrix[j][k]))) - * MAXJSAMPLE; - /* Ensure round towards zero despite C's lack of consistency - * about rounding negative values in integer division... - */ - odither[j][k] = (int) (num<0 ? -((-num)/den) : num/den); - } - } - return odither; -} - - -/* - * Create the ordered-dither tables. - * Components having the same number of representative colors may - * share a dither table. - */ - -LOCAL(void) -create_odither_tables (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - ODITHER_MATRIX_PTR odither; - int i, j, nci; - - for (i = 0; i < cinfo->out_color_components; i++) { - nci = cquantize->Ncolors[i]; /* # of distinct values for this color */ - odither = NULL; /* search for matching prior component */ - for (j = 0; j < i; j++) { - if (nci == cquantize->Ncolors[j]) { - odither = cquantize->odither[j]; - break; - } - } - if (odither == NULL) /* need a new table? */ - odither = make_odither_array(cinfo, nci); - cquantize->odither[i] = odither; - } -} - - -/* - * Map some rows of pixels to the output colormapped representation. - */ - -METHODDEF(void) -color_quantize (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* General case, no dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - JSAMPARRAY colorindex = cquantize->colorindex; - register int pixcode, ci; - register JSAMPROW ptrin, ptrout; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - register int nc = cinfo->out_color_components; - - for (row = 0; row < num_rows; row++) { - ptrin = input_buf[row]; - ptrout = output_buf[row]; - for (col = width; col > 0; col--) { - pixcode = 0; - for (ci = 0; ci < nc; ci++) { - pixcode += GETJSAMPLE(colorindex[ci][GETJSAMPLE(*ptrin++)]); - } - *ptrout++ = (JSAMPLE) pixcode; - } - } -} - - -METHODDEF(void) -color_quantize3 (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* Fast path for out_color_components==3, no dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register int pixcode; - register JSAMPROW ptrin, ptrout; - JSAMPROW colorindex0 = cquantize->colorindex[0]; - JSAMPROW colorindex1 = cquantize->colorindex[1]; - JSAMPROW colorindex2 = cquantize->colorindex[2]; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - ptrin = input_buf[row]; - ptrout = output_buf[row]; - for (col = width; col > 0; col--) { - pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*ptrin++)]); - pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*ptrin++)]); - pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*ptrin++)]); - *ptrout++ = (JSAMPLE) pixcode; - } - } -} - - -METHODDEF(void) -quantize_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* General case, with ordered dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register JSAMPROW input_ptr; - register JSAMPROW output_ptr; - JSAMPROW colorindex_ci; - int * dither; /* points to active row of dither matrix */ - int row_index, col_index; /* current indexes into dither matrix */ - int nc = cinfo->out_color_components; - int ci; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - /* Initialize output values to 0 so can process components separately */ - jzero_far((void FAR *) output_buf[row], - (size_t) (width * SIZEOF(JSAMPLE))); - row_index = cquantize->row_index; - for (ci = 0; ci < nc; ci++) { - input_ptr = input_buf[row] + ci; - output_ptr = output_buf[row]; - colorindex_ci = cquantize->colorindex[ci]; - dither = cquantize->odither[ci][row_index]; - col_index = 0; - - for (col = width; col > 0; col--) { - /* Form pixel value + dither, range-limit to 0..MAXJSAMPLE, - * select output value, accumulate into output code for this pixel. - * Range-limiting need not be done explicitly, as we have extended - * the colorindex table to produce the right answers for out-of-range - * inputs. The maximum dither is +- MAXJSAMPLE; this sets the - * required amount of padding. - */ - *output_ptr += colorindex_ci[GETJSAMPLE(*input_ptr)+dither[col_index]]; - input_ptr += nc; - output_ptr++; - col_index = (col_index + 1) & ODITHER_MASK; - } - } - /* Advance row index for next row */ - row_index = (row_index + 1) & ODITHER_MASK; - cquantize->row_index = row_index; - } -} - - -METHODDEF(void) -quantize3_ord_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* Fast path for out_color_components==3, with ordered dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register int pixcode; - register JSAMPROW input_ptr; - register JSAMPROW output_ptr; - JSAMPROW colorindex0 = cquantize->colorindex[0]; - JSAMPROW colorindex1 = cquantize->colorindex[1]; - JSAMPROW colorindex2 = cquantize->colorindex[2]; - int * dither0; /* points to active row of dither matrix */ - int * dither1; - int * dither2; - int row_index, col_index; /* current indexes into dither matrix */ - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - row_index = cquantize->row_index; - input_ptr = input_buf[row]; - output_ptr = output_buf[row]; - dither0 = cquantize->odither[0][row_index]; - dither1 = cquantize->odither[1][row_index]; - dither2 = cquantize->odither[2][row_index]; - col_index = 0; - - for (col = width; col > 0; col--) { - pixcode = GETJSAMPLE(colorindex0[GETJSAMPLE(*input_ptr++) + - dither0[col_index]]); - pixcode += GETJSAMPLE(colorindex1[GETJSAMPLE(*input_ptr++) + - dither1[col_index]]); - pixcode += GETJSAMPLE(colorindex2[GETJSAMPLE(*input_ptr++) + - dither2[col_index]]); - *output_ptr++ = (JSAMPLE) pixcode; - col_index = (col_index + 1) & ODITHER_MASK; - } - row_index = (row_index + 1) & ODITHER_MASK; - cquantize->row_index = row_index; - } -} - - -METHODDEF(void) -quantize_fs_dither (j_decompress_ptr cinfo, JSAMPARRAY input_buf, - JSAMPARRAY output_buf, int num_rows) -/* General case, with Floyd-Steinberg dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - register LOCFSERROR cur; /* current error or pixel value */ - LOCFSERROR belowerr; /* error for pixel below cur */ - LOCFSERROR bpreverr; /* error for below/prev col */ - LOCFSERROR bnexterr; /* error for below/next col */ - LOCFSERROR delta; - register FSERRPTR errorptr; /* => fserrors[] at column before current */ - register JSAMPROW input_ptr; - register JSAMPROW output_ptr; - JSAMPROW colorindex_ci; - JSAMPROW colormap_ci; - int pixcode; - int nc = cinfo->out_color_components; - int dir; /* 1 for left-to-right, -1 for right-to-left */ - int dirnc; /* dir * nc */ - int ci; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - JSAMPLE *range_limit = cinfo->sample_range_limit; - SHIFT_TEMPS - - for (row = 0; row < num_rows; row++) { - /* Initialize output values to 0 so can process components separately */ - jzero_far((void FAR *) output_buf[row], - (size_t) (width * SIZEOF(JSAMPLE))); - for (ci = 0; ci < nc; ci++) { - input_ptr = input_buf[row] + ci; - output_ptr = output_buf[row]; - if (cquantize->on_odd_row) { - /* work right to left in this row */ - input_ptr += (width-1) * nc; /* so point to rightmost pixel */ - output_ptr += width-1; - dir = -1; - dirnc = -nc; - errorptr = cquantize->fserrors[ci] + (width+1); /* => entry after last column */ - } else { - /* work left to right in this row */ - dir = 1; - dirnc = nc; - errorptr = cquantize->fserrors[ci]; /* => entry before first column */ - } - colorindex_ci = cquantize->colorindex[ci]; - colormap_ci = cquantize->sv_colormap[ci]; - /* Preset error values: no error propagated to first pixel from left */ - cur = 0; - /* and no error propagated to row below yet */ - belowerr = bpreverr = 0; - - for (col = width; col > 0; col--) { - /* cur holds the error propagated from the previous pixel on the - * current line. Add the error propagated from the previous line - * to form the complete error correction term for this pixel, and - * round the error term (which is expressed * 16) to an integer. - * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct - * for either sign of the error value. - * Note: errorptr points to *previous* column's array entry. - */ - cur = RIGHT_SHIFT(cur + errorptr[dir] + 8, 4); - /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. - * The maximum error is +- MAXJSAMPLE; this sets the required size - * of the range_limit array. - */ - cur += GETJSAMPLE(*input_ptr); - cur = GETJSAMPLE(range_limit[cur]); - /* Select output value, accumulate into output code for this pixel */ - pixcode = GETJSAMPLE(colorindex_ci[cur]); - *output_ptr += (JSAMPLE) pixcode; - /* Compute actual representation error at this pixel */ - /* Note: we can do this even though we don't have the final */ - /* pixel code, because the colormap is orthogonal. */ - cur -= GETJSAMPLE(colormap_ci[pixcode]); - /* Compute error fractions to be propagated to adjacent pixels. - * Add these into the running sums, and simultaneously shift the - * next-line error sums left by 1 column. - */ - bnexterr = cur; - delta = cur * 2; - cur += delta; /* form error * 3 */ - errorptr[0] = (FSERROR) (bpreverr + cur); - cur += delta; /* form error * 5 */ - bpreverr = belowerr + cur; - belowerr = bnexterr; - cur += delta; /* form error * 7 */ - /* At this point cur contains the 7/16 error value to be propagated - * to the next pixel on the current line, and all the errors for the - * next line have been shifted over. We are therefore ready to move on. - */ - input_ptr += dirnc; /* advance input ptr to next column */ - output_ptr += dir; /* advance output ptr to next column */ - errorptr += dir; /* advance errorptr to current column */ - } - /* Post-loop cleanup: we must unload the final error value into the - * final fserrors[] entry. Note we need not unload belowerr because - * it is for the dummy column before or after the actual array. - */ - errorptr[0] = (FSERROR) bpreverr; /* unload prev err into array */ - } - cquantize->on_odd_row = (cquantize->on_odd_row ? FALSE : TRUE); - } -} - - -/* - * Allocate workspace for Floyd-Steinberg errors. - */ - -LOCAL(void) -alloc_fs_workspace (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - size_t arraysize; - int i; - - arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); - for (i = 0; i < cinfo->out_color_components; i++) { - cquantize->fserrors[i] = (FSERRPTR) - (*cinfo->mem->alloc_large)((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); - } -} - - -/* - * Initialize for one-pass color quantization. - */ - -METHODDEF(void) -start_pass_1_quant (j_decompress_ptr cinfo, boolean is_pre_scan) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - size_t arraysize; - int i; - - /* Install my colormap. */ - cinfo->colormap = cquantize->sv_colormap; - cinfo->actual_number_of_colors = cquantize->sv_actual; - - /* Initialize for desired dithering mode. */ - switch (cinfo->dither_mode) { - case JDITHER_NONE: - if (cinfo->out_color_components == 3) - cquantize->pub.color_quantize = color_quantize3; - else - cquantize->pub.color_quantize = color_quantize; - break; - case JDITHER_ORDERED: - if (cinfo->out_color_components == 3) - cquantize->pub.color_quantize = quantize3_ord_dither; - else - cquantize->pub.color_quantize = quantize_ord_dither; - cquantize->row_index = 0; /* initialize state for ordered dither */ - /* If user changed to ordered dither from another mode, - * we must recreate the color index table with padding. - * This will cost extra space, but probably isn't very likely. - */ - if (! cquantize->is_padded) - create_colorindex(cinfo); - /* Create ordered-dither tables if we didn't already. */ - if (cquantize->odither[0] == NULL) - create_odither_tables(cinfo); - break; - case JDITHER_FS: - cquantize->pub.color_quantize = quantize_fs_dither; - cquantize->on_odd_row = FALSE; /* initialize state for F-S dither */ - /* Allocate Floyd-Steinberg workspace if didn't already. */ - if (cquantize->fserrors[0] == NULL) - alloc_fs_workspace(cinfo); - /* Initialize the propagated errors to zero. */ - arraysize = (size_t) ((cinfo->output_width + 2) * SIZEOF(FSERROR)); - for (i = 0; i < cinfo->out_color_components; i++) - jzero_far((void FAR *) cquantize->fserrors[i], arraysize); - break; - default: - ERREXIT(cinfo, JERR_NOT_COMPILED); - break; - } -} - - -/* - * Finish up at the end of the pass. - */ - -METHODDEF(void) -finish_pass_1_quant (j_decompress_ptr cinfo) -{ - /* no work in 1-pass case */ -} - - -/* - * Switch to a new external colormap between output passes. - * Shouldn't get to this module! - */ - -METHODDEF(void) -new_color_map_1_quant (j_decompress_ptr cinfo) -{ - ERREXIT(cinfo, JERR_MODE_CHANGE); -} - - -/* - * Module initialization routine for 1-pass color quantization. - */ - -GLOBAL(void) -jinit_1pass_quantizer (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize; - - cquantize = (my_cquantize_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_cquantizer)); - cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; - cquantize->pub.start_pass = start_pass_1_quant; - cquantize->pub.finish_pass = finish_pass_1_quant; - cquantize->pub.new_color_map = new_color_map_1_quant; - cquantize->fserrors[0] = NULL; /* Flag FS workspace not allocated */ - cquantize->odither[0] = NULL; /* Also flag odither arrays not allocated */ - - /* Make sure my internal arrays won't overflow */ - if (cinfo->out_color_components > MAX_Q_COMPS) - ERREXIT1(cinfo, JERR_QUANT_COMPONENTS, MAX_Q_COMPS); - /* Make sure colormap indexes can be represented by JSAMPLEs */ - if (cinfo->desired_number_of_colors > (MAXJSAMPLE+1)) - ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXJSAMPLE+1); - - /* Create the colormap and color index table. */ - create_colormap(cinfo); - create_colorindex(cinfo); - - /* Allocate Floyd-Steinberg workspace now if requested. - * We do this now since it is FAR storage and may affect the memory - * manager's space calculations. If the user changes to FS dither - * mode in a later pass, we will allocate the space then, and will - * possibly overrun the max_memory_to_use setting. - */ - if (cinfo->dither_mode == JDITHER_FS) - alloc_fs_workspace(cinfo); -} - -#endif /* QUANT_1PASS_SUPPORTED */ diff --git a/oversampling/WDL/jpeglib/jquant2.c b/oversampling/WDL/jpeglib/jquant2.c deleted file mode 100644 index af601e3..0000000 --- a/oversampling/WDL/jpeglib/jquant2.c +++ /dev/null @@ -1,1310 +0,0 @@ -/* - * jquant2.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains 2-pass color quantization (color mapping) routines. - * These routines provide selection of a custom color map for an image, - * followed by mapping of the image to that color map, with optional - * Floyd-Steinberg dithering. - * It is also possible to use just the second pass to map to an arbitrary - * externally-given color map. - * - * Note: ordered dithering is not supported, since there isn't any fast - * way to compute intercolor distances; it's unclear that ordered dither's - * fundamental assumptions even hold with an irregularly spaced color map. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - -#ifdef QUANT_2PASS_SUPPORTED - - -/* - * This module implements the well-known Heckbert paradigm for color - * quantization. Most of the ideas used here can be traced back to - * Heckbert's seminal paper - * Heckbert, Paul. "Color Image Quantization for Frame Buffer Display", - * Proc. SIGGRAPH '82, Computer Graphics v.16 #3 (July 1982), pp 297-304. - * - * In the first pass over the image, we accumulate a histogram showing the - * usage count of each possible color. To keep the histogram to a reasonable - * size, we reduce the precision of the input; typical practice is to retain - * 5 or 6 bits per color, so that 8 or 4 different input values are counted - * in the same histogram cell. - * - * Next, the color-selection step begins with a box representing the whole - * color space, and repeatedly splits the "largest" remaining box until we - * have as many boxes as desired colors. Then the mean color in each - * remaining box becomes one of the possible output colors. - * - * The second pass over the image maps each input pixel to the closest output - * color (optionally after applying a Floyd-Steinberg dithering correction). - * This mapping is logically trivial, but making it go fast enough requires - * considerable care. - * - * Heckbert-style quantizers vary a good deal in their policies for choosing - * the "largest" box and deciding where to cut it. The particular policies - * used here have proved out well in experimental comparisons, but better ones - * may yet be found. - * - * In earlier versions of the IJG code, this module quantized in YCbCr color - * space, processing the raw upsampled data without a color conversion step. - * This allowed the color conversion math to be done only once per colormap - * entry, not once per pixel. However, that optimization precluded other - * useful optimizations (such as merging color conversion with upsampling) - * and it also interfered with desired capabilities such as quantizing to an - * externally-supplied colormap. We have therefore abandoned that approach. - * The present code works in the post-conversion color space, typically RGB. - * - * To improve the visual quality of the results, we actually work in scaled - * RGB space, giving G distances more weight than R, and R in turn more than - * B. To do everything in integer math, we must use integer scale factors. - * The 2/3/1 scale factors used here correspond loosely to the relative - * weights of the colors in the NTSC grayscale equation. - * If you want to use this code to quantize a non-RGB color space, you'll - * probably need to change these scale factors. - */ - -#define R_SCALE 2 /* scale R distances by this much */ -#define G_SCALE 3 /* scale G distances by this much */ -#define B_SCALE 1 /* and B by this much */ - -/* Relabel R/G/B as components 0/1/2, respecting the RGB ordering defined - * in jmorecfg.h. As the code stands, it will do the right thing for R,G,B - * and B,G,R orders. If you define some other weird order in jmorecfg.h, - * you'll get compile errors until you extend this logic. In that case - * you'll probably want to tweak the histogram sizes too. - */ - -#if RGB_RED == 0 -#define C0_SCALE R_SCALE -#endif -#if RGB_BLUE == 0 -#define C0_SCALE B_SCALE -#endif -#if RGB_GREEN == 1 -#define C1_SCALE G_SCALE -#endif -#if RGB_RED == 2 -#define C2_SCALE R_SCALE -#endif -#if RGB_BLUE == 2 -#define C2_SCALE B_SCALE -#endif - - -/* - * First we have the histogram data structure and routines for creating it. - * - * The number of bits of precision can be adjusted by changing these symbols. - * We recommend keeping 6 bits for G and 5 each for R and B. - * If you have plenty of memory and cycles, 6 bits all around gives marginally - * better results; if you are short of memory, 5 bits all around will save - * some space but degrade the results. - * To maintain a fully accurate histogram, we'd need to allocate a "long" - * (preferably unsigned long) for each cell. In practice this is overkill; - * we can get by with 16 bits per cell. Few of the cell counts will overflow, - * and clamping those that do overflow to the maximum value will give close- - * enough results. This reduces the recommended histogram size from 256Kb - * to 128Kb, which is a useful savings on PC-class machines. - * (In the second pass the histogram space is re-used for pixel mapping data; - * in that capacity, each cell must be able to store zero to the number of - * desired colors. 16 bits/cell is plenty for that too.) - * Since the JPEG code is intended to run in small memory model on 80x86 - * machines, we can't just allocate the histogram in one chunk. Instead - * of a true 3-D array, we use a row of pointers to 2-D arrays. Each - * pointer corresponds to a C0 value (typically 2^5 = 32 pointers) and - * each 2-D array has 2^6*2^5 = 2048 or 2^6*2^6 = 4096 entries. Note that - * on 80x86 machines, the pointer row is in near memory but the actual - * arrays are in far memory (same arrangement as we use for image arrays). - */ - -#define MAXNUMCOLORS (MAXJSAMPLE+1) /* maximum size of colormap */ - -/* These will do the right thing for either R,G,B or B,G,R color order, - * but you may not like the results for other color orders. - */ -#define HIST_C0_BITS 5 /* bits of precision in R/B histogram */ -#define HIST_C1_BITS 6 /* bits of precision in G histogram */ -#define HIST_C2_BITS 5 /* bits of precision in B/R histogram */ - -/* Number of elements along histogram axes. */ -#define HIST_C0_ELEMS (1<cquantize; - register JSAMPROW ptr; - register histptr histp; - register hist3d histogram = cquantize->histogram; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - ptr = input_buf[row]; - for (col = width; col > 0; col--) { - /* get pixel value and index into the histogram */ - histp = & histogram[GETJSAMPLE(ptr[0]) >> C0_SHIFT] - [GETJSAMPLE(ptr[1]) >> C1_SHIFT] - [GETJSAMPLE(ptr[2]) >> C2_SHIFT]; - /* increment, check for overflow and undo increment if so. */ - if (++(*histp) <= 0) - (*histp)--; - ptr += 3; - } - } -} - - -/* - * Next we have the really interesting routines: selection of a colormap - * given the completed histogram. - * These routines work with a list of "boxes", each representing a rectangular - * subset of the input color space (to histogram precision). - */ - -typedef struct { - /* The bounds of the box (inclusive); expressed as histogram indexes */ - int c0min, c0max; - int c1min, c1max; - int c2min, c2max; - /* The volume (actually 2-norm) of the box */ - INT32 volume; - /* The number of nonzero histogram cells within this box */ - long colorcount; -} box; - -typedef box * boxptr; - - -LOCAL(boxptr) -find_biggest_color_pop (boxptr boxlist, int numboxes) -/* Find the splittable box with the largest color population */ -/* Returns NULL if no splittable boxes remain */ -{ - register boxptr boxp; - register int i; - register long maxc = 0; - boxptr which = NULL; - - for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { - if (boxp->colorcount > maxc && boxp->volume > 0) { - which = boxp; - maxc = boxp->colorcount; - } - } - return which; -} - - -LOCAL(boxptr) -find_biggest_volume (boxptr boxlist, int numboxes) -/* Find the splittable box with the largest (scaled) volume */ -/* Returns NULL if no splittable boxes remain */ -{ - register boxptr boxp; - register int i; - register INT32 maxv = 0; - boxptr which = NULL; - - for (i = 0, boxp = boxlist; i < numboxes; i++, boxp++) { - if (boxp->volume > maxv) { - which = boxp; - maxv = boxp->volume; - } - } - return which; -} - - -LOCAL(void) -update_box (j_decompress_ptr cinfo, boxptr boxp) -/* Shrink the min/max bounds of a box to enclose only nonzero elements, */ -/* and recompute its volume and population */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - histptr histp; - int c0,c1,c2; - int c0min,c0max,c1min,c1max,c2min,c2max; - INT32 dist0,dist1,dist2; - long ccount; - - c0min = boxp->c0min; c0max = boxp->c0max; - c1min = boxp->c1min; c1max = boxp->c1max; - c2min = boxp->c2min; c2max = boxp->c2max; - - if (c0max > c0min) - for (c0 = c0min; c0 <= c0max; c0++) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c0min = c0min = c0; - goto have_c0min; - } - } - have_c0min: - if (c0max > c0min) - for (c0 = c0max; c0 >= c0min; c0--) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c0max = c0max = c0; - goto have_c0max; - } - } - have_c0max: - if (c1max > c1min) - for (c1 = c1min; c1 <= c1max; c1++) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c1min = c1min = c1; - goto have_c1min; - } - } - have_c1min: - if (c1max > c1min) - for (c1 = c1max; c1 >= c1min; c1--) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) - if (*histp++ != 0) { - boxp->c1max = c1max = c1; - goto have_c1max; - } - } - have_c1max: - if (c2max > c2min) - for (c2 = c2min; c2 <= c2max; c2++) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1min][c2]; - for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) - if (*histp != 0) { - boxp->c2min = c2min = c2; - goto have_c2min; - } - } - have_c2min: - if (c2max > c2min) - for (c2 = c2max; c2 >= c2min; c2--) - for (c0 = c0min; c0 <= c0max; c0++) { - histp = & histogram[c0][c1min][c2]; - for (c1 = c1min; c1 <= c1max; c1++, histp += HIST_C2_ELEMS) - if (*histp != 0) { - boxp->c2max = c2max = c2; - goto have_c2max; - } - } - have_c2max: - - /* Update box volume. - * We use 2-norm rather than real volume here; this biases the method - * against making long narrow boxes, and it has the side benefit that - * a box is splittable iff norm > 0. - * Since the differences are expressed in histogram-cell units, - * we have to shift back to JSAMPLE units to get consistent distances; - * after which, we scale according to the selected distance scale factors. - */ - dist0 = ((c0max - c0min) << C0_SHIFT) * C0_SCALE; - dist1 = ((c1max - c1min) << C1_SHIFT) * C1_SCALE; - dist2 = ((c2max - c2min) << C2_SHIFT) * C2_SCALE; - boxp->volume = dist0*dist0 + dist1*dist1 + dist2*dist2; - - /* Now scan remaining volume of box and compute population */ - ccount = 0; - for (c0 = c0min; c0 <= c0max; c0++) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++, histp++) - if (*histp != 0) { - ccount++; - } - } - boxp->colorcount = ccount; -} - - -LOCAL(int) -median_cut (j_decompress_ptr cinfo, boxptr boxlist, int numboxes, - int desired_colors) -/* Repeatedly select and split the largest box until we have enough boxes */ -{ - int n,lb; - int c0,c1,c2,cmax; - register boxptr b1,b2; - - while (numboxes < desired_colors) { - /* Select box to split. - * Current algorithm: by population for first half, then by volume. - */ - if (numboxes*2 <= desired_colors) { - b1 = find_biggest_color_pop(boxlist, numboxes); - } else { - b1 = find_biggest_volume(boxlist, numboxes); - } - if (b1 == NULL) /* no splittable boxes left! */ - break; - b2 = &boxlist[numboxes]; /* where new box will go */ - /* Copy the color bounds to the new box. */ - b2->c0max = b1->c0max; b2->c1max = b1->c1max; b2->c2max = b1->c2max; - b2->c0min = b1->c0min; b2->c1min = b1->c1min; b2->c2min = b1->c2min; - /* Choose which axis to split the box on. - * Current algorithm: longest scaled axis. - * See notes in update_box about scaling distances. - */ - c0 = ((b1->c0max - b1->c0min) << C0_SHIFT) * C0_SCALE; - c1 = ((b1->c1max - b1->c1min) << C1_SHIFT) * C1_SCALE; - c2 = ((b1->c2max - b1->c2min) << C2_SHIFT) * C2_SCALE; - /* We want to break any ties in favor of green, then red, blue last. - * This code does the right thing for R,G,B or B,G,R color orders only. - */ -#if RGB_RED == 0 - cmax = c1; n = 1; - if (c0 > cmax) { cmax = c0; n = 0; } - if (c2 > cmax) { n = 2; } -#else - cmax = c1; n = 1; - if (c2 > cmax) { cmax = c2; n = 2; } - if (c0 > cmax) { n = 0; } -#endif - /* Choose split point along selected axis, and update box bounds. - * Current algorithm: split at halfway point. - * (Since the box has been shrunk to minimum volume, - * any split will produce two nonempty subboxes.) - * Note that lb value is max for lower box, so must be < old max. - */ - switch (n) { - case 0: - lb = (b1->c0max + b1->c0min) / 2; - b1->c0max = lb; - b2->c0min = lb+1; - break; - case 1: - lb = (b1->c1max + b1->c1min) / 2; - b1->c1max = lb; - b2->c1min = lb+1; - break; - case 2: - lb = (b1->c2max + b1->c2min) / 2; - b1->c2max = lb; - b2->c2min = lb+1; - break; - } - /* Update stats for boxes */ - update_box(cinfo, b1); - update_box(cinfo, b2); - numboxes++; - } - return numboxes; -} - - -LOCAL(void) -compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor) -/* Compute representative color for a box, put it in colormap[icolor] */ -{ - /* Current algorithm: mean weighted by pixels (not colors) */ - /* Note it is important to get the rounding correct! */ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - histptr histp; - int c0,c1,c2; - int c0min,c0max,c1min,c1max,c2min,c2max; - long count; - long total = 0; - long c0total = 0; - long c1total = 0; - long c2total = 0; - - c0min = boxp->c0min; c0max = boxp->c0max; - c1min = boxp->c1min; c1max = boxp->c1max; - c2min = boxp->c2min; c2max = boxp->c2max; - - for (c0 = c0min; c0 <= c0max; c0++) - for (c1 = c1min; c1 <= c1max; c1++) { - histp = & histogram[c0][c1][c2min]; - for (c2 = c2min; c2 <= c2max; c2++) { - if ((count = *histp++) != 0) { - total += count; - c0total += ((c0 << C0_SHIFT) + ((1<>1)) * count; - c1total += ((c1 << C1_SHIFT) + ((1<>1)) * count; - c2total += ((c2 << C2_SHIFT) + ((1<>1)) * count; - } - } - } - - cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total); - cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total); - cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total); -} - - -LOCAL(void) -select_colors (j_decompress_ptr cinfo, int desired_colors) -/* Master routine for color selection */ -{ - boxptr boxlist; - int numboxes; - int i; - - /* Allocate workspace for box list */ - boxlist = (boxptr) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, desired_colors * SIZEOF(box)); - /* Initialize one box containing whole space */ - numboxes = 1; - boxlist[0].c0min = 0; - boxlist[0].c0max = MAXJSAMPLE >> C0_SHIFT; - boxlist[0].c1min = 0; - boxlist[0].c1max = MAXJSAMPLE >> C1_SHIFT; - boxlist[0].c2min = 0; - boxlist[0].c2max = MAXJSAMPLE >> C2_SHIFT; - /* Shrink it to actually-used volume and set its statistics */ - update_box(cinfo, & boxlist[0]); - /* Perform median-cut to produce final box list */ - numboxes = median_cut(cinfo, boxlist, numboxes, desired_colors); - /* Compute the representative color for each box, fill colormap */ - for (i = 0; i < numboxes; i++) - compute_color(cinfo, & boxlist[i], i); - cinfo->actual_number_of_colors = numboxes; - TRACEMS1(cinfo, 1, JTRC_QUANT_SELECTED, numboxes); -} - - -/* - * These routines are concerned with the time-critical task of mapping input - * colors to the nearest color in the selected colormap. - * - * We re-use the histogram space as an "inverse color map", essentially a - * cache for the results of nearest-color searches. All colors within a - * histogram cell will be mapped to the same colormap entry, namely the one - * closest to the cell's center. This may not be quite the closest entry to - * the actual input color, but it's almost as good. A zero in the cache - * indicates we haven't found the nearest color for that cell yet; the array - * is cleared to zeroes before starting the mapping pass. When we find the - * nearest color for a cell, its colormap index plus one is recorded in the - * cache for future use. The pass2 scanning routines call fill_inverse_cmap - * when they need to use an unfilled entry in the cache. - * - * Our method of efficiently finding nearest colors is based on the "locally - * sorted search" idea described by Heckbert and on the incremental distance - * calculation described by Spencer W. Thomas in chapter III.1 of Graphics - * Gems II (James Arvo, ed. Academic Press, 1991). Thomas points out that - * the distances from a given colormap entry to each cell of the histogram can - * be computed quickly using an incremental method: the differences between - * distances to adjacent cells themselves differ by a constant. This allows a - * fairly fast implementation of the "brute force" approach of computing the - * distance from every colormap entry to every histogram cell. Unfortunately, - * it needs a work array to hold the best-distance-so-far for each histogram - * cell (because the inner loop has to be over cells, not colormap entries). - * The work array elements have to be INT32s, so the work array would need - * 256Kb at our recommended precision. This is not feasible in DOS machines. - * - * To get around these problems, we apply Thomas' method to compute the - * nearest colors for only the cells within a small subbox of the histogram. - * The work array need be only as big as the subbox, so the memory usage - * problem is solved. Furthermore, we need not fill subboxes that are never - * referenced in pass2; many images use only part of the color gamut, so a - * fair amount of work is saved. An additional advantage of this - * approach is that we can apply Heckbert's locality criterion to quickly - * eliminate colormap entries that are far away from the subbox; typically - * three-fourths of the colormap entries are rejected by Heckbert's criterion, - * and we need not compute their distances to individual cells in the subbox. - * The speed of this approach is heavily influenced by the subbox size: too - * small means too much overhead, too big loses because Heckbert's criterion - * can't eliminate as many colormap entries. Empirically the best subbox - * size seems to be about 1/512th of the histogram (1/8th in each direction). - * - * Thomas' article also describes a refined method which is asymptotically - * faster than the brute-force method, but it is also far more complex and - * cannot efficiently be applied to small subboxes. It is therefore not - * useful for programs intended to be portable to DOS machines. On machines - * with plenty of memory, filling the whole histogram in one shot with Thomas' - * refined method might be faster than the present code --- but then again, - * it might not be any faster, and it's certainly more complicated. - */ - - -/* log2(histogram cells in update box) for each axis; this can be adjusted */ -#define BOX_C0_LOG (HIST_C0_BITS-3) -#define BOX_C1_LOG (HIST_C1_BITS-3) -#define BOX_C2_LOG (HIST_C2_BITS-3) - -#define BOX_C0_ELEMS (1<actual_number_of_colors; - int maxc0, maxc1, maxc2; - int centerc0, centerc1, centerc2; - int i, x, ncolors; - INT32 minmaxdist, min_dist, max_dist, tdist; - INT32 mindist[MAXNUMCOLORS]; /* min distance to colormap entry i */ - - /* Compute true coordinates of update box's upper corner and center. - * Actually we compute the coordinates of the center of the upper-corner - * histogram cell, which are the upper bounds of the volume we care about. - * Note that since ">>" rounds down, the "center" values may be closer to - * min than to max; hence comparisons to them must be "<=", not "<". - */ - maxc0 = minc0 + ((1 << BOX_C0_SHIFT) - (1 << C0_SHIFT)); - centerc0 = (minc0 + maxc0) >> 1; - maxc1 = minc1 + ((1 << BOX_C1_SHIFT) - (1 << C1_SHIFT)); - centerc1 = (minc1 + maxc1) >> 1; - maxc2 = minc2 + ((1 << BOX_C2_SHIFT) - (1 << C2_SHIFT)); - centerc2 = (minc2 + maxc2) >> 1; - - /* For each color in colormap, find: - * 1. its minimum squared-distance to any point in the update box - * (zero if color is within update box); - * 2. its maximum squared-distance to any point in the update box. - * Both of these can be found by considering only the corners of the box. - * We save the minimum distance for each color in mindist[]; - * only the smallest maximum distance is of interest. - */ - minmaxdist = 0x7FFFFFFFL; - - for (i = 0; i < numcolors; i++) { - /* We compute the squared-c0-distance term, then add in the other two. */ - x = GETJSAMPLE(cinfo->colormap[0][i]); - if (x < minc0) { - tdist = (x - minc0) * C0_SCALE; - min_dist = tdist*tdist; - tdist = (x - maxc0) * C0_SCALE; - max_dist = tdist*tdist; - } else if (x > maxc0) { - tdist = (x - maxc0) * C0_SCALE; - min_dist = tdist*tdist; - tdist = (x - minc0) * C0_SCALE; - max_dist = tdist*tdist; - } else { - /* within cell range so no contribution to min_dist */ - min_dist = 0; - if (x <= centerc0) { - tdist = (x - maxc0) * C0_SCALE; - max_dist = tdist*tdist; - } else { - tdist = (x - minc0) * C0_SCALE; - max_dist = tdist*tdist; - } - } - - x = GETJSAMPLE(cinfo->colormap[1][i]); - if (x < minc1) { - tdist = (x - minc1) * C1_SCALE; - min_dist += tdist*tdist; - tdist = (x - maxc1) * C1_SCALE; - max_dist += tdist*tdist; - } else if (x > maxc1) { - tdist = (x - maxc1) * C1_SCALE; - min_dist += tdist*tdist; - tdist = (x - minc1) * C1_SCALE; - max_dist += tdist*tdist; - } else { - /* within cell range so no contribution to min_dist */ - if (x <= centerc1) { - tdist = (x - maxc1) * C1_SCALE; - max_dist += tdist*tdist; - } else { - tdist = (x - minc1) * C1_SCALE; - max_dist += tdist*tdist; - } - } - - x = GETJSAMPLE(cinfo->colormap[2][i]); - if (x < minc2) { - tdist = (x - minc2) * C2_SCALE; - min_dist += tdist*tdist; - tdist = (x - maxc2) * C2_SCALE; - max_dist += tdist*tdist; - } else if (x > maxc2) { - tdist = (x - maxc2) * C2_SCALE; - min_dist += tdist*tdist; - tdist = (x - minc2) * C2_SCALE; - max_dist += tdist*tdist; - } else { - /* within cell range so no contribution to min_dist */ - if (x <= centerc2) { - tdist = (x - maxc2) * C2_SCALE; - max_dist += tdist*tdist; - } else { - tdist = (x - minc2) * C2_SCALE; - max_dist += tdist*tdist; - } - } - - mindist[i] = min_dist; /* save away the results */ - if (max_dist < minmaxdist) - minmaxdist = max_dist; - } - - /* Now we know that no cell in the update box is more than minmaxdist - * away from some colormap entry. Therefore, only colors that are - * within minmaxdist of some part of the box need be considered. - */ - ncolors = 0; - for (i = 0; i < numcolors; i++) { - if (mindist[i] <= minmaxdist) - colorlist[ncolors++] = (JSAMPLE) i; - } - return ncolors; -} - - -LOCAL(void) -find_best_colors (j_decompress_ptr cinfo, int minc0, int minc1, int minc2, - int numcolors, JSAMPLE colorlist[], JSAMPLE bestcolor[]) -/* Find the closest colormap entry for each cell in the update box, - * given the list of candidate colors prepared by find_nearby_colors. - * Return the indexes of the closest entries in the bestcolor[] array. - * This routine uses Thomas' incremental distance calculation method to - * find the distance from a colormap entry to successive cells in the box. - */ -{ - int ic0, ic1, ic2; - int i, icolor; - register INT32 * bptr; /* pointer into bestdist[] array */ - JSAMPLE * cptr; /* pointer into bestcolor[] array */ - INT32 dist0, dist1; /* initial distance values */ - register INT32 dist2; /* current distance in inner loop */ - INT32 xx0, xx1; /* distance increments */ - register INT32 xx2; - INT32 inc0, inc1, inc2; /* initial values for increments */ - /* This array holds the distance to the nearest-so-far color for each cell */ - INT32 bestdist[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; - - /* Initialize best-distance for each cell of the update box */ - bptr = bestdist; - for (i = BOX_C0_ELEMS*BOX_C1_ELEMS*BOX_C2_ELEMS-1; i >= 0; i--) - *bptr++ = 0x7FFFFFFFL; - - /* For each color selected by find_nearby_colors, - * compute its distance to the center of each cell in the box. - * If that's less than best-so-far, update best distance and color number. - */ - - /* Nominal steps between cell centers ("x" in Thomas article) */ -#define STEP_C0 ((1 << C0_SHIFT) * C0_SCALE) -#define STEP_C1 ((1 << C1_SHIFT) * C1_SCALE) -#define STEP_C2 ((1 << C2_SHIFT) * C2_SCALE) - - for (i = 0; i < numcolors; i++) { - icolor = GETJSAMPLE(colorlist[i]); - /* Compute (square of) distance from minc0/c1/c2 to this color */ - inc0 = (minc0 - GETJSAMPLE(cinfo->colormap[0][icolor])) * C0_SCALE; - dist0 = inc0*inc0; - inc1 = (minc1 - GETJSAMPLE(cinfo->colormap[1][icolor])) * C1_SCALE; - dist0 += inc1*inc1; - inc2 = (minc2 - GETJSAMPLE(cinfo->colormap[2][icolor])) * C2_SCALE; - dist0 += inc2*inc2; - /* Form the initial difference increments */ - inc0 = inc0 * (2 * STEP_C0) + STEP_C0 * STEP_C0; - inc1 = inc1 * (2 * STEP_C1) + STEP_C1 * STEP_C1; - inc2 = inc2 * (2 * STEP_C2) + STEP_C2 * STEP_C2; - /* Now loop over all cells in box, updating distance per Thomas method */ - bptr = bestdist; - cptr = bestcolor; - xx0 = inc0; - for (ic0 = BOX_C0_ELEMS-1; ic0 >= 0; ic0--) { - dist1 = dist0; - xx1 = inc1; - for (ic1 = BOX_C1_ELEMS-1; ic1 >= 0; ic1--) { - dist2 = dist1; - xx2 = inc2; - for (ic2 = BOX_C2_ELEMS-1; ic2 >= 0; ic2--) { - if (dist2 < *bptr) { - *bptr = dist2; - *cptr = (JSAMPLE) icolor; - } - dist2 += xx2; - xx2 += 2 * STEP_C2 * STEP_C2; - bptr++; - cptr++; - } - dist1 += xx1; - xx1 += 2 * STEP_C1 * STEP_C1; - } - dist0 += xx0; - xx0 += 2 * STEP_C0 * STEP_C0; - } - } -} - - -LOCAL(void) -fill_inverse_cmap (j_decompress_ptr cinfo, int c0, int c1, int c2) -/* Fill the inverse-colormap entries in the update box that contains */ -/* histogram cell c0/c1/c2. (Only that one cell MUST be filled, but */ -/* we can fill as many others as we wish.) */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - int minc0, minc1, minc2; /* lower left corner of update box */ - int ic0, ic1, ic2; - register JSAMPLE * cptr; /* pointer into bestcolor[] array */ - register histptr cachep; /* pointer into main cache array */ - /* This array lists the candidate colormap indexes. */ - JSAMPLE colorlist[MAXNUMCOLORS]; - int numcolors; /* number of candidate colors */ - /* This array holds the actually closest colormap index for each cell. */ - JSAMPLE bestcolor[BOX_C0_ELEMS * BOX_C1_ELEMS * BOX_C2_ELEMS]; - - /* Convert cell coordinates to update box ID */ - c0 >>= BOX_C0_LOG; - c1 >>= BOX_C1_LOG; - c2 >>= BOX_C2_LOG; - - /* Compute true coordinates of update box's origin corner. - * Actually we compute the coordinates of the center of the corner - * histogram cell, which are the lower bounds of the volume we care about. - */ - minc0 = (c0 << BOX_C0_SHIFT) + ((1 << C0_SHIFT) >> 1); - minc1 = (c1 << BOX_C1_SHIFT) + ((1 << C1_SHIFT) >> 1); - minc2 = (c2 << BOX_C2_SHIFT) + ((1 << C2_SHIFT) >> 1); - - /* Determine which colormap entries are close enough to be candidates - * for the nearest entry to some cell in the update box. - */ - numcolors = find_nearby_colors(cinfo, minc0, minc1, minc2, colorlist); - - /* Determine the actually nearest colors. */ - find_best_colors(cinfo, minc0, minc1, minc2, numcolors, colorlist, - bestcolor); - - /* Save the best color numbers (plus 1) in the main cache array */ - c0 <<= BOX_C0_LOG; /* convert ID back to base cell indexes */ - c1 <<= BOX_C1_LOG; - c2 <<= BOX_C2_LOG; - cptr = bestcolor; - for (ic0 = 0; ic0 < BOX_C0_ELEMS; ic0++) { - for (ic1 = 0; ic1 < BOX_C1_ELEMS; ic1++) { - cachep = & histogram[c0+ic0][c1+ic1][c2]; - for (ic2 = 0; ic2 < BOX_C2_ELEMS; ic2++) { - *cachep++ = (histcell) (GETJSAMPLE(*cptr++) + 1); - } - } - } -} - - -/* - * Map some rows of pixels to the output colormapped representation. - */ - -METHODDEF(void) -pass2_no_dither (j_decompress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) -/* This version performs no dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - register JSAMPROW inptr, outptr; - register histptr cachep; - register int c0, c1, c2; - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - - for (row = 0; row < num_rows; row++) { - inptr = input_buf[row]; - outptr = output_buf[row]; - for (col = width; col > 0; col--) { - /* get pixel value and index into the cache */ - c0 = GETJSAMPLE(*inptr++) >> C0_SHIFT; - c1 = GETJSAMPLE(*inptr++) >> C1_SHIFT; - c2 = GETJSAMPLE(*inptr++) >> C2_SHIFT; - cachep = & histogram[c0][c1][c2]; - /* If we have not seen this color before, find nearest colormap entry */ - /* and update the cache */ - if (*cachep == 0) - fill_inverse_cmap(cinfo, c0,c1,c2); - /* Now emit the colormap index for this cell */ - *outptr++ = (JSAMPLE) (*cachep - 1); - } - } -} - - -METHODDEF(void) -pass2_fs_dither (j_decompress_ptr cinfo, - JSAMPARRAY input_buf, JSAMPARRAY output_buf, int num_rows) -/* This version performs Floyd-Steinberg dithering */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - register LOCFSERROR cur0, cur1, cur2; /* current error or pixel value */ - LOCFSERROR belowerr0, belowerr1, belowerr2; /* error for pixel below cur */ - LOCFSERROR bpreverr0, bpreverr1, bpreverr2; /* error for below/prev col */ - register FSERRPTR errorptr; /* => fserrors[] at column before current */ - JSAMPROW inptr; /* => current input pixel */ - JSAMPROW outptr; /* => current output pixel */ - histptr cachep; - int dir; /* +1 or -1 depending on direction */ - int dir3; /* 3*dir, for advancing inptr & errorptr */ - int row; - JDIMENSION col; - JDIMENSION width = cinfo->output_width; - JSAMPLE *range_limit = cinfo->sample_range_limit; - int *error_limit = cquantize->error_limiter; - JSAMPROW colormap0 = cinfo->colormap[0]; - JSAMPROW colormap1 = cinfo->colormap[1]; - JSAMPROW colormap2 = cinfo->colormap[2]; - SHIFT_TEMPS - - for (row = 0; row < num_rows; row++) { - inptr = input_buf[row]; - outptr = output_buf[row]; - if (cquantize->on_odd_row) { - /* work right to left in this row */ - inptr += (width-1) * 3; /* so point to rightmost pixel */ - outptr += width-1; - dir = -1; - dir3 = -3; - errorptr = cquantize->fserrors + (width+1)*3; /* => entry after last column */ - cquantize->on_odd_row = FALSE; /* flip for next time */ - } else { - /* work left to right in this row */ - dir = 1; - dir3 = 3; - errorptr = cquantize->fserrors; /* => entry before first real column */ - cquantize->on_odd_row = TRUE; /* flip for next time */ - } - /* Preset error values: no error propagated to first pixel from left */ - cur0 = cur1 = cur2 = 0; - /* and no error propagated to row below yet */ - belowerr0 = belowerr1 = belowerr2 = 0; - bpreverr0 = bpreverr1 = bpreverr2 = 0; - - for (col = width; col > 0; col--) { - /* curN holds the error propagated from the previous pixel on the - * current line. Add the error propagated from the previous line - * to form the complete error correction term for this pixel, and - * round the error term (which is expressed * 16) to an integer. - * RIGHT_SHIFT rounds towards minus infinity, so adding 8 is correct - * for either sign of the error value. - * Note: errorptr points to *previous* column's array entry. - */ - cur0 = RIGHT_SHIFT(cur0 + errorptr[dir3+0] + 8, 4); - cur1 = RIGHT_SHIFT(cur1 + errorptr[dir3+1] + 8, 4); - cur2 = RIGHT_SHIFT(cur2 + errorptr[dir3+2] + 8, 4); - /* Limit the error using transfer function set by init_error_limit. - * See comments with init_error_limit for rationale. - */ - cur0 = error_limit[cur0]; - cur1 = error_limit[cur1]; - cur2 = error_limit[cur2]; - /* Form pixel value + error, and range-limit to 0..MAXJSAMPLE. - * The maximum error is +- MAXJSAMPLE (or less with error limiting); - * this sets the required size of the range_limit array. - */ - cur0 += GETJSAMPLE(inptr[0]); - cur1 += GETJSAMPLE(inptr[1]); - cur2 += GETJSAMPLE(inptr[2]); - cur0 = GETJSAMPLE(range_limit[cur0]); - cur1 = GETJSAMPLE(range_limit[cur1]); - cur2 = GETJSAMPLE(range_limit[cur2]); - /* Index into the cache with adjusted pixel value */ - cachep = & histogram[cur0>>C0_SHIFT][cur1>>C1_SHIFT][cur2>>C2_SHIFT]; - /* If we have not seen this color before, find nearest colormap */ - /* entry and update the cache */ - if (*cachep == 0) - fill_inverse_cmap(cinfo, cur0>>C0_SHIFT,cur1>>C1_SHIFT,cur2>>C2_SHIFT); - /* Now emit the colormap index for this cell */ - { register int pixcode = *cachep - 1; - *outptr = (JSAMPLE) pixcode; - /* Compute representation error for this pixel */ - cur0 -= GETJSAMPLE(colormap0[pixcode]); - cur1 -= GETJSAMPLE(colormap1[pixcode]); - cur2 -= GETJSAMPLE(colormap2[pixcode]); - } - /* Compute error fractions to be propagated to adjacent pixels. - * Add these into the running sums, and simultaneously shift the - * next-line error sums left by 1 column. - */ - { register LOCFSERROR bnexterr, delta; - - bnexterr = cur0; /* Process component 0 */ - delta = cur0 * 2; - cur0 += delta; /* form error * 3 */ - errorptr[0] = (FSERROR) (bpreverr0 + cur0); - cur0 += delta; /* form error * 5 */ - bpreverr0 = belowerr0 + cur0; - belowerr0 = bnexterr; - cur0 += delta; /* form error * 7 */ - bnexterr = cur1; /* Process component 1 */ - delta = cur1 * 2; - cur1 += delta; /* form error * 3 */ - errorptr[1] = (FSERROR) (bpreverr1 + cur1); - cur1 += delta; /* form error * 5 */ - bpreverr1 = belowerr1 + cur1; - belowerr1 = bnexterr; - cur1 += delta; /* form error * 7 */ - bnexterr = cur2; /* Process component 2 */ - delta = cur2 * 2; - cur2 += delta; /* form error * 3 */ - errorptr[2] = (FSERROR) (bpreverr2 + cur2); - cur2 += delta; /* form error * 5 */ - bpreverr2 = belowerr2 + cur2; - belowerr2 = bnexterr; - cur2 += delta; /* form error * 7 */ - } - /* At this point curN contains the 7/16 error value to be propagated - * to the next pixel on the current line, and all the errors for the - * next line have been shifted over. We are therefore ready to move on. - */ - inptr += dir3; /* Advance pixel pointers to next column */ - outptr += dir; - errorptr += dir3; /* advance errorptr to current column */ - } - /* Post-loop cleanup: we must unload the final error values into the - * final fserrors[] entry. Note we need not unload belowerrN because - * it is for the dummy column before or after the actual array. - */ - errorptr[0] = (FSERROR) bpreverr0; /* unload prev errs into array */ - errorptr[1] = (FSERROR) bpreverr1; - errorptr[2] = (FSERROR) bpreverr2; - } -} - - -/* - * Initialize the error-limiting transfer function (lookup table). - * The raw F-S error computation can potentially compute error values of up to - * +- MAXJSAMPLE. But we want the maximum correction applied to a pixel to be - * much less, otherwise obviously wrong pixels will be created. (Typical - * effects include weird fringes at color-area boundaries, isolated bright - * pixels in a dark area, etc.) The standard advice for avoiding this problem - * is to ensure that the "corners" of the color cube are allocated as output - * colors; then repeated errors in the same direction cannot cause cascading - * error buildup. However, that only prevents the error from getting - * completely out of hand; Aaron Giles reports that error limiting improves - * the results even with corner colors allocated. - * A simple clamping of the error values to about +- MAXJSAMPLE/8 works pretty - * well, but the smoother transfer function used below is even better. Thanks - * to Aaron Giles for this idea. - */ - -LOCAL(void) -init_error_limit (j_decompress_ptr cinfo) -/* Allocate and fill in the error_limiter table */ -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - int * table; - int in, out; - - table = (int *) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE*2+1) * SIZEOF(int)); - table += MAXJSAMPLE; /* so can index -MAXJSAMPLE .. +MAXJSAMPLE */ - cquantize->error_limiter = table; - -#define STEPSIZE ((MAXJSAMPLE+1)/16) - /* Map errors 1:1 up to +- MAXJSAMPLE/16 */ - out = 0; - for (in = 0; in < STEPSIZE; in++, out++) { - table[in] = out; table[-in] = -out; - } - /* Map errors 1:2 up to +- 3*MAXJSAMPLE/16 */ - for (; in < STEPSIZE*3; in++, out += (in&1) ? 0 : 1) { - table[in] = out; table[-in] = -out; - } - /* Clamp the rest to final out value (which is (MAXJSAMPLE+1)/8) */ - for (; in <= MAXJSAMPLE; in++) { - table[in] = out; table[-in] = -out; - } -#undef STEPSIZE -} - - -/* - * Finish up at the end of each pass. - */ - -METHODDEF(void) -finish_pass1 (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - - /* Select the representative colors and fill in cinfo->colormap */ - cinfo->colormap = cquantize->sv_colormap; - select_colors(cinfo, cquantize->desired); - /* Force next pass to zero the color index table */ - cquantize->needs_zeroed = TRUE; -} - - -METHODDEF(void) -finish_pass2 (j_decompress_ptr cinfo) -{ - /* no work */ -} - - -/* - * Initialize for each processing pass. - */ - -METHODDEF(void) -start_pass_2_quant (j_decompress_ptr cinfo, boolean is_pre_scan) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - hist3d histogram = cquantize->histogram; - int i; - - /* Only F-S dithering or no dithering is supported. */ - /* If user asks for ordered dither, give him F-S. */ - if (cinfo->dither_mode != JDITHER_NONE) - cinfo->dither_mode = JDITHER_FS; - - if (is_pre_scan) { - /* Set up method pointers */ - cquantize->pub.color_quantize = prescan_quantize; - cquantize->pub.finish_pass = finish_pass1; - cquantize->needs_zeroed = TRUE; /* Always zero histogram */ - } else { - /* Set up method pointers */ - if (cinfo->dither_mode == JDITHER_FS) - cquantize->pub.color_quantize = pass2_fs_dither; - else - cquantize->pub.color_quantize = pass2_no_dither; - cquantize->pub.finish_pass = finish_pass2; - - /* Make sure color count is acceptable */ - i = cinfo->actual_number_of_colors; - if (i < 1) - ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 1); - if (i > MAXNUMCOLORS) - ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); - - if (cinfo->dither_mode == JDITHER_FS) { - size_t arraysize = (size_t) ((cinfo->output_width + 2) * - (3 * SIZEOF(FSERROR))); - /* Allocate Floyd-Steinberg workspace if we didn't already. */ - if (cquantize->fserrors == NULL) - cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, arraysize); - /* Initialize the propagated errors to zero. */ - jzero_far((void FAR *) cquantize->fserrors, arraysize); - /* Make the error-limit table if we didn't already. */ - if (cquantize->error_limiter == NULL) - init_error_limit(cinfo); - cquantize->on_odd_row = FALSE; - } - - } - /* Zero the histogram or inverse color map, if necessary */ - if (cquantize->needs_zeroed) { - for (i = 0; i < HIST_C0_ELEMS; i++) { - jzero_far((void FAR *) histogram[i], - HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); - } - cquantize->needs_zeroed = FALSE; - } -} - - -/* - * Switch to a new external colormap between output passes. - */ - -METHODDEF(void) -new_color_map_2_quant (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize = (my_cquantize_ptr) cinfo->cquantize; - - /* Reset the inverse color map */ - cquantize->needs_zeroed = TRUE; -} - - -/* - * Module initialization routine for 2-pass color quantization. - */ - -GLOBAL(void) -jinit_2pass_quantizer (j_decompress_ptr cinfo) -{ - my_cquantize_ptr cquantize; - int i; - - cquantize = (my_cquantize_ptr) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, - SIZEOF(my_cquantizer)); - cinfo->cquantize = (struct jpeg_color_quantizer *) cquantize; - cquantize->pub.start_pass = start_pass_2_quant; - cquantize->pub.new_color_map = new_color_map_2_quant; - cquantize->fserrors = NULL; /* flag optional arrays not allocated */ - cquantize->error_limiter = NULL; - - /* Make sure jdmaster didn't give me a case I can't handle */ - if (cinfo->out_color_components != 3) - ERREXIT(cinfo, JERR_NOTIMPL); - - /* Allocate the histogram/inverse colormap storage */ - cquantize->histogram = (hist3d) (*cinfo->mem->alloc_small) - ((j_common_ptr) cinfo, JPOOL_IMAGE, HIST_C0_ELEMS * SIZEOF(hist2d)); - for (i = 0; i < HIST_C0_ELEMS; i++) { - cquantize->histogram[i] = (hist2d) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - HIST_C1_ELEMS*HIST_C2_ELEMS * SIZEOF(histcell)); - } - cquantize->needs_zeroed = TRUE; /* histogram is garbage now */ - - /* Allocate storage for the completed colormap, if required. - * We do this now since it is FAR storage and may affect - * the memory manager's space calculations. - */ - if (cinfo->enable_2pass_quant) { - /* Make sure color count is acceptable */ - int desired = cinfo->desired_number_of_colors; - /* Lower bound on # of colors ... somewhat arbitrary as long as > 0 */ - if (desired < 8) - ERREXIT1(cinfo, JERR_QUANT_FEW_COLORS, 8); - /* Make sure colormap indexes can be represented by JSAMPLEs */ - if (desired > MAXNUMCOLORS) - ERREXIT1(cinfo, JERR_QUANT_MANY_COLORS, MAXNUMCOLORS); - cquantize->sv_colormap = (*cinfo->mem->alloc_sarray) - ((j_common_ptr) cinfo,JPOOL_IMAGE, (JDIMENSION) desired, (JDIMENSION) 3); - cquantize->desired = desired; - } else - cquantize->sv_colormap = NULL; - - /* Only F-S dithering or no dithering is supported. */ - /* If user asks for ordered dither, give him F-S. */ - if (cinfo->dither_mode != JDITHER_NONE) - cinfo->dither_mode = JDITHER_FS; - - /* Allocate Floyd-Steinberg workspace if necessary. - * This isn't really needed until pass 2, but again it is FAR storage. - * Although we will cope with a later change in dither_mode, - * we do not promise to honor max_memory_to_use if dither_mode changes. - */ - if (cinfo->dither_mode == JDITHER_FS) { - cquantize->fserrors = (FSERRPTR) (*cinfo->mem->alloc_large) - ((j_common_ptr) cinfo, JPOOL_IMAGE, - (size_t) ((cinfo->output_width + 2) * (3 * SIZEOF(FSERROR)))); - /* Might as well create the error-limiting table too. */ - init_error_limit(cinfo); - } -} - -#endif /* QUANT_2PASS_SUPPORTED */ diff --git a/oversampling/WDL/jpeglib/jutils.c b/oversampling/WDL/jpeglib/jutils.c deleted file mode 100644 index d18a955..0000000 --- a/oversampling/WDL/jpeglib/jutils.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * jutils.c - * - * Copyright (C) 1991-1996, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains tables and miscellaneous utility routines needed - * for both compression and decompression. - * Note we prefix all global names with "j" to minimize conflicts with - * a surrounding application. - */ - -#define JPEG_INTERNALS -#include "jinclude.h" -#include "jpeglib.h" - - -/* - * jpeg_zigzag_order[i] is the zigzag-order position of the i'th element - * of a DCT block read in natural order (left to right, top to bottom). - */ - -#if 0 /* This table is not actually needed in v6a */ - -const int jpeg_zigzag_order[DCTSIZE2] = { - 0, 1, 5, 6, 14, 15, 27, 28, - 2, 4, 7, 13, 16, 26, 29, 42, - 3, 8, 12, 17, 25, 30, 41, 43, - 9, 11, 18, 24, 31, 40, 44, 53, - 10, 19, 23, 32, 39, 45, 52, 54, - 20, 22, 33, 38, 46, 51, 55, 60, - 21, 34, 37, 47, 50, 56, 59, 61, - 35, 36, 48, 49, 57, 58, 62, 63 -}; - -#endif - -/* - * jpeg_natural_order[i] is the natural-order position of the i'th element - * of zigzag order. - * - * When reading corrupted data, the Huffman decoders could attempt - * to reference an entry beyond the end of this array (if the decoded - * zero run length reaches past the end of the block). To prevent - * wild stores without adding an inner-loop test, we put some extra - * "63"s after the real entries. This will cause the extra coefficient - * to be stored in location 63 of the block, not somewhere random. - * The worst case would be a run-length of 15, which means we need 16 - * fake entries. - */ - -const int jpeg_natural_order[DCTSIZE2+16] = { - 0, 1, 8, 16, 9, 2, 3, 10, - 17, 24, 32, 25, 18, 11, 4, 5, - 12, 19, 26, 33, 40, 48, 41, 34, - 27, 20, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, - 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63, - 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */ - 63, 63, 63, 63, 63, 63, 63, 63 -}; - - -/* - * Arithmetic utilities - */ - -GLOBAL(long) -jdiv_round_up (long a, long b) -/* Compute a/b rounded up to next integer, ie, ceil(a/b) */ -/* Assumes a >= 0, b > 0 */ -{ - return (a + b - 1L) / b; -} - - -GLOBAL(long) -jround_up (long a, long b) -/* Compute a rounded up to next multiple of b, ie, ceil(a/b)*b */ -/* Assumes a >= 0, b > 0 */ -{ - a += b - 1L; - return a - (a % b); -} - - -/* On normal machines we can apply MEMCOPY() and MEMZERO() to sample arrays - * and coefficient-block arrays. This won't work on 80x86 because the arrays - * are FAR and we're assuming a small-pointer memory model. However, some - * DOS compilers provide far-pointer versions of memcpy() and memset() even - * in the small-model libraries. These will be used if USE_FMEM is defined. - * Otherwise, the routines below do it the hard way. (The performance cost - * is not all that great, because these routines aren't very heavily used.) - */ - -#ifndef NEED_FAR_POINTERS /* normal case, same as regular macros */ -#define FMEMCOPY(dest,src,size) MEMCOPY(dest,src,size) -#define FMEMZERO(target,size) MEMZERO(target,size) -#else /* 80x86 case, define if we can */ -#ifdef USE_FMEM -#define FMEMCOPY(dest,src,size) _fmemcpy((void FAR *)(dest), (const void FAR *)(src), (size_t)(size)) -#define FMEMZERO(target,size) _fmemset((void FAR *)(target), 0, (size_t)(size)) -#endif -#endif - - -GLOBAL(void) -jcopy_sample_rows (JSAMPARRAY input_array, int source_row, - JSAMPARRAY output_array, int dest_row, - int num_rows, JDIMENSION num_cols) -/* Copy some rows of samples from one place to another. - * num_rows rows are copied from input_array[source_row++] - * to output_array[dest_row++]; these areas may overlap for duplication. - * The source and destination arrays must be at least as wide as num_cols. - */ -{ - register JSAMPROW inptr, outptr; -#ifdef FMEMCOPY - register size_t count = (size_t) (num_cols * SIZEOF(JSAMPLE)); -#else - register JDIMENSION count; -#endif - register int row; - - input_array += source_row; - output_array += dest_row; - - for (row = num_rows; row > 0; row--) { - inptr = *input_array++; - outptr = *output_array++; -#ifdef FMEMCOPY - FMEMCOPY(outptr, inptr, count); -#else - for (count = num_cols; count > 0; count--) - *outptr++ = *inptr++; /* needn't bother with GETJSAMPLE() here */ -#endif - } -} - - -GLOBAL(void) -jcopy_block_row (JBLOCKROW input_row, JBLOCKROW output_row, - JDIMENSION num_blocks) -/* Copy a row of coefficient blocks from one place to another. */ -{ -#ifdef FMEMCOPY - FMEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * SIZEOF(JCOEF))); -#else - register JCOEFPTR inptr, outptr; - register long count; - - inptr = (JCOEFPTR) input_row; - outptr = (JCOEFPTR) output_row; - for (count = (long) num_blocks * DCTSIZE2; count > 0; count--) { - *outptr++ = *inptr++; - } -#endif -} - - -GLOBAL(void) -jzero_far (void FAR * target, size_t bytestozero) -/* Zero out a chunk of FAR memory. */ -/* This might be sample-array data, block-array data, or alloc_large data. */ -{ -#ifdef FMEMZERO - FMEMZERO(target, bytestozero); -#else - register char FAR * ptr = (char FAR *) target; - register size_t count; - - for (count = bytestozero; count > 0; count--) { - *ptr++ = 0; - } -#endif -} diff --git a/oversampling/WDL/jpeglib/jversion.h b/oversampling/WDL/jpeglib/jversion.h deleted file mode 100644 index 6472c58..0000000 --- a/oversampling/WDL/jpeglib/jversion.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * jversion.h - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains software version identification. - */ - - -#define JVERSION "6b 27-Mar-1998" - -#define JCOPYRIGHT "Copyright (C) 1998, Thomas G. Lane" diff --git a/oversampling/WDL/lameencdec.cpp b/oversampling/WDL/lameencdec.cpp deleted file mode 100644 index dec614b..0000000 --- a/oversampling/WDL/lameencdec.cpp +++ /dev/null @@ -1,467 +0,0 @@ -/* - WDL - lameencdec.cpp - Copyright (C) 2005 and later Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - - -*/ - - - -#ifdef _WIN32 -#include -#include -#else -#include -#endif - -#include -#include -#include - -#include "wdlcstring.h" -#include "lameencdec.h" -#include "win32_utf8.h" -#include "ptrlist.h" - -#ifdef __APPLE__ - #include -#endif -#ifndef _WIN32 - #include -#endif - -// note: calling code should include WDL/metadata.h from somewhere to implement these functions -struct ID3RawTag; -int PackID3Chunk(WDL_HeapBuf *hb, WDL_StringKeyedArray *metadata, - bool want_embed_otherschemes, int *ixml_lenwritten, int ixml_padtolen, - WDL_PtrList *rawtags=NULL); -int PackApeChunk(WDL_HeapBuf *hb, WDL_StringKeyedArray *metadata); -int PackXMPChunk(WDL_HeapBuf *hb, WDL_StringKeyedArray *metadata); -bool ParseUserDefMetadata(const char *id, const char *val, - const char **k, const char **v, int *klen, int *vlen); -bool HasScheme(const char *scheme, WDL_StringKeyedArray *metadata); - - -typedef enum MPEG_mode_e { - STEREO = 0, - JOINT_STEREO, - DUAL_CHANNEL, /* LAME doesn't supports this! */ - MONO, - NOT_SET, - MAX_INDICATOR /* Don't use this! It's used for sanity checks. */ -} MPEG_mode; - -typedef void *lame_t; - -static struct { - int (*close)(lame_t); - lame_t (*init)(); - int (*set_in_samplerate)(lame_t, int); - int (*set_num_channels)(lame_t,int); - int (*set_out_samplerate)(lame_t,int); - int (*set_quality)(lame_t,int); - int (*set_mode)(lame_t,MPEG_mode); - int (*set_brate)(lame_t, int); - int (*init_params)(lame_t); - int (*get_framesize)(lame_t); - - int (*encode_buffer_float)(lame_t, - const float buffer_l [], /* PCM data for left channel */ - const float buffer_r [], /* PCM data for right channel */ - const int nsamples, /* number of samples per channel */ - unsigned char* mp3buf, /* pointer to encoded MP3 stream */ - const int mp3buf_size ); - int (*encode_flush)(lame_t,unsigned char* mp3buf, int size); - -// these are optional - int (*set_VBR)(lame_t, int); - int (*set_VBR_q)(lame_t, int); - int (*set_VBR_mean_bitrate_kbps)(lame_t, int); - int (*set_VBR_min_bitrate_kbps)(lame_t, int); - int (*set_VBR_max_bitrate_kbps)(lame_t, int); - size_t (*get_lametag_frame)(lame_t, unsigned char *, size_t); - const char *(*get_lame_version)(); - int (*set_findReplayGain)(lame_t, int); - -} lame; - -#if 1 -#define LAME_DEBUG_LOADING(x) -#else -#define LAME_DEBUG_LOADING(x) OutputDebugString(x) -#endif - -static char s_last_dll_file[128]; - -static bool tryLoadDLL2(const char *name) -{ -#ifdef _WIN32 - HINSTANCE dll = LoadLibrary(name); -#else - void *dll=dlopen(name,RTLD_NOW|RTLD_LOCAL); -#endif - - if (!dll) return false; - - LAME_DEBUG_LOADING("trying to load"); - LAME_DEBUG_LOADING(name); - int errcnt = 0; - #ifdef _WIN32 - #define GETITEM(x) if (NULL == (*(void **)&lame.x = GetProcAddress((HINSTANCE)dll,"lame_" #x))) errcnt++; - #define GETITEM_NP(x) if (NULL == (*(void **)&lame.x = GetProcAddress((HINSTANCE)dll, #x))) errcnt++; - #else - #define GETITEM(x) if (NULL == (*(void **)&lame.x = dlsym(dll,"lame_" #x))) errcnt++; - #define GETITEM_NP(x) if (NULL == (*(void **)&lame.x = dlsym(dll,#x))) errcnt++; - #endif - GETITEM(close) - GETITEM(init) - GETITEM(set_in_samplerate) - GETITEM(set_num_channels) - GETITEM(set_out_samplerate) - GETITEM(set_quality) - GETITEM(set_mode) - GETITEM(set_brate) - GETITEM(init_params) - GETITEM(get_framesize) - GETITEM(encode_buffer_float) - GETITEM(encode_flush) - - int errcnt2 = errcnt; - GETITEM(set_VBR) - GETITEM(set_VBR_q) - GETITEM(set_VBR_mean_bitrate_kbps) - GETITEM(set_VBR_min_bitrate_kbps) - GETITEM(set_VBR_max_bitrate_kbps) - GETITEM(get_lametag_frame) - GETITEM(set_findReplayGain) - GETITEM_NP(get_lame_version) - - #undef GETITEM - #undef GETITEM_NP - if (errcnt2) - { - memset(&lame, 0, sizeof(lame)); - -#ifdef _WIN32 - FreeLibrary(dll); -#else - dlclose(dll); -#endif - return false; - } - - LAME_DEBUG_LOADING("loaded normal mode"); - - lstrcpyn_safe(s_last_dll_file, name, sizeof(s_last_dll_file)); -#ifdef _WIN32 -// if (!strstr(name,"\\")) - GetModuleFileName(dll,s_last_dll_file, (DWORD)sizeof(s_last_dll_file)); -#else -// if (!strstr(name,"/")) - { - Dl_info inf={0,}; - dladdr((void*)lame.init,&inf); - if (inf.dli_fname) - lstrcpyn_safe(s_last_dll_file,inf.dli_fname,sizeof(s_last_dll_file)); - } -#endif - - return true; -} - - - -void LameEncoder::InitDLL(const char *extrapath, bool forceRetry) -{ - static int a; - if (a<0) return; - - if (forceRetry) a=0; - else if (a > 30) return; // give up - - a++; - - char me[1024]; -#ifdef _WIN32 - const char *dll = "libmp3lame.dll"; -#elif defined(__APPLE__) - const char *dll = "libmp3lame.dylib"; -#else - const char *dll = "libmp3lame.so.0"; -#endif - - if (extrapath) - { - snprintf(me,sizeof(me),"%s%c%s",extrapath,WDL_DIRCHAR,dll); - if (tryLoadDLL2(me)) { a = -1; return; } - } - - if (tryLoadDLL2(dll)) a=-1; - -} - -const char *LameEncoder::GetLibName() { return s_last_dll_file; } - -const char *LameEncoder::GetInfo() -{ - static char buf[128]; - if (!CheckDLL()) return NULL; - const char *p = lame.get_lame_version ? lame.get_lame_version() : NULL; - if (p && *p) - { - snprintf(buf, sizeof(buf), "LAME %s", p); - return buf; - } - return "LAME ?.??"; -} - -int LameEncoder::CheckDLL() // returns 1 for lame API, 2 for Blade, 0 for none -{ - InitDLL(); - if (!lame.close|| - !lame.init|| - !lame.set_in_samplerate|| - !lame.set_num_channels|| - !lame.set_out_samplerate|| - !lame.set_quality|| - !lame.set_mode|| - !lame.set_brate|| - !lame.init_params|| - !lame.get_framesize|| - !lame.encode_buffer_float|| - !lame.encode_flush) - { - return 0; - } - - return 1; - -} - -LameEncoder::LameEncoder(int srate, int nch, int bitrate, int stereomode, int quality, - int vbrmethod, int vbrquality, int vbrmax, int abr, int rpgain, - WDL_StringKeyedArray *metadata) -{ - m_lamestate=0; - if (!CheckDLL()) - { - errorstat=1; - return; - } - - errorstat=0; - m_nch=nch; - m_encoder_nch = stereomode == 3 ? 1 : m_nch; - m_id3_len=m_ixml_len=0; - - m_lamestate=lame.init(); - if (!m_lamestate) - { - errorstat=1; - return; - } - - lame.set_in_samplerate(m_lamestate, srate); - lame.set_num_channels(m_lamestate,m_encoder_nch); - int outrate=srate; - - int maxbr = (vbrmethod != -1 ? vbrmax : bitrate); - if (outrate>=32000 && maxbr <= 32*m_encoder_nch) outrate/=2; - - lame.set_out_samplerate(m_lamestate,outrate); - lame.set_quality(m_lamestate,(quality>9 ||quality<0) ? 0 : quality); - if (m_encoder_nch == 1 || stereomode >= 0) - lame.set_mode(m_lamestate,(MPEG_mode) (m_encoder_nch==1?3 :stereomode )); - lame.set_brate(m_lamestate,bitrate); - - //int vbrmethod (-1 no vbr), int vbrquality (nVBRQuality), int vbrmax, int abr - if (vbrmethod != -1 && lame.set_VBR) - { - int vm=4; // mtrh - if (vbrmethod == 4) vm = 3; //ABR - lame.set_VBR(m_lamestate,vm); - - if (lame.set_VBR_q) lame.set_VBR_q(m_lamestate,vbrquality); - - if (vbrmethod == 4&&lame.set_VBR_mean_bitrate_kbps) - { - lame.set_VBR_mean_bitrate_kbps(m_lamestate,abr); - } - if (lame.set_VBR_max_bitrate_kbps) - { - lame.set_VBR_max_bitrate_kbps(m_lamestate,vbrmax); - } - if (lame.set_VBR_min_bitrate_kbps) - { - lame.set_VBR_min_bitrate_kbps(m_lamestate,bitrate); - } - } - if (rpgain>0 && lame.set_findReplayGain) lame.set_findReplayGain(m_lamestate,1); - - if (metadata && metadata->GetSize()) - { - WDL_HeapBuf hb; - if (PackID3Chunk(&hb, metadata, true, &m_ixml_len, 0)) - { - outqueue.Add(hb.Get(), hb.GetSize()); - m_id3_len=hb.GetSize(); - } - PackApeChunk(&m_apetag, metadata); - } - - lame.init_params(m_lamestate); - - in_size_samples=lame.get_framesize(m_lamestate); - - outtmp.Resize(65536); -} - -void LameEncoder::Encode(float *in, int in_spls, int spacing) -{ - if (errorstat) return; - - if (in_spls > 0) - { - if (m_nch > 1 && m_encoder_nch==1) - { - // downmix - int x; - int pos=0; - int adv=2*spacing; - for (x = 0; x < in_spls; x ++) - { - float f=in[pos]+in[pos+1]; - f*=16384.0f; - spltmp[0].Add(&f,sizeof(float)); - pos+=adv; - } - } - else if (m_encoder_nch > 1) // deinterleave - { - int x; - int pos=0; - int adv=2*spacing; - for (x = 0; x < in_spls; x ++) - { - float f=in[pos]; - f*=32768.0f; - spltmp[0].Add(&f,sizeof(float)); - - f=in[pos+1]; - f*=32768.0f; - spltmp[1].Add(&f,sizeof(float)); - - pos+=adv; - } - } - else - { - int x; - int pos=0; - for (x = 0; x < in_spls; x ++) - { - float f=in[pos]; - f*=32768.0f; - spltmp[0].Add(&f,sizeof(float)); - - pos+=spacing; - } - } - } - for (;;) - { - int a = spltmp[0].Available()/sizeof(float); - if (a >= in_size_samples) a = in_size_samples; - else if (a<1 || in_spls>0) break; // not enough samples available, and not flushing - - int dwo=lame.encode_buffer_float(m_lamestate,(float *)spltmp[0].Get(),(float*)spltmp[m_encoder_nch>1].Get(), a,(unsigned char *)outtmp.Get(),outtmp.GetSize()); - outqueue.Add(outtmp.Get(),dwo); - spltmp[0].Advance(a*sizeof(float)); - if (m_encoder_nch > 1) spltmp[1].Advance(a*sizeof(float)); - } - - if (in_spls<1) - { - int a=lame.encode_flush(m_lamestate,(unsigned char *)outtmp.Get(),outtmp.GetSize()); - if (a>0) outqueue.Add(outtmp.Get(),a); - } - - - - spltmp[0].Compact(); - spltmp[1].Compact(); - -} - -#ifdef _WIN32 - -static BOOL HasUTF8(const char *_str) -{ - const unsigned char *str = (const unsigned char *)_str; - if (!str) return FALSE; - while (*str) - { - unsigned char c = *str; - if (c >= 0xC2) // discard overlongs - { - if (c <= 0xDF && str[1] >=0x80 && str[1] <= 0xBF) return TRUE; - else if (c <= 0xEF && str[1] >=0x80 && str[1] <= 0xBF && str[2] >=0x80 && str[2] <= 0xBF) return TRUE; - else if (c <= 0xF4 && str[1] >=0x80 && str[1] <= 0xBF && str[2] >=0x80 && str[2] <= 0xBF) return TRUE; - } - str++; - } - return FALSE; -} -#endif - - -LameEncoder::~LameEncoder() -{ - if (m_lamestate) - { - if (m_vbrfile.Get()[0] && lame.get_lametag_frame) - { - unsigned char buf[16384]; - size_t a=lame.get_lametag_frame(m_lamestate,buf,sizeof(buf)); - if ((a>0 && a<=sizeof(buf)) || m_apetag.GetSize()) - { - FILE *fp = fopenUTF8(m_vbrfile.Get(),"r+b"); - if (fp) - { - if (a > 0 && a <= sizeof(buf)) - { - fseek(fp, m_id3_len, SEEK_SET); - fwrite(buf,1,a,fp); - } - if (m_apetag.GetSize()) - { - fseek(fp, 0, SEEK_END); - fwrite(m_apetag.Get(), 1, m_apetag.GetSize(), fp); - } - fclose(fp); - } - } - } - lame.close(m_lamestate); - m_lamestate=0; - } -} - - diff --git a/oversampling/WDL/lameencdec.h b/oversampling/WDL/lameencdec.h deleted file mode 100644 index 343d02f..0000000 --- a/oversampling/WDL/lameencdec.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - WDL - lameencdec.h - Copyright (C) 2005 and later Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - - This file provides a simple interface for using lame_enc/libmp3lame MP3 encoding - -*/ - - -#ifndef _LAMEENCDEC_H_ -#define _LAMEENCDEC_H_ - -#include "queue.h" -#include "wdlstring.h" -#include "assocarray.h" - -class LameEncoder -{ - public: - - LameEncoder(int srate, int nch, int bitrate, int stereomode=1, int quality=2, - int vbrmethod=-1, int vbrquality=2, int vbrmax=320, int abr=128, int rpgain=0, - WDL_StringKeyedArray *metadata=NULL); - ~LameEncoder(); - - int Status() { return errorstat; } // 1=no dll, 2=error - - void Encode(float *in, int in_spls, int spacing=1); - - WDL_Queue outqueue; - - void reinit() - { - spltmp[0].Advance(spltmp[0].Available()); - spltmp[0].Compact(); - spltmp[1].Advance(spltmp[1].Available()); - spltmp[1].Compact(); - } - - static const char *GetInfo(); - static const char *GetLibName(); - static int CheckDLL(); // returns >0 if DLL present, 1 for lame, 2 for old bladeenc - static void InitDLL(const char *extrapath=NULL, bool forceRetry=false); // call with extrapath != NULL if you want to try loading from another path - - void SetVBRFilename(const char *fn) - { - m_vbrfile.Set(fn); - } - - int GetNumChannels() { return m_encoder_nch; } - - int GetID3Len() const { return m_id3_len; } - int GetIXMLLen() const { return m_ixml_len; } - - private: - - void SetMetadata(WDL_StringKeyedArray *metadata); - int m_id3_len, m_ixml_len; - WDL_HeapBuf m_apetag; - - void *m_lamestate; - WDL_Queue spltmp[2]; - WDL_HeapBuf outtmp; - WDL_String m_vbrfile; - int errorstat; - int in_size_samples; - int m_nch,m_encoder_nch; -}; - -#endif diff --git a/oversampling/WDL/libpng/CHANGES b/oversampling/WDL/libpng/CHANGES deleted file mode 100644 index 5e22343..0000000 --- a/oversampling/WDL/libpng/CHANGES +++ /dev/null @@ -1,5424 +0,0 @@ -#if 0 -CHANGES - changes for libpng - -version 0.1 [March 29, 1995] - initial work-in-progress release - -version 0.2 [April 1, 1995] - added reader into png.h - fixed small problems in stub file - -version 0.3 [April 8, 1995] - added pull reader - split up pngwrite.c to several files - added pnglib.txt - added example.c - cleaned up writer, adding a few new transformations - fixed some bugs in writer - interfaced with zlib 0.5 - added K&R support - added check for 64 KB blocks for 16 bit machines - -version 0.4 [April 26, 1995] - cleaned up code and commented code - simplified time handling into png_time - created png_color_16 and png_color_8 to handle color needs - cleaned up color type defines - fixed various bugs - made various names more consistent - interfaced with zlib 0.71 - cleaned up zTXt reader and writer (using zlib's Reset functions) - split transformations into pngrtran.c and pngwtran.c - -version 0.5 [April 30, 1995] - interfaced with zlib 0.8 - fixed many reading and writing bugs - saved using 3 spaces instead of tabs - -version 0.6 [May 1, 1995] - first beta release - added png_large_malloc() and png_large_free() - added png_size_t - cleaned up some compiler warnings - added png_start_read_image() - -version 0.7 [June 24, 1995] - cleaned up lots of bugs - finished dithering and other stuff - added test program - changed name from pnglib to libpng - -version 0.71 [June 26, 1995] - changed pngtest.png for zlib 0.93 - fixed error in libpng.txt and example.c - -version 0.8 [August 20, 1995] - cleaned up some bugs - added png_set_filler() - split up pngstub.c into pngmem.c, pngio.c, and pngerror.c - added #define's to remove unwanted code - moved png_info_init() to png.c - added old_size into png_realloc() - added functions to manually set filtering and compression info - changed compression parameters based on image type - optimized filter selection code - added version info - changed external functions passing floats to doubles (k&r problems?) - put all the configurable stuff in pngconf.h - enabled png_set_shift to work with paletted images on read - added png_read_update_info() - updates info structure with transformations - -Version 0.81 [August, 1995] - incorporated Tim Wegner's medium model code (thanks, Tim) - -Version 0.82 [September, 1995] - [unspecified changes] - -Version 0.85 [December, 1995] - added more medium model code (almost everything's a far) - added i/o, error, and memory callback functions - fixed some bugs (16-bit, 4-bit interlaced, etc.) - added first run progressive reader (barely tested) - -Version 0.86 [January, 1996] - fixed bugs - improved documentation - -Version 0.87 [January, 1996] - fixed medium model bugs - fixed other bugs introduced in 0.85 and 0.86 - added some minor documentation - -Version 0.88 [January, 1996] - fixed progressive bugs - replaced tabs with spaces - cleaned up documentation - added callbacks for read/write and warning/error functions - -Version 0.89 [June 5, 1996] - Added new initialization API to make libpng work better with shared libs - we now have png_create_read_struct(), png_create_write_struct(), - png_create_info_struct(), png_destroy_read_struct(), and - png_destroy_write_struct() instead of the separate calls to - malloc and png_read_init(), png_info_init(), and png_write_init() - Changed warning/error callback functions to fix bug - this means you - should use the new initialization API if you were using the old - png_set_message_fn() calls, and that the old API no longer exists - so that people are aware that they need to change their code - Changed filter selection API to allow selection of multiple filters - since it didn't work in previous versions of libpng anyways - Optimized filter selection code - Fixed png_set_background() to allow using an arbitrary RGB color for - paletted images - Fixed gamma and background correction for paletted images, so - png_correct_palette is not needed unless you are correcting an - external palette (you will need to #define PNG_CORRECT_PALETTE_SUPPORTED - in pngconf.h) - if nobody uses this, it may disappear in the future. - Fixed bug with Borland 64K memory allocation (Alexander Lehmann) - Fixed bug in interlace handling (Smarasderagd, I think) - Added more error checking for writing and image to reduce invalid files - Separated read and write functions so that they won't both be linked - into a binary when only reading or writing functionality is used - New pngtest image also has interlacing and zTXt - Updated documentation to reflect new API - -Version 0.89c [June 17, 1996] - Bug fixes. - -Version 0.90 [January, 1997] - Made CRC errors/warnings on critical and ancillary chunks configurable - libpng will use the zlib CRC routines by (compile-time) default - Changed DOS small/medium model memory support - needs zlib 1.04 (Tim Wegner) - Added external C++ wrapper statements to png.h (Gilles Dauphin) - Allow PNG file to be read when some or all of file signature has already - been read from the beginning of the stream. ****This affects the size - of info_struct and invalidates all programs that use a shared libpng**** - Fixed png_filler() declarations - Fixed? background color conversions - Fixed order of error function pointers to match documentation - Current chunk name is now available in png_struct to reduce the number - of nearly identical error messages (will simplify multi-lingual - support when available) - Try to get ready for unknown-chunk callback functions: - - previously read critical chunks are flagged, so the chunk handling - routines can determine if the chunk is in the right place - - all chunk handling routines have the same prototypes, so we will - be able to handle all chunks via a callback mechanism - Try to fix Linux "setjmp" buffer size problems - Removed png_large_malloc, png_large_free, and png_realloc functions. - -Version 0.95 [March, 1997] - Fixed bug in pngwutil.c allocating "up_row" twice and "avg_row" never - Fixed bug in PNG file signature compares when start != 0 - Changed parameter type of png_set_filler(...filler...) from png_byte - to png_uint_32 - Added test for MACOS to ensure that both math.h and fp.h are not #included - Added macros for libpng to be compiled as a Windows DLL (Andreas Kupries) - Added "packswap" transformation, which changes the endianness of - packed-pixel bytes (Kevin Bracey) - Added "strip_alpha" transformation, which removes the alpha channel of - input images without using it (not necessarily a good idea) - Added "swap_alpha" transformation, which puts the alpha channel in front - of the color bytes instead of after - Removed all implicit variable tests which assume NULL == 0 (I think) - Changed several variables to "png_size_t" to show 16/32-bit limitations - Added new pCAL chunk read/write support - Added experimental filter selection weighting (Greg Roelofs) - Removed old png_set_rgbx() and png_set_xrgb() functions that have been - obsolete for about 2 years now (use png_set_filler() instead) - Added macros to read 16- and 32-bit ints directly from buffer, to be - used only on those systems that support it (namely PowerPC and 680x0) - With some testing, this may become the default for MACOS/PPC systems. - Only calculate CRC on data if we are going to use it - Added macros for zTXt compression type PNG_zTXt_COMPRESSION_??? - Added macros for simple libpng debugging output selectable at compile time - Removed PNG_READ_END_MODE in progressive reader (Smarasderagd) - More description of info_struct in libpng.txt and png.h - More instructions in example.c - More chunk types tested in pngtest.c - Renamed pngrcb.c to pngset.c, and all png_read_ functions to be - png_set_. We now have corresponding png_get_ - functions in pngget.c to get information in info_ptr. This isolates - the application from the internal organization of png_info_struct - (good for shared library implementations). - -Version 0.96 [May, 1997] - Fixed serious bug with < 8bpp images introduced in 0.95 - Fixed 256-color transparency bug (Greg Roelofs) - Fixed up documentation (Greg Roelofs, Laszlo Nyul) - Fixed "error" in pngconf.h for Linux setjmp() behavior - Fixed DOS medium model support (Tim Wegner) - Fixed png_check_keyword() for case with error in static string text - Added read of CRC after IEND chunk for embedded PNGs (Laszlo Nyul) - Added typecasts to quiet compiler errors - Added more debugging info - -Version 0.97 [January, 1998] - Removed PNG_USE_OWN_CRC capability - Relocated png_set_crc_action from pngrutil.c to pngrtran.c - Fixed typecasts of "new_key", etc. (Andreas Dilger) - Added RFC 1152 [sic] date support - Fixed bug in gamma handling of 4-bit grayscale - Added 2-bit grayscale gamma handling (Glenn R-P) - Added more typecasts. 65536L becomes (png_uint_32)65536L, etc. (Glenn R-P) - Minor corrections in libpng.txt - Added simple sRGB support (Glenn R-P) - Easier conditional compiling, e.g., - define PNG_READ/WRITE_NOT_FULLY_SUPPORTED; - all configurable options can be selected from command-line instead - of having to edit pngconf.h (Glenn R-P) - Fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P) - Added more conditions for png_do_background, to avoid changing - black pixels to background when a background is supplied and - no pixels are transparent - Repaired PNG_NO_STDIO behavior - Tested NODIV support and made it default behavior (Greg Roelofs) - Added "-m" option and PNGTEST_DEBUG_MEMORY to pngtest (John Bowler) - Regularized version numbering scheme and bumped shared-library major - version number to 2 to avoid problems with libpng 0.89 apps - (Greg Roelofs) - -Version 0.98 [January, 1998] - Cleaned up some typos in libpng.txt and in code documentation - Fixed memory leaks in pCAL chunk processing (Glenn R-P and John Bowler) - Cosmetic change "display_gamma" to "screen_gamma" in pngrtran.c - Changed recommendation about file_gamma for PC images to .51 from .45, - in example.c and libpng.txt, added comments to distinguish between - screen_gamma, viewing_gamma, and display_gamma. - Changed all references to RFC1152 to read RFC1123 and changed the - PNG_TIME_RFC1152_SUPPORTED macro to PNG_TIME_RFC1123_SUPPORTED - Added png_invert_alpha capability (Glenn R-P -- suggestion by Jon Vincent) - Changed srgb_intent from png_byte to int to avoid compiler bugs - -Version 0.99 [January 30, 1998] - Free info_ptr->text instead of end_info_ptr->text in pngread.c (John Bowler) - Fixed a longstanding "packswap" bug in pngtrans.c - Fixed some inconsistencies in pngconf.h that prevented compiling with - PNG_READ_GAMMA_SUPPORTED and PNG_READ_hIST_SUPPORTED undefined - Fixed some typos and made other minor rearrangement of libpng.txt (Andreas) - Changed recommendation about file_gamma for PC images to .50 from .51 in - example.c and libpng.txt, and changed file_gamma for sRGB images to .45 - Added a number of functions to access information from the png structure - png_get_image_height(), etc. (Glenn R-P, suggestion by Brad Pettit) - Added TARGET_MACOS similar to zlib-1.0.8 - Define PNG_ALWAYS_EXTERN when __MWERKS__ && WIN32 are defined - Added type casting to all png_malloc() function calls - -Version 0.99a [January 31, 1998] - Added type casts and parentheses to all returns that return a value.(Tim W.) - -Version 0.99b [February 4, 1998] - Added type cast png_uint_32 on malloc function calls where needed. - Changed type of num_hist from png_uint_32 to int (same as num_palette). - Added checks for rowbytes overflow, in case png_size_t is less than 32 bits. - Renamed makefile.elf to makefile.lnx. - -Version 0.99c [February 7, 1998] - More type casting. Removed erroneous overflow test in pngmem.c. - Added png_buffered_memcpy() and png_buffered_memset(), apply them to rowbytes. - Added UNIX manual pages libpng.3 (incorporating libpng.txt) and png.5. - -Version 0.99d [February 11, 1998] - Renamed "far_to_near()" "png_far_to_near()" - Revised libpng.3 - Version 99c "buffered" operations didn't work as intended. Replaced them - with png_memcpy_check() and png_memset_check(). - Added many "if (png_ptr == NULL) return" to quell compiler warnings about - unused png_ptr, mostly in pngget.c and pngset.c. - Check for overlength tRNS chunk present when indexed-color PLTE is read. - Cleaned up spelling errors in libpng.3/libpng.txt - Corrected a problem with png_get_tRNS() which returned undefined trans array - -Version 0.99e [February 28, 1998] - Corrected png_get_tRNS() again. - Add parentheses for easier reading of pngget.c, fixed "||" should be "&&". - Touched up example.c to make more of it compileable, although the entire - file still can't be compiled (Willem van Schaik) - Fixed a bug in png_do_shift() (Bryan Tsai) - Added a space in png.h prototype for png_write_chunk_start() - Replaced pngtest.png with one created with zlib 1.1.1 - Changed pngtest to report PASS even when file size is different (Jean-loup G.) - Corrected some logic errors in png_do_invert_alpha() (Chris Patterson) - -Version 0.99f [March 5, 1998] - Corrected a bug in pngpread() introduced in version 99c (Kevin Bracey) - Moved makefiles into a "scripts" directory, and added INSTALL instruction file - Added makefile.os2 and pngos2.def (A. Zabolotny) and makefile.s2x (W. Sebok) - Added pointers to "note on libpng versions" in makefile.lnx and README - Added row callback feature when reading and writing nonprogressive rows - and added a test of this feature in pngtest.c - Added user transform callbacks, with test of the feature in pngtest.c - -Version 0.99g [March 6, 1998, morning] - Minor changes to pngtest.c to suppress compiler warnings. - Removed "beta" language from documentation. - -Version 0.99h [March 6, 1998, evening] - Minor changes to previous minor changes to pngtest.c - Changed PNG_READ_NOT_FULLY_SUPPORTED to PNG_READ_TRANSFORMS_NOT_SUPPORTED - and added PNG_PROGRESSIVE_READ_NOT_SUPPORTED macro - Added user transform capability - -Version 1.00 [March 7, 1998] - Changed several typedefs in pngrutil.c - Added makefile.wat (Pawel Mrochen), updated makefile.tc3 (Willem van Schaik) - Replaced "while(1)" with "for(;;)" - Added PNGARG() to prototypes in pngtest.c and removed some prototypes - Updated some of the makefiles (Tom Lane) - Changed some typedefs (s_start, etc.) in pngrutil.c - Fixed dimensions of "short_months" array in pngwrite.c - Replaced ansi2knr.c with the one from jpeg-v6 - -Version 1.0.0 [March 8, 1998] - Changed name from 1.00 to 1.0.0 (Adam Costello) - Added smakefile.ppc (with SCOPTIONS.ppc) for Amiga PPC (Andreas Kleinert) - -Version 1.0.0a [March 9, 1998] - Fixed three bugs in pngrtran.c to make gamma+background handling consistent - (Greg Roelofs) - Changed format of the PNG_LIBPNG_VER integer to xyyzz instead of xyz - for major, minor, and bugfix releases. This is 10001. (Adam Costello, - Tom Lane) - Make months range from 1-12 in png_convert_to_rfc1123 - -Version 1.0.0b [March 13, 1998] - Quieted compiler complaints about two empty "for" loops in pngrutil.c - Minor changes to makefile.s2x - Removed #ifdef/#endif around a png_free() in pngread.c - -Version 1.0.1 [March 14, 1998] - Changed makefile.s2x to reduce security risk of using a relative pathname - Fixed some typos in the documentation (Greg). - Fixed a problem with value of "channels" returned by png_read_update_info() - -Version 1.0.1a [April 21, 1998] - Optimized Paeth calculations by replacing abs() function calls with intrinsics - plus other loop optimizations. Improves avg decoding speed by about 20%. - Commented out i386istic "align" compiler flags in makefile.lnx. - Reduced the default warning level in some makefiles, to make them consistent. - Removed references to IJG and JPEG in the ansi2knr.c copyright statement. - Fixed a bug in png_do_strip_filler with XXRRGGBB => RRGGBB transformation. - Added grayscale and 16-bit capability to png_do_read_filler(). - Fixed a bug in pngset.c, introduced in version 0.99c, that sets rowbytes - too large when writing an image with bit_depth < 8 (Bob Dellaca). - Corrected some bugs in the experimental weighted filtering heuristics. - Moved a misplaced pngrutil code block that truncates tRNS if it has more - than num_palette entries -- test was done before num_palette was defined. - Fixed a png_convert_to_rfc1123() bug that converts day 31 to 0 (Steve Eddins). - Changed compiler flags in makefile.wat for better optimization - (Pawel Mrochen). - -Version 1.0.1b [May 2, 1998] - Relocated png_do_gray_to_rgb() within png_do_read_transformations() (Greg). - Relocated the png_composite macros from pngrtran.c to png.h (Greg). - Added makefile.sco (contributed by Mike Hopkirk). - Fixed two bugs (missing definitions of "istop") introduced in libpng-1.0.1a. - Fixed a bug in pngrtran.c that would set channels=5 under some circumstances. - More work on the Paeth-filtering, achieving imperceptible speedup - (A Kleinert). - More work on loop optimization which may help when compiled with C++ - compilers. - Added warnings when people try to use transforms they've defined out. - Collapsed 4 "i" and "c" loops into single "i" loops in pngrtran and pngwtran. - Revised paragraph about png_set_expand() in libpng.txt and libpng.3 (Greg) - -Version 1.0.1c [May 11, 1998] - Fixed a bug in pngrtran.c (introduced in libpng-1.0.1a) where the masks for - filler bytes should have been 0xff instead of 0xf. - Added max_pixel_depth=32 in pngrutil.c when using FILLER with palette images. - Moved PNG_WRITE_WEIGHTED_FILTER_SUPPORTED and PNG_WRITE_FLUSH_SUPPORTED - out of the PNG_WRITE_TRANSFORMS_NOT_SUPPORTED block of pngconf.h - Added "PNG_NO_WRITE_TRANSFORMS" etc., as alternatives for *_NOT_SUPPORTED, - for consistency, in pngconf.h - Added individual "ifndef PNG_NO_[CAPABILITY]" in pngconf.h to make it easier - to remove unwanted capabilities via the compile line - Made some corrections to grammar (which, it's) in documentation (Greg). - Corrected example.c, use of row_pointers in png_write_image(). - -Version 1.0.1d [May 24, 1998] - Corrected several statements that used side effects illegally in pngrutil.c - and pngtrans.c, that were introduced in version 1.0.1b - Revised png_read_rows() to avoid repeated if-testing for NULL (A Kleinert) - More corrections to example.c, use of row_pointers in png_write_image() - and png_read_rows(). - Added pngdll.mak and pngdef.pas to scripts directory, contributed by - Bob Dellaca, to make a png32bd.dll with Borland C++ 4.5 - Fixed error in example.c with png_set_text: num_text is 3, not 2 (Guido V.) - Changed several loops from count-down to count-up, for consistency. - -Version 1.0.1e [June 6, 1998] - Revised libpng.txt and libpng.3 description of png_set_read|write_fn(), and - added warnings when people try to set png_read_fn and png_write_fn in - the same structure. - Added a test such that png_do_gamma will be done when num_trans==0 - for truecolor images that have defined a background. This corrects an - error that was introduced in libpng-0.90 that can cause gamma processing - to be skipped. - Added tests in png.h to include "trans" and "trans_values" in structures - when PNG_READ_BACKGROUND_SUPPORTED or PNG_READ_EXPAND_SUPPORTED is defined. - Add png_free(png_ptr->time_buffer) in png_destroy_read_struct() - Moved png_convert_to_rfc_1123() from pngwrite.c to png.c - Added capability for user-provided malloc_fn() and free_fn() functions, - and revised pngtest.c to demonstrate their use, replacing the - PNGTEST_DEBUG_MEM feature. - Added makefile.w32, for Microsoft C++ 4.0 and later (Tim Wegner). - -Version 1.0.2 [June 14, 1998] - Fixed two bugs in makefile.bor . - -Version 1.0.2a [December 30, 1998] - Replaced and extended code that was removed from png_set_filler() in 1.0.1a. - Fixed a bug in png_do_filler() that made it fail to write filler bytes in - the left-most pixel of each row (Kevin Bracey). - Changed "static pngcharp tIME_string" to "static char tIME_string[30]" - in pngtest.c (Duncan Simpson). - Fixed a bug in pngtest.c that caused pngtest to try to write a tIME chunk - even when no tIME chunk was present in the source file. - Fixed a problem in pngrutil.c: gray_to_rgb didn't always work with 16-bit. - Fixed a problem in png_read_push_finish_row(), which would not skip some - passes that it should skip, for images that are less than 3 pixels high. - Interchanged the order of calls to png_do_swap() and png_do_shift() - in pngwtran.c (John Cromer). - Added #ifdef PNG_DEBUG/#endif surrounding use of PNG_DEBUG in png.h . - Changed "bad adaptive filter type" from error to warning in pngrutil.c . - Fixed a documentation error about default filtering with 8-bit indexed-color. - Separated the PNG_NO_STDIO macro into PNG_NO_STDIO and PNG_NO_CONSOLE_IO - (L. Peter Deutsch). - Added png_set_rgb_to_gray() and png_get_rgb_to_gray_status() functions. - Added png_get_copyright() and png_get_header_version() functions. - Revised comments on png_set_progressive_read_fn() in libpng.txt and example.c - Added information about debugging in libpng.txt and libpng.3 . - Changed "ln -sf" to "ln -s -f" in makefile.s2x, makefile.lnx, and - makefile.sco. - Removed lines after Dynamic Dependencies" in makefile.aco . - Revised makefile.dec to make a shared library (Jeremie Petit). - Removed trailing blanks from all files. - -Version 1.0.2a [January 6, 1999] - Removed misplaced #endif and #ifdef PNG_NO_EXTERN near the end of png.h - Added "if" tests to silence complaints about unused png_ptr in png.h and png.c - Changed "check_if_png" function in example.c to return true (nonzero) if PNG. - Changed libpng.txt to demonstrate png_sig_cmp() instead of png_check_sig() - which is obsolete. - -Version 1.0.3 [January 14, 1999] - Added makefile.hux, for Hewlett Packard HPUX 10.20 and 11.00 (Jim Rice) - Added a statement of Y2K compliance in png.h, libpng.3, and Y2KINFO. - -Version 1.0.3a [August 12, 1999] - Added check for PNG_READ_INTERLACE_SUPPORTED in pngread.c; issue a warning - if an attempt is made to read an interlaced image when it's not supported. - Added check if png_ptr->trans is defined before freeing it in pngread.c - Modified the Y2K statement to include versions back to version 0.71 - Fixed a bug in the check for valid IHDR bit_depth/color_types in pngrutil.c - Modified makefile.wat (added -zp8 flag, ".symbolic", changed some comments) - Replaced leading blanks with tab characters in makefile.hux - Changed "dworkin.wustl.edu" to "ccrc.wustl.edu" in various documents. - Changed (float)red and (float)green to (double)red, (double)green - in png_set_rgb_to_gray() to avoid "promotion" problems in AIX. - Fixed a bug in pngconf.h that omitted when PNG_DEBUG==0 (K Bracey). - Reformatted libpng.3 and libpngpf.3 with proper fonts (script by J. vanZandt). - Updated documentation to refer to the PNG-1.2 specification. - Removed ansi2knr.c and left pointers to the latest source for ansi2knr.c - in makefile.knr, INSTALL, and README (L. Peter Deutsch) - Fixed bugs in calculation of the length of rowbytes when adding alpha - channels to 16-bit images, in pngrtran.c (Chris Nokleberg) - Added function png_set_user_transform_info() to store user_transform_ptr, - user_depth, and user_channels into the png_struct, and a function - png_get_user_transform_ptr() to retrieve the pointer (Chris Nokleberg) - Added function png_set_empty_plte_permitted() to make libpng useable - in MNG applications. - Corrected the typedef for png_free_ptr in png.h (Jesse Jones). - Correct gamma with srgb is 45455 instead of 45000 in pngrutil.c, to be - consistent with PNG-1.2, and allow variance of 500 before complaining. - Added assembler code contributed by Intel in file pngvcrd.c and modified - makefile.w32 to use it (Nirav Chhatrapati, INTEL Corporation, - Gilles Vollant) - Changed "ln -s -f" to "ln -f -s" in the makefiles to make Solaris happy. - Added some aliases for png_set_expand() in pngrtran.c, namely - png_set_expand_PLTE(), png_set_expand_depth(), and png_set_expand_tRNS() - (Greg Roelofs, in "PNG: The Definitive Guide"). - Added makefile.beo for BEOS on X86, contributed by Sander Stok. - -Version 1.0.3b [August 26, 1999] - Replaced 2147483647L several places with PNG_MAX_UINT macro, defined in png.h - Changed leading blanks to tabs in all makefiles. - Define PNG_USE_PNGVCRD in makefile.w32, to get MMX assembler code. - Made alternate versions of png_set_expand() in pngrtran.c, namely - png_set_gray_1_2_4_to_8, png_set_palette_to_rgb, and png_set_tRNS_to_alpha - (Greg Roelofs, in "PNG: The Definitive Guide"). Deleted the 1.0.3a aliases. - Relocated start of 'extern "C"' block in png.h so it doesn't include pngconf.h - Revised calculation of num_blocks in pngmem.c to avoid a potentially - negative shift distance, whose results are undefined in the C language. - Added a check in pngset.c to prevent writing multiple tIME chunks. - Added a check in pngwrite.c to detect invalid small window_bits sizes. - -Version 1.0.3d [September 4, 1999] - Fixed type casting of igamma in pngrutil.c - Added new png_expand functions to scripts/pngdef.pas and pngos2.def - Added a demo read_user_transform_fn that examines the row filters in pngtest.c - -Version 1.0.4 [September 24, 1999, not distributed publicly] - Define PNG_ALWAYS_EXTERN in pngconf.h if __STDC__ is defined - Delete #define PNG_INTERNAL and include "png.h" from pngasmrd.h - Made several minor corrections to pngtest.c - Renamed the makefiles with longer but more user friendly extensions. - Copied the PNG copyright and license to a separate LICENSE file. - Revised documentation, png.h, and example.c to remove reference to - "viewing_gamma" which no longer appears in the PNG specification. - Revised pngvcrd.c to use MMX code for interlacing only on the final pass. - Updated pngvcrd.c to use the faster C filter algorithms from libpng-1.0.1a - Split makefile.win32vc into two versions, makefile.vcawin32 (uses MMX - assembler code) and makefile.vcwin32 (doesn't). - Added a CPU timing report to pngtest.c (enabled by defining PNGTEST_TIMING) - Added a copy of pngnow.png to the distribution. - -Version 1.0.4a [September 25, 1999] - Increase max_pixel_depth in pngrutil.c if a user transform needs it. - Changed several division operations to right-shifts in pngvcrd.c - -Version 1.0.4b [September 30, 1999] - Added parentheses in line 3732 of pngvcrd.c - Added a comment in makefile.linux warning about buggy -O3 in pgcc 2.95.1 - -Version 1.0.4c [October 1, 1999] - Added a "png_check_version" function in png.c and pngtest.c that will generate - a helpful compiler error if an old png.h is found in the search path. - Changed type of png_user_transform_depth|channels from int to png_byte. - Added "Libpng is OSI Certified Open Source Software" statement to png.h - -Version 1.0.4d [October 6, 1999] - Changed 0.45 to 0.45455 in png_set_sRGB() - Removed unused PLTE entries from pngnow.png - Re-enabled some parts of pngvcrd.c (png_combine_row) that work properly. - -Version 1.0.4e [October 10, 1999] - Fixed sign error in pngvcrd.c (Greg Roelofs) - Replaced some instances of memcpy with simple assignments in pngvcrd (GR-P) - -Version 1.0.4f [October 15, 1999] - Surrounded example.c code with #if 0 .. #endif to prevent people from - inadvertently trying to compile it. - Changed png_get_header_version() from a function to a macro in png.h - Added type casting mostly in pngrtran.c and pngwtran.c - Removed some pointless "ptr = NULL" in pngmem.c - Added a "contrib" directory containing the source code from Greg's book. - -Version 1.0.5 [October 15, 1999] - Minor editing of the INSTALL and README files. - -Version 1.0.5a [October 23, 1999] - Added contrib/pngsuite and contrib/pngminus (Willem van Schaik) - Fixed a typo in the png_set_sRGB() function call in example.c (Jan Nijtmans) - Further optimization and bugfix of pngvcrd.c - Revised pngset.c so that it does not allocate or free memory in the user's - text_ptr structure. Instead, it makes its own copy. - Created separate write_end_info_struct in pngtest.c for a more severe test. - Added code in pngwrite.c to free info_ptr->text[i].key to stop a memory leak. - -Version 1.0.5b [November 23, 1999] - Moved PNG_FLAG_HAVE_CHUNK_HEADER, PNG_FLAG_BACKGROUND_IS_GRAY and - PNG_FLAG_WROTE_tIME from flags to mode. - Added png_write_info_before_PLTE() function. - Fixed some typecasting in contrib/gregbook/*.c - Updated scripts/makevms.com and added makevms.com to contrib/gregbook - and contrib/pngminus (Martin Zinser) - -Version 1.0.5c [November 26, 1999] - Moved png_get_header_version from png.h to png.c, to accommodate ansi2knr. - Removed all global arrays (according to PNG_NO_GLOBAL_ARRAYS macro), to - accommodate making DLL's: Moved usr_png_ver from global variable to function - png_get_header_ver() in png.c. Moved png_sig to png_sig_bytes in png.c and - eliminated use of png_sig in pngwutil.c. Moved the various png_CHNK arrays - into pngtypes.h. Eliminated use of global png_pass arrays. Declared the - png_CHNK and png_pass arrays to be "const". Made the global arrays - available to applications (although none are used in libpng itself) when - PNG_NO_GLOBAL_ARRAYS is not defined or when PNG_GLOBAL_ARRAYS is defined. - Removed some extraneous "-I" from contrib/pngminus/makefile.std - Changed the PNG_sRGB_INTENT macros in png.h to be consistent with PNG-1.2. - Change PNG_SRGB_INTENT to PNG_sRGB_INTENT in libpng.txt and libpng.3 - -Version 1.0.5d [November 29, 1999] - Add type cast (png_const_charp) two places in png.c - Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays. - Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available - to applications a macro "PNG_USE_LOCAL_ARRAYS". - comment out (with #ifdef) all the new declarations when - PNG_USE_GLOBAL_ARRAYS is defined. - Added PNG_EXPORT_VAR macro to accommodate making DLL's. - -Version 1.0.5e [November 30, 1999] - Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text - structure; refactored the inflate/deflate support to make adding new chunks - with trailing compressed parts easier in the future, and added new functions - png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP, - png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond). - NOTE: Applications that write text chunks MUST define png_text->lang - before calling png_set_text(). It must be set to NULL if you want to - write tEXt or zTXt chunks. If you want your application to be able to - run with older versions of libpng, use - - #ifdef PNG_iTXt_SUPPORTED - png_text[i].lang = NULL; - #endif - - Changed png_get_oFFs() and png_set_oFFs() to use signed rather than unsigned - offsets (Eric S. Raymond). - Combined PNG_READ_cHNK_SUPPORTED and PNG_WRITE_cHNK_SUPPORTED macros into - PNG_cHNK_SUPPORTED and combined the three types of PNG_text_SUPPORTED - macros, leaving the separate macros also available. - Removed comments on #endifs at the end of many short, non-nested #if-blocks. - -Version 1.0.5f [December 6, 1999] - Changed makefile.solaris to issue a warning about potential problems when - the ucb "ld" is in the path ahead of the ccs "ld". - Removed "- [date]" from the "synopsis" line in libpng.3 and libpngpf.3. - Added sCAL chunk support (Eric S. Raymond). - -Version 1.0.5g [December 7, 1999] - Fixed "png_free_spallettes" typo in png.h - Added code to handle new chunks in pngpread.c - Moved PNG_CHNK string macro definitions outside of PNG_NO_EXTERN block - Added "translated_key" to png_text structure and png_write_iTXt(). - Added code in pngwrite.c to work around a newly discovered zlib bug. - -Version 1.0.5h [December 10, 1999] - NOTE: regarding the note for version 1.0.5e, the following must also - be included in your code: - png_text[i].translated_key = NULL; - Unknown chunk handling is now supported. - Option to eliminate all floating point support was added. Some new - fixed-point functions such as png_set_gAMA_fixed() were added. - Expanded tabs and removed trailing blanks in source files. - -Version 1.0.5i [December 13, 1999] - Added some type casts to silence compiler warnings. - Renamed "png_free_spalette" to "png_free_spalettes" for consistency. - Removed leading blanks from a #define in pngvcrd.c - Added some parameters to the new png_set_keep_unknown_chunks() function. - Added a test for up->location != 0 in the first instance of writing - unknown chunks in pngwrite.c - Changed "num" to "i" in png_free_spalettes() and png_free_unknowns() to - prevent recursion. - Added png_free_hIST() function. - Various patches to fix bugs in the sCAL and integer cHRM processing, - and to add some convenience macros for use with sCAL. - -Version 1.0.5j [December 21, 1999] - Changed "unit" parameter of png_write_sCAL from png_byte to int, to work - around buggy compilers. - Added new type "png_fixed_point" for integers that hold float*100000 values - Restored backward compatibility of tEXt/zTXt chunk processing: - Restored the first four members of png_text to the same order as v.1.0.5d. - Added members "lang_key" and "itxt_length" to png_text struct. Set - text_length=0 when "text" contains iTXt data. Use the "compression" - member to distinguish among tEXt/zTXt/iTXt types. Added - PNG_ITXT_COMPRESSION_NONE (1) and PNG_ITXT_COMPRESSION_zTXt(2) macros. - The "Note" above, about backward incompatibility of libpng-1.0.5e, no - longer applies. - Fixed png_read|write_iTXt() to read|write parameters in the right order, - and to write the iTXt chunk after IDAT if it appears in the end_ptr. - Added pnggccrd.c, version of pngvcrd.c Intel assembler for gcc (Greg Roelofs) - Reversed the order of trying to write floating-point and fixed-point gAMA. - -Version 1.0.5k [December 27, 1999] - Added many parentheses, e.g., "if (a && b & c)" becomes "if (a && (b & c))" - Added png_handle_as_unknown() function (Glenn) - Added png_free_chunk_list() function and chunk_list and num_chunk_list members - of png_ptr. - Eliminated erroneous warnings about multiple sPLT chunks and sPLT-after-PLTE. - Fixed a libpng-1.0.5h bug in pngrutil.c that was issuing erroneous warnings - about ignoring incorrect gAMA with sRGB (gAMA was in fact not ignored) - Added png_free_tRNS(); png_set_tRNS() now malloc's its own trans array (ESR). - Define png_get_int_32 when oFFs chunk is supported as well as when pCAL is. - Changed type of proflen from png_int_32 to png_uint_32 in png_get_iCCP(). - -Version 1.0.5l [January 1, 2000] - Added functions png_set_read_user_chunk_fn() and png_get_user_chunk_ptr() - for setting a callback function to handle unknown chunks and for - retrieving the associated user pointer (Glenn). - -Version 1.0.5m [January 7, 2000] - Added high-level functions png_read_png(), png_write_png(), png_free_pixels(). - -Version 1.0.5n [January 9, 2000] - Added png_free_PLTE() function, and modified png_set_PLTE() to malloc its - own memory for info_ptr->palette. This makes it safe for the calling - application to free its copy of the palette any time after it calls - png_set_PLTE(). - -Version 1.0.5o [January 20, 2000] - Cosmetic changes only (removed some trailing blanks and TABs) - -Version 1.0.5p [January 31, 2000] - Renamed pngdll.mak to makefile.bd32 - Cosmetic changes in pngtest.c - -Version 1.0.5q [February 5, 2000] - Relocated the makefile.solaris warning about PATH problems. - Fixed pngvcrd.c bug by pushing/popping registers in mmxsupport (Bruce Oberg) - Revised makefile.gcmmx - Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() macros - -Version 1.0.5r [February 7, 2000] - Removed superfluous prototype for png_get_itxt from png.h - Fixed a bug in pngrtran.c that improperly expanded the background color. - Return *num_text=0 from png_get_text() when appropriate, and fix documentation - of png_get_text() in libpng.txt/libpng.3. - -Version 1.0.5s [February 18, 2000] - Added "png_jmp_env()" macro to pngconf.h, to help people migrate to the - new error handler that's planned for the next libpng release, and changed - example.c, pngtest.c, and contrib programs to use this macro. - Revised some of the DLL-export macros in pngconf.h (Greg Roelofs) - Fixed a bug in png_read_png() that caused it to fail to expand some images - that it should have expanded. - Fixed some mistakes in the unused and undocumented INCH_CONVERSIONS functions - in pngget.c - Changed the allocation of palette, history, and trans arrays back to - the version 1.0.5 method (linking instead of copying) which restores - backward compatibility with version 1.0.5. Added some remarks about - that in example.c. Added "free_me" member to info_ptr and png_ptr - and added png_free_data() function. - Updated makefile.linux and makefile.gccmmx to make directories conditionally. - Made cosmetic changes to pngasmrd.h - Added png_set_rows() and png_get_rows(), for use with png_read|write_png(). - Modified png_read_png() to allocate info_ptr->row_pointers only if it - hasn't already been allocated. - -Version 1.0.5t [March 4, 2000] - Changed png_jmp_env() migration aiding macro to png_jmpbuf(). - Fixed "interlace" typo (should be "interlaced") in contrib/gregbook/read2-x.c - Fixed bug with use of PNG_BEFORE_IHDR bit in png_ptr->mode, introduced when - PNG_FLAG_HAVE_CHUNK_HEADER was moved into png_ptr->mode in version 1.0.5b - Files in contrib/gregbook were revised to use png_jmpbuf() and to select - a 24-bit visual if one is available, and to allow abbreviated options. - Files in contrib/pngminus were revised to use the png_jmpbuf() macro. - Removed spaces in makefile.linux and makefile.gcmmx, introduced in 1.0.5s - -Version 1.0.5u [March 5, 2000] - Simplified the code that detects old png.h in png.c and pngtest.c - Renamed png_spalette (_p, _pp) to png_sPLT_t (_tp, _tpp) - Increased precision of rgb_to_gray calculations from 8 to 15 bits and - added png_set_rgb_to_gray_fixed() function. - Added makefile.bc32 (32-bit Borland C++, C mode) - -Version 1.0.5v [March 11, 2000] - Added some parentheses to the png_jmpbuf macro definition. - Updated references to the zlib home page, which has moved to freesoftware.com. - Corrected bugs in documentation regarding png_read_row() and png_write_row(). - Updated documentation of png_rgb_to_gray calculations in libpng.3/libpng.txt. - Renamed makefile.borland,turboc3 back to makefile.bor,tc3 as in version 1.0.3, - revised borland makefiles; added makefile.ibmvac3 and makefile.gcc (Cosmin) - -Version 1.0.6 [March 20, 2000] - Minor revisions of makefile.bor, libpng.txt, and gregbook/rpng2-win.c - Added makefile.sggcc (SGI IRIX with gcc) - -Version 1.0.6d [April 7, 2000] - Changed sprintf() to strcpy() in png_write_sCAL_s() to work without STDIO - Added data_length parameter to png_decompress_chunk() function - Revised documentation to remove reference to abandoned png_free_chnk functions - Fixed an error in png_rgb_to_gray_fixed() - Revised example.c, usage of png_destroy_write_struct(). - Renamed makefile.ibmvac3 to makefile.ibmc, added libpng.icc IBM project file - Added a check for info_ptr->free_me&PNG_FREE_TEXT when freeing text in png.c - Simplify png_sig_bytes() function to remove use of non-ISO-C strdup(). - -Version 1.0.6e [April 9, 2000] - Added png_data_freer() function. - In the code that checks for over-length tRNS chunks, added check of - info_ptr->num_trans as well as png_ptr->num_trans (Matthias Benckmann) - Minor revisions of libpng.txt/libpng.3. - Check for existing data and free it if the free_me flag is set, in png_set_*() - and png_handle_*(). - Only define PNG_WEIGHTED_FILTERS_SUPPORTED when PNG_FLOATING_POINT_SUPPORTED - is defined. - Changed several instances of PNG_NO_CONSOLE_ID to PNG_NO_STDIO in pngrutil.c - and mentioned the purposes of the two macros in libpng.txt/libpng.3. - -Version 1.0.6f [April 14, 2000] - Revised png_set_iCCP() and png_set_rows() to avoid prematurely freeing data. - Add checks in png_set_text() for NULL members of the input text structure. - Revised libpng.txt/libpng.3. - Removed superfluous prototype for png_set_iTXt from png.h - Removed "else" from pngread.c, after png_error(), and changed "0" to "length". - Changed several png_errors about malformed ancillary chunks to png_warnings. - -Version 1.0.6g [April 24, 2000] - Added png_pass-* arrays to pnggccrd.c when PNG_USE_LOCAL_ARRAYS is defined. - Relocated paragraph about png_set_background() in libpng.3/libpng.txt - and other revisions (Matthias Benckmann) - Relocated info_ptr->free_me, png_ptr->free_me, and other info_ptr and - png_ptr members to restore binary compatibility with libpng-1.0.5 - (breaks compatibility with libpng-1.0.6). - -Version 1.0.6h [April 24, 2000] - Changed shared library so-number pattern from 2.x.y.z to xy.z (this builds - libpng.so.10 & libpng.so.10.6h instead of libpng.so.2 & libpng.so.2.1.0.6h) - This is a temporary change for test purposes. - -Version 1.0.6i [May 2, 2000] - Rearranged some members at the end of png_info and png_struct, to put - unknown_chunks_num and free_me within the original size of the png_structs - and free_me, png_read_user_fn, and png_free_fn within the original png_info, - because some old applications allocate the structs directly instead of - using png_create_*(). - Added documentation of user memory functions in libpng.txt/libpng.3 - Modified png_read_png so that it will use user_allocated row_pointers - if present, unless free_me directs that it be freed, and added description - of the use of png_set_rows() and png_get_rows() in libpng.txt/libpng.3. - Added PNG_LEGACY_SUPPORTED macro, and #ifdef out all new (since version - 1.00) members of png_struct and png_info, to regain binary compatibility - when you define this macro. Capabilities lost in this event - are user transforms (new in version 1.0.0),the user transform pointer - (new in version 1.0.2), rgb_to_gray (new in 1.0.5), iCCP, sCAL, sPLT, - the high-level interface, and unknown chunks support (all new in 1.0.6). - This was necessary because of old applications that allocate the structs - directly as authors were instructed to do in libpng-0.88 and earlier, - instead of using png_create_*(). - Added modes PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT which - can be used to detect codes that directly allocate the structs, and - code to check these modes in png_read_init() and png_write_init() and - generate a libpng error if the modes aren't set and PNG_LEGACY_SUPPORTED - was not defined. - Added makefile.intel and updated makefile.watcom (Pawel Mrochen) - -Version 1.0.6j [May 3, 2000] - Overloaded png_read_init() and png_write_init() with macros that convert - calls to png_read_init_2() or png_write_init_2() that check the version - and structure sizes. - -Version 1.0.7beta11 [May 7, 2000] - Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes - which are no longer used. - Eliminated the three new members of png_text when PNG_LEGACY_SUPPORTED is - defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXT_SUPPORTED - is defined. - Made PNG_NO_READ|WRITE_iTXt the default setting, to avoid memory - overrun when old applications fill the info_ptr->text structure directly. - Added PNGAPI macro, and added it to the definitions of all exported functions. - Relocated version macro definitions ahead of the includes of zlib.h and - pngconf.h in png.h. - -Version 1.0.7beta12 [May 12, 2000] - Revised pngset.c to avoid a problem with expanding the png_debug macro. - Deleted some extraneous defines from pngconf.h - Made PNG_NO_CONSOLE_IO the default condition when PNG_BUILD_DLL is defined. - Use MSC _RPTn debugging instead of fprintf if _MSC_VER is defined. - Added png_access_version_number() function. - Check for mask&PNG_FREE_CHNK (for TEXT, SCAL, PCAL) in png_free_data(). - Expanded libpng.3/libpng.txt information about png_data_freer(). - -Version 1.0.7beta14 [May 17, 2000] (beta13 was not published) - Changed pnggccrd.c and pngvcrd.c to handle bad adaptive filter types as - warnings instead of errors, as pngrutil.c does. - Set the PNG_INFO_IDAT valid flag in png_set_rows() so png_write_png() - will actually write IDATs. - Made the default PNG_USE_LOCAL_ARRAYS depend on PNG_DLL instead of WIN32. - Make png_free_data() ignore its final parameter except when freeing data - that can have multiple instances (text, sPLT, unknowns). - Fixed a new bug in png_set_rows(). - Removed info_ptr->valid tests from png_free_data(), as in version 1.0.5. - Added png_set_invalid() function. - Fixed incorrect illustrations of png_destroy_write_struct() in example.c. - -Version 1.0.7beta15 [May 30, 2000] - Revised the deliberately erroneous Linux setjmp code in pngconf.h to produce - fewer error messages. - Rearranged checks for Z_OK to check the most likely path first in pngpread.c - and pngwutil.c. - Added checks in pngtest.c for png_create_*() returning NULL, and mentioned - in libpng.txt/libpng.3 the need for applications to check this. - Changed names of png_default_*() functions in pngtest to pngtest_*(). - Changed return type of png_get_x|y_offset_*() from png_uint_32 to png_int_32. - Fixed some bugs in the unused PNG_INCH_CONVERSIONS functions in pngget.c - Set each pointer to NULL after freeing it in png_free_data(). - Worked around a problem in pngconf.h; AIX's strings.h defines an "index" - macro that conflicts with libpng's png_color_16.index. (Dimitri - Papadapoulos) - Added "msvc" directory with MSVC++ project files (Simon-Pierre Cadieux). - -Version 1.0.7beta16 [June 4, 2000] - Revised the workaround of AIX string.h "index" bug. - Added a check for overlength PLTE chunk in pngrutil.c. - Added PNG_NO_POINTER_INDEXING macro to use array-indexing instead of pointer - indexing in pngrutil.c and pngwutil.c to accommodate a buggy compiler. - Added a warning in png_decompress_chunk() when it runs out of data, e.g. - when it tries to read an erroneous PhotoShop iCCP chunk. - Added PNG_USE_DLL macro. - Revised the copyright/disclaimer/license notice. - Added contrib/msvctest directory - -Version 1.0.7rc1 [June 9, 2000] - Corrected the definition of PNG_TRANSFORM_INVERT_ALPHA (0x0400 not 0x0200) - Added contrib/visupng directory (Willem van Schaik) - -Version 1.0.7beta18 [June 23, 2000] - Revised PNGAPI definition, and pngvcrd.c to work with __GCC__ - and do not redefine PNGAPI if it is passed in via a compiler directive. - Revised visupng/PngFile.c to remove returns from within the Try block. - Removed leading underscores from "_PNG_H" and "_PNG_SAVE_BSD_SOURCE" macros. - Updated contrib/visupng/cexcept.h to version 1.0.0. - Fixed bugs in pngwrite.c and pngwutil.c that prevented writing iCCP chunks. - -Version 1.0.7rc2 [June 28, 2000] - Updated license to include disclaimers required by UCITA. - Fixed "DJBPP" typo in pnggccrd.c introduced in beta18. - -Version 1.0.7 [July 1, 2000] - Revised the definition of "trans_values" in libpng.3/libpng.txt - -Version 1.0.8beta1 [July 8, 2000] - Added png_free(png_ptr, key) two places in pngpread.c to stop memory leaks. - Changed PNG_NO_STDIO to PNG_NO_CONSOLE_IO, several places in pngrutil.c and - pngwutil.c. - Changed PNG_EXPORT_VAR to use PNG_IMPEXP, in pngconf.h. - Removed unused "#include " from png.c - Added WindowsCE support. - Revised pnggccrd.c to work with gcc-2.95.2 and in the Cygwin environment. - -Version 1.0.8beta2 [July 10, 2000] - Added project files to the wince directory and made further revisions - of pngtest.c, pngrio.c, and pngwio.c in support of WindowsCE. - -Version 1.0.8beta3 [July 11, 2000] - Only set the PNG_FLAG_FREE_TRNS or PNG_FREE_TRNS flag in png_handle_tRNS() - for indexed-color input files to avoid potential double-freeing trans array - under some unusual conditions; problem was introduced in version 1.0.6f. - Further revisions to pngtest.c and files in the wince subdirectory. - -Version 1.0.8beta4 [July 14, 2000] - Added the files pngbar.png and pngbar.jpg to the distribution. - Added makefile.cygwin, and cygwin support in pngconf.h - Added PNG_NO_ZALLOC_ZERO macro (makes png_zalloc skip zeroing memory) - -Version 1.0.8rc1 [July 16, 2000] - Revised png_debug() macros and statements to eliminate compiler warnings. - -Version 1.0.8 [July 24, 2000] - Added png_flush() in pngwrite.c, after png_write_IEND(). - Updated makefile.hpux to build a shared library. - -Version 1.0.9beta1 [November 10, 2000] - Fixed typo in scripts/makefile.hpux - Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser) - Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser) - Changed "cdrom.com" in documentation to "libpng.org" - Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg). - Changed type of "params" from voidp to png_voidp in png_read|write_png(). - Make sure PNGAPI and PNG_IMPEXP are defined in pngconf.h. - Revised the 3 instances of WRITEFILE in pngtest.c. - Relocated "msvc" and "wince" project subdirectories into "dll" subdirectory. - Updated png.rc in dll/msvc project - Revised makefile.dec to define and use LIBPATH and INCPATH - Increased size of global png_libpng_ver[] array from 12 to 18 chars. - Made global png_libpng_ver[], png_sig[] and png_pass_*[] arrays const. - Removed duplicate png_crc_finish() from png_handle_bKGD() function. - Added a warning when application calls png_read_update_info() multiple times. - Revised makefile.cygwin - Fixed bugs in iCCP support in pngrutil.c and pngwutil.c. - Replaced png_set_empty_plte_permitted() with png_permit_mng_features(). - -Version 1.0.9beta2 [November 19, 2000] - Renamed the "dll" subdirectory "projects". - Added borland project files to "projects" subdirectory. - Set VS_FF_PRERELEASE and VS_FF_PATCHED flags in msvc/png.rc when appropriate. - Add error message in png_set_compression_buffer_size() when malloc fails. - -Version 1.0.9beta3 [November 23, 2000] - Revised PNG_LIBPNG_BUILD_TYPE macro in png.h, used in the msvc project. - Removed the png_flush() in pngwrite.c that crashes some applications - that don't set png_output_flush_fn. - Added makefile.macosx and makefile.aix to scripts directory. - -Version 1.0.9beta4 [December 1, 2000] - Change png_chunk_warning to png_warning in png_check_keyword(). - Increased the first part of msg buffer from 16 to 18 in png_chunk_error(). - -Version 1.0.9beta5 [December 15, 2000] - Added support for filter method 64 (for PNG datastreams embedded in MNG). - -Version 1.0.9beta6 [December 18, 2000] - Revised png_set_filter() to accept filter method 64 when appropriate. - Added new PNG_HAVE_PNG_SIGNATURE bit to png_ptr->mode and use it to - help prevent applications from using MNG features in PNG datastreams. - Added png_permit_mng_features() function. - Revised libpng.3/libpng.txt. Changed "filter type" to "filter method". - -Version 1.0.9rc1 [December 23, 2000] - Revised test for PNG_HAVE_PNG_SIGNATURE in pngrutil.c - Fixed error handling of unknown compression type in png_decompress_chunk(). - In pngconf.h, define __cdecl when _MSC_VER is defined. - -Version 1.0.9beta7 [December 28, 2000] - Changed PNG_TEXT_COMPRESSION_zTXt to PNG_COMPRESSION_TYPE_BASE several places. - Revised memory management in png_set_hIST and png_handle_hIST in a backward - compatible manner. PLTE and tRNS were revised similarly. - Revised the iCCP chunk reader to ignore trailing garbage. - -Version 1.0.9beta8 [January 12, 2001] - Moved pngasmrd.h into pngconf.h. - Improved handling of out-of-spec garbage iCCP chunks generated by PhotoShop. - -Version 1.0.9beta9 [January 15, 2001] - Added png_set_invalid, png_permit_mng_features, and png_mmx_supported to - wince and msvc project module definition files. - Minor revision of makefile.cygwin. - Fixed bug with progressive reading of narrow interlaced images in pngpread.c - -Version 1.0.9beta10 [January 16, 2001] - Do not typedef png_FILE_p in pngconf.h when PNG_NO_STDIO is defined. - Fixed "png_mmx_supported" typo in project definition files. - -Version 1.0.9beta11 [January 19, 2001] - Updated makefile.sgi to make shared library. - Removed png_mmx_support() function and disabled PNG_MNG_FEATURES_SUPPORTED - by default, for the benefit of DLL forward compatibility. These will - be re-enabled in version 1.2.0. - -Version 1.0.9rc2 [January 22, 2001] - Revised cygwin support. - -Version 1.0.9 [January 31, 2001] - Added check of cygwin's ALL_STATIC in pngconf.h - Added "-nommx" parameter to contrib/gregbook/rpng2-win and rpng2-x demos. - -Version 1.0.10beta1 [March 14, 2001] - Revised makefile.dec, makefile.sgi, and makefile.sggcc; added makefile.hpgcc. - Reformatted libpng.3 to eliminate bad line breaks. - Added checks for _mmx_supported in the read_filter_row function of pnggccrd.c - Added prototype for png_mmx_support() near the top of pnggccrd.c - Moved some error checking from png_handle_IHDR to png_set_IHDR. - Added PNG_NO_READ_SUPPORTED and PNG_NO_WRITE_SUPPORTED macros. - Revised png_mmx_support() function in pnggccrd.c - Restored version 1.0.8 PNG_WRITE_EMPTY_PLTE_SUPPORTED behavior in pngwutil.c - Fixed memory leak in contrib/visupng/PngFile.c - Fixed bugs in png_combine_row() in pnggccrd.c and pngvcrd.c (C version) - Added warnings when retrieving or setting gamma=0. - Increased the first part of msg buffer from 16 to 18 in png_chunk_warning(). - -Version 1.0.10rc1 [March 23, 2001] - Changed all instances of memcpy, strcpy, and strlen to png_memcpy, png_strcpy, - and png_strlen. - Revised png_mmx_supported() function in pnggccrd.c to return proper value. - Fixed bug in progressive reading (pngpread.c) with small images (height < 8). - -Version 1.0.10 [March 30, 2001] - Deleted extraneous space (introduced in 1.0.9) from line 42 of makefile.cygwin - Added beos project files (Chris Herborth) - -Version 1.0.11beta1 [April 3, 2001] - Added type casts on several png_malloc() calls (Dimitri Papadapoulos). - Removed a no-longer needed AIX work-around from pngconf.h - Changed several "//" single-line comments to C-style in pnggccrd.c - -Version 1.0.11beta2 [April 11, 2001] - Removed PNGAPI from several functions whose prototypes did not have PNGAPI. - Updated scripts/pngos2.def - -Version 1.0.11beta3 [April 14, 2001] - Added checking the results of many instances of png_malloc() for NULL - -Version 1.0.11beta4 [April 20, 2001] - Undid the changes from version 1.0.11beta3. Added a check for NULL return - from user's malloc_fn(). - Removed some useless type casts of the NULL pointer. - Added makefile.netbsd - -Version 1.0.11 [April 27, 2001] - Revised makefile.netbsd - -Version 1.0.12beta1 [May 14, 2001] - Test for Windows platform in pngconf.h when including malloc.h (Emmanuel Blot) - Updated makefile.cygwin and handling of Cygwin's ALL_STATIC in pngconf.h - Added some never-to-be-executed code in pnggccrd.c to quiet compiler warnings. - Eliminated the png_error about apps using png_read|write_init(). Instead, - libpng will reallocate the png_struct and info_struct if they are too small. - This retains future binary compatibility for old applications written for - libpng-0.88 and earlier. - -Version 1.2.0beta1 [May 6, 2001] - Bumped DLLNUM to 2. - Re-enabled PNG_MNG_FEATURES_SUPPORTED and enabled PNG_ASSEMBLER_CODE_SUPPORTED - by default. - Added runtime selection of MMX features. - Added png_set_strip_error_numbers function and related macros. - -Version 1.2.0beta2 [May 7, 2001] - Finished merging 1.2.0beta1 with version 1.0.11 - Added a check for attempts to read or write PLTE in grayscale PNG datastreams. - -Version 1.2.0beta3 [May 17, 2001] - Enabled user memory function by default. - Modified png_create_struct so it passes user mem_ptr to user memory allocator. - Increased png_mng_features flag from png_byte to png_uint_32. - Bumped shared-library (so-number) and dll-number to 3. - -Version 1.2.0beta4 [June 23, 2001] - Check for missing profile length field in iCCP chunk and free chunk_data - in case of truncated iCCP chunk. - Bumped shared-library number to 3 in makefile.sgi and makefile.sggcc - Bumped dll-number from 2 to 3 in makefile.cygwin - Revised contrib/gregbook/rpng*-x.c to avoid a memory leak and to exit cleanly - if user attempts to run it on an 8-bit display. - Updated contrib/gregbook - Use png_malloc instead of png_zalloc to allocate palette in pngset.c - Updated makefile.ibmc - Added some typecasts to eliminate gcc 3.0 warnings. Changed prototypes - of png_write_oFFS width and height from png_uint_32 to png_int_32. - Updated example.c - Revised prototypes for png_debug_malloc and png_debug_free in pngtest.c - -Version 1.2.0beta5 [August 8, 2001] - Revised contrib/gregbook - Revised makefile.gcmmx - Revised pnggccrd.c to conditionally compile some thread-unsafe code only - when PNG_THREAD_UNSAFE_OK is defined. - Added tests to prevent pngwutil.c from writing a bKGD or tRNS chunk with - value exceeding 2^bit_depth-1 - Revised makefile.sgi and makefile.sggcc - Replaced calls to fprintf(stderr,...) with png_warning() in pnggccrd.c - Removed restriction that do_invert_mono only operate on 1-bit opaque files - -Version 1.2.0 [September 1, 2001] - Changed a png_warning() to png_debug() in pnggccrd.c - Fixed contrib/gregbook/rpng-x.c, rpng2-x.c to avoid crash with XFreeGC(). - -Version 1.2.1beta1 [October 19, 2001] - Revised makefile.std in contrib/pngminus - Include background_1 in png_struct regardless of gamma support. - Revised makefile.netbsd and makefile.macosx, added makefile.darwin. - Revised example.c to provide more details about using row_callback(). - -Version 1.2.1beta2 [October 25, 2001] - Added type cast to each NULL appearing in a function call, except for - WINCE functions. - Added makefile.so9. - -Version 1.2.1beta3 [October 27, 2001] - Removed type casts from all NULLs. - Simplified png_create_struct_2(). - -Version 1.2.1beta4 [November 7, 2001] - Revised png_create_info_struct() and png_creat_struct_2(). - Added error message if png_write_info() was omitted. - Type cast NULLs appearing in function calls when _NO_PROTO or - PNG_TYPECAST_NULL is defined. - -Version 1.2.1rc1 [November 24, 2001] - Type cast NULLs appearing in function calls except when PNG_NO_TYPECAST_NULL - is defined. - Changed typecast of "size" argument to png_size_t in pngmem.c calls to - the user malloc_fn, to agree with the prototype in png.h - Added a pop/push operation to pnggccrd.c, to preserve Eflag (Maxim Sobolev) - Updated makefile.sgi to recognize LIBPATH and INCPATH. - Updated various makefiles so "make clean" does not remove previous major - version of the shared library. - -Version 1.2.1rc2 [December 4, 2001] - Always allocate 256-entry internal palette, hist, and trans arrays, to - avoid out-of-bounds memory reference caused by invalid PNG datastreams. - Added a check for prefix_length > data_length in iCCP chunk handler. - -Version 1.2.1 [December 7, 2001] - None. - -Version 1.2.2beta1 [February 22, 2002] - Fixed a bug with reading the length of iCCP profiles (Larry Reeves). - Revised makefile.linux, makefile.gcmmx, and makefile.sgi to generate - libpng.a, libpng12.so (not libpng.so.3), and libpng12/png.h - Revised makefile.darwin to remove "-undefined suppress" option. - Added checks for gamma and chromaticity values over 21474.83, which exceed - the limit for PNG unsigned 32-bit integers when encoded. - Revised calls to png_create_read_struct() and png_create_write_struct() - for simpler debugging. - Revised png_zalloc() so zlib handles errors (uses PNG_FLAG_MALLOC_NULL_MEM_OK) - -Version 1.2.2beta2 [February 23, 2002] - Check chunk_length and idat_size for invalid (over PNG_MAX_UINT) lengths. - Check for invalid image dimensions in png_get_IHDR. - Added missing "fi;" in the install target of the SGI makefiles. - Added install-static to all makefiles that make shared libraries. - Always do gamma compensation when image is partially transparent. - -Version 1.2.2beta3 [March 7, 2002] - Compute background.gray and background_1.gray even when color_type is RGB - in case image gets reduced to gray later. - Modified shared-library makefiles to install pkgconfig/libpngNN.pc. - Export (with PNGAPI) png_zalloc, png_zfree, and png_handle_as_unknown - Removed unused png_write_destroy_info prototype from png.h - Eliminated incorrect use of width_mmx from pnggccrd.c in pixel_bytes == 8 case - Added install-shared target to all makefiles that make shared libraries. - Stopped a double free of palette, hist, and trans when not using free_me. - Added makefile.32sunu for Sun Ultra 32 and makefile.64sunu for Sun Ultra 64. - -Version 1.2.2beta4 [March 8, 2002] - Compute background.gray and background_1.gray even when color_type is RGB - in case image gets reduced to gray later (Jason Summers). - Relocated a misplaced /bin/rm in the "install-shared" makefile targets - Added PNG_1_0_X macro which can be used to build a 1.0.x-compatible library. - -Version 1.2.2beta5 [March 26, 2002] - Added missing PNGAPI to several function definitions. - Check for invalid bit_depth or color_type in png_get_IHDR(), and - check for missing PLTE or IHDR in png_push_read_chunk() (Matthias Clasen). - Revised iTXt support to accept NULL for lang and lang_key. - Compute gamma for color components of background even when color_type is gray. - Changed "()" to "{}" in scripts/libpng.pc.in. - Revised makefiles to put png.h and pngconf.h only in $prefix/include/libpngNN - Revised makefiles to make symlink to libpng.so.NN in addition to libpngNN.so - -Version 1.2.2beta6 [March 31, 2002] - -Version 1.0.13beta1 [March 31, 2002] - Prevent png_zalloc() from trying to memset memory that it failed to acquire. - Add typecasts of PNG_MAX_UINT in pngset_cHRM_fixed() (Matt Holgate). - Ensure that the right function (user or default) is used to free the - png_struct after an error in png_create_read_struct_2(). - -Version 1.2.2rc1 [April 7, 2002] - -Version 1.0.13rc1 [April 7, 2002] - Save the ebx register in pnggccrd.c (Sami Farin) - Add "mem_ptr = png_ptr->mem_ptr" in png_destroy_write_struct() (Paul Gardner). - Updated makefiles to put headers in include/libpng and remove old include/*.h. - -Version 1.2.2 [April 15, 2002] - -Version 1.0.13 [April 15, 2002] - Revised description of png_set_filter() in libpng.3/libpng.txt. - Revised makefile.netbsd and added makefile.neNNbsd and makefile.freebsd - -Version 1.0.13patch01 [April 17, 2002] - -Version 1.2.2patch01 [April 17, 2002] - Changed ${PNGMAJ}.${PNGVER} bug to ${PNGVER} in makefile.sgi and - makefile.sggcc - Fixed VER -> PNGVER typo in makefile.macosx and added install-static to - install - Added install: target to makefile.32sunu and makefile.64sunu - -Version 1.0.13patch03 [April 18, 2002] - -Version 1.2.2patch03 [April 18, 2002] - Revised 15 makefiles to link libpng.a to libpngNN.a and the include libpng - subdirectory to libpngNN subdirectory without the full pathname. - Moved generation of libpng.pc from "install" to "all" in 15 makefiles. - -Version 1.2.3rc1 [April 28, 2002] - Added install-man target to 15 makefiles (Dimitri Papadopolous-Orfanos). - Added $(DESTDIR) feature to 24 makefiles (Tim Mooney) - Fixed bug with $prefix, should be $(prefix) in makefile.hpux. - Updated cygwin-specific portion of pngconf.h and revised makefile.cygwin - Added a link from libpngNN.pc to libpng.pc in 15 makefiles. - Added links from include/libpngNN/*.h to include/*.h in 24 makefiles. - Revised makefile.darwin to make relative links without full pathname. - Added setjmp() at the end of png_create_*_struct_2() in case user forgets - to put one in their application. - Restored png_zalloc() and png_zfree() prototypes to version 1.2.1 and - removed them from module definition files. - -Version 1.2.3rc2 [May 1, 2002] - Fixed bug in reporting number of channels in pngget.c and pngset.c, - that was introduced in version 1.2.2beta5. - Exported png_zalloc(), png_zfree(), png_default_read(), png_default_write(), - png_default_flush(), and png_push_fill_buffer() and included them in - module definition files. - Added "libpng.pc" dependency to the "install-shared" target in 15 makefiles. - -Version 1.2.3rc3 [May 1, 2002] - Revised prototype for png_default_flush() - Remove old libpng.pc and libpngNN.pc before installing new ones. - -Version 1.2.3rc4 [May 2, 2002] - Typos in *.def files (png_default_read|write -> png_default_read|write_data) - In makefiles, changed rm libpng.NN.pc to rm libpngNN.pc - Added libpng-config and libpngNN-config and modified makefiles to install - them. - Changed $(MANPATH) to $(DESTDIR)$(MANPATH) in makefiles - Added "Win32 DLL VB" configuration to projects/msvc/libpng.dsp - -Version 1.2.3rc5 [May 11, 2002] - Changed "error" and "message" in prototypes to "error_message" and - "warning_message" to avoid namespace conflict. - Revised 15 makefiles to build libpng-config from libpng-config-*.in - Once more restored png_zalloc and png_zfree to regular nonexported form. - Restored png_default_read|write_data, png_default_flush, png_read_fill_buffer - to nonexported form, but with PNGAPI, and removed them from module def - files. - -Version 1.2.3rc6 [May 14, 2002] - Removed "PNGAPI" from png_zalloc() and png_zfree() in png.c - Changed "Gz" to "Gd" in projects/msvc/libpng.dsp and zlib.dsp. - Removed leftover libpng-config "sed" script from four makefiles. - Revised libpng-config creating script in 16 makefiles. - -Version 1.2.3 [May 22, 2002] - Revised libpng-config target in makefile.cygwin. - Removed description of png_set_mem_fn() from documentation. - Revised makefile.freebsd. - Minor cosmetic changes to 15 makefiles, e.g., $(DI) = $(DESTDIR)/$(INCDIR). - Revised projects/msvc/README.txt - Changed -lpng to -lpngNN in LDFLAGS in several makefiles. - -Version 1.2.4beta1 [May 24, 2002] - Added libpng.pc and libpng-config to "all:" target in 16 makefiles. - Fixed bug in 16 makefiles: $(DESTDIR)/$(LIBPATH) to $(DESTDIR)$(LIBPATH) - Added missing "\" before closing double quote in makefile.gcmmx. - Plugged various memory leaks; added png_malloc_warn() and png_set_text_2() - functions. - -Version 1.2.4beta2 [June 25, 2002] - Plugged memory leak of png_ptr->current_text (Matt Holgate). - Check for buffer overflow before reading CRC in pngpread.c (Warwick Allison) - Added -soname to the loader flags in makefile.dec, makefile.sgi, and - makefile.sggcc. - Added "test-installed" target to makefile.linux, makefile.gcmmx, - makefile.sgi, and makefile.sggcc. - -Version 1.2.4beta3 [June 28, 2002] - Plugged memory leak of row_buf in pngtest.c when there is a png_error(). - Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data. - Added "test-installed" target to makefile.32sunu, makefile.64sunu, - makefile.beos, makefile.darwin, makefile.dec, makefile.macosx, - makefile.solaris, makefile.hpux, makefile.hpgcc, and makefile.so9. - -Version 1.2.4rc1 and 1.0.14rc1 [July 2, 2002] - Added "test-installed" target to makefile.cygwin and makefile.sco. - Revised pnggccrd.c to be able to back out version 1.0.x via PNG_1_0_X macro. - -Version 1.2.4 and 1.0.14 [July 8, 2002] - Changed png_warning() to png_error() when width is too large to process. - -Version 1.2.4patch01 [July 20, 2002] - Revised makefile.cygwin to use DLL number 12 instead of 13. - -Version 1.2.5beta1 [August 6, 2002] - Added code to contrib/gregbook/readpng2.c to ignore unused chunks. - Replaced toucan.png in contrib/gregbook (it has been corrupt since 1.0.11) - Removed some stray *.o files from contrib/gregbook. - Changed png_error() to png_warning() about "Too much data" in pngpread.c - and about "Extra compressed data" in pngrutil.c. - Prevent png_ptr->pass from exceeding 7 in png_push_finish_row(). - Updated makefile.hpgcc - Updated png.c and pnggccrd.c handling of return from png_mmx_support() - -Version 1.2.5beta2 [August 15, 2002] - Only issue png_warning() about "Too much data" in pngpread.c when avail_in - is nonzero. - Updated makefiles to install a separate libpng.so.3 with its own rpath. - -Version 1.2.5rc1 and 1.0.15rc1 [August 24, 2002] - Revised makefiles to not remove previous minor versions of shared libraries. - -Version 1.2.5rc2 and 1.0.15rc2 [September 16, 2002] - Revised 13 makefiles to remove "-lz" and "-L$(ZLIBLIB)", etc., from shared - library loader directive. - Added missing "$OBJSDLL" line to makefile.gcmmx. - Added missing "; fi" to makefile.32sunu. - -Version 1.2.5rc3 and 1.0.15rc3 [September 18, 2002] - Revised libpng-config script. - -Version 1.2.5 and 1.0.15 [October 3, 2002] - Revised makefile.macosx, makefile.darwin, makefile.hpgcc, and makefile.hpux, - and makefile.aix. - Relocated two misplaced PNGAPI lines in pngtest.c - -Version 1.2.6beta1 [October 22, 2002] - Commented out warning about uninitialized mmx_support in pnggccrd.c. - Changed "IBMCPP__" flag to "__IBMCPP__" in pngconf.h. - Relocated two more misplaced PNGAPI lines in pngtest.c - Fixed memory overrun bug in png_do_read_filler() with 16-bit datastreams, - introduced in version 1.0.2. - Revised makefile.macosx, makefile.dec, makefile.aix, and makefile.32sunu. - -Version 1.2.6beta2 [November 1, 2002] - Added libpng-config "--ldopts" output. - Added "AR=ar" and "ARFLAGS=rc" and changed "ar rc" to "$(AR) $(ARFLAGS)" - in makefiles. - -Version 1.2.6beta3 [July 18, 2004] - Reverted makefile changes from version 1.2.6beta2 and some of the changes - from version 1.2.6beta1; these will be postponed until version 1.2.7. - Version 1.2.6 is going to be a simple bugfix release. - Changed the one instance of "ln -sf" to "ln -f -s" in each Sun makefile. - Fixed potential overrun in pngerror.c by using strncpy instead of memcpy. - Added "#!/bin/sh" at the top of configure, for recognition of the - 'x' flag under Cygwin (Cosmin). - Optimized vacuous tests that silence compiler warnings, in png.c (Cosmin). - Added support for PNG_USER_CONFIG, in pngconf.h (Cosmin). - Fixed the special memory handler for Borland C under DOS, in pngmem.c - (Cosmin). - Removed some spurious assignments in pngrutil.c (Cosmin). - Replaced 65536 with 65536L, and 0xffff with 0xffffL, to silence warnings - on 16-bit platforms (Cosmin). - Enclosed shift op expressions in parentheses, to silence warnings (Cosmin). - Used proper type png_fixed_point, to avoid problems on 16-bit platforms, - in png_handle_sRGB() (Cosmin). - Added compression_type to png_struct, and optimized the window size - inside the deflate stream (Cosmin). - Fixed definition of isnonalpha(), in pngerror.c and pngrutil.c (Cosmin). - Fixed handling of unknown chunks that come after IDAT (Cosmin). - Allowed png_error() and png_warning() to work even if png_ptr == NULL - (Cosmin). - Replaced row_info->rowbytes with row_bytes in png_write_find_filter() - (Cosmin). - Fixed definition of PNG_LIBPNG_VER_DLLNUM (Simon-Pierre). - Used PNG_LIBPNG_VER and PNG_LIBPNG_VER_STRING instead of the hardcoded - values in png.c (Simon-Pierre, Cosmin). - Initialized png_libpng_ver[] with PNG_LIBPNG_VER_STRING (Simon-Pierre). - Replaced PNG_LIBPNG_VER_MAJOR with PNG_LIBPNG_VER_DLLNUM in png.rc - (Simon-Pierre). - Moved the definition of PNG_HEADER_VERSION_STRING near the definitions - of the other PNG_LIBPNG_VER_... symbols in png.h (Cosmin). - Relocated #ifndef PNGAPI guards in pngconf.h (Simon-Pierre, Cosmin). - Updated scripts/makefile.vc(a)win32 (Cosmin). - Updated the MSVC project (Simon-Pierre, Cosmin). - Updated the Borland C++ Builder project (Cosmin). - Avoided access to asm_flags in pngvcrd.c, if PNG_1_0_X is defined (Cosmin). - Commented out warning about uninitialized mmx_support in pngvcrd.c (Cosmin). - Removed scripts/makefile.bd32 and scripts/pngdef.pas (Cosmin). - Added extra guard around inclusion of Turbo C memory headers, in pngconf.h - (Cosmin). - Renamed projects/msvc/ to projects/visualc6/, and projects/borland/ to - projects/cbuilder5/ (Cosmin). - Moved projects/visualc6/png32ms.def to scripts/pngw32.def, - and projects/visualc6/png.rc to scripts/pngw32.rc (Cosmin). - Added projects/visualc6/pngtest.dsp; removed contrib/msvctest/ (Cosmin). - Changed line endings to DOS style in cbuilder5 and visualc6 files, even - in the tar.* distributions (Cosmin). - Updated contrib/visupng/VisualPng.dsp (Cosmin). - Updated contrib/visupng/cexcept.h to version 2.0.0 (Cosmin). - Added a separate distribution with "configure" and supporting files (Junichi). - -Version 1.2.6beta4 [July 28, 2004] - Added user ability to change png_size_t via a PNG_SIZE_T macro. - Added png_sizeof() and png_convert_size() functions. - Added PNG_SIZE_MAX (maximum value of a png_size_t variable. - Added check in png_malloc_default() for (size_t)size != (png_uint_32)size - which would indicate an overflow. - Changed sPLT failure action from png_error to png_warning and abandon chunk. - Changed sCAL and iCCP failures from png_error to png_warning and abandon. - Added png_get_uint_31(png_ptr, buf) function. - Added PNG_UINT_32_MAX macro. - Renamed PNG_MAX_UINT to PNG_UINT_31_MAX. - Made png_zalloc() issue a png_warning and return NULL on potential - overflow. - Turn on PNG_NO_ZALLOC_ZERO by default in version 1.2.x - Revised "clobber list" in pnggccrd.c so it will compile under gcc-3.4. - Revised Borland portion of png_malloc() to return NULL or issue - png_error() according to setting of PNG_FLAG_MALLOC_NULL_MEM_OK. - Added PNG_NO_SEQUENTIAL_READ_SUPPORTED macro to conditionally remove - sequential read support. - Added some "#if PNG_WRITE_SUPPORTED" blocks. - Added #ifdef to remove some redundancy in png_malloc_default(). - Use png_malloc instead of png_zalloc to allocate the pallete. - -Version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004] - Fixed buffer overflow vulnerability (CVE-2004-0597) in png_handle_tRNS(). - Fixed NULL dereference vulnerability (CVE-2004-0598) in png_handle_iCCP(). - Fixed integer overflow vulnerability (CVE-2004-0599) in png_read_png(). - Fixed some harmless bugs in png_handle_sBIT, etc, that would cause - duplicate chunk types to go undetected. - Fixed some timestamps in the -config version - Rearranged order of processing of color types in png_handle_tRNS(). - Added ROWBYTES macro to calculate rowbytes without integer overflow. - Updated makefile.darwin and removed makefile.macosx from scripts directory. - Imposed default one million column, one-million row limits on the image - dimensions, and added png_set_user_limits() function to override them. - Revised use of PNG_SET_USER_LIMITS_SUPPORTED macro. - Fixed wrong cast of returns from png_get_user_width|height_max(). - Changed some "keep the compiler happy" from empty statements to returns, - Revised libpng.txt to remove 1.2.x stuff from the 1.0.x distribution - -Version 1.0.16rc2 and 1.2.6rc2 [August 7, 2004] - Revised makefile.darwin and makefile.solaris. Removed makefile.macosx. - Revised pngtest's png_debug_malloc() to use png_malloc() instead of - png_malloc_default() which is not supposed to be exported. - Fixed off-by-one error in one of the conversions to PNG_ROWBYTES() in - pngpread.c. Bug was introduced in 1.2.6rc1. - Fixed bug in RGB to RGBX transformation introduced in 1.2.6rc1. - Fixed old bug in RGB to Gray transformation. - Fixed problem with 64-bit compilers by casting arguments to abs() - to png_int_32. - Changed "ln -sf" to "ln -f -s" in three makefiles (solaris, sco, so9). - Changed "HANDLE_CHUNK_*" to "PNG_HANDLE_CHUNK_*" (Cosmin) - Added "-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)" to 15 *NIX makefiles. - Added code to update the row_info->colortype in png_do_read_filler() (MSB). - -Version 1.0.16rc3 and 1.2.6rc3 [August 9, 2004] - Eliminated use of "abs()" in testing cHRM and gAMA values, to avoid - trouble with some 64-bit compilers. Created PNG_OUT_OF_RANGE() macro. - Revised documentation of png_set_keep_unknown_chunks(). - Check handle_as_unknown status in pngpread.c, as in pngread.c previously. - Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_INTERNAL section of png.h - Added "rim" definitions for CONST4 and CONST6 in pnggccrd.c - -Version 1.0.16rc4 and 1.2.6rc4 [August 10, 2004] - Fixed mistake in pngtest.c introduced in 1.2.6rc2 (declaration of - "pinfo" was out of place). - -Version 1.0.16rc5 and 1.2.6rc5 [August 10, 2004] - Moved "PNG_HANDLE_CHUNK_*" macros out of PNG_ASSEMBLER_CODE_SUPPORTED - section of png.h where they were inadvertently placed in version rc3. - -Version 1.2.6 and 1.0.16 [August 15, 2004] - Revised pngtest so memory allocation testing is only done when PNG_DEBUG==1. - -Version 1.2.7beta1 [August 26, 2004] - Removed unused pngasmrd.h file. - Removed references to uu.net for archived files. Added references to - PNG Spec (second edition) and the PNG ISO/IEC Standard. - Added "test-dd" target in 15 makefiles, to run pngtest in DESTDIR. - Fixed bug with "optimized window size" in the IDAT datastream, that - causes libpng to write PNG files with incorrect zlib header bytes. - -Version 1.2.7beta2 [August 28, 2004] - Fixed bug with sCAL chunk and big-endian machines (David Munro). - Undid new code added in 1.2.6rc2 to update the color_type in - png_set_filler(). - Added png_set_add_alpha() that updates color type. - -Version 1.0.17rc1 and 1.2.7rc1 [September 4, 2004] - Revised png_set_strip_filler() to not remove alpha if color_type has alpha. - -Version 1.2.7 and 1.0.17 [September 12, 2004] - Added makefile.hp64 - Changed projects/msvc/png32ms.def to scripts/png32ms.def in makefile.cygwin - -Version 1.2.8beta1 [November 1, 2004] - Fixed bug in png_text_compress() that would fail to complete a large block. - Fixed bug, introduced in libpng-1.2.7, that overruns a buffer during - strip alpha operation in png_do_strip_filler(). - Added PNG_1_2_X definition in pngconf.h - Use #ifdef to comment out png_info_init in png.c and png_read_init in - pngread.c (as of 1.3.0) - -Version 1.2.8beta2 [November 2, 2004] - Reduce color_type to a nonalpha type after strip alpha operation in - png_do_strip_filler(). - -Version 1.2.8beta3 [November 3, 2004] - Revised definitions of PNG_MAX_UINT_32, PNG_MAX_SIZE, and PNG_MAXSUM - -Version 1.2.8beta4 [November 12, 2004] - Fixed (again) definition of PNG_LIBPNG_VER_DLLNUM in png.h (Cosmin). - Added PNG_LIBPNG_BUILD_PRIVATE in png.h (Cosmin). - Set png_ptr->zstream.data_type to Z_BINARY, to avoid unnecessary detection - of data type in deflate (Cosmin). - Deprecated but continue to support SPECIALBUILD and PRIVATEBUILD in favor of - PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING. - -Version 1.2.8beta5 [November 20, 2004] - Use png_ptr->flags instead of png_ptr->transformations to pass - PNG_STRIP_ALPHA info to png_do_strip_filler(), to preserve ABI - compatibility. - Revised handling of SPECIALBUILD, PRIVATEBUILD, - PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING. - -Version 1.2.8rc1 [November 24, 2004] - Moved handling of BUILD macros from pngconf.h to png.h - Added definition of PNG_LIBPNG_BASE_TYPE in png.h, inadvertently - omitted from beta5. - Revised scripts/pngw32.rc - Despammed mailing addresses by masking "@" with "at". - Inadvertently installed a supposedly faster test version of pngrutil.c - -Version 1.2.8rc2 [November 26, 2004] - Added two missing "\" in png.h - Change tests in pngread.c and pngpread.c to - if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA)) - png_do_read_transformations(png_ptr); - -Version 1.2.8rc3 [November 28, 2004] - Reverted pngrutil.c to version libpng-1.2.8beta5. - Added scripts/makefile.elf with supporting code in pngconf.h for symbol - versioning (John Bowler). - -Version 1.2.8rc4 [November 29, 2004] - Added projects/visualc7 (Simon-pierre). - -Version 1.2.8rc5 [November 29, 2004] - Fixed new typo in scripts/pngw32.rc - -Version 1.2.8 [December 3, 2004] - Removed projects/visualc7, added projects/visualc71. - -Version 1.2.9beta1 [February 21, 2006] - Initialized some structure members in pngwutil.c to avoid gcc-4.0.0 complaints - Revised man page and libpng.txt to make it clear that one should not call - png_read_end or png_write_end after png_read_png or png_write_png. - Updated references to png-mng-implement mailing list. - Fixed an incorrect typecast in pngrutil.c - Added PNG_NO_READ_SUPPORTED conditional for making a write-only library. - Added PNG_NO_WRITE_INTERLACING_SUPPORTED conditional. - Optimized alpha-inversion loops in pngwtran.c - Moved test for nonzero gamma outside of png_build_gamma_table() in pngrtran.c - Make sure num_trans is <= 256 before copying data in png_set_tRNS(). - Make sure num_palette is <= 256 before copying data in png_set_PLTE(). - Interchanged order of write_swap_alpha and write_invert_alpha transforms. - Added parentheses in the definition of PNG_LIBPNG_BUILD_TYPE (Cosmin). - Optimized zlib window flag (CINFO) in contrib/pngsuite/*.png (Cosmin). - Updated scripts/makefile.bc32 for Borland C++ 5.6 (Cosmin). - Exported png_get_uint_32, png_save_uint_32, png_get_uint_16, png_save_uint_16, - png_get_int_32, png_save_int_32, png_get_uint_31 (Cosmin). - Added type cast (png_byte) in png_write_sCAL() (Cosmin). - Fixed scripts/makefile.cygwin (Christian Biesinger, Cosmin). - Default iTXt support was inadvertently enabled. - -Version 1.2.9beta2 [February 21, 2006] - Check for png_rgb_to_gray and png_gray_to_rgb read transformations before - checking for png_read_dither in pngrtran.c - Revised checking of chromaticity limits to accommodate extended RGB - colorspace (John Denker). - Changed line endings in some of the project files to CRLF, even in the - "Unix" tar distributions (Cosmin). - Made png_get_int_32 and png_save_int_32 always available (Cosmin). - Updated scripts/pngos2.def, scripts/pngw32.def and projects/wince/png32ce.def - with the newly exported functions. - Eliminated distributions without the "configure" script. - Updated INSTALL instructions. - -Version 1.2.9beta3 [February 24, 2006] - Fixed CRCRLF line endings in contrib/visupng/VisualPng.dsp - Made libpng.pc respect EXEC_PREFIX (D. P. Kreil, J. Bowler) - Removed reference to pngasmrd.h from Makefile.am - Renamed CHANGES to ChangeLog. - Renamed LICENSE to COPYING. - Renamed ANNOUNCE to NEWS. - Created AUTHORS file. - -Version 1.2.9beta4 [March 3, 2006] - Changed definition of PKGCONFIG from $prefix/lib to $libdir in configure.ac - Reverted to filenames LICENSE and ANNOUNCE; removed AUTHORS and COPYING. - Removed newline from the end of some error and warning messages. - Removed test for sqrt() from configure.ac and configure. - Made swap tables in pngtrans.c PNG_CONST (Carlo Bramix). - Disabled default iTXt support that was inadvertently enabled in - libpng-1.2.9beta1. - Added "OS2" to list of systems that don't need underscores, in pnggccrd.c - Removed libpng version and date from *.c files. - -Version 1.2.9beta5 [March 4, 2006] - Removed trailing blanks from source files. - Put version and date of latest change in each source file, and changed - copyright year accordingly. - More cleanup of configure.ac, Makefile.am, and associated scripts. - Restored scripts/makefile.elf which was inadvertently deleted. - -Version 1.2.9beta6 [March 6, 2006] - Fixed typo (RELEASE) in configuration files. - -Version 1.2.9beta7 [March 7, 2006] - Removed libpng.vers and libpng.sym from libpng12_la_SOURCES in Makefile.am - Fixed inconsistent #ifdef's around png_sig_bytes() and png_set_sCAL_s() - in png.h. - Updated makefile.elf as suggested by debian. - Made cosmetic changes to some makefiles, adding LN_SF and other macros. - Made some makefiles accept "exec_prefix". - -Version 1.2.9beta8 [March 9, 2006] - Fixed some "#if defined (..." which should be "#if defined(..." - Bug introduced in libpng-1.2.8. - Fixed inconsistency in definition of png_default_read_data() - Restored blank that was lost from makefile.sggcc "clean" target in beta7. - Revised calculation of "current" and "major" for irix in ltmain.sh - Changed "mkdir" to "MKDIR_P" in some makefiles. - Separated PNG_EXPAND and PNG_EXPAND_tRNS. - Added png_set_expand_gray_1_2_4_to_8() and deprecated - png_set_gray_1_2_4_to_8() which also expands tRNS to alpha. - -Version 1.2.9beta9 [March 10, 2006] - Include "config.h" in pngconf.h when available. - Added some checks for NULL png_ptr or NULL info_ptr (timeless) - -Version 1.2.9beta10 [March 20, 2006] - Removed extra CR from contrib/visualpng/VisualPng.dsw (Cosmin) - Made pnggccrd.c PIC-compliant (Christian Aichinger). - Added makefile.mingw (Wolfgang Glas). - Revised pngconf.h MMX checking. - -Version 1.2.9beta11 [March 22, 2006] - Fixed out-of-order declaration in pngwrite.c that was introduced in beta9 - Simplified some makefiles by using LIBSO, LIBSOMAJ, and LIBSOVER macros. - -Version 1.2.9rc1 [March 31, 2006] - Defined PNG_USER_PRIVATEBUILD when including "pngusr.h" (Cosmin). - Removed nonsensical assertion check from pngtest.c (Cosmin). - -Version 1.2.9 [April 14, 2006] - Revised makefile.beos and added "none" selector in ltmain.sh - -Version 1.2.10beta1 [April 15, 2006] - Renamed "config.h" to "png_conf.h" and revised Makefile.am to add - -DPNG_BUILDING_LIBPNG to compile directive, and modified pngconf.h - to include png_conf.h only when PNG_BUILDING_LIBPNG is defined. - -Version 1.2.10beta2 [April 15, 2006] - Manually updated Makefile.in and configure. Changed png_conf.h.in - back to config.h. - -Version 1.2.10beta3 [April 15, 2006] - Change png_conf.h back to config.h in pngconf.h. - -Version 1.2.10beta4 [April 16, 2006] - Change PNG_BUILDING_LIBPNG to PNG_CONFIGURE_LIBPNG in config/Makefile*. - -Version 1.2.10beta5 [April 16, 2006] - Added a configure check for compiling assembler code in pnggccrd.c - -Version 1.2.10beta6 [April 17, 2006] - Revised the configure check for pnggccrd.c - Moved -DPNG_CONFIGURE_LIBPNG into @LIBPNG_DEFINES@ - Added @LIBPNG_DEFINES@ to arguments when building libpng.sym - -Version 1.2.10beta7 [April 18, 2006] - Change "exec_prefix=$prefix" to "exec_prefix=$(prefix)" in makefiles. - -Version 1.2.10rc1 [April 19, 2006] - Ensure pngconf.h doesn't define both PNG_USE_PNGGCCRD and PNG_USE_PNGVCRD - Fixed "LN_FS" typo in makefile.sco and makefile.solaris. - -Version 1.2.10rc2 [April 20, 2006] - Added a backslash between -DPNG_CONFIGURE_LIBPNG and -DPNG_NO_ASSEMBLER_CODE - in configure.ac and configure - Made the configure warning about versioned symbols less arrogant. - -Version 1.2.10rc3 [April 21, 2006] - Added a note in libpng.txt that png_set_sig_bytes(8) can be used when - writing an embedded PNG without the 8-byte signature. - Revised makefiles and configure to avoid making links to libpng.so.* - -Version 1.2.10 [April 23, 2006] - Reverted configure to "rc2" state. - -Version 1.2.11beta1 [May 31, 2006] - scripts/libpng.pc.in contained "configure" style version info and would - not work with makefiles. - The shared-library makefiles were linking to libpng.so.0 instead of - libpng.so.3 compatibility as the library. - -Version 1.2.11beta2 [June 2, 2006] - Increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid - buffer overflow. - Fixed bug in example.c (png_set_palette_rgb -> png_set_palette_to_rgb) - -Version 1.2.11beta3 [June 5, 2006] - Prepended "#! /bin/sh" to ltmail.sh and contrib/pngminus/*.sh (Cosmin). - Removed the accidental leftover Makefile.in~ (Cosmin). - Avoided potential buffer overflow and optimized buffer in - png_write_sCAL(), png_write_sCAL_s() (Cosmin). - Removed the include directories and libraries from CFLAGS and LDFLAGS - in scripts/makefile.gcc (Nelson A. de Oliveira, Cosmin). - -Version 1.2.11beta4 [June 6, 2006] - Allow zero-length IDAT chunks after the entire zlib datastream, but not - after another intervening chunk type. - -Version 1.0.19rc1, 1.2.11rc1 [June 13, 2006] - Deleted extraneous square brackets from [config.h] in configure.ac - -Version 1.0.19rc2, 1.2.11rc2 [June 14, 2006] - Added prototypes for PNG_INCH_CONVERSIONS functions to png.h - Revised INSTALL and autogen.sh - Fixed typo in several makefiles (-W1 should be -Wl) - Added typedef for png_int_32 and png_uint_32 on 64-bit systems. - -Version 1.0.19rc3, 1.2.11rc3 [June 15, 2006] - Removed the new typedefs for 64-bit systems (delay until version 1.4.0) - Added one zero element to png_gamma_shift[] array in pngrtran.c to avoid - reading out of bounds. - -Version 1.0.19rc4, 1.2.11rc4 [June 15, 2006] - Really removed the new typedefs for 64-bit systems. - -Version 1.0.19rc5, 1.2.11rc5 [June 22, 2006] - Removed png_sig_bytes entry from scripts/pngw32.def - -Version 1.0.19, 1.2.11 [June 26, 2006] - None. - -Version 1.0.20, 1.2.12 [June 27, 2006] - Really increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid - buffer overflow. - -Version 1.2.13beta1 [October 2, 2006] - Removed AC_FUNC_MALLOC from configure.ac - Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h - Change "logical" to "bitwise" throughout documentation. - Detect and fix attempt to write wrong iCCP profile length (CVE-2006-7244) - -Version 1.0.21, 1.2.13 [November 14, 2006] - Fix potential buffer overflow in sPLT chunk handler. - Fix Makefile.am to not try to link to noexistent files. - Check all exported functions for NULL png_ptr. - -Version 1.2.14beta1 [November 17, 2006] - Relocated three misplaced tests for NULL png_ptr. - Built Makefile.in with automake-1.9.6 instead of 1.9.2. - Build configure with autoconf-2.60 instead of 2.59 - -Version 1.2.14beta2 [November 17, 2006] - Added some typecasts in png_zalloc(). - -Version 1.2.14rc1 [November 20, 2006] - Changed "strtod" to "png_strtod" in pngrutil.c - -Version 1.0.22, 1.2.14 [November 27, 2006] - Added missing "$(srcdir)" in Makefile.am and Makefile.in - -Version 1.2.15beta1 [December 3, 2006] - Generated configure with autoconf-2.61 instead of 2.60 - Revised configure.ac to update libpng.pc and libpng-config. - -Version 1.2.15beta2 [December 3, 2006] - Always export MMX asm functions, just stubs if not building pnggccrd.c - -Version 1.2.15beta3 [December 4, 2006] - Add "png_bytep" typecast to profile while calculating length in pngwutil.c - -Version 1.2.15beta4 [December 7, 2006] - Added scripts/CMakeLists.txt - Changed PNG_NO_ASSEMBLER_CODE to PNG_NO_MMX_CODE in scripts, like 1.4.0beta - -Version 1.2.15beta5 [December 7, 2006] - Changed some instances of PNG_ASSEMBLER_* to PNG_MMX_* in pnggccrd.c - Revised scripts/CMakeLists.txt - -Version 1.2.15beta6 [December 13, 2006] - Revised scripts/CMakeLists.txt and configure.ac - -Version 1.2.15rc1 [December 18, 2006] - Revised scripts/CMakeLists.txt - -Version 1.2.15rc2 [December 21, 2006] - Added conditional #undef jmpbuf in pngtest.c to undo #define in AIX headers. - Added scripts/makefile.nommx - -Version 1.2.15rc3 [December 25, 2006] - Fixed shared library numbering error that was introduced in 1.2.15beta6. - -Version 1.2.15rc4 [December 27, 2006] - Fixed handling of rgb_to_gray when png_ptr->color.gray isn't set. - -Version 1.2.15rc5 [December 31, 2006] - Revised handling of rgb_to_gray. - -Version 1.2.15 [January 5, 2007] - Added some (unsigned long) typecasts in pngtest.c to avoid printing errors. - -Version 1.2.16beta1 [January 6, 2007] - Fix bugs in makefile.nommx - -Version 1.2.16beta2 [January 16, 2007] - Revised scripts/CMakeLists.txt - -Version 1.2.16 [January 31, 2007] - No changes. - -Version 1.2.17beta1 [March 6, 2007] - Revised scripts/CMakeLists.txt to install both shared and static libraries. - Deleted a redundant line from pngset.c. - -Version 1.2.17beta2 [April 26, 2007] - Relocated misplaced test for png_ptr == NULL in pngpread.c - Change "==" to "&" for testing PNG_RGB_TO_GRAY_ERR & PNG_RGB_TO_GRAY_WARN - flags. - Changed remaining instances of PNG_ASSEMBLER_* to PNG_MMX_* - Added pngerror() when write_IHDR fails in deflateInit2(). - Added "const" to some array declarations. - Mention examples of libpng usage in the libpng*.txt and libpng.3 documents. - -Version 1.2.17rc1 [May 4, 2007] - No changes. - -Version 1.2.17rc2 [May 8, 2007] - Moved several PNG_HAVE_* macros out of PNG_INTERNAL because applications - calling set_unknown_chunk_location() need them. - Changed transformation flag from PNG_EXPAND_tRNS to PNG_EXPAND in - png_set_expand_gray_1_2_4_to_8(). - Added png_ptr->unknown_chunk to hold working unknown chunk data, so it - can be free'ed in case of error. Revised unknown chunk handling in - pngrutil.c and pngpread.c to use this structure. - -Version 1.2.17rc3 [May 8, 2007] - Revised symbol-handling in configure script. - -Version 1.2.17rc4 [May 10, 2007] - Revised unknown chunk handling to avoid storing unknown critical chunks. - -Version 1.0.25 [May 15, 2007] -Version 1.2.17 [May 15, 2007] - Added "png_ptr->num_trans=0" before error return in png_handle_tRNS, - to eliminate a vulnerability (CVE-2007-2445, CERT VU#684664) - -Version 1.0.26 [May 15, 2007] -Version 1.2.18 [May 15, 2007] - Reverted the libpng-1.2.17rc3 change to symbol-handling in configure script - -Version 1.2.19beta1 [May 18, 2007] - Changed "const static" to "static PNG_CONST" everywhere, mostly undoing - change of libpng-1.2.17beta2. Changed other "const" to "PNG_CONST" - Changed some handling of unused parameters, to avoid compiler warnings. - "if (unused == NULL) return;" becomes "unused = unused". - -Version 1.2.19beta2 [May 18, 2007] - Only use the valid bits of tRNS value in png_do_expand() (Brian Cartier) - -Version 1.2.19beta3 [May 19, 2007] - Add some "png_byte" typecasts in png_check_keyword() and write new_key - instead of key in zTXt chunk (Kevin Ryde). - -Version 1.2.19beta4 [May 21, 2007] - Add png_snprintf() function and use it in place of sprint() for improved - defense against buffer overflows. - -Version 1.2.19beta5 [May 21, 2007] - Fixed png_handle_tRNS() to only use the valid bits of tRNS value. - Changed handling of more unused parameters, to avoid compiler warnings. - Removed some PNG_CONST in pngwutil.c to avoid compiler warnings. - -Version 1.2.19beta6 [May 22, 2007] - Added some #ifdef PNG_MMX_CODE_SUPPORTED where needed in pngvcrd.c - Added a special "_MSC_VER" case that defines png_snprintf to _snprintf - -Version 1.2.19beta7 [May 22, 2007] - Squelched png_squelch_warnings() in pnggccrd.c and added - an #ifdef PNG_MMX_CODE_SUPPORTED block around the declarations that caused - the warnings that png_squelch_warnings was squelching. - -Version 1.2.19beta8 [May 22, 2007] - Removed __MMX__ from test in pngconf.h. - -Version 1.2.19beta9 [May 23, 2007] - Made png_squelch_warnings() available via PNG_SQUELCH_WARNINGS macro. - Revised png_squelch_warnings() so it might work. - Updated makefile.sgcc and makefile.solaris; added makefile.solaris-x86. - -Version 1.2.19beta10 [May 24, 2007] - Resquelched png_squelch_warnings(), use "__attribute__((used))" instead. - -Version 1.4.0beta1 [April 20, 2006] - Enabled iTXt support (changes png_struct, thus requires so-number change). - Cleaned up PNG_ASSEMBLER_CODE_SUPPORTED vs PNG_MMX_CODE_SUPPORTED - Eliminated PNG_1_0_X and PNG_1_2_X macros. - Removed deprecated functions png_read_init, png_write_init, png_info_init, - png_permit_empty_plte, png_set_gray_1_2_4_to_8, png_check_sig, and - removed the deprecated macro PNG_MAX_UINT. - Moved "PNG_INTERNAL" parts of png.h and pngconf.h into pngintrn.h - Removed many WIN32_WCE #ifdefs (Cosmin). - Reduced dependency on C-runtime library when on Windows (Simon-Pierre) - Replaced sprintf() with png_sprintf() (Simon-Pierre) - -Version 1.4.0beta2 [April 20, 2006] - Revised makefiles and configure to avoid making links to libpng.so.* - Moved some leftover MMX-related defines from pngconf.h to pngintrn.h - Updated scripts/pngos2.def, pngw32.def, and projects/wince/png32ce.def - -Version 1.4.0beta3 [May 10, 2006] - Updated scripts/pngw32.def to comment out MMX functions. - Added PNG_NO_GET_INT_32 and PNG_NO_SAVE_INT_32 macros. - Scripts/libpng.pc.in contained "configure" style version info and would - not work with makefiles. - Revised pngconf.h and added pngconf.h.in, so makefiles and configure can - pass defines to libpng and applications. - -Version 1.4.0beta4 [May 11, 2006] - Revised configure.ac, Makefile.am, and many of the makefiles to write - their defines in pngconf.h. - -Version 1.4.0beta5 [May 15, 2006] - Added a missing semicolon in Makefile.am and Makefile.in - Deleted extraneous square brackets from configure.ac - -Version 1.4.0beta6 [June 2, 2006] - Increased sprintf buffer from 50 to 52 chars in pngrutil.c to avoid - buffer overflow. - Changed sonum from 0 to 1. - Removed unused prototype for png_check_sig() from png.h - -Version 1.4.0beta7 [June 16, 2006] - Exported png_write_sig (Cosmin). - Optimized buffer in png_handle_cHRM() (Cosmin). - Set pHYs = 2835 x 2835 pixels per meter, and added - sCAL = 0.352778e-3 x 0.352778e-3 meters, in pngtest.png (Cosmin). - Added png_set_benign_errors(), png_benign_error(), png_chunk_benign_error(). - Added typedef for png_int_32 and png_uint_32 on 64-bit systems. - Added "(unsigned long)" typecast on png_uint_32 variables in printf lists. - -Version 1.4.0beta8 [June 22, 2006] - Added demonstration of user chunk support in pngtest.c, to support the - public sTER chunk and a private vpAg chunk. - -Version 1.4.0beta9 [July 3, 2006] - Removed ordinals from scripts/pngw32.def and removed png_info_int and - png_set_gray_1_2_4_to_8 entries. - Inline call of png_get_uint_32() in png_get_uint_31(). - Use png_get_uint_31() to get vpAg width and height in pngtest.c - Removed WINCE and Netware projects. - Removed standalone Y2KINFO file. - -Version 1.4.0beta10 [July 12, 2006] - Eliminated automatic copy of pngconf.h to pngconf.h.in from configure and - some makefiles, because it was not working reliably. Instead, distribute - pngconf.h.in along with pngconf.h and cause configure and some of the - makefiles to update pngconf.h from pngconf.h.in. - Added pngconf.h to DEPENDENCIES in Makefile.am - -Version 1.4.0beta11 [August 19, 2006] - Removed AC_FUNC_MALLOC from configure.ac. - Added a warning when writing iCCP profile with mismatched profile length. - Patched pnggccrd.c to assemble on x86_64 platforms. - Moved chunk header reading into a separate function png_read_chunk_header() - in pngrutil.c. The chunk header (len+sig) is now serialized in a single - operation (Cosmin). - Implemented support for I/O states. Added png_ptr member io_state, and - functions png_get_io_chunk_name() and png_get_io_state() in pngget.c - (Cosmin). - Added png_get_io_chunk_name and png_get_io_state to scripts/*.def (Cosmin). - Renamed scripts/pngw32.* to scripts/pngwin.* (Cosmin). - Removed the include directories and libraries from CFLAGS and LDFLAGS - in scripts/makefile.gcc (Cosmin). - Used png_save_uint_32() to set vpAg width and height in pngtest.c (Cosmin). - Cast to proper type when getting/setting vpAg units in pngtest.c (Cosmin). - Added pngintrn.h to the Visual C++ projects (Cosmin). - Removed scripts/list (Cosmin). - Updated copyright year in scripts/pngwin.def (Cosmin). - Removed PNG_TYPECAST_NULL and used standard NULL consistently (Cosmin). - Disallowed the user to redefine png_size_t, and enforced a consistent use - of png_size_t across libpng (Cosmin). - Changed the type of png_ptr->rowbytes, PNG_ROWBYTES() and friends - to png_size_t (Cosmin). - Removed png_convert_size() and replaced png_sizeof with sizeof (Cosmin). - Removed some unnecessary type casts (Cosmin). - Changed prototype of png_get_compression_buffer_size() and - png_set_compression_buffer_size() to work with png_size_t instead of - png_uint_32 (Cosmin). - Removed png_memcpy_check() and png_memset_check() (Cosmin). - Fixed a typo (png_byte --> png_bytep) in libpng.3 and libpng.txt (Cosmin). - Clarified that png_zalloc() does not clear the allocated memory, - and png_zalloc() and png_zfree() cannot be PNGAPI (Cosmin). - Renamed png_mem_size_t to png_alloc_size_t, fixed its definition in - pngconf.h, and used it in all memory allocation functions (Cosmin). - Renamed pngintrn.h to pngpriv.h, added a comment at the top of the file - mentioning that the symbols declared in that file are private, and - updated the scripts and the Visual C++ projects accordingly (Cosmin). - Removed circular references between pngconf.h and pngconf.h.in in - scripts/makefile.vc*win32 (Cosmin). - Removing trailing '.' from the warning and error messages (Cosmin). - Added pngdefs.h that is built by makefile or configure, instead of - pngconf.h.in (Glenn). - Detect and fix attempt to write wrong iCCP profile length. - -Version 1.4.0beta12 [October 19, 2006] - Changed "logical" to "bitwise" in the documentation. - Work around Intel-Mac compiler bug by setting PNG_NO_MMX_CODE in pngconf.h - Add a typecast to stifle compiler warning in pngrutil.c - -Version 1.4.0beta13 [November 10, 2006] - Fix potential buffer overflow in sPLT chunk handler. - Fix Makefile.am to not try to link to noexistent files. - -Version 1.4.0beta14 [November 15, 2006] - Check all exported functions for NULL png_ptr. - -Version 1.4.0beta15 [November 17, 2006] - Relocated two misplaced tests for NULL png_ptr. - Built Makefile.in with automake-1.9.6 instead of 1.9.2. - Build configure with autoconf-2.60 instead of 2.59 - Add "install: all" in Makefile.am so "configure; make install" will work. - -Version 1.4.0beta16 [November 17, 2006] - Added a typecast in png_zalloc(). - -Version 1.4.0beta17 [December 4, 2006] - Changed "new_key[79] = '\0';" to "(*new_key)[79] = '\0';" in pngwutil.c - Add "png_bytep" typecast to profile while calculating length in pngwutil.c - -Version 1.4.0beta18 [December 7, 2006] - Added scripts/CMakeLists.txt - -Version 1.4.0beta19 [May 16, 2007] - Revised scripts/CMakeLists.txt - Rebuilt configure and Makefile.in with newer tools. - Added conditional #undef jmpbuf in pngtest.c to undo #define in AIX headers. - Added scripts/makefile.nommx - -Version 1.4.0beta20 [July 9, 2008] - Moved several PNG_HAVE_* macros from pngpriv.h to png.h because applications - calling set_unknown_chunk_location() need them. - Moved several macro definitions from pngpriv.h to pngconf.h - Merge with changes to the 1.2.X branch, as of 1.2.30beta04. - Deleted all use of the MMX assembler code and Intel-licensed optimizations. - Revised makefile.mingw - -Version 1.4.0beta21 [July 21, 2008] - Moved local array "chunkdata" from pngrutil.c to the png_struct, so - it will be freed by png_read_destroy() in case of a read error (Kurt - Christensen). - -Version 1.4.0beta22 [July 21, 2008] - Change "purpose" and "buffer" to png_ptr->chunkdata to avoid memory leaking. - -Version 1.4.0beta23 [July 22, 2008] - Change "chunkdata = NULL" to "png_ptr->chunkdata = NULL" several places in - png_decompress_chunk(). - -Version 1.4.0beta24 [July 25, 2008] - Change all remaining "chunkdata" to "png_ptr->chunkdata" in - png_decompress_chunk(), and remove "chunkdata" from parameter list. - Put a call to png_check_chunk_name() in png_read_chunk_header(). - Revised png_check_chunk_name() to reject a name with a lowercase 3rd byte. - Removed two calls to png_check_chunk_name() occurring later in the process. - Define PNG_NO_ERROR_NUMBERS by default in pngconf.h - -Version 1.4.0beta25 [July 30, 2008] - Added a call to png_check_chunk_name() in pngpread.c - Reverted png_check_chunk_name() to accept a name with a lowercase 3rd byte. - Added png_push_have_buffer() function to pngpread.c - Eliminated PNG_BIG_ENDIAN_SUPPORTED and associated png_get_* macros. - Made inline expansion of png_get_*() optional with PNG_USE_READ_MACROS. - Eliminated all PNG_USELESS_TESTS and PNG_CORRECT_PALETTE_SUPPORTED code. - Synced contrib directory and configure files with libpng-1.2.30beta06. - Eliminated no-longer-used pngdefs.h (but it's still built in the makefiles) - Relocated a misplaced "#endif /* PNG_NO_WRITE_FILTER */" in pngwutil.c - -Version 1.4.0beta26 [August 4, 2008] - Removed png_push_have_buffer() function in pngpread.c. It increased the - compiled library size slightly. - Changed "-Wall" to "-W -Wall" in the CFLAGS in all makefiles (Cosmin Truta) - Declared png_ptr "volatile" in pngread.c and pngwrite.c to avoid warnings. - Updated contrib/visupng/cexcept.h to version 2.0.1 - Added PNG_LITERAL_CHARACTER macros for #, [, and ]. - -Version 1.4.0beta27 [August 5, 2008] - Revised usage of PNG_LITERAL_SHARP in pngerror.c. - Moved newline character from individual png_debug messages into the - png_debug macros. - Allow user to #define their own png_debug, png_debug1, and png_debug2. - -Version 1.4.0beta28 [August 5, 2008] - Revised usage of PNG_LITERAL_SHARP in pngerror.c. - Added PNG_STRING_NEWLINE macro - -Version 1.4.0beta29 [August 9, 2008] - Revised usage of PNG_STRING_NEWLINE to work on non-ISO compilers. - Added PNG_STRING_COPYRIGHT macro. - Added non-ISO versions of png_debug macros. - -Version 1.4.0beta30 [August 14, 2008] - Added premultiplied alpha feature (Volker Wiendl). - -Version 1.4.0beta31 [August 18, 2008] - Moved png_set_premultiply_alpha from pngtrans.c to pngrtran.c - Removed extra crc check at the end of png_handle_cHRM(). Bug introduced - in libpng-1.4.0beta20. - -Version 1.4.0beta32 [August 19, 2008] - Added PNG_WRITE_FLUSH_SUPPORTED block around new png_flush() call. - Revised PNG_NO_STDIO version of png_write_flush() - -Version 1.4.0beta33 [August 20, 2008] - Added png_get|set_chunk_cache_max() to limit the total number of sPLT, - text, and unknown chunks that can be stored. - -Version 1.4.0beta34 [September 6, 2008] - Shortened tIME_string to 29 bytes in pngtest.c - Fixed off-by-one error introduced in png_push_read_zTXt() function in - libpng-1.2.30beta04/pngpread.c (Harald van Dijk) - -Version 1.4.0beta35 [October 6, 2008] - Changed "trans_values" to "trans_color". - Changed so-number from 0 to 14. Some OS do not like 0. - Revised makefile.darwin to fix shared library numbering. - Change png_set_gray_1_2_4_to_8() to png_set_expand_gray_1_2_4_to_8() - in example.c (debian bug report) - -Version 1.4.0beta36 [October 25, 2008] - Sync with tEXt vulnerability fix in libpng-1.2.33rc02. - -Version 1.4.0beta37 [November 13, 2008] - Added png_check_cHRM in png.c and moved checking from pngget.c, pngrutil.c, - and pngwrite.c - -Version 1.4.0beta38 [November 22, 2008] - Added check for zero-area RGB cHRM triangle in png_check_cHRM() and - png_check_cHRM_fixed(). - -Version 1.4.0beta39 [November 23, 2008] - Revised png_warning() to write its message on standard output by default - when warning_fn is NULL. - -Version 1.4.0beta40 [November 24, 2008] - Eliminated png_check_cHRM(). Instead, always use png_check_cHRM_fixed(). - In png_check_cHRM_fixed(), ensure white_y is > 0, and removed redundant - check for all-zero coordinates that is detected by the triangle check. - -Version 1.4.0beta41 [November 26, 2008] - Fixed string vs pointer-to-string error in png_check_keyword(). - Rearranged test expressions in png_check_cHRM_fixed() to avoid internal - overflows. - Added PNG_NO_CHECK_cHRM conditional. - -Version 1.4.0beta42, 43 [December 1, 2008] - Merge png_debug with version 1.2.34beta04. - -Version 1.4.0beta44 [December 6, 2008] - Removed redundant check for key==NULL before calling png_check_keyword() - to ensure that new_key gets initialized and removed extra warning - (Merge with version 1.2.34beta05 -- Arvan Pritchard). - -Version 1.4.0beta45 [December 9, 2008] - In png_write_png(), respect the placement of the filler bytes in an earlier - call to png_set_filler() (Jim Barry). - -Version 1.4.0beta46 [December 10, 2008] - Undid previous change and added PNG_TRANSFORM_STRIP_FILLER_BEFORE and - PNG_TRANSFORM_STRIP_FILLER_AFTER conditionals and deprecated - PNG_TRANSFORM_STRIP_FILLER (Jim Barry). - -Version 1.4.0beta47 [December 15, 2008] - Support for dithering was disabled by default, because it has never - been well tested and doesn't work very well. The code has not - been removed, however, and can be enabled by building libpng with - PNG_READ_DITHER_SUPPORTED defined. - -Version 1.4.0beta48 [February 14, 2009] - Added new exported function png_calloc(). - Combined several instances of png_malloc(); png_memset() into png_calloc(). - Removed prototype for png_freeptr() that was added in libpng-1.4.0beta24 - but was never defined. - -Version 1.4.0beta49 [February 28, 2009] - Added png_fileno() macro to pngconf.h, used in pngwio.c - Corrected order of #ifdef's in png_debug definition in png.h - Fixed bug introduced in libpng-1.4.0beta48 with the memset arguments - for pcal_params. - Fixed order of #ifdef directives in the png_debug defines in png.h - (bug introduced in libpng-1.2.34/1.4.0beta29). - Revised comments in png_set_read_fn() and png_set_write_fn(). - -Version 1.4.0beta50 [March 18, 2009] - Use png_calloc() instead of png_malloc() to allocate big_row_buf when - reading an interlaced file, to avoid a possible UMR. - Undid revision of PNG_NO_STDIO version of png_write_flush(). Users - having trouble with fflush() can build with PNG_NO_WRITE_FLUSH defined - or supply their own flush_fn() replacement. - Revised libpng*.txt and png.h documentation about use of png_write_flush() - and png_set_write_fn(). - Removed fflush() from pngtest.c. - Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h - -Version 1.4.0beta51 [March 21, 2009] - Removed new png_fileno() macro from pngconf.h . - -Version 1.4.0beta52 [March 27, 2009] - Relocated png_do_chop() ahead of building gamma tables in pngrtran.c - This avoids building 16-bit gamma tables unnecessarily. - Removed fflush() from pngtest.c. - Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h - Added a section on differences between 1.0.x and 1.2.x to libpng.3/libpng.txt - -Version 1.4.0beta53 [April 1, 2009] - Removed some remaining MMX macros from pngpriv.h - Fixed potential memory leak of "new_name" in png_write_iCCP() (Ralph Giles) - -Version 1.4.0beta54 [April 13, 2009] - Added "ifndef PNG_SKIP_SETJMP_CHECK" block in pngconf.h to allow - application code writers to bypass the check for multiple inclusion - of setjmp.h when they know that it is safe to ignore the situation. - Eliminated internal use of setjmp() in pngread.c and pngwrite.c - Reordered ancillary chunks in pngtest.png to be the same as what - pngtest now produces, and made some cosmetic changes to pngtest output. - Eliminated deprecated png_read_init_3() and png_write_init_3() functions. - -Version 1.4.0beta55 [April 15, 2009] - Simplified error handling in pngread.c and pngwrite.c by putting - the new png_read_cleanup() and png_write_cleanup() functions inline. - -Version 1.4.0beta56 [April 25, 2009] - Renamed "user_chunk_data" to "my_user_chunk_data" in pngtest.c to suppress - "shadowed declaration" warning from gcc-4.3.3. - Renamed "gamma" to "png_gamma" in pngset.c to avoid "shadowed declaration" - warning about a global "gamma" variable in math.h on some platforms. - -Version 1.4.0beta57 [May 2, 2009] - Removed prototype for png_freeptr() that was added in libpng-1.4.0beta24 - but was never defined (again). - Rebuilt configure scripts with autoconf-2.63 instead of 2.62 - Removed pngprefs.h and MMX from makefiles - -Version 1.4.0beta58 [May 14, 2009] - Changed pngw32.def to pngwin.def in makefile.mingw (typo was introduced - in beta57). - Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri) - -Version 1.4.0beta59 [May 15, 2009] - Reformated sources in libpng style (3-space intentation, comment format) - Fixed typo in libpng docs (PNG_FILTER_AVE should be PNG_FILTER_AVG) - Added sections about the git repository and our coding style to the - documentation - Relocated misplaced #endif in pngwrite.c, sCAL chunk handler. - -Version 1.4.0beta60 [May 19, 2009] - Conditionally compile png_read_finish_row() which is not used by - progressive readers. - Added contrib/pngminim/preader to demonstrate building minimal progressive - decoder, based on contrib/gregbook with embedded libpng and zlib. - -Version 1.4.0beta61 [May 20, 2009] - In contrib/pngminim/*, renamed "makefile.std" to "makefile", since there - is only one makefile in those directories, and revised the README files - accordingly. - More reformatting of comments, mostly to capitalize sentences. - -Version 1.4.0beta62 [June 2, 2009] - Added "#define PNG_NO_WRITE_SWAP" to contrib/pngminim/encoder/pngusr.h - and "define PNG_NO_READ_SWAP" to decoder/pngusr.h and preader/pngusr.h - Reformatted several remaining "else statement" into two lines. - Added a section to the libpng documentation about using png_get_io_ptr() - in configure scripts to detect the presence of libpng. - -Version 1.4.0beta63 [June 15, 2009] - Revised libpng*.txt and libpng.3 to mention calling png_set_IHDR() - multiple times and to specify the sample order in the tRNS chunk, - because the ISO PNG specification has a typo in the tRNS table. - Changed several PNG_UNKNOWN_CHUNK_SUPPORTED to - PNG_HANDLE_AS_UNKNOWN_SUPPORTED, to make the png_set_keep mechanism - available for ignoring known chunks even when not saving unknown chunks. - Adopted preference for consistent use of "#ifdef" and "#ifndef" versus - "#if defined()" and "if !defined()" where possible. - -Version 1.4.0beta64 [June 24, 2009] - Eliminated PNG_LEGACY_SUPPORTED code. - Moved the various unknown chunk macro definitions outside of the - PNG_READ|WRITE_ANCILLARY_CHUNK_SUPPORTED blocks. - -Version 1.4.0beta65 [June 26, 2009] - Added a reference to the libpng license in each file. - -Version 1.4.0beta66 [June 27, 2009] - Refer to the libpng license instead of the libpng license in each file. - -Version 1.4.0beta67 [July 6, 2009] - Relocated INVERT_ALPHA within png_read_png() and png_write_png(). - Added high-level API transform PNG_TRANSFORM_GRAY_TO_RGB. - Added an "xcode" project to the projects directory (Alam Arias). - -Version 1.4.0beta68 [July 19, 2009] - Avoid some tests in filter selection in pngwutil.c - -Version 1.4.0beta69 [July 25, 2009] - Simplified the new filter-selection test. This runs faster in the - common "PNG_ALL_FILTERS" and PNG_FILTER_NONE cases. - Removed extraneous declaration from the new call to png_read_gray_to_rgb() - (bug introduced in libpng-1.4.0beta67). - Fixed up xcode project (Alam Arias) - Added a prototype for png_64bit_product() in png.c - -Version 1.4.0beta70 [July 27, 2009] - Avoid a possible NULL dereference in debug build, in png_set_text_2(). - (bug introduced in libpng-0.95, discovered by Evan Rouault) - -Version 1.4.0beta71 [July 29, 2009] - Rebuilt configure scripts with autoconf-2.64. - -Version 1.4.0beta72 [August 1, 2009] - Replaced *.tar.lzma with *.tar.xz in distribution. Get the xz codec - from . - -Version 1.4.0beta73 [August 1, 2009] - Reject attempt to write iCCP chunk with negative embedded profile length - (JD Chen) (CVE-2009-5063). - -Version 1.4.0beta74 [August 8, 2009] - Changed png_ptr and info_ptr member "trans" to "trans_alpha". - -Version 1.4.0beta75 [August 21, 2009] - Removed an extra png_debug() recently added to png_write_find_filter(). - Fixed incorrect #ifdef in pngset.c regarding unknown chunk support. - -Version 1.4.0beta76 [August 22, 2009] - Moved an incorrectly located test in png_read_row() in pngread.c - -Version 1.4.0beta77 [August 27, 2009] - Removed lpXYZ.tar.bz2 (with CRLF), KNOWNBUG, libpng-x.y.z-KNOWNBUG.txt, - and the "noconfig" files from the distribution. - Moved CMakeLists.txt from scripts into the main libpng directory. - Various bugfixes and improvements to CMakeLists.txt (Philip Lowman) - -Version 1.4.0beta78 [August 31, 2009] - Converted all PNG_NO_* tests to PNG_*_SUPPORTED everywhere except pngconf.h - Eliminated PNG_NO_FREE_ME and PNG_FREE_ME_SUPPORTED macros. - Use png_malloc plus a loop instead of png_calloc() to initialize - row_pointers in png_read_png(). - -Version 1.4.0beta79 [September 1, 2009] - Eliminated PNG_GLOBAL_ARRAYS and PNG_LOCAL_ARRAYS; always use local arrays. - Eliminated PNG_CALLOC_SUPPORTED macro and always provide png_calloc(). - -Version 1.4.0beta80 [September 17, 2009] - Removed scripts/libpng.icc - Changed typecast of filler from png_byte to png_uint_16 in png_set_filler(). - (Dennis Gustafsson) - Fixed typo introduced in beta78 in pngtest.c ("#if def " should be "#ifdef ") - -Version 1.4.0beta81 [September 23, 2009] - Eliminated unused PNG_FLAG_FREE_* defines from pngpriv.h - Expanded TAB characters in pngrtran.c - Removed PNG_CONST from all "PNG_CONST PNG_CHNK" declarations to avoid - compiler complaints about doubly declaring things "const". - Changed all "#if [!]defined(X)" to "if[n]def X" where possible. - Eliminated unused png_ptr->row_buf_size - -Version 1.4.0beta82 [September 25, 2009] - Moved redundant IHDR checking into new png_check_IHDR() in png.c - and report all errors found in the IHDR data. - Eliminated useless call to png_check_cHRM() from pngset.c - -Version 1.4.0beta83 [September 25, 2009] - Revised png_check_IHDR() to eliminate bogus complaint about filter_type. - -Version 1.4.0beta84 [September 30, 2009] - Fixed some inconsistent indentation in pngconf.h - Revised png_check_IHDR() to add a test for width variable less than 32-bit. - -Version 1.4.0beta85 [October 1, 2009] - Revised png_check_IHDR() again, to check info_ptr members instead of - the contents of the returned parameters. - -Version 1.4.0beta86 [October 9, 2009] - Updated the "xcode" project (Alam Arias). - Eliminated a shadowed declaration of "pp" in png_handle_sPLT(). - -Version 1.4.0rc01 [October 19, 2009] - Trivial cosmetic changes. - -Version 1.4.0beta87 [October 30, 2009] - Moved version 1.4.0 back into beta. - -Version 1.4.0beta88 [October 30, 2009] - Revised libpng*.txt section about differences between 1.2.x and 1.4.0 - because most of the new features have now been ported back to 1.2.41 - -Version 1.4.0beta89 [November 1, 2009] - More bugfixes and improvements to CMakeLists.txt (Philip Lowman) - Removed a harmless extra png_set_invert_alpha() from pngwrite.c - Apply png_user_chunk_cache_max within png_decompress_chunk(). - Merged libpng-1.2.41.txt with libpng-1.4.0.txt where appropriate. - -Version 1.4.0beta90 [November 2, 2009] - Removed all remaining WIN32_WCE #ifdefs except those involving the - time.h "tm" structure - -Version 1.4.0beta91 [November 3, 2009] - Updated scripts/pngw32.def and projects/wince/png32ce.def - Copied projects/wince/png32ce.def to the scripts directory. - Added scripts/makefile.wce - Patched ltmain.sh for wince support. - Added PNG_CONVERT_tIME_SUPPORTED macro. - -Version 1.4.0beta92 [November 4, 2009] - Make inclusion of time.h in pngconf.h depend on PNG_CONVERT_tIME_SUPPORTED - Make #define PNG_CONVERT_tIME_SUPPORTED depend on PNG_WRITE_tIME_SUPPORTED - Revised libpng*.txt to describe differences from 1.2.40 to 1.4.0 (instead - of differences from 1.2.41 to 1.4.0) - -Version 1.4.0beta93 [November 7, 2009] - Added PNG_DEPSTRUCT, PNG_DEPRECATED, PNG_USE_RESULT, PNG_NORETURN, and - PNG_ALLOCATED macros to detect deprecated direct access to the - png_struct or info_struct members and other deprecated usage in - applications (John Bowler). - Updated scripts/makefile* to add "-DPNG_CONFIGURE_LIBPNG" to CFLAGS, - to prevent warnings about direct access to png structs by libpng - functions while building libpng. They need to be tested, especially - those using compilers other than gcc. - Updated projects/visualc6 and visualc71 with "/d PNG_CONFIGURE_LIBPNG". - They should work but still need to be updated to remove - references to pnggccrd.c or pngvcrd.c and ASM building. - Added README.txt to the beos, cbuilder5, netware, and xcode projects warning - that they need to be updated, to remove references to pnggccrd.c and - pngvcrd.c and to depend on pngpriv.h - Removed three direct references to read_info_ptr members in pngtest.c - that were detected by the new PNG_DEPSTRUCT macro. - Moved the png_debug macro definitions and the png_read_destroy(), - png_write_destroy() and png_far_to_near() prototypes from png.h - to pngpriv.h (John Bowler) - Moved the synopsis lines for png_read_destroy(), png_write_destroy() - png_debug(), png_debug1(), and png_debug2() from libpng.3 to libpngpf.3. - -Version 1.4.0beta94 [November 9, 2009] - Removed the obsolete, unused pnggccrd.c and pngvcrd.c files. - Updated CMakeLists.txt to add "-DPNG_CONFIGURE_LIBPNG" to the definitions. - Removed dependency of pngtest.o on pngpriv.h in the makefiles. - Only #define PNG_DEPSTRUCT, etc. in pngconf.h if not already defined. - -Version 1.4.0beta95 [November 10, 2009] - Changed png_check_sig() to !png_sig_cmp() in contrib programs. - Added -DPNG_CONFIGURE_LIBPNG to contrib/pngminm/*/makefile - Changed png_check_sig() to !png_sig_cmp() in contrib programs. - Corrected the png_get_IHDR() call in contrib/gregbook/readpng2.c - Changed pngminim/*/gather.sh to stop trying to remove pnggccrd.c and pngvcrd.c - Added dependency on pngpriv.h in contrib/pngminim/*/makefile - -Version 1.4.0beta96 [November 12, 2009] - Renamed scripts/makefile.wce to scripts/makefile.cegcc - Revised Makefile.am to use libpng.sys while building libpng.so - so that only PNG_EXPORT functions are exported. - Removed the deprecated png_check_sig() function/macro. - Removed recently removed function names from scripts/*.def - Revised pngtest.png to put chunks in the same order written by pngtest - (evidently the same change made in libpng-1.0beta54 was lost). - Added PNG_PRIVATE macro definition in pngconf.h for possible future use. - -Version 1.4.0beta97 [November 13, 2009] - Restored pngtest.png to the libpng-1.4.0beta7 version. - Removed projects/beos and netware.txt; no one seems to be supporting them. - Revised Makefile.in - -Version 1.4.0beta98 [November 13, 2009] - Added the "xcode" project to zip distributions, - Fixed a typo in scripts/pngwin.def introduced in beta97. - -Version 1.4.0beta99 [November 14, 2009] - Moved libpng-config.in and libpng.pc-configure.in out of the scripts - directory, to libpng-config.in and libpng-pc.in, respectively, and - modified Makefile.am and configure.ac accordingly. Now "configure" - needs nothing from the "scripts" directory. - Avoid redefining PNG_CONST in pngconf.h - -Version 1.4.0beta100 [November 14, 2009] - Removed ASM builds from projects/visualc6 and projects/visualc71 - Removed scripts/makefile.nommx and makefile.vcawin32 - Revised CMakeLists.txt to account for new location of libpng-config.in - and libpng-pc.in - Updated INSTALL to reflect removal and relocation of files. - -Version 1.4.0beta101 [November 14, 2009] - Restored the binary files (*.jpg, *.png, some project files) that were - accidentally deleted from the zip and 7z distributions when the xcode - project was added. - -Version 1.4.0beta102 [November 18, 2009] - Added libpng-config.in and libpng-pc.in to the zip and 7z distributions. - Fixed a typo in projects/visualc6/pngtest.dsp, introduced in beta100. - Moved descriptions of makefiles and other scripts out of INSTALL into - scripts/README.txt - Updated the copyright year in scripts/pngwin.rc from 2006 to 2009. - -Version 1.4.0beta103 [November 21, 2009] - Removed obsolete comments about ASM from projects/visualc71/README_zlib.txt - Align row_buf on 16-byte boundary in memory. - Restored the PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED guard around the call - to png_flush() after png_write_IEND(). See 1.4.0beta32, 1.4.0beta50 - changes above and 1.2.30, 1.2.30rc01 and rc03 in 1.2.41 CHANGES. Someone - needs this feature. - Make the 'png_jmpbuf' macro expand to a call that records the correct - longjmp function as well as returning a pointer to the setjmp - jmp_buf buffer, and marked direct access to jmpbuf 'deprecated'. - (John Bowler) - -Version 1.4.0beta104 [November 22, 2009] - Removed png_longjmp_ptr from scripts/*.def and libpng.3 - Rebuilt configure scripts with autoconf-2.65 - -Version 1.4.0beta105 [November 25, 2009] - Use fast integer PNG_DIVIDE_BY_255() or PNG_DIVIDE_BY_65535() - to accomplish alpha premultiplication when - PNG_READ_COMPOSITE_NODIV_SUPPORTED is defined. - Changed "/255" to "/255.0" in background calculations to make it clear - that the 255 is used as a double. - -Version 1.4.0beta106 [November 27, 2009] - Removed premultiplied alpha feature. - -Version 1.4.0beta107 [December 4, 2009] - Updated README - Added "#define PNG_NO_PEDANTIC_WARNINGS" in the libpng source files. - Removed "-DPNG_CONFIGURE_LIBPNG" from the makefiles and projects. - Revised scripts/makefile.netbsd, makefile.openbsd, and makefile.sco - to put png.h and pngconf.h in $prefix/include, like the other scripts, - instead of in $prefix/include/libpng. Also revised makefile.sco - to put them in $prefix/include/libpng15 instead of in - $prefix/include/libpng/libpng15. - -Version 1.4.0beta108 [December 11, 2009] - Removed leftover "-DPNG_CONFIGURE_LIBPNG" from contrib/pngminim/*/makefile - Relocated png_do_chop() to its original position in pngrtran.c; the - change in version 1.2.41beta08 caused transparency to be handled wrong - in some 16-bit datastreams (Yusaku Sugai). - -Version 1.4.0beta109 [December 13, 2009] - Added "bit_depth" parameter to the private png_build_gamma_table() function. - Pass bit_depth=8 to png_build_gamma_table() when bit_depth is 16 but the - PNG_16_TO_8 transform has been set, to avoid unnecessary build of 16-bit - tables. - -Version 1.4.0rc02 [December 20, 2009] - Declared png_cleanup_needed "volatile" in pngread.c and pngwrite.c - -Version 1.4.0rc03 [December 22, 2009] - Renamed libpng-pc.in back to libpng.pc.in and revised CMakeLists.txt - (revising the change in 1.4.0beta99) - -Version 1.4.0rc04 [December 25, 2009] - Swapped PNG_UNKNOWN_CHUNKS_SUPPORTED and PNG_HANDLE_AS_UNKNOWN_SUPPORTED - in pngset.c to be consistent with other changes in version 1.2.38. - -Version 1.4.0rc05 [December 25, 2009] - Changed "libpng-pc.in" to "libpng.pc.in" in configure.ac, configure, and - Makefile.in to be consistent with changes in libpng-1.4.0rc03 - -Version 1.4.0rc06 [December 29, 2009] - Reverted the gamma_table changes from libpng-1.4.0beta109. - Fixed some indentation errors. - -Version 1.4.0rc07 [January 1, 2010] - Revised libpng*.txt and libpng.3 about 1.2.x->1.4.x differences. - Use png_calloc() instead of png_malloc(); png_memset() in pngrutil.c - Update copyright year to 2010. - -Version 1.4.0rc08 [January 2, 2010] - Avoid deprecated references to png_ptr-io_ptr and png_ptr->error_ptr - in pngtest.c - -Version 1.4.0 [January 3, 2010] - No changes. - -Version 1.4.1beta01 [January 8, 2010] - Updated CMakeLists.txt for consistent indentation and to avoid an - unclosed if-statement warning (Philip Lowman). - Revised Makefile.am and Makefile.in to remove references to Y2KINFO, - KNOWNBUG, and libpng.la (Robert Schwebel). - Revised the makefiles to install the same files and symbolic - links as configure, except for libpng.la and libpng14.la. - Make png_set|get_compression_buffer_size() available even when - PNG_WRITE_SUPPORTED is not enabled. - Revised Makefile.am and Makefile.in to simplify their maintenance. - Revised scripts/makefile.linux to install a link to libpng14.so.14.1 - -Version 1.4.1beta02 [January 9, 2010] - Revised the rest of the makefiles to install a link to libpng14.so.14.1 - -Version 1.4.1beta03 [January 10, 2010] - Removed png_set_premultiply_alpha() from scripts/*.def - -Version 1.4.1rc01 [January 16, 2010] - No changes. - -Version 1.4.1beta04 [January 23, 2010] - Revised png_decompress_chunk() to improve speed and memory usage when - decoding large chunks. - Added png_set|get_chunk_malloc_max() functions. - -Version 1.4.1beta05 [January 26, 2010] - Relocated "int k" declaration in pngtest.c to minimize its scope. - -Version 1.4.1beta06 [January 28, 2010] - Revised png_decompress_chunk() to use a two-pass method suggested by - John Bowler. - -Version 1.4.1beta07 [February 6, 2010] - Folded some long lines in the source files. - Added defineable PNG_USER_CHUNK_CACHE_MAX, PNG_USER_CHUNK_MALLOC_MAX, - and a PNG_USER_LIMITS_SUPPORTED flag. - Eliminated use of png_ptr->irowbytes and reused the slot in png_ptr as - png_ptr->png_user_chunk_malloc_max. - Revised png_push_save_buffer() to do fewer but larger png_malloc() calls. - -Version 1.4.1beta08 [February 6, 2010] - Minor cleanup and updating of dates and copyright year. - -Version 1.5.0beta01 [February 7, 2010] - Moved declaration of png_struct into private pngstruct.h and png_info - into pnginfo.h - -Version 1.4.1beta09 and 1.5.0beta02 [February 7, 2010] - Reverted to original png_push_save_buffer() code. - -Version 1.4.1beta10 and 1.5.0beta03 [February 8, 2010] - Return allocated "old_buffer" in png_push_save_buffer() before - calling png_error(), to avoid a potential memory leak. - Updated configure script to use SO number 15. - -Version 1.5.0beta04 [February 9, 2010] - Removed malformed "incomplete struct declaration" of png_info from png.h - -Version 1.5.0beta05 [February 12, 2010] - Removed PNG_DEPSTRUCT markup in pngstruct.h and pnginfo.h, and undid the - linewrapping that it entailed. - Revised comments in pngstruct.h and pnginfo.h and added pointers to - the libpng license. - Changed PNG_INTERNAL to PNG_EXPOSE_INTERNAL_STRUCTURES - Removed the cbuilder5 project, which has not been updated to 1.4.0. - -Version 1.4.1beta12 and 1.5.0beta06 [February 14, 2010] - Fixed type declaration of png_get_chunk_malloc_max() in pngget.c (Daisuke - Nishikawa) - -Version 1.5.0beta07 [omitted] - -Version 1.5.0beta08 [February 19, 2010] - Changed #ifdef PNG_NO_STDIO_SUPPORTED to #ifdef PNG_NO_CONSOLE_IO_SUPPORTED - wherever png_snprintf() is used to construct error and warning messages. - Noted in scripts/makefile.mingw that it expects to be run under MSYS. - Removed obsolete unused MMX-querying support from contrib/gregbook - Added exported png_longjmp() function. - Removed the AIX redefinition of jmpbuf in png.h - Added -D_ALLSOURCE in configure.ac, makefile.aix, and CMakeLists.txt - when building on AIX. - -Version 1.5.0beta09 [February 19, 2010] - Removed -D_ALLSOURCE from configure.ac, makefile.aix, and CMakeLists.txt. - Changed the name of png_ptr->jmpbuf to png_ptr->png_jmpbuf in pngstruct.h - -Version 1.5.0beta10 [February 25, 2010] - Removed unused gzio.c from contrib/pngminim gather and makefile scripts - Removed replacement error handlers from contrib/gregbook. Because of - the new png_longjmp() function they are no longer needed. - -Version 1.5.0beta11 [March 6, 2010] - Removed checking for already-included setjmp.h from pngconf.h - Fixed inconsistent indentations and made numerous cosmetic changes. - Revised the "SEE ALSO" style of libpng.3, libpngpf.3, and png.5 - -Version 1.5.0beta12 [March 9, 2010] - Moved "#include png.h" inside pngpriv.h and removed "#include png.h" from - the source files, along with "#define PNG_EXPOSE_INTERNAL_STRUCTURES" - and "#define PNG_NO_PEDANTIC_WARNINGS" (John Bowler). - Created new pngdebug.h and moved debug definitions there. - -Version 1.5.0beta13 [March 10, 2010] - Protect pngstruct.h, pnginfo.h, and pngdebug.h from being included twice. - Revise the "#ifdef" blocks in png_inflate() so it will compile when neither - PNG_USER_CHUNK_MALLOC_MAX nor PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED - is defined. - Removed unused png_measure_compressed_chunk() from pngpriv.h and libpngpf.3 - Moved the 'config.h' support from pngconf.h to pngpriv.h - Removed PNGAPI from the png_longjmp_ptr typedef. - Eliminated dependence of pngtest.c on the private pngdebug.h file. - Make all png_debug macros into *unterminated* statements or - expressions (i.e. a trailing ';' must always be added) and correct - the format statements in various png_debug messages. - -Version 1.5.0beta14 [March 14, 2010] - Removed direct access to png_ptr->io_ptr from the Windows code in pngtest.c - Revised Makefile.am to account for recent additions and replacements. - Corrected CE and OS/2 DEF files (scripts/png*def) for symbols removed and - added ordinal numbers to the Windows DEF file and corrected the duplicated - ordinal numbers on CE symbols that are commented out. - Added back in export symbols that can be present in the Windows build but - are disabled by default. - PNG_EXPORT changed to include an 'ordinal' field for DEF file generation. - PNG_CALLBACK added to make callback definitions uniform. PNGAPI split - into PNGCAPI (base C form), PNGAPI (exports) and PNGCBAPI (callbacks), - and appropriate changes made to all files. Cygwin builds re-hinged to - allow procedure call standard changes and to remove the need for the DEF - file (fixes build on Cygwin). - Enabled 'attribute' warnings that are relevant to library APIs and callbacks. - Changed rules for generation of the various symbol files and added a new - rule for a DEF file (which is also added to the distribution). - Updated the symbol file generation to stop it adding spurious spaces - to EOL (coming from preprocessor macro expansion). Added a facility - to join tokens in the output and rewrite *.dfn to use this. - Eliminated scripts/*.def in favor of libpng.def; updated projects/visualc71 - and removed scripts/makefile.cygwin. - Made PNG_BUILD_DLL safe: it can be set whenever a DLL is being built. - Removed the include of sys/types.h - apparently unnecessary now on the - platforms on which it happened (all but Mac OS and RISC OS). - Moved the Mac OS test into pngpriv.h (the only place it is used.) - -Version 1.5.0beta15 [March 17, 2010] - Added symbols.chk target to Makefile.am to validate the symbols in png.h - against the new DEF file scripts/symbols.def. - Changed the default DEF file back to pngwin.def. - Removed makefile.mingw. - Eliminated PNG_NO_EXTERN and PNG_ALL_EXTERN - -Version 1.5.0beta16 [April 1, 2010] - Make png_text_struct independent of PNG_iTXt_SUPPORTED, so that - fields are initialized in all configurations. The READ/WRITE - macros (PNG_(READ|WRITE)_iTXt_SUPPORTED) still function as - before to disable code to actually read or write iTXt chunks - and iTXt_SUPPORTED can be used to detect presence of either - read or write support (but it is probably better to check for - the one actually required - read or write.) - Combined multiple png_warning() calls for a single error. - Restored the macro definition of png_check_sig(). - -Version 1.5.0beta17 [April 17, 2010] - Added some "(long)" typecasts to printf calls in png_handle_cHRM(). - Documented the fact that png_set_dither() was disabled since libpng-1.4.0. - Reenabled png_set_dither() but renamed it to png_set_quantize() to reflect - more accurately what it actually does. At the same time, renamed - the PNG_DITHER_[RED,GREEN_BLUE]_BITS macros to - PNG_QUANTIZE_[RED,GREEN,BLUE]_BITS. - Added some "(long)" typecasts to printf calls in png_handle_cHRM(). - Freeze build-time only configuration in the build. - In all prior versions of libpng most configuration options - controlled by compiler #defines had to be repeated by the - application code that used libpng. This patch changes this - so that compilation options that can only be changed at build - time are frozen in the build. Options that are compiler - dependent (and those that are system dependent) are evaluated - each time - pngconf.h holds these. Options that can be changed - per-file in the application are in png.h. Frozen options are - in the new installed header file pnglibconf.h (John Bowler) - Removed the xcode project because it has not been updated to work - with libpng-1.5.0. - Removed the ability to include optional pngusr.h - -Version 1.5.0beta18 [April 17, 2010] - Restored the ability to include optional pngusr.h - Moved replacements for png_error() and png_warning() from the - contrib/pngminim project to pngerror.c, for use when warnings or - errors are disabled via PNG_NO_WARN or PNG_NO_ERROR_TEXT, to avoid - storing unneeded error/warning text. - Updated contrib/pngminim project to work with the new pnglibconf.h - Added some PNG_NO_* defines to contrib/pngminim/*/pngusr.h to save space. - -Version 1.5.0beta19 [April 24, 2010] - Added PNG_{READ,WRITE}_INT_FUNCTIONS_SUPPORTED. This allows the functions - to read and write ints to be disabled independently of PNG_USE_READ_MACROS, - which allows libpng to be built with the functions even though the default - is to use the macros - this allows applications to choose at app build - time whether or not to use macros (previously impossible because the - functions weren't in the default build.) - Changed Windows calling convention back to __cdecl for API functions. - For Windows/x86 platforms only: - __stdcall is no longer needed for Visual Basic, so libpng-1.5.0 uses - __cdecl throughout (both API functions and callbacks) on Windows/x86 - platforms. - Replaced visualc6 and visualc71 projects with new vstudio project - Relaxed the overly-restrictive permissions of some files. - -Version 1.5.0beta20 [April 24, 2010] - Relaxed more overly-restrictive permissions of some files. - -Version 1.5.0beta21 [April 27, 2010] - Removed some unwanted binary bytes and changed CRLF to NEWLINE in the new - vstudio project files, and some trivial editing of some files in the - scripts directory. - Set PNG_NO_READ_BGR, PNG_NO_IO_STATE, and PNG_NO_TIME_RFC1123 in - contrib/pngminim/decoder/pngusr.h to make a smaller decoder application. - -Version 1.5.0beta22 [April 28, 2010] - Fixed dependencies of GET_INT_32 - it does not require READ_INT_FUNCTIONS - because it has a macro equivalent. - Improved the options.awk script; added an "everything off" option. - Revised contrib/pngminim to use the "everything off" option in pngusr.dfa. - -Version 1.5.0beta23 [April 29, 2010] - Corrected PNG_REMOVED macro to take five arguments. - The macro was documented with two arguments (name,ordinal), however - the symbol checking .dfn files assumed five arguments. The five - argument form seems more useful so it is changed to that. - Corrected PNG_UNKNOWN_CHUNKS_SUPPORTED to PNG_HANDLE_AS_UNKNOWN_SUPPORTED - in gregbook/readpng2.c - Corrected protection of png_get_user_transform_ptr. The API declaration in - png.h is removed if both READ and WRITE USER_TRANSFORM are turned off - but was left defined in pngtrans.c - Added logunsupported=1 to cause pnglibconf.h to document disabled options. - This makes the installed pnglibconf.h more readable but causes no - other change. The intention is that users of libpng will find it - easier to understand if an API they need is missing. - Include png_reset_zstream() in png.c only when PNG_READ_SUPPORTED is defined. - Removed dummy_inflate.c from contrib/pngminim/encoder - Removed contrib/pngminim/*/gather.sh; gathering is now done in the makefile. - -Version 1.5.0beta24 [May 7, 2010] - Use bitwise "&" instead of arithmetic mod in pngrutil.c calculation of the - offset of the png_ptr->rowbuf pointer into png_ptr->big_row_buf. - Added more blank lines for readability. - -Version 1.5.0beta25 [June 18, 2010] - In pngpread.c: png_push_have_row() add check for new_row > height - Removed the now-redundant check for out-of-bounds new_row from example.c - -Version 1.5.0beta26 [June 18, 2010] - In pngpread.c: png_push_process_row() add check for too many rows. - -Version 1.5.0beta27 [June 18, 2010] - Removed the check added in beta25 as it is now redundant. - -Version 1.5.0beta28 [June 20, 2010] - Rewrote png_process_IDAT_data to consistently treat extra data as warnings - and handle end conditions more cleanly. - Removed the new (beta26) check in png_push_process_row(). - -Version 1.5.0beta29 [June 21, 2010] - Revised scripts/options.awk to work on Sunos (but still doesn't work) - Added comment to options.awk and contrib/pngminim/*/makefile to try nawk. - -Version 1.5.0beta30 [June 22, 2010] - Stop memory leak when reading a malformed sCAL chunk. - -Version 1.5.0beta31 [June 26, 2010] - Revised pngpread.c patch of beta28 to avoid an endless loop. - Removed some trailing blanks. - -Version 1.5.0beta32 [June 26, 2010] - Removed leftover scripts/options.patch and scripts/options.rej - -Version 1.5.0beta33 [July 6, 3010] - Made FIXED and FLOATING options consistent in the APIs they enable and - disable. Corrected scripts/options.awk to handle both command line - options and options specified in the .dfa files. - Changed char *msg to PNG_CONST char *msg in pngrutil.c - Make png_set_sRGB_gAMA_and_cHRM set values using either the fixed or - floating point APIs, but not both. - Reversed patch to remove error handler when the jmp_buf is stored in the - main program structure, not the png_struct. - The error handler is needed because the default handler in libpng will - always use the jmp_buf in the library control structure; this is never - set. The gregbook code is a useful example because, even though it - uses setjmp/longjmp, it shows how error handling can be implemented - using control mechanisms not directly supported by libpng. The - technique will work correctly with mechanisms such as Microsoft - Structure Exceptions or C++ exceptions (compiler willing - note that gcc - does not by default support interworking of C and C++ error handling.) - Reverted changes to call png_longjmp in contrib/gregbook where it is not - appropriate. If mainprog->jmpbuf is used by setjmp, then png_longjmp - cannot be used. - Changed "extern PNG_EXPORT" to "PNG_EXPORT" in png.h (Jan Nijtmans) - Changed "extern" to "PNG_EXTERN" in pngpriv.h (except for the 'extern "C" {') - -Version 1.5.0beta34 [July 12, 2010] - Put #ifndef PNG_EXTERN, #endif around the define PNG_EXTERN in pngpriv.h - -Version 1.5.0beta35 [July 24, 2010] - Removed some newly-added TAB characters. - Added -DNO_PNG_SNPRINTF to CFLAGS in scripts/makefile.dj2 - Moved the definition of png_snprintf() outside of the enclosing - #ifdef blocks in pngconf.h - -Version 1.5.0beta36 [July 29, 2010] - Patches by John Bowler: - Fixed point APIs are now supported throughout (no missing APIs). - Internal fixed point arithmetic support exists for all internal floating - point operations. - sCAL validates the floating point strings it is passed. - Safe, albeit rudimentary, Watcom support is provided by PNG_API_RULE==2 - Two new APIs exist to get the number of passes without turning on the - PNG_INTERLACE transform and to get the number of rows in the current - pass. - A new test program, pngvalid.c, validates the gamma code. - Errors in the 16-bit gamma correction (overflows) have been corrected. - cHRM chunk testing is done consistently (previously the floating point - API bypassed it, because the test really didn't work on FP, now the test - is performed on the actual values to be stored in the PNG file so it - works in the FP case too.) - Most floating point APIs now simply call the fixed point APIs after - converting the values to the fixed point form used in the PNG file. - The standard headers no longer include zlib.h, which is currently only - required for pngstruct.h and can therefore be internal. - Revised png_get_int_32 to undo the PNG two's complement representation of - negative numbers. - -Version 1.5.0beta37 [July 30, 2010] - Added a typecast in png_get_int_32() in png.h and pngrutil.h to avoid - a compiler warning. - Replaced oFFs 0,0 with oFFs -10,20 in pngtest.png - -Version 1.5.0beta38 [July 31, 2010] - Implemented remaining "_fixed" functions. - Corrected a number of recently introduced warnings mostly resulting from - safe but uncast assignments to shorter integers. Also added a zlib - VStudio release library project because the latest zlib Official Windows - build does not include such a thing. - Revised png_get_int_16() to be similar to png_get_int_32(). - Restored projects/visualc71. - -Version 1.5.0beta39 [August 2, 2010] - VisualC/GCC warning fixes, VisualC build fixes - The changes include support for function attributes in VC in addition to - those already present in GCC - necessary because without these some - warnings are unavoidable. Fixes include signed/unsigned fixes in - pngvalid and checks with gcc -Wall -Wextra -Wunused. - VC requires function attributes on function definitions as well as - declarations, PNG_FUNCTION has been added to enable this and the - relevant function definitions changed. - -Version 1.5.0beta40 [August 6, 2010] - Correct use of _WINDOWS_ in pngconf.h - Removed png_mem_ #defines; they are no longer used. - Added the sRGB chunk to pngtest.png - -Version 1.5.0beta41 [August 11, 2010] - Added the cHRM chunk to pngtest.png - Don't try to use version-script with cygwin/mingw. - Revised contrib/gregbook to work under cygwin/mingw. - -Version 1.5.0beta42 [August 18, 2010] - Add .dll.a to the list of extensions to be symlinked by Makefile.am (Yaakov) - Made all API functions that have const arguments and constant string - literal pointers declare them (John Bowler). - -Version 1.5.0beta43 [August 20, 2010] - Removed spurious tabs, shorten long lines (no source change) - Also added scripts/chkfmt to validate the format of all the files that can - reasonably be validated (it is suggested to run "make distclean" before - checking, because some machine generated files have long lines.) - Reformatted the CHANGES file to be more consistent throughout. - Made changes to address various issues identified by GCC, mostly - signed/unsigned and shortening problems on assignment but also a few - difficult to optimize (for GCC) loops. - Fixed non-GCC fixed point builds. In png.c a declaration was misplaced - in an earlier update. Fixed to declare the auto variables at the head. - Use cexcept.h in pngvalid.c. - -Version 1.5.0beta44 [August 24, 2010] - Updated CMakeLists.txt to use CMAKE_INSTALL_LIBDIR variable; useful for - installing libpng in /usr/lib64 (Funda Wang). - Revised CMakeLists.txt to put the man pages in share/man/man* not man/man* - Revised CMakeLists.txt to make symlinks instead of copies when installing. - Changed PNG_LIB_NAME from pngNN to libpngNN in CMakeLists.txt (Philip Lowman) - Implemented memory checks within pngvalid - Reformatted/rearranged pngvalid.c to assist use of progressive reader. - Check interlaced images in pngvalid - Clarified pngusr.h comments in pnglibconf.dfa - Simplified the pngvalid error-handling code now that cexcept.h is in place. - Implemented progressive reader in pngvalid.c for standard tests - Implemented progressive read in pngvalid.c gamma tests - Turn on progressive reader in pngvalid.c by default and tidy code. - -Version 1.5.0beta45 [August 26, 2010] - Added an explicit make step to projects/vstudio for pnglibconf.h - Also corrected zlib.vcxproj into which Visual Studio had introduced - what it calls an "authoring error". The change to make pnglibconf.h - simply copies the file; in the future it may actually generate the - file from scripts/pnglibconf.dfa as the other build systems do. - Changed pngvalid to work when floating point APIs are disabled - Renamed the prebuilt scripts/pnglibconf.h to scripts/pnglibconf.h.prebuilt - Supply default values for PNG_USER_PRIVATEBUILD and PNG_USER_DLLFNAME_POSTFIX - in pngpriv.h in case the user neglected to define them in their pngusr.h - -Version 1.5.0beta46 [August 28, 2010] - Added new private header files to libpng_sources in CMakeLists.txt - Added PNG_READ_16BIT, PNG_WRITE_16BIT, and PNG_16BIT options. - Added reference to scripts/pnglibconf.h.prebuilt in the visualc71 project. - -Version 1.5.0beta47 [September 11, 2010] - Fixed a number of problems with 64-bit compilation reported by Visual - Studio 2010 (John Bowler). - -Version 1.5.0beta48 [October 4, 2010] - Updated CMakeLists.txt (Philip Lowman). - Revised autogen.sh to recognize and use $AUTOCONF, $AUTOMAKE, $AUTOHEADER, - $AUTOPOINT, $ACLOCAL and $LIBTOOLIZE - Fixed problem with symbols creation in Makefile.am which was assuming that - all versions of ccp write to standard output by default (Martin Banky). The - bug was introduced in libpng-1.2.9beta5. - Removed unused mkinstalldirs. - -Version 1.5.0beta49 [October 8, 2010] - Undid Makefile.am revision of 1.5.0beta48. - -Version 1.5.0beta50 [October 14, 2010] - Revised Makefile.in to account for mkinstalldirs being removed. - Added some "(unsigned long)" typecasts in printf statements in pngvalid.c. - Suppressed a compiler warning in png_handle_sPLT(). - Check for out-of-range text compression mode in png_set_text(). - -Version 1.5.0beta51 [October 15, 2010] - Changed embedded dates to "(PENDING RELEASE) in beta releases (and future - rc releases) to minimize the difference between releases. - -Version 1.5.0beta52 [October 16, 2010] - Restored some of the embedded dates (in png.h, png.c, documentation, etc.) - -Version 1.5.0beta53 [October 18, 2010] - Updated INSTALL to mention using "make maintainer-clean" and to remove - obsolete statement about a custom ltmain.sh - Disabled "color-tests" by default in Makefile.am so it will work with - automake versions earlier than 1.11.1 - Use document name "libpng-manual.txt" instead of "libpng-.txt" - to simplify version differences. - Removed obsolete remarks about setjmp handling from INSTALL. - Revised and renamed the typedef in png.h and png.c that was designed - to catch library and header mismatch. - -Version 1.5.0beta54 [November 10, 2010] - Require 48 bytes, not 64 bytes, for big_row_buf in overflow checks. - Used a consistent structure for the pngget.c functions. - -Version 1.5.0beta55 [November 21, 2010] - Revised png_get_uint_32, png_get_int_32, png_get_uint_16 (Cosmin) - Moved reading of file signature into png_read_sig (Cosmin) - Fixed atomicity of chunk header serialization (Cosmin) - Added test for io_state in pngtest.c (Cosmin) - Added "#!/bin/sh" at the top of contrib/pngminim/*/gather.sh scripts. - Changes to remove gcc warnings (John Bowler) - Certain optional gcc warning flags resulted in warnings in libpng code. - With these changes only -Wconversion and -Wcast-qual cannot be turned on. - Changes are trivial rearrangements of code. -Wconversion is not possible - for pngrutil.c (because of the widespread use of += et al on variables - smaller than (int) or (unsigned int)) and -Wcast-qual is not possible - with pngwio.c and pngwutil.c because the 'write' callback and zlib - compression both fail to declare their input buffers with 'const'. - -Version 1.5.0beta56 [December 7, 2010] - Added the private PNG_UNUSED() macro definition in pngpriv.h. - Added some commentary about PNG_EXPORT in png.h and pngconf.h - Revised PNG_EXPORT() macro and added PNG_EXPORTA() macro, with the - objective of simplifying and improving the cosmetic appearance of png.h. - Fixed some incorrect "=" macro names in pnglibconf.dfa - Included documentation of changes in 1.5.0 from 1.4.x in libpng-manual.txt - -Version 1.5.0beta57 [December 9, 2010] - Documented the pngvalid gamma error summary with additional comments and - print statements. - Improved missing symbol handling in checksym.awk; symbols missing in both - the old and new files can now be optionally ignored, treated as errors - or warnings. - Removed references to pngvcrd.c and pnggccrd.c from the vstudio project. - Updated "libpng14" to "libpng15" in the visualc71 project. - Enabled the strip16 tests in pngvalid.` - Don't display test results (except PASS/FAIL) when running "make test". - Instead put them in pngtest-log.txt - Added "--with-zprefix=" to configure.ac - Updated the prebuilt configuration files to autoconf version 2.68 - -Version 1.5.0beta58 [December 19, 2010] - Fixed interlace image handling and add test cases (John Bowler) - Fixed the clean rule in Makefile.am to remove pngtest-log.txt - Made minor changes to work around warnings in gcc 3.4 - -Version 1.5.0rc01 [December 27, 2010] - No changes. - -Version 1.5.0rc02 [December 27, 2010] - Eliminated references to the scripts/*.def files in project/visualc71. - -Version 1.5.0rc03 [December 28, 2010] - Eliminated scripts/*.def and revised Makefile.am accordingly - -Version 1.5.0rc04 [December 29, 2010] - Fixed bug in background transformation handling in pngrtran.c (it was - looking for the flag in png_ptr->transformations instead of in - png_ptr->flags) (David Raymond). - -Version 1.5.0rc05 [December 31, 2010] - Fixed typo in a comment in CMakeLists.txt (libpng14 => libpng15) (Cosmin) - -Version 1.5.0rc06 [January 4, 2011] - Changed the new configure option "zprefix=string" to "zlib-prefix=string" - -Version 1.5.0rc07 [January 4, 2011] - Updated copyright year. - -Version 1.5.0 [January 6, 2011] - No changes. - -version 1.5.1beta01 [January 8, 2011] - Added description of png_set_crc_action() to the manual. - Added a note in the manual that the type of the iCCP profile was changed - from png_charpp to png_bytepp in png_get_iCCP(). This change happened - in version 1.5.0beta36 but is not noted in the CHANGES. Similarly, - it was changed from png_charpp to png_const_bytepp in png_set_iCCP(). - Ensure that png_rgb_to_gray ignores palette mapped images, if libpng - internally happens to call it with one, and fixed a failure to handle - palette mapped images correctly. This fixes CVE-2690. - -Version 1.5.1beta02 [January 14, 2011] - Fixed a bug in handling of interlaced images (bero at arklinux.org). - Updated CMakeLists.txt (Clifford Yapp) - -Version 1.5.1beta03 [January 14, 2011] - Fixed typecasting of some png_debug() statements (Cosmin) - -Version 1.5.1beta04 [January 16, 2011] - Updated documentation of png_set|get_tRNS() (Thomas Klausner). - Mentioned in the documentation that applications must #include "zlib.h" - if they need access to anything in zlib.h, and that a number of - macros such as png_memset() are no longer accessible by applications. - Corrected pngvalid gamma test "sample" function to access all of the color - samples of each pixel, instead of sampling the red channel three times. - Prefixed variable names index, div, exp, gamma with "png_" to avoid "shadow" - warnings, and (mistakenly) changed png_exp() to exp(). - -Version 1.5.1beta05 [January 16, 2011] - Changed variable names png_index, png_div, png_exp, and png_gamma to - char_index, divisor, exp_b10, and gamma_val, respectively, and - changed exp() back to png_exp(). - -Version 1.5.1beta06 [January 20, 2011] - Prevent png_push_crc_skip() from hanging while reading an unknown chunk - or an over-large compressed zTXt chunk with the progressive reader. - Eliminated more GCC "shadow" warnings. - Revised png_fixed() in png.c to avoid compiler warning about reaching the - end without returning anything. - -Version 1.5.1beta07 [January 22, 2011] - In the manual, describe the png_get_IHDR() arguments in the correct order. - Added const_png_structp and const_png_infop types, and used them in - prototypes for most png_get_*() functions. - -Version 1.5.1beta08 [January 23, 2011] - Added png_get_io_chunk_type() and deprecated png_get_io_chunk_name() - Added synopses for the IO_STATE functions and other missing synopses - to the manual. Removed the synopses from libpngpf.3 because they - were out of date and no longer useful. Better information can be - obtained by reading the prototypes and comments in pngpriv.h - Attempted to fix cpp on Solaris with S. Studio 12 cc, fix build - Added a make macro DFNCPP that is a CPP that will accept the tokens in - a .dfn file and adds configure stuff to test for such a CPP. ./configure - should fail if one is not available. - Corrected const_png_ in png.h to png_const_ to avoid polluting the namespace. - Added png_get_current_row_number and png_get_current_pass_number for the - benefit of the user transform callback. - Added png_process_data_pause and png_process_data_skip for the benefit of - progressive readers that need to stop data processing or want to optimize - skipping of unread data (e.g., if the reader marks a chunk to be skipped.) - -Version 1.5.1beta09 [January 24, 2011] - Enhanced pngvalid, corrected an error in gray_to_rgb, corrected doc error. - pngvalid contains tests of transforms, which tests are currently disabled - because they are incompletely tested. gray_to_rgb was failing to expand - the bit depth for smaller bit depth images; this seems to be a long - standing error and resulted, apparently, in invalid output - (CVE-2011-0408, CERT VU#643140). The documentation did not accurately - describe what libpng really does when converting RGB to gray. - -Version 1.5.1beta10 [January 27, 2010] - Fixed incorrect examples of callback prototypes in the manual, that were - introduced in libpng-1.0.0. - In addition the order of the png_get_uint macros with respect to the - relevant function definitions has been reversed. This helps the - preprocessing of the symbol files be more robust. Furthermore, the - symbol file preprocessing now uses -DPNG_NO_USE_READ_MACROS even when - the library may actually be built with PNG_USE_READ_MACROS; this stops - the read macros interfering with the symbol file format. - Made the manual, synopses, and function prototypes use the function - argument names file_gamma, int_file_gamma, and srgb_intent consistently. - -Version 1.5.1beta11 [January 28, 2011] - Changed PNG_UNUSED from "param=param;" to "{if(param){}}". - Corrected local variable type in new API png_process_data_skip() - The type was self-evidently incorrect but only causes problems on 64-bit - architectures. - Added transform tests to pngvalid and simplified the arguments. - -Version 1.5.1rc01 [January 29, 2011] - No changes. - -Version 1.5.1rc02 [January 31, 2011] - Added a request in the manual that applications do not use "png_" or - "PNG_" to begin any of their own symbols. - Changed PNG_UNUSED to "(void)param;" and updated the commentary in pngpriv.h - -Version 1.5.1 [February 3, 2011] - No changes. - -Version 1.5.2beta01 [February 13, 2011] - More -Wshadow fixes for older gcc compilers. Older gcc versions apparently - check formal parameters names in function declarations (as well as - definitions) to see if they match a name in the global namespace. - Revised PNG_EXPORTA macro to not use an empty parameter, to accommodate the - old VisualC++ preprocessor. - Turned on interlace handling in png_read_png(). - Fixed gcc pendantic warnings. - Handle longjmp in Cygwin. - Fixed png_get_current_row_number() in the interlaced case. - Cleaned up ALPHA flags and transformations. - Implemented expansion to 16 bits. - -Version 1.5.2beta02 [February 19, 2011] - Fixed mistake in the descriptions of user read_transform and write_transform - function prototypes in the manual. The row_info struct is png_row_infop. - Reverted png_get_current_row_number() to previous (1.5.2beta01) behavior. - Corrected png_get_current_row_number documentation - Fixed the read/write row callback documentation. - This documents the current behavior, where the callback is called after - every row with information pertaining to the next row. - -Version 1.5.2beta03 [March 3, 2011] - Fixed scripts/makefile.vcwin32 - Updated contrib/pngsuite/README to add the word "modify". - Define PNG_ALLOCATED to blank when _MSC_VER<1300. - -Version 1.5.2rc01 [March 19, 2011] - Define remaining attributes to blank when MSC_VER<1300. - ifdef out mask arrays in pngread.c when interlacing is not supported. - -Version 1.5.2rc02 [March 22, 2011] - Added a hint to try CPP=/bin/cpp if "cpp -E" fails in scripts/pnglibconf.mak - and in contrib/pngminim/*/makefile, eg., on SunOS 5.10, and removed "strip" - from the makefiles. - Fixed a bug (present since libpng-1.0.7) that makes png_handle_sPLT() fail - to compile when PNG_NO_POINTER_INDEXING is defined (Chubanov Kirill) - -Version 1.5.2rc03 [March 24, 2011] - Don't include standard header files in png.h while building the symbol table, - to avoid cpp failure on SunOS (introduced PNG_BUILDING_SYMBOL_TABLE macro). - -Version 1.5.2 [March 31, 2011] - No changes. - -Version 1.5.3beta01 [April 1, 2011] - Re-initialize the zlib compressor before compressing non-IDAT chunks. - Added API functions (png_set_text_compression_level() and four others) to - set parameters for zlib compression of non-IDAT chunks. - -Version 1.5.3beta02 [April 3, 2011] - Updated scripts/symbols.def with new API functions. - Only compile the new zlib re-initializing code when text or iCCP is - supported, using PNG_WRITE_COMPRESSED_TEXT_SUPPORTED macro. - Improved the optimization of the zlib CMF byte (see libpng-1.2.6beta03). - Optimize the zlib CMF byte in non-IDAT compressed chunks - -Version 1.5.3beta03 [April 16, 2011] - Fixed gcc -ansi -pedantic compile. A strict ANSI system does not have - snprintf, and the "__STRICT_ANSI__" detects that condition more reliably - than __STDC__ (John Bowler). - Removed the PNG_PTR_NORETURN attribute because it too dangerous. It tells - the compiler that a user supplied callback (the error handler) does not - return, yet there is no guarantee in practice that the application code - will correctly implement the error handler because the compiler only - issues a warning if there is a mistake (John Bowler). - Removed the no-longer-used PNG_DEPSTRUCT macro. - Updated the zlib version to 1.2.5 in the VStudio project. - Fixed 64-bit builds where png_uint_32 is smaller than png_size_t in - pngwutil.c (John Bowler). - Fixed bug with stripping the filler or alpha channel when writing, that - was introduced in libpng-1.5.2beta01 (bug report by Andrew Church). - -Version 1.5.3beta04 [April 27, 2011] - Updated pngtest.png with the new zlib CMF optimization. - Cleaned up conditional compilation code and of background/gamma handling - Internal changes only except a new option to avoid compiling the - png_build_grayscale_palette API (which is not used at all internally.) - The main change is to move the transform tests (READ_TRANSFORMS, - WRITE_TRANSFORMS) up one level to the caller of the APIs. This avoids - calls to spurious functions if all transforms are disabled and slightly - simplifies those functions. Pngvalid modified to handle this. - A minor change is to stop the strip_16 and expand_16 interfaces from - disabling each other; this allows the future alpha premultiplication - code to use 16-bit intermediate values while still producing 8-bit output. - png_do_background and png_do_gamma have been simplified to take a single - pointer to the png_struct rather than pointers to every item required - from the png_struct. This makes no practical difference to the internal - code. - A serious bug in the pngvalid internal routine 'standard_display_init' has - been fixed - this failed to initialize the red channel and accidentally - initialized the alpha channel twice. - Changed png_struct jmp_buf member name from png_jmpbuf to tmp_jmpbuf to - avoid a possible clash with the png_jmpbuf macro on some platforms. - -Version 1.5.3beta05 [May 6, 2011] - Added the "_POSIX_SOURCE" feature test macro to ensure libpng sees the - correct API. _POSIX_SOURCE is defined in pngpriv.h, pngtest.c and - pngvalid.c to ensure that POSIX conformant systems disable non-POSIX APIs. - Removed png_snprintf and added formatted warning messages. This change adds - internal APIs to allow png_warning messages to have parameters without - requiring the host OS to implement snprintf. As a side effect the - dependency of the tIME-supporting RFC1132 code on stdio is removed and - PNG_NO_WARNINGS does actually work now. - Pass "" instead of '\0' to png_default_error() in png_err(). This mistake - was introduced in libpng-1.2.20beta01. This fixes CVE-2011-2691. - Added PNG_WRITE_OPTIMIZE_CMF_SUPPORTED macro to make the zlib "CMF" byte - optimization configureable. - IDAT compression failed if preceded by a compressed text chunk (bug - introduced in libpng-1.5.3beta01-02). This was because the attempt to - reset the zlib stream in png_write_IDAT happened after the first IDAT - chunk had been deflated - much too late. In this change internal - functions were added to claim/release the z_stream and, hopefully, make - the code more robust. Also deflateEnd checking is added - previously - libpng would ignore an error at the end of the stream. - -Version 1.5.3beta06 [May 8, 2011] - Removed the -D_ALL_SOURCE from definitions for AIX in CMakeLists.txt - Implemented premultiplied alpha support: png_set_alpha_mode API - -Version 1.5.3beta07 [May 11, 2011] - Added expand_16 support to the high level interface. - Added named value and 'flag' gamma support to png_set_gamma. Made a minor - change from the previous (unreleased) ABI/API to hide the exact value used - for Macs - it's not a good idea to embed this in the ABI! - Moved macro definitions for PNG_HAVE_IHDR, PNG_HAVE_PLTE, and PNG_AFTER_IDAT - from pngpriv.h to png.h because they must be visible to applications - that call png_set_unknown_chunks(). - Check for up->location !PNG_AFTER_IDAT when writing unknown chunks - before IDAT. - -Version 1.5.3beta08 [May 16, 2011] - Improved "pngvalid --speed" to exclude more of pngvalid from the time. - Documented png_set_alpha_mode(), other changes in libpng.3/libpng-manual.txt - The cHRM chunk now sets the defaults for png_set_rgb_to_gray() (when negative - parameters are supplied by the caller), while in the absence of cHRM - sRGB/Rec 709 values are still used. This introduced a divide-by-zero - bug in png_handle_cHRM(). - The bKGD chunk no longer overwrites the background value set by - png_set_background(), allowing the latter to be used before the file - header is read. It never performed any useful function to override - the default anyway. - Added memory overwrite and palette image checks to pngvalid.c - Previously palette image code was poorly checked. Since the transformation - code has a special palette path in most cases this was a severe weakness. - Minor cleanup and some extra checking in pngrutil.c and pngrtran.c. When - expanding an indexed image, always expand to RGBA if transparency is - present. - -Version 1.5.3beta09 [May 17, 2011] - Reversed earlier 1.5.3 change of transformation order; move png_expand_16 - back where it was. The change doesn't work because it requires 16-bit - gamma tables when the code only generates 8-bit ones. This fails - silently; the libpng code just doesn't do any gamma correction. Moving - the tests back leaves the old, inaccurate, 8-bit gamma calculations, but - these are clearly better than none! - -Version 1.5.3beta10 [May 20, 2011] - - png_set_background() and png_expand_16() did not work together correctly. - This problem is present in 1.5.2; if png_set_background is called with - need_expand false and the matching 16 bit color libpng erroneously just - treats it as an 8-bit color because of where png_do_expand_16 is in the - transform list. This simple fix reduces the supplied colour to 8-bits, - so it gets smashed, but this is better than the current behavior. - Added tests for expand16, more fixes for palette image tests to pngvalid. - Corrects the code for palette image tests and disables attempts to - validate palette colors. - -Version 1.5.3rc01 [June 3, 2011] - No changes. - -Version 1.5.3rc02 [June 8, 2011] - Fixed uninitialized memory read in png_format_buffer() (Bug report by - Frank Busse, CVE-2011-2501, related to CVE-2004-0421). - -Version 1.5.3beta11 [June 11, 2011] - Fixed png_handle_sCAL which is broken in 1.5. This fixes CVE 2011-2692. - Added sCAL to pngtest.png - Revised documentation about png_set_user_limits() to say that it also affects - png writing. - Revised handling of png_set_user_limits() so that it can increase the - limit beyond the PNG_USER_WIDTH|HEIGHT_MAX; previously it could only - reduce it. - Make the 16-to-8 scaling accurate. Dividing by 256 with no rounding is - wrong (high by one) 25% of the time. Dividing by 257 with rounding is - wrong in 128 out of 65536 cases. Getting the right answer all the time - without division is easy. - Added "_SUPPORTED" to the PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION macro. - Added projects/owatcom, an IDE project for OpenWatcom to replace - scripts/makefile.watcom. This project works with OpenWatcom 1.9. The - IDE autogenerates appropriate makefiles (libpng.mk) for batch processing. - The project is configurable, unlike the Visual Studio project, so long - as the developer has an awk. - Changed png_set_gAMA to limit the gamma value range so that the inverse - of the stored value cannot overflow the fixed point representation, - and changed other things OpenWatcom warns about. - Revised pngvalid.c to test PNG_ALPHA_MODE_SUPPORTED correctly. This allows - pngvalid to build when ALPHA_MODE is not supported, which is required if - it is to build on libpng 1.4. - Removed string/memory macros that are no longer used and are not - necessarily fully supportable, particularly png_strncpy and png_snprintf. - Added log option to pngvalid.c and attempted to improve gamma messages. - -Version 1.5.3 [omitted] - People found the presence of a beta release following an rc release - to be confusing; therefore we bump the version to libpng-1.5.4beta01 - and there will be no libpng-1.5.3 release. - -Version 1.5.4beta01 [June 14, 2011] - Made it possible to undefine PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED - to get the same (inaccurate) output as libpng-1.5.2 and earlier. - Moved definitions of PNG_HAVE_IHDR, PNG_AFTER_IDAT, and PNG_HAVE_PLTE - outside of an unknown-chunk block in png.h because they are also - needed for other uses. - -Version 1.5.4beta02 [June 14, 2011] - Fixed and clarified LEGACY 16-to-8 scaling code. - Added png_set_chop_16() API, to match inaccurate results from previous - libpng versions. - Removed the ACCURATE and LEGACY options (they are no longer useable) - Use the old scaling method for background if png_set_chop_16() was - called. - Made png_set_chop_16() API removeable by disabling PNG_CHOP_16_TO_8_SUPPORTED - -Version 1.5.4beta03 [June 15, 2011] - Fixed a problem in png_do_expand_palette() exposed by optimization in - 1.5.3beta06 - Also removed a spurious and confusing "trans" member ("trans") from png_info. - The palette expand optimization prevented expansion to an intermediate RGBA - form if tRNS was present but alpha was marked to be stripped; this exposed - a check for tRNS in png_do_expand_palette() which is inconsistent with the - code elsewhere in libpng. - Correction to the expand_16 code; removed extra instance of - png_set_scale_16_to_8 from pngpriv.h - -Version 1.5.4beta04 [June 16, 2011] - Added a missing "#ifdef PNG_READ_BACKGROUND_SUPPORTED/#endif" in pngrtran.c - Added PNG_TRANSFORM_CHOP_16 to the high-level read transforms. - Made PNG_READ_16_TO_8_ACCURATE_SCALE configurable again. If this is - not enabled, png_set_strip_16() and png_do_scale_16_to_8() aren't built. - Revised contrib/visupng, gregbook, and pngminim to demonstrate chop_16_to_8 - -Version 1.5.4beta05 [June 16, 2011] - Renamed png_set_strip_16() to png_set_scale_16() and renamed - png_set_chop_16() to png_set_strip(16) in an attempt to minimize the - behavior changes between libpng14 and libpng15. - -Version 1.5.4beta06 [June 18, 2011] - Fixed new bug that was causing both strip_16 and scale_16 to be applied. - -Version 1.5.4beta07 [June 19, 2011] - Fixed pngvalid, simplified macros, added checking for 0 in sCAL. - The ACCURATE scale macro is no longer defined in 1.5 - call the - png_scale_16_to_8 API. Made sure that PNG_READ_16_TO_8 is still defined - if the png_strip_16_to_8 API is present. png_check_fp_number now - maintains some state so that positive, negative and zero values are - identified. sCAL uses these to be strictly spec conformant. - -Version 1.5.4beta08 [June 23, 2011] - Fixed pngvalid if ACCURATE_SCALE is defined. - Updated scripts/pnglibconf.h.prebuilt. - -Version 1.5.4rc01 [June 30, 2011] - Define PNG_ALLOCATED to "restrict" only if MSC_VER >= 1400. - -Version 1.5.4 [July 7, 2011] - No changes. - -Version 1.5.5beta01 [July 13, 2011] - Fixed some typos and made other minor changes in the manual. - Updated contrib/pngminus/makefile.std (Samuli Souminen) - -Version 1.5.5beta02 [July 14, 2011] - Revised Makefile.am and Makefile.in to look in the right directory for - pnglibconf.h.prebuilt - -Version 1.5.5beta03 [July 27, 2011] - Enabled compilation with g++ compiler. This compiler does not recognize - the file extension, so it always compiles with C++ rules. Made minor - changes to pngrutil.c to cast results where C++ expects it but C does not. - Minor editing of libpng.3 and libpng-manual.txt. - -Version 1.5.5beta04 [July 29, 2011] - Revised CMakeLists.txt (Clifford Yapp) - Updated commentary about the png_rgb_to_gray() default coefficients - in the manual and in pngrtran.c - -Version 1.5.5beta05 [August 17, 2011] - Prevent unexpected API exports from non-libpng DLLs on Windows. The "_DLL" - is removed from the test of whether a DLL is being built (this erroneously - caused the libpng APIs to be marked as DLL exports in static builds under - Microsoft Visual Studio). Almost all of the libpng building configuration - is moved from pngconf.h to pngpriv.h, but PNG_DLL_EXPORT remains in - pngconf.h, though, so that it is colocated with the import definition (it - is no longer used anywhere in the installed headers). The VStudio project - definitions have been cleaned up: "_USRDLL" has been removed from the - static library builds (this was incorrect), and PNG_USE_DLL has been added - to pngvalid to test the functionality (pngtest does not supply it, - deliberately). The spurious "_EXPORTS" has been removed from the - libpng build (all these errors were a result of copy/paste between project - configurations.) - Added new types and internal functions for CIE RGB end point handling to - pngpriv.h (functions yet to be implemented). - -Version 1.5.5beta06 [August 26, 2011] - Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set in CMakeLists.txt - (Clifford Yap) - Fixes to rgb_to_gray and cHRM XYZ APIs (John Bowler): - The rgb_to_gray code had errors when combined with gamma correction. - Some pixels were treated as true grey when they weren't and such pixels - and true grey ones were not gamma corrected (the original value of the - red component was used instead). APIs to get and set cHRM using color - space end points have been added and the rgb_to_gray code that defaults - based on cHRM, and the divide-by-zero bug in png_handle_cHRM (CERT - VU#477046, CVE-2011-3328, introduced in 1.5.4) have been corrected. - A considerable number of tests has been added to pngvalid for the - rgb_to_gray transform. - Arithmetic errors in rgb_to_gray whereby the calculated gray value was - truncated to the bit depth rather than rounded have been fixed except in - the 8-bit non-gamma-corrected case (where consistency seems more important - than correctness.) The code still has considerable inaccuracies in the - 8-bit case because 8-bit linear arithmetic is used. - -Version 1.5.5beta07 [September 7, 2011] - Added "$(ARCH)" option to makefile.darwin - Added SunOS support to configure.ac and Makefile.am - Changed png_chunk_benign_error() to png_warning() in png.c, in - png_XYZ_from_xy_checked(). - -Version 1.5.5beta08 [September 10, 2011] - Fixed 64-bit compilation errors (gcc). The errors fixed relate - to conditions where types that are 32 bits in the GCC 32-bit - world (uLong and png_size_t) become 64 bits in the 64-bit - world. This produces potential truncation errors which the - compiler correctly flags. - Relocated new HAVE_SOLARIS_LD definition in configure.ac - Constant changes for 64-bit compatibility (removal of L suffixes). The - 16-bit cases still use "L" as we don't have a 16-bit test system. - -Version 1.5.5rc01 [September 15, 2011] - Removed "L" suffixes in pngpriv.h - -Version 1.5.5 [September 22, 2011] - No changes. - -Version 1.5.6beta01 [September 22, 2011] - Fixed some 64-bit type conversion warnings in pngrtran.c - Moved row_info from png_struct to a local variable. - The various interlace mask arrays have been made into arrays of - bytes and made PNG_CONST and static (previously some arrays were - marked PNG_CONST and some weren't). - Additional checks have been added to the transform code to validate the - pixel depths after the transforms on both read and write. - Removed some redundant code from pngwrite.c, in png_destroy_write_struct(). - Changed chunk reading/writing code to use png_uint_32 instead of png_byte[4]. - This removes the need to allocate temporary strings for chunk names on - the stack in the read/write code. Unknown chunk handling still uses the - string form because this is exposed in the API. - -Version 1.5.6beta02 [September 26, 2011] - Added a note in the manual the png_read_update_info() must be called only - once with a particular info_ptr. - Fixed a typo in the definition of the new PNG_STRING_FROM_CHUNK(s,c) macro. - -Version 1.5.6beta03 [September 28, 2011] - Revised test-pngtest.sh to report FAIL when pngtest fails. - Added "--strict" option to pngtest, to report FAIL when the failure is - only because the resulting valid files are different. - Revised CMakeLists.txt to work with mingw and removed some material from - CMakeLists.txt that is no longer useful in libpng-1.5. - -Version 1.5.6beta04 [October 5, 2011] - Fixed typo in Makefile.in and Makefile.am ("-M Wl" should be "-M -Wl")." - -Version 1.5.6beta05 [October 12, 2011] - Speed up png_combine_row() for interlaced images. This reduces the generality - of the code, allowing it to be optimized for Adam7 interlace. The masks - passed to png_combine_row() are now generated internally, avoiding - some code duplication and localizing the interlace handling somewhat. - Align png_struct::row_buf - previously it was always unaligned, caused by - a bug in the code that attempted to align it; the code needs to subtract - one from the pointer to take account of the filter byte prepended to - each row. - Optimized png_combine_row() when rows are aligned. This gains a small - percentage for 16-bit and 32-bit pixels in the typical case where the - output row buffers are appropriately aligned. The optimization was not - previously possible because the png_struct buffer was always misaligned. - Fixed bug in png_write_chunk_header() debug print, introduced in 1.5.6beta01. - -Version 1.5.6beta06 [October 17, 2011] - Removed two redundant tests for unitialized row. - Fixed a relatively harmless memory overwrite in compressed text writing - with a 1 byte zlib buffer. - Add ability to call png_read_update_info multiple times to pngvalid.c. - Fixes for multiple calls to png_read_update_info. These fixes attend to - most of the errors revealed in pngvalid, however doing the gamma work - twice results in inaccuracies that can't be easily fixed. There is now - a warning in the code if this is going to happen. - Turned on multiple png_read_update_info in pngvalid transform tests. - Prevent libpng from overwriting unused bits at the end of the image when - it is not byte aligned, while reading. Prior to libpng-1.5.6 libpng would - overwrite the partial byte at the end of each row if the row width was not - an exact multiple of 8 bits and the image is not interlaced. - -Version 1.5.6beta07 [October 21, 2011] - Made png_ptr->prev_row an aligned pointer into png_ptr->big_prev_row - (Mans Rullgard). - -Version 1.5.6rc01 [October 26, 2011] - Changed misleading "Missing PLTE before cHRM" warning to "Out of place cHRM" - -Version 1.5.6rc02 [October 27, 2011] - Added LSR() macro to defend against buggy compilers that evaluate non-taken - code branches and complain about out-of-range shifts. - -Version 1.5.6rc03 [October 28, 2011] - Renamed the LSR() macro to PNG_LSR() and added PNG_LSL() macro. - Fixed compiler warnings with Intel and MSYS compilers. The logical shift - fix for Microsoft Visual C is required by other compilers, so this - enables that fix for all compilers when using compile-time constants. - Under MSYS 'byte' is a name declared in a system header file, so we - changed the name of a local variable to avoid the warnings that result. - Added #define PNG_ALIGN_TYPE PNG_ALIGN_NONE to contrib/pngminim/*/pngusr.h - -Version 1.5.6 [November 3, 2011] - No changes. - -Version 1.5.7beta01 [November 4, 2011] - Added support for ARM processor, when decoding all PNG up-filtered rows - and any other-filtered rows with 3 or 4 bytes per pixel (Mans Rullgard). - Fixed bug in pngvalid on early allocation failure; fixed type cast in - pngmem.c; pngvalid would attempt to call png_error() if the allocation - of a png_struct or png_info failed. This would probably have led to a - crash. The pngmem.c implementation of png_malloc() included a cast - to png_size_t which would fail on large allocations on 16-bit systems. - Fix for the preprocessor of the Intel C compiler. The preprocessor - splits adjacent @ signs with a space; this changes the concatentation - token from @-@-@ to PNG_JOIN; that should work with all compiler - preprocessors. - Paeth filter speed improvements from work by Siarhei Siamashka. This - changes the 'Paeth' reconstruction function to improve the GCC code - generation on x86. The changes are only part of the suggested ones; - just the changes that definitely improve speed and remain simple. - The changes also slightly increase the clarity of the code. - -Version 1.5.7beta02 [November 11, 2011] - Check compression_type parameter in png_get_iCCP and remove spurious - casts. The compression_type parameter is always assigned to, so must - be non-NULL. The cast of the profile length potentially truncated the - value unnecessarily on a 16-bit int system, so the cast of the (byte) - compression type to (int) is specified by ANSI-C anyway. - Fixed FP division by zero in pngvalid.c; the 'test_pixel' code left - the sBIT fields in the test pixel as 0, which resulted in a floating - point division by zero which was irrelevant but causes systems where - FP exceptions cause a crash. Added code to pngvalid to turn on FP - exceptions if the appropriate glibc support is there to ensure this is - tested in the future. - Updated scripts/pnglibconf.mak and scripts/makefile.std to handle the - new PNG_JOIN macro. - Added versioning to pnglibconf.h comments. - Simplified read/write API initial version; basic read/write tested on - a variety of images, limited documentation (in the header file.) - Installed more accurate linear to sRGB conversion tables. The slightly - modified tables reduce the number of 16-bit values that - convert to an off-by-one 8-bit value. The "makesRGB.c" code that was used - to generate the tables is now in a contrib/sRGBtables sub-directory. - -Version 1.5.7beta03 [November 17, 2011] - Removed PNG_CONST from the sRGB table declarations in pngpriv.h and png.c - Added run-time detection of NEON support. - Added contrib/libtests; includes simplified API test and timing test and - a color conversion utility for rapid checking of failed 'pngstest' results. - Multiple transform bug fixes plus a work-round for double gamma correction. - libpng does not support more than one transform that requires linear data - at once - if this is tried typically the results is double gamma - correction. Since the simplified APIs can need rgb to gray combined with - a compose operation it is necessary to do one of these outside the main - libpng transform code. This check-in also contains fixes to various bugs - in the simplified APIs themselves and to some bugs in compose and rgb to - gray (on palette) itself. - Fixes for C++ compilation using g++ When libpng source is compiled - using g++. The compiler imposes C++ rules on the C source; thus it - is desireable to make the source work with either C or C++ rules - without throwing away useful error information. This change adds - png_voidcast to allow C semantic (void*) cases or the corresponding - C++ static_cast operation, as appropriate. - Added --noexecstack to assembler file compilation. GCC does not set - this on assembler compilation, even though it does on C compilation. - This creates security issues if assembler code is enabled; the - work-around is to set it by default in the flags for $(CCAS) - Work around compilers that don't support declaration of const data. Some - compilers fault 'extern const' data declarations (because the data is - not initialized); this turns on const-ness only for compilers where - this is known to work. - -Version 1.5.7beta04 [November 17, 2011] - Since the gcc driver does not recognize the --noexecstack flag, we must - use the -Wa prefix to have it passed through to the assembler. - Also removed a duplicate setting of this flag. - Added files that were omitted from the libpng-1.5.7beta03 zip distribution. - -Version 1.5.7beta05 [November 25, 2011] - Removed "zTXt" from warning in generic chunk decompression function. - Validate time settings passed to png_set_tIME() and png_convert_to_rfc1123() - (Frank Busse). Note: This prevented CVE-2015-7981 from affecting - libpng-1.5.7 and later. - Added MINGW support to CMakeLists.txt - Reject invalid compression flag or method when reading the iTXt chunk. - Backed out 'simplified' API changes. The API seems too complex and there - is a lack of consensus or enthusiasm for the proposals. The API also - reveals significant bugs inside libpng (double gamma correction and the - known bug of being unable to retrieve a corrected palette). It seems - better to wait until the bugs, at least, are corrected. - Moved pngvalid.c into contrib/libtests - Rebuilt Makefile.in, configure, etc., with autoconf-2.68 - -Version 1.5.7rc01 [December 1, 2011] - Replaced an "#if" with "#ifdef" in pngrtran.c - Revised #if PNG_DO_BC block in png.c (use #ifdef and add #else) - -Version 1.5.7rc02 [December 5, 2011] - Revised project files and contrib/pngvalid/pngvalid.c to account for - the relocation of pngvalid into contrib/libtests. - Revised pngconf.h to use " __declspec(restrict)" only when MSC_VER >= 1400, - as in libpng-1.5.4. - Put CRLF line endings in the owatcom project files. - -Version 1.5.7rc03 [December 7, 2011] - Updated CMakeLists.txt to account for the relocation of pngvalid.c - -Version 1.5.7 [December 15, 2011] - Minor fixes to pngvalid.c for gcc 4.6.2 compatibility to remove warnings - reported by earlier versions. - Fixed minor memset/sizeof errors in pngvalid.c. - -Version 1.6.0beta01 [December 15, 2011] - Removed machine-generated configure files from the GIT repository (they will - continue to appear in the tarball distributions and in the libpng15 and - earlier GIT branches). - Restored the new 'simplified' API, which was started in libpng-1.5.7beta02 - but later deleted from libpng-1.5.7beta05. - Added example programs for the new 'simplified' API. - Added ANSI-C (C90) headers and require them, and take advantage of the - change. Also fixed some of the projects/* and contrib/* files that needed - updates for libpng16 and the move of pngvalid.c. - With this change the required ANSI-C header files are assumed to exist: the - implementation must provide float.h, limits.h, stdarg.h and stddef.h and - libpng relies on limits.h and stddef.h existing and behaving as defined - (the other two required headers aren't used). Non-ANSI systems that don't - have stddef.h or limits.h will have to provide an appropriate fake - containing the relevant types and #defines. - Dropped support for 16-bit platforms. The use of FAR/far has been eliminated - and the definition of png_alloc_size_t is now controlled by a flag so - that 'small size_t' systems can select it if necessary. Libpng 1.6 may - not currently work on such systems -- it seems likely that it will - ask 'malloc' for more than 65535 bytes with any image that has a - sufficiently large row size (rather than simply failing to read such - images). - New tools directory containing tools used to generate libpng code. - Fixed race conditions in parallel make builds. With higher degrees of - parallelism during 'make' the use of the same temporary file names such - as 'dfn*' can result in a race where a temporary file from one arm of the - build is deleted or overwritten in another arm. This changes the - temporary files for suffix rules to always use $* and ensures that the - non-suffix rules use unique file names. - -Version 1.6.0beta02 [December 21, 2011] - Correct configure builds where build and source directories are separate. - The include path of 'config.h' was erroneously made relative in pngvalid.c - in libpng 1.5.7. - -Version 1.6.0beta03 [December 22, 2011] - Start-up code size improvements, error handler flexibility. These changes - alter how the tricky allocation of the initial png_struct and png_info - structures are handled. png_info is now handled in pretty much the same - way as everything else, except that the allocations handle NULL return - silently. png_struct is changed in a similar way on allocation and on - deallocation a 'safety' error handler is put in place (which should never - be required). The error handler itself is changed to permit mismatches - in the application and libpng error buffer size; however, this means a - silent change to the API to return the jmp_buf if the size doesn't match - the size from the libpng compilation; libpng now allocates the memory and - this may fail. Overall these changes result in slight code size - reductions; however, this is a reduction in code that is always executed - so is particularly valuable. Overall on a 64-bit system the libpng DLL - decreases in code size by 1733 bytes. pngerror.o increases in size by - about 465 bytes because of the new functionality. - Added png_convert_to_rfc1123_buffer() and deprecated png_convert_to_rfc1123() - to avoid including a spurious buffer in the png_struct. - -Version 1.6.0beta04 [December 30, 2011] - Regenerated configure scripts with automake-1.11.2 - Eliminated png_info_destroy(). It is now used only in png.c and only calls - one other internal function and memset(). - Enabled png_get_sCAL_fixed() if floating point APIs are enabled. Previously - it was disabled whenever internal fixed point arithmetic was selected, - which meant it didn't exist even on systems where FP was available but not - preferred. - Added pngvalid.c compile time checks for const APIs. - Implemented 'restrict' for png_info and png_struct. Because of the way - libpng works both png_info and png_struct are always accessed via a - single pointer. This means adding C99 'restrict' to the pointer gives - the compiler some opportunity to optimize the code. This change allows - that. - Moved AC_MSG_CHECKING([if libraries can be versioned]) later to the proper - location in configure.ac (Gilles Espinasse). - Changed png_memcpy to C assignment where appropriate. Changed all those - uses of png_memcpy that were doing a simple assignment to assignments - (all those cases where the thing being copied is a non-array C L-value). - Added some error checking to png_set_*() routines. - Removed the reference to the non-exported function png_memcpy() from - example.c. - Fixed the Visual C 64-bit build - it requires jmp_buf to be aligned, but - it had become misaligned. - Revised contrib/pngminus/pnm2png.c to avoid warnings when png_uint_32 - and unsigned long are of different sizes. - -Version 1.6.0beta05 [January 15, 2012] - Updated manual with description of the simplified API (copied from png.h) - Fix bug in pngerror.c: some long warnings were being improperly truncated - (CVE-2011-3464, bug introduced in libpng-1.5.3beta05). - -Version 1.6.0beta06 [January 24, 2012] - Added palette support to the simplified APIs. This commit - changes some of the macro definitions in png.h, app code - may need corresponding changes. - Increased the formatted warning buffer to 192 bytes. - Added color-map support to simplified API. This is an initial version for - review; the documentation has not yet been updated. - Fixed Min/GW uninstall to remove libpng.dll.a - -Version 1.6.0beta07 [January 28, 2012] - Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived) - compiler issues slightly different warnings from those issued by the - current vesions of GCC. This eliminates those warnings by - adding/removing casts and small code rewrites. - Updated configure.ac from autoupdate: added --enable-werror option. - Also some layout regularization and removal of introduced tab characters - (replaced with 3-character indentation). Obsolete macros identified by - autoupdate have been removed; the replacements are all in 2.59 so - the pre-req hasn't been changed. --enable-werror checks for support - for -Werror (or the given argument) in the compiler. This mimics the - gcc configure option by allowing -Werror to be turned on safely; without - the option the tests written in configure itself fail compilation because - they cause compiler warnings. - Rewrote autogen.sh to run autoreconf instead of running tools one-by-one. - Conditionalize the install rules for MINGW and CYGWIN in CMakeLists.txt and - set CMAKE_LIBRARY_OUTPUT_DIRECTORY to "lib" on all platforms (C. Yapp). - Freeze libtool files in the 'scripts' directory. This version of autogen.sh - attempts to dissuade people from running it when it is not, or should not, - be necessary. In fact, autogen.sh does not work when run in a libpng - directory extracted from a tar distribution anymore. You must run it in - a GIT clone instead. - Added two images to contrib/pngsuite (1-bit and 2-bit transparent grayscale), - and renamed three whose names were inconsistent with those in - pngsuite/README.txt. - -Version 1.6.0beta08 [February 1, 2012] - Fixed Image::colormap misalignment in pngstest.c - Check libtool/libtoolize version number (2.4.2) in configure.ac - Divide test-pngstest.sh into separate pngstest runs for basic and - transparent images. - Moved automake options to AM_INIT_AUTOMAKE in configure.ac - Added color-tests, silent-rules (Not yet implemented in Makefile.am) and - version checking to configure.ac - Improved pngstest speed by not doing redundant tests and add const to - the background parameter of png_image_finish_read. The --background - option is now done automagically only when required, so that commandline - option no longer exists. - Cleaned up pngpriv.h to consistently declare all functions and data. - Also eliminated PNG_CONST_DATA, which is apparently not needed but we - can't be sure until it is gone. - Added symbol prefixing that allows all the libpng external symbols - to be prefixed (suggested by Reuben Hawkins). - Updated "ftbb*.png" list in the owatcom and vstudio projects. - Fixed 'prefix' builds on clean systems. The generation of pngprefix.h - should not require itself. - Updated INSTALL to explain that autogen.sh must be run in a GIT clone, - not in a libpng directory extracted from a tar distribution. - -Version 1.6.0beta09 [February 1, 2012] - Reverted the prebuilt configure files to libpng-1.6.0beta05 condition. - -Version 1.6.0beta10 [February 3, 2012] - Added Z_SOLO for zlib-1.2.6+ and correct pngstest tests - Updated list of test images in CMakeLists.txt - Updated the prebuilt configure files to current condition. - Revised INSTALL information about autogen.sh; it works in tar distributions. - -Version 1.6.0beta11 [February 16, 2012] - Fix character count in pngstest command in projects/owatcom/pngstest.tgt - Revised test-pngstest.sh to report PASS/FAIL for each image. - Updated documentation about the simplified API. - Corrected estimate of error in libpng png_set_rgb_to_gray API. The API is - extremely inaccurate for sRGB conversions because it uses an 8-bit - intermediate linear value and it does not use the sRGB transform, so it - suffers from the known instability in gamma transforms for values close - to 0 (see Poynton). The net result is that the calculation has a maximum - error of 14.99/255; 0.5/255^(1/2.2). pngstest now uses 15 for the - permitted 8-bit error. This may still not be enough because of arithmetic - error. - Removed some unused arrays (with #ifdef) from png_read_push_finish_row(). - Fixed a memory overwrite bug in simplified read of RGB PNG with - non-linear gamma Also bugs in the error checking in pngread.c and changed - quite a lot of the checks in pngstest.c to be correct; either correctly - written or not over-optimistic. The pngstest changes are insufficient to - allow all possible RGB transforms to be passed; pngstest cmppixel needs - to be rewritten to make it clearer which errors it allows and then changed - to permit known inaccuracies. - Removed tests for no-longer-used *_EMPTY_PLTE_SUPPORTED from pngstruct.h - Fixed fixed/float API export conditionals. 1) If FIXED_POINT or - FLOATING_POINT options were switched off, png.h ended up with lone ';' - characters. This is not valid ANSI-C outside a function. The ';' - characters have been moved inside the definition of PNG_FP_EXPORT and - PNG_FIXED_EXPORT. 2) If either option was switched off, the declaration - of the corresponding functions were completely omitted, even though some - of them are still used internally. The result is still valid, but - produces warnings from gcc with some warning options (including -Wall). The - fix is to cause png.h to declare the functions with PNG_INTERNAL_FUNCTION - when png.h is included from pngpriv.h. - Check for invalid palette index while reading paletted PNG. When one is - found, issue a warning and increase png_ptr->num_palette accordingly. - Apps are responsible for checking to see if that happened. - -Version 1.6.0beta12 [February 18, 2012] - Do not increase num_palette on invalid_index. - Relocated check for invalid palette index to pngrtran.c, after unpacking - the sub-8-bit pixels. - Fixed CVE-2011-3026 buffer overrun bug. This bug was introduced when - iCCP chunk support was added at libpng-1.0.6. Deal more correctly with the - test on iCCP chunk length. Also removed spurious casts that may hide - problems on 16-bit systems. - -Version 1.6.0beta13 [February 24, 2012] - Eliminated redundant png_push_read_tEXt|zTXt|iTXt|unknown code from - pngpread.c and use the sequential png_handle_tEXt, etc., in pngrutil.c; - now that png_ptr->buffer is inaccessible to applications, the special - handling is no longer useful. - Added PNG_SAFE_LIMITS feature to pnglibconf.dfa, pngpriv.h, and new - pngusr.dfa to reset the user limits to safe ones if PNG_SAFE_LIMITS is - defined. To enable, use "CPPFLAGS=-DPNG_SAFE_LIMITS_SUPPORTED=1" on the - configure command or put #define PNG_SAFE_LIMITS_SUPPORTED in - pnglibconf.h.prebuilt and pnglibconf.h. - -Version 1.6.0beta14 [February 27, 2012] - Added information about the new limits in the manual. - Updated Makefile.in - -Version 1.6.0beta15 [March 2, 2012] - Removed unused "current_text" members of png_struct and the png_free() - of png_ptr->current_text from pngread.c - Rewrote pngstest.c for substantial speed improvement. - Fixed transparent pixel and 16-bit rgb tests in pngstest and removed a - spurious check in pngwrite.c - Added PNG_IMAGE_FLAG_FAST for the benefit of applications that store - intermediate files, or intermediate in-memory data, while processing - image data with the simplified API. The option makes the files larger - but faster to write and read. pngstest now uses this by default; this - can be disabled with the --slow option. - Improved pngstest fine tuning of error numbers, new test file generator. - The generator generates images that test the full range of sample values, - allow the error numbers in pngstest to be tuned and checked. makepng - also allows generation of images with extra chunks, although this is - still work-in-progress. - Added check for invalid palette index while reading. - Fixed some bugs in ICC profile writing. The code should now accept - all potentially valid ICC profiles and reject obviously invalid ones. - It now uses png_error() to do so rather than casually writing a PNG - without the necessary color data. - Removed whitespace from the end of lines in all source files and scripts. - -Version 1.6.0beta16 [March 6, 2012] - Relocated palette-index checking function from pngrutil.c to pngtrans.c - Added palette-index checking while writing. - Changed png_inflate() and calling routines to avoid overflow problems. - This is an intermediate check-in that solves the immediate problems and - introduces one performance improvement (avoiding a copy via png_ptr->zbuf.) - Further changes will be made to make ICC profile handling more secure. - Fixed build warnings (MSVC, GCC, GCC v3). Cygwin GCC with default options - declares 'index' as a global, causing a warning if it is used as a local - variable. GCC 64-bit warns about assigning a (size_t) (unsigned 64-bit) - to an (int) (signed 32-bit). MSVC, however, warns about using the - unary '-' operator on an unsigned value (even though it is well defined - by ANSI-C to be ~x+1). The padding calculation was changed to use a - different method. Removed the tests on png_ptr->pass. - Added contrib/libtests/tarith.c to test internal arithmetic functions from - png.c. This is a libpng maintainer program used to validate changes to the - internal arithmetic functions. - Made read 'inflate' handling like write 'deflate' handling. The read - code now claims and releases png_ptr->zstream, like the write code. - The bug whereby the progressive reader failed to release the zstream - is now fixed, all initialization is delayed, and the code checks for - changed parameters on deflate rather than always calling - deflatedEnd/deflateInit. - Validate the zTXt strings in pngvalid. - Added code to validate the windowBits value passed to deflateInit2(). - If the call to deflateInit2() is wrong a png_warning will be issued - (in fact this is harmless, but the PNG data produced may be sub-optimal). - -Version 1.6.0beta17 [March 10, 2012] - Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition. - Reject all iCCP chunks after the first, even if the first one is invalid. - Deflate/inflate was reworked to move common zlib calls into single - functions [rw]util.c. A new shared keyword check routine was also added - and the 'zbuf' is no longer allocated on progressive read. It is now - possible to call png_inflate() incrementally. A warning is no longer - issued if the language tag or translated keyword in the iTXt chunk - has zero length. - If benign errors are disabled use maximum window on ancilliary inflate. - This works round a bug introduced in 1.5.4 where compressed ancillary - chunks could end up with a too-small windowBits value in the deflate - header. - -Version 1.6.0beta18 [March 16, 2012] - Issue a png_benign_error() instead of png_warning() about bad palette index. - In pngtest, treat benign errors as errors if "-strict" is present. - Fixed an off-by-one error in the palette index checking function. - Fixed a compiler warning under Cygwin (Windows-7, 32-bit system) - Revised example.c to put text strings in a temporary character array - instead of directly assigning string constants to png_textp members. - This avoids compiler warnings when -Wwrite-strings is enabled. - Added output flushing to aid debugging under Visual Studio. Unfortunately - this is necessary because the VS2010 output window otherwise simply loses - the error messages on error (they weren't flushed to the window before - the process exited, apparently!) - Added configuration support for benign errors and changed the read - default. Also changed some warnings in the iCCP and sRGB handling - from to benign errors. Configuration now makes read benign - errors warnings and write benign errors to errors by default (thus - changing the behavior on read). The simplified API always forces - read benign errors to warnings (regardless of the system default, unless - this is disabled in which case the simplified API can't be built.) - -Version 1.6.0beta19 [March 18, 2012] - Work around for duplicate row start calls; added warning messages. - This turns on PNG_FLAG_DETECT_UNINITIALIZED to detect app code that - fails to call one of the 'start' routines (not enabled in libpng-1.5 - because it is technically an API change, since it did normally work - before.) It also makes duplicate calls to png_read_start_row (an - internal function called at the start of the image read) benign, as - they were before changes to use png_inflate_claim. Somehow webkit is - causing this to happen; this is probably a mis-feature in the zlib - changes so this commit is only a work-round. - Removed erroneous setting of DETECT_UNINITIALIZED and added more - checks. The code now does a png_error if an attempt is made to do the - row initialization twice; this is an application error and it has - serious consequences because the transform data in png_struct is - changed by each call. - Added application error reporting and added chunk names to read - benign errors; also added --strict to pngstest - not enabled - yet because a warning is produced. - Avoid the double gamma correction warning in the simplified API. - This allows the --strict option to pass in the pngstest checks - -Version 1.6.0beta20 [March 29, 2012] - Changed chunk handler warnings into benign errors, incrementally load iCCP - Added checksum-icc.c to contrib/tools - Prevent PNG_EXPAND+PNG_SHIFT doing the shift twice. - Recognize known sRGB ICC profiles while reading; prefer writing the - iCCP profile over writing the sRGB chunk, controlled by the - PNG_sRGB_PROFILE_CHECKS option. - Revised png_set_text_2() to avoid potential memory corruption (fixes - CVE-2011-3048, also known as CVE-2012-3425). - -Version 1.6.0beta21 [April 27, 2012] - Revised scripts/makefile.darwin: use system zlib; remove quotes around - architecture list; add missing ppc architecture; add architecture options - to shared library link; don't try to create a shared lib based on missing - RELEASE variable. - Enable png_set_check_for_invalid_index() for both read and write. - Removed #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED in pngpriv.h around - declaration of png_handle_unknown(). - Added -lssp_nonshared in a comment in scripts/makefile.freebsd - and changed deprecated NOOBJ and NOPROFILE to NO_OBJ and NO_PROFILE. - -Version 1.6.0beta22 [May 23, 2012] - Removed need for -Wno-cast-align with clang. clang correctly warns on - alignment increasing pointer casts when -Wcast-align is passed. This - fixes the cases that clang warns about either by eliminating the - casts from png_bytep to png_uint_16p (pngread.c), or, for pngrutil.c - where the cast is previously verified or pngstest.c where it is OK, by - introducing new png_aligncast macros to do the cast in a way that clang - accepts. - -Version 1.6.0beta23 [June 6, 2012] - Revised CMakeLists.txt to not attempt to make a symlink under mingw. - Made fixes for new optimization warnings from gcc 4.7.0. The compiler - performs an optimization which is safe; however it then warns about it. - Changing the type of 'palette_number' in pngvalid.c removes the warning. - Do not depend upon a GCC feature macro being available for use in generating - the linker mapfile symbol prefix. - Improved performance of new do_check_palette_indexes() function (only - update the value when it actually increases, move test for whether - the check is wanted out of the function. - -Version 1.6.0beta24 [June 7, 2012] - Don't check palette indexes if num_palette is 0 (as it can be in MNG files). - -Version 1.6.0beta25 [June 16, 2012] - Revised png_set_keep_unknown_chunks() so num_chunks < 0 means ignore all - unknown chunks and all known chunks except for IHDR, PLTE, tRNS, IDAT, - and IEND. Previously it only meant ignore all unknown chunks, the - same as num_chunks == 0. Revised png_image_skip_unused_chunks() to - provide a list of chunks to be processed instead of a list of chunks to - ignore. Revised contrib/gregbook/readpng2.c accordingly. - -Version 1.6.0beta26 [July 10, 2012] - Removed scripts/makefile.cegcc from the *.zip and *.7z distributions; it - depends on configure, which is not included in those archives. - Moved scripts/chkfmt to contrib/tools. - Changed "a+w" to "u+w" in Makefile.in to fix CVE-2012-3386. - -Version 1.6.0beta27 [August 11, 2012] - Do not compile PNG_DEPRECATED, PNG_ALLOC and PNG_PRIVATE when __GNUC__ < 3. - Do not use __restrict when GNUC is <= 3.1 - Removed references to png_zalloc() and png_zfree() from the manual. - Fixed configurations where floating point is completely disabled. Because - of the changes to support symbol prefixing PNG_INTERNAL_FUNCTION declares - floating point APIs during libpng builds even if they are completely - disabled. This requires the png floating point types (png_double*) to be - declared even though the functions are never actually defined. This - change provides a dummy definition so that the declarations work, yet any - implementation will fail to compile because of an incomplete type. - Re-eliminated the use of strcpy() in pngtest.c. An unncessary use of - strcpy() was accidentally re-introduced in libpng16; this change replaces - it with strncpy(). - Eliminated use of png_sizeof(); use sizeof() instead. - Use a consistent style for (sizeof type) and (sizeof (array)) - Cleanup of png_set_filler(). This function does very different things on - read and write. In libpng 1.6 the two cases can be distinguished and - considerable code cleanup, and extra error checking, is possible. This - makes calls on the write side that have no effect be ignored with a - png_app_error(), which can be disabled in the app using - png_set_benign_errors(), and removes the spurious use of usr_channels - on the read side. - Insist on autotools 1.12.1 for git builds because there are security issues - with 1.12 and insisting on anything less would allow 1.12 to be used. - Removed info_ptr->signature[8] from WRITE-only builds. - Add some conditions for compiling png_fixed(). This is a small function - but it requires "-lm" on some platforms. - Cause pngtest --strict to fail on any warning from libpng (not just errors) - and cause it not to fail at the comparison step if libpng lacks support - for writing chunks that it reads from the input (currently only implemented - for compressed text chunks). - Make all three "make check" test programs work without READ or WRITE support. - Now "make check" will succeed even if libpng is compiled with -DPNG_NO_READ - or -DPNG_NO_WRITE. The tests performed are reduced, but the basic reading - and writing of a PNG file is always tested by one or more of the tests. - Consistently use strlen(), memset(), memcpy(), and memcmp() instead of the - png_strlen(), png_memset(), png_memcpy(), and png_memcmp() macros. - Removed the png_sizeof(), png_strlen(), png_memset(), png_memcpy(), and - png_memcmp() macros. - Work around gcc 3.x and Microsoft Visual Studio 2010 complaints. Both object - to the split initialization of num_chunks. - -Version 1.6.0beta28 [August 29, 2012] - Unknown handling fixes and clean up. This adds more correct option - control of the unknown handling, corrects the pre-existing bug where - the per-chunk 'keep' setting is ignored and makes it possible to skip - IDAT chunks in the sequential reader (broken in earlier 1.6 versions). - There is a new test program, test-unknown.c, which is a work in progress - (not currently part of the test suite). Comments in the header files now - explain how the unknown handling works. - Allow fine grain control of unknown chunk APIs. This change allows - png_set_keep_unknown_chunks() to be turned off if not required and causes - both read and write to behave appropriately (on read this is only possible - if the user callback is used to handle unknown chunks). The change - also removes the support for storing unknown chunks in the info_struct - if the only unknown handling enabled is via the callback, allowing libpng - to be configured with callback reading and none of the unnecessary code. - Corrected fix for unknown handling in pngtest. This reinstates the - libpng handling of unknown chunks other than vpAg and sTER (including - unsafe-to-copy chunks which were dropped before) and eliminates the - repositioning of vpAg and sTER in pngtest.png by changing pngtest.png - (so the chunks are where libpng would put them). - Added "tunknown" test and corrected a logic error in png_handle_unknown() - when SAVE support is absent. Moved the shell test scripts for - contrib/libtests from the libpng top directory to contrib/libtests. - png_handle_unknown() must always read or skip the chunk, if - SAVE_UNKNOWN_CHUNKS is turned off *and* the application does not set - a user callback an unknown chunk will not be read, leading to a read - error, which was revealed by the "tunknown" test. - Cleaned up and corrected ICC profile handling. - contrib/libtests/makepng: corrected 'rgb' and 'gray' cases. profile_error - messages could be truncated; made a correct buffer size calculation and - adjusted pngerror.c appropriately. png_icc_check_* checking improved; - changed the functions to receive the correct color type of the PNG on read - or write and check that it matches the color space of the profile (despite - what the comments said before, there is danger in assuming the app will - cope correctly with an RGB profile on a grayscale image and, since it - violates the PNG spec, allowing it is certain to produce inconsistent - app behavior and might even cause app crashes.) Check that profiles - contain the tags needed to process the PNG (tags all required by the ICC - spec). Removed unused PNG_STATIC from pngpriv.h. - -Version 1.6.0beta29 [September 4, 2012] - Fixed the simplified API example programs to add the *colormap parameter - to several of he API and improved the error message if the version field - is not set. - Added contrib/examples/* to the *.zip and *.7z distributions. - Updated simplified API synopses and description of the png_image structure - in the manual. - Made makepng and pngtest produce identical PNGs, add "--relaxed" option - to pngtest. The "--relaxed" option turns off the benign errors that are - enabled by default in pre-RC builds. makepng can now write ICC profiles - where the length has not been extended to a multiple of 4, and pngtest - now intercepts all libpng errors, allowing the previously-introduced - "--strict test" on no warnings to actually work. - Improved ICC profile handling including cHRM chunk generation and fixed - Cygwin+MSVC build errors. The ICC profile handling now includes more - checking. Several errors that caused rejection of the profile are now - handled with a warning in such a way that the invalid profiles will be - read by default in release (but not pre-RC) builds but will not be - written by default. The easy part of handling the cHRM chunk is written, - where the ICC profile contains the required data. The more difficult - part plus guessing a gAMA value requires code to pass selected RGB values - through the profile. - -Version 1.6.0beta30 [October 24, 2012] - Changed ICC profile matrix/vector types to not depend on array type rules. - By the ANSI-C standard the new types should be identical to the previous - versions, and all known versions of gcc tested with the previous versions - except for GCC-4.2.1 work with this version. The change makes the ANSI-C - rule that const applied to an array of elements applies instead to the - elements in the array moot by explicitly applying const to the base - elements of the png_icc_matrix and png_icc_vector types. The accidental - (harmless) 'const' previously applied to the parameters of two of the - functions have also been removed. - Added a work around for GCC 4.2 optimization bug. - Marked the broken (bad white point) original HP sRGB profiles correctly and - correct comments. - Added -DZ_SOLO to contrib/pngminim/*/makefile to work with zlib-1.2.7 - Use /MDd for vstudio debug builds. Also added pngunkown to the vstudio - builds, fixed build errors and corrected a minor exit code error in - pngvalid if the 'touch' file name is invalid. - Add updated WARNING file to projects/vstudio from libpng 1.5/vstudio - Fixed build when using #define PNG_NO_READ_GAMMA in png_do_compose() in - pngrtran.c (Domani Hannes). - -Version 1.6.0beta31 [November 1, 2012] - Undid the erroneous change to vstudio/pngvalid build in libpng-1.6.0beta30. - Made pngvalid so that it will build outside the libpng source tree. - Made builds -DPNG_NO_READ_GAMMA compile (the unit tests still fail). - Made PNG_NO_READ_GAMMA switch off interfaces that depend on READ_GAMMA. - Prior to 1.6.0 switching off READ_GAMMA did unpredictable things to the - interfaces that use it (specifically, png_do_background in 1.4 would - simply display composite for grayscale images but do composition - with the incorrect arithmetic for color ones). In 1.6 the semantic - of -DPNG_NO_READ_GAMMA is changed to simply disable any interface that - depends on it; this obliges people who set it to consider whether they - really want it off if they happen to use any of the interfaces in - question (typically most users who disable it won't). - Fixed GUIDs in projects/vstudio. Some were duplicated or missing, - resulting in VS2010 having to update the files. - Removed non-working ICC profile support code that was mostly added to - libpng-1.6.0beta29 and beta30. There was too much code for too little - gain; implementing full ICC color correction may be desireable but is left - up to applications. - -Version 1.6.0beta32 [November 25, 2012] - Fixed an intermittent SEGV in pngstest due to an uninitialized array element. - Added the ability for contrib/libtests/makepng.c to make a PNG with just one - color. This is useful for debugging pngstest color inaccuracy reports. - Fixed error checking in the simplified write API (Olaf van der Spek) - Made png_user_version_check() ok to use with libpng version 1.10.x and later. - -Version 1.6.0beta33 [December 15, 2012] - Fixed typo in png.c (PNG_SET_CHUNK_MALLOC_MAX should be PNG_CHUNK_MALLOC_MAX) - that causes the MALLOC_MAX limit not to work (John Bowler) - Change png_warning() to png_app_error() in pngwrite.c and comment the - fall-through condition. - Change png_warning() to png_app_warning() in png_write_tRNS(). - Rearranged the ARM-NEON optimizations: Isolated the machine specific code - to the hardware subdirectory and added comments to pngrutil.c so that - implementors of other optimizations know what to do. - Fixed cases of unquoted DESTDIR in Makefile.am - Rebuilt Makefile.in, etc., with autoconf-2.69 and automake-1.12.5. - -Version 1.6.0beta34 [December 19, 2012] - Cleaned up whitespace in the synopsis portion of the manpage "libpng.3" - Disassembled the version number in scripts/options.awk (necessary for - building on SunOs). - -Version 1.6.0beta35 [December 23, 2012] - Made default Zlib compression settings be configurable. This adds #defines to - pnglibconf.h to control the defaults. - Fixed Windows build issues, enabled ARM compilation. Various warnings issued - by earlier versions of GCC fixed for Cygwin and Min/GW (which both use old - GCCs.) ARM support is enabled by default in zlib.props (unsupported by - Microsoft) and ARM compilation is made possible by deleting the check for - x86. The test programs cannot be run because they are not signed. - -Version 1.6.0beta36 [January 2, 2013] - Discontinued distributing libpng-1.x.x.tar.bz2. - Discontinued distributing libpng-1.7.0-1.6.0-diff.txt and similar. - Rebuilt configure with autoconf-2.69 (inadvertently not done in beta33) - Fixed 'make distcheck' on SUN OS - libpng.so was not being removed - -Version 1.6.0beta37 [January 10, 2013] - Fixed conceivable but difficult to repro overflow. Also added two test - programs to generate and test a PNG which should have the problem. - -Version 1.6.0beta39 [January 19, 2013] - Again corrected attempt at overflow detection in png_set_unknown_chunks() - (CVE-2013-7353). Added overflow detection in png_set_sPLT() and - png_set_text_2() (CVE-2013-7354). - -Version 1.6.0beta40 [January 20, 2013] - Use consistent handling of overflows in text, sPLT and unknown png_set_* APIs - -Version 1.6.0rc01 [January 26, 2013] - No changes. - -Version 1.6.0rc02 [February 4, 2013] - Added png_get_palette_max() function. - -Version 1.6.0rc03 [February 5, 2013] - Fixed the png_get_palette_max API. - -Version 1.6.0rc04 [February 7, 2013] - Turn serial tests back on (recently turned off by autotools upgrade). - -Version 1.6.0rc05 [February 8, 2013] - Update manual about png_get_palette_max(). - -Version 1.6.0rc06 [February 9, 2013] - Fixed missing dependency in --prefix builds The intermediate - internal 'prefix.h' file can only be generated correctly after - pnglibconf.h, however the dependency was not in Makefile.am. The - symptoms are unpredictable depending on the order make chooses to - build pngprefix.h and pnglibconf.h, often the error goes unnoticed - because there is a system pnglibconf.h to use instead. - -Version 1.6.0rc07 [February 10, 2013] - Enclosed the new png_get_palette_max in #ifdef PNG_GET_PALETTE_MAX_SUPPORTED - block, and revised pnglibconf.h and pnglibconf.h.prebuilt accordingly. - -Version 1.6.0rc08 [February 10, 2013] - Fix typo in png.h #ifdef - -Version 1.6.0 [February 14, 2013] - No changes. - -Version 1.6.1beta01 [February 16, 2013] - Made symbol prefixing work with the ARM neon optimizations. Also allow - pngpriv.h to be included for preprocessor definitions only, so it can - be used in non-C/C++ files. Back ported from libpng 1.7. - Made sRGB check numbers consistent. - Ported libpng 1.5 options.awk/dfn file handling to 1.6, fixed one bug. - Removed cc -E workround, corrected png_get_palette_max API Tested on - SUN OS cc 5.9, which demonstrates the tokenization problem previously - avoided by using /lib/cpp. Since all .dfn output is now protected in - double quotes unless it is to be macro substituted the fix should - work everywhere. - Enabled parallel tests - back ported from libpng-1.7. - scripts/pnglibconf.dfa formatting improvements back ported from libpng17. - Fixed a race condition in the creation of the build 'scripts' directory - while building with a parallel make. - Use approved/supported Android method to check for NEON, use Linux/POSIX - 1003.1 API to check /proc/self/auxv avoiding buffer allocation and other - library calls (ported from libpng15). - -Version 1.6.1beta02 [February 19, 2013] - Use parentheses more consistently in "#if defined(MACRO)" tests. - Folded long lines. - Reenabled code to allow zero length PLTE chunks for MNG. - -Version 1.6.1beta03 [February 22, 2013] - Fixed ALIGNED_MEMORY support. - Added a new configure option: - --enable-arm-neon=always will stop the run-time checks. New checks - within arm/arm_init.c will cause the code not to be compiled unless - __ARM_NEON__ is set. This should make it fail safe (if someone asks - for it on then the build will fail if it can't be done.) - Updated the INSTALL document. - -Version 1.6.1beta04 [February 27, 2013] - Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES. - Revised scripts/makefile.freebsd to respect ZLIBLIB and ZLIBINC. - Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble - with CRLF line endings. - -Version 1.6.1beta05 [March 1, 2013] - Avoid a possible memory leak in contrib/gregbook/readpng.c - -Version 1.6.1beta06 [March 4, 2013] - Better documentation of unknown handling API interactions. - Corrected Android builds and corrected libpng.vers with symbol - prefixing. It also makes those tests compile and link on Android. - Added an API png_set_option() to set optimization options externally, - providing an alternative and general solution for the non-portable - run-time tests used by the ARM Neon code, using the PNG_ARM_NEON option. - The order of settings vs options in pnglibconf.h is reversed to allow - settings to depend on options and options can now set (or override) the - defaults for settings. - -Version 1.6.1beta07 [March 7, 2013] - Corrected simplified API default gamma for color-mapped output, added - a flag to change default. In 1.6.0 when the simplified API was used - to produce color-mapped output from an input image with no gamma - information the gamma assumed for the input could be different from - that assumed for non-color-mapped output. In particular 16-bit depth - input files were assumed to be sRGB encoded, whereas in the 'direct' - case they were assumed to have linear data. This was an error. The - fix makes the simplified API treat all input files the same way and - adds a new flag to the png_image::flags member to allow the - application/user to specify that 16-bit files contain sRGB data - rather than the default linear. - Fixed bugs in the pngpixel and makepng test programs. - -Version 1.6.1beta08 [March 7, 2013] - Fixed CMakelists.txt to allow building a single variant of the library - (Claudio Bley): - Introduced a PNG_LIB_TARGETS variable that lists all activated library - targets. It is an error if this variable ends up empty, ie. you have - to build at least one library variant. - Made the *_COPY targets only depend on library targets actually being build. - Use PNG_LIB_TARGETS to unify a code path. - Changed the CREATE_SYMLINK macro to expect the full path to a file as the - first argument. When symlinking the filename component of that path is - determined and used as the link target. - Use copy_if_different in the CREATE_SYMLINK macro. - -Version 1.6.1beta09 [March 13, 2013] - Eliminated two warnings from the Intel C compiler. The warnings are - technically valid, although a reasonable treatment of division would - show it to be incorrect. - -Version 1.6.1rc01 [March 21, 2013] - No changes. - -Version 1.6.1 [March 28, 2013] - No changes. - -Version 1.6.2beta01 [April 14, 2013] - Updated documentation of 1.5.x to 1.6.x changes in iCCP chunk handling. - Fixed incorrect warning of excess deflate data. End condition - the - warning would be produced if the end of the deflate stream wasn't read - in the last row. The warning is harmless. - Corrected the test on user transform changes on read. It was in the - png_set of the transform function, but that doesn't matter unless the - transform function changes the rowbuf size, and that is only valid if - transform_info is called. - Corrected a misplaced closing bracket in contrib/libtests/pngvalid.c - (Flavio Medeiros). - Corrected length written to uncompressed iTXt chunks (Samuli Suominen). - Bug was introduced in libpng-1.6.0. - -Version 1.6.2rc01 [April 18, 2013] - Added contrib/tools/fixitxt.c, to repair the erroneous iTXt chunk length - written by libpng-1.6.0 and 1.6.1. - Disallow storing sRGB information when the sRGB is not supported. - -Version 1.6.2rc02 [April 18, 2013] - Merge pngtest.c with libpng-1.7.0 - -Version 1.6.2rc03 [April 22, 2013] - Trivial spelling cleanup. - -Version 1.6.2rc04 and 1.6.2rc05 [omitted] - -Version 1.6.2rc06 [April 24, 2013] - Reverted to version 1.6.2rc03. Recent changes to arm/neon support - have been ported to libpng-1.7.0beta09 and will reappear in version - 1.6.3beta01. - -Version 1.6.2 [April 25, 2013] - No changes. - -Version 1.6.3beta01 [April 25, 2013] - Revised stack marking in arm/filter_neon.S and configure.ac. - Ensure that NEON filter stuff is completely disabled when switched 'off'. - Previously the ARM NEON specific files were still built if the option - was switched 'off' as opposed to being explicitly disabled. - -Version 1.6.3beta02 [April 26, 2013] - Test for 'arm*' not just 'arm' in the host_cpu configure variable. - Rebuilt the configure scripts. - -Version 1.6.3beta03 [April 30, 2013] - Expanded manual paragraph about writing private chunks, particularly - the need to call png_set_keep_unknown_chunks() when writing them. - Avoid dereferencing NULL pointer possibly returned from - png_create_write_struct() (Andrew Church). - -Version 1.6.3beta05 [May 9, 2013] - Calculate our own zlib windowBits when decoding rather than trusting the - CMF bytes in the PNG datastream. - Added an option to force maximum window size for inflating, which was - the behavior of libpng15 and earlier, via a new PNG_MAXIMUM_INFLATE_WINDOW - option for png_set_options(). - Added png-fix-itxt and png-fix-too-far-back to the built programs and - removed warnings from the source code and timepng that are revealed as - a result. - Detect wrong libpng versions linked to png-fix-too-far-back, which currently - only works with libpng versions that can be made to reliably fail when - the deflate data contains an out-of-window reference. This means only - 1.6 and later. - Fixed gnu issues: g++ needs a static_cast, gcc 4.4.7 has a broken warning - message which it is easier to work round than ignore. - Updated contrib/pngminus/pnm2png.c (Paul Stewart): - Check for EOF - Ignore "#" delimited comments in input file to pnm2png.c. - Fixed whitespace handling - Added a call to png_set_packing() - Initialize dimension values so if sscanf fails at least we have known - invalid values. - Attempt to detect configuration issues with png-fix-too-far-back, which - requires both the correct libpng and the correct zlib to function - correctly. - Check ZLIB_VERNUM for mismatches, enclose #error in quotes - Added information in the documentation about problems with and fixes for - the bad CRC and bad iTXt chunk situations. - -Version 1.6.3beta06 [May 12, 2013] - Allow contrib/pngminus/pnm2png.c to compile without WRITE_INVERT and - WRITE_PACK supported (writes error message that it can't read P1 or - P4 PBM files). - Improved png-fix-too-far-back usage message, added --suffix option. - Revised contrib/pngminim/*/makefile to generate pnglibconf.h with the - right zlib header files. - Separated CPPFLAGS and CFLAGS in contrib/pngminim/*/makefile - -Version 1.6.3beta07 [June 8, 2013] - Removed a redundant test in png_set_IHDR(). - Added set(CMAKE_CONFIGURATION_TYPES ...) to CMakeLists.txt (Andrew Hundt) - Deleted set(CMAKE_BUILD_TYPE) block from CMakeLists.txt - Enclose the prototypes for the simplified write API in - #ifdef PNG_STDIO_SUPPORTED/#endif - Make ARM NEON support work at compile time (not just configure time). - This moves the test on __ARM_NEON__ into pngconf.h to avoid issues when - using a compiler that compiles for multiple architectures at one time. - Removed PNG_FILTER_OPTIMIZATIONS and PNG_ARM_NEON_SUPPORTED from - pnglibconf.h, allowing more of the decisions to be made internally - (pngpriv.h) during the compile. Without this, symbol prefixing is broken - under certain circumstances on ARM platforms. Now only the API parts of - the optimizations ('check' vs 'api') are exposed in the public header files - except that the new setting PNG_ARM_NEON_OPT documents how libpng makes the - decision about whether or not to use the optimizations. - Protect symbol prefixing against CC/CPPFLAGS/CFLAGS useage. - Previous iOS/Xcode fixes for the ARM NEON optimizations moved the test - on __ARM_NEON__ from configure time to compile time. This breaks symbol - prefixing because the definition of the special png_init_filter_functions - call was hidden at configure time if the relevant compiler arguments are - passed in CFLAGS as opposed to CC. This change attempts to avoid all - the confusion that would result by declaring the init function even when - it is not used, so that it will always get prefixed. - -Version 1.6.3beta08 [June 18, 2013] - Revised libpng.3 so that "doclifter" can process it. - -Version 1.6.3beta09 [June 27, 2013] - Revised example.c to illustrate use of PNG_DEFAULT_sRGB and PNG_GAMMA_MAC_18 - as parameters for png_set_gamma(). These have been available since - libpng-1.5.4. - Renamed contrib/tools/png-fix-too-far-back.c to pngfix.c and revised it - to check all compressed chunks known to libpng. - -Version 1.6.3beta10 [July 5, 2013] - Updated documentation to show default behavior of benign errors correctly. - Only compile ARM code when PNG_READ_SUPPORTED is defined. - Fixed undefined behavior in contrib/tools/pngfix.c and added new strip - option. pngfix relied on undefined behavior and even a simple change from - gcc to g++ caused it to fail. The new strip option 'unsafe' has been - implemented and is the default if --max is given. Option names have - been clarified, with --strip=transform now stripping the bKGD chunk, - which was stripped previously with --strip=unused. - Added all documented chunk types to pngpriv.h - Unified pngfix.c source with libpng17. - -Version 1.6.3rc01 [July 11, 2013] - No changes. - -Version 1.6.3 [July 18, 2013] - Revised manual about changes in iTXt chunk handling made in libpng-1.6.0. - Added "/* SAFE */" comments in pngrutil.c and pngrtran.c where warnings - may be erroneously issued by code-checking applications. - -Version 1.6.4beta01 [August 21, 2013] - Added information about png_set_options() to the manual. - Delay calling png_init_filter_functions() until a row with nonzero filter - is found. - -Version 1.6.4beta02 [August 30, 2013] - Fixed inconsistent conditional compilation of png_chunk_unknown_handling() - prototype, definition, and usage. Made it depend on - PNG_HANDLE_AS_UNKNOWN_SUPPORTED everywhere. - -Version 1.6.4rc01 [September 5, 2013] - No changes. - -Version 1.6.4 [September 12, 2013] - No changes. - -Version 1.6.5 [September 14, 2013] - Removed two stray lines of code from arm/arm_init.c. - -Version 1.6.6 [September 16, 2013] - Removed two stray lines of code from arm/arm_init.c, again. - -Version 1.6.7beta01 [September 30, 2013] - Revised unknown chunk code to correct several bugs in the NO_SAVE_/NO_WRITE - combination - Allow HANDLE_AS_UNKNOWN to work when other options are configured off. Also - fixed the pngminim makefiles to work when $(MAKEFLAGS) contains stuff - which terminates the make options (as by default in recent versions of - Gentoo). - Avoid up-cast warnings in pngvalid.c. On ARM the alignment requirements of - png_modifier are greater than that of png_store and as a consequence - compilation of pngvalid.c results in a warning about increased alignment - requirements because of the bare cast to (png_modifier*). The code is safe, - because the pointer is known to point to a stack allocated png_modifier, - but this change avoids the warning. - Fixed default behavior of ARM_NEON_API. If the ARM NEON API option was - compiled without the CHECK option it defaulted to on, not off. - Check user callback behavior in pngunknown.c. Previous versions compiled - if SAVE_UNKNOWN was not available but did nothing since the callback - was never implemented. - Merged pngunknown.c with 1.7 version and back ported 1.7 improvements/fixes - -Version 1.6.7beta02 [October 12, 2013] - Made changes for compatibility with automake 1.14: - 1) Added the 'compile' program to the list of programs that must be cleaned - in autogen.sh - 2) Added 'subdir-objects' which causes .c files in sub-directories to be - compiled such that the corresponding .o files are also in the - sub-directory. This is because automake 1.14 warns that the - current behavior of compiling to the top level directory may be removed - in the future. - 3) Updated dependencies on pnglibconf.h to match the new .o locations and - added all the files in contrib/libtests and contrib/tools that depend - on pnglibconf.h - 4) Added 'BUILD_SOURCES = pnglibconf.h'; this is the automake recommended - way of handling the dependencies of sources that are machine generated; - unfortunately it only works if the user does 'make all' or 'make check', - so the dependencies (3) are still required. - Cleaned up (char*) casts of zlib messages. The latest version of the Intel C - compiler complains about casting a string literal as (char*), so copied the - treatment of z_const from the library code into pngfix.c - Simplified error message code in pngunknown. The simplification has the - useful side effect of avoiding a bogus warning generated by the latest - version of the Intel C compiler (it objects to - condition ? string-literal : string-literal). - Make autogen.sh work with automake 1.13 as well as 1.14. Do this by always - removing the 1.14 'compile' script but never checking for it. - -Version 1.6.7beta03 [October 19, 2013] - Added ARMv8 support (James Yu ). Added file - arm/filter_neon_intrinsics.c; enable with -mfpu=neon. - Revised pngvalid to generate size images with as many filters as it can - manage, limited by the number of rows. - Cleaned up ARM NEON compilation handling. The tests are now in pngpriv.h - and detect the broken GCC compilers. - -Version 1.6.7beta04 [October 26, 2013] - Allow clang derived from older GCC versions to use ARM intrinsics. This - causes all clang builds that use -mfpu=neon to use the intrinsics code, - not the assembler code. This has only been tested on iOS 7. It may be - necessary to exclude some earlier clang versions but this seems unlikely. - Changed NEON implementation selection mechanism. This allows assembler - or intrinsics to be turned on at compile time during the build by defining - PNG_ARM_NEON_IMPLEMENTATION to the correct value (2 or 1). This macro - is undefined by default and the build type is selected in pngpriv.h. - -Version 1.6.7rc01 [November 2, 2013] - No changes. - -Version 1.6.7rc02 [November 7, 2013] - Fixed #include in filter_neon_intrinsics.c and ctype macros. The ctype char - checking macros take an unsigned char argument, not a signed char. - -Version 1.6.7 [November 14, 2013] - No changes. - -Version 1.6.8beta01 [November 24, 2013] - Moved prototype for png_handle_unknown() in pngpriv.h outside of - the #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED/#endif block. - Added "-Wall" to CFLAGS in contrib/pngminim/*/makefile - Conditionally compile some unused functions reported by -Wall in - pngminim. - Fixed 'minimal' builds. Various obviously useful minimal configurations - don't build because of missing contrib/libtests test programs and - overly complex dependencies in scripts/pnglibconf.dfa. This change - adds contrib/conftest/*.dfa files that can be used in automatic build - scripts to ensure that these configurations continue to build. - Enabled WRITE_INVERT and WRITE_PACK in contrib/pngminim/encoder. - Fixed pngvalid 'fail' function declaration on the Intel C Compiler. - This reverts to the previous 'static' implementation and works round - the 'unused static function' warning by using PNG_UNUSED(). - -Version 1.6.8beta02 [November 30, 2013] - Removed or marked PNG_UNUSED some harmless "dead assignments" reported - by clang scan-build. - Changed tabs to 3 spaces in png_debug macros and changed '"%s"m' - to '"%s" m' to improve portability among compilers. - Changed png_free_default() to free() in pngtest.c - -Version 1.6.8rc01 [December 12, 2013] - Tidied up pngfix inits and fixed pngtest no-write builds. - -Version 1.6.8rc02 [December 14, 2013] - Handle zero-length PLTE chunk or NULL palette with png_error() - instead of png_chunk_report(), which by default issues a warning - rather than an error, leading to later reading from a NULL pointer - (png_ptr->palette) in png_do_expand_palette(). This is CVE-2013-6954 - and VU#650142. Libpng-1.6.1 through 1.6.7 are vulnerable. - Libpng-1.6.0 and earlier do not have this bug. - -Version 1.6.8 [December 19, 2013] - No changes. - -Version 1.6.9beta01 [December 26, 2013] - Bookkeeping: Moved functions around (no changes). Moved transform - function definitions before the place where they are called so that - they can be made static. Move the intrapixel functions and the - grayscale palette builder out of the png?tran.c files. The latter - isn't a transform function and is no longer used internally, and the - former MNG specific functions are better placed in pngread/pngwrite.c - Made transform implementation functions static. This makes the internal - functions called by png_do_{read|write}_transformations static. On an - x86-64 DLL build (Gentoo Linux) this reduces the size of the text - segment of the DLL by 1208 bytes, about 0.6%. It also simplifies - maintenance by removing the declarations from pngpriv.h and allowing - easier changes to the internal interfaces. - Rebuilt configure scripts with automake-1.14.1 and autoconf-2.69 - in the tar distributions. - -Version 1.6.9beta02 [January 1, 2014] - Added checks for libpng 1.5 to pngvalid.c. This supports the use of - this version of pngvalid in libpng 1.5 - Merged with pngvalid.c from libpng-1.7 changes to create a single - pngvalid.c - Removed #error macro from contrib/tools/pngfix.c (Thomas Klausner). - Merged pngrio.c, pngtrans.c, pngwio.c, and pngerror.c with libpng-1.7.0 - Merged libpng-1.7.0 changes to make no-interlace configurations work - with test programs. - Revised pngvalid.c to support libpng 1.5, which does not support the - PNG_MAXIMUM_INFLATE_WINDOW option, so #define it out when appropriate in - pngvalid.c - Allow unversioned links created on install to be disabled in configure. - In configure builds 'make install' changes/adds links like png.h - and libpng.a to point to the newly installed, versioned, files (e.g. - libpng17/png.h and libpng17.a). Three new configure options and some - rearrangement of Makefile.am allow creation of these links to be disabled. - -Version 1.6.9beta03 [January 10, 2014] - Removed potentially misleading warning from png_check_IHDR(). - -Version 1.6.9beta04 [January 20, 2014] - Updated scripts/makefile.* to use CPPFLAGS (Cosmin). - Added clang attribute support (Cosmin). - -Version 1.6.9rc01 [January 28, 2014] - No changes. - -Version 1.6.9rc02 [January 30, 2014] - Quiet an uninitialized memory warning from VC2013 in png_get_png(). - -Version 1.6.9 [February 6, 2014] - -Version 1.6.10beta01 [February 9, 2014] - Backported changes from libpng-1.7.0beta30 and beta31: - Fixed a large number of instances where PNGCBAPI was omitted from - function definitions. - Added pngimage test program for png_read_png() and png_write_png() - with two new test scripts. - Removed dependence on !PNG_READ_EXPAND_SUPPORTED for calling - png_set_packing() in png_read_png(). - Fixed combination of ~alpha with shift. On read invert alpha, processing - occurred after shift processing, which causes the final values to be - outside the range that should be produced by the shift. Reversing the - order on read makes the two transforms work together correctly and mirrors - the order used on write. - Do not read invalid sBIT chunks. Previously libpng only checked sBIT - values on write, so a malicious PNG writer could therefore cause - the read code to return an invalid sBIT chunk, which might lead to - application errors or crashes. Such chunks are now skipped (with - chunk_benign_error). - Make png_read_png() and png_write_png() prototypes in png.h depend - upon PNG_READ_SUPPORTED and PNG_WRITE_SUPPORTED. - Support builds with unsupported PNG_TRANSFORM_* values. All of the - PNG_TRANSFORM_* values are always defined in png.h and, because they - are used for both read and write in some cases, it is not reliable - to #if out ones that are totally unsupported. This change adds error - detection in png_read_image() and png_write_image() to do a - png_app_error() if the app requests something that cannot be done - and it adds corresponding code to pngimage.c to handle such options - by not attempting to test them. - -Version 1.6.10beta02 [February 23, 2014] - Moved redefines of png_error(), png_warning(), png_chunk_error(), - and png_chunk_warning() from pngpriv.h to png.h to make them visible - to libpng-calling applications. - Moved OS dependent code from arm/arm_init.c, to allow the included - implementation of the ARM NEON discovery function to be set at - build-time and provide sample implementations from the current code in the - contrib/arm-neon subdirectory. The __linux__ code has also been changed to - compile and link on Android by using /proc/cpuinfo, and the old linux code - is in contrib/arm-neon/linux-auxv.c. The new code avoids POSIX and Linux - dependencies apart from opening /proc/cpuinfo and is C90 compliant. - Check for info_ptr == NULL early in png_read_end() so we don't need to - run all the png_handle_*() and depend on them to return if info_ptr == NULL. - This improves the performance of png_read_end(png_ptr, NULL) and makes - it more robust against future programming errors. - Check for __has_extension before using it in pngconf.h, to - support older Clang versions (Jeremy Sequoia). - Treat CRC error handling with png_set_crc_action(), instead of with - png_set_benign_errors(), which has been the case since libpng-1.6.0beta18. - Use a user warning handler in contrib/gregbook/readpng2.c instead of default, - so warnings will be put on stderr even if libpng has CONSOLE_IO disabled. - Added png_ptr->process_mode = PNG_READ_IDAT_MODE in png_push_read_chunk - after recognizing the IDAT chunk, which avoids an infinite loop while - reading a datastream whose first IDAT chunk is of zero-length. - This fixes CERT VU#684412 and CVE-2014-0333. - Don't recognize known sRGB profiles as sRGB if they have been hacked, - but don't reject them and don't issue a copyright violation warning. - -Version 1.6.10beta03 [February 25, 2014] - Moved some documentation from png.h to libpng.3 and libpng-manual.txt - Minor editing of contrib/arm-neon/README and contrib/examples/*.c - -Version 1.6.10rc01 [February 27, 2014] - Fixed typos in the manual and in scripts/pnglibconf.dfa (CFLAGS -> CPPFLAGS - and PNG_USR_CONFIG -> PNG_USER_CONFIG). - -Version 1.6.10rc02 [February 28, 2014] - Removed unreachable return statement after png_chunk_error() - in pngrutil.c - -Version 1.6.10rc03 [March 4, 2014] - Un-deprecated png_data_freer(). - -Version 1.6.10 [March 6, 2014] - No changes. - -Version 1.6.11beta01 [March 17, 2014] - Use "if (value != 0)" instead of "if (value)" consistently. - Changed ZlibSrcDir from 1.2.5 to 1.2.8 in projects/vstudio. - Moved configuration information from the manual to the INSTALL file. - -Version 1.6.11beta02 [April 6, 2014] - Removed #if/#else/#endif from inside two pow() calls in pngvalid.c because - they were handled improperly by Portland Group's PGI-14.1 - PGI-14.3 - when using its "__builtin_pow()" function. - Silence 'unused parameter' build warnings (Cosmin Truta). - $(CP) is now used alongside $(RM_F). Also, use 'copy' instead of 'cp' - where applicable, and applied other minor makefile changes (Cosmin). - Don't warn about invalid dimensions exceeding user limits (Cosmin). - Allow an easy replacement of the default pre-built configuration - header with a custom header, via the make PNGLIBCONF_H_PREBUILT - macro (Cosmin). - -Version 1.6.11beta03 [April 6, 2014] - Fixed a typo in pngrutil.c, introduced in libpng-1.5.6, that interferes - with "blocky" expansion of sub-8-bit interlaced PNG files (Eric Huss). - Optionally use __builtin_bswap16() in png_do_swap(). - -Version 1.6.11beta04 [April 19, 2014] - Made progressive reading of interlaced images consistent with the - behavior of the sequential reader and consistent with the manual, by - moving some code out of the PNG_READ_INTERLACING_SUPPORTED blocks. The - row_callback now receives the proper pass number and unexpanded rows, when - png_combine_row() isn't built or used, and png_set_interlace_handling() - is not called. - Allow PNG_sRGB_PROFILE_CHECKING = (-1) to mean no sRGB profile checking. - -Version 1.6.11beta05 [April 26, 2014] - Do not reject ICC V2 profiles that lack padding (Kai-Uwe Behrmann). - Relocated closing bracket of the sRGB profile test loop to avoid getting - "Not recognizing known sRGB profile that has been edited" warning for - ICC V2 profiles that lack the MD5 signature in the profile header. - -Version 1.6.11beta06 [May 19, 2014] - Added PNG_SKIP_sRGB_CHECK_PROFILE choice for png_set_option(). - -Version 1.6.11rc01 [May 27, 2014] - No changes. - -Version 1.6.11rc02 [June 3, 2014] - Test ZLIB_VERNUM instead of PNG_ZLIB_VERNUM in contrib/tools/pngfix.c - -Version 1.6.11 [June 5, 2014] - No changes. - -Version 1.6.12rc01 [June 6, 2014] - Relocated new code from 1.6.11beta06 in png.c to a point after the - declarations (Max Stepin). - -Version 1.6.12rc02 [June 7, 2014] - Changed file permissions of contrib/tools/intgamma.sh, - test-driver, and compile from 0644 to 0755 (Cosmin). - -Version 1.6.12rc03 [June 8, 2014] - Ensure "__has_attribute()" macro exists before trying to use it with - old clang compilers (MacPorts Ticket #43939). - -Version 1.6.12 [June 12, 2014] - No changes. - -Version 1.6.13beta01 [July 4, 2014] - Quieted -Wsign-compare and -Wclobber compiler warnings in - contrib/pngminus/*.c - Added "(void) png_ptr;" where needed in contrib/gregbook to quiet - compiler complaints about unused pointers. - Split a long output string in contrib/gregbook/rpng2-x.c. - Added "PNG_SET_OPTION" requirement for sRGB chunk support to pnglibconf.dfa, - Needed for write-only support (John Bowler). - Changed "if defined(__ARM_NEON__)" to - "if (defined(__ARM_NEON__) || defined(__ARM_NEON))" (James Wu). - Fixed clang no-warning builds: png_digit was defined but never used. - -Version 1.6.13beta02 [July 21, 2014] - Fixed an incorrect separator ("/" should be "\") in scripts/makefile.vcwin32 - (bug report from Wolfgang S. Kechel). Bug was introduced in libpng-1.6.11. - Also fixed makefile.bc32, makefile.bor, makefile.msc, makefile.intel, and - makefile.tc3 similarly. - -Version 1.6.13beta03 [August 3, 2014] - Removed scripts/makefile.elf. It has not worked since libpng-1.5.0beta14 - due to elimination of the PNG_FUNCTION_EXPORT and PNG_DATA_EXPORT - definitions from pngconf.h. - Ensure that CMakeLists.txt makes the target "lib" directory before making - symbolic link into it (SourceForge bug report #226 by Rolf Timmermans). - -Version 1.6.13beta04 [August 8, 2014] - Added opinion that the ECCN (Export Control Classification Number) for - libpng is EAR99 to the README file. - Eliminated use of "$<" in makefile explicit rules, when copying - $PNGLIBCONF_H_PREBUILT. This does not work on some versions of make; - bug introduced in libpng version 1.6.11. - -Version 1.6.13rc01 [August 14, 2014] - Made "ccopts" agree with "CFLAGS" in scripts/makefile.hp* and makefile.*sunu - -Version 1.6.13 [August 21, 2014] - No changes. - -Version 1.6.14beta01 [September 14, 2014] - Guard usage of png_ptr->options with #ifdef PNG_SET_OPTION_SUPPORTED. - Do not build contrib/tools/pngfix.c when PNG_SETJMP_NOT_SUPPORTED, - to allow "make" to complete without setjmp support (bug report by - Claudio Fontana) - Add "#include " to contrib/tools/pngfix.c (John Bowler) - -Version 1.6.14beta02 [September 18, 2014] - Use nanosleep() instead of usleep() in contrib/gregbook/rpng2-x.c - because usleep() is deprecated. - Define usleep() in contrib/gregbook/rpng2-x.c if not already defined - in unistd.h and nanosleep() is not available; fixes error introduced - in libpng-1.6.13. - Disable floating point exception handling in pngvalid.c when - PNG_FLOATING_ARITHMETIC is not supported (bug report by "zootus - at users.sourceforge.net"). - -Version 1.6.14beta03 [September 19, 2014] - Define FE_DIVBYZERO, FE_INVALID, and FE_OVERFLOW in pngvalid.c if not - already defined. Revert floating point exception handling in pngvalid.c - to version 1.6.14beta01 behavior. - -Version 1.6.14beta04 [September 27, 2014] - Fixed incorrect handling of the iTXt compression flag in pngrutil.c - (bug report by Shunsaku Hirata). Bug was introduced in libpng-1.6.0. - -Version 1.6.14beta05 [October 1, 2014] - Added "option READ_iCCP enables READ_COMPRESSED_TEXT" to pnglibconf.dfa - -Version 1.6.14beta06 [October 5, 2014] - Removed unused "text_len" parameter from private function png_write_zTXt(). - Conditionally compile some code in png_deflate_claim(), when - PNG_WARNINGS_SUPPORTED and PNG_ERROR_TEXT_SUPPORTED are disabled. - Replaced repeated code in pngpread.c with PNG_PUSH_SAVE_BUFFER_IF_FULL. - Added "chunk iTXt enables TEXT" and "chunk zTXt enables TEXT" - to pnglibconf.dfa. - Removed "option READ_COMPRESSED_TEXT enables READ_TEXT" from pnglibconf.dfa, - to make it possible to configure a libpng that supports iCCP but not TEXT. - -Version 1.6.14beta07 [October 7, 2014] - Removed "option WRITE_COMPRESSED_TEXT enables WRITE_TEXT" from pnglibconf.dfa - Only mark text chunks as written after successfully writing them. - -Version 1.6.14rc01 [October 15, 2014] - Fixed some typos in comments. - -Version 1.6.14rc02 [October 17, 2014] - Changed png_convert_to_rfc_1123() to png_convert_to_rfc_1123_buffer() - in the manual, to reflect the change made in libpng-1.6.0. - Updated README file to explain that direct access to the png_struct - and info_struct members has not been permitted since libpng-1.5.0. - -Version 1.6.14 [October 23, 2014] - No changes. - -Version 1.6.15beta01 [October 29, 2014] - Changed "if (!x)" to "if (x == 0)" and "if (x)" to "if (x != 0)" - Simplified png_free_data(). - Added missing "ptr = NULL" after some instances of png_free(). - -Version 1.6.15beta02 [November 1, 2014] - Changed remaining "if (!x)" to "if (x == 0)" and "if (x)" to "if (x != 0)" - -Version 1.6.15beta03 [November 3, 2014] - Added PNG_USE_ARM_NEON configuration flag (Marcin Juszkiewicz). - -Version 1.6.15beta04 [November 4, 2014] - Removed new PNG_USE_ARM_NEON configuration flag and made a one-line - revision to configure.ac to support ARM on aarch64 instead (John Bowler). - -Version 1.6.15beta05 [November 5, 2014] - Use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING in - example.c, pngtest.c, and applications in the contrib directory. - Avoid out-of-bounds memory access in png_user_version_check(). - Simplified and future-proofed png_user_version_check(). - Fixed GCC unsigned int->float warnings. Various versions of GCC - seem to generate warnings when an unsigned value is implicitly - converted to double. This is probably a GCC bug but this change - avoids the issue by explicitly converting to (int) where safe. - Free all allocated memory in pngimage. The file buffer cache was left - allocated at the end of the program, harmless but it causes memory - leak reports from clang. - Fixed array size calculations to avoid warnings. At various points - in the code the number of elements in an array is calculated using - sizeof. This generates a compile time constant of type (size_t) which - is then typically assigned to an (unsigned int) or (int). Some versions - of GCC on 64-bit systems warn about the apparent narrowing, even though - the same compiler does apparently generate the correct, in-range, - numeric constant. This adds appropriate, safe, casts to make the - warnings go away. - -Version 1.6.15beta06 [November 6, 2014] - Reverted use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING - in the manual, example.c, pngtest.c, and applications in the contrib - directory. It was incorrect advice. - -Version 1.6.15beta07 [November 7, 2014] - Removed #ifdef PNG_16BIT_SUPPORTED/#endif around png_product2(); it is - needed by png_reciprocal2(). - Added #ifdef PNG_16BIT_SUPPORTED/#endif around png_log16bit() and - png_do_swap(). - Changed all "#endif /* PNG_FEATURE_SUPPORTED */" to "#endif /* FEATURE */" - -Version 1.6.15beta08 [November 8, 2014] - More housecleaning in *.h - -Version 1.6.15rc01 [November 13, 2014] - -Version 1.6.15rc02 [November 14, 2014] - The macros passed in the command line to Borland make were ignored if - similarly-named macros were already defined in makefiles. This behavior - is different from POSIX make and other make programs. Surround the - macro definitions with ifndef guards (Cosmin). - -Version 1.6.15rc03 [November 16, 2014] - Added "-D_CRT_SECURE_NO_WARNINGS" to CFLAGS in scripts/makefile.vcwin32. - Removed the obsolete $ARCH variable from scripts/makefile.darwin. - -Version 1.6.15 [November 20, 2014] - No changes. - -Version 1.6.16beta01 [December 14, 2014] - Added ".align 2" to arm/filter_neon.S to support old GAS assemblers that - don't do alignment correctly. - Revised Makefile.am and scripts/symbols.dfn to work with MinGW/MSYS - (Bob Friesenhahn). - -Version 1.6.16beta02 [December 15, 2014] - Revised Makefile.am and scripts/*.dfn again to work with MinGW/MSYS; - renamed scripts/*.dfn to scripts/*.c (John Bowler). - -Version 1.6.16beta03 [December 21, 2014] - Quiet a "comparison always true" warning in pngstest.c (John Bowler). - -Version 1.6.16rc01 [December 21, 2014] - Restored a test on width that was removed from png.c at libpng-1.6.9 - (Bug report by Alex Eubanks, CVE-2015-0973). - -Version 1.6.16rc02 [December 21, 2014] - Undid the update to pngrutil.c in 1.6.16rc01. - -Version 1.6.16rc03 [December 21, 2014] - Fixed an overflow in png_combine_row() with very wide interlaced images - (Bug report and fix by John Bowler, CVE-2014-9495). - -Version 1.6.16 [December 22, 2014] - No changes. - -Version 1.6.17beta01 [January 29, 2015] - Removed duplicate PNG_SAFE_LIMITS_SUPPORTED handling from pngconf.h - Corrected the width limit calculation in png_check_IHDR(). - Removed user limits from pngfix. Also pass NULL pointers to - png_read_row to skip the unnecessary row de-interlace stuff. - Added testing of png_set_packing() to pngvalid.c - Regenerated configure scripts in the *.tar distributions with libtool-2.4.4 - Implement previously untested cases of libpng transforms in pngvalid.c - Fixed byte order in png_do_read_filler() with 16-bit input. Previously - the high and low bytes of the filler, from png_set_filler() or from - png_set_add_alpha(), were read in the wrong order. - Made the check for out-of-range values in png_set_tRNS() detect - values that are exactly 2^bit_depth, and work on 16-bit platforms. - Merged some parts of libpng-1.6.17beta01 and libpng-1.7.0beta47. - Added #ifndef __COVERITY__ where needed in png.c, pngrutil.c and - pngset.c to avoid warnings about dead code. - Added "& 0xff" to many instances of expressions that are typecast - to (png_byte), to avoid Coverity warnings. - -Version 1.6.17beta02 [February 7, 2015] - Work around one more Coverity-scan dead-code warning. - Do not build png_product2() when it is unused. - -Version 1.6.17beta03 [February 17, 2015] - Display user limits in the output from pngtest. - Eliminated the PNG_SAFE_LIMITS macro and restored the 1-million-column - and 1-million-row default limits in pnglibconf.dfa, that can be reset - by the user at build time or run time. This provides a more robust - defense against DOS and as-yet undiscovered overflows. - -Version 1.6.17beta04 [February 21, 2015] - Added PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED macro, on by default. - Allow user to call png_get_IHDR() with NULL arguments (Reuben Hawkins). - Rebuilt configure scripts with automake-1.15 and libtool-2.4.6 - -Version 1.6.17beta05 [February 25, 2015] - Restored compiling of png_reciprocal2 with PNG_NO_16BIT. - -Version 1.6.17beta06 [February 27, 2015] - Moved png_set_filter() prototype into a PNG_WRITE_SUPPORTED block - of png.h. - Avoid runtime checks when converting integer to png_byte with - Visual Studio (Sergey Kosarevsky) - -Version 1.6.17rc01 [March 4, 2015] - No changes. - -Version 1.6.17rc02 [March 9, 2015] - Removed some comments that the configure script did not handle - properly from scripts/pnglibconf.dfa and pnglibconf.h.prebuilt. - Free the unknown_chunks structure even when it contains no data. - -Version 1.6.17rc03 [March 12, 2015] - Updated CMakeLists.txt to add OSX framework, change YES/NO to ON/OFF - for consistency, and remove some useless tests (Alexey Petruchik). - -Version 1.6.17rc04 [March 16, 2015] - Remove pnglibconf.h, pnglibconf.c, and pnglibconf.out instead of - pnglibconf.* in "make clean" (Cosmin). - Fix bug in calculation of maxbits, in png_write_sBIT, introduced - in libpng-1.6.17beta01 (John Bowler). - -Version 1.6.17rc05 [March 21, 2015] - Define PNG_FILTER_* and PNG_FILTER_VALUE_* in png.h even when WRITE - is not supported (John Bowler). This fixes an error introduced in - libpng-1.6.17beta06. - Reverted "& 0xff" additions of version 1.6.17beta01. Libpng passes - the Coverity scan without them. - -Version 1.6.17rc06 [March 23, 2015] - Remove pnglibconf.dfn and pnglibconf.pre with "make clean". - Reformatted some "&0xff" instances to "& 0xff". - Fixed simplified 8-bit-linear to sRGB alpha. The calculated alpha - value was wrong. It's not clear if this affected the final stored - value; in the obvious code path the upper and lower 8-bits of the - alpha value were identical and the alpha was truncated to 8-bits - rather than dividing by 257 (John Bowler). - -Version 1.6.17 [March 26, 2015] - No changes. - -Version 1.6.18beta01 [April 1, 2015] - Removed PNG_SET_CHUNK_[CACHE|MALLOC]_LIMIT_SUPPORTED macros. They - have been combined with PNG_SET_USER_LIMITS_SUPPORTED (resolves - bug report by Andrew Church). - Fixed rgb_to_gray checks and added tRNS checks to pngvalid.c. This - fixes some arithmetic errors that caused some tests to fail on - some 32-bit platforms (Bug reports by Peter Breitenlohner [i686] - and Petr Gajdos [i586]). - -Version 1.6.18beta02 [April 26, 2015] - Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler - (Bug report by Viktor Szakats). - -Version 1.6.18beta03 [May 6, 2015] - Replaced "unexpected" with an integer (0xabadca11) in pngset.c - where a long was expected, to avoid a compiler warning when PNG_DEBUG > 1. - Added contrib/examples/simpleover.c, to demonstrate how to handle - alpha compositing of multiple images, using the "simplified API" - and an example PNG generation tool, contrib/examples/genpng.c - (John Bowler). - -Version 1.6.18beta04 [May 20, 2015] - PNG_RELEASE_BUILD replaces tests where the code depended on the build base - type and can be defined on the command line, allowing testing in beta - builds (John Bowler). - Avoid Coverity issue 80858 (REVERSE NULL) in pngtest.c PNG_DEBUG builds. - Avoid a harmless potential integer overflow in png_XYZ_from_xy() (Bug - report from Christopher Ferris). - -Version 1.6.18beta05 [May 31, 2015] - Backport filter selection code from libpng-1.7.0beta51, to combine - sub_row, up_row, avg_row, and paeth_row into try_row and tst_row. - Changed png_voidcast(), etc., to voidcast(), etc., in contrib/tools/pngfix.c - to avoid confusion with the libpng private macros. - Fixed old cut&paste bug in the weighted filter selection code in - pngwutil.c, introduced in libpng-0.95, March 1997. - -Version 1.6.18beta06 [June 1, 2015] - Removed WRITE_WEIGHTED_FILTERED code, to save a few kbytes of the - compiled library size. It never worked properly and as far as we can - tell, no one uses it. The png_set_filter_heuristics() and - png_set_filter_heuristics_fixed() APIs are retained but deprecated - and do nothing. - -Version 1.6.18beta07 [June 6, 2015] - Removed non-working progressive reader 'skip' function. This - function has apparently never been used. It was implemented - to support back-door modification of png_struct in libpng-1.4.x - but (because it does nothing and cannot do anything) was apparently - never tested (John Bowler). - Fixed cexcept.h in which GCC 5 now reports that one of the auto - variables in the Try macro needs to be volatile to prevent value - being lost over the setjmp (John Bowler). - Fixed NO_WRITE_FILTER and -Wconversion build breaks (John Bowler). - Fix g++ build breaks (John Bowler). - Quieted some Coverity issues in pngfix.c, png-fix-itxt.c, pngvalid.c, - pngstest.c, and pngimage.c. Most seem harmless, but png-fix-itxt - would only work with iTXt chunks with length 255 or less. - Added #ifdef's to contrib/examples programs so people don't try - to compile them without the minimum required support enabled - (suggested by Flavio Medeiros). - -Version 1.6.18beta08 [June 30, 2015] - Eliminated the final two Coverity defects (insecure temporary file - handling in contrib/libtests/pngstest.c; possible overflow of - unsigned char in contrib/tools/png-fix-itxt.c). To use the "secure" - file handling, define PNG_USE_MKSTEMP, otherwise "tmpfile()" will - be used. - Removed some unused WEIGHTED_FILTER macros from png.h and pngstruct.h - -Version 1.6.18beta09 [July 5, 2015] - Removed some useless typecasts from contrib/tools/png-fix-itxt.c - Fixed a new signed-unsigned comparison in pngrtran.c (Max Stepin). - Replaced arbitrary use of 'extern' with #define PNG_LINKAGE_*. To - preserve API compatibility, the new defines all default to "extern" - (requested by Jan Nijtmans). - -Version 1.6.18rc01 [July 9, 2015] - Belatedly added Mans Rullgard and James Yu to the list of Contributing - Authors. - -Version 1.6.18rc02 [July 12, 2015] - Restored unused FILTER_HEURISTIC macros removed at libpng-1.6.18beta08 - to png.h to avoid compatibility warnings. - -Version 1.6.18rc03 [July 15, 2015] - Minor changes to the man page - -Version 1.6.18 [July 23, 2015] - No changes. - -Version 1.6.19beta01 [July 30, 2015] - Updated obsolete information about the simplified API macros in the - manual pages (Bug report by Arc Riley). - Avoid potentially dereferencing NULL info_ptr in png_info_init_3(). - Rearranged png.h to put the major sections in the same order as - in libpng17. - Eliminated unused PNG_COST_SHIFT, PNG_WEIGHT_SHIFT, PNG_COST_FACTOR, and - PNG_WEIGHT_FACTOR macros. - Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler - (Bug report by Viktor Szakats). Several warnings remain and are - unavoidable, where we test for overflow. - Fixed potential leak of png_pixels in contrib/pngminus/pnm2png.c - Fixed uninitialized variable in contrib/gregbook/rpng2-x.c - -Version 1.6.19beta02 [August 19, 2015] - Moved config.h.in~ from the "libpng_autotools_files" list to the - "libpng_autotools_extra" list in autogen.sh because it was causing a - false positive for missing files (bug report by Robert C. Seacord). - Removed unreachable "break" statements in png.c, pngread.c, and pngrtran.c - to suppress clang warnings (Bug report by Viktor Szakats). - Fixed some bad links in the man page. - Changed "n bit" to "n-bit" in comments. - Added signed/unsigned 16-bit safety net. This removes the dubious - 0x8000 flag definitions on 16-bit systems. They aren't supported - yet the defs *probably* work, however it seems much safer to do this - and be advised if anyone, contrary to advice, is building libpng 1.6 - on a 16-bit system. It also adds back various switch default clauses - for GCC; GCC errors out if they are not present (with an appropriately - high level of warnings). - Safely convert num_bytes to a png_byte in png_set_sig_bytes() (Robert - Seacord). - Fixed the recently reported 1's complement security issue by replacing - the value that is illegal in the PNG spec, in both signed and unsigned - values, with 0. Illegal unsigned values (anything greater than or equal - to 0x80000000) can still pass through, but since these are not illegal - in ANSI-C (unlike 0x80000000 in the signed case) the checking that - occurs later can catch them (John Bowler). - -Version 1.6.19beta03 [September 26, 2015] - Fixed png_save_int_32 when int is not 2's complement (John Bowler). - Updated libpng16 with all the recent test changes from libpng17, - including changes to pngvalid.c to ensure that the original, - distributed, version of contrib/visupng/cexcept.h can be used - (John Bowler). - pngvalid contains the correction to the use of SAVE/STORE_ - UNKNOWN_CHUNKS; a bug revealed by changes in libpng 1.7. More - tests contain the --strict option to detect warnings and the - pngvalid-standard test has been corrected so that it does not - turn on progressive-read. There is a separate test which does - that. (John Bowler) - Also made some signed/unsigned fixes. - Make pngstest error limits version specific. Splitting the machine - generated error structs out to a file allows the values to be updated - without changing pngstest.c itself. Since libpng 1.6 and 1.7 have - slightly different error limits this simplifies maintenance. The - makepngs.sh script has also been updated to more accurately reflect - current problems in libpng 1.7 (John Bowler). - Incorporated new test PNG files into make check. tests/pngstest-* - are changed so that the new test files are divided into 8 groups by - gamma and alpha channel. These tests have considerably better code - and pixel-value coverage than contrib/pngsuite; however,coverage is - still incomplete (John Bowler). - Removed the '--strict' in 1.6 because of the double-gamma-correction - warning, updated pngstest-errors.h for the errors detected with the - new contrib/testspngs PNG test files (John Bowler). - -Version 1.6.19beta04 [October 15, 2015] - Worked around rgb-to-gray issues in libpng 1.6. The previous - attempts to ignore the errors in the code aren't quite enough to - deal with the 'channel selection' encoding added to libpng 1.7; abort. - pngvalid.c is changed to drop this encoding in prior versions. - Fixed 'pow' macros in pngvalid.c. It is legal for 'pow' to be a - macro, therefore the argument list cannot contain preprocessing - directives. Make sure pow is a function where this happens. This is - a minimal safe fix, the issue only arises in non-performance-critical - code (bug report by Curtis Leach, fix by John Bowler). - Added sPLT support to pngtest.c - -Version 1.6.19rc01 [October 23, 2015] - No changes. - -Version 1.6.19rc02 [October 31, 2015] - Prevent setting or writing over-length PLTE chunk (Cosmin Truta). - Silently truncate over-length PLTE chunk while reading. - Libpng incorrectly calculated the output rowbytes when the application - decreased either the number of channels or the bit depth (or both) in - a user transform. This was safe; libpng overallocated buffer space - (potentially by quite a lot; up to 4 times the amount required) but, - from 1.5.4 on, resulted in a png_error (John Bowler). - -Version 1.6.19rc03 [November 3, 2015] - Fixed some inconsequential cut-and-paste typos in png_set_cHRM_XYZ_fixed(). - Clarified COPYRIGHT information to state explicitly that versions - are derived from previous versions. - Removed much of the long list of previous versions from png.h and - libpng.3. - -Version 1.6.19rc04 [November 5, 2015] - Fixed new bug with CRC error after reading an over-length palette - (bug report by Cosmin Truta). - -Version 1.6.19 [November 12, 2015] - Cleaned up coding style in png_handle_PLTE(). - -Send comments/corrections/commendations to png-mng-implement at lists.sf.net -(subscription required; visit -https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe) -or to glennrp at users.sourceforge.net - -Glenn R-P -#endif diff --git a/oversampling/WDL/libpng/LICENSE b/oversampling/WDL/libpng/LICENSE deleted file mode 100644 index 2433b50..0000000 --- a/oversampling/WDL/libpng/LICENSE +++ /dev/null @@ -1,112 +0,0 @@ - -This copy of the libpng notices is provided for your convenience. In case of -any discrepancy between this copy and the notices in the file png.h that is -included in the libpng distribution, the latter shall prevail. - -COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: - -If you modify libpng you may insert additional notices immediately following -this sentence. - -This code is released under the libpng license. - -libpng versions 1.0.7, July 1, 2000, through 1.6.19, November 12, 2015, are -Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, are -derived from libpng-1.0.6, and are distributed according to the same -disclaimer and license as libpng-1.0.6 with the following individuals -added to the list of Contributing Authors: - - Simon-Pierre Cadieux - Eric S. Raymond - Mans Rullgard - Cosmin Truta - Gilles Vollant - James Yu - -and with the following additions to the disclaimer: - - There is no warranty against interference with your enjoyment of the - library or against infringement. There is no warranty that our - efforts or the library will fulfill any of your particular purposes - or needs. This library is provided with all faults, and the entire - risk of satisfactory quality, performance, accuracy, and effort is with - the user. - -libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are -Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from -libpng-0.96, and are distributed according to the same disclaimer and -license as libpng-0.96, with the following individuals added to the list -of Contributing Authors: - - Tom Lane - Glenn Randers-Pehrson - Willem van Schaik - -libpng versions 0.89, June 1996, through 0.96, May 1997, are -Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88, -and are distributed according to the same disclaimer and license as -libpng-0.88, with the following individuals added to the list of -Contributing Authors: - - John Bowler - Kevin Bracey - Sam Bushell - Magnus Holmgren - Greg Roelofs - Tom Tanner - -libpng versions 0.5, May 1995, through 0.88, January 1996, are -Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - -For the purposes of this copyright and license, "Contributing Authors" -is defined as the following set of individuals: - - Andreas Dilger - Dave Martindale - Guy Eric Schalnat - Paul Schmidt - Tim Wegner - -The PNG Reference Library is supplied "AS IS". The Contributing Authors -and Group 42, Inc. disclaim all warranties, expressed or implied, -including, without limitation, the warranties of merchantability and of -fitness for any purpose. The Contributing Authors and Group 42, Inc. -assume no liability for direct, indirect, incidental, special, exemplary, -or consequential damages, which may result from the use of the PNG -Reference Library, even if advised of the possibility of such damage. - -Permission is hereby granted to use, copy, modify, and distribute this -source code, or portions hereof, for any purpose, without fee, subject -to the following restrictions: - - 1. The origin of this source code must not be misrepresented. - - 2. Altered versions must be plainly marked as such and must not - be misrepresented as being the original source. - - 3. This Copyright notice may not be removed or altered from any - source or altered source distribution. - -The Contributing Authors and Group 42, Inc. specifically permit, without -fee, and encourage the use of this source code as a component to -supporting the PNG file format in commercial products. If you use this -source code in a product, acknowledgment is not required but would be -appreciated. - -END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE. - -A "png_get_copyright" function is available, for convenient use in "about" -boxes and the like: - - printf("%s", png_get_copyright(NULL)); - -Also, the PNG logo (in PNG format, of course) is supplied in the -files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). - -Libpng is OSI Certified Open Source Software. OSI Certified Open Source is -a certification mark of the Open Source Initiative. OSI has not addressed -the additional disclaimers inserted at version 1.0.7. - -Glenn Randers-Pehrson -glennrp at users.sourceforge.net -November 12, 2015 diff --git a/oversampling/WDL/libpng/README b/oversampling/WDL/libpng/README deleted file mode 100644 index a9e64d4..0000000 --- a/oversampling/WDL/libpng/README +++ /dev/null @@ -1,215 +0,0 @@ -README for libpng version 1.6.19 - November 12, 2015 (shared library 16.0) -See the note about version numbers near the top of png.h - -See INSTALL for instructions on how to install libpng. - -Libpng comes in several distribution formats. Get libpng-*.tar.gz or -libpng-*.tar.xz or if you want UNIX-style line endings in the text files, -or lpng*.7z or lpng*.zip if you want DOS-style line endings. - -Version 0.89 was the first official release of libpng. Don't let the -fact that it's the first release fool you. The libpng library has been in -extensive use and testing since mid-1995. By late 1997 it had -finally gotten to the stage where there hadn't been significant -changes to the API in some time, and people have a bad feeling about -libraries with versions < 1.0. Version 1.0.0 was released in -March 1998. - -**** -Note that some of the changes to the png_info structure render this -version of the library binary incompatible with libpng-0.89 or -earlier versions if you are using a shared library. The type of the -"filler" parameter for png_set_filler() has changed from png_byte to -png_uint_32, which will affect shared-library applications that use -this function. - -To avoid problems with changes to the internals of png info_struct, -new APIs have been made available in 0.95 to avoid direct application -access to info_ptr. These functions are the png_set_ and -png_get_ functions. These functions should be used when -accessing/storing the info_struct data, rather than manipulating it -directly, to avoid such problems in the future. - -It is important to note that the APIs did not make current programs -that access the info struct directly incompatible with the new -library, through libpng-1.2.x. In libpng-1.4.x, which was meant to -be a transitional release, members of the png_struct and the -info_struct can still be accessed, but the compiler will issue a -warning about deprecated usage. Since libpng-1.5.0, direct access -to these structs is not allowed, and the definitions of the structs -reside in private pngstruct.h and pnginfo.h header files that are not -accessible to applications. It is strongly suggested that new -programs use the new APIs (as shown in example.c and pngtest.c), and -older programs be converted to the new format, to facilitate upgrades -in the future. -**** - -Additions since 0.90 include the ability to compile libpng as a -Windows DLL, and new APIs for accessing data in the info struct. -Experimental functions include the ability to set weighting and cost -factors for row filter selection, direct reads of integers from buffers -on big-endian processors that support misaligned data access, faster -methods of doing alpha composition, and more accurate 16->8 bit color -conversion. - -The additions since 0.89 include the ability to read from a PNG stream -which has had some (or all) of the signature bytes read by the calling -application. This also allows the reading of embedded PNG streams that -do not have the PNG file signature. As well, it is now possible to set -the library action on the detection of chunk CRC errors. It is possible -to set different actions based on whether the CRC error occurred in a -critical or an ancillary chunk. - -The changes made to the library, and bugs fixed are based on discussions -on the PNG-implement mailing list and not on material submitted -privately to Guy, Andreas, or Glenn. They will forward any good -suggestions to the list. - -For a detailed description on using libpng, read libpng-manual.txt. For -examples of libpng in a program, see example.c and pngtest.c. For usage -information and restrictions (what little they are) on libpng, see -png.h. For a description on using zlib (the compression library used by -libpng) and zlib's restrictions, see zlib.h - -I have included a general makefile, as well as several machine and -compiler specific ones, but you may have to modify one for your own needs. - -You should use zlib 1.0.4 or later to run this, but it MAY work with -versions as old as zlib 0.95. Even so, there are bugs in older zlib -versions which can cause the output of invalid compression streams for -some images. You will definitely need zlib 1.0.4 or later if you are -taking advantage of the MS-DOS "far" structure allocation for the small -and medium memory models. You should also note that zlib is a -compression library that is useful for more things than just PNG files. -You can use zlib as a drop-in replacement for fread() and fwrite() if -you are so inclined. - -zlib should be available at the same place that libpng is, or at zlib.net. - -You may also want a copy of the PNG specification. It is available -as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find -these at http://www.libpng.org/pub/png/documents/ - -This code is currently being archived at libpng.sf.net in the -[DOWNLOAD] area, and at ftp://ftp.simplesystems.org. If you can't find it -in any of those places, e-mail me, and I'll help you find it. - -I am not a lawyer, but I believe that the Export Control Classification -Number (ECCN) for libpng is EAR99, which means not subject to export -controls or International Traffic in Arms Regulations (ITAR) because it -is open source, publicly available software, that does not contain any -encryption software. See the EAR, paragraphs 734.3(b)(3) and 734.7(b). - -If you have any code changes, requests, problems, etc., please e-mail -them to me. Also, I'd appreciate any make files or project files, -and any modifications you needed to make to get libpng to compile, -along with a #define variable to tell what compiler/system you are on. -If you needed to add transformations to libpng, or wish libpng would -provide the image in a different way, drop me a note (and code, if -possible), so I can consider supporting the transformation. -Finally, if you get any warning messages when compiling libpng -(note: not zlib), and they are easy to fix, I'd appreciate the -fix. Please mention "libpng" somewhere in the subject line. Thanks. - -This release was created and will be supported by myself (of course -based in a large way on Guy's and Andreas' earlier work), and the PNG -development group. - -Send comments/corrections/commendations to png-mng-implement at -lists.sourceforge.net (subscription required; visit -https://lists.sourceforge.net/lists/listinfo/png-mng-implement -to subscribe) or to glennrp at users.sourceforge.net - -You can't reach Guy, the original libpng author, at the addresses -given in previous versions of this document. He and Andreas will -read mail addressed to the png-implement list, however. - -Please do not send general questions about PNG. Send them to -png-mng-misc at lists.sf.net (subscription required; visit -https://lists.sourceforge.net/lists/listinfo/png-mng-misc to -subscribe). If you have a question about something -in the PNG specification that is related to using libpng, send it -to me. Send me any questions that start with "I was using libpng, -and ...". If in doubt, send questions to me. I'll bounce them -to others, if necessary. - -Please do not send suggestions on how to change PNG. We have -been discussing PNG for twenty years now, and it is official and -finished. If you have suggestions for libpng, however, I'll -gladly listen. Even if your suggestion is not used immediately, -it may be used later. - -Files in this distribution: - - ANNOUNCE => Announcement of this version, with recent changes - CHANGES => Description of changes between libpng versions - KNOWNBUG => List of known bugs and deficiencies - LICENSE => License to use and redistribute libpng - README => This file - TODO => Things not implemented in the current library - Y2KINFO => Statement of Y2K compliance - example.c => Example code for using libpng functions - libpng.3 => manual page for libpng (includes libpng-manual.txt) - libpng-manual.txt => Description of libpng and its functions - libpngpf.3 => manual page for libpng's private functions - png.5 => manual page for the PNG format - png.c => Basic interface functions common to library - png.h => Library function and interface declarations (public) - pngpriv.h => Library function and interface declarations (private) - pngconf.h => System specific library configuration (public) - pngstruct.h => png_struct declaration (private) - pnginfo.h => png_info struct declaration (private) - pngdebug.h => debugging macros (private) - pngerror.c => Error/warning message I/O functions - pngget.c => Functions for retrieving info from struct - pngmem.c => Memory handling functions - pngbar.png => PNG logo, 88x31 - pngnow.png => PNG logo, 98x31 - pngpread.c => Progressive reading functions - pngread.c => Read data/helper high-level functions - pngrio.c => Lowest-level data read I/O functions - pngrtran.c => Read data transformation functions - pngrutil.c => Read data utility functions - pngset.c => Functions for storing data into the info_struct - pngtest.c => Library test program - pngtest.png => Library test sample image - pngtrans.c => Common data transformation functions - pngwio.c => Lowest-level write I/O functions - pngwrite.c => High-level write functions - pngwtran.c => Write data transformations - pngwutil.c => Write utility functions - arm => Contains optimized code for the ARM platform - contrib => Contributions - examples => Example programs - gregbook => source code for PNG reading and writing, from - Greg Roelofs' "PNG: The Definitive Guide", - O'Reilly, 1999 - libtests => Test programs - pngminim => Minimal decoder, encoder, and progressive decoder - programs demonstrating use of pngusr.dfa - pngminus => Simple pnm2png and png2pnm programs - pngsuite => Test images - tools => Various tools - visupng => Contains a MSVC workspace for VisualPng - projects => Contains project files and workspaces for - building a DLL - owatcom => Contains a WATCOM project for building libpng - visualc71 => Contains a Microsoft Visual C++ (MSVC) - workspace for building libpng and zlib - vstudio => Contains a Microsoft Visual C++ (MSVC) - workspace for building libpng and zlib - scripts => Directory containing scripts for building libpng: - (see scripts/README.txt for the list of scripts) - -Good luck, and happy coding. - --Glenn Randers-Pehrson (current maintainer, since 1998) - Internet: glennrp at users.sourceforge.net - --Andreas Eric Dilger (former maintainer, 1996-1997) - Internet: adilger at enel.ucalgary.ca - Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/ - --Guy Eric Schalnat (original author and former maintainer, 1995-1996) - (formerly of Group 42, Inc) - Internet: gschal at infinet.com diff --git a/oversampling/WDL/libpng/png.c b/oversampling/WDL/libpng/png.c deleted file mode 100644 index 757c755..0000000 --- a/oversampling/WDL/libpng/png.c +++ /dev/null @@ -1,4607 +0,0 @@ - -/* png.c - location for general purpose libpng functions - * - * Copyright (c) 2018-2019 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - */ - -#include "pngpriv.h" - -/* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_37 Your_png_h_is_not_version_1_6_37; - -#ifdef __GNUC__ -/* The version tests may need to be added to, but the problem warning has - * consistently been fixed in GCC versions which obtain wide-spread release. - * The problem is that many versions of GCC rearrange comparison expressions in - * the optimizer in such a way that the results of the comparison will change - * if signed integer overflow occurs. Such comparisons are not permitted in - * ANSI C90, however GCC isn't clever enough to work out that that do not occur - * below in png_ascii_from_fp and png_muldiv, so it produces a warning with - * -Wextra. Unfortunately this is highly dependent on the optimizer and the - * machine architecture so the warning comes and goes unpredictably and is - * impossible to "fix", even were that a good idea. - */ -#if __GNUC__ == 7 && __GNUC_MINOR__ == 1 -#define GCC_STRICT_OVERFLOW 1 -#endif /* GNU 7.1.x */ -#endif /* GNU */ -#ifndef GCC_STRICT_OVERFLOW -#define GCC_STRICT_OVERFLOW 0 -#endif - -/* Tells libpng that we have already handled the first "num_bytes" bytes - * of the PNG file signature. If the PNG data is embedded into another - * stream we can set num_bytes = 8 so that libpng will not attempt to read - * or write any of the magic bytes before it starts on the IHDR. - */ - -#ifdef PNG_READ_SUPPORTED -void PNGAPI -png_set_sig_bytes(png_structrp png_ptr, int num_bytes) -{ - unsigned int nb = (unsigned int)num_bytes; - - png_debug(1, "in png_set_sig_bytes"); - - if (png_ptr == NULL) - return; - - if (num_bytes < 0) - nb = 0; - - if (nb > 8) - png_error(png_ptr, "Too many bytes for PNG signature"); - - png_ptr->sig_bytes = (png_byte)nb; -} - -/* Checks whether the supplied bytes match the PNG signature. We allow - * checking less than the full 8-byte signature so that those apps that - * already read the first few bytes of a file to determine the file type - * can simply check the remaining bytes for extra assurance. Returns - * an integer less than, equal to, or greater than zero if sig is found, - * respectively, to be less than, to match, or be greater than the correct - * PNG signature (this is the same behavior as strcmp, memcmp, etc). - */ -int PNGAPI -png_sig_cmp(png_const_bytep sig, size_t start, size_t num_to_check) -{ - png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - - if (num_to_check > 8) - num_to_check = 8; - - else if (num_to_check < 1) - return (-1); - - if (start > 7) - return (-1); - - if (start + num_to_check > 8) - num_to_check = 8 - start; - - return ((int)(memcmp(&sig[start], &png_signature[start], num_to_check))); -} - -#endif /* READ */ - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -/* Function to allocate memory for zlib */ -PNG_FUNCTION(voidpf /* PRIVATE */, -png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED) -{ - png_alloc_size_t num_bytes = size; - - if (png_ptr == NULL) - return NULL; - - if (items >= (~(png_alloc_size_t)0)/size) - { - png_warning (png_voidcast(png_structrp, png_ptr), - "Potential overflow in png_zalloc()"); - return NULL; - } - - num_bytes *= items; - return png_malloc_warn(png_voidcast(png_structrp, png_ptr), num_bytes); -} - -/* Function to free memory for zlib */ -void /* PRIVATE */ -png_zfree(voidpf png_ptr, voidpf ptr) -{ - png_free(png_voidcast(png_const_structrp,png_ptr), ptr); -} - -/* Reset the CRC variable to 32 bits of 1's. Care must be taken - * in case CRC is > 32 bits to leave the top bits 0. - */ -void /* PRIVATE */ -png_reset_crc(png_structrp png_ptr) -{ - /* The cast is safe because the crc is a 32-bit value. */ - png_ptr->crc = (png_uint_32)crc32(0, Z_NULL, 0); -} - -/* Calculate the CRC over a section of data. We can only pass as - * much data to this routine as the largest single buffer size. We - * also check that this data will actually be used before going to the - * trouble of calculating it. - */ -void /* PRIVATE */ -png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, size_t length) -{ - int need_crc = 1; - - if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0) - { - if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == - (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) - need_crc = 0; - } - - else /* critical */ - { - if ((png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) != 0) - need_crc = 0; - } - - /* 'uLong' is defined in zlib.h as unsigned long; this means that on some - * systems it is a 64-bit value. crc32, however, returns 32 bits so the - * following cast is safe. 'uInt' may be no more than 16 bits, so it is - * necessary to perform a loop here. - */ - if (need_crc != 0 && length > 0) - { - uLong crc = png_ptr->crc; /* Should never issue a warning */ - - do - { - uInt safe_length = (uInt)length; -#ifndef __COVERITY__ - if (safe_length == 0) - safe_length = (uInt)-1; /* evil, but safe */ -#endif - - crc = crc32(crc, ptr, safe_length); - - /* The following should never issue compiler warnings; if they do the - * target system has characteristics that will probably violate other - * assumptions within the libpng code. - */ - ptr += safe_length; - length -= safe_length; - } - while (length > 0); - - /* And the following is always safe because the crc is only 32 bits. */ - png_ptr->crc = (png_uint_32)crc; - } -} - -/* Check a user supplied version number, called from both read and write - * functions that create a png_struct. - */ -int -png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver) -{ - /* Libpng versions 1.0.0 and later are binary compatible if the version - * string matches through the second '.'; we must recompile any - * applications that use any older library version. - */ - - if (user_png_ver != NULL) - { - int i = -1; - int found_dots = 0; - - do - { - i++; - if (user_png_ver[i] != PNG_LIBPNG_VER_STRING[i]) - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - if (user_png_ver[i] == '.') - found_dots++; - } while (found_dots < 2 && user_png_ver[i] != 0 && - PNG_LIBPNG_VER_STRING[i] != 0); - } - - else - png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - - if ((png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) != 0) - { -#ifdef PNG_WARNINGS_SUPPORTED - size_t pos = 0; - char m[128]; - - pos = png_safecat(m, (sizeof m), pos, - "Application built with libpng-"); - pos = png_safecat(m, (sizeof m), pos, user_png_ver); - pos = png_safecat(m, (sizeof m), pos, " but running with "); - pos = png_safecat(m, (sizeof m), pos, PNG_LIBPNG_VER_STRING); - PNG_UNUSED(pos) - - png_warning(png_ptr, m); -#endif - -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags = 0; -#endif - - return 0; - } - - /* Success return. */ - return 1; -} - -/* Generic function to create a png_struct for either read or write - this - * contains the common initialization. - */ -PNG_FUNCTION(png_structp /* PRIVATE */, -png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) -{ - png_struct create_struct; -# ifdef PNG_SETJMP_SUPPORTED - jmp_buf create_jmp_buf; -# endif - - /* This temporary stack-allocated structure is used to provide a place to - * build enough context to allow the user provided memory allocator (if any) - * to be called. - */ - memset(&create_struct, 0, (sizeof create_struct)); - - /* Added at libpng-1.2.6 */ -# ifdef PNG_USER_LIMITS_SUPPORTED - create_struct.user_width_max = PNG_USER_WIDTH_MAX; - create_struct.user_height_max = PNG_USER_HEIGHT_MAX; - -# ifdef PNG_USER_CHUNK_CACHE_MAX - /* Added at libpng-1.2.43 and 1.4.0 */ - create_struct.user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX; -# endif - -# ifdef PNG_USER_CHUNK_MALLOC_MAX - /* Added at libpng-1.2.43 and 1.4.1, required only for read but exists - * in png_struct regardless. - */ - create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX; -# endif -# endif - - /* The following two API calls simply set fields in png_struct, so it is safe - * to do them now even though error handling is not yet set up. - */ -# ifdef PNG_USER_MEM_SUPPORTED - png_set_mem_fn(&create_struct, mem_ptr, malloc_fn, free_fn); -# else - PNG_UNUSED(mem_ptr) - PNG_UNUSED(malloc_fn) - PNG_UNUSED(free_fn) -# endif - - /* (*error_fn) can return control to the caller after the error_ptr is set, - * this will result in a memory leak unless the error_fn does something - * extremely sophisticated. The design lacks merit but is implicit in the - * API. - */ - png_set_error_fn(&create_struct, error_ptr, error_fn, warn_fn); - -# ifdef PNG_SETJMP_SUPPORTED - if (!setjmp(create_jmp_buf)) -# endif - { -# ifdef PNG_SETJMP_SUPPORTED - /* Temporarily fake out the longjmp information until we have - * successfully completed this function. This only works if we have - * setjmp() support compiled in, but it is safe - this stuff should - * never happen. - */ - create_struct.jmp_buf_ptr = &create_jmp_buf; - create_struct.jmp_buf_size = 0; /*stack allocation*/ - create_struct.longjmp_fn = longjmp; -# endif - /* Call the general version checker (shared with read and write code): - */ - if (png_user_version_check(&create_struct, user_png_ver) != 0) - { - png_structrp png_ptr = png_voidcast(png_structrp, - png_malloc_warn(&create_struct, (sizeof *png_ptr))); - - if (png_ptr != NULL) - { - /* png_ptr->zstream holds a back-pointer to the png_struct, so - * this can only be done now: - */ - create_struct.zstream.zalloc = png_zalloc; - create_struct.zstream.zfree = png_zfree; - create_struct.zstream.opaque = png_ptr; - -# ifdef PNG_SETJMP_SUPPORTED - /* Eliminate the local error handling: */ - create_struct.jmp_buf_ptr = NULL; - create_struct.jmp_buf_size = 0; - create_struct.longjmp_fn = 0; -# endif - - *png_ptr = create_struct; - - /* This is the successful return point */ - return png_ptr; - } - } - } - - /* A longjmp because of a bug in the application storage allocator or a - * simple failure to allocate the png_struct. - */ - return NULL; -} - -/* Allocate the memory for an info_struct for the application. */ -PNG_FUNCTION(png_infop,PNGAPI -png_create_info_struct,(png_const_structrp png_ptr),PNG_ALLOCATED) -{ - png_inforp info_ptr; - - png_debug(1, "in png_create_info_struct"); - - if (png_ptr == NULL) - return NULL; - - /* Use the internal API that does not (or at least should not) error out, so - * that this call always returns ok. The application typically sets up the - * error handling *after* creating the info_struct because this is the way it - * has always been done in 'example.c'. - */ - info_ptr = png_voidcast(png_inforp, png_malloc_base(png_ptr, - (sizeof *info_ptr))); - - if (info_ptr != NULL) - memset(info_ptr, 0, (sizeof *info_ptr)); - - return info_ptr; -} - -/* This function frees the memory associated with a single info struct. - * Normally, one would use either png_destroy_read_struct() or - * png_destroy_write_struct() to free an info struct, but this may be - * useful for some applications. From libpng 1.6.0 this function is also used - * internally to implement the png_info release part of the 'struct' destroy - * APIs. This ensures that all possible approaches free the same data (all of - * it). - */ -void PNGAPI -png_destroy_info_struct(png_const_structrp png_ptr, png_infopp info_ptr_ptr) -{ - png_inforp info_ptr = NULL; - - png_debug(1, "in png_destroy_info_struct"); - - if (png_ptr == NULL) - return; - - if (info_ptr_ptr != NULL) - info_ptr = *info_ptr_ptr; - - if (info_ptr != NULL) - { - /* Do this first in case of an error below; if the app implements its own - * memory management this can lead to png_free calling png_error, which - * will abort this routine and return control to the app error handler. - * An infinite loop may result if it then tries to free the same info - * ptr. - */ - *info_ptr_ptr = NULL; - - png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); - memset(info_ptr, 0, (sizeof *info_ptr)); - png_free(png_ptr, info_ptr); - } -} - -/* Initialize the info structure. This is now an internal function (0.89) - * and applications using it are urged to use png_create_info_struct() - * instead. Use deprecated in 1.6.0, internal use removed (used internally it - * is just a memset). - * - * NOTE: it is almost inconceivable that this API is used because it bypasses - * the user-memory mechanism and the user error handling/warning mechanisms in - * those cases where it does anything other than a memset. - */ -PNG_FUNCTION(void,PNGAPI -png_info_init_3,(png_infopp ptr_ptr, size_t png_info_struct_size), - PNG_DEPRECATED) -{ - png_inforp info_ptr = *ptr_ptr; - - png_debug(1, "in png_info_init_3"); - - if (info_ptr == NULL) - return; - - if ((sizeof (png_info)) > png_info_struct_size) - { - *ptr_ptr = NULL; - /* The following line is why this API should not be used: */ - free(info_ptr); - info_ptr = png_voidcast(png_inforp, png_malloc_base(NULL, - (sizeof *info_ptr))); - if (info_ptr == NULL) - return; - *ptr_ptr = info_ptr; - } - - /* Set everything to 0 */ - memset(info_ptr, 0, (sizeof *info_ptr)); -} - -/* The following API is not called internally */ -void PNGAPI -png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr, - int freer, png_uint_32 mask) -{ - png_debug(1, "in png_data_freer"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (freer == PNG_DESTROY_WILL_FREE_DATA) - info_ptr->free_me |= mask; - - else if (freer == PNG_USER_WILL_FREE_DATA) - info_ptr->free_me &= ~mask; - - else - png_error(png_ptr, "Unknown freer parameter in png_data_freer"); -} - -void PNGAPI -png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, - int num) -{ - png_debug(1, "in png_free_data"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - -#ifdef PNG_TEXT_SUPPORTED - /* Free text item num or (if num == -1) all text items */ - if (info_ptr->text != NULL && - ((mask & PNG_FREE_TEXT) & info_ptr->free_me) != 0) - { - if (num != -1) - { - png_free(png_ptr, info_ptr->text[num].key); - info_ptr->text[num].key = NULL; - } - - else - { - int i; - - for (i = 0; i < info_ptr->num_text; i++) - png_free(png_ptr, info_ptr->text[i].key); - - png_free(png_ptr, info_ptr->text); - info_ptr->text = NULL; - info_ptr->num_text = 0; - info_ptr->max_text = 0; - } - } -#endif - -#ifdef PNG_tRNS_SUPPORTED - /* Free any tRNS entry */ - if (((mask & PNG_FREE_TRNS) & info_ptr->free_me) != 0) - { - info_ptr->valid &= ~PNG_INFO_tRNS; - png_free(png_ptr, info_ptr->trans_alpha); - info_ptr->trans_alpha = NULL; - info_ptr->num_trans = 0; - } -#endif - -#ifdef PNG_sCAL_SUPPORTED - /* Free any sCAL entry */ - if (((mask & PNG_FREE_SCAL) & info_ptr->free_me) != 0) - { - png_free(png_ptr, info_ptr->scal_s_width); - png_free(png_ptr, info_ptr->scal_s_height); - info_ptr->scal_s_width = NULL; - info_ptr->scal_s_height = NULL; - info_ptr->valid &= ~PNG_INFO_sCAL; - } -#endif - -#ifdef PNG_pCAL_SUPPORTED - /* Free any pCAL entry */ - if (((mask & PNG_FREE_PCAL) & info_ptr->free_me) != 0) - { - png_free(png_ptr, info_ptr->pcal_purpose); - png_free(png_ptr, info_ptr->pcal_units); - info_ptr->pcal_purpose = NULL; - info_ptr->pcal_units = NULL; - - if (info_ptr->pcal_params != NULL) - { - int i; - - for (i = 0; i < info_ptr->pcal_nparams; i++) - png_free(png_ptr, info_ptr->pcal_params[i]); - - png_free(png_ptr, info_ptr->pcal_params); - info_ptr->pcal_params = NULL; - } - info_ptr->valid &= ~PNG_INFO_pCAL; - } -#endif - -#ifdef PNG_iCCP_SUPPORTED - /* Free any profile entry */ - if (((mask & PNG_FREE_ICCP) & info_ptr->free_me) != 0) - { - png_free(png_ptr, info_ptr->iccp_name); - png_free(png_ptr, info_ptr->iccp_profile); - info_ptr->iccp_name = NULL; - info_ptr->iccp_profile = NULL; - info_ptr->valid &= ~PNG_INFO_iCCP; - } -#endif - -#ifdef PNG_sPLT_SUPPORTED - /* Free a given sPLT entry, or (if num == -1) all sPLT entries */ - if (info_ptr->splt_palettes != NULL && - ((mask & PNG_FREE_SPLT) & info_ptr->free_me) != 0) - { - if (num != -1) - { - png_free(png_ptr, info_ptr->splt_palettes[num].name); - png_free(png_ptr, info_ptr->splt_palettes[num].entries); - info_ptr->splt_palettes[num].name = NULL; - info_ptr->splt_palettes[num].entries = NULL; - } - - else - { - int i; - - for (i = 0; i < info_ptr->splt_palettes_num; i++) - { - png_free(png_ptr, info_ptr->splt_palettes[i].name); - png_free(png_ptr, info_ptr->splt_palettes[i].entries); - } - - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes = NULL; - info_ptr->splt_palettes_num = 0; - info_ptr->valid &= ~PNG_INFO_sPLT; - } - } -#endif - -#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED - if (info_ptr->unknown_chunks != NULL && - ((mask & PNG_FREE_UNKN) & info_ptr->free_me) != 0) - { - if (num != -1) - { - png_free(png_ptr, info_ptr->unknown_chunks[num].data); - info_ptr->unknown_chunks[num].data = NULL; - } - - else - { - int i; - - for (i = 0; i < info_ptr->unknown_chunks_num; i++) - png_free(png_ptr, info_ptr->unknown_chunks[i].data); - - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks = NULL; - info_ptr->unknown_chunks_num = 0; - } - } -#endif - -#ifdef PNG_eXIf_SUPPORTED - /* Free any eXIf entry */ - if (((mask & PNG_FREE_EXIF) & info_ptr->free_me) != 0) - { -# ifdef PNG_READ_eXIf_SUPPORTED - if (info_ptr->eXIf_buf) - { - png_free(png_ptr, info_ptr->eXIf_buf); - info_ptr->eXIf_buf = NULL; - } -# endif - if (info_ptr->exif) - { - png_free(png_ptr, info_ptr->exif); - info_ptr->exif = NULL; - } - info_ptr->valid &= ~PNG_INFO_eXIf; - } -#endif - -#ifdef PNG_hIST_SUPPORTED - /* Free any hIST entry */ - if (((mask & PNG_FREE_HIST) & info_ptr->free_me) != 0) - { - png_free(png_ptr, info_ptr->hist); - info_ptr->hist = NULL; - info_ptr->valid &= ~PNG_INFO_hIST; - } -#endif - - /* Free any PLTE entry that was internally allocated */ - if (((mask & PNG_FREE_PLTE) & info_ptr->free_me) != 0) - { - png_free(png_ptr, info_ptr->palette); - info_ptr->palette = NULL; - info_ptr->valid &= ~PNG_INFO_PLTE; - info_ptr->num_palette = 0; - } - -#ifdef PNG_INFO_IMAGE_SUPPORTED - /* Free any image bits attached to the info structure */ - if (((mask & PNG_FREE_ROWS) & info_ptr->free_me) != 0) - { - if (info_ptr->row_pointers != NULL) - { - png_uint_32 row; - for (row = 0; row < info_ptr->height; row++) - png_free(png_ptr, info_ptr->row_pointers[row]); - - png_free(png_ptr, info_ptr->row_pointers); - info_ptr->row_pointers = NULL; - } - info_ptr->valid &= ~PNG_INFO_IDAT; - } -#endif - - if (num != -1) - mask &= ~PNG_FREE_MUL; - - info_ptr->free_me &= ~mask; -} -#endif /* READ || WRITE */ - -/* This function returns a pointer to the io_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy() or png_read_destroy() are called. - */ -png_voidp PNGAPI -png_get_io_ptr(png_const_structrp png_ptr) -{ - if (png_ptr == NULL) - return (NULL); - - return (png_ptr->io_ptr); -} - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -# ifdef PNG_STDIO_SUPPORTED -/* Initialize the default input/output functions for the PNG file. If you - * use your own read or write routines, you can call either png_set_read_fn() - * or png_set_write_fn() instead of png_init_io(). If you have defined - * PNG_NO_STDIO or otherwise disabled PNG_STDIO_SUPPORTED, you must use a - * function of your own because "FILE *" isn't necessarily available. - */ -void PNGAPI -png_init_io(png_structrp png_ptr, png_FILE_p fp) -{ - png_debug(1, "in png_init_io"); - - if (png_ptr == NULL) - return; - - png_ptr->io_ptr = (png_voidp)fp; -} -# endif - -# ifdef PNG_SAVE_INT_32_SUPPORTED -/* PNG signed integers are saved in 32-bit 2's complement format. ANSI C-90 - * defines a cast of a signed integer to an unsigned integer either to preserve - * the value, if it is positive, or to calculate: - * - * (UNSIGNED_MAX+1) + integer - * - * Where UNSIGNED_MAX is the appropriate maximum unsigned value, so when the - * negative integral value is added the result will be an unsigned value - * correspnding to the 2's complement representation. - */ -void PNGAPI -png_save_int_32(png_bytep buf, png_int_32 i) -{ - png_save_uint_32(buf, (png_uint_32)i); -} -# endif - -# ifdef PNG_TIME_RFC1123_SUPPORTED -/* Convert the supplied time into an RFC 1123 string suitable for use in - * a "Creation Time" or other text-based time string. - */ -int PNGAPI -png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime) -{ - static const char short_months[12][4] = - {"Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - - if (out == NULL) - return 0; - - if (ptime->year > 9999 /* RFC1123 limitation */ || - ptime->month == 0 || ptime->month > 12 || - ptime->day == 0 || ptime->day > 31 || - ptime->hour > 23 || ptime->minute > 59 || - ptime->second > 60) - return 0; - - { - size_t pos = 0; - char number_buf[5]; /* enough for a four-digit year */ - -# define APPEND_STRING(string) pos = png_safecat(out, 29, pos, (string)) -# define APPEND_NUMBER(format, value)\ - APPEND_STRING(PNG_FORMAT_NUMBER(number_buf, format, (value))) -# define APPEND(ch) if (pos < 28) out[pos++] = (ch) - - APPEND_NUMBER(PNG_NUMBER_FORMAT_u, (unsigned)ptime->day); - APPEND(' '); - APPEND_STRING(short_months[(ptime->month - 1)]); - APPEND(' '); - APPEND_NUMBER(PNG_NUMBER_FORMAT_u, ptime->year); - APPEND(' '); - APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->hour); - APPEND(':'); - APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->minute); - APPEND(':'); - APPEND_NUMBER(PNG_NUMBER_FORMAT_02u, (unsigned)ptime->second); - APPEND_STRING(" +0000"); /* This reliably terminates the buffer */ - PNG_UNUSED (pos) - -# undef APPEND -# undef APPEND_NUMBER -# undef APPEND_STRING - } - - return 1; -} - -# if PNG_LIBPNG_VER < 10700 -/* To do: remove the following from libpng-1.7 */ -/* Original API that uses a private buffer in png_struct. - * Deprecated because it causes png_struct to carry a spurious temporary - * buffer (png_struct::time_buffer), better to have the caller pass this in. - */ -png_const_charp PNGAPI -png_convert_to_rfc1123(png_structrp png_ptr, png_const_timep ptime) -{ - if (png_ptr != NULL) - { - /* The only failure above if png_ptr != NULL is from an invalid ptime */ - if (png_convert_to_rfc1123_buffer(png_ptr->time_buffer, ptime) == 0) - png_warning(png_ptr, "Ignoring invalid time value"); - - else - return png_ptr->time_buffer; - } - - return NULL; -} -# endif /* LIBPNG_VER < 10700 */ -# endif /* TIME_RFC1123 */ - -#endif /* READ || WRITE */ - -png_const_charp PNGAPI -png_get_copyright(png_const_structrp png_ptr) -{ - PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */ -#ifdef PNG_STRING_COPYRIGHT - return PNG_STRING_COPYRIGHT -#else - return PNG_STRING_NEWLINE \ - "libpng version 1.6.37" PNG_STRING_NEWLINE \ - "Copyright (c) 2018-2019 Cosmin Truta" PNG_STRING_NEWLINE \ - "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \ - PNG_STRING_NEWLINE \ - "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ - "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ - PNG_STRING_NEWLINE; -#endif -} - -/* The following return the library version as a short string in the - * format 1.0.0 through 99.99.99zz. To get the version of *.h files - * used with your application, print out PNG_LIBPNG_VER_STRING, which - * is defined in png.h. - * Note: now there is no difference between png_get_libpng_ver() and - * png_get_header_ver(). Due to the version_nn_nn_nn typedef guard, - * it is guaranteed that png.c uses the correct version of png.h. - */ -png_const_charp PNGAPI -png_get_libpng_ver(png_const_structrp png_ptr) -{ - /* Version of *.c files used when building libpng */ - return png_get_header_ver(png_ptr); -} - -png_const_charp PNGAPI -png_get_header_ver(png_const_structrp png_ptr) -{ - /* Version of *.h files used when building libpng */ - PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */ - return PNG_LIBPNG_VER_STRING; -} - -png_const_charp PNGAPI -png_get_header_version(png_const_structrp png_ptr) -{ - /* Returns longer string containing both version and date */ - PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */ -#ifdef __STDC__ - return PNG_HEADER_VERSION_STRING -# ifndef PNG_READ_SUPPORTED - " (NO READ SUPPORT)" -# endif - PNG_STRING_NEWLINE; -#else - return PNG_HEADER_VERSION_STRING; -#endif -} - -#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED -/* NOTE: this routine is not used internally! */ -/* Build a grayscale palette. Palette is assumed to be 1 << bit_depth - * large of png_color. This lets grayscale images be treated as - * paletted. Most useful for gamma correction and simplification - * of code. This API is not used internally. - */ -void PNGAPI -png_build_grayscale_palette(int bit_depth, png_colorp palette) -{ - int num_palette; - int color_inc; - int i; - int v; - - png_debug(1, "in png_do_build_grayscale_palette"); - - if (palette == NULL) - return; - - switch (bit_depth) - { - case 1: - num_palette = 2; - color_inc = 0xff; - break; - - case 2: - num_palette = 4; - color_inc = 0x55; - break; - - case 4: - num_palette = 16; - color_inc = 0x11; - break; - - case 8: - num_palette = 256; - color_inc = 1; - break; - - default: - num_palette = 0; - color_inc = 0; - break; - } - - for (i = 0, v = 0; i < num_palette; i++, v += color_inc) - { - palette[i].red = (png_byte)(v & 0xff); - palette[i].green = (png_byte)(v & 0xff); - palette[i].blue = (png_byte)(v & 0xff); - } -} -#endif - -#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED -int PNGAPI -png_handle_as_unknown(png_const_structrp png_ptr, png_const_bytep chunk_name) -{ - /* Check chunk_name and return "keep" value if it's on the list, else 0 */ - png_const_bytep p, p_end; - - if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list == 0) - return PNG_HANDLE_CHUNK_AS_DEFAULT; - - p_end = png_ptr->chunk_list; - p = p_end + png_ptr->num_chunk_list*5; /* beyond end */ - - /* The code is the fifth byte after each four byte string. Historically this - * code was always searched from the end of the list, this is no longer - * necessary because the 'set' routine handles duplicate entries correctly. - */ - do /* num_chunk_list > 0, so at least one */ - { - p -= 5; - - if (memcmp(chunk_name, p, 4) == 0) - return p[4]; - } - while (p > p_end); - - /* This means that known chunks should be processed and unknown chunks should - * be handled according to the value of png_ptr->unknown_default; this can be - * confusing because, as a result, there are two levels of defaulting for - * unknown chunks. - */ - return PNG_HANDLE_CHUNK_AS_DEFAULT; -} - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\ - defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) -int /* PRIVATE */ -png_chunk_unknown_handling(png_const_structrp png_ptr, png_uint_32 chunk_name) -{ - png_byte chunk_string[5]; - - PNG_CSTRING_FROM_CHUNK(chunk_string, chunk_name); - return png_handle_as_unknown(png_ptr, chunk_string); -} -#endif /* READ_UNKNOWN_CHUNKS || HANDLE_AS_UNKNOWN */ -#endif /* SET_UNKNOWN_CHUNKS */ - -#ifdef PNG_READ_SUPPORTED -/* This function, added to libpng-1.0.6g, is untested. */ -int PNGAPI -png_reset_zstream(png_structrp png_ptr) -{ - if (png_ptr == NULL) - return Z_STREAM_ERROR; - - /* WARNING: this resets the window bits to the maximum! */ - return (inflateReset(&png_ptr->zstream)); -} -#endif /* READ */ - -/* This function was added to libpng-1.0.7 */ -png_uint_32 PNGAPI -png_access_version_number(void) -{ - /* Version of *.c files used when building libpng */ - return((png_uint_32)PNG_LIBPNG_VER); -} - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -/* Ensure that png_ptr->zstream.msg holds some appropriate error message string. - * If it doesn't 'ret' is used to set it to something appropriate, even in cases - * like Z_OK or Z_STREAM_END where the error code is apparently a success code. - */ -void /* PRIVATE */ -png_zstream_error(png_structrp png_ptr, int ret) -{ - /* Translate 'ret' into an appropriate error string, priority is given to the - * one in zstream if set. This always returns a string, even in cases like - * Z_OK or Z_STREAM_END where the error code is a success code. - */ - if (png_ptr->zstream.msg == NULL) switch (ret) - { - default: - case Z_OK: - png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected zlib return code"); - break; - - case Z_STREAM_END: - /* Normal exit */ - png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected end of LZ stream"); - break; - - case Z_NEED_DICT: - /* This means the deflate stream did not have a dictionary; this - * indicates a bogus PNG. - */ - png_ptr->zstream.msg = PNGZ_MSG_CAST("missing LZ dictionary"); - break; - - case Z_ERRNO: - /* gz APIs only: should not happen */ - png_ptr->zstream.msg = PNGZ_MSG_CAST("zlib IO error"); - break; - - case Z_STREAM_ERROR: - /* internal libpng error */ - png_ptr->zstream.msg = PNGZ_MSG_CAST("bad parameters to zlib"); - break; - - case Z_DATA_ERROR: - png_ptr->zstream.msg = PNGZ_MSG_CAST("damaged LZ stream"); - break; - - case Z_MEM_ERROR: - png_ptr->zstream.msg = PNGZ_MSG_CAST("insufficient memory"); - break; - - case Z_BUF_ERROR: - /* End of input or output; not a problem if the caller is doing - * incremental read or write. - */ - png_ptr->zstream.msg = PNGZ_MSG_CAST("truncated"); - break; - - case Z_VERSION_ERROR: - png_ptr->zstream.msg = PNGZ_MSG_CAST("unsupported zlib version"); - break; - - case PNG_UNEXPECTED_ZLIB_RETURN: - /* Compile errors here mean that zlib now uses the value co-opted in - * pngpriv.h for PNG_UNEXPECTED_ZLIB_RETURN; update the switch above - * and change pngpriv.h. Note that this message is "... return", - * whereas the default/Z_OK one is "... return code". - */ - png_ptr->zstream.msg = PNGZ_MSG_CAST("unexpected zlib return"); - break; - } -} - -/* png_convert_size: a PNGAPI but no longer in png.h, so deleted - * at libpng 1.5.5! - */ - -/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */ -#ifdef PNG_GAMMA_SUPPORTED /* always set if COLORSPACE */ -static int -png_colorspace_check_gamma(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_fixed_point gAMA, int from) - /* This is called to check a new gamma value against an existing one. The - * routine returns false if the new gamma value should not be written. - * - * 'from' says where the new gamma value comes from: - * - * 0: the new gamma value is the libpng estimate for an ICC profile - * 1: the new gamma value comes from a gAMA chunk - * 2: the new gamma value comes from an sRGB chunk - */ -{ - png_fixed_point gtest; - - if ((colorspace->flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 && - (png_muldiv(>est, colorspace->gamma, PNG_FP_1, gAMA) == 0 || - png_gamma_significant(gtest) != 0)) - { - /* Either this is an sRGB image, in which case the calculated gamma - * approximation should match, or this is an image with a profile and the - * value libpng calculates for the gamma of the profile does not match the - * value recorded in the file. The former, sRGB, case is an error, the - * latter is just a warning. - */ - if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0 || from == 2) - { - png_chunk_report(png_ptr, "gamma value does not match sRGB", - PNG_CHUNK_ERROR); - /* Do not overwrite an sRGB value */ - return from == 2; - } - - else /* sRGB tag not involved */ - { - png_chunk_report(png_ptr, "gamma value does not match libpng estimate", - PNG_CHUNK_WARNING); - return from == 1; - } - } - - return 1; -} - -void /* PRIVATE */ -png_colorspace_set_gamma(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_fixed_point gAMA) -{ - /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't - * occur. Since the fixed point representation is asymmetrical it is - * possible for 1/gamma to overflow the limit of 21474 and this means the - * gamma value must be at least 5/100000 and hence at most 20000.0. For - * safety the limits here are a little narrower. The values are 0.00016 to - * 6250.0, which are truly ridiculous gamma values (and will produce - * displays that are all black or all white.) - * - * In 1.6.0 this test replaces the ones in pngrutil.c, in the gAMA chunk - * handling code, which only required the value to be >0. - */ - png_const_charp errmsg; - - if (gAMA < 16 || gAMA > 625000000) - errmsg = "gamma value out of range"; - -# ifdef PNG_READ_gAMA_SUPPORTED - /* Allow the application to set the gamma value more than once */ - else if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 && - (colorspace->flags & PNG_COLORSPACE_FROM_gAMA) != 0) - errmsg = "duplicate"; -# endif - - /* Do nothing if the colorspace is already invalid */ - else if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0) - return; - - else - { - if (png_colorspace_check_gamma(png_ptr, colorspace, gAMA, - 1/*from gAMA*/) != 0) - { - /* Store this gamma value. */ - colorspace->gamma = gAMA; - colorspace->flags |= - (PNG_COLORSPACE_HAVE_GAMMA | PNG_COLORSPACE_FROM_gAMA); - } - - /* At present if the check_gamma test fails the gamma of the colorspace is - * not updated however the colorspace is not invalidated. This - * corresponds to the case where the existing gamma comes from an sRGB - * chunk or profile. An error message has already been output. - */ - return; - } - - /* Error exit - errmsg has been set. */ - colorspace->flags |= PNG_COLORSPACE_INVALID; - png_chunk_report(png_ptr, errmsg, PNG_CHUNK_WRITE_ERROR); -} - -void /* PRIVATE */ -png_colorspace_sync_info(png_const_structrp png_ptr, png_inforp info_ptr) -{ - if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0) - { - /* Everything is invalid */ - info_ptr->valid &= ~(PNG_INFO_gAMA|PNG_INFO_cHRM|PNG_INFO_sRGB| - PNG_INFO_iCCP); - -# ifdef PNG_COLORSPACE_SUPPORTED - /* Clean up the iCCP profile now if it won't be used. */ - png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, -1/*not used*/); -# else - PNG_UNUSED(png_ptr) -# endif - } - - else - { -# ifdef PNG_COLORSPACE_SUPPORTED - /* Leave the INFO_iCCP flag set if the pngset.c code has already set - * it; this allows a PNG to contain a profile which matches sRGB and - * yet still have that profile retrievable by the application. - */ - if ((info_ptr->colorspace.flags & PNG_COLORSPACE_MATCHES_sRGB) != 0) - info_ptr->valid |= PNG_INFO_sRGB; - - else - info_ptr->valid &= ~PNG_INFO_sRGB; - - if ((info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) - info_ptr->valid |= PNG_INFO_cHRM; - - else - info_ptr->valid &= ~PNG_INFO_cHRM; -# endif - - if ((info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0) - info_ptr->valid |= PNG_INFO_gAMA; - - else - info_ptr->valid &= ~PNG_INFO_gAMA; - } -} - -#ifdef PNG_READ_SUPPORTED -void /* PRIVATE */ -png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr) -{ - if (info_ptr == NULL) /* reduce code size; check here not in the caller */ - return; - - info_ptr->colorspace = png_ptr->colorspace; - png_colorspace_sync_info(png_ptr, info_ptr); -} -#endif -#endif /* GAMMA */ - -#ifdef PNG_COLORSPACE_SUPPORTED -/* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for - * cHRM, as opposed to using chromaticities. These internal APIs return - * non-zero on a parameter error. The X, Y and Z values are required to be - * positive and less than 1.0. - */ -static int -png_xy_from_XYZ(png_xy *xy, const png_XYZ *XYZ) -{ - png_int_32 d, dwhite, whiteX, whiteY; - - d = XYZ->red_X + XYZ->red_Y + XYZ->red_Z; - if (png_muldiv(&xy->redx, XYZ->red_X, PNG_FP_1, d) == 0) - return 1; - if (png_muldiv(&xy->redy, XYZ->red_Y, PNG_FP_1, d) == 0) - return 1; - dwhite = d; - whiteX = XYZ->red_X; - whiteY = XYZ->red_Y; - - d = XYZ->green_X + XYZ->green_Y + XYZ->green_Z; - if (png_muldiv(&xy->greenx, XYZ->green_X, PNG_FP_1, d) == 0) - return 1; - if (png_muldiv(&xy->greeny, XYZ->green_Y, PNG_FP_1, d) == 0) - return 1; - dwhite += d; - whiteX += XYZ->green_X; - whiteY += XYZ->green_Y; - - d = XYZ->blue_X + XYZ->blue_Y + XYZ->blue_Z; - if (png_muldiv(&xy->bluex, XYZ->blue_X, PNG_FP_1, d) == 0) - return 1; - if (png_muldiv(&xy->bluey, XYZ->blue_Y, PNG_FP_1, d) == 0) - return 1; - dwhite += d; - whiteX += XYZ->blue_X; - whiteY += XYZ->blue_Y; - - /* The reference white is simply the sum of the end-point (X,Y,Z) vectors, - * thus: - */ - if (png_muldiv(&xy->whitex, whiteX, PNG_FP_1, dwhite) == 0) - return 1; - if (png_muldiv(&xy->whitey, whiteY, PNG_FP_1, dwhite) == 0) - return 1; - - return 0; -} - -static int -png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) -{ - png_fixed_point red_inverse, green_inverse, blue_scale; - png_fixed_point left, right, denominator; - - /* Check xy and, implicitly, z. Note that wide gamut color spaces typically - * have end points with 0 tristimulus values (these are impossible end - * points, but they are used to cover the possible colors). We check - * xy->whitey against 5, not 0, to avoid a possible integer overflow. - */ - if (xy->redx < 0 || xy->redx > PNG_FP_1) return 1; - if (xy->redy < 0 || xy->redy > PNG_FP_1-xy->redx) return 1; - if (xy->greenx < 0 || xy->greenx > PNG_FP_1) return 1; - if (xy->greeny < 0 || xy->greeny > PNG_FP_1-xy->greenx) return 1; - if (xy->bluex < 0 || xy->bluex > PNG_FP_1) return 1; - if (xy->bluey < 0 || xy->bluey > PNG_FP_1-xy->bluex) return 1; - if (xy->whitex < 0 || xy->whitex > PNG_FP_1) return 1; - if (xy->whitey < 5 || xy->whitey > PNG_FP_1-xy->whitex) return 1; - - /* The reverse calculation is more difficult because the original tristimulus - * value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8 - * derived values were recorded in the cHRM chunk; - * (red,green,blue,white)x(x,y). This loses one degree of freedom and - * therefore an arbitrary ninth value has to be introduced to undo the - * original transformations. - * - * Think of the original end-points as points in (X,Y,Z) space. The - * chromaticity values (c) have the property: - * - * C - * c = --------- - * X + Y + Z - * - * For each c (x,y,z) from the corresponding original C (X,Y,Z). Thus the - * three chromaticity values (x,y,z) for each end-point obey the - * relationship: - * - * x + y + z = 1 - * - * This describes the plane in (X,Y,Z) space that intersects each axis at the - * value 1.0; call this the chromaticity plane. Thus the chromaticity - * calculation has scaled each end-point so that it is on the x+y+z=1 plane - * and chromaticity is the intersection of the vector from the origin to the - * (X,Y,Z) value with the chromaticity plane. - * - * To fully invert the chromaticity calculation we would need the three - * end-point scale factors, (red-scale, green-scale, blue-scale), but these - * were not recorded. Instead we calculated the reference white (X,Y,Z) and - * recorded the chromaticity of this. The reference white (X,Y,Z) would have - * given all three of the scale factors since: - * - * color-C = color-c * color-scale - * white-C = red-C + green-C + blue-C - * = red-c*red-scale + green-c*green-scale + blue-c*blue-scale - * - * But cHRM records only white-x and white-y, so we have lost the white scale - * factor: - * - * white-C = white-c*white-scale - * - * To handle this the inverse transformation makes an arbitrary assumption - * about white-scale: - * - * Assume: white-Y = 1.0 - * Hence: white-scale = 1/white-y - * Or: red-Y + green-Y + blue-Y = 1.0 - * - * Notice the last statement of the assumption gives an equation in three of - * the nine values we want to calculate. 8 more equations come from the - * above routine as summarised at the top above (the chromaticity - * calculation): - * - * Given: color-x = color-X / (color-X + color-Y + color-Z) - * Hence: (color-x - 1)*color-X + color.x*color-Y + color.x*color-Z = 0 - * - * This is 9 simultaneous equations in the 9 variables "color-C" and can be - * solved by Cramer's rule. Cramer's rule requires calculating 10 9x9 matrix - * determinants, however this is not as bad as it seems because only 28 of - * the total of 90 terms in the various matrices are non-zero. Nevertheless - * Cramer's rule is notoriously numerically unstable because the determinant - * calculation involves the difference of large, but similar, numbers. It is - * difficult to be sure that the calculation is stable for real world values - * and it is certain that it becomes unstable where the end points are close - * together. - * - * So this code uses the perhaps slightly less optimal but more - * understandable and totally obvious approach of calculating color-scale. - * - * This algorithm depends on the precision in white-scale and that is - * (1/white-y), so we can immediately see that as white-y approaches 0 the - * accuracy inherent in the cHRM chunk drops off substantially. - * - * libpng arithmetic: a simple inversion of the above equations - * ------------------------------------------------------------ - * - * white_scale = 1/white-y - * white-X = white-x * white-scale - * white-Y = 1.0 - * white-Z = (1 - white-x - white-y) * white_scale - * - * white-C = red-C + green-C + blue-C - * = red-c*red-scale + green-c*green-scale + blue-c*blue-scale - * - * This gives us three equations in (red-scale,green-scale,blue-scale) where - * all the coefficients are now known: - * - * red-x*red-scale + green-x*green-scale + blue-x*blue-scale - * = white-x/white-y - * red-y*red-scale + green-y*green-scale + blue-y*blue-scale = 1 - * red-z*red-scale + green-z*green-scale + blue-z*blue-scale - * = (1 - white-x - white-y)/white-y - * - * In the last equation color-z is (1 - color-x - color-y) so we can add all - * three equations together to get an alternative third: - * - * red-scale + green-scale + blue-scale = 1/white-y = white-scale - * - * So now we have a Cramer's rule solution where the determinants are just - * 3x3 - far more tractible. Unfortunately 3x3 determinants still involve - * multiplication of three coefficients so we can't guarantee to avoid - * overflow in the libpng fixed point representation. Using Cramer's rule in - * floating point is probably a good choice here, but it's not an option for - * fixed point. Instead proceed to simplify the first two equations by - * eliminating what is likely to be the largest value, blue-scale: - * - * blue-scale = white-scale - red-scale - green-scale - * - * Hence: - * - * (red-x - blue-x)*red-scale + (green-x - blue-x)*green-scale = - * (white-x - blue-x)*white-scale - * - * (red-y - blue-y)*red-scale + (green-y - blue-y)*green-scale = - * 1 - blue-y*white-scale - * - * And now we can trivially solve for (red-scale,green-scale): - * - * green-scale = - * (white-x - blue-x)*white-scale - (red-x - blue-x)*red-scale - * ----------------------------------------------------------- - * green-x - blue-x - * - * red-scale = - * 1 - blue-y*white-scale - (green-y - blue-y) * green-scale - * --------------------------------------------------------- - * red-y - blue-y - * - * Hence: - * - * red-scale = - * ( (green-x - blue-x) * (white-y - blue-y) - - * (green-y - blue-y) * (white-x - blue-x) ) / white-y - * ------------------------------------------------------------------------- - * (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x) - * - * green-scale = - * ( (red-y - blue-y) * (white-x - blue-x) - - * (red-x - blue-x) * (white-y - blue-y) ) / white-y - * ------------------------------------------------------------------------- - * (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x) - * - * Accuracy: - * The input values have 5 decimal digits of accuracy. The values are all in - * the range 0 < value < 1, so simple products are in the same range but may - * need up to 10 decimal digits to preserve the original precision and avoid - * underflow. Because we are using a 32-bit signed representation we cannot - * match this; the best is a little over 9 decimal digits, less than 10. - * - * The approach used here is to preserve the maximum precision within the - * signed representation. Because the red-scale calculation above uses the - * difference between two products of values that must be in the range -1..+1 - * it is sufficient to divide the product by 7; ceil(100,000/32767*2). The - * factor is irrelevant in the calculation because it is applied to both - * numerator and denominator. - * - * Note that the values of the differences of the products of the - * chromaticities in the above equations tend to be small, for example for - * the sRGB chromaticities they are: - * - * red numerator: -0.04751 - * green numerator: -0.08788 - * denominator: -0.2241 (without white-y multiplication) - * - * The resultant Y coefficients from the chromaticities of some widely used - * color space definitions are (to 15 decimal places): - * - * sRGB - * 0.212639005871510 0.715168678767756 0.072192315360734 - * Kodak ProPhoto - * 0.288071128229293 0.711843217810102 0.000085653960605 - * Adobe RGB - * 0.297344975250536 0.627363566255466 0.075291458493998 - * Adobe Wide Gamut RGB - * 0.258728243040113 0.724682314948566 0.016589442011321 - */ - /* By the argument, above overflow should be impossible here. The return - * value of 2 indicates an internal error to the caller. - */ - if (png_muldiv(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 7) == 0) - return 2; - if (png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 7) == 0) - return 2; - denominator = left - right; - - /* Now find the red numerator. */ - if (png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 7) == 0) - return 2; - if (png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 7) == 0) - return 2; - - /* Overflow is possible here and it indicates an extreme set of PNG cHRM - * chunk values. This calculation actually returns the reciprocal of the - * scale value because this allows us to delay the multiplication of white-y - * into the denominator, which tends to produce a small number. - */ - if (png_muldiv(&red_inverse, xy->whitey, denominator, left-right) == 0 || - red_inverse <= xy->whitey /* r+g+b scales = white scale */) - return 1; - - /* Similarly for green_inverse: */ - if (png_muldiv(&left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 7) == 0) - return 2; - if (png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 7) == 0) - return 2; - if (png_muldiv(&green_inverse, xy->whitey, denominator, left-right) == 0 || - green_inverse <= xy->whitey) - return 1; - - /* And the blue scale, the checks above guarantee this can't overflow but it - * can still produce 0 for extreme cHRM values. - */ - blue_scale = png_reciprocal(xy->whitey) - png_reciprocal(red_inverse) - - png_reciprocal(green_inverse); - if (blue_scale <= 0) - return 1; - - - /* And fill in the png_XYZ: */ - if (png_muldiv(&XYZ->red_X, xy->redx, PNG_FP_1, red_inverse) == 0) - return 1; - if (png_muldiv(&XYZ->red_Y, xy->redy, PNG_FP_1, red_inverse) == 0) - return 1; - if (png_muldiv(&XYZ->red_Z, PNG_FP_1 - xy->redx - xy->redy, PNG_FP_1, - red_inverse) == 0) - return 1; - - if (png_muldiv(&XYZ->green_X, xy->greenx, PNG_FP_1, green_inverse) == 0) - return 1; - if (png_muldiv(&XYZ->green_Y, xy->greeny, PNG_FP_1, green_inverse) == 0) - return 1; - if (png_muldiv(&XYZ->green_Z, PNG_FP_1 - xy->greenx - xy->greeny, PNG_FP_1, - green_inverse) == 0) - return 1; - - if (png_muldiv(&XYZ->blue_X, xy->bluex, blue_scale, PNG_FP_1) == 0) - return 1; - if (png_muldiv(&XYZ->blue_Y, xy->bluey, blue_scale, PNG_FP_1) == 0) - return 1; - if (png_muldiv(&XYZ->blue_Z, PNG_FP_1 - xy->bluex - xy->bluey, blue_scale, - PNG_FP_1) == 0) - return 1; - - return 0; /*success*/ -} - -static int -png_XYZ_normalize(png_XYZ *XYZ) -{ - png_int_32 Y; - - if (XYZ->red_Y < 0 || XYZ->green_Y < 0 || XYZ->blue_Y < 0 || - XYZ->red_X < 0 || XYZ->green_X < 0 || XYZ->blue_X < 0 || - XYZ->red_Z < 0 || XYZ->green_Z < 0 || XYZ->blue_Z < 0) - return 1; - - /* Normalize by scaling so the sum of the end-point Y values is PNG_FP_1. - * IMPLEMENTATION NOTE: ANSI requires signed overflow not to occur, therefore - * relying on addition of two positive values producing a negative one is not - * safe. - */ - Y = XYZ->red_Y; - if (0x7fffffff - Y < XYZ->green_X) - return 1; - Y += XYZ->green_Y; - if (0x7fffffff - Y < XYZ->blue_X) - return 1; - Y += XYZ->blue_Y; - - if (Y != PNG_FP_1) - { - if (png_muldiv(&XYZ->red_X, XYZ->red_X, PNG_FP_1, Y) == 0) - return 1; - if (png_muldiv(&XYZ->red_Y, XYZ->red_Y, PNG_FP_1, Y) == 0) - return 1; - if (png_muldiv(&XYZ->red_Z, XYZ->red_Z, PNG_FP_1, Y) == 0) - return 1; - - if (png_muldiv(&XYZ->green_X, XYZ->green_X, PNG_FP_1, Y) == 0) - return 1; - if (png_muldiv(&XYZ->green_Y, XYZ->green_Y, PNG_FP_1, Y) == 0) - return 1; - if (png_muldiv(&XYZ->green_Z, XYZ->green_Z, PNG_FP_1, Y) == 0) - return 1; - - if (png_muldiv(&XYZ->blue_X, XYZ->blue_X, PNG_FP_1, Y) == 0) - return 1; - if (png_muldiv(&XYZ->blue_Y, XYZ->blue_Y, PNG_FP_1, Y) == 0) - return 1; - if (png_muldiv(&XYZ->blue_Z, XYZ->blue_Z, PNG_FP_1, Y) == 0) - return 1; - } - - return 0; -} - -static int -png_colorspace_endpoints_match(const png_xy *xy1, const png_xy *xy2, int delta) -{ - /* Allow an error of +/-0.01 (absolute value) on each chromaticity */ - if (PNG_OUT_OF_RANGE(xy1->whitex, xy2->whitex,delta) || - PNG_OUT_OF_RANGE(xy1->whitey, xy2->whitey,delta) || - PNG_OUT_OF_RANGE(xy1->redx, xy2->redx, delta) || - PNG_OUT_OF_RANGE(xy1->redy, xy2->redy, delta) || - PNG_OUT_OF_RANGE(xy1->greenx, xy2->greenx,delta) || - PNG_OUT_OF_RANGE(xy1->greeny, xy2->greeny,delta) || - PNG_OUT_OF_RANGE(xy1->bluex, xy2->bluex, delta) || - PNG_OUT_OF_RANGE(xy1->bluey, xy2->bluey, delta)) - return 0; - return 1; -} - -/* Added in libpng-1.6.0, a different check for the validity of a set of cHRM - * chunk chromaticities. Earlier checks used to simply look for the overflow - * condition (where the determinant of the matrix to solve for XYZ ends up zero - * because the chromaticity values are not all distinct.) Despite this it is - * theoretically possible to produce chromaticities that are apparently valid - * but that rapidly degrade to invalid, potentially crashing, sets because of - * arithmetic inaccuracies when calculations are performed on them. The new - * check is to round-trip xy -> XYZ -> xy and then check that the result is - * within a small percentage of the original. - */ -static int -png_colorspace_check_xy(png_XYZ *XYZ, const png_xy *xy) -{ - int result; - png_xy xy_test; - - /* As a side-effect this routine also returns the XYZ endpoints. */ - result = png_XYZ_from_xy(XYZ, xy); - if (result != 0) - return result; - - result = png_xy_from_XYZ(&xy_test, XYZ); - if (result != 0) - return result; - - if (png_colorspace_endpoints_match(xy, &xy_test, - 5/*actually, the math is pretty accurate*/) != 0) - return 0; - - /* Too much slip */ - return 1; -} - -/* This is the check going the other way. The XYZ is modified to normalize it - * (another side-effect) and the xy chromaticities are returned. - */ -static int -png_colorspace_check_XYZ(png_xy *xy, png_XYZ *XYZ) -{ - int result; - png_XYZ XYZtemp; - - result = png_XYZ_normalize(XYZ); - if (result != 0) - return result; - - result = png_xy_from_XYZ(xy, XYZ); - if (result != 0) - return result; - - XYZtemp = *XYZ; - return png_colorspace_check_xy(&XYZtemp, xy); -} - -/* Used to check for an endpoint match against sRGB */ -static const png_xy sRGB_xy = /* From ITU-R BT.709-3 */ -{ - /* color x y */ - /* red */ 64000, 33000, - /* green */ 30000, 60000, - /* blue */ 15000, 6000, - /* white */ 31270, 32900 -}; - -static int -png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr, - png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ, - int preferred) -{ - if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0) - return 0; - - /* The consistency check is performed on the chromaticities; this factors out - * variations because of the normalization (or not) of the end point Y - * values. - */ - if (preferred < 2 && - (colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) - { - /* The end points must be reasonably close to any we already have. The - * following allows an error of up to +/-.001 - */ - if (png_colorspace_endpoints_match(xy, &colorspace->end_points_xy, - 100) == 0) - { - colorspace->flags |= PNG_COLORSPACE_INVALID; - png_benign_error(png_ptr, "inconsistent chromaticities"); - return 0; /* failed */ - } - - /* Only overwrite with preferred values */ - if (preferred == 0) - return 1; /* ok, but no change */ - } - - colorspace->end_points_xy = *xy; - colorspace->end_points_XYZ = *XYZ; - colorspace->flags |= PNG_COLORSPACE_HAVE_ENDPOINTS; - - /* The end points are normally quoted to two decimal digits, so allow +/-0.01 - * on this test. - */ - if (png_colorspace_endpoints_match(xy, &sRGB_xy, 1000) != 0) - colorspace->flags |= PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB; - - else - colorspace->flags &= PNG_COLORSPACE_CANCEL( - PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB); - - return 2; /* ok and changed */ -} - -int /* PRIVATE */ -png_colorspace_set_chromaticities(png_const_structrp png_ptr, - png_colorspacerp colorspace, const png_xy *xy, int preferred) -{ - /* We must check the end points to ensure they are reasonable - in the past - * color management systems have crashed as a result of getting bogus - * colorant values, while this isn't the fault of libpng it is the - * responsibility of libpng because PNG carries the bomb and libpng is in a - * position to protect against it. - */ - png_XYZ XYZ; - - switch (png_colorspace_check_xy(&XYZ, xy)) - { - case 0: /* success */ - return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, xy, &XYZ, - preferred); - - case 1: - /* We can't invert the chromaticities so we can't produce value XYZ - * values. Likely as not a color management system will fail too. - */ - colorspace->flags |= PNG_COLORSPACE_INVALID; - png_benign_error(png_ptr, "invalid chromaticities"); - break; - - default: - /* libpng is broken; this should be a warning but if it happens we - * want error reports so for the moment it is an error. - */ - colorspace->flags |= PNG_COLORSPACE_INVALID; - png_error(png_ptr, "internal error checking chromaticities"); - } - - return 0; /* failed */ -} - -int /* PRIVATE */ -png_colorspace_set_endpoints(png_const_structrp png_ptr, - png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred) -{ - png_XYZ XYZ = *XYZ_in; - png_xy xy; - - switch (png_colorspace_check_XYZ(&xy, &XYZ)) - { - case 0: - return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, &xy, &XYZ, - preferred); - - case 1: - /* End points are invalid. */ - colorspace->flags |= PNG_COLORSPACE_INVALID; - png_benign_error(png_ptr, "invalid end points"); - break; - - default: - colorspace->flags |= PNG_COLORSPACE_INVALID; - png_error(png_ptr, "internal error checking chromaticities"); - } - - return 0; /* failed */ -} - -#if defined(PNG_sRGB_SUPPORTED) || defined(PNG_iCCP_SUPPORTED) -/* Error message generation */ -static char -png_icc_tag_char(png_uint_32 byte) -{ - byte &= 0xff; - if (byte >= 32 && byte <= 126) - return (char)byte; - else - return '?'; -} - -static void -png_icc_tag_name(char *name, png_uint_32 tag) -{ - name[0] = '\''; - name[1] = png_icc_tag_char(tag >> 24); - name[2] = png_icc_tag_char(tag >> 16); - name[3] = png_icc_tag_char(tag >> 8); - name[4] = png_icc_tag_char(tag ); - name[5] = '\''; -} - -static int -is_ICC_signature_char(png_alloc_size_t it) -{ - return it == 32 || (it >= 48 && it <= 57) || (it >= 65 && it <= 90) || - (it >= 97 && it <= 122); -} - -static int -is_ICC_signature(png_alloc_size_t it) -{ - return is_ICC_signature_char(it >> 24) /* checks all the top bits */ && - is_ICC_signature_char((it >> 16) & 0xff) && - is_ICC_signature_char((it >> 8) & 0xff) && - is_ICC_signature_char(it & 0xff); -} - -static int -png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_alloc_size_t value, png_const_charp reason) -{ - size_t pos; - char message[196]; /* see below for calculation */ - - if (colorspace != NULL) - colorspace->flags |= PNG_COLORSPACE_INVALID; - - pos = png_safecat(message, (sizeof message), 0, "profile '"); /* 9 chars */ - pos = png_safecat(message, pos+79, pos, name); /* Truncate to 79 chars */ - pos = png_safecat(message, (sizeof message), pos, "': "); /* +2 = 90 */ - if (is_ICC_signature(value) != 0) - { - /* So 'value' is at most 4 bytes and the following cast is safe */ - png_icc_tag_name(message+pos, (png_uint_32)value); - pos += 6; /* total +8; less than the else clause */ - message[pos++] = ':'; - message[pos++] = ' '; - } -# ifdef PNG_WARNINGS_SUPPORTED - else - { - char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114*/ - - pos = png_safecat(message, (sizeof message), pos, - png_format_number(number, number+(sizeof number), - PNG_NUMBER_FORMAT_x, value)); - pos = png_safecat(message, (sizeof message), pos, "h: "); /*+2 = 116*/ - } -# endif - /* The 'reason' is an arbitrary message, allow +79 maximum 195 */ - pos = png_safecat(message, (sizeof message), pos, reason); - PNG_UNUSED(pos) - - /* This is recoverable, but make it unconditionally an app_error on write to - * avoid writing invalid ICC profiles into PNG files (i.e., we handle them - * on read, with a warning, but on write unless the app turns off - * application errors the PNG won't be written.) - */ - png_chunk_report(png_ptr, message, - (colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR); - - return 0; -} -#endif /* sRGB || iCCP */ - -#ifdef PNG_sRGB_SUPPORTED -int /* PRIVATE */ -png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, - int intent) -{ - /* sRGB sets known gamma, end points and (from the chunk) intent. */ - /* IMPORTANT: these are not necessarily the values found in an ICC profile - * because ICC profiles store values adapted to a D50 environment; it is - * expected that the ICC profile mediaWhitePointTag will be D50; see the - * checks and code elsewhere to understand this better. - * - * These XYZ values, which are accurate to 5dp, produce rgb to gray - * coefficients of (6968,23435,2366), which are reduced (because they add up - * to 32769 not 32768) to (6968,23434,2366). These are the values that - * libpng has traditionally used (and are the best values given the 15bit - * algorithm used by the rgb to gray code.) - */ - static const png_XYZ sRGB_XYZ = /* D65 XYZ (*not* the D50 adapted values!) */ - { - /* color X Y Z */ - /* red */ 41239, 21264, 1933, - /* green */ 35758, 71517, 11919, - /* blue */ 18048, 7219, 95053 - }; - - /* Do nothing if the colorspace is already invalidated. */ - if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0) - return 0; - - /* Check the intent, then check for existing settings. It is valid for the - * PNG file to have cHRM or gAMA chunks along with sRGB, but the values must - * be consistent with the correct values. If, however, this function is - * called below because an iCCP chunk matches sRGB then it is quite - * conceivable that an older app recorded incorrect gAMA and cHRM because of - * an incorrect calculation based on the values in the profile - this does - * *not* invalidate the profile (though it still produces an error, which can - * be ignored.) - */ - if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST) - return png_icc_profile_error(png_ptr, colorspace, "sRGB", - (png_alloc_size_t)intent, "invalid sRGB rendering intent"); - - if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 && - colorspace->rendering_intent != intent) - return png_icc_profile_error(png_ptr, colorspace, "sRGB", - (png_alloc_size_t)intent, "inconsistent rendering intents"); - - if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0) - { - png_benign_error(png_ptr, "duplicate sRGB information ignored"); - return 0; - } - - /* If the standard sRGB cHRM chunk does not match the one from the PNG file - * warn but overwrite the value with the correct one. - */ - if ((colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0 && - !png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy, - 100)) - png_chunk_report(png_ptr, "cHRM chunk does not match sRGB", - PNG_CHUNK_ERROR); - - /* This check is just done for the error reporting - the routine always - * returns true when the 'from' argument corresponds to sRGB (2). - */ - (void)png_colorspace_check_gamma(png_ptr, colorspace, PNG_GAMMA_sRGB_INVERSE, - 2/*from sRGB*/); - - /* intent: bugs in GCC force 'int' to be used as the parameter type. */ - colorspace->rendering_intent = (png_uint_16)intent; - colorspace->flags |= PNG_COLORSPACE_HAVE_INTENT; - - /* endpoints */ - colorspace->end_points_xy = sRGB_xy; - colorspace->end_points_XYZ = sRGB_XYZ; - colorspace->flags |= - (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB); - - /* gamma */ - colorspace->gamma = PNG_GAMMA_sRGB_INVERSE; - colorspace->flags |= PNG_COLORSPACE_HAVE_GAMMA; - - /* Finally record that we have an sRGB profile */ - colorspace->flags |= - (PNG_COLORSPACE_MATCHES_sRGB|PNG_COLORSPACE_FROM_sRGB); - - return 1; /* set */ -} -#endif /* sRGB */ - -#ifdef PNG_iCCP_SUPPORTED -/* Encoded value of D50 as an ICC XYZNumber. From the ICC 2010 spec the value - * is XYZ(0.9642,1.0,0.8249), which scales to: - * - * (63189.8112, 65536, 54060.6464) - */ -static const png_byte D50_nCIEXYZ[12] = - { 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d }; - -static int /* bool */ -icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length) -{ - if (profile_length < 132) - return png_icc_profile_error(png_ptr, colorspace, name, profile_length, - "too short"); - return 1; -} - -#ifdef PNG_READ_iCCP_SUPPORTED -int /* PRIVATE */ -png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length) -{ - if (!icc_check_length(png_ptr, colorspace, name, profile_length)) - return 0; - - /* This needs to be here because the 'normal' check is in - * png_decompress_chunk, yet this happens after the attempt to - * png_malloc_base the required data. We only need this on read; on write - * the caller supplies the profile buffer so libpng doesn't allocate it. See - * the call to icc_check_length below (the write case). - */ -# ifdef PNG_SET_USER_LIMITS_SUPPORTED - else if (png_ptr->user_chunk_malloc_max > 0 && - png_ptr->user_chunk_malloc_max < profile_length) - return png_icc_profile_error(png_ptr, colorspace, name, profile_length, - "exceeds application limits"); -# elif PNG_USER_CHUNK_MALLOC_MAX > 0 - else if (PNG_USER_CHUNK_MALLOC_MAX < profile_length) - return png_icc_profile_error(png_ptr, colorspace, name, profile_length, - "exceeds libpng limits"); -# else /* !SET_USER_LIMITS */ - /* This will get compiled out on all 32-bit and better systems. */ - else if (PNG_SIZE_MAX < profile_length) - return png_icc_profile_error(png_ptr, colorspace, name, profile_length, - "exceeds system limits"); -# endif /* !SET_USER_LIMITS */ - - return 1; -} -#endif /* READ_iCCP */ - -int /* PRIVATE */ -png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length, - png_const_bytep profile/* first 132 bytes only */, int color_type) -{ - png_uint_32 temp; - - /* Length check; this cannot be ignored in this code because profile_length - * is used later to check the tag table, so even if the profile seems over - * long profile_length from the caller must be correct. The caller can fix - * this up on read or write by just passing in the profile header length. - */ - temp = png_get_uint_32(profile); - if (temp != profile_length) - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "length does not match profile"); - - temp = (png_uint_32) (*(profile+8)); - if (temp > 3 && (profile_length & 3)) - return png_icc_profile_error(png_ptr, colorspace, name, profile_length, - "invalid length"); - - temp = png_get_uint_32(profile+128); /* tag count: 12 bytes/tag */ - if (temp > 357913930 || /* (2^32-4-132)/12: maximum possible tag count */ - profile_length < 132+12*temp) /* truncated tag table */ - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "tag count too large"); - - /* The 'intent' must be valid or we can't store it, ICC limits the intent to - * 16 bits. - */ - temp = png_get_uint_32(profile+64); - if (temp >= 0xffff) /* The ICC limit */ - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "invalid rendering intent"); - - /* This is just a warning because the profile may be valid in future - * versions. - */ - if (temp >= PNG_sRGB_INTENT_LAST) - (void)png_icc_profile_error(png_ptr, NULL, name, temp, - "intent outside defined range"); - - /* At this point the tag table can't be checked because it hasn't necessarily - * been loaded; however, various header fields can be checked. These checks - * are for values permitted by the PNG spec in an ICC profile; the PNG spec - * restricts the profiles that can be passed in an iCCP chunk (they must be - * appropriate to processing PNG data!) - */ - - /* Data checks (could be skipped). These checks must be independent of the - * version number; however, the version number doesn't accommodate changes in - * the header fields (just the known tags and the interpretation of the - * data.) - */ - temp = png_get_uint_32(profile+36); /* signature 'ascp' */ - if (temp != 0x61637370) - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "invalid signature"); - - /* Currently the PCS illuminant/adopted white point (the computational - * white point) are required to be D50, - * however the profile contains a record of the illuminant so perhaps ICC - * expects to be able to change this in the future (despite the rationale in - * the introduction for using a fixed PCS adopted white.) Consequently the - * following is just a warning. - */ - if (memcmp(profile+68, D50_nCIEXYZ, 12) != 0) - (void)png_icc_profile_error(png_ptr, NULL, name, 0/*no tag value*/, - "PCS illuminant is not D50"); - - /* The PNG spec requires this: - * "If the iCCP chunk is present, the image samples conform to the colour - * space represented by the embedded ICC profile as defined by the - * International Color Consortium [ICC]. The colour space of the ICC profile - * shall be an RGB colour space for colour images (PNG colour types 2, 3, and - * 6), or a greyscale colour space for greyscale images (PNG colour types 0 - * and 4)." - * - * This checking code ensures the embedded profile (on either read or write) - * conforms to the specification requirements. Notice that an ICC 'gray' - * color-space profile contains the information to transform the monochrome - * data to XYZ or L*a*b (according to which PCS the profile uses) and this - * should be used in preference to the standard libpng K channel replication - * into R, G and B channels. - * - * Previously it was suggested that an RGB profile on grayscale data could be - * handled. However it it is clear that using an RGB profile in this context - * must be an error - there is no specification of what it means. Thus it is - * almost certainly more correct to ignore the profile. - */ - temp = png_get_uint_32(profile+16); /* data colour space field */ - switch (temp) - { - case 0x52474220: /* 'RGB ' */ - if ((color_type & PNG_COLOR_MASK_COLOR) == 0) - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "RGB color space not permitted on grayscale PNG"); - break; - - case 0x47524159: /* 'GRAY' */ - if ((color_type & PNG_COLOR_MASK_COLOR) != 0) - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "Gray color space not permitted on RGB PNG"); - break; - - default: - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "invalid ICC profile color space"); - } - - /* It is up to the application to check that the profile class matches the - * application requirements; the spec provides no guidance, but it's pretty - * weird if the profile is not scanner ('scnr'), monitor ('mntr'), printer - * ('prtr') or 'spac' (for generic color spaces). Issue a warning in these - * cases. Issue an error for device link or abstract profiles - these don't - * contain the records necessary to transform the color-space to anything - * other than the target device (and not even that for an abstract profile). - * Profiles of these classes may not be embedded in images. - */ - temp = png_get_uint_32(profile+12); /* profile/device class */ - switch (temp) - { - case 0x73636e72: /* 'scnr' */ - case 0x6d6e7472: /* 'mntr' */ - case 0x70727472: /* 'prtr' */ - case 0x73706163: /* 'spac' */ - /* All supported */ - break; - - case 0x61627374: /* 'abst' */ - /* May not be embedded in an image */ - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "invalid embedded Abstract ICC profile"); - - case 0x6c696e6b: /* 'link' */ - /* DeviceLink profiles cannot be interpreted in a non-device specific - * fashion, if an app uses the AToB0Tag in the profile the results are - * undefined unless the result is sent to the intended device, - * therefore a DeviceLink profile should not be found embedded in a - * PNG. - */ - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "unexpected DeviceLink ICC profile class"); - - case 0x6e6d636c: /* 'nmcl' */ - /* A NamedColor profile is also device specific, however it doesn't - * contain an AToB0 tag that is open to misinterpretation. Almost - * certainly it will fail the tests below. - */ - (void)png_icc_profile_error(png_ptr, NULL, name, temp, - "unexpected NamedColor ICC profile class"); - break; - - default: - /* To allow for future enhancements to the profile accept unrecognized - * profile classes with a warning, these then hit the test below on the - * tag content to ensure they are backward compatible with one of the - * understood profiles. - */ - (void)png_icc_profile_error(png_ptr, NULL, name, temp, - "unrecognized ICC profile class"); - break; - } - - /* For any profile other than a device link one the PCS must be encoded - * either in XYZ or Lab. - */ - temp = png_get_uint_32(profile+20); - switch (temp) - { - case 0x58595a20: /* 'XYZ ' */ - case 0x4c616220: /* 'Lab ' */ - break; - - default: - return png_icc_profile_error(png_ptr, colorspace, name, temp, - "unexpected ICC PCS encoding"); - } - - return 1; -} - -int /* PRIVATE */ -png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length, - png_const_bytep profile /* header plus whole tag table */) -{ - png_uint_32 tag_count = png_get_uint_32(profile+128); - png_uint_32 itag; - png_const_bytep tag = profile+132; /* The first tag */ - - /* First scan all the tags in the table and add bits to the icc_info value - * (temporarily in 'tags'). - */ - for (itag=0; itag < tag_count; ++itag, tag += 12) - { - png_uint_32 tag_id = png_get_uint_32(tag+0); - png_uint_32 tag_start = png_get_uint_32(tag+4); /* must be aligned */ - png_uint_32 tag_length = png_get_uint_32(tag+8);/* not padded */ - - /* The ICC specification does not exclude zero length tags, therefore the - * start might actually be anywhere if there is no data, but this would be - * a clear abuse of the intent of the standard so the start is checked for - * being in range. All defined tag types have an 8 byte header - a 4 byte - * type signature then 0. - */ - - /* This is a hard error; potentially it can cause read outside the - * profile. - */ - if (tag_start > profile_length || tag_length > profile_length - tag_start) - return png_icc_profile_error(png_ptr, colorspace, name, tag_id, - "ICC profile tag outside profile"); - - if ((tag_start & 3) != 0) - { - /* CNHP730S.icc shipped with Microsoft Windows 64 violates this; it is - * only a warning here because libpng does not care about the - * alignment. - */ - (void)png_icc_profile_error(png_ptr, NULL, name, tag_id, - "ICC profile tag start not a multiple of 4"); - } - } - - return 1; /* success, maybe with warnings */ -} - -#ifdef PNG_sRGB_SUPPORTED -#if PNG_sRGB_PROFILE_CHECKS >= 0 -/* Information about the known ICC sRGB profiles */ -static const struct -{ - png_uint_32 adler, crc, length; - png_uint_32 md5[4]; - png_byte have_md5; - png_byte is_broken; - png_uint_16 intent; - -# define PNG_MD5(a,b,c,d) { a, b, c, d }, (a!=0)||(b!=0)||(c!=0)||(d!=0) -# define PNG_ICC_CHECKSUM(adler, crc, md5, intent, broke, date, length, fname)\ - { adler, crc, length, md5, broke, intent }, - -} png_sRGB_checks[] = -{ - /* This data comes from contrib/tools/checksum-icc run on downloads of - * all four ICC sRGB profiles from www.color.org. - */ - /* adler32, crc32, MD5[4], intent, date, length, file-name */ - PNG_ICC_CHECKSUM(0x0a3fd9f6, 0x3b8772b9, - PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0, - "2009/03/27 21:36:31", 3048, "sRGB_IEC61966-2-1_black_scaled.icc") - - /* ICC sRGB v2 perceptual no black-compensation: */ - PNG_ICC_CHECKSUM(0x4909e5e1, 0x427ebb21, - PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0, - "2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc") - - PNG_ICC_CHECKSUM(0xfd2144a1, 0x306fd8ae, - PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0, - "2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc") - - /* ICC sRGB v4 perceptual */ - PNG_ICC_CHECKSUM(0x209c35d2, 0xbbef7812, - PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0, - "2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc") - - /* The following profiles have no known MD5 checksum. If there is a match - * on the (empty) MD5 the other fields are used to attempt a match and - * a warning is produced. The first two of these profiles have a 'cprt' tag - * which suggests that they were also made by Hewlett Packard. - */ - PNG_ICC_CHECKSUM(0xa054d762, 0x5d5129ce, - PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0, - "2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc") - - /* This is a 'mntr' (display) profile with a mediaWhitePointTag that does not - * match the D50 PCS illuminant in the header (it is in fact the D65 values, - * so the white point is recorded as the un-adapted value.) The profiles - * below only differ in one byte - the intent - and are basically the same as - * the previous profile except for the mediaWhitePointTag error and a missing - * chromaticAdaptationTag. - */ - PNG_ICC_CHECKSUM(0xf784f3fb, 0x182ea552, - PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/, - "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual") - - PNG_ICC_CHECKSUM(0x0398f3fc, 0xf29e526d, - PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/, - "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative") -}; - -static int -png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, - png_const_bytep profile, uLong adler) -{ - /* The quick check is to verify just the MD5 signature and trust the - * rest of the data. Because the profile has already been verified for - * correctness this is safe. png_colorspace_set_sRGB will check the 'intent' - * field too, so if the profile has been edited with an intent not defined - * by sRGB (but maybe defined by a later ICC specification) the read of - * the profile will fail at that point. - */ - - png_uint_32 length = 0; - png_uint_32 intent = 0x10000; /* invalid */ -#if PNG_sRGB_PROFILE_CHECKS > 1 - uLong crc = 0; /* the value for 0 length data */ -#endif - unsigned int i; - -#ifdef PNG_SET_OPTION_SUPPORTED - /* First see if PNG_SKIP_sRGB_CHECK_PROFILE has been set to "on" */ - if (((png_ptr->options >> PNG_SKIP_sRGB_CHECK_PROFILE) & 3) == - PNG_OPTION_ON) - return 0; -#endif - - for (i=0; i < (sizeof png_sRGB_checks) / (sizeof png_sRGB_checks[0]); ++i) - { - if (png_get_uint_32(profile+84) == png_sRGB_checks[i].md5[0] && - png_get_uint_32(profile+88) == png_sRGB_checks[i].md5[1] && - png_get_uint_32(profile+92) == png_sRGB_checks[i].md5[2] && - png_get_uint_32(profile+96) == png_sRGB_checks[i].md5[3]) - { - /* This may be one of the old HP profiles without an MD5, in that - * case we can only use the length and Adler32 (note that these - * are not used by default if there is an MD5!) - */ -# if PNG_sRGB_PROFILE_CHECKS == 0 - if (png_sRGB_checks[i].have_md5 != 0) - return 1+png_sRGB_checks[i].is_broken; -# endif - - /* Profile is unsigned or more checks have been configured in. */ - if (length == 0) - { - length = png_get_uint_32(profile); - intent = png_get_uint_32(profile+64); - } - - /* Length *and* intent must match */ - if (length == (png_uint_32) png_sRGB_checks[i].length && - intent == (png_uint_32) png_sRGB_checks[i].intent) - { - /* Now calculate the adler32 if not done already. */ - if (adler == 0) - { - adler = adler32(0, NULL, 0); - adler = adler32(adler, profile, length); - } - - if (adler == png_sRGB_checks[i].adler) - { - /* These basic checks suggest that the data has not been - * modified, but if the check level is more than 1 perform - * our own crc32 checksum on the data. - */ -# if PNG_sRGB_PROFILE_CHECKS > 1 - if (crc == 0) - { - crc = crc32(0, NULL, 0); - crc = crc32(crc, profile, length); - } - - /* So this check must pass for the 'return' below to happen. - */ - if (crc == png_sRGB_checks[i].crc) -# endif - { - if (png_sRGB_checks[i].is_broken != 0) - { - /* These profiles are known to have bad data that may cause - * problems if they are used, therefore attempt to - * discourage their use, skip the 'have_md5' warning below, - * which is made irrelevant by this error. - */ - png_chunk_report(png_ptr, "known incorrect sRGB profile", - PNG_CHUNK_ERROR); - } - - /* Warn that this being done; this isn't even an error since - * the profile is perfectly valid, but it would be nice if - * people used the up-to-date ones. - */ - else if (png_sRGB_checks[i].have_md5 == 0) - { - png_chunk_report(png_ptr, - "out-of-date sRGB profile with no signature", - PNG_CHUNK_WARNING); - } - - return 1+png_sRGB_checks[i].is_broken; - } - } - -# if PNG_sRGB_PROFILE_CHECKS > 0 - /* The signature matched, but the profile had been changed in some - * way. This probably indicates a data error or uninformed hacking. - * Fall through to "no match". - */ - png_chunk_report(png_ptr, - "Not recognizing known sRGB profile that has been edited", - PNG_CHUNK_WARNING); - break; -# endif - } - } - } - - return 0; /* no match */ -} - -void /* PRIVATE */ -png_icc_set_sRGB(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_const_bytep profile, uLong adler) -{ - /* Is this profile one of the known ICC sRGB profiles? If it is, just set - * the sRGB information. - */ - if (png_compare_ICC_profile_with_sRGB(png_ptr, profile, adler) != 0) - (void)png_colorspace_set_sRGB(png_ptr, colorspace, - (int)/*already checked*/png_get_uint_32(profile+64)); -} -#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */ -#endif /* sRGB */ - -int /* PRIVATE */ -png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length, png_const_bytep profile, - int color_type) -{ - if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0) - return 0; - - if (icc_check_length(png_ptr, colorspace, name, profile_length) != 0 && - png_icc_check_header(png_ptr, colorspace, name, profile_length, profile, - color_type) != 0 && - png_icc_check_tag_table(png_ptr, colorspace, name, profile_length, - profile) != 0) - { -# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0 - /* If no sRGB support, don't try storing sRGB information */ - png_icc_set_sRGB(png_ptr, colorspace, profile, 0); -# endif - return 1; - } - - /* Failure case */ - return 0; -} -#endif /* iCCP */ - -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED -void /* PRIVATE */ -png_colorspace_set_rgb_coefficients(png_structrp png_ptr) -{ - /* Set the rgb_to_gray coefficients from the colorspace. */ - if (png_ptr->rgb_to_gray_coefficients_set == 0 && - (png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) - { - /* png_set_background has not been called, get the coefficients from the Y - * values of the colorspace colorants. - */ - png_fixed_point r = png_ptr->colorspace.end_points_XYZ.red_Y; - png_fixed_point g = png_ptr->colorspace.end_points_XYZ.green_Y; - png_fixed_point b = png_ptr->colorspace.end_points_XYZ.blue_Y; - png_fixed_point total = r+g+b; - - if (total > 0 && - r >= 0 && png_muldiv(&r, r, 32768, total) && r >= 0 && r <= 32768 && - g >= 0 && png_muldiv(&g, g, 32768, total) && g >= 0 && g <= 32768 && - b >= 0 && png_muldiv(&b, b, 32768, total) && b >= 0 && b <= 32768 && - r+g+b <= 32769) - { - /* We allow 0 coefficients here. r+g+b may be 32769 if two or - * all of the coefficients were rounded up. Handle this by - * reducing the *largest* coefficient by 1; this matches the - * approach used for the default coefficients in pngrtran.c - */ - int add = 0; - - if (r+g+b > 32768) - add = -1; - else if (r+g+b < 32768) - add = 1; - - if (add != 0) - { - if (g >= r && g >= b) - g += add; - else if (r >= g && r >= b) - r += add; - else - b += add; - } - - /* Check for an internal error. */ - if (r+g+b != 32768) - png_error(png_ptr, - "internal error handling cHRM coefficients"); - - else - { - png_ptr->rgb_to_gray_red_coeff = (png_uint_16)r; - png_ptr->rgb_to_gray_green_coeff = (png_uint_16)g; - } - } - - /* This is a png_error at present even though it could be ignored - - * it should never happen, but it is important that if it does, the - * bug is fixed. - */ - else - png_error(png_ptr, "internal error handling cHRM->XYZ"); - } -} -#endif /* READ_RGB_TO_GRAY */ - -#endif /* COLORSPACE */ - -#ifdef __GNUC__ -/* This exists solely to work round a warning from GNU C. */ -static int /* PRIVATE */ -png_gt(size_t a, size_t b) -{ - return a > b; -} -#else -# define png_gt(a,b) ((a) > (b)) -#endif - -void /* PRIVATE */ -png_check_IHDR(png_const_structrp png_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_type, int compression_type, - int filter_type) -{ - int error = 0; - - /* Check for width and height valid values */ - if (width == 0) - { - png_warning(png_ptr, "Image width is zero in IHDR"); - error = 1; - } - - if (width > PNG_UINT_31_MAX) - { - png_warning(png_ptr, "Invalid image width in IHDR"); - error = 1; - } - - if (png_gt(((width + 7) & (~7U)), - ((PNG_SIZE_MAX - - 48 /* big_row_buf hack */ - - 1) /* filter byte */ - / 8) /* 8-byte RGBA pixels */ - - 1)) /* extra max_pixel_depth pad */ - { - /* The size of the row must be within the limits of this architecture. - * Because the read code can perform arbitrary transformations the - * maximum size is checked here. Because the code in png_read_start_row - * adds extra space "for safety's sake" in several places a conservative - * limit is used here. - * - * NOTE: it would be far better to check the size that is actually used, - * but the effect in the real world is minor and the changes are more - * extensive, therefore much more dangerous and much more difficult to - * write in a way that avoids compiler warnings. - */ - png_warning(png_ptr, "Image width is too large for this architecture"); - error = 1; - } - -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (width > png_ptr->user_width_max) -#else - if (width > PNG_USER_WIDTH_MAX) -#endif - { - png_warning(png_ptr, "Image width exceeds user limit in IHDR"); - error = 1; - } - - if (height == 0) - { - png_warning(png_ptr, "Image height is zero in IHDR"); - error = 1; - } - - if (height > PNG_UINT_31_MAX) - { - png_warning(png_ptr, "Invalid image height in IHDR"); - error = 1; - } - -#ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (height > png_ptr->user_height_max) -#else - if (height > PNG_USER_HEIGHT_MAX) -#endif - { - png_warning(png_ptr, "Image height exceeds user limit in IHDR"); - error = 1; - } - - /* Check other values */ - if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && - bit_depth != 8 && bit_depth != 16) - { - png_warning(png_ptr, "Invalid bit depth in IHDR"); - error = 1; - } - - if (color_type < 0 || color_type == 1 || - color_type == 5 || color_type > 6) - { - png_warning(png_ptr, "Invalid color type in IHDR"); - error = 1; - } - - if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || - ((color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8)) - { - png_warning(png_ptr, "Invalid color type/bit depth combination in IHDR"); - error = 1; - } - - if (interlace_type >= PNG_INTERLACE_LAST) - { - png_warning(png_ptr, "Unknown interlace method in IHDR"); - error = 1; - } - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - { - png_warning(png_ptr, "Unknown compression method in IHDR"); - error = 1; - } - -#ifdef PNG_MNG_FEATURES_SUPPORTED - /* Accept filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not read a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && - png_ptr->mng_features_permitted != 0) - png_warning(png_ptr, "MNG features are not allowed in a PNG datastream"); - - if (filter_type != PNG_FILTER_TYPE_BASE) - { - if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && - ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA))) - { - png_warning(png_ptr, "Unknown filter method in IHDR"); - error = 1; - } - - if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0) - { - png_warning(png_ptr, "Invalid filter method in IHDR"); - error = 1; - } - } - -#else - if (filter_type != PNG_FILTER_TYPE_BASE) - { - png_warning(png_ptr, "Unknown filter method in IHDR"); - error = 1; - } -#endif - - if (error == 1) - png_error(png_ptr, "Invalid IHDR data"); -} - -#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED) -/* ASCII to fp functions */ -/* Check an ASCII formatted floating point value, see the more detailed - * comments in pngpriv.h - */ -/* The following is used internally to preserve the sticky flags */ -#define png_fp_add(state, flags) ((state) |= (flags)) -#define png_fp_set(state, value) ((state) = (value) | ((state) & PNG_FP_STICKY)) - -int /* PRIVATE */ -png_check_fp_number(png_const_charp string, size_t size, int *statep, - png_size_tp whereami) -{ - int state = *statep; - size_t i = *whereami; - - while (i < size) - { - int type; - /* First find the type of the next character */ - switch (string[i]) - { - case 43: type = PNG_FP_SAW_SIGN; break; - case 45: type = PNG_FP_SAW_SIGN + PNG_FP_NEGATIVE; break; - case 46: type = PNG_FP_SAW_DOT; break; - case 48: type = PNG_FP_SAW_DIGIT; break; - case 49: case 50: case 51: case 52: - case 53: case 54: case 55: case 56: - case 57: type = PNG_FP_SAW_DIGIT + PNG_FP_NONZERO; break; - case 69: - case 101: type = PNG_FP_SAW_E; break; - default: goto PNG_FP_End; - } - - /* Now deal with this type according to the current - * state, the type is arranged to not overlap the - * bits of the PNG_FP_STATE. - */ - switch ((state & PNG_FP_STATE) + (type & PNG_FP_SAW_ANY)) - { - case PNG_FP_INTEGER + PNG_FP_SAW_SIGN: - if ((state & PNG_FP_SAW_ANY) != 0) - goto PNG_FP_End; /* not a part of the number */ - - png_fp_add(state, type); - break; - - case PNG_FP_INTEGER + PNG_FP_SAW_DOT: - /* Ok as trailer, ok as lead of fraction. */ - if ((state & PNG_FP_SAW_DOT) != 0) /* two dots */ - goto PNG_FP_End; - - else if ((state & PNG_FP_SAW_DIGIT) != 0) /* trailing dot? */ - png_fp_add(state, type); - - else - png_fp_set(state, PNG_FP_FRACTION | type); - - break; - - case PNG_FP_INTEGER + PNG_FP_SAW_DIGIT: - if ((state & PNG_FP_SAW_DOT) != 0) /* delayed fraction */ - png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT); - - png_fp_add(state, type | PNG_FP_WAS_VALID); - - break; - - case PNG_FP_INTEGER + PNG_FP_SAW_E: - if ((state & PNG_FP_SAW_DIGIT) == 0) - goto PNG_FP_End; - - png_fp_set(state, PNG_FP_EXPONENT); - - break; - - /* case PNG_FP_FRACTION + PNG_FP_SAW_SIGN: - goto PNG_FP_End; ** no sign in fraction */ - - /* case PNG_FP_FRACTION + PNG_FP_SAW_DOT: - goto PNG_FP_End; ** Because SAW_DOT is always set */ - - case PNG_FP_FRACTION + PNG_FP_SAW_DIGIT: - png_fp_add(state, type | PNG_FP_WAS_VALID); - break; - - case PNG_FP_FRACTION + PNG_FP_SAW_E: - /* This is correct because the trailing '.' on an - * integer is handled above - so we can only get here - * with the sequence ".E" (with no preceding digits). - */ - if ((state & PNG_FP_SAW_DIGIT) == 0) - goto PNG_FP_End; - - png_fp_set(state, PNG_FP_EXPONENT); - - break; - - case PNG_FP_EXPONENT + PNG_FP_SAW_SIGN: - if ((state & PNG_FP_SAW_ANY) != 0) - goto PNG_FP_End; /* not a part of the number */ - - png_fp_add(state, PNG_FP_SAW_SIGN); - - break; - - /* case PNG_FP_EXPONENT + PNG_FP_SAW_DOT: - goto PNG_FP_End; */ - - case PNG_FP_EXPONENT + PNG_FP_SAW_DIGIT: - png_fp_add(state, PNG_FP_SAW_DIGIT | PNG_FP_WAS_VALID); - - break; - - /* case PNG_FP_EXPONEXT + PNG_FP_SAW_E: - goto PNG_FP_End; */ - - default: goto PNG_FP_End; /* I.e. break 2 */ - } - - /* The character seems ok, continue. */ - ++i; - } - -PNG_FP_End: - /* Here at the end, update the state and return the correct - * return code. - */ - *statep = state; - *whereami = i; - - return (state & PNG_FP_SAW_DIGIT) != 0; -} - - -/* The same but for a complete string. */ -int -png_check_fp_string(png_const_charp string, size_t size) -{ - int state=0; - size_t char_index=0; - - if (png_check_fp_number(string, size, &state, &char_index) != 0 && - (char_index == size || string[char_index] == 0)) - return state /* must be non-zero - see above */; - - return 0; /* i.e. fail */ -} -#endif /* pCAL || sCAL */ - -#ifdef PNG_sCAL_SUPPORTED -# ifdef PNG_FLOATING_POINT_SUPPORTED -/* Utility used below - a simple accurate power of ten from an integral - * exponent. - */ -static double -png_pow10(int power) -{ - int recip = 0; - double d = 1; - - /* Handle negative exponent with a reciprocal at the end because - * 10 is exact whereas .1 is inexact in base 2 - */ - if (power < 0) - { - if (power < DBL_MIN_10_EXP) return 0; - recip = 1; power = -power; - } - - if (power > 0) - { - /* Decompose power bitwise. */ - double mult = 10; - do - { - if (power & 1) d *= mult; - mult *= mult; - power >>= 1; - } - while (power > 0); - - if (recip != 0) d = 1/d; - } - /* else power is 0 and d is 1 */ - - return d; -} - -/* Function to format a floating point value in ASCII with a given - * precision. - */ -#if GCC_STRICT_OVERFLOW -#pragma GCC diagnostic push -/* The problem arises below with exp_b10, which can never overflow because it - * comes, originally, from frexp and is therefore limited to a range which is - * typically +/-710 (log2(DBL_MAX)/log2(DBL_MIN)). - */ -#pragma GCC diagnostic warning "-Wstrict-overflow=2" -#endif /* GCC_STRICT_OVERFLOW */ -void /* PRIVATE */ -png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, size_t size, - double fp, unsigned int precision) -{ - /* We use standard functions from math.h, but not printf because - * that would require stdio. The caller must supply a buffer of - * sufficient size or we will png_error. The tests on size and - * the space in ascii[] consumed are indicated below. - */ - if (precision < 1) - precision = DBL_DIG; - - /* Enforce the limit of the implementation precision too. */ - if (precision > DBL_DIG+1) - precision = DBL_DIG+1; - - /* Basic sanity checks */ - if (size >= precision+5) /* See the requirements below. */ - { - if (fp < 0) - { - fp = -fp; - *ascii++ = 45; /* '-' PLUS 1 TOTAL 1 */ - --size; - } - - if (fp >= DBL_MIN && fp <= DBL_MAX) - { - int exp_b10; /* A base 10 exponent */ - double base; /* 10^exp_b10 */ - - /* First extract a base 10 exponent of the number, - * the calculation below rounds down when converting - * from base 2 to base 10 (multiply by log10(2) - - * 0.3010, but 77/256 is 0.3008, so exp_b10 needs to - * be increased. Note that the arithmetic shift - * performs a floor() unlike C arithmetic - using a - * C multiply would break the following for negative - * exponents. - */ - (void)frexp(fp, &exp_b10); /* exponent to base 2 */ - - exp_b10 = (exp_b10 * 77) >> 8; /* <= exponent to base 10 */ - - /* Avoid underflow here. */ - base = png_pow10(exp_b10); /* May underflow */ - - while (base < DBL_MIN || base < fp) - { - /* And this may overflow. */ - double test = png_pow10(exp_b10+1); - - if (test <= DBL_MAX) - { - ++exp_b10; base = test; - } - - else - break; - } - - /* Normalize fp and correct exp_b10, after this fp is in the - * range [.1,1) and exp_b10 is both the exponent and the digit - * *before* which the decimal point should be inserted - * (starting with 0 for the first digit). Note that this - * works even if 10^exp_b10 is out of range because of the - * test on DBL_MAX above. - */ - fp /= base; - while (fp >= 1) - { - fp /= 10; ++exp_b10; - } - - /* Because of the code above fp may, at this point, be - * less than .1, this is ok because the code below can - * handle the leading zeros this generates, so no attempt - * is made to correct that here. - */ - - { - unsigned int czero, clead, cdigits; - char exponent[10]; - - /* Allow up to two leading zeros - this will not lengthen - * the number compared to using E-n. - */ - if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */ - { - czero = 0U-exp_b10; /* PLUS 2 digits: TOTAL 3 */ - exp_b10 = 0; /* Dot added below before first output. */ - } - else - czero = 0; /* No zeros to add */ - - /* Generate the digit list, stripping trailing zeros and - * inserting a '.' before a digit if the exponent is 0. - */ - clead = czero; /* Count of leading zeros */ - cdigits = 0; /* Count of digits in list. */ - - do - { - double d; - - fp *= 10; - /* Use modf here, not floor and subtract, so that - * the separation is done in one step. At the end - * of the loop don't break the number into parts so - * that the final digit is rounded. - */ - if (cdigits+czero+1 < precision+clead) - fp = modf(fp, &d); - - else - { - d = floor(fp + .5); - - if (d > 9) - { - /* Rounding up to 10, handle that here. */ - if (czero > 0) - { - --czero; d = 1; - if (cdigits == 0) --clead; - } - else - { - while (cdigits > 0 && d > 9) - { - int ch = *--ascii; - - if (exp_b10 != (-1)) - ++exp_b10; - - else if (ch == 46) - { - ch = *--ascii; ++size; - /* Advance exp_b10 to '1', so that the - * decimal point happens after the - * previous digit. - */ - exp_b10 = 1; - } - - --cdigits; - d = ch - 47; /* I.e. 1+(ch-48) */ - } - - /* Did we reach the beginning? If so adjust the - * exponent but take into account the leading - * decimal point. - */ - if (d > 9) /* cdigits == 0 */ - { - if (exp_b10 == (-1)) - { - /* Leading decimal point (plus zeros?), if - * we lose the decimal point here it must - * be reentered below. - */ - int ch = *--ascii; - - if (ch == 46) - { - ++size; exp_b10 = 1; - } - - /* Else lost a leading zero, so 'exp_b10' is - * still ok at (-1) - */ - } - else - ++exp_b10; - - /* In all cases we output a '1' */ - d = 1; - } - } - } - fp = 0; /* Guarantees termination below. */ - } - - if (d == 0) - { - ++czero; - if (cdigits == 0) ++clead; - } - else - { - /* Included embedded zeros in the digit count. */ - cdigits += czero - clead; - clead = 0; - - while (czero > 0) - { - /* exp_b10 == (-1) means we just output the decimal - * place - after the DP don't adjust 'exp_b10' any - * more! - */ - if (exp_b10 != (-1)) - { - if (exp_b10 == 0) - { - *ascii++ = 46; --size; - } - /* PLUS 1: TOTAL 4 */ - --exp_b10; - } - *ascii++ = 48; --czero; - } - - if (exp_b10 != (-1)) - { - if (exp_b10 == 0) - { - *ascii++ = 46; --size; /* counted above */ - } - - --exp_b10; - } - *ascii++ = (char)(48 + (int)d); ++cdigits; - } - } - while (cdigits+czero < precision+clead && fp > DBL_MIN); - - /* The total output count (max) is now 4+precision */ - - /* Check for an exponent, if we don't need one we are - * done and just need to terminate the string. At this - * point, exp_b10==(-1) is effectively a flag: it got - * to '-1' because of the decrement, after outputting - * the decimal point above. (The exponent required is - * *not* -1.) - */ - if (exp_b10 >= (-1) && exp_b10 <= 2) - { - /* The following only happens if we didn't output the - * leading zeros above for negative exponent, so this - * doesn't add to the digit requirement. Note that the - * two zeros here can only be output if the two leading - * zeros were *not* output, so this doesn't increase - * the output count. - */ - while (exp_b10-- > 0) *ascii++ = 48; - - *ascii = 0; - - /* Total buffer requirement (including the '\0') is - * 5+precision - see check at the start. - */ - return; - } - - /* Here if an exponent is required, adjust size for - * the digits we output but did not count. The total - * digit output here so far is at most 1+precision - no - * decimal point and no leading or trailing zeros have - * been output. - */ - size -= cdigits; - - *ascii++ = 69; --size; /* 'E': PLUS 1 TOTAL 2+precision */ - - /* The following use of an unsigned temporary avoids ambiguities in - * the signed arithmetic on exp_b10 and permits GCC at least to do - * better optimization. - */ - { - unsigned int uexp_b10; - - if (exp_b10 < 0) - { - *ascii++ = 45; --size; /* '-': PLUS 1 TOTAL 3+precision */ - uexp_b10 = 0U-exp_b10; - } - - else - uexp_b10 = 0U+exp_b10; - - cdigits = 0; - - while (uexp_b10 > 0) - { - exponent[cdigits++] = (char)(48 + uexp_b10 % 10); - uexp_b10 /= 10; - } - } - - /* Need another size check here for the exponent digits, so - * this need not be considered above. - */ - if (size > cdigits) - { - while (cdigits > 0) *ascii++ = exponent[--cdigits]; - - *ascii = 0; - - return; - } - } - } - else if (!(fp >= DBL_MIN)) - { - *ascii++ = 48; /* '0' */ - *ascii = 0; - return; - } - else - { - *ascii++ = 105; /* 'i' */ - *ascii++ = 110; /* 'n' */ - *ascii++ = 102; /* 'f' */ - *ascii = 0; - return; - } - } - - /* Here on buffer too small. */ - png_error(png_ptr, "ASCII conversion buffer too small"); -} -#if GCC_STRICT_OVERFLOW -#pragma GCC diagnostic pop -#endif /* GCC_STRICT_OVERFLOW */ - -# endif /* FLOATING_POINT */ - -# ifdef PNG_FIXED_POINT_SUPPORTED -/* Function to format a fixed point value in ASCII. - */ -void /* PRIVATE */ -png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii, - size_t size, png_fixed_point fp) -{ - /* Require space for 10 decimal digits, a decimal point, a minus sign and a - * trailing \0, 13 characters: - */ - if (size > 12) - { - png_uint_32 num; - - /* Avoid overflow here on the minimum integer. */ - if (fp < 0) - { - *ascii++ = 45; num = (png_uint_32)(-fp); - } - else - num = (png_uint_32)fp; - - if (num <= 0x80000000) /* else overflowed */ - { - unsigned int ndigits = 0, first = 16 /* flag value */; - char digits[10]; - - while (num) - { - /* Split the low digit off num: */ - unsigned int tmp = num/10; - num -= tmp*10; - digits[ndigits++] = (char)(48 + num); - /* Record the first non-zero digit, note that this is a number - * starting at 1, it's not actually the array index. - */ - if (first == 16 && num > 0) - first = ndigits; - num = tmp; - } - - if (ndigits > 0) - { - while (ndigits > 5) *ascii++ = digits[--ndigits]; - /* The remaining digits are fractional digits, ndigits is '5' or - * smaller at this point. It is certainly not zero. Check for a - * non-zero fractional digit: - */ - if (first <= 5) - { - unsigned int i; - *ascii++ = 46; /* decimal point */ - /* ndigits may be <5 for small numbers, output leading zeros - * then ndigits digits to first: - */ - i = 5; - while (ndigits < i) - { - *ascii++ = 48; --i; - } - while (ndigits >= first) *ascii++ = digits[--ndigits]; - /* Don't output the trailing zeros! */ - } - } - else - *ascii++ = 48; - - /* And null terminate the string: */ - *ascii = 0; - return; - } - } - - /* Here on buffer too small. */ - png_error(png_ptr, "ASCII conversion buffer too small"); -} -# endif /* FIXED_POINT */ -#endif /* SCAL */ - -#if defined(PNG_FLOATING_POINT_SUPPORTED) && \ - !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \ - (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \ - defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \ - (defined(PNG_sCAL_SUPPORTED) && \ - defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)) -png_fixed_point -png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text) -{ - double r = floor(100000 * fp + .5); - - if (r > 2147483647. || r < -2147483648.) - png_fixed_error(png_ptr, text); - -# ifndef PNG_ERROR_TEXT_SUPPORTED - PNG_UNUSED(text) -# endif - - return (png_fixed_point)r; -} -#endif - -#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_COLORSPACE_SUPPORTED) ||\ - defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED) -/* muldiv functions */ -/* This API takes signed arguments and rounds the result to the nearest - * integer (or, for a fixed point number - the standard argument - to - * the nearest .00001). Overflow and divide by zero are signalled in - * the result, a boolean - true on success, false on overflow. - */ -#if GCC_STRICT_OVERFLOW /* from above */ -/* It is not obvious which comparison below gets optimized in such a way that - * signed overflow would change the result; looking through the code does not - * reveal any tests which have the form GCC complains about, so presumably the - * optimizer is moving an add or subtract into the 'if' somewhere. - */ -#pragma GCC diagnostic push -#pragma GCC diagnostic warning "-Wstrict-overflow=2" -#endif /* GCC_STRICT_OVERFLOW */ -int -png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times, - png_int_32 divisor) -{ - /* Return a * times / divisor, rounded. */ - if (divisor != 0) - { - if (a == 0 || times == 0) - { - *res = 0; - return 1; - } - else - { -#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - double r = a; - r *= times; - r /= divisor; - r = floor(r+.5); - - /* A png_fixed_point is a 32-bit integer. */ - if (r <= 2147483647. && r >= -2147483648.) - { - *res = (png_fixed_point)r; - return 1; - } -#else - int negative = 0; - png_uint_32 A, T, D; - png_uint_32 s16, s32, s00; - - if (a < 0) - negative = 1, A = -a; - else - A = a; - - if (times < 0) - negative = !negative, T = -times; - else - T = times; - - if (divisor < 0) - negative = !negative, D = -divisor; - else - D = divisor; - - /* Following can't overflow because the arguments only - * have 31 bits each, however the result may be 32 bits. - */ - s16 = (A >> 16) * (T & 0xffff) + - (A & 0xffff) * (T >> 16); - /* Can't overflow because the a*times bit is only 30 - * bits at most. - */ - s32 = (A >> 16) * (T >> 16) + (s16 >> 16); - s00 = (A & 0xffff) * (T & 0xffff); - - s16 = (s16 & 0xffff) << 16; - s00 += s16; - - if (s00 < s16) - ++s32; /* carry */ - - if (s32 < D) /* else overflow */ - { - /* s32.s00 is now the 64-bit product, do a standard - * division, we know that s32 < D, so the maximum - * required shift is 31. - */ - int bitshift = 32; - png_fixed_point result = 0; /* NOTE: signed */ - - while (--bitshift >= 0) - { - png_uint_32 d32, d00; - - if (bitshift > 0) - d32 = D >> (32-bitshift), d00 = D << bitshift; - - else - d32 = 0, d00 = D; - - if (s32 > d32) - { - if (s00 < d00) --s32; /* carry */ - s32 -= d32, s00 -= d00, result += 1<= d00) - s32 = 0, s00 -= d00, result += 1<= (D >> 1)) - ++result; - - if (negative != 0) - result = -result; - - /* Check for overflow. */ - if ((negative != 0 && result <= 0) || - (negative == 0 && result >= 0)) - { - *res = result; - return 1; - } - } -#endif - } - } - - return 0; -} -#if GCC_STRICT_OVERFLOW -#pragma GCC diagnostic pop -#endif /* GCC_STRICT_OVERFLOW */ -#endif /* READ_GAMMA || INCH_CONVERSIONS */ - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED) -/* The following is for when the caller doesn't much care about the - * result. - */ -png_fixed_point -png_muldiv_warn(png_const_structrp png_ptr, png_fixed_point a, png_int_32 times, - png_int_32 divisor) -{ - png_fixed_point result; - - if (png_muldiv(&result, a, times, divisor) != 0) - return result; - - png_warning(png_ptr, "fixed point overflow ignored"); - return 0; -} -#endif - -#ifdef PNG_GAMMA_SUPPORTED /* more fixed point functions for gamma */ -/* Calculate a reciprocal, return 0 on div-by-zero or overflow. */ -png_fixed_point -png_reciprocal(png_fixed_point a) -{ -#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - double r = floor(1E10/a+.5); - - if (r <= 2147483647. && r >= -2147483648.) - return (png_fixed_point)r; -#else - png_fixed_point res; - - if (png_muldiv(&res, 100000, 100000, a) != 0) - return res; -#endif - - return 0; /* error/overflow */ -} - -/* This is the shared test on whether a gamma value is 'significant' - whether - * it is worth doing gamma correction. - */ -int /* PRIVATE */ -png_gamma_significant(png_fixed_point gamma_val) -{ - return gamma_val < PNG_FP_1 - PNG_GAMMA_THRESHOLD_FIXED || - gamma_val > PNG_FP_1 + PNG_GAMMA_THRESHOLD_FIXED; -} -#endif - -#ifdef PNG_READ_GAMMA_SUPPORTED -#ifdef PNG_16BIT_SUPPORTED -/* A local convenience routine. */ -static png_fixed_point -png_product2(png_fixed_point a, png_fixed_point b) -{ - /* The required result is 1/a * 1/b; the following preserves accuracy. */ -#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - double r = a * 1E-5; - r *= b; - r = floor(r+.5); - - if (r <= 2147483647. && r >= -2147483648.) - return (png_fixed_point)r; -#else - png_fixed_point res; - - if (png_muldiv(&res, a, b, 100000) != 0) - return res; -#endif - - return 0; /* overflow */ -} -#endif /* 16BIT */ - -/* The inverse of the above. */ -png_fixed_point -png_reciprocal2(png_fixed_point a, png_fixed_point b) -{ - /* The required result is 1/a * 1/b; the following preserves accuracy. */ -#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - if (a != 0 && b != 0) - { - double r = 1E15/a; - r /= b; - r = floor(r+.5); - - if (r <= 2147483647. && r >= -2147483648.) - return (png_fixed_point)r; - } -#else - /* This may overflow because the range of png_fixed_point isn't symmetric, - * but this API is only used for the product of file and screen gamma so it - * doesn't matter that the smallest number it can produce is 1/21474, not - * 1/100000 - */ - png_fixed_point res = png_product2(a, b); - - if (res != 0) - return png_reciprocal(res); -#endif - - return 0; /* overflow */ -} -#endif /* READ_GAMMA */ - -#ifdef PNG_READ_GAMMA_SUPPORTED /* gamma table code */ -#ifndef PNG_FLOATING_ARITHMETIC_SUPPORTED -/* Fixed point gamma. - * - * The code to calculate the tables used below can be found in the shell script - * contrib/tools/intgamma.sh - * - * To calculate gamma this code implements fast log() and exp() calls using only - * fixed point arithmetic. This code has sufficient precision for either 8-bit - * or 16-bit sample values. - * - * The tables used here were calculated using simple 'bc' programs, but C double - * precision floating point arithmetic would work fine. - * - * 8-bit log table - * This is a table of -log(value/255)/log(2) for 'value' in the range 128 to - * 255, so it's the base 2 logarithm of a normalized 8-bit floating point - * mantissa. The numbers are 32-bit fractions. - */ -static const png_uint_32 -png_8bit_l2[128] = -{ - 4270715492U, 4222494797U, 4174646467U, 4127164793U, 4080044201U, 4033279239U, - 3986864580U, 3940795015U, 3895065449U, 3849670902U, 3804606499U, 3759867474U, - 3715449162U, 3671346997U, 3627556511U, 3584073329U, 3540893168U, 3498011834U, - 3455425220U, 3413129301U, 3371120137U, 3329393864U, 3287946700U, 3246774933U, - 3205874930U, 3165243125U, 3124876025U, 3084770202U, 3044922296U, 3005329011U, - 2965987113U, 2926893432U, 2888044853U, 2849438323U, 2811070844U, 2772939474U, - 2735041326U, 2697373562U, 2659933400U, 2622718104U, 2585724991U, 2548951424U, - 2512394810U, 2476052606U, 2439922311U, 2404001468U, 2368287663U, 2332778523U, - 2297471715U, 2262364947U, 2227455964U, 2192742551U, 2158222529U, 2123893754U, - 2089754119U, 2055801552U, 2022034013U, 1988449497U, 1955046031U, 1921821672U, - 1888774511U, 1855902668U, 1823204291U, 1790677560U, 1758320682U, 1726131893U, - 1694109454U, 1662251657U, 1630556815U, 1599023271U, 1567649391U, 1536433567U, - 1505374214U, 1474469770U, 1443718700U, 1413119487U, 1382670639U, 1352370686U, - 1322218179U, 1292211689U, 1262349810U, 1232631153U, 1203054352U, 1173618059U, - 1144320946U, 1115161701U, 1086139034U, 1057251672U, 1028498358U, 999877854U, - 971388940U, 943030410U, 914801076U, 886699767U, 858725327U, 830876614U, - 803152505U, 775551890U, 748073672U, 720716771U, 693480120U, 666362667U, - 639363374U, 612481215U, 585715177U, 559064263U, 532527486U, 506103872U, - 479792461U, 453592303U, 427502463U, 401522014U, 375650043U, 349885648U, - 324227938U, 298676034U, 273229066U, 247886176U, 222646516U, 197509248U, - 172473545U, 147538590U, 122703574U, 97967701U, 73330182U, 48790236U, - 24347096U, 0U - -#if 0 - /* The following are the values for 16-bit tables - these work fine for the - * 8-bit conversions but produce very slightly larger errors in the 16-bit - * log (about 1.2 as opposed to 0.7 absolute error in the final value). To - * use these all the shifts below must be adjusted appropriately. - */ - 65166, 64430, 63700, 62976, 62257, 61543, 60835, 60132, 59434, 58741, 58054, - 57371, 56693, 56020, 55352, 54689, 54030, 53375, 52726, 52080, 51439, 50803, - 50170, 49542, 48918, 48298, 47682, 47070, 46462, 45858, 45257, 44661, 44068, - 43479, 42894, 42312, 41733, 41159, 40587, 40020, 39455, 38894, 38336, 37782, - 37230, 36682, 36137, 35595, 35057, 34521, 33988, 33459, 32932, 32408, 31887, - 31369, 30854, 30341, 29832, 29325, 28820, 28319, 27820, 27324, 26830, 26339, - 25850, 25364, 24880, 24399, 23920, 23444, 22970, 22499, 22029, 21562, 21098, - 20636, 20175, 19718, 19262, 18808, 18357, 17908, 17461, 17016, 16573, 16132, - 15694, 15257, 14822, 14390, 13959, 13530, 13103, 12678, 12255, 11834, 11415, - 10997, 10582, 10168, 9756, 9346, 8937, 8531, 8126, 7723, 7321, 6921, 6523, - 6127, 5732, 5339, 4947, 4557, 4169, 3782, 3397, 3014, 2632, 2251, 1872, 1495, - 1119, 744, 372 -#endif -}; - -static png_int_32 -png_log8bit(unsigned int x) -{ - unsigned int lg2 = 0; - /* Each time 'x' is multiplied by 2, 1 must be subtracted off the final log, - * because the log is actually negate that means adding 1. The final - * returned value thus has the range 0 (for 255 input) to 7.994 (for 1 - * input), return -1 for the overflow (log 0) case, - so the result is - * always at most 19 bits. - */ - if ((x &= 0xff) == 0) - return -1; - - if ((x & 0xf0) == 0) - lg2 = 4, x <<= 4; - - if ((x & 0xc0) == 0) - lg2 += 2, x <<= 2; - - if ((x & 0x80) == 0) - lg2 += 1, x <<= 1; - - /* result is at most 19 bits, so this cast is safe: */ - return (png_int_32)((lg2 << 16) + ((png_8bit_l2[x-128]+32768)>>16)); -} - -/* The above gives exact (to 16 binary places) log2 values for 8-bit images, - * for 16-bit images we use the most significant 8 bits of the 16-bit value to - * get an approximation then multiply the approximation by a correction factor - * determined by the remaining up to 8 bits. This requires an additional step - * in the 16-bit case. - * - * We want log2(value/65535), we have log2(v'/255), where: - * - * value = v' * 256 + v'' - * = v' * f - * - * So f is value/v', which is equal to (256+v''/v') since v' is in the range 128 - * to 255 and v'' is in the range 0 to 255 f will be in the range 256 to less - * than 258. The final factor also needs to correct for the fact that our 8-bit - * value is scaled by 255, whereas the 16-bit values must be scaled by 65535. - * - * This gives a final formula using a calculated value 'x' which is value/v' and - * scaling by 65536 to match the above table: - * - * log2(x/257) * 65536 - * - * Since these numbers are so close to '1' we can use simple linear - * interpolation between the two end values 256/257 (result -368.61) and 258/257 - * (result 367.179). The values used below are scaled by a further 64 to give - * 16-bit precision in the interpolation: - * - * Start (256): -23591 - * Zero (257): 0 - * End (258): 23499 - */ -#ifdef PNG_16BIT_SUPPORTED -static png_int_32 -png_log16bit(png_uint_32 x) -{ - unsigned int lg2 = 0; - - /* As above, but now the input has 16 bits. */ - if ((x &= 0xffff) == 0) - return -1; - - if ((x & 0xff00) == 0) - lg2 = 8, x <<= 8; - - if ((x & 0xf000) == 0) - lg2 += 4, x <<= 4; - - if ((x & 0xc000) == 0) - lg2 += 2, x <<= 2; - - if ((x & 0x8000) == 0) - lg2 += 1, x <<= 1; - - /* Calculate the base logarithm from the top 8 bits as a 28-bit fractional - * value. - */ - lg2 <<= 28; - lg2 += (png_8bit_l2[(x>>8)-128]+8) >> 4; - - /* Now we need to interpolate the factor, this requires a division by the top - * 8 bits. Do this with maximum precision. - */ - x = ((x << 16) + (x >> 9)) / (x >> 8); - - /* Since we divided by the top 8 bits of 'x' there will be a '1' at 1<<24, - * the value at 1<<16 (ignoring this) will be 0 or 1; this gives us exactly - * 16 bits to interpolate to get the low bits of the result. Round the - * answer. Note that the end point values are scaled by 64 to retain overall - * precision and that 'lg2' is current scaled by an extra 12 bits, so adjust - * the overall scaling by 6-12. Round at every step. - */ - x -= 1U << 24; - - if (x <= 65536U) /* <= '257' */ - lg2 += ((23591U * (65536U-x)) + (1U << (16+6-12-1))) >> (16+6-12); - - else - lg2 -= ((23499U * (x-65536U)) + (1U << (16+6-12-1))) >> (16+6-12); - - /* Safe, because the result can't have more than 20 bits: */ - return (png_int_32)((lg2 + 2048) >> 12); -} -#endif /* 16BIT */ - -/* The 'exp()' case must invert the above, taking a 20-bit fixed point - * logarithmic value and returning a 16 or 8-bit number as appropriate. In - * each case only the low 16 bits are relevant - the fraction - since the - * integer bits (the top 4) simply determine a shift. - * - * The worst case is the 16-bit distinction between 65535 and 65534. This - * requires perhaps spurious accuracy in the decoding of the logarithm to - * distinguish log2(65535/65534.5) - 10^-5 or 17 bits. There is little chance - * of getting this accuracy in practice. - * - * To deal with this the following exp() function works out the exponent of the - * fractional part of the logarithm by using an accurate 32-bit value from the - * top four fractional bits then multiplying in the remaining bits. - */ -static const png_uint_32 -png_32bit_exp[16] = -{ - /* NOTE: the first entry is deliberately set to the maximum 32-bit value. */ - 4294967295U, 4112874773U, 3938502376U, 3771522796U, 3611622603U, 3458501653U, - 3311872529U, 3171459999U, 3037000500U, 2908241642U, 2784941738U, 2666869345U, - 2553802834U, 2445529972U, 2341847524U, 2242560872U -}; - -/* Adjustment table; provided to explain the numbers in the code below. */ -#if 0 -for (i=11;i>=0;--i){ print i, " ", (1 - e(-(2^i)/65536*l(2))) * 2^(32-i), "\n"} - 11 44937.64284865548751208448 - 10 45180.98734845585101160448 - 9 45303.31936980687359311872 - 8 45364.65110595323018870784 - 7 45395.35850361789624614912 - 6 45410.72259715102037508096 - 5 45418.40724413220722311168 - 4 45422.25021786898173001728 - 3 45424.17186732298419044352 - 2 45425.13273269940811464704 - 1 45425.61317555035558641664 - 0 45425.85339951654943850496 -#endif - -static png_uint_32 -png_exp(png_fixed_point x) -{ - if (x > 0 && x <= 0xfffff) /* Else overflow or zero (underflow) */ - { - /* Obtain a 4-bit approximation */ - png_uint_32 e = png_32bit_exp[(x >> 12) & 0x0f]; - - /* Incorporate the low 12 bits - these decrease the returned value by - * multiplying by a number less than 1 if the bit is set. The multiplier - * is determined by the above table and the shift. Notice that the values - * converge on 45426 and this is used to allow linear interpolation of the - * low bits. - */ - if (x & 0x800) - e -= (((e >> 16) * 44938U) + 16U) >> 5; - - if (x & 0x400) - e -= (((e >> 16) * 45181U) + 32U) >> 6; - - if (x & 0x200) - e -= (((e >> 16) * 45303U) + 64U) >> 7; - - if (x & 0x100) - e -= (((e >> 16) * 45365U) + 128U) >> 8; - - if (x & 0x080) - e -= (((e >> 16) * 45395U) + 256U) >> 9; - - if (x & 0x040) - e -= (((e >> 16) * 45410U) + 512U) >> 10; - - /* And handle the low 6 bits in a single block. */ - e -= (((e >> 16) * 355U * (x & 0x3fU)) + 256U) >> 9; - - /* Handle the upper bits of x. */ - e >>= x >> 16; - return e; - } - - /* Check for overflow */ - if (x <= 0) - return png_32bit_exp[0]; - - /* Else underflow */ - return 0; -} - -static png_byte -png_exp8bit(png_fixed_point lg2) -{ - /* Get a 32-bit value: */ - png_uint_32 x = png_exp(lg2); - - /* Convert the 32-bit value to 0..255 by multiplying by 256-1. Note that the - * second, rounding, step can't overflow because of the first, subtraction, - * step. - */ - x -= x >> 8; - return (png_byte)(((x + 0x7fffffU) >> 24) & 0xff); -} - -#ifdef PNG_16BIT_SUPPORTED -static png_uint_16 -png_exp16bit(png_fixed_point lg2) -{ - /* Get a 32-bit value: */ - png_uint_32 x = png_exp(lg2); - - /* Convert the 32-bit value to 0..65535 by multiplying by 65536-1: */ - x -= x >> 16; - return (png_uint_16)((x + 32767U) >> 16); -} -#endif /* 16BIT */ -#endif /* FLOATING_ARITHMETIC */ - -png_byte -png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val) -{ - if (value > 0 && value < 255) - { -# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - /* 'value' is unsigned, ANSI-C90 requires the compiler to correctly - * convert this to a floating point value. This includes values that - * would overflow if 'value' were to be converted to 'int'. - * - * Apparently GCC, however, does an intermediate conversion to (int) - * on some (ARM) but not all (x86) platforms, possibly because of - * hardware FP limitations. (E.g. if the hardware conversion always - * assumes the integer register contains a signed value.) This results - * in ANSI-C undefined behavior for large values. - * - * Other implementations on the same machine might actually be ANSI-C90 - * conformant and therefore compile spurious extra code for the large - * values. - * - * We can be reasonably sure that an unsigned to float conversion - * won't be faster than an int to float one. Therefore this code - * assumes responsibility for the undefined behavior, which it knows - * can't happen because of the check above. - * - * Note the argument to this routine is an (unsigned int) because, on - * 16-bit platforms, it is assigned a value which might be out of - * range for an (int); that would result in undefined behavior in the - * caller if the *argument* ('value') were to be declared (int). - */ - double r = floor(255*pow((int)/*SAFE*/value/255.,gamma_val*.00001)+.5); - return (png_byte)r; -# else - png_int_32 lg2 = png_log8bit(value); - png_fixed_point res; - - if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1) != 0) - return png_exp8bit(res); - - /* Overflow. */ - value = 0; -# endif - } - - return (png_byte)(value & 0xff); -} - -#ifdef PNG_16BIT_SUPPORTED -png_uint_16 -png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val) -{ - if (value > 0 && value < 65535) - { -# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - /* The same (unsigned int)->(double) constraints apply here as above, - * however in this case the (unsigned int) to (int) conversion can - * overflow on an ANSI-C90 compliant system so the cast needs to ensure - * that this is not possible. - */ - double r = floor(65535*pow((png_int_32)value/65535., - gamma_val*.00001)+.5); - return (png_uint_16)r; -# else - png_int_32 lg2 = png_log16bit(value); - png_fixed_point res; - - if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1) != 0) - return png_exp16bit(res); - - /* Overflow. */ - value = 0; -# endif - } - - return (png_uint_16)value; -} -#endif /* 16BIT */ - -/* This does the right thing based on the bit_depth field of the - * png_struct, interpreting values as 8-bit or 16-bit. While the result - * is nominally a 16-bit value if bit depth is 8 then the result is - * 8-bit (as are the arguments.) - */ -png_uint_16 /* PRIVATE */ -png_gamma_correct(png_structrp png_ptr, unsigned int value, - png_fixed_point gamma_val) -{ - if (png_ptr->bit_depth == 8) - return png_gamma_8bit_correct(value, gamma_val); - -#ifdef PNG_16BIT_SUPPORTED - else - return png_gamma_16bit_correct(value, gamma_val); -#else - /* should not reach this */ - return 0; -#endif /* 16BIT */ -} - -#ifdef PNG_16BIT_SUPPORTED -/* Internal function to build a single 16-bit table - the table consists of - * 'num' 256 entry subtables, where 'num' is determined by 'shift' - the amount - * to shift the input values right (or 16-number_of_signifiant_bits). - * - * The caller is responsible for ensuring that the table gets cleaned up on - * png_error (i.e. if one of the mallocs below fails) - i.e. the *table argument - * should be somewhere that will be cleaned. - */ -static void -png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, - unsigned int shift, png_fixed_point gamma_val) -{ - /* Various values derived from 'shift': */ - unsigned int num = 1U << (8U - shift); -#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - /* CSE the division and work round wacky GCC warnings (see the comments - * in png_gamma_8bit_correct for where these come from.) - */ - double fmax = 1.0 / (((png_int_32)1 << (16U - shift)) - 1); -#endif - unsigned int max = (1U << (16U - shift)) - 1U; - unsigned int max_by_2 = 1U << (15U - shift); - unsigned int i; - - png_uint_16pp table = *ptable = - (png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p))); - - for (i = 0; i < num; i++) - { - png_uint_16p sub_table = table[i] = - (png_uint_16p)png_malloc(png_ptr, 256 * (sizeof (png_uint_16))); - - /* The 'threshold' test is repeated here because it can arise for one of - * the 16-bit tables even if the others don't hit it. - */ - if (png_gamma_significant(gamma_val) != 0) - { - /* The old code would overflow at the end and this would cause the - * 'pow' function to return a result >1, resulting in an - * arithmetic error. This code follows the spec exactly; ig is - * the recovered input sample, it always has 8-16 bits. - * - * We want input * 65535/max, rounded, the arithmetic fits in 32 - * bits (unsigned) so long as max <= 32767. - */ - unsigned int j; - for (j = 0; j < 256; j++) - { - png_uint_32 ig = (j << (8-shift)) + i; -# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - /* Inline the 'max' scaling operation: */ - /* See png_gamma_8bit_correct for why the cast to (int) is - * required here. - */ - double d = floor(65535.*pow(ig*fmax, gamma_val*.00001)+.5); - sub_table[j] = (png_uint_16)d; -# else - if (shift != 0) - ig = (ig * 65535U + max_by_2)/max; - - sub_table[j] = png_gamma_16bit_correct(ig, gamma_val); -# endif - } - } - else - { - /* We must still build a table, but do it the fast way. */ - unsigned int j; - - for (j = 0; j < 256; j++) - { - png_uint_32 ig = (j << (8-shift)) + i; - - if (shift != 0) - ig = (ig * 65535U + max_by_2)/max; - - sub_table[j] = (png_uint_16)ig; - } - } - } -} - -/* NOTE: this function expects the *inverse* of the overall gamma transformation - * required. - */ -static void -png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable, - unsigned int shift, png_fixed_point gamma_val) -{ - unsigned int num = 1U << (8U - shift); - unsigned int max = (1U << (16U - shift))-1U; - unsigned int i; - png_uint_32 last; - - png_uint_16pp table = *ptable = - (png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p))); - - /* 'num' is the number of tables and also the number of low bits of low - * bits of the input 16-bit value used to select a table. Each table is - * itself indexed by the high 8 bits of the value. - */ - for (i = 0; i < num; i++) - table[i] = (png_uint_16p)png_malloc(png_ptr, - 256 * (sizeof (png_uint_16))); - - /* 'gamma_val' is set to the reciprocal of the value calculated above, so - * pow(out,g) is an *input* value. 'last' is the last input value set. - * - * In the loop 'i' is used to find output values. Since the output is - * 8-bit there are only 256 possible values. The tables are set up to - * select the closest possible output value for each input by finding - * the input value at the boundary between each pair of output values - * and filling the table up to that boundary with the lower output - * value. - * - * The boundary values are 0.5,1.5..253.5,254.5. Since these are 9-bit - * values the code below uses a 16-bit value in i; the values start at - * 128.5 (for 0.5) and step by 257, for a total of 254 values (the last - * entries are filled with 255). Start i at 128 and fill all 'last' - * table entries <= 'max' - */ - last = 0; - for (i = 0; i < 255; ++i) /* 8-bit output value */ - { - /* Find the corresponding maximum input value */ - png_uint_16 out = (png_uint_16)(i * 257U); /* 16-bit output value */ - - /* Find the boundary value in 16 bits: */ - png_uint_32 bound = png_gamma_16bit_correct(out+128U, gamma_val); - - /* Adjust (round) to (16-shift) bits: */ - bound = (bound * max + 32768U)/65535U + 1U; - - while (last < bound) - { - table[last & (0xffU >> shift)][last >> (8U - shift)] = out; - last++; - } - } - - /* And fill in the final entries. */ - while (last < (num << 8)) - { - table[last & (0xff >> shift)][last >> (8U - shift)] = 65535U; - last++; - } -} -#endif /* 16BIT */ - -/* Build a single 8-bit table: same as the 16-bit case but much simpler (and - * typically much faster). Note that libpng currently does no sBIT processing - * (apparently contrary to the spec) so a 256-entry table is always generated. - */ -static void -png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable, - png_fixed_point gamma_val) -{ - unsigned int i; - png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256); - - if (png_gamma_significant(gamma_val) != 0) - for (i=0; i<256; i++) - table[i] = png_gamma_8bit_correct(i, gamma_val); - - else - for (i=0; i<256; ++i) - table[i] = (png_byte)(i & 0xff); -} - -/* Used from png_read_destroy and below to release the memory used by the gamma - * tables. - */ -void /* PRIVATE */ -png_destroy_gamma_table(png_structrp png_ptr) -{ - png_free(png_ptr, png_ptr->gamma_table); - png_ptr->gamma_table = NULL; - -#ifdef PNG_16BIT_SUPPORTED - if (png_ptr->gamma_16_table != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_table[i]); - } - png_free(png_ptr, png_ptr->gamma_16_table); - png_ptr->gamma_16_table = NULL; - } -#endif /* 16BIT */ - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - png_free(png_ptr, png_ptr->gamma_from_1); - png_ptr->gamma_from_1 = NULL; - png_free(png_ptr, png_ptr->gamma_to_1); - png_ptr->gamma_to_1 = NULL; - -#ifdef PNG_16BIT_SUPPORTED - if (png_ptr->gamma_16_from_1 != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_from_1[i]); - } - png_free(png_ptr, png_ptr->gamma_16_from_1); - png_ptr->gamma_16_from_1 = NULL; - } - if (png_ptr->gamma_16_to_1 != NULL) - { - int i; - int istop = (1 << (8 - png_ptr->gamma_shift)); - for (i = 0; i < istop; i++) - { - png_free(png_ptr, png_ptr->gamma_16_to_1[i]); - } - png_free(png_ptr, png_ptr->gamma_16_to_1); - png_ptr->gamma_16_to_1 = NULL; - } -#endif /* 16BIT */ -#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ -} - -/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit - * tables, we don't make a full table if we are reducing to 8-bit in - * the future. Note also how the gamma_16 tables are segmented so that - * we don't need to allocate > 64K chunks for a full 16-bit table. - */ -void /* PRIVATE */ -png_build_gamma_table(png_structrp png_ptr, int bit_depth) -{ - png_debug(1, "in png_build_gamma_table"); - - /* Remove any existing table; this copes with multiple calls to - * png_read_update_info. The warning is because building the gamma tables - * multiple times is a performance hit - it's harmless but the ability to - * call png_read_update_info() multiple times is new in 1.5.6 so it seems - * sensible to warn if the app introduces such a hit. - */ - if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL) - { - png_warning(png_ptr, "gamma table being rebuilt"); - png_destroy_gamma_table(png_ptr); - } - - if (bit_depth <= 8) - { - png_build_8bit_table(png_ptr, &png_ptr->gamma_table, - png_ptr->screen_gamma > 0 ? - png_reciprocal2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma) : PNG_FP_1); - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0) - { - png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1, - png_reciprocal(png_ptr->colorspace.gamma)); - - png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1, - png_ptr->screen_gamma > 0 ? - png_reciprocal(png_ptr->screen_gamma) : - png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); - } -#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ - } -#ifdef PNG_16BIT_SUPPORTED - else - { - png_byte shift, sig_bit; - - if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) - { - sig_bit = png_ptr->sig_bit.red; - - if (png_ptr->sig_bit.green > sig_bit) - sig_bit = png_ptr->sig_bit.green; - - if (png_ptr->sig_bit.blue > sig_bit) - sig_bit = png_ptr->sig_bit.blue; - } - else - sig_bit = png_ptr->sig_bit.gray; - - /* 16-bit gamma code uses this equation: - * - * ov = table[(iv & 0xff) >> gamma_shift][iv >> 8] - * - * Where 'iv' is the input color value and 'ov' is the output value - - * pow(iv, gamma). - * - * Thus the gamma table consists of up to 256 256-entry tables. The table - * is selected by the (8-gamma_shift) most significant of the low 8 bits - * of the color value then indexed by the upper 8 bits: - * - * table[low bits][high 8 bits] - * - * So the table 'n' corresponds to all those 'iv' of: - * - * ..<(n+1 << gamma_shift)-1> - * - */ - if (sig_bit > 0 && sig_bit < 16U) - /* shift == insignificant bits */ - shift = (png_byte)((16U - sig_bit) & 0xff); - - else - shift = 0; /* keep all 16 bits */ - - if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0) - { - /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively - * the significant bits in the *input* when the output will - * eventually be 8 bits. By default it is 11. - */ - if (shift < (16U - PNG_MAX_GAMMA_8)) - shift = (16U - PNG_MAX_GAMMA_8); - } - - if (shift > 8U) - shift = 8U; /* Guarantees at least one table! */ - - png_ptr->gamma_shift = shift; - - /* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now - * PNG_COMPOSE). This effectively smashed the background calculation for - * 16-bit output because the 8-bit table assumes the result will be - * reduced to 8 bits. - */ - if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0) - png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift, - png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma) : PNG_FP_1); - - else - png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift, - png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma) : PNG_FP_1); - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0) - { - png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift, - png_reciprocal(png_ptr->colorspace.gamma)); - - /* Notice that the '16 from 1' table should be full precision, however - * the lookup on this table still uses gamma_shift, so it can't be. - * TODO: fix this. - */ - png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift, - png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) : - png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); - } -#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ - } -#endif /* 16BIT */ -} -#endif /* READ_GAMMA */ - -/* HARDWARE OR SOFTWARE OPTION SUPPORT */ -#ifdef PNG_SET_OPTION_SUPPORTED -int PNGAPI -png_set_option(png_structrp png_ptr, int option, int onoff) -{ - if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT && - (option & 1) == 0) - { - png_uint_32 mask = 3U << option; - png_uint_32 setting = (2U + (onoff != 0)) << option; - png_uint_32 current = png_ptr->options; - - png_ptr->options = (png_uint_32)((current & ~mask) | setting); - - return (int)(current & mask) >> option; - } - - return PNG_OPTION_INVALID; -} -#endif - -/* sRGB support */ -#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ - defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) -/* sRGB conversion tables; these are machine generated with the code in - * contrib/tools/makesRGB.c. The actual sRGB transfer curve defined in the - * specification (see the article at https://en.wikipedia.org/wiki/SRGB) - * is used, not the gamma=1/2.2 approximation use elsewhere in libpng. - * The sRGB to linear table is exact (to the nearest 16-bit linear fraction). - * The inverse (linear to sRGB) table has accuracies as follows: - * - * For all possible (255*65535+1) input values: - * - * error: -0.515566 - 0.625971, 79441 (0.475369%) of readings inexact - * - * For the input values corresponding to the 65536 16-bit values: - * - * error: -0.513727 - 0.607759, 308 (0.469978%) of readings inexact - * - * In all cases the inexact readings are only off by one. - */ - -#ifdef PNG_SIMPLIFIED_READ_SUPPORTED -/* The convert-to-sRGB table is only currently required for read. */ -const png_uint_16 png_sRGB_table[256] = -{ - 0,20,40,60,80,99,119,139, - 159,179,199,219,241,264,288,313, - 340,367,396,427,458,491,526,562, - 599,637,677,718,761,805,851,898, - 947,997,1048,1101,1156,1212,1270,1330, - 1391,1453,1517,1583,1651,1720,1790,1863, - 1937,2013,2090,2170,2250,2333,2418,2504, - 2592,2681,2773,2866,2961,3058,3157,3258, - 3360,3464,3570,3678,3788,3900,4014,4129, - 4247,4366,4488,4611,4736,4864,4993,5124, - 5257,5392,5530,5669,5810,5953,6099,6246, - 6395,6547,6700,6856,7014,7174,7335,7500, - 7666,7834,8004,8177,8352,8528,8708,8889, - 9072,9258,9445,9635,9828,10022,10219,10417, - 10619,10822,11028,11235,11446,11658,11873,12090, - 12309,12530,12754,12980,13209,13440,13673,13909, - 14146,14387,14629,14874,15122,15371,15623,15878, - 16135,16394,16656,16920,17187,17456,17727,18001, - 18277,18556,18837,19121,19407,19696,19987,20281, - 20577,20876,21177,21481,21787,22096,22407,22721, - 23038,23357,23678,24002,24329,24658,24990,25325, - 25662,26001,26344,26688,27036,27386,27739,28094, - 28452,28813,29176,29542,29911,30282,30656,31033, - 31412,31794,32179,32567,32957,33350,33745,34143, - 34544,34948,35355,35764,36176,36591,37008,37429, - 37852,38278,38706,39138,39572,40009,40449,40891, - 41337,41785,42236,42690,43147,43606,44069,44534, - 45002,45473,45947,46423,46903,47385,47871,48359, - 48850,49344,49841,50341,50844,51349,51858,52369, - 52884,53401,53921,54445,54971,55500,56032,56567, - 57105,57646,58190,58737,59287,59840,60396,60955, - 61517,62082,62650,63221,63795,64372,64952,65535 -}; -#endif /* SIMPLIFIED_READ */ - -/* The base/delta tables are required for both read and write (but currently - * only the simplified versions.) - */ -const png_uint_16 png_sRGB_base[512] = -{ - 128,1782,3383,4644,5675,6564,7357,8074, - 8732,9346,9921,10463,10977,11466,11935,12384, - 12816,13233,13634,14024,14402,14769,15125,15473, - 15812,16142,16466,16781,17090,17393,17690,17981, - 18266,18546,18822,19093,19359,19621,19879,20133, - 20383,20630,20873,21113,21349,21583,21813,22041, - 22265,22487,22707,22923,23138,23350,23559,23767, - 23972,24175,24376,24575,24772,24967,25160,25352, - 25542,25730,25916,26101,26284,26465,26645,26823, - 27000,27176,27350,27523,27695,27865,28034,28201, - 28368,28533,28697,28860,29021,29182,29341,29500, - 29657,29813,29969,30123,30276,30429,30580,30730, - 30880,31028,31176,31323,31469,31614,31758,31902, - 32045,32186,32327,32468,32607,32746,32884,33021, - 33158,33294,33429,33564,33697,33831,33963,34095, - 34226,34357,34486,34616,34744,34873,35000,35127, - 35253,35379,35504,35629,35753,35876,35999,36122, - 36244,36365,36486,36606,36726,36845,36964,37083, - 37201,37318,37435,37551,37668,37783,37898,38013, - 38127,38241,38354,38467,38580,38692,38803,38915, - 39026,39136,39246,39356,39465,39574,39682,39790, - 39898,40005,40112,40219,40325,40431,40537,40642, - 40747,40851,40955,41059,41163,41266,41369,41471, - 41573,41675,41777,41878,41979,42079,42179,42279, - 42379,42478,42577,42676,42775,42873,42971,43068, - 43165,43262,43359,43456,43552,43648,43743,43839, - 43934,44028,44123,44217,44311,44405,44499,44592, - 44685,44778,44870,44962,45054,45146,45238,45329, - 45420,45511,45601,45692,45782,45872,45961,46051, - 46140,46229,46318,46406,46494,46583,46670,46758, - 46846,46933,47020,47107,47193,47280,47366,47452, - 47538,47623,47709,47794,47879,47964,48048,48133, - 48217,48301,48385,48468,48552,48635,48718,48801, - 48884,48966,49048,49131,49213,49294,49376,49458, - 49539,49620,49701,49782,49862,49943,50023,50103, - 50183,50263,50342,50422,50501,50580,50659,50738, - 50816,50895,50973,51051,51129,51207,51285,51362, - 51439,51517,51594,51671,51747,51824,51900,51977, - 52053,52129,52205,52280,52356,52432,52507,52582, - 52657,52732,52807,52881,52956,53030,53104,53178, - 53252,53326,53400,53473,53546,53620,53693,53766, - 53839,53911,53984,54056,54129,54201,54273,54345, - 54417,54489,54560,54632,54703,54774,54845,54916, - 54987,55058,55129,55199,55269,55340,55410,55480, - 55550,55620,55689,55759,55828,55898,55967,56036, - 56105,56174,56243,56311,56380,56448,56517,56585, - 56653,56721,56789,56857,56924,56992,57059,57127, - 57194,57261,57328,57395,57462,57529,57595,57662, - 57728,57795,57861,57927,57993,58059,58125,58191, - 58256,58322,58387,58453,58518,58583,58648,58713, - 58778,58843,58908,58972,59037,59101,59165,59230, - 59294,59358,59422,59486,59549,59613,59677,59740, - 59804,59867,59930,59993,60056,60119,60182,60245, - 60308,60370,60433,60495,60558,60620,60682,60744, - 60806,60868,60930,60992,61054,61115,61177,61238, - 61300,61361,61422,61483,61544,61605,61666,61727, - 61788,61848,61909,61969,62030,62090,62150,62211, - 62271,62331,62391,62450,62510,62570,62630,62689, - 62749,62808,62867,62927,62986,63045,63104,63163, - 63222,63281,63340,63398,63457,63515,63574,63632, - 63691,63749,63807,63865,63923,63981,64039,64097, - 64155,64212,64270,64328,64385,64443,64500,64557, - 64614,64672,64729,64786,64843,64900,64956,65013, - 65070,65126,65183,65239,65296,65352,65409,65465 -}; - -const png_byte png_sRGB_delta[512] = -{ - 207,201,158,129,113,100,90,82,77,72,68,64,61,59,56,54, - 52,50,49,47,46,45,43,42,41,40,39,39,38,37,36,36, - 35,34,34,33,33,32,32,31,31,30,30,30,29,29,28,28, - 28,27,27,27,27,26,26,26,25,25,25,25,24,24,24,24, - 23,23,23,23,23,22,22,22,22,22,22,21,21,21,21,21, - 21,20,20,20,20,20,20,20,20,19,19,19,19,19,19,19, - 19,18,18,18,18,18,18,18,18,18,18,17,17,17,17,17, - 17,17,17,17,17,17,16,16,16,16,16,16,16,16,16,16, - 16,16,16,16,15,15,15,15,15,15,15,15,15,15,15,15, - 15,15,15,15,14,14,14,14,14,14,14,14,14,14,14,14, - 14,14,14,14,14,14,14,13,13,13,13,13,13,13,13,13, - 13,13,13,13,13,13,13,13,13,13,13,13,13,13,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, - 12,12,12,12,12,12,12,12,12,12,12,12,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11, - 11,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, - 10,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 9,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, - 8,8,8,8,8,8,8,8,8,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 -}; -#endif /* SIMPLIFIED READ/WRITE sRGB support */ - -/* SIMPLIFIED READ/WRITE SUPPORT */ -#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ - defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) -static int -png_image_free_function(png_voidp argument) -{ - png_imagep image = png_voidcast(png_imagep, argument); - png_controlp cp = image->opaque; - png_control c; - - /* Double check that we have a png_ptr - it should be impossible to get here - * without one. - */ - if (cp->png_ptr == NULL) - return 0; - - /* First free any data held in the control structure. */ -# ifdef PNG_STDIO_SUPPORTED - if (cp->owned_file != 0) - { - FILE *fp = png_voidcast(FILE*, cp->png_ptr->io_ptr); - cp->owned_file = 0; - - /* Ignore errors here. */ - if (fp != NULL) - { - cp->png_ptr->io_ptr = NULL; - (void)fclose(fp); - } - } -# endif - - /* Copy the control structure so that the original, allocated, version can be - * safely freed. Notice that a png_error here stops the remainder of the - * cleanup, but this is probably fine because that would indicate bad memory - * problems anyway. - */ - c = *cp; - image->opaque = &c; - png_free(c.png_ptr, cp); - - /* Then the structures, calling the correct API. */ - if (c.for_write != 0) - { -# ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED - png_destroy_write_struct(&c.png_ptr, &c.info_ptr); -# else - png_error(c.png_ptr, "simplified write not supported"); -# endif - } - else - { -# ifdef PNG_SIMPLIFIED_READ_SUPPORTED - png_destroy_read_struct(&c.png_ptr, &c.info_ptr, NULL); -# else - png_error(c.png_ptr, "simplified read not supported"); -# endif - } - - /* Success. */ - return 1; -} - -void PNGAPI -png_image_free(png_imagep image) -{ - /* Safely call the real function, but only if doing so is safe at this point - * (if not inside an error handling context). Otherwise assume - * png_safe_execute will call this API after the return. - */ - if (image != NULL && image->opaque != NULL && - image->opaque->error_buf == NULL) - { - png_image_free_function(image); - image->opaque = NULL; - } -} - -int /* PRIVATE */ -png_image_error(png_imagep image, png_const_charp error_message) -{ - /* Utility to log an error. */ - png_safecat(image->message, (sizeof image->message), 0, error_message); - image->warning_or_error |= PNG_IMAGE_ERROR; - png_image_free(image); - return 0; -} - -#endif /* SIMPLIFIED READ/WRITE */ -#endif /* READ || WRITE */ diff --git a/oversampling/WDL/libpng/png.h b/oversampling/WDL/libpng/png.h deleted file mode 100644 index 139eb0d..0000000 --- a/oversampling/WDL/libpng/png.h +++ /dev/null @@ -1,3247 +0,0 @@ - -/* png.h - header file for PNG reference library - * - * libpng version 1.6.37 - April 14, 2019 - * - * Copyright (c) 2018-2019 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. (See LICENSE, below.) - * - * Authors and maintainers: - * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat - * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.6.35, July 2018: - * Glenn Randers-Pehrson - * libpng versions 1.6.36, December 2018, through 1.6.37, April 2019: - * Cosmin Truta - * See also "Contributing Authors", below. - */ - -/* - * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE - * ========================================= - * - * PNG Reference Library License version 2 - * --------------------------------------- - * - * * Copyright (c) 1995-2019 The PNG Reference Library Authors. - * * Copyright (c) 2018-2019 Cosmin Truta. - * * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. - * * Copyright (c) 1996-1997 Andreas Dilger. - * * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * The software is supplied "as is", without warranty of any kind, - * express or implied, including, without limitation, the warranties - * of merchantability, fitness for a particular purpose, title, and - * non-infringement. In no event shall the Copyright owners, or - * anyone distributing the software, be liable for any damages or - * other liability, whether in contract, tort or otherwise, arising - * from, out of, or in connection with the software, or the use or - * other dealings in the software, even if advised of the possibility - * of such damage. - * - * Permission is hereby granted to use, copy, modify, and distribute - * this software, or portions hereof, for any purpose, without fee, - * subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you - * must not claim that you wrote the original software. If you - * use this software in a product, an acknowledgment in the product - * documentation would be appreciated, but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must - * not be misrepresented as being the original software. - * - * 3. This Copyright notice may not be removed or altered from any - * source or altered source distribution. - * - * - * PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35) - * ----------------------------------------------------------------------- - * - * libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are - * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are - * derived from libpng-1.0.6, and are distributed according to the same - * disclaimer and license as libpng-1.0.6 with the following individuals - * added to the list of Contributing Authors: - * - * Simon-Pierre Cadieux - * Eric S. Raymond - * Mans Rullgard - * Cosmin Truta - * Gilles Vollant - * James Yu - * Mandar Sahastrabuddhe - * Google Inc. - * Vadim Barkov - * - * and with the following additions to the disclaimer: - * - * There is no warranty against interference with your enjoyment of - * the library or against infringement. There is no warranty that our - * efforts or the library will fulfill any of your particular purposes - * or needs. This library is provided with all faults, and the entire - * risk of satisfactory quality, performance, accuracy, and effort is - * with the user. - * - * Some files in the "contrib" directory and some configure-generated - * files that are distributed with libpng have other copyright owners, and - * are released under other open source licenses. - * - * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are - * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from - * libpng-0.96, and are distributed according to the same disclaimer and - * license as libpng-0.96, with the following individuals added to the - * list of Contributing Authors: - * - * Tom Lane - * Glenn Randers-Pehrson - * Willem van Schaik - * - * libpng versions 0.89, June 1996, through 0.96, May 1997, are - * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88, - * and are distributed according to the same disclaimer and license as - * libpng-0.88, with the following individuals added to the list of - * Contributing Authors: - * - * John Bowler - * Kevin Bracey - * Sam Bushell - * Magnus Holmgren - * Greg Roelofs - * Tom Tanner - * - * Some files in the "scripts" directory have other copyright owners, - * but are released under this license. - * - * libpng versions 0.5, May 1995, through 0.88, January 1996, are - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * For the purposes of this copyright and license, "Contributing Authors" - * is defined as the following set of individuals: - * - * Andreas Dilger - * Dave Martindale - * Guy Eric Schalnat - * Paul Schmidt - * Tim Wegner - * - * The PNG Reference Library is supplied "AS IS". The Contributing - * Authors and Group 42, Inc. disclaim all warranties, expressed or - * implied, including, without limitation, the warranties of - * merchantability and of fitness for any purpose. The Contributing - * Authors and Group 42, Inc. assume no liability for direct, indirect, - * incidental, special, exemplary, or consequential damages, which may - * result from the use of the PNG Reference Library, even if advised of - * the possibility of such damage. - * - * Permission is hereby granted to use, copy, modify, and distribute this - * source code, or portions hereof, for any purpose, without fee, subject - * to the following restrictions: - * - * 1. The origin of this source code must not be misrepresented. - * - * 2. Altered versions must be plainly marked as such and must not - * be misrepresented as being the original source. - * - * 3. This Copyright notice may not be removed or altered from any - * source or altered source distribution. - * - * The Contributing Authors and Group 42, Inc. specifically permit, - * without fee, and encourage the use of this source code as a component - * to supporting the PNG file format in commercial products. If you use - * this source code in a product, acknowledgment is not required but would - * be appreciated. - * - * END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE. - * - * TRADEMARK - * ========= - * - * The name "libpng" has not been registered by the Copyright owners - * as a trademark in any jurisdiction. However, because libpng has - * been distributed and maintained world-wide, continually since 1995, - * the Copyright owners claim "common-law trademark protection" in any - * jurisdiction where common-law trademark is recognized. - */ - -/* - * A "png_get_copyright" function is available, for convenient use in "about" - * boxes and the like: - * - * printf("%s", png_get_copyright(NULL)); - * - * Also, the PNG logo (in PNG format, of course) is supplied in the - * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). - */ - -/* - * The contributing authors would like to thank all those who helped - * with testing, bug fixes, and patience. This wouldn't have been - * possible without all of you. - * - * Thanks to Frank J. T. Wojcik for helping with the documentation. - */ - -/* Note about libpng version numbers: - * - * Due to various miscommunications, unforeseen code incompatibilities - * and occasional factors outside the authors' control, version numbering - * on the library has not always been consistent and straightforward. - * The following table summarizes matters since version 0.89c, which was - * the first widely used release: - * - * source png.h png.h shared-lib - * version string int version - * ------- ------ ----- ---------- - * 0.89c "1.0 beta 3" 0.89 89 1.0.89 - * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] - * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] - * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] - * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] - * 0.97c 0.97 97 2.0.97 - * 0.98 0.98 98 2.0.98 - * 0.99 0.99 98 2.0.99 - * 0.99a-m 0.99 99 2.0.99 - * 1.00 1.00 100 2.1.0 [100 should be 10000] - * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] - * 1.0.1 png.h string is 10001 2.1.0 - * 1.0.1a-e identical to the 10002 from here on, the shared library - * 1.0.2 source version) 10002 is 2.V where V is the source code - * 1.0.2a-b 10003 version, except as noted. - * 1.0.3 10003 - * 1.0.3a-d 10004 - * 1.0.4 10004 - * 1.0.4a-f 10005 - * 1.0.5 (+ 2 patches) 10005 - * 1.0.5a-d 10006 - * 1.0.5e-r 10100 (not source compatible) - * 1.0.5s-v 10006 (not binary compatible) - * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) - * 1.0.6d-f 10007 (still binary incompatible) - * 1.0.6g 10007 - * 1.0.6h 10007 10.6h (testing xy.z so-numbering) - * 1.0.6i 10007 10.6i - * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) - * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) - * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) - * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) - * 1.0.7 1 10007 (still compatible) - * ... - * 1.0.69 10 10069 10.so.0.69[.0] - * ... - * 1.2.59 13 10259 12.so.0.59[.0] - * ... - * 1.4.20 14 10420 14.so.0.20[.0] - * ... - * 1.5.30 15 10530 15.so.15.30[.0] - * ... - * 1.6.37 16 10637 16.so.16.37[.0] - * - * Henceforth the source version will match the shared-library major and - * minor numbers; the shared-library major version number will be used for - * changes in backward compatibility, as it is intended. - * The PNG_LIBPNG_VER macro, which is not used within libpng but is - * available for applications, is an unsigned integer of the form XYYZZ - * corresponding to the source version X.Y.Z (leading zeros in Y and Z). - * Beta versions were given the previous public release number plus a - * letter, until version 1.0.6j; from then on they were given the upcoming - * public release number plus "betaNN" or "rcNN". - * - * Binary incompatibility exists only when applications make direct access - * to the info_ptr or png_ptr members through png.h, and the compiled - * application is loaded with a different version of the library. - * - * DLLNUM will change each time there are forward or backward changes - * in binary compatibility (e.g., when a new feature is added). - * - * See libpng.txt or libpng.3 for more information. The PNG specification - * is available as a W3C Recommendation and as an ISO/IEC Standard; see - * - */ - -#ifndef PNG_H -#define PNG_H - -/* This is not the place to learn how to use libpng. The file libpng-manual.txt - * describes how to use libpng, and the file example.c summarizes it - * with some code on which to build. This file is useful for looking - * at the actual function definitions and structure components. If that - * file has been stripped from your copy of libpng, you can find it at - * - * - * If you just need to read a PNG file and don't want to read the documentation - * skip to the end of this file and read the section entitled 'simplified API'. - */ - -/* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.6.37" -#define PNG_HEADER_VERSION_STRING " libpng version 1.6.37 - April 14, 2019\n" - -#define PNG_LIBPNG_VER_SONUM 16 -#define PNG_LIBPNG_VER_DLLNUM 16 - -/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ -#define PNG_LIBPNG_VER_MAJOR 1 -#define PNG_LIBPNG_VER_MINOR 6 -#define PNG_LIBPNG_VER_RELEASE 37 - -/* This should be zero for a public release, or non-zero for a - * development version. [Deprecated] - */ -#define PNG_LIBPNG_VER_BUILD 0 - -/* Release Status */ -#define PNG_LIBPNG_BUILD_ALPHA 1 -#define PNG_LIBPNG_BUILD_BETA 2 -#define PNG_LIBPNG_BUILD_RC 3 -#define PNG_LIBPNG_BUILD_STABLE 4 -#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7 - -/* Release-Specific Flags */ -#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with - PNG_LIBPNG_BUILD_STABLE only */ -#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with - PNG_LIBPNG_BUILD_SPECIAL */ -#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with - PNG_LIBPNG_BUILD_PRIVATE */ - -#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE - -/* Careful here. At one time, Guy wanted to use 082, but that - * would be octal. We must not include leading zeros. - * Versions 0.7 through 1.0.0 were in the range 0 to 100 here - * (only version 1.0.0 was mis-numbered 100 instead of 10000). - * From version 1.0.1 it is: - * XXYYZZ, where XX=major, YY=minor, ZZ=release - */ -#define PNG_LIBPNG_VER 10637 /* 1.6.37 */ - -/* Library configuration: these options cannot be changed after - * the library has been built. - */ -#ifndef PNGLCONF_H -/* If pnglibconf.h is missing, you can - * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h - */ -# include "pnglibconf.h" -#endif - -#ifndef PNG_VERSION_INFO_ONLY -/* Machine specific configuration. */ -# include "pngconf.h" -#endif - -/* - * Added at libpng-1.2.8 - * - * Ref MSDN: Private as priority over Special - * VS_FF_PRIVATEBUILD File *was not* built using standard release - * procedures. If this value is given, the StringFileInfo block must - * contain a PrivateBuild string. - * - * VS_FF_SPECIALBUILD File *was* built by the original company using - * standard release procedures but is a variation of the standard - * file of the same version number. If this value is given, the - * StringFileInfo block must contain a SpecialBuild string. - */ - -#ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */ -# define PNG_LIBPNG_BUILD_TYPE \ - (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE) -#else -# ifdef PNG_LIBPNG_SPECIALBUILD -# define PNG_LIBPNG_BUILD_TYPE \ - (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL) -# else -# define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE) -# endif -#endif - -#ifndef PNG_VERSION_INFO_ONLY - -/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Version information for C files, stored in png.c. This had better match - * the version above. - */ -#define png_libpng_ver png_get_header_ver(NULL) - -/* This file is arranged in several sections: - * - * 1. [omitted] - * 2. Any configuration options that can be specified by for the application - * code when it is built. (Build time configuration is in pnglibconf.h) - * 3. Type definitions (base types are defined in pngconf.h), structure - * definitions. - * 4. Exported library functions. - * 5. Simplified API. - * 6. Implementation options. - * - * The library source code has additional files (principally pngpriv.h) that - * allow configuration of the library. - */ - -/* Section 1: [omitted] */ - -/* Section 2: run time configuration - * See pnglibconf.h for build time configuration - * - * Run time configuration allows the application to choose between - * implementations of certain arithmetic APIs. The default is set - * at build time and recorded in pnglibconf.h, but it is safe to - * override these (and only these) settings. Note that this won't - * change what the library does, only application code, and the - * settings can (and probably should) be made on a per-file basis - * by setting the #defines before including png.h - * - * Use macros to read integers from PNG data or use the exported - * functions? - * PNG_USE_READ_MACROS: use the macros (see below) Note that - * the macros evaluate their argument multiple times. - * PNG_NO_USE_READ_MACROS: call the relevant library function. - * - * Use the alternative algorithm for compositing alpha samples that - * does not use division? - * PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division' - * algorithm. - * PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm. - * - * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is - * false? - * PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error - * APIs to png_warning. - * Otherwise the calls are mapped to png_error. - */ - -/* Section 3: type definitions, including structures and compile time - * constants. - * See pngconf.h for base types that vary by machine/system - */ - -/* This triggers a compiler error in png.c, if png.c and png.h - * do not agree upon the version number. - */ -typedef char* png_libpng_version_1_6_37; - -/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. - * - * png_struct is the cache of information used while reading or writing a single - * PNG file. One of these is always required, although the simplified API - * (below) hides the creation and destruction of it. - */ -typedef struct png_struct_def png_struct; -typedef const png_struct * png_const_structp; -typedef png_struct * png_structp; -typedef png_struct * * png_structpp; - -/* png_info contains information read from or to be written to a PNG file. One - * or more of these must exist while reading or creating a PNG file. The - * information is not used by libpng during read but is used to control what - * gets written when a PNG file is created. "png_get_" function calls read - * information during read and "png_set_" functions calls write information - * when creating a PNG. - * been moved into a separate header file that is not accessible to - * applications. Read libpng-manual.txt or libpng.3 for more info. - */ -typedef struct png_info_def png_info; -typedef png_info * png_infop; -typedef const png_info * png_const_infop; -typedef png_info * * png_infopp; - -/* Types with names ending 'p' are pointer types. The corresponding types with - * names ending 'rp' are identical pointer types except that the pointer is - * marked 'restrict', which means that it is the only pointer to the object - * passed to the function. Applications should not use the 'restrict' types; - * it is always valid to pass 'p' to a pointer with a function argument of the - * corresponding 'rp' type. Different compilers have different rules with - * regard to type matching in the presence of 'restrict'. For backward - * compatibility libpng callbacks never have 'restrict' in their parameters and, - * consequentially, writing portable application code is extremely difficult if - * an attempt is made to use 'restrict'. - */ -typedef png_struct * PNG_RESTRICT png_structrp; -typedef const png_struct * PNG_RESTRICT png_const_structrp; -typedef png_info * PNG_RESTRICT png_inforp; -typedef const png_info * PNG_RESTRICT png_const_inforp; - -/* Three color definitions. The order of the red, green, and blue, (and the - * exact size) is not important, although the size of the fields need to - * be png_byte or png_uint_16 (as defined below). - */ -typedef struct png_color_struct -{ - png_byte red; - png_byte green; - png_byte blue; -} png_color; -typedef png_color * png_colorp; -typedef const png_color * png_const_colorp; -typedef png_color * * png_colorpp; - -typedef struct png_color_16_struct -{ - png_byte index; /* used for palette files */ - png_uint_16 red; /* for use in red green blue files */ - png_uint_16 green; - png_uint_16 blue; - png_uint_16 gray; /* for use in grayscale files */ -} png_color_16; -typedef png_color_16 * png_color_16p; -typedef const png_color_16 * png_const_color_16p; -typedef png_color_16 * * png_color_16pp; - -typedef struct png_color_8_struct -{ - png_byte red; /* for use in red green blue files */ - png_byte green; - png_byte blue; - png_byte gray; /* for use in grayscale files */ - png_byte alpha; /* for alpha channel files */ -} png_color_8; -typedef png_color_8 * png_color_8p; -typedef const png_color_8 * png_const_color_8p; -typedef png_color_8 * * png_color_8pp; - -/* - * The following two structures are used for the in-core representation - * of sPLT chunks. - */ -typedef struct png_sPLT_entry_struct -{ - png_uint_16 red; - png_uint_16 green; - png_uint_16 blue; - png_uint_16 alpha; - png_uint_16 frequency; -} png_sPLT_entry; -typedef png_sPLT_entry * png_sPLT_entryp; -typedef const png_sPLT_entry * png_const_sPLT_entryp; -typedef png_sPLT_entry * * png_sPLT_entrypp; - -/* When the depth of the sPLT palette is 8 bits, the color and alpha samples - * occupy the LSB of their respective members, and the MSB of each member - * is zero-filled. The frequency member always occupies the full 16 bits. - */ - -typedef struct png_sPLT_struct -{ - png_charp name; /* palette name */ - png_byte depth; /* depth of palette samples */ - png_sPLT_entryp entries; /* palette entries */ - png_int_32 nentries; /* number of palette entries */ -} png_sPLT_t; -typedef png_sPLT_t * png_sPLT_tp; -typedef const png_sPLT_t * png_const_sPLT_tp; -typedef png_sPLT_t * * png_sPLT_tpp; - -#ifdef PNG_TEXT_SUPPORTED -/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, - * and whether that contents is compressed or not. The "key" field - * points to a regular zero-terminated C string. The "text" fields can be a - * regular C string, an empty string, or a NULL pointer. - * However, the structure returned by png_get_text() will always contain - * the "text" field as a regular zero-terminated C string (possibly - * empty), never a NULL pointer, so it can be safely used in printf() and - * other string-handling functions. Note that the "itxt_length", "lang", and - * "lang_key" members of the structure only exist when the library is built - * with iTXt chunk support. Prior to libpng-1.4.0 the library was built by - * default without iTXt support. Also note that when iTXt *is* supported, - * the "lang" and "lang_key" fields contain NULL pointers when the - * "compression" field contains * PNG_TEXT_COMPRESSION_NONE or - * PNG_TEXT_COMPRESSION_zTXt. Note that the "compression value" is not the - * same as what appears in the PNG tEXt/zTXt/iTXt chunk's "compression flag" - * which is always 0 or 1, or its "compression method" which is always 0. - */ -typedef struct png_text_struct -{ - int compression; /* compression value: - -1: tEXt, none - 0: zTXt, deflate - 1: iTXt, none - 2: iTXt, deflate */ - png_charp key; /* keyword, 1-79 character description of "text" */ - png_charp text; /* comment, may be an empty string (ie "") - or a NULL pointer */ - size_t text_length; /* length of the text string */ - size_t itxt_length; /* length of the itxt string */ - png_charp lang; /* language code, 0-79 characters - or a NULL pointer */ - png_charp lang_key; /* keyword translated UTF-8 string, 0 or more - chars or a NULL pointer */ -} png_text; -typedef png_text * png_textp; -typedef const png_text * png_const_textp; -typedef png_text * * png_textpp; -#endif - -/* Supported compression types for text in PNG files (tEXt, and zTXt). - * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ -#define PNG_TEXT_COMPRESSION_NONE_WR -3 -#define PNG_TEXT_COMPRESSION_zTXt_WR -2 -#define PNG_TEXT_COMPRESSION_NONE -1 -#define PNG_TEXT_COMPRESSION_zTXt 0 -#define PNG_ITXT_COMPRESSION_NONE 1 -#define PNG_ITXT_COMPRESSION_zTXt 2 -#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ - -/* png_time is a way to hold the time in an machine independent way. - * Two conversions are provided, both from time_t and struct tm. There - * is no portable way to convert to either of these structures, as far - * as I know. If you know of a portable way, send it to me. As a side - * note - PNG has always been Year 2000 compliant! - */ -typedef struct png_time_struct -{ - png_uint_16 year; /* full year, as in, 1995 */ - png_byte month; /* month of year, 1 - 12 */ - png_byte day; /* day of month, 1 - 31 */ - png_byte hour; /* hour of day, 0 - 23 */ - png_byte minute; /* minute of hour, 0 - 59 */ - png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ -} png_time; -typedef png_time * png_timep; -typedef const png_time * png_const_timep; -typedef png_time * * png_timepp; - -#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) ||\ - defined(PNG_USER_CHUNKS_SUPPORTED) -/* png_unknown_chunk is a structure to hold queued chunks for which there is - * no specific support. The idea is that we can use this to queue - * up private chunks for output even though the library doesn't actually - * know about their semantics. - * - * The data in the structure is set by libpng on read and used on write. - */ -typedef struct png_unknown_chunk_t -{ - png_byte name[5]; /* Textual chunk name with '\0' terminator */ - png_byte *data; /* Data, should not be modified on read! */ - size_t size; - - /* On write 'location' must be set using the flag values listed below. - * Notice that on read it is set by libpng however the values stored have - * more bits set than are listed below. Always treat the value as a - * bitmask. On write set only one bit - setting multiple bits may cause the - * chunk to be written in multiple places. - */ - png_byte location; /* mode of operation at read time */ -} -png_unknown_chunk; - -typedef png_unknown_chunk * png_unknown_chunkp; -typedef const png_unknown_chunk * png_const_unknown_chunkp; -typedef png_unknown_chunk * * png_unknown_chunkpp; -#endif - -/* Flag values for the unknown chunk location byte. */ -#define PNG_HAVE_IHDR 0x01 -#define PNG_HAVE_PLTE 0x02 -#define PNG_AFTER_IDAT 0x08 - -/* Maximum positive integer used in PNG is (2^31)-1 */ -#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL) -#define PNG_UINT_32_MAX ((png_uint_32)(-1)) -#define PNG_SIZE_MAX ((size_t)(-1)) - -/* These are constants for fixed point values encoded in the - * PNG specification manner (x100000) - */ -#define PNG_FP_1 100000 -#define PNG_FP_HALF 50000 -#define PNG_FP_MAX ((png_fixed_point)0x7fffffffL) -#define PNG_FP_MIN (-PNG_FP_MAX) - -/* These describe the color_type field in png_info. */ -/* color type masks */ -#define PNG_COLOR_MASK_PALETTE 1 -#define PNG_COLOR_MASK_COLOR 2 -#define PNG_COLOR_MASK_ALPHA 4 - -/* color types. Note that not all combinations are legal */ -#define PNG_COLOR_TYPE_GRAY 0 -#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) -#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) -#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) -#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) -/* aliases */ -#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA -#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA - -/* This is for compression type. PNG 1.0-1.2 only define the single type. */ -#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ -#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE - -/* This is for filter type. PNG 1.0-1.2 only define the single type. */ -#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ -#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */ -#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE - -/* These are for the interlacing type. These values should NOT be changed. */ -#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */ -#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */ -#define PNG_INTERLACE_LAST 2 /* Not a valid value */ - -/* These are for the oFFs chunk. These values should NOT be changed. */ -#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */ -#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */ -#define PNG_OFFSET_LAST 2 /* Not a valid value */ - -/* These are for the pCAL chunk. These values should NOT be changed. */ -#define PNG_EQUATION_LINEAR 0 /* Linear transformation */ -#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */ -#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */ -#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */ -#define PNG_EQUATION_LAST 4 /* Not a valid value */ - -/* These are for the sCAL chunk. These values should NOT be changed. */ -#define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */ -#define PNG_SCALE_METER 1 /* meters per pixel */ -#define PNG_SCALE_RADIAN 2 /* radians per pixel */ -#define PNG_SCALE_LAST 3 /* Not a valid value */ - -/* These are for the pHYs chunk. These values should NOT be changed. */ -#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */ -#define PNG_RESOLUTION_METER 1 /* pixels/meter */ -#define PNG_RESOLUTION_LAST 2 /* Not a valid value */ - -/* These are for the sRGB chunk. These values should NOT be changed. */ -#define PNG_sRGB_INTENT_PERCEPTUAL 0 -#define PNG_sRGB_INTENT_RELATIVE 1 -#define PNG_sRGB_INTENT_SATURATION 2 -#define PNG_sRGB_INTENT_ABSOLUTE 3 -#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */ - -/* This is for text chunks */ -#define PNG_KEYWORD_MAX_LENGTH 79 - -/* Maximum number of entries in PLTE/sPLT/tRNS arrays */ -#define PNG_MAX_PALETTE_LENGTH 256 - -/* These determine if an ancillary chunk's data has been successfully read - * from the PNG header, or if the application has filled in the corresponding - * data in the info_struct to be written into the output file. The values - * of the PNG_INFO_ defines should NOT be changed. - */ -#define PNG_INFO_gAMA 0x0001U -#define PNG_INFO_sBIT 0x0002U -#define PNG_INFO_cHRM 0x0004U -#define PNG_INFO_PLTE 0x0008U -#define PNG_INFO_tRNS 0x0010U -#define PNG_INFO_bKGD 0x0020U -#define PNG_INFO_hIST 0x0040U -#define PNG_INFO_pHYs 0x0080U -#define PNG_INFO_oFFs 0x0100U -#define PNG_INFO_tIME 0x0200U -#define PNG_INFO_pCAL 0x0400U -#define PNG_INFO_sRGB 0x0800U /* GR-P, 0.96a */ -#define PNG_INFO_iCCP 0x1000U /* ESR, 1.0.6 */ -#define PNG_INFO_sPLT 0x2000U /* ESR, 1.0.6 */ -#define PNG_INFO_sCAL 0x4000U /* ESR, 1.0.6 */ -#define PNG_INFO_IDAT 0x8000U /* ESR, 1.0.6 */ -#define PNG_INFO_eXIf 0x10000U /* GR-P, 1.6.31 */ - -/* This is used for the transformation routines, as some of them - * change these values for the row. It also should enable using - * the routines for other purposes. - */ -typedef struct png_row_info_struct -{ - png_uint_32 width; /* width of row */ - size_t rowbytes; /* number of bytes in row */ - png_byte color_type; /* color type of row */ - png_byte bit_depth; /* bit depth of row */ - png_byte channels; /* number of channels (1, 2, 3, or 4) */ - png_byte pixel_depth; /* bits per pixel (depth * channels) */ -} png_row_info; - -typedef png_row_info * png_row_infop; -typedef png_row_info * * png_row_infopp; - -/* These are the function types for the I/O functions and for the functions - * that allow the user to override the default I/O functions with his or her - * own. The png_error_ptr type should match that of user-supplied warning - * and error functions, while the png_rw_ptr type should match that of the - * user read/write data functions. Note that the 'write' function must not - * modify the buffer it is passed. The 'read' function, on the other hand, is - * expected to return the read data in the buffer. - */ -typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp)); -typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, size_t)); -typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp)); -typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32, - int)); -typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32, - int)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop)); -typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop)); - -/* The following callback receives png_uint_32 row_number, int pass for the - * png_bytep data of the row. When transforming an interlaced image the - * row number is the row number within the sub-image of the interlace pass, so - * the value will increase to the height of the sub-image (not the full image) - * then reset to 0 for the next pass. - * - * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to - * find the output pixel (x,y) given an interlaced sub-image pixel - * (row,col,pass). (See below for these macros.) - */ -typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep, - png_uint_32, int)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop, - png_bytep)); -#endif - -#ifdef PNG_USER_CHUNKS_SUPPORTED -typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp, - png_unknown_chunkp)); -#endif -#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED -/* not used anywhere */ -/* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */ -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* This must match the function definition in , and the application - * must include this before png.h to obtain the definition of jmp_buf. The - * function is required to be PNG_NORETURN, but this is not checked. If the - * function does return the application will crash via an abort() or similar - * system level call. - * - * If you get a warning here while building the library you may need to make - * changes to ensure that pnglibconf.h records the calling convention used by - * your compiler. This may be very difficult - try using a different compiler - * to build the library! - */ -PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef); -#endif - -/* Transform masks for the high-level interface */ -#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ -#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ -#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ -#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ -#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ -#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ -#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ -#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ -#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ -#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ -#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ -#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ -#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* write only */ -/* Added to libpng-1.2.34 */ -#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER -#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */ -/* Added to libpng-1.4.0 */ -#define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */ -/* Added to libpng-1.5.4 */ -#define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */ -#if INT_MAX >= 0x8000 /* else this might break */ -#define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */ -#endif - -/* Flags for MNG supported features */ -#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 -#define PNG_FLAG_MNG_FILTER_64 0x04 -#define PNG_ALL_MNG_FEATURES 0x05 - -/* NOTE: prior to 1.5 these functions had no 'API' style declaration, - * this allowed the zlib default functions to be used on Windows - * platforms. In 1.5 the zlib default malloc (which just calls malloc and - * ignores the first argument) should be completely compatible with the - * following. - */ -typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp, - png_alloc_size_t)); -typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp)); - -/* Section 4: exported functions - * Here are the function definitions most commonly used. This is not - * the place to find out how to use libpng. See libpng-manual.txt for the - * full explanation, see example.c for the summary. This just provides - * a simple one line description of the use of each function. - * - * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in - * pngconf.h and in the *.dfn files in the scripts directory. - * - * PNG_EXPORT(ordinal, type, name, (args)); - * - * ordinal: ordinal that is used while building - * *.def files. The ordinal value is only - * relevant when preprocessing png.h with - * the *.dfn files for building symbol table - * entries, and are removed by pngconf.h. - * type: return type of the function - * name: function name - * args: function arguments, with types - * - * When we wish to append attributes to a function prototype we use - * the PNG_EXPORTA() macro instead. - * - * PNG_EXPORTA(ordinal, type, name, (args), attributes); - * - * ordinal, type, name, and args: same as in PNG_EXPORT(). - * attributes: function attributes - */ - -/* Returns the version number of the library */ -PNG_EXPORT(1, png_uint_32, png_access_version_number, (void)); - -/* Tell lib we have already handled the first magic bytes. - * Handling more than 8 bytes from the beginning of the file is an error. - */ -PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes)); - -/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a - * PNG file. Returns zero if the supplied bytes match the 8-byte PNG - * signature, and non-zero otherwise. Having num_to_check == 0 or - * start > 7 will always fail (ie return non-zero). - */ -PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, size_t start, - size_t num_to_check)); - -/* Simple signature checking function. This is the same as calling - * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). - */ -#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n)) - -/* Allocate and initialize png_ptr struct for reading, and any other memory. */ -PNG_EXPORTA(4, png_structp, png_create_read_struct, - (png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn), - PNG_ALLOCATED); - -/* Allocate and initialize png_ptr struct for writing, and any other memory */ -PNG_EXPORTA(5, png_structp, png_create_write_struct, - (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warn_fn), - PNG_ALLOCATED); - -PNG_EXPORT(6, size_t, png_get_compression_buffer_size, - (png_const_structrp png_ptr)); - -PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr, - size_t size)); - -/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp - * match up. - */ -#ifdef PNG_SETJMP_SUPPORTED -/* This function returns the jmp_buf built in to *png_ptr. It must be - * supplied with an appropriate 'longjmp' function to use on that jmp_buf - * unless the default error function is overridden in which case NULL is - * acceptable. The size of the jmp_buf is checked against the actual size - * allocated by the library - the call will return NULL on a mismatch - * indicating an ABI mismatch. - */ -PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr, - png_longjmp_ptr longjmp_fn, size_t jmp_buf_size)); -# define png_jmpbuf(png_ptr) \ - (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf)))) -#else -# define png_jmpbuf(png_ptr) \ - (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP) -#endif -/* This function should be used by libpng applications in place of - * longjmp(png_ptr->jmpbuf, val). If longjmp_fn() has been set, it - * will use it; otherwise it will call PNG_ABORT(). This function was - * added in libpng-1.5.0. - */ -PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val), - PNG_NORETURN); - -#ifdef PNG_READ_SUPPORTED -/* Reset the compression stream */ -PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED); -#endif - -/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ -#ifdef PNG_USER_MEM_SUPPORTED -PNG_EXPORTA(11, png_structp, png_create_read_struct_2, - (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warn_fn, - png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), - PNG_ALLOCATED); -PNG_EXPORTA(12, png_structp, png_create_write_struct_2, - (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warn_fn, - png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), - PNG_ALLOCATED); -#endif - -/* Write the PNG file signature. */ -PNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr)); - -/* Write a PNG chunk - size, type, (optional) data, CRC. */ -PNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep - chunk_name, png_const_bytep data, size_t length)); - -/* Write the start of a PNG chunk - length and chunk name. */ -PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr, - png_const_bytep chunk_name, png_uint_32 length)); - -/* Write the data of a PNG chunk started with png_write_chunk_start(). */ -PNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr, - png_const_bytep data, size_t length)); - -/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ -PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr)); - -/* Allocate and initialize the info structure */ -PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr), - PNG_ALLOCATED); - -/* DEPRECATED: this function allowed init structures to be created using the - * default allocation method (typically malloc). Use is deprecated in 1.6.0 and - * the API will be removed in the future. - */ -PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr, - size_t png_info_struct_size), PNG_DEPRECATED); - -/* Writes all the PNG information before the image. */ -PNG_EXPORT(20, void, png_write_info_before_PLTE, - (png_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(21, void, png_write_info, - (png_structrp png_ptr, png_const_inforp info_ptr)); - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read the information before the actual image data. */ -PNG_EXPORT(22, void, png_read_info, - (png_structrp png_ptr, png_inforp info_ptr)); -#endif - -#ifdef PNG_TIME_RFC1123_SUPPORTED - /* Convert to a US string format: there is no localization support in this - * routine. The original implementation used a 29 character buffer in - * png_struct, this will be removed in future versions. - */ -#if PNG_LIBPNG_VER < 10700 -/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */ -PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr, - png_const_timep ptime),PNG_DEPRECATED); -#endif -PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29], - png_const_timep ptime)); -#endif - -#ifdef PNG_CONVERT_tIME_SUPPORTED -/* Convert from a struct tm to png_time */ -PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime, - const struct tm * ttime)); - -/* Convert from time_t to png_time. Uses gmtime() */ -PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime)); -#endif /* CONVERT_tIME */ - -#ifdef PNG_READ_EXPAND_SUPPORTED -/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ -PNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr)); -PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr)); -PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr)); -PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr)); -#endif - -#ifdef PNG_READ_EXPAND_16_SUPPORTED -/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion - * of a tRNS chunk if present. - */ -PNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr)); -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* Use blue, green, red order for pixels. */ -PNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr)); -#endif - -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED -/* Expand the grayscale to 24-bit RGB if necessary. */ -PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr)); -#endif - -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED -/* Reduce RGB to grayscale. */ -#define PNG_ERROR_ACTION_NONE 1 -#define PNG_ERROR_ACTION_WARN 2 -#define PNG_ERROR_ACTION_ERROR 3 -#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/ - -PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr, - int error_action, double red, double green)) -PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr, - int error_action, png_fixed_point red, png_fixed_point green)) - -PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp - png_ptr)); -#endif - -#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED -PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth, - png_colorp palette)); -#endif - -#ifdef PNG_READ_ALPHA_MODE_SUPPORTED -/* How the alpha channel is interpreted - this affects how the color channels - * of a PNG file are returned to the calling application when an alpha channel, - * or a tRNS chunk in a palette file, is present. - * - * This has no effect on the way pixels are written into a PNG output - * datastream. The color samples in a PNG datastream are never premultiplied - * with the alpha samples. - * - * The default is to return data according to the PNG specification: the alpha - * channel is a linear measure of the contribution of the pixel to the - * corresponding composited pixel, and the color channels are unassociated - * (not premultiplied). The gamma encoded color channels must be scaled - * according to the contribution and to do this it is necessary to undo - * the encoding, scale the color values, perform the composition and re-encode - * the values. This is the 'PNG' mode. - * - * The alternative is to 'associate' the alpha with the color information by - * storing color channel values that have been scaled by the alpha. - * image. These are the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' modes - * (the latter being the two common names for associated alpha color channels). - * - * For the 'OPTIMIZED' mode, a pixel is treated as opaque only if the alpha - * value is equal to the maximum value. - * - * The final choice is to gamma encode the alpha channel as well. This is - * broken because, in practice, no implementation that uses this choice - * correctly undoes the encoding before handling alpha composition. Use this - * choice only if other serious errors in the software or hardware you use - * mandate it; the typical serious error is for dark halos to appear around - * opaque areas of the composited PNG image because of arithmetic overflow. - * - * The API function png_set_alpha_mode specifies which of these choices to use - * with an enumerated 'mode' value and the gamma of the required output: - */ -#define PNG_ALPHA_PNG 0 /* according to the PNG standard */ -#define PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */ -#define PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */ -#define PNG_ALPHA_PREMULTIPLIED 1 /* as above */ -#define PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */ -#define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */ - -PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode, - double output_gamma)) -PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr, - int mode, png_fixed_point output_gamma)) -#endif - -#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED) -/* The output_gamma value is a screen gamma in libpng terminology: it expresses - * how to decode the output values, not how they are encoded. - */ -#define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */ -#define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */ -#define PNG_GAMMA_sRGB 220000 /* Television standards--matches sRGB gamma */ -#define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */ -#endif - -/* The following are examples of calls to png_set_alpha_mode to achieve the - * required overall gamma correction and, where necessary, alpha - * premultiplication. - * - * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); - * This is the default libpng handling of the alpha channel - it is not - * pre-multiplied into the color components. In addition the call states - * that the output is for a sRGB system and causes all PNG files without gAMA - * chunks to be assumed to be encoded using sRGB. - * - * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); - * In this case the output is assumed to be something like an sRGB conformant - * display preceded by a power-law lookup table of power 1.45. This is how - * early Mac systems behaved. - * - * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR); - * This is the classic Jim Blinn approach and will work in academic - * environments where everything is done by the book. It has the shortcoming - * of assuming that input PNG data with no gamma information is linear - this - * is unlikely to be correct unless the PNG files where generated locally. - * Most of the time the output precision will be so low as to show - * significant banding in dark areas of the image. - * - * png_set_expand_16(pp); - * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB); - * This is a somewhat more realistic Jim Blinn inspired approach. PNG files - * are assumed to have the sRGB encoding if not marked with a gamma value and - * the output is always 16 bits per component. This permits accurate scaling - * and processing of the data. If you know that your input PNG files were - * generated locally you might need to replace PNG_DEFAULT_sRGB with the - * correct value for your system. - * - * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB); - * If you just need to composite the PNG image onto an existing background - * and if you control the code that does this you can use the optimization - * setting. In this case you just copy completely opaque pixels to the - * output. For pixels that are not completely transparent (you just skip - * those) you do the composition math using png_composite or png_composite_16 - * below then encode the resultant 8-bit or 16-bit values to match the output - * encoding. - * - * Other cases - * If neither the PNG nor the standard linear encoding work for you because - * of the software or hardware you use then you have a big problem. The PNG - * case will probably result in halos around the image. The linear encoding - * will probably result in a washed out, too bright, image (it's actually too - * contrasty.) Try the ALPHA_OPTIMIZED mode above - this will probably - * substantially reduce the halos. Alternatively try: - * - * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB); - * This option will also reduce the halos, but there will be slight dark - * halos round the opaque parts of the image where the background is light. - * In the OPTIMIZED mode the halos will be light halos where the background - * is dark. Take your pick - the halos are unavoidable unless you can get - * your hardware/software fixed! (The OPTIMIZED approach is slightly - * faster.) - * - * When the default gamma of PNG files doesn't match the output gamma. - * If you have PNG files with no gamma information png_set_alpha_mode allows - * you to provide a default gamma, but it also sets the output gamma to the - * matching value. If you know your PNG files have a gamma that doesn't - * match the output you can take advantage of the fact that - * png_set_alpha_mode always sets the output gamma but only sets the PNG - * default if it is not already set: - * - * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); - * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); - * The first call sets both the default and the output gamma values, the - * second call overrides the output gamma without changing the default. This - * is easier than achieving the same effect with png_set_gamma. You must use - * PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will - * fire if more than one call to png_set_alpha_mode and png_set_background is - * made in the same read operation, however multiple calls with PNG_ALPHA_PNG - * are ignored. - */ - -#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED -PNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr)); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -PNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -PNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr)); -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -/* Add a filler byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */ -PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler, - int flags)); -/* The values of the PNG_FILLER_ defines should NOT be changed */ -# define PNG_FILLER_BEFORE 0 -# define PNG_FILLER_AFTER 1 -/* Add an alpha byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */ -PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr, - png_uint_32 filler, int flags)); -#endif /* READ_FILLER || WRITE_FILLER */ - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* Swap bytes in 16-bit depth files. */ -PNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ -PNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr)); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ - defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* Swap packing order of pixels in bytes. */ -PNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr)); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) -/* Converts files to legal bit depths. */ -PNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p - true_bits)); -#endif - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Have the code handle the interlacing. Returns the number of passes. - * MUST be called before png_read_update_info or png_start_read_image, - * otherwise it will not have the desired effect. Note that it is still - * necessary to call png_read_row or png_read_rows png_get_image_height - * times for each pass. -*/ -PNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -/* Invert monochrome files */ -PNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr)); -#endif - -#ifdef PNG_READ_BACKGROUND_SUPPORTED -/* Handle alpha and tRNS by replacing with a background color. Prior to - * libpng-1.5.4 this API must not be called before the PNG file header has been - * read. Doing so will result in unexpected behavior and possible warnings or - * errors if the PNG file contains a bKGD chunk. - */ -PNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr, - png_const_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma)) -PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr, - png_const_color_16p background_color, int background_gamma_code, - int need_expand, png_fixed_point background_gamma)) -#endif -#ifdef PNG_READ_BACKGROUND_SUPPORTED -# define PNG_BACKGROUND_GAMMA_UNKNOWN 0 -# define PNG_BACKGROUND_GAMMA_SCREEN 1 -# define PNG_BACKGROUND_GAMMA_FILE 2 -# define PNG_BACKGROUND_GAMMA_UNIQUE 3 -#endif - -#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED -/* Scale a 16-bit depth file down to 8-bit, accurately. */ -PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr)); -#endif - -#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED -#define PNG_READ_16_TO_8_SUPPORTED /* Name prior to 1.5.4 */ -/* Strip the second byte of information from a 16-bit depth file. */ -PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr)); -#endif - -#ifdef PNG_READ_QUANTIZE_SUPPORTED -/* Turn on quantizing, and reduce the palette to the number of colors - * available. - */ -PNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr, - png_colorp palette, int num_palette, int maximum_colors, - png_const_uint_16p histogram, int full_quantize)); -#endif - -#ifdef PNG_READ_GAMMA_SUPPORTED -/* The threshold on gamma processing is configurable but hard-wired into the - * library. The following is the floating point variant. - */ -#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001) - -/* Handle gamma correction. Screen_gamma=(display_exponent). - * NOTE: this API simply sets the screen and file gamma values. It will - * therefore override the value for gamma in a PNG file if it is called after - * the file header has been read - use with care - call before reading the PNG - * file for best results! - * - * These routines accept the same gamma values as png_set_alpha_mode (described - * above). The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either - * API (floating point or fixed.) Notice, however, that the 'file_gamma' value - * is the inverse of a 'screen gamma' value. - */ -PNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr, - double screen_gamma, double override_file_gamma)) -PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr, - png_fixed_point screen_gamma, png_fixed_point override_file_gamma)) -#endif - -#ifdef PNG_WRITE_FLUSH_SUPPORTED -/* Set how many lines between output flushes - 0 for no flushing */ -PNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows)); -/* Flush the current PNG output buffer */ -PNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr)); -#endif - -/* Optional update palette with requested transformations */ -PNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr)); - -/* Optional call to update the users info structure */ -PNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr, - png_inforp info_ptr)); - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read one or more rows of image data. */ -PNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row, - png_bytepp display_row, png_uint_32 num_rows)); -#endif - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read a row of data. */ -PNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row, - png_bytep display_row)); -#endif - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read the whole image into memory at once. */ -PNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image)); -#endif - -/* Write a row of image data */ -PNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr, - png_const_bytep row)); - -/* Write a few rows of image data: (*row) is not written; however, the type - * is declared as writeable to maintain compatibility with previous versions - * of libpng and to allow the 'display_row' array from read_rows to be passed - * unchanged to write_rows. - */ -PNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row, - png_uint_32 num_rows)); - -/* Write the image data */ -PNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image)); - -/* Write the end of the PNG file. */ -PNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr, - png_inforp info_ptr)); - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read the end of the PNG file. */ -PNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr)); -#endif - -/* Free any memory associated with the png_info_struct */ -PNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr, - png_infopp info_ptr_ptr)); - -/* Free any memory associated with the png_struct and the png_info_structs */ -PNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr, - png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); - -/* Free any memory associated with the png_struct and the png_info_structs */ -PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr, - png_infopp info_ptr_ptr)); - -/* Set the libpng method of handling chunk CRC errors */ -PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action, - int ancil_action)); - -/* Values for png_set_crc_action() say how to handle CRC errors in - * ancillary and critical chunks, and whether to use the data contained - * therein. Note that it is impossible to "discard" data in a critical - * chunk. For versions prior to 0.90, the action was always error/quit, - * whereas in version 0.90 and later, the action for CRC errors in ancillary - * chunks is warn/discard. These values should NOT be changed. - * - * value action:critical action:ancillary - */ -#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ -#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ -#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ -#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ -#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ -#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ - -#ifdef PNG_WRITE_SUPPORTED -/* These functions give the user control over the scan-line filtering in - * libpng and the compression methods used by zlib. These functions are - * mainly useful for testing, as the defaults should work with most users. - * Those users who are tight on memory or want faster performance at the - * expense of compression can modify them. See the compression library - * header file (zlib.h) for an explination of the compression functions. - */ - -/* Set the filtering method(s) used by libpng. Currently, the only valid - * value for "method" is 0. - */ -PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method, - int filters)); -#endif /* WRITE */ - -/* Flags for png_set_filter() to say which filters to use. The flags - * are chosen so that they don't conflict with real filter types - * below, in case they are supplied instead of the #defined constants. - * These values should NOT be changed. - */ -#define PNG_NO_FILTERS 0x00 -#define PNG_FILTER_NONE 0x08 -#define PNG_FILTER_SUB 0x10 -#define PNG_FILTER_UP 0x20 -#define PNG_FILTER_AVG 0x40 -#define PNG_FILTER_PAETH 0x80 -#define PNG_FAST_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP) -#define PNG_ALL_FILTERS (PNG_FAST_FILTERS | PNG_FILTER_AVG | PNG_FILTER_PAETH) - -/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. - * These defines should NOT be changed. - */ -#define PNG_FILTER_VALUE_NONE 0 -#define PNG_FILTER_VALUE_SUB 1 -#define PNG_FILTER_VALUE_UP 2 -#define PNG_FILTER_VALUE_AVG 3 -#define PNG_FILTER_VALUE_PAETH 4 -#define PNG_FILTER_VALUE_LAST 5 - -#ifdef PNG_WRITE_SUPPORTED -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */ -PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr, - int heuristic_method, int num_weights, png_const_doublep filter_weights, - png_const_doublep filter_costs)) -PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, - (png_structrp png_ptr, int heuristic_method, int num_weights, - png_const_fixed_point_p filter_weights, - png_const_fixed_point_p filter_costs)) -#endif /* WRITE_WEIGHTED_FILTER */ - -/* The following are no longer used and will be removed from libpng-1.7: */ -#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ -#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ -#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ -#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ - -/* Set the library compression level. Currently, valid values range from - * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 - * (0 - no compression, 9 - "maximal" compression). Note that tests have - * shown that zlib compression levels 3-6 usually perform as well as level 9 - * for PNG images, and do considerably fewer caclulations. In the future, - * these values may not correspond directly to the zlib compression levels. - */ -#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED -PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr, - int level)); - -PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr, - int mem_level)); - -PNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr, - int strategy)); - -/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a - * smaller value of window_bits if it can do so safely. - */ -PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr, - int window_bits)); - -PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr, - int method)); -#endif /* WRITE_CUSTOMIZE_COMPRESSION */ - -#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED -/* Also set zlib parameters for compressing non-IDAT chunks */ -PNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr, - int level)); - -PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr, - int mem_level)); - -PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr, - int strategy)); - -/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a - * smaller value of window_bits if it can do so safely. - */ -PNG_EXPORT(225, void, png_set_text_compression_window_bits, - (png_structrp png_ptr, int window_bits)); - -PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr, - int method)); -#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */ -#endif /* WRITE */ - -/* These next functions are called for input/output, memory, and error - * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, - * and call standard C I/O routines such as fread(), fwrite(), and - * fprintf(). These functions can be made to use other I/O routines - * at run time for those applications that need to handle I/O in a - * different manner by calling png_set_???_fn(). See libpng-manual.txt for - * more information. - */ - -#ifdef PNG_STDIO_SUPPORTED -/* Initialize the input/output for the PNG file to the default functions. */ -PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp)); -#endif - -/* Replace the (error and abort), and warning functions with user - * supplied functions. If no messages are to be printed you must still - * write and use replacement functions. The replacement error_fn should - * still do a longjmp to the last setjmp location if you are using this - * method of error handling. If error_fn or warning_fn is NULL, the - * default function will be used. - */ - -PNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); - -/* Return the user pointer associated with the error functions */ -PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr)); - -/* Replace the default data output functions with a user supplied one(s). - * If buffered output is not used, then output_flush_fn can be set to NULL. - * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time - * output_flush_fn will be ignored (and thus can be NULL). - * It is probably a mistake to use NULL for output_flush_fn if - * write_data_fn is not also NULL unless you have built libpng with - * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's - * default flush function, which uses the standard *FILE structure, will - * be used. - */ -PNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr, - png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); - -/* Replace the default data input function with a user supplied one. */ -PNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr, - png_rw_ptr read_data_fn)); - -/* Return the user pointer associated with the I/O functions */ -PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr)); - -PNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr, - png_read_status_ptr read_row_fn)); - -PNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr, - png_write_status_ptr write_row_fn)); - -#ifdef PNG_USER_MEM_SUPPORTED -/* Replace the default memory allocation functions with user supplied one(s). */ -PNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -/* Return the user pointer associated with the memory functions */ -PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr)); -#endif - -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED -PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr, - png_user_transform_ptr read_user_transform_fn)); -#endif - -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED -PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr, - png_user_transform_ptr write_user_transform_fn)); -#endif - -#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED -PNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr, - png_voidp user_transform_ptr, int user_transform_depth, - int user_transform_channels)); -/* Return the user pointer associated with the user transform functions */ -PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr, - (png_const_structrp png_ptr)); -#endif - -#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED -/* Return information about the row currently being processed. Note that these - * APIs do not fail but will return unexpected results if called outside a user - * transform callback. Also note that when transforming an interlaced image the - * row number is the row number within the sub-image of the interlace pass, so - * the value will increase to the height of the sub-image (not the full image) - * then reset to 0 for the next pass. - * - * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to - * find the output pixel (x,y) given an interlaced sub-image pixel - * (row,col,pass). (See below for these macros.) - */ -PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp)); -PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp)); -#endif - -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED -/* This callback is called only for *unknown* chunks. If - * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known - * chunks to be treated as unknown, however in this case the callback must do - * any processing required by the chunk (e.g. by calling the appropriate - * png_set_ APIs.) - * - * There is no write support - on write, by default, all the chunks in the - * 'unknown' list are written in the specified position. - * - * The integer return from the callback function is interpreted thus: - * - * negative: An error occurred; png_chunk_error will be called. - * zero: The chunk was not handled, the chunk will be saved. A critical - * chunk will cause an error at this point unless it is to be saved. - * positive: The chunk was handled, libpng will ignore/discard it. - * - * See "INTERACTION WITH USER CHUNK CALLBACKS" below for important notes about - * how this behavior will change in libpng 1.7 - */ -PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr, - png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); -#endif - -#ifdef PNG_USER_CHUNKS_SUPPORTED -PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr)); -#endif - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -/* Sets the function callbacks for the push reader, and a pointer to a - * user-defined structure available to the callback functions. - */ -PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr, - png_voidp progressive_ptr, png_progressive_info_ptr info_fn, - png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)); - -/* Returns the user pointer associated with the push read functions */ -PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, - (png_const_structrp png_ptr)); - -/* Function to be called when data becomes available */ -PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr, - png_inforp info_ptr, png_bytep buffer, size_t buffer_size)); - -/* A function which may be called *only* within png_process_data to stop the - * processing of any more data. The function returns the number of bytes - * remaining, excluding any that libpng has cached internally. A subsequent - * call to png_process_data must supply these bytes again. If the argument - * 'save' is set to true the routine will first save all the pending data and - * will always return 0. - */ -PNG_EXPORT(219, size_t, png_process_data_pause, (png_structrp, int save)); - -/* A function which may be called *only* outside (after) a call to - * png_process_data. It returns the number of bytes of data to skip in the - * input. Normally it will return 0, but if it returns a non-zero value the - * application must skip than number of bytes of input data and pass the - * following data to the next call to png_process_data. - */ -PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp)); - -/* Function that combines rows. 'new_row' is a flag that should come from - * the callback and be non-NULL if anything needs to be done; the library - * stores its own version of the new data internally and ignores the passed - * in value. - */ -PNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr, - png_bytep old_row, png_const_bytep new_row)); -#endif /* PROGRESSIVE_READ */ - -PNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr, - png_alloc_size_t size), PNG_ALLOCATED); -/* Added at libpng version 1.4.0 */ -PNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr, - png_alloc_size_t size), PNG_ALLOCATED); - -/* Added at libpng version 1.2.4 */ -PNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr, - png_alloc_size_t size), PNG_ALLOCATED); - -/* Frees a pointer allocated by png_malloc() */ -PNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr)); - -/* Free data that was allocated internally */ -PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr, - png_inforp info_ptr, png_uint_32 free_me, int num)); - -/* Reassign responsibility for freeing existing data, whether allocated - * by libpng or by the application; this works on the png_info structure passed - * in, it does not change the state for other png_info structures. - * - * It is unlikely that this function works correctly as of 1.6.0 and using it - * may result either in memory leaks or double free of allocated data. - */ -PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr, - png_inforp info_ptr, int freer, png_uint_32 mask)); - -/* Assignments for png_data_freer */ -#define PNG_DESTROY_WILL_FREE_DATA 1 -#define PNG_SET_WILL_FREE_DATA 1 -#define PNG_USER_WILL_FREE_DATA 2 -/* Flags for png_ptr->free_me and info_ptr->free_me */ -#define PNG_FREE_HIST 0x0008U -#define PNG_FREE_ICCP 0x0010U -#define PNG_FREE_SPLT 0x0020U -#define PNG_FREE_ROWS 0x0040U -#define PNG_FREE_PCAL 0x0080U -#define PNG_FREE_SCAL 0x0100U -#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_FREE_UNKN 0x0200U -#endif -/* PNG_FREE_LIST 0x0400U removed in 1.6.0 because it is ignored */ -#define PNG_FREE_PLTE 0x1000U -#define PNG_FREE_TRNS 0x2000U -#define PNG_FREE_TEXT 0x4000U -#define PNG_FREE_EXIF 0x8000U /* Added at libpng-1.6.31 */ -#define PNG_FREE_ALL 0xffffU -#define PNG_FREE_MUL 0x4220U /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ - -#ifdef PNG_USER_MEM_SUPPORTED -PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr, - png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED); -PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr, - png_voidp ptr), PNG_DEPRECATED); -#endif - -#ifdef PNG_ERROR_TEXT_SUPPORTED -/* Fatal error in PNG image of libpng - can't continue */ -PNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr, - png_const_charp error_message), PNG_NORETURN); - -/* The same, but the chunk name is prepended to the error string. */ -PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr, - png_const_charp error_message), PNG_NORETURN); - -#else -/* Fatal error in PNG image of libpng - can't continue */ -PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN); -# define png_error(s1,s2) png_err(s1) -# define png_chunk_error(s1,s2) png_err(s1) -#endif - -#ifdef PNG_WARNINGS_SUPPORTED -/* Non-fatal error in libpng. Can continue, but may have a problem. */ -PNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr, - png_const_charp warning_message)); - -/* Non-fatal error in libpng, chunk name is prepended to message. */ -PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr, - png_const_charp warning_message)); -#else -# define png_warning(s1,s2) ((void)(s1)) -# define png_chunk_warning(s1,s2) ((void)(s1)) -#endif - -#ifdef PNG_BENIGN_ERRORS_SUPPORTED -/* Benign error in libpng. Can continue, but may have a problem. - * User can choose whether to handle as a fatal error or as a warning. */ -PNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr, - png_const_charp warning_message)); - -#ifdef PNG_READ_SUPPORTED -/* Same, chunk name is prepended to message (only during read) */ -PNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr, - png_const_charp warning_message)); -#endif - -PNG_EXPORT(109, void, png_set_benign_errors, - (png_structrp png_ptr, int allowed)); -#else -# ifdef PNG_ALLOW_BENIGN_ERRORS -# define png_benign_error png_warning -# define png_chunk_benign_error png_chunk_warning -# else -# define png_benign_error png_error -# define png_chunk_benign_error png_chunk_error -# endif -#endif - -/* The png_set_ functions are for storing values in the png_info_struct. - * Similarly, the png_get_ calls are used to read values from the - * png_info_struct, either storing the parameters in the passed variables, or - * setting pointers into the png_info_struct where the data is stored. The - * png_get_ functions return a non-zero value if the data was available - * in info_ptr, or return zero and do not change any of the parameters if the - * data was not available. - * - * These functions should be used instead of directly accessing png_info - * to avoid problems with future changes in the size and internal layout of - * png_info_struct. - */ -/* Returns "flag" if chunk data is valid in info_ptr. */ -PNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr, - png_const_inforp info_ptr, png_uint_32 flag)); - -/* Returns number of bytes needed to hold a transformed row. */ -PNG_EXPORT(111, size_t, png_get_rowbytes, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -#ifdef PNG_INFO_IMAGE_SUPPORTED -/* Returns row_pointers, which is an array of pointers to scanlines that was - * returned from png_read_png(). - */ -PNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -/* Set row_pointers, which is an array of pointers to scanlines for use - * by png_write_png(). - */ -PNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr, - png_inforp info_ptr, png_bytepp row_pointers)); -#endif - -/* Returns number of color channels in image. */ -PNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -#ifdef PNG_EASY_ACCESS_SUPPORTED -/* Returns image width in pixels. */ -PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -/* Returns image height in pixels. */ -PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -/* Returns image bit_depth. */ -PNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -/* Returns image color_type. */ -PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -/* Returns image filter_type. */ -PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -/* Returns image interlace_type. */ -PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -/* Returns image compression_type. */ -PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -/* Returns image resolution in pixels per meter, from pHYs chunk data. */ -PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); - -/* Returns pixel aspect ratio, computed from pHYs chunk data. */ -PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio, - (png_const_structrp png_ptr, png_const_inforp info_ptr)) -PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr)) - -/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ -PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(128, png_int_32, png_get_x_offset_microns, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(129, png_int_32, png_get_y_offset_microns, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); - -#endif /* EASY_ACCESS */ - -#ifdef PNG_READ_SUPPORTED -/* Returns pointer to signature string read from PNG header */ -PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); -#endif - -#ifdef PNG_bKGD_SUPPORTED -PNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr, - png_inforp info_ptr, png_color_16p *background)); -#endif - -#ifdef PNG_bKGD_SUPPORTED -PNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_color_16p background)); -#endif - -#ifdef PNG_cHRM_SUPPORTED -PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr, - png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x, - double *red_y, double *green_x, double *green_y, double *blue_x, - double *blue_y)) -PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr, - png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z, - double *green_X, double *green_Y, double *green_Z, double *blue_X, - double *blue_Y, double *blue_Z)) -PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr, - png_fixed_point *int_white_x, png_fixed_point *int_white_y, - png_fixed_point *int_red_x, png_fixed_point *int_red_y, - png_fixed_point *int_green_x, png_fixed_point *int_green_y, - png_fixed_point *int_blue_x, png_fixed_point *int_blue_y)) -PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr, - png_fixed_point *int_red_X, png_fixed_point *int_red_Y, - png_fixed_point *int_red_Z, png_fixed_point *int_green_X, - png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, - png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, - png_fixed_point *int_blue_Z)) -#endif - -#ifdef PNG_cHRM_SUPPORTED -PNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr, - png_inforp info_ptr, - double white_x, double white_y, double red_x, double red_y, double green_x, - double green_y, double blue_x, double blue_y)) -PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr, - png_inforp info_ptr, double red_X, double red_Y, double red_Z, - double green_X, double green_Y, double green_Z, double blue_X, - double blue_Y, double blue_Z)) -PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr, - png_inforp info_ptr, png_fixed_point int_white_x, - png_fixed_point int_white_y, png_fixed_point int_red_x, - png_fixed_point int_red_y, png_fixed_point int_green_x, - png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)) -PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr, - png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, - png_fixed_point int_red_Z, png_fixed_point int_green_X, - png_fixed_point int_green_Y, png_fixed_point int_green_Z, - png_fixed_point int_blue_X, png_fixed_point int_blue_Y, - png_fixed_point int_blue_Z)) -#endif - -#ifdef PNG_eXIf_SUPPORTED -PNG_EXPORT(246, png_uint_32, png_get_eXIf, (png_const_structrp png_ptr, - png_inforp info_ptr, png_bytep *exif)); -PNG_EXPORT(247, void, png_set_eXIf, (png_const_structrp png_ptr, - png_inforp info_ptr, png_bytep exif)); - -PNG_EXPORT(248, png_uint_32, png_get_eXIf_1, (png_const_structrp png_ptr, - png_const_inforp info_ptr, png_uint_32 *num_exif, png_bytep *exif)); -PNG_EXPORT(249, void, png_set_eXIf_1, (png_const_structrp png_ptr, - png_inforp info_ptr, png_uint_32 num_exif, png_bytep exif)); -#endif - -#ifdef PNG_gAMA_SUPPORTED -PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr, - png_const_inforp info_ptr, double *file_gamma)) -PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr, - png_fixed_point *int_file_gamma)) -#endif - -#ifdef PNG_gAMA_SUPPORTED -PNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr, - png_inforp info_ptr, double file_gamma)) -PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr, - png_inforp info_ptr, png_fixed_point int_file_gamma)) -#endif - -#ifdef PNG_hIST_SUPPORTED -PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr, - png_inforp info_ptr, png_uint_16p *hist)); -PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_uint_16p hist)); -#endif - -PNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr, - png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, - int *bit_depth, int *color_type, int *interlace_method, - int *compression_method, int *filter_method)); - -PNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr, - png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_method, int compression_method, - int filter_method)); - -#ifdef PNG_oFFs_SUPPORTED -PNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr, - png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, - int *unit_type)); -#endif - -#ifdef PNG_oFFs_SUPPORTED -PNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr, - png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y, - int unit_type)); -#endif - -#ifdef PNG_pCAL_SUPPORTED -PNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr, - png_inforp info_ptr, png_charp *purpose, png_int_32 *X0, - png_int_32 *X1, int *type, int *nparams, png_charp *units, - png_charpp *params)); -#endif - -#ifdef PNG_pCAL_SUPPORTED -PNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1, - int type, int nparams, png_const_charp units, png_charpp params)); -#endif - -#ifdef PNG_pHYs_SUPPORTED -PNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr, - png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, - int *unit_type)); -#endif - -#ifdef PNG_pHYs_SUPPORTED -PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr, - png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); -#endif - -PNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr, - png_inforp info_ptr, png_colorp *palette, int *num_palette)); - -PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr, - png_inforp info_ptr, png_const_colorp palette, int num_palette)); - -#ifdef PNG_sBIT_SUPPORTED -PNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr, - png_inforp info_ptr, png_color_8p *sig_bit)); -#endif - -#ifdef PNG_sBIT_SUPPORTED -PNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_color_8p sig_bit)); -#endif - -#ifdef PNG_sRGB_SUPPORTED -PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr, - png_const_inforp info_ptr, int *file_srgb_intent)); -#endif - -#ifdef PNG_sRGB_SUPPORTED -PNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr, - png_inforp info_ptr, int srgb_intent)); -PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr, - png_inforp info_ptr, int srgb_intent)); -#endif - -#ifdef PNG_iCCP_SUPPORTED -PNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr, - png_inforp info_ptr, png_charpp name, int *compression_type, - png_bytepp profile, png_uint_32 *proflen)); -#endif - -#ifdef PNG_iCCP_SUPPORTED -PNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_charp name, int compression_type, - png_const_bytep profile, png_uint_32 proflen)); -#endif - -#ifdef PNG_sPLT_SUPPORTED -PNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr, - png_inforp info_ptr, png_sPLT_tpp entries)); -#endif - -#ifdef PNG_sPLT_SUPPORTED -PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)); -#endif - -#ifdef PNG_TEXT_SUPPORTED -/* png_get_text also returns the number of text chunks in *num_text */ -PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr, - png_inforp info_ptr, png_textp *text_ptr, int *num_text)); -#endif - -/* Note while png_set_text() will accept a structure whose text, - * language, and translated keywords are NULL pointers, the structure - * returned by png_get_text will always contain regular - * zero-terminated C strings. They might be empty strings but - * they will never be NULL pointers. - */ - -#ifdef PNG_TEXT_SUPPORTED -PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_textp text_ptr, int num_text)); -#endif - -#ifdef PNG_tIME_SUPPORTED -PNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr, - png_inforp info_ptr, png_timep *mod_time)); -#endif - -#ifdef PNG_tIME_SUPPORTED -PNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_timep mod_time)); -#endif - -#ifdef PNG_tRNS_SUPPORTED -PNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr, - png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans, - png_color_16p *trans_color)); -#endif - -#ifdef PNG_tRNS_SUPPORTED -PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr, - png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans, - png_const_color_16p trans_color)); -#endif - -#ifdef PNG_sCAL_SUPPORTED -PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr, - png_const_inforp info_ptr, int *unit, double *width, double *height)) -#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ - defined(PNG_FLOATING_POINT_SUPPORTED) -/* NOTE: this API is currently implemented using floating point arithmetic, - * consequently it can only be used on systems with floating point support. - * In any case the range of values supported by png_fixed_point is small and it - * is highly recommended that png_get_sCAL_s be used instead. - */ -PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, - png_fixed_point *width, png_fixed_point *height)) -#endif -PNG_EXPORT(169, png_uint_32, png_get_sCAL_s, - (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, - png_charpp swidth, png_charpp sheight)); - -PNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr, - png_inforp info_ptr, int unit, double width, double height)) -PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr, - png_inforp info_ptr, int unit, png_fixed_point width, - png_fixed_point height)) -PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr, - png_inforp info_ptr, int unit, - png_const_charp swidth, png_const_charp sheight)); -#endif /* sCAL */ - -#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED -/* Provide the default handling for all unknown chunks or, optionally, for - * specific unknown chunks. - * - * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was - * ignored and the default was used, the per-chunk setting only had an effect on - * write. If you wish to have chunk-specific handling on read in code that must - * work on earlier versions you must use a user chunk callback to specify the - * desired handling (keep or discard.) - * - * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below. The - * parameter is interpreted as follows: - * - * READ: - * PNG_HANDLE_CHUNK_AS_DEFAULT: - * Known chunks: do normal libpng processing, do not keep the chunk (but - * see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED) - * Unknown chunks: for a specific chunk use the global default, when used - * as the default discard the chunk data. - * PNG_HANDLE_CHUNK_NEVER: - * Discard the chunk data. - * PNG_HANDLE_CHUNK_IF_SAFE: - * Keep the chunk data if the chunk is not critical else raise a chunk - * error. - * PNG_HANDLE_CHUNK_ALWAYS: - * Keep the chunk data. - * - * If the chunk data is saved it can be retrieved using png_get_unknown_chunks, - * below. Notice that specifying "AS_DEFAULT" as a global default is equivalent - * to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks - * it simply resets the behavior to the libpng default. - * - * INTERACTION WITH USER CHUNK CALLBACKS: - * The per-chunk handling is always used when there is a png_user_chunk_ptr - * callback and the callback returns 0; the chunk is then always stored *unless* - * it is critical and the per-chunk setting is other than ALWAYS. Notice that - * the global default is *not* used in this case. (In effect the per-chunk - * value is incremented to at least IF_SAFE.) - * - * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and - * per-chunk defaults will be honored. If you want to preserve the current - * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE - * as the default - if you don't do this libpng 1.6 will issue a warning. - * - * If you want unhandled unknown chunks to be discarded in libpng 1.6 and - * earlier simply return '1' (handled). - * - * PNG_HANDLE_AS_UNKNOWN_SUPPORTED: - * If this is *not* set known chunks will always be handled by libpng and - * will never be stored in the unknown chunk list. Known chunks listed to - * png_set_keep_unknown_chunks will have no effect. If it is set then known - * chunks listed with a keep other than AS_DEFAULT will *never* be processed - * by libpng, in addition critical chunks must either be processed by the - * callback or saved. - * - * The IHDR and IEND chunks must not be listed. Because this turns off the - * default handling for chunks that would otherwise be recognized the - * behavior of libpng transformations may well become incorrect! - * - * WRITE: - * When writing chunks the options only apply to the chunks specified by - * png_set_unknown_chunks (below), libpng will *always* write known chunks - * required by png_set_ calls and will always write the core critical chunks - * (as required for PLTE). - * - * Each chunk in the png_set_unknown_chunks list is looked up in the - * png_set_keep_unknown_chunks list to find the keep setting, this is then - * interpreted as follows: - * - * PNG_HANDLE_CHUNK_AS_DEFAULT: - * Write safe-to-copy chunks and write other chunks if the global - * default is set to _ALWAYS, otherwise don't write this chunk. - * PNG_HANDLE_CHUNK_NEVER: - * Do not write the chunk. - * PNG_HANDLE_CHUNK_IF_SAFE: - * Write the chunk if it is safe-to-copy, otherwise do not write it. - * PNG_HANDLE_CHUNK_ALWAYS: - * Write the chunk. - * - * Note that the default behavior is effectively the opposite of the read case - - * in read unknown chunks are not stored by default, in write they are written - * by default. Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different - * - on write the safe-to-copy bit is checked, on read the critical bit is - * checked and on read if the chunk is critical an error will be raised. - * - * num_chunks: - * =========== - * If num_chunks is positive, then the "keep" parameter specifies the manner - * for handling only those chunks appearing in the chunk_list array, - * otherwise the chunk list array is ignored. - * - * If num_chunks is 0 the "keep" parameter specifies the default behavior for - * unknown chunks, as described above. - * - * If num_chunks is negative, then the "keep" parameter specifies the manner - * for handling all unknown chunks plus all chunks recognized by libpng - * except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to - * be processed by libpng. - */ -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr, - int keep, png_const_bytep chunk_list, int num_chunks)); -#endif /* HANDLE_AS_UNKNOWN */ - -/* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned; - * the result is therefore true (non-zero) if special handling is required, - * false for the default handling. - */ -PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr, - png_const_bytep chunk_name)); -#endif /* SET_UNKNOWN_CHUNKS */ - -#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED -PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_unknown_chunkp unknowns, - int num_unknowns)); - /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added - * unknowns to the location currently stored in the png_struct. This is - * invariably the wrong value on write. To fix this call the following API - * for each chunk in the list with the correct location. If you know your - * code won't be compiled on earlier versions you can rely on - * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing - * the correct thing. - */ - -PNG_EXPORT(175, void, png_set_unknown_chunk_location, - (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location)); - -PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr, - png_inforp info_ptr, png_unknown_chunkpp entries)); -#endif - -/* Png_free_data() will turn off the "valid" flag for anything it frees. - * If you need to turn it off for a chunk that your application has freed, - * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); - */ -PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr, - png_inforp info_ptr, int mask)); - -#ifdef PNG_INFO_IMAGE_SUPPORTED -/* The "params" pointer is currently not used and is for future expansion. */ -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr, - int transforms, png_voidp params)); -#endif -#ifdef PNG_WRITE_SUPPORTED -PNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr, - int transforms, png_voidp params)); -#endif -#endif - -PNG_EXPORT(180, png_const_charp, png_get_copyright, - (png_const_structrp png_ptr)); -PNG_EXPORT(181, png_const_charp, png_get_header_ver, - (png_const_structrp png_ptr)); -PNG_EXPORT(182, png_const_charp, png_get_header_version, - (png_const_structrp png_ptr)); -PNG_EXPORT(183, png_const_charp, png_get_libpng_ver, - (png_const_structrp png_ptr)); - -#ifdef PNG_MNG_FEATURES_SUPPORTED -PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr, - png_uint_32 mng_features_permitted)); -#endif - -/* For use in png_set_keep_unknown, added to version 1.2.6 */ -#define PNG_HANDLE_CHUNK_AS_DEFAULT 0 -#define PNG_HANDLE_CHUNK_NEVER 1 -#define PNG_HANDLE_CHUNK_IF_SAFE 2 -#define PNG_HANDLE_CHUNK_ALWAYS 3 -#define PNG_HANDLE_CHUNK_LAST 4 - -/* Strip the prepended error numbers ("#nnn ") from error and warning - * messages before passing them to the error or warning handler. - */ -#ifdef PNG_ERROR_NUMBERS_SUPPORTED -PNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr, - png_uint_32 strip_mode)); -#endif - -/* Added in libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -PNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr, - png_uint_32 user_width_max, png_uint_32 user_height_max)); -PNG_EXPORT(187, png_uint_32, png_get_user_width_max, - (png_const_structrp png_ptr)); -PNG_EXPORT(188, png_uint_32, png_get_user_height_max, - (png_const_structrp png_ptr)); -/* Added in libpng-1.4.0 */ -PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr, - png_uint_32 user_chunk_cache_max)); -PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max, - (png_const_structrp png_ptr)); -/* Added in libpng-1.4.1 */ -PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr, - png_alloc_size_t user_chunk_cache_max)); -PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max, - (png_const_structrp png_ptr)); -#endif - -#if defined(PNG_INCH_CONVERSIONS_SUPPORTED) -PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); - -PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); - -PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); - -PNG_FP_EXPORT(196, float, png_get_x_offset_inches, - (png_const_structrp png_ptr, png_const_inforp info_ptr)) -#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ -PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr)) -#endif - -PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr, - png_const_inforp info_ptr)) -#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ -PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr)) -#endif - -# ifdef PNG_pHYs_SUPPORTED -PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr, - png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, - int *unit_type)); -# endif /* pHYs */ -#endif /* INCH_CONVERSIONS */ - -/* Added in libpng-1.4.0 */ -#ifdef PNG_IO_STATE_SUPPORTED -PNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr)); - -/* Removed from libpng 1.6; use png_get_io_chunk_type. */ -PNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr), - PNG_DEPRECATED) - -PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, - (png_const_structrp png_ptr)); - -/* The flags returned by png_get_io_state() are the following: */ -# define PNG_IO_NONE 0x0000 /* no I/O at this moment */ -# define PNG_IO_READING 0x0001 /* currently reading */ -# define PNG_IO_WRITING 0x0002 /* currently writing */ -# define PNG_IO_SIGNATURE 0x0010 /* currently at the file signature */ -# define PNG_IO_CHUNK_HDR 0x0020 /* currently at the chunk header */ -# define PNG_IO_CHUNK_DATA 0x0040 /* currently at the chunk data */ -# define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */ -# define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */ -# define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */ -#endif /* IO_STATE */ - -/* Interlace support. The following macros are always defined so that if - * libpng interlace handling is turned off the macros may be used to handle - * interlaced images within the application. - */ -#define PNG_INTERLACE_ADAM7_PASSES 7 - -/* Two macros to return the first row and first column of the original, - * full, image which appears in a given pass. 'pass' is in the range 0 - * to 6 and the result is in the range 0 to 7. - */ -#define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7) -#define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7) - -/* A macro to return the offset between pixels in the output row for a pair of - * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that - * follows. Note that ROW_OFFSET is the offset from one row to the next whereas - * COL_OFFSET is from one column to the next, within a row. - */ -#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8) -#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1)) - -/* Two macros to help evaluate the number of rows or columns in each - * pass. This is expressed as a shift - effectively log2 of the number or - * rows or columns in each 8x8 tile of the original image. - */ -#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3) -#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3) - -/* Hence two macros to determine the number of rows or columns in a given - * pass of an image given its height or width. In fact these macros may - * return non-zero even though the sub-image is empty, because the other - * dimension may be empty for a small image. - */ -#define PNG_PASS_ROWS(height, pass) (((height)+(((1<>PNG_PASS_ROW_SHIFT(pass)) -#define PNG_PASS_COLS(width, pass) (((width)+(((1<>PNG_PASS_COL_SHIFT(pass)) - -/* For the reader row callbacks (both progressive and sequential) it is - * necessary to find the row in the output image given a row in an interlaced - * image, so two more macros: - */ -#define PNG_ROW_FROM_PASS_ROW(y_in, pass) \ - (((y_in)<>(((7-(off))-(pass))<<2)) & 0xF) | \ - ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0)) - -#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \ - ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1) -#define PNG_COL_IN_INTERLACE_PASS(x, pass) \ - ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1) - -#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED -/* With these routines we avoid an integer divide, which will be slower on - * most machines. However, it does take more operations than the corresponding - * divide method, so it may be slower on a few RISC systems. There are two - * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. - * - * Note that the rounding factors are NOT supposed to be the same! 128 and - * 32768 are correct for the NODIV code; 127 and 32767 are correct for the - * standard method. - * - * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] - */ - - /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ - -# define png_composite(composite, fg, alpha, bg) \ - { \ - png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \ - * (png_uint_16)(alpha) \ - + (png_uint_16)(bg)*(png_uint_16)(255 \ - - (png_uint_16)(alpha)) + 128); \ - (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); \ - } - -# define png_composite_16(composite, fg, alpha, bg) \ - { \ - png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \ - * (png_uint_32)(alpha) \ - + (png_uint_32)(bg)*(65535 \ - - (png_uint_32)(alpha)) + 32768); \ - (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); \ - } - -#else /* Standard method using integer division */ - -# define png_composite(composite, fg, alpha, bg) \ - (composite) = \ - (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) + \ - (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ - 127) / 255)) - -# define png_composite_16(composite, fg, alpha, bg) \ - (composite) = \ - (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \ - (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ - 32767) / 65535)) -#endif /* READ_COMPOSITE_NODIV */ - -#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED -PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf)); -PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf)); -PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf)); -#endif - -PNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr, - png_const_bytep buf)); -/* No png_get_int_16 -- may be added if there's a real need for it. */ - -/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */ -#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED -PNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i)); -#endif -#ifdef PNG_SAVE_INT_32_SUPPORTED -PNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i)); -#endif - -/* Place a 16-bit number into a buffer in PNG byte order. - * The parameter is declared unsigned int, not png_uint_16, - * just to avoid potential problems on pre-ANSI C compilers. - */ -#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED -PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); -/* No png_save_int_16 -- may be added if there's a real need for it. */ -#endif - -#ifdef PNG_USE_READ_MACROS -/* Inline macros to do direct reads of bytes from the input buffer. - * The png_get_int_32() routine assumes we are using two's complement - * format for negative values, which is almost certainly true. - */ -# define PNG_get_uint_32(buf) \ - (((png_uint_32)(*(buf)) << 24) + \ - ((png_uint_32)(*((buf) + 1)) << 16) + \ - ((png_uint_32)(*((buf) + 2)) << 8) + \ - ((png_uint_32)(*((buf) + 3)))) - - /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the - * function) incorrectly returned a value of type png_uint_32. - */ -# define PNG_get_uint_16(buf) \ - ((png_uint_16) \ - (((unsigned int)(*(buf)) << 8) + \ - ((unsigned int)(*((buf) + 1))))) - -# define PNG_get_int_32(buf) \ - ((png_int_32)((*(buf) & 0x80) \ - ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \ - : (png_int_32)png_get_uint_32(buf))) - -/* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h, - * but defining a macro name prefixed with PNG_PREFIX. - */ -# ifndef PNG_PREFIX -# define png_get_uint_32(buf) PNG_get_uint_32(buf) -# define png_get_uint_16(buf) PNG_get_uint_16(buf) -# define png_get_int_32(buf) PNG_get_int_32(buf) -# endif -#else -# ifdef PNG_PREFIX - /* No macros; revert to the (redefined) function */ -# define PNG_get_uint_32 (png_get_uint_32) -# define PNG_get_uint_16 (png_get_uint_16) -# define PNG_get_int_32 (png_get_int_32) -# endif -#endif - -#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED -PNG_EXPORT(242, void, png_set_check_for_invalid_index, - (png_structrp png_ptr, int allowed)); -# ifdef PNG_GET_PALETTE_MAX_SUPPORTED -PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr, - png_const_infop info_ptr)); -# endif -#endif /* CHECK_FOR_INVALID_INDEX */ - -/******************************************************************************* - * Section 5: SIMPLIFIED API - ******************************************************************************* - * - * Please read the documentation in libpng-manual.txt (TODO: write said - * documentation) if you don't understand what follows. - * - * The simplified API hides the details of both libpng and the PNG file format - * itself. It allows PNG files to be read into a very limited number of - * in-memory bitmap formats or to be written from the same formats. If these - * formats do not accommodate your needs then you can, and should, use the more - * sophisticated APIs above - these support a wide variety of in-memory formats - * and a wide variety of sophisticated transformations to those formats as well - * as a wide variety of APIs to manipulate ancillary information. - * - * To read a PNG file using the simplified API: - * - * 1) Declare a 'png_image' structure (see below) on the stack, set the - * version field to PNG_IMAGE_VERSION and the 'opaque' pointer to NULL - * (this is REQUIRED, your program may crash if you don't do it.) - * 2) Call the appropriate png_image_begin_read... function. - * 3) Set the png_image 'format' member to the required sample format. - * 4) Allocate a buffer for the image and, if required, the color-map. - * 5) Call png_image_finish_read to read the image and, if required, the - * color-map into your buffers. - * - * There are no restrictions on the format of the PNG input itself; all valid - * color types, bit depths, and interlace methods are acceptable, and the - * input image is transformed as necessary to the requested in-memory format - * during the png_image_finish_read() step. The only caveat is that if you - * request a color-mapped image from a PNG that is full-color or makes - * complex use of an alpha channel the transformation is extremely lossy and the - * result may look terrible. - * - * To write a PNG file using the simplified API: - * - * 1) Declare a 'png_image' structure on the stack and memset() it to all zero. - * 2) Initialize the members of the structure that describe the image, setting - * the 'format' member to the format of the image samples. - * 3) Call the appropriate png_image_write... function with a pointer to the - * image and, if necessary, the color-map to write the PNG data. - * - * png_image is a structure that describes the in-memory format of an image - * when it is being read or defines the in-memory format of an image that you - * need to write: - */ -#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) || \ - defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) - -#define PNG_IMAGE_VERSION 1 - -typedef struct png_control *png_controlp; -typedef struct -{ - png_controlp opaque; /* Initialize to NULL, free with png_image_free */ - png_uint_32 version; /* Set to PNG_IMAGE_VERSION */ - png_uint_32 width; /* Image width in pixels (columns) */ - png_uint_32 height; /* Image height in pixels (rows) */ - png_uint_32 format; /* Image format as defined below */ - png_uint_32 flags; /* A bit mask containing informational flags */ - png_uint_32 colormap_entries; - /* Number of entries in the color-map */ - - /* In the event of an error or warning the following field will be set to a - * non-zero value and the 'message' field will contain a '\0' terminated - * string with the libpng error or warning message. If both warnings and - * an error were encountered, only the error is recorded. If there - * are multiple warnings, only the first one is recorded. - * - * The upper 30 bits of this value are reserved, the low two bits contain - * a value as follows: - */ -# define PNG_IMAGE_WARNING 1 -# define PNG_IMAGE_ERROR 2 - /* - * The result is a two-bit code such that a value more than 1 indicates - * a failure in the API just called: - * - * 0 - no warning or error - * 1 - warning - * 2 - error - * 3 - error preceded by warning - */ -# define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1) - - png_uint_32 warning_or_error; - - char message[64]; -} png_image, *png_imagep; - -/* The samples of the image have one to four channels whose components have - * original values in the range 0 to 1.0: - * - * 1: A single gray or luminance channel (G). - * 2: A gray/luminance channel and an alpha channel (GA). - * 3: Three red, green, blue color channels (RGB). - * 4: Three color channels and an alpha channel (RGBA). - * - * The components are encoded in one of two ways: - * - * a) As a small integer, value 0..255, contained in a single byte. For the - * alpha channel the original value is simply value/255. For the color or - * luminance channels the value is encoded according to the sRGB specification - * and matches the 8-bit format expected by typical display devices. - * - * The color/gray channels are not scaled (pre-multiplied) by the alpha - * channel and are suitable for passing to color management software. - * - * b) As a value in the range 0..65535, contained in a 2-byte integer. All - * channels can be converted to the original value by dividing by 65535; all - * channels are linear. Color channels use the RGB encoding (RGB end-points) of - * the sRGB specification. This encoding is identified by the - * PNG_FORMAT_FLAG_LINEAR flag below. - * - * When the simplified API needs to convert between sRGB and linear colorspaces, - * the actual sRGB transfer curve defined in the sRGB specification (see the - * article at ) is used, not the gamma=1/2.2 - * approximation used elsewhere in libpng. - * - * When an alpha channel is present it is expected to denote pixel coverage - * of the color or luminance channels and is returned as an associated alpha - * channel: the color/gray channels are scaled (pre-multiplied) by the alpha - * value. - * - * The samples are either contained directly in the image data, between 1 and 8 - * bytes per pixel according to the encoding, or are held in a color-map indexed - * by bytes in the image data. In the case of a color-map the color-map entries - * are individual samples, encoded as above, and the image data has one byte per - * pixel to select the relevant sample from the color-map. - */ - -/* PNG_FORMAT_* - * - * #defines to be used in png_image::format. Each #define identifies a - * particular layout of sample data and, if present, alpha values. There are - * separate defines for each of the two component encodings. - * - * A format is built up using single bit flag values. All combinations are - * valid. Formats can be built up from the flag values or you can use one of - * the predefined values below. When testing formats always use the FORMAT_FLAG - * macros to test for individual features - future versions of the library may - * add new flags. - * - * When reading or writing color-mapped images the format should be set to the - * format of the entries in the color-map then png_image_{read,write}_colormap - * called to read or write the color-map and set the format correctly for the - * image data. Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly! - * - * NOTE: libpng can be built with particular features disabled. If you see - * compiler errors because the definition of one of the following flags has been - * compiled out it is because libpng does not have the required support. It is - * possible, however, for the libpng configuration to enable the format on just - * read or just write; in that case you may see an error at run time. You can - * guard against this by checking for the definition of the appropriate - * "_SUPPORTED" macro, one of: - * - * PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED - */ -#define PNG_FORMAT_FLAG_ALPHA 0x01U /* format with an alpha channel */ -#define PNG_FORMAT_FLAG_COLOR 0x02U /* color format: otherwise grayscale */ -#define PNG_FORMAT_FLAG_LINEAR 0x04U /* 2-byte channels else 1-byte */ -#define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */ - -#ifdef PNG_FORMAT_BGR_SUPPORTED -# define PNG_FORMAT_FLAG_BGR 0x10U /* BGR colors, else order is RGB */ -#endif - -#ifdef PNG_FORMAT_AFIRST_SUPPORTED -# define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */ -#endif - -#define PNG_FORMAT_FLAG_ASSOCIATED_ALPHA 0x40U /* alpha channel is associated */ - -/* Commonly used formats have predefined macros. - * - * First the single byte (sRGB) formats: - */ -#define PNG_FORMAT_GRAY 0 -#define PNG_FORMAT_GA PNG_FORMAT_FLAG_ALPHA -#define PNG_FORMAT_AG (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST) -#define PNG_FORMAT_RGB PNG_FORMAT_FLAG_COLOR -#define PNG_FORMAT_BGR (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR) -#define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA) -#define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST) -#define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA) -#define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST) - -/* Then the linear 2-byte formats. When naming these "Y" is used to - * indicate a luminance (gray) channel. - */ -#define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR -#define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA) -#define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR) -#define PNG_FORMAT_LINEAR_RGB_ALPHA \ - (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA) - -/* With color-mapped formats the image data is one byte for each pixel, the byte - * is an index into the color-map which is formatted as above. To obtain a - * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP - * to one of the above definitions, or you can use one of the definitions below. - */ -#define PNG_FORMAT_RGB_COLORMAP (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP) -#define PNG_FORMAT_BGR_COLORMAP (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP) -#define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP) -#define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP) -#define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP) -#define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP) - -/* PNG_IMAGE macros - * - * These are convenience macros to derive information from a png_image - * structure. The PNG_IMAGE_SAMPLE_ macros return values appropriate to the - * actual image sample values - either the entries in the color-map or the - * pixels in the image. The PNG_IMAGE_PIXEL_ macros return corresponding values - * for the pixels and will always return 1 for color-mapped formats. The - * remaining macros return information about the rows in the image and the - * complete image. - * - * NOTE: All the macros that take a png_image::format parameter are compile time - * constants if the format parameter is, itself, a constant. Therefore these - * macros can be used in array declarations and case labels where required. - * Similarly the macros are also pre-processor constants (sizeof is not used) so - * they can be used in #if tests. - * - * First the information about the samples. - */ -#define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\ - (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1) - /* Return the total number of channels in a given format: 1..4 */ - -#define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\ - ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1) - /* Return the size in bytes of a single component of a pixel or color-map - * entry (as appropriate) in the image: 1 or 2. - */ - -#define PNG_IMAGE_SAMPLE_SIZE(fmt)\ - (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)) - /* This is the size of the sample data for one sample. If the image is - * color-mapped it is the size of one color-map entry (and image pixels are - * one byte in size), otherwise it is the size of one image pixel. - */ - -#define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\ - (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256) - /* The maximum size of the color-map required by the format expressed in a - * count of components. This can be used to compile-time allocate a - * color-map: - * - * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)]; - * - * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)]; - * - * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the - * information from one of the png_image_begin_read_ APIs and dynamically - * allocate the required memory. - */ - -/* Corresponding information about the pixels */ -#define PNG_IMAGE_PIXEL_(test,fmt)\ - (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt)) - -#define PNG_IMAGE_PIXEL_CHANNELS(fmt)\ - PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt) - /* The number of separate channels (components) in a pixel; 1 for a - * color-mapped image. - */ - -#define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\ - PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt) - /* The size, in bytes, of each component in a pixel; 1 for a color-mapped - * image. - */ - -#define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt) - /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */ - -/* Information about the whole row, or whole image */ -#define PNG_IMAGE_ROW_STRIDE(image)\ - (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width) - /* Return the total number of components in a single row of the image; this - * is the minimum 'row stride', the minimum count of components between each - * row. For a color-mapped image this is the minimum number of bytes in a - * row. - * - * WARNING: this macro overflows for some images with more than one component - * and very large image widths. libpng will refuse to process an image where - * this macro would overflow. - */ - -#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\ - (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride)) - /* Return the size, in bytes, of an image buffer given a png_image and a row - * stride - the number of components to leave space for in each row. - * - * WARNING: this macro overflows a 32-bit integer for some large PNG images, - * libpng will refuse to process an image where such an overflow would occur. - */ - -#define PNG_IMAGE_SIZE(image)\ - PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image)) - /* Return the size, in bytes, of the image in memory given just a png_image; - * the row stride is the minimum stride required for the image. - */ - -#define PNG_IMAGE_COLORMAP_SIZE(image)\ - (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries) - /* Return the size, in bytes, of the color-map of this image. If the image - * format is not a color-map format this will return a size sufficient for - * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if - * you don't want to allocate a color-map in this case. - */ - -/* PNG_IMAGE_FLAG_* - * - * Flags containing additional information about the image are held in the - * 'flags' field of png_image. - */ -#define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01 - /* This indicates that the RGB values of the in-memory bitmap do not - * correspond to the red, green and blue end-points defined by sRGB. - */ - -#define PNG_IMAGE_FLAG_FAST 0x02 - /* On write emphasise speed over compression; the resultant PNG file will be - * larger but will be produced significantly faster, particular for large - * images. Do not use this option for images which will be distributed, only - * used it when producing intermediate files that will be read back in - * repeatedly. For a typical 24-bit image the option will double the read - * speed at the cost of increasing the image size by 25%, however for many - * more compressible images the PNG file can be 10 times larger with only a - * slight speed gain. - */ - -#define PNG_IMAGE_FLAG_16BIT_sRGB 0x04 - /* On read if the image is a 16-bit per component image and there is no gAMA - * or sRGB chunk assume that the components are sRGB encoded. Notice that - * images output by the simplified API always have gamma information; setting - * this flag only affects the interpretation of 16-bit images from an - * external source. It is recommended that the application expose this flag - * to the user; the user can normally easily recognize the difference between - * linear and sRGB encoding. This flag has no effect on write - the data - * passed to the write APIs must have the correct encoding (as defined - * above.) - * - * If the flag is not set (the default) input 16-bit per component data is - * assumed to be linear. - * - * NOTE: the flag can only be set after the png_image_begin_read_ call, - * because that call initializes the 'flags' field. - */ - -#ifdef PNG_SIMPLIFIED_READ_SUPPORTED -/* READ APIs - * --------- - * - * The png_image passed to the read APIs must have been initialized by setting - * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.) - */ -#ifdef PNG_STDIO_SUPPORTED -PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image, - const char *file_name)); - /* The named file is opened for read and the image header is filled in - * from the PNG header in the file. - */ - -PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image, - FILE* file)); - /* The PNG header is read from the stdio FILE object. */ -#endif /* STDIO */ - -PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image, - png_const_voidp memory, size_t size)); - /* The PNG header is read from the given memory buffer. */ - -PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image, - png_const_colorp background, void *buffer, png_int_32 row_stride, - void *colormap)); - /* Finish reading the image into the supplied buffer and clean up the - * png_image structure. - * - * row_stride is the step, in byte or 2-byte units as appropriate, - * between adjacent rows. A positive stride indicates that the top-most row - * is first in the buffer - the normal top-down arrangement. A negative - * stride indicates that the bottom-most row is first in the buffer. - * - * background need only be supplied if an alpha channel must be removed from - * a png_byte format and the removal is to be done by compositing on a solid - * color; otherwise it may be NULL and any composition will be done directly - * onto the buffer. The value is an sRGB color to use for the background, - * for grayscale output the green channel is used. - * - * background must be supplied when an alpha channel must be removed from a - * single byte color-mapped output format, in other words if: - * - * 1) The original format from png_image_begin_read_from_* had - * PNG_FORMAT_FLAG_ALPHA set. - * 2) The format set by the application does not. - * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and - * PNG_FORMAT_FLAG_LINEAR *not* set. - * - * For linear output removing the alpha channel is always done by compositing - * on black and background is ignored. - * - * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set. It must - * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE. - * image->colormap_entries will be updated to the actual number of entries - * written to the colormap; this may be less than the original value. - */ - -PNG_EXPORT(238, void, png_image_free, (png_imagep image)); - /* Free any data allocated by libpng in image->opaque, setting the pointer to - * NULL. May be called at any time after the structure is initialized. - */ -#endif /* SIMPLIFIED_READ */ - -#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED -/* WRITE APIS - * ---------- - * For write you must initialize a png_image structure to describe the image to - * be written. To do this use memset to set the whole structure to 0 then - * initialize fields describing your image. - * - * version: must be set to PNG_IMAGE_VERSION - * opaque: must be initialized to NULL - * width: image width in pixels - * height: image height in rows - * format: the format of the data (image and color-map) you wish to write - * flags: set to 0 unless one of the defined flags applies; set - * PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB - * values do not correspond to the colors in sRGB. - * colormap_entries: set to the number of entries in the color-map (0 to 256) - */ -#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED -PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image, - const char *file, int convert_to_8bit, const void *buffer, - png_int_32 row_stride, const void *colormap)); - /* Write the image to the named file. */ - -PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file, - int convert_to_8_bit, const void *buffer, png_int_32 row_stride, - const void *colormap)); - /* Write the image to the given (FILE*). */ -#endif /* SIMPLIFIED_WRITE_STDIO */ - -/* With all write APIs if image is in one of the linear formats with 16-bit - * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG - * gamma encoded according to the sRGB specification, otherwise a 16-bit linear - * encoded PNG file is written. - * - * With color-mapped data formats the colormap parameter point to a color-map - * with at least image->colormap_entries encoded in the specified format. If - * the format is linear the written PNG color-map will be converted to sRGB - * regardless of the convert_to_8_bit flag. - * - * With all APIs row_stride is handled as in the read APIs - it is the spacing - * from one row to the next in component sized units (1 or 2 bytes) and if - * negative indicates a bottom-up row layout in the buffer. If row_stride is - * zero, libpng will calculate it for you from the image width and number of - * channels. - * - * Note that the write API does not support interlacing, sub-8-bit pixels or - * most ancillary chunks. If you need to write text chunks (e.g. for copyright - * notices) you need to use one of the other APIs. - */ - -PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory, - png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8_bit, - const void *buffer, png_int_32 row_stride, const void *colormap)); - /* Write the image to the given memory buffer. The function both writes the - * whole PNG data stream to *memory and updates *memory_bytes with the count - * of bytes written. - * - * 'memory' may be NULL. In this case *memory_bytes is not read however on - * success the number of bytes which would have been written will still be - * stored in *memory_bytes. On failure *memory_bytes will contain 0. - * - * If 'memory' is not NULL it must point to memory[*memory_bytes] of - * writeable memory. - * - * If the function returns success memory[*memory_bytes] (if 'memory' is not - * NULL) contains the written PNG data. *memory_bytes will always be less - * than or equal to the original value. - * - * If the function returns false and *memory_bytes was not changed an error - * occurred during write. If *memory_bytes was changed, or is not 0 if - * 'memory' was NULL, the write would have succeeded but for the memory - * buffer being too small. *memory_bytes contains the required number of - * bytes and will be bigger that the original value. - */ - -#define png_image_write_get_memory_size(image, size, convert_to_8_bit, buffer,\ - row_stride, colormap)\ - png_image_write_to_memory(&(image), 0, &(size), convert_to_8_bit, buffer,\ - row_stride, colormap) - /* Return the amount of memory in 'size' required to compress this image. - * The png_image structure 'image' must be filled in as in the above - * function and must not be changed before the actual write call, the buffer - * and all other parameters must also be identical to that in the final - * write call. The 'size' variable need not be initialized. - * - * NOTE: the macro returns true/false, if false is returned 'size' will be - * set to zero and the write failed and probably will fail if tried again. - */ - -/* You can pre-allocate the buffer by making sure it is of sufficient size - * regardless of the amount of compression achieved. The buffer size will - * always be bigger than the original image and it will never be filled. The - * following macros are provided to assist in allocating the buffer. - */ -#define PNG_IMAGE_DATA_SIZE(image) (PNG_IMAGE_SIZE(image)+(image).height) - /* The number of uncompressed bytes in the PNG byte encoding of the image; - * uncompressing the PNG IDAT data will give this number of bytes. - * - * NOTE: while PNG_IMAGE_SIZE cannot overflow for an image in memory this - * macro can because of the extra bytes used in the PNG byte encoding. You - * need to avoid this macro if your image size approaches 2^30 in width or - * height. The same goes for the remainder of these macros; they all produce - * bigger numbers than the actual in-memory image size. - */ -#ifndef PNG_ZLIB_MAX_SIZE -# define PNG_ZLIB_MAX_SIZE(b) ((b)+(((b)+7U)>>3)+(((b)+63U)>>6)+11U) - /* An upper bound on the number of compressed bytes given 'b' uncompressed - * bytes. This is based on deflateBounds() in zlib; different - * implementations of zlib compression may conceivably produce more data so - * if your zlib implementation is not zlib itself redefine this macro - * appropriately. - */ -#endif - -#define PNG_IMAGE_COMPRESSED_SIZE_MAX(image)\ - PNG_ZLIB_MAX_SIZE((png_alloc_size_t)PNG_IMAGE_DATA_SIZE(image)) - /* An upper bound on the size of the data in the PNG IDAT chunks. */ - -#define PNG_IMAGE_PNG_SIZE_MAX_(image, image_size)\ - ((8U/*sig*/+25U/*IHDR*/+16U/*gAMA*/+44U/*cHRM*/+12U/*IEND*/+\ - (((image).format&PNG_FORMAT_FLAG_COLORMAP)?/*colormap: PLTE, tRNS*/\ - 12U+3U*(image).colormap_entries/*PLTE data*/+\ - (((image).format&PNG_FORMAT_FLAG_ALPHA)?\ - 12U/*tRNS*/+(image).colormap_entries:0U):0U)+\ - 12U)+(12U*((image_size)/PNG_ZBUF_SIZE))/*IDAT*/+(image_size)) - /* A helper for the following macro; if your compiler cannot handle the - * following macro use this one with the result of - * PNG_IMAGE_COMPRESSED_SIZE_MAX(image) as the second argument (most - * compilers should handle this just fine.) - */ - -#define PNG_IMAGE_PNG_SIZE_MAX(image)\ - PNG_IMAGE_PNG_SIZE_MAX_(image, PNG_IMAGE_COMPRESSED_SIZE_MAX(image)) - /* An upper bound on the total length of the PNG data stream for 'image'. - * The result is of type png_alloc_size_t, on 32-bit systems this may - * overflow even though PNG_IMAGE_DATA_SIZE does not overflow; the write will - * run out of buffer space but return a corrected size which should work. - */ -#endif /* SIMPLIFIED_WRITE */ -/******************************************************************************* - * END OF SIMPLIFIED API - ******************************************************************************/ -#endif /* SIMPLIFIED_{READ|WRITE} */ - -/******************************************************************************* - * Section 6: IMPLEMENTATION OPTIONS - ******************************************************************************* - * - * Support for arbitrary implementation-specific optimizations. The API allows - * particular options to be turned on or off. 'Option' is the number of the - * option and 'onoff' is 0 (off) or non-0 (on). The value returned is given - * by the PNG_OPTION_ defines below. - * - * HARDWARE: normally hardware capabilities, such as the Intel SSE instructions, - * are detected at run time, however sometimes it may be impossible - * to do this in user mode, in which case it is necessary to discover - * the capabilities in an OS specific way. Such capabilities are - * listed here when libpng has support for them and must be turned - * ON by the application if present. - * - * SOFTWARE: sometimes software optimizations actually result in performance - * decrease on some architectures or systems, or with some sets of - * PNG images. 'Software' options allow such optimizations to be - * selected at run time. - */ -#ifdef PNG_SET_OPTION_SUPPORTED -#ifdef PNG_ARM_NEON_API_SUPPORTED -# define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */ -#endif -#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */ -#define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */ -#ifdef PNG_MIPS_MSA_API_SUPPORTED -# define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */ -#endif -#define PNG_IGNORE_ADLER32 8 -#ifdef PNG_POWERPC_VSX_API_SUPPORTED -# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions supported */ -#endif -#define PNG_OPTION_NEXT 12 /* Next option - numbers must be even */ - -/* Return values: NOTE: there are four values and 'off' is *not* zero */ -#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */ -#define PNG_OPTION_INVALID 1 /* Option number out of range */ -#define PNG_OPTION_OFF 2 -#define PNG_OPTION_ON 3 - -PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option, - int onoff)); -#endif /* SET_OPTION */ - -/******************************************************************************* - * END OF HARDWARE AND SOFTWARE OPTIONS - ******************************************************************************/ - -/* Maintainer: Put new public prototypes here ^, in libpng.3, in project - * defs, and in scripts/symbols.def. - */ - -/* The last ordinal number (this is the *last* one already used; the next - * one to use is one more than this.) - */ -#ifdef PNG_EXPORT_LAST_ORDINAL - PNG_EXPORT_LAST_ORDINAL(249); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* PNG_VERSION_INFO_ONLY */ -/* Do not put anything past this line */ -#endif /* PNG_H */ diff --git a/oversampling/WDL/libpng/pngconf.h b/oversampling/WDL/libpng/pngconf.h deleted file mode 100644 index 927a769..0000000 --- a/oversampling/WDL/libpng/pngconf.h +++ /dev/null @@ -1,623 +0,0 @@ - -/* pngconf.h - machine-configurable file for libpng - * - * libpng version 1.6.37 - * - * Copyright (c) 2018-2019 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * - * Any machine specific code is near the front of this file, so if you - * are configuring libpng for a machine, you may want to read the section - * starting here down to where it starts to typedef png_color, png_text, - * and png_info. - */ - -#ifndef PNGCONF_H -#define PNGCONF_H - -#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */ - -/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C - * compiler for correct compilation. The following header files are required by - * the standard. If your compiler doesn't provide these header files, or they - * do not match the standard, you will need to provide/improve them. - */ -#include -#include - -/* Library header files. These header files are all defined by ISOC90; libpng - * expects conformant implementations, however, an ISOC90 conformant system need - * not provide these header files if the functionality cannot be implemented. - * In this case it will be necessary to disable the relevant parts of libpng in - * the build of pnglibconf.h. - * - * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not - * include this unnecessary header file. - */ - -#ifdef PNG_STDIO_SUPPORTED - /* Required for the definition of FILE: */ -# include -#endif - -#ifdef PNG_SETJMP_SUPPORTED - /* Required for the definition of jmp_buf and the declaration of longjmp: */ -# include -#endif - -#ifdef PNG_CONVERT_tIME_SUPPORTED - /* Required for struct tm: */ -# include -#endif - -#endif /* PNG_BUILDING_SYMBOL_TABLE */ - -/* Prior to 1.6.0, it was possible to turn off 'const' in declarations, - * using PNG_NO_CONST. This is no longer supported. - */ -#define PNG_CONST const /* backward compatibility only */ - -/* This controls optimization of the reading of 16-bit and 32-bit - * values from PNG files. It can be set on a per-app-file basis: it - * just changes whether a macro is used when the function is called. - * The library builder sets the default; if read functions are not - * built into the library the macro implementation is forced on. - */ -#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED -# define PNG_USE_READ_MACROS -#endif -#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) -# if PNG_DEFAULT_READ_MACROS -# define PNG_USE_READ_MACROS -# endif -#endif - -/* COMPILER SPECIFIC OPTIONS. - * - * These options are provided so that a variety of difficult compilers - * can be used. Some are fixed at build time (e.g. PNG_API_RULE - * below) but still have compiler specific implementations, others - * may be changed on a per-file basis when compiling against libpng. - */ - -/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect - * against legacy (pre ISOC90) compilers that did not understand function - * prototypes. It is not required for modern C compilers. - */ -#ifndef PNGARG -# define PNGARG(arglist) arglist -#endif - -/* Function calling conventions. - * ============================= - * Normally it is not necessary to specify to the compiler how to call - * a function - it just does it - however on x86 systems derived from - * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems - * and some others) there are multiple ways to call a function and the - * default can be changed on the compiler command line. For this reason - * libpng specifies the calling convention of every exported function and - * every function called via a user supplied function pointer. This is - * done in this file by defining the following macros: - * - * PNGAPI Calling convention for exported functions. - * PNGCBAPI Calling convention for user provided (callback) functions. - * PNGCAPI Calling convention used by the ANSI-C library (required - * for longjmp callbacks and sometimes used internally to - * specify the calling convention for zlib). - * - * These macros should never be overridden. If it is necessary to - * change calling convention in a private build this can be done - * by setting PNG_API_RULE (which defaults to 0) to one of the values - * below to select the correct 'API' variants. - * - * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout. - * This is correct in every known environment. - * PNG_API_RULE=1 Use the operating system convention for PNGAPI and - * the 'C' calling convention (from PNGCAPI) for - * callbacks (PNGCBAPI). This is no longer required - * in any known environment - if it has to be used - * please post an explanation of the problem to the - * libpng mailing list. - * - * These cases only differ if the operating system does not use the C - * calling convention, at present this just means the above cases - * (x86 DOS/Windows systems) and, even then, this does not apply to - * Cygwin running on those systems. - * - * Note that the value must be defined in pnglibconf.h so that what - * the application uses to call the library matches the conventions - * set when building the library. - */ - -/* Symbol export - * ============= - * When building a shared library it is almost always necessary to tell - * the compiler which symbols to export. The png.h macro 'PNG_EXPORT' - * is used to mark the symbols. On some systems these symbols can be - * extracted at link time and need no special processing by the compiler, - * on other systems the symbols are flagged by the compiler and just - * the declaration requires a special tag applied (unfortunately) in a - * compiler dependent way. Some systems can do either. - * - * A small number of older systems also require a symbol from a DLL to - * be flagged to the program that calls it. This is a problem because - * we do not know in the header file included by application code that - * the symbol will come from a shared library, as opposed to a statically - * linked one. For this reason the application must tell us by setting - * the magic flag PNG_USE_DLL to turn on the special processing before - * it includes png.h. - * - * Four additional macros are used to make this happen: - * - * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from - * the build or imported if PNG_USE_DLL is set - compiler - * and system specific. - * - * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to - * 'type', compiler specific. - * - * PNG_DLL_EXPORT Set to the magic to use during a libpng build to - * make a symbol exported from the DLL. Not used in the - * public header files; see pngpriv.h for how it is used - * in the libpng build. - * - * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come - * from a DLL - used to define PNG_IMPEXP when - * PNG_USE_DLL is set. - */ - -/* System specific discovery. - * ========================== - * This code is used at build time to find PNG_IMPEXP, the API settings - * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL - * import processing is possible. On Windows systems it also sets - * compiler-specific macros to the values required to change the calling - * conventions of the various functions. - */ -#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ - defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) - /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or - * MinGW on any architecture currently supported by Windows. Also includes - * Watcom builds but these need special treatment because they are not - * compatible with GCC or Visual C because of different calling conventions. - */ -# if PNG_API_RULE == 2 - /* If this line results in an error, either because __watcall is not - * understood or because of a redefine just below you cannot use *this* - * build of the library with the compiler you are using. *This* build was - * build using Watcom and applications must also be built using Watcom! - */ -# define PNGCAPI __watcall -# endif - -# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800)) -# define PNGCAPI __cdecl -# if PNG_API_RULE == 1 - /* If this line results in an error __stdcall is not understood and - * PNG_API_RULE should not have been set to '1'. - */ -# define PNGAPI __stdcall -# endif -# else - /* An older compiler, or one not detected (erroneously) above, - * if necessary override on the command line to get the correct - * variants for the compiler. - */ -# ifndef PNGCAPI -# define PNGCAPI _cdecl -# endif -# if PNG_API_RULE == 1 && !defined(PNGAPI) -# define PNGAPI _stdcall -# endif -# endif /* compiler/api */ - - /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ - -# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) -# error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed" -# endif - -# if (defined(_MSC_VER) && _MSC_VER < 800) ||\ - (defined(__BORLANDC__) && __BORLANDC__ < 0x500) - /* older Borland and MSC - * compilers used '__export' and required this to be after - * the type. - */ -# ifndef PNG_EXPORT_TYPE -# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP -# endif -# define PNG_DLL_EXPORT __export -# else /* newer compiler */ -# define PNG_DLL_EXPORT __declspec(dllexport) -# ifndef PNG_DLL_IMPORT -# define PNG_DLL_IMPORT __declspec(dllimport) -# endif -# endif /* compiler */ - -#else /* !Windows */ -# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) -# define PNGAPI _System -# else /* !Windows/x86 && !OS/2 */ - /* Use the defaults, or define PNG*API on the command line (but - * this will have to be done for every compile!) - */ -# endif /* other system, !OS/2 */ -#endif /* !Windows/x86 */ - -/* Now do all the defaulting . */ -#ifndef PNGCAPI -# define PNGCAPI -#endif -#ifndef PNGCBAPI -# define PNGCBAPI PNGCAPI -#endif -#ifndef PNGAPI -# define PNGAPI PNGCAPI -#endif - -/* PNG_IMPEXP may be set on the compilation system command line or (if not set) - * then in an internal header file when building the library, otherwise (when - * using the library) it is set here. - */ -#ifndef PNG_IMPEXP -# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) - /* This forces use of a DLL, disallowing static linking */ -# define PNG_IMPEXP PNG_DLL_IMPORT -# endif - -# ifndef PNG_IMPEXP -# define PNG_IMPEXP -# endif -#endif - -/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat - * 'attributes' as a storage class - the attributes go at the start of the - * function definition, and attributes are always appended regardless of the - * compiler. This considerably simplifies these macros but may cause problems - * if any compilers both need function attributes and fail to handle them as - * a storage class (this is unlikely.) - */ -#ifndef PNG_FUNCTION -# define PNG_FUNCTION(type, name, args, attributes) attributes type name args -#endif - -#ifndef PNG_EXPORT_TYPE -# define PNG_EXPORT_TYPE(type) PNG_IMPEXP type -#endif - - /* The ordinal value is only relevant when preprocessing png.h for symbol - * table entries, so we discard it here. See the .dfn files in the - * scripts directory. - */ - -#ifndef PNG_EXPORTA -# define PNG_EXPORTA(ordinal, type, name, args, attributes) \ - PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \ - PNG_LINKAGE_API attributes) -#endif - -/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument, - * so make something non-empty to satisfy the requirement: - */ -#define PNG_EMPTY /*empty list*/ - -#define PNG_EXPORT(ordinal, type, name, args) \ - PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY) - -/* Use PNG_REMOVED to comment out a removed interface. */ -#ifndef PNG_REMOVED -# define PNG_REMOVED(ordinal, type, name, args, attributes) -#endif - -#ifndef PNG_CALLBACK -# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args) -#endif - -/* Support for compiler specific function attributes. These are used - * so that where compiler support is available incorrect use of API - * functions in png.h will generate compiler warnings. - * - * Added at libpng-1.2.41. - */ - -#ifndef PNG_NO_PEDANTIC_WARNINGS -# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED -# define PNG_PEDANTIC_WARNINGS_SUPPORTED -# endif -#endif - -#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED - /* Support for compiler specific function attributes. These are used - * so that where compiler support is available, incorrect use of API - * functions in png.h will generate compiler warnings. Added at libpng - * version 1.2.41. Disabling these removes the warnings but may also produce - * less efficient code. - */ -# if defined(__clang__) && defined(__has_attribute) - /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */ -# if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__) -# define PNG_USE_RESULT __attribute__((__warn_unused_result__)) -# endif -# if !defined(PNG_NORETURN) && __has_attribute(__noreturn__) -# define PNG_NORETURN __attribute__((__noreturn__)) -# endif -# if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__) -# define PNG_ALLOCATED __attribute__((__malloc__)) -# endif -# if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__) -# define PNG_DEPRECATED __attribute__((__deprecated__)) -# endif -# if !defined(PNG_PRIVATE) -# ifdef __has_extension -# if __has_extension(attribute_unavailable_with_message) -# define PNG_PRIVATE __attribute__((__unavailable__(\ - "This function is not exported by libpng."))) -# endif -# endif -# endif -# ifndef PNG_RESTRICT -# define PNG_RESTRICT __restrict -# endif - -# elif defined(__GNUC__) -# ifndef PNG_USE_RESULT -# define PNG_USE_RESULT __attribute__((__warn_unused_result__)) -# endif -# ifndef PNG_NORETURN -# define PNG_NORETURN __attribute__((__noreturn__)) -# endif -# if __GNUC__ >= 3 -# ifndef PNG_ALLOCATED -# define PNG_ALLOCATED __attribute__((__malloc__)) -# endif -# ifndef PNG_DEPRECATED -# define PNG_DEPRECATED __attribute__((__deprecated__)) -# endif -# ifndef PNG_PRIVATE -# if 0 /* Doesn't work so we use deprecated instead*/ -# define PNG_PRIVATE \ - __attribute__((warning("This function is not exported by libpng."))) -# else -# define PNG_PRIVATE \ - __attribute__((__deprecated__)) -# endif -# endif -# if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1)) -# ifndef PNG_RESTRICT -# define PNG_RESTRICT __restrict -# endif -# endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */ -# endif /* __GNUC__ >= 3 */ - -# elif defined(_MSC_VER) && (_MSC_VER >= 1300) -# ifndef PNG_USE_RESULT -# define PNG_USE_RESULT /* not supported */ -# endif -# ifndef PNG_NORETURN -# define PNG_NORETURN __declspec(noreturn) -# endif -# ifndef PNG_ALLOCATED -# if (_MSC_VER >= 1400) -# define PNG_ALLOCATED __declspec(restrict) -# endif -# endif -# ifndef PNG_DEPRECATED -# define PNG_DEPRECATED __declspec(deprecated) -# endif -# ifndef PNG_PRIVATE -# define PNG_PRIVATE __declspec(deprecated) -# endif -# ifndef PNG_RESTRICT -# if (_MSC_VER >= 1400) -# define PNG_RESTRICT __restrict -# endif -# endif - -# elif defined(__WATCOMC__) -# ifndef PNG_RESTRICT -# define PNG_RESTRICT __restrict -# endif -# endif -#endif /* PNG_PEDANTIC_WARNINGS */ - -#ifndef PNG_DEPRECATED -# define PNG_DEPRECATED /* Use of this function is deprecated */ -#endif -#ifndef PNG_USE_RESULT -# define PNG_USE_RESULT /* The result of this function must be checked */ -#endif -#ifndef PNG_NORETURN -# define PNG_NORETURN /* This function does not return */ -#endif -#ifndef PNG_ALLOCATED -# define PNG_ALLOCATED /* The result of the function is new memory */ -#endif -#ifndef PNG_PRIVATE -# define PNG_PRIVATE /* This is a private libpng function */ -#endif -#ifndef PNG_RESTRICT -# define PNG_RESTRICT /* The C99 "restrict" feature */ -#endif - -#ifndef PNG_FP_EXPORT /* A floating point API. */ -# ifdef PNG_FLOATING_POINT_SUPPORTED -# define PNG_FP_EXPORT(ordinal, type, name, args)\ - PNG_EXPORT(ordinal, type, name, args); -# else /* No floating point APIs */ -# define PNG_FP_EXPORT(ordinal, type, name, args) -# endif -#endif -#ifndef PNG_FIXED_EXPORT /* A fixed point API. */ -# ifdef PNG_FIXED_POINT_SUPPORTED -# define PNG_FIXED_EXPORT(ordinal, type, name, args)\ - PNG_EXPORT(ordinal, type, name, args); -# else /* No fixed point APIs */ -# define PNG_FIXED_EXPORT(ordinal, type, name, args) -# endif -#endif - -#ifndef PNG_BUILDING_SYMBOL_TABLE -/* Some typedefs to get us started. These should be safe on most of the common - * platforms. - * - * png_uint_32 and png_int_32 may, currently, be larger than required to hold a - * 32-bit value however this is not normally advisable. - * - * png_uint_16 and png_int_16 should always be two bytes in size - this is - * verified at library build time. - * - * png_byte must always be one byte in size. - * - * The checks below use constants from limits.h, as defined by the ISOC90 - * standard. - */ -#if CHAR_BIT == 8 && UCHAR_MAX == 255 - typedef unsigned char png_byte; -#else -# error "libpng requires 8-bit bytes" -#endif - -#if INT_MIN == -32768 && INT_MAX == 32767 - typedef int png_int_16; -#elif SHRT_MIN == -32768 && SHRT_MAX == 32767 - typedef short png_int_16; -#else -# error "libpng requires a signed 16-bit type" -#endif - -#if UINT_MAX == 65535 - typedef unsigned int png_uint_16; -#elif USHRT_MAX == 65535 - typedef unsigned short png_uint_16; -#else -# error "libpng requires an unsigned 16-bit type" -#endif - -#if INT_MIN < -2147483646 && INT_MAX > 2147483646 - typedef int png_int_32; -#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646 - typedef long int png_int_32; -#else -# error "libpng requires a signed 32-bit (or more) type" -#endif - -#if UINT_MAX > 4294967294U - typedef unsigned int png_uint_32; -#elif ULONG_MAX > 4294967294U - typedef unsigned long int png_uint_32; -#else -# error "libpng requires an unsigned 32-bit (or more) type" -#endif - -/* Prior to 1.6.0, it was possible to disable the use of size_t and ptrdiff_t. - * From 1.6.0 onwards, an ISO C90 compiler, as well as a standard-compliant - * behavior of sizeof and ptrdiff_t are required. - * The legacy typedefs are provided here for backwards compatibility. - */ -typedef size_t png_size_t; -typedef ptrdiff_t png_ptrdiff_t; - -/* libpng needs to know the maximum value of 'size_t' and this controls the - * definition of png_alloc_size_t, below. This maximum value of size_t limits - * but does not control the maximum allocations the library makes - there is - * direct application control of this through png_set_user_limits(). - */ -#ifndef PNG_SMALL_SIZE_T - /* Compiler specific tests for systems where size_t is known to be less than - * 32 bits (some of these systems may no longer work because of the lack of - * 'far' support; see above.) - */ -# if (defined(__TURBOC__) && !defined(__FLAT__)) ||\ - (defined(_MSC_VER) && defined(MAXSEG_64K)) -# define PNG_SMALL_SIZE_T -# endif -#endif - -/* png_alloc_size_t is guaranteed to be no smaller than size_t, and no smaller - * than png_uint_32. Casts from size_t or png_uint_32 to png_alloc_size_t are - * not necessary; in fact, it is recommended not to use them at all, so that - * the compiler can complain when something turns out to be problematic. - * - * Casts in the other direction (from png_alloc_size_t to size_t or - * png_uint_32) should be explicitly applied; however, we do not expect to - * encounter practical situations that require such conversions. - * - * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than - * 4294967295 - i.e. less than the maximum value of png_uint_32. - */ -#ifdef PNG_SMALL_SIZE_T - typedef png_uint_32 png_alloc_size_t; -#else - typedef size_t png_alloc_size_t; -#endif - -/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler - * implementations of Intel CPU specific support of user-mode segmented address - * spaces, where 16-bit pointers address more than 65536 bytes of memory using - * separate 'segment' registers. The implementation requires two different - * types of pointer (only one of which includes the segment value.) - * - * If required this support is available in version 1.2 of libpng and may be - * available in versions through 1.5, although the correctness of the code has - * not been verified recently. - */ - -/* Typedef for floating-point numbers that are converted to fixed-point with a - * multiple of 100,000, e.g., gamma - */ -typedef png_int_32 png_fixed_point; - -/* Add typedefs for pointers */ -typedef void * png_voidp; -typedef const void * png_const_voidp; -typedef png_byte * png_bytep; -typedef const png_byte * png_const_bytep; -typedef png_uint_32 * png_uint_32p; -typedef const png_uint_32 * png_const_uint_32p; -typedef png_int_32 * png_int_32p; -typedef const png_int_32 * png_const_int_32p; -typedef png_uint_16 * png_uint_16p; -typedef const png_uint_16 * png_const_uint_16p; -typedef png_int_16 * png_int_16p; -typedef const png_int_16 * png_const_int_16p; -typedef char * png_charp; -typedef const char * png_const_charp; -typedef png_fixed_point * png_fixed_point_p; -typedef const png_fixed_point * png_const_fixed_point_p; -typedef size_t * png_size_tp; -typedef const size_t * png_const_size_tp; - -#ifdef PNG_STDIO_SUPPORTED -typedef FILE * png_FILE_p; -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double * png_doublep; -typedef const double * png_const_doublep; -#endif - -/* Pointers to pointers; i.e. arrays */ -typedef png_byte * * png_bytepp; -typedef png_uint_32 * * png_uint_32pp; -typedef png_int_32 * * png_int_32pp; -typedef png_uint_16 * * png_uint_16pp; -typedef png_int_16 * * png_int_16pp; -typedef const char * * png_const_charpp; -typedef char * * png_charpp; -typedef png_fixed_point * * png_fixed_point_pp; -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double * * png_doublepp; -#endif - -/* Pointers to pointers to pointers; i.e., pointer to array */ -typedef char * * * png_charppp; - -#endif /* PNG_BUILDING_SYMBOL_TABLE */ - -#endif /* PNGCONF_H */ diff --git a/oversampling/WDL/libpng/pngdebug.h b/oversampling/WDL/libpng/pngdebug.h deleted file mode 100644 index 00d5a45..0000000 --- a/oversampling/WDL/libpng/pngdebug.h +++ /dev/null @@ -1,153 +0,0 @@ - -/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c - * - * Copyright (c) 2018 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - */ - -/* Define PNG_DEBUG at compile time for debugging information. Higher - * numbers for PNG_DEBUG mean more debugging information. This has - * only been added since version 0.95 so it is not implemented throughout - * libpng yet, but more support will be added as needed. - * - * png_debug[1-2]?(level, message ,arg{0-2}) - * Expands to a statement (either a simple expression or a compound - * do..while(0) statement) that outputs a message with parameter - * substitution if PNG_DEBUG is defined to 2 or more. If PNG_DEBUG - * is undefined, 0 or 1 every png_debug expands to a simple expression - * (actually ((void)0)). - * - * level: level of detail of message, starting at 0. A level 'n' - * message is preceded by 'n' 3-space indentations (not implemented - * on Microsoft compilers unless PNG_DEBUG_FILE is also - * defined, to allow debug DLL compilation with no standard IO). - * message: a printf(3) style text string. A trailing '\n' is added - * to the message. - * arg: 0 to 2 arguments for printf(3) style substitution in message. - */ -#ifndef PNGDEBUG_H -#define PNGDEBUG_H -/* These settings control the formatting of messages in png.c and pngerror.c */ -/* Moved to pngdebug.h at 1.5.0 */ -# ifndef PNG_LITERAL_SHARP -# define PNG_LITERAL_SHARP 0x23 -# endif -# ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET -# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b -# endif -# ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET -# define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d -# endif -# ifndef PNG_STRING_NEWLINE -# define PNG_STRING_NEWLINE "\n" -# endif - -#ifdef PNG_DEBUG -# if (PNG_DEBUG > 0) -# if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) -# include -# if (PNG_DEBUG > 1) -# ifndef _DEBUG -# define _DEBUG -# endif -# ifndef png_debug -# define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE) -# endif -# ifndef png_debug1 -# define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1) -# endif -# ifndef png_debug2 -# define png_debug2(l,m,p1,p2) \ - _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2) -# endif -# endif -# else /* PNG_DEBUG_FILE || !_MSC_VER */ -# ifndef PNG_STDIO_SUPPORTED -# include /* not included yet */ -# endif -# ifndef PNG_DEBUG_FILE -# define PNG_DEBUG_FILE stderr -# endif /* PNG_DEBUG_FILE */ - -# if (PNG_DEBUG > 1) -# ifdef __STDC__ -# ifndef png_debug -# define png_debug(l,m) \ - do { \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \ - (num_tabs==2 ? " " : (num_tabs>2 ? " " : "")))); \ - } while (0) -# endif -# ifndef png_debug1 -# define png_debug1(l,m,p1) \ - do { \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \ - (num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1); \ - } while (0) -# endif -# ifndef png_debug2 -# define png_debug2(l,m,p1,p2) \ - do { \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \ - (num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1,p2);\ - } while (0) -# endif -# else /* __STDC __ */ -# ifndef png_debug -# define png_debug(l,m) \ - do { \ - int num_tabs=l; \ - char format[256]; \ - snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ - m,PNG_STRING_NEWLINE); \ - fprintf(PNG_DEBUG_FILE,format); \ - } while (0) -# endif -# ifndef png_debug1 -# define png_debug1(l,m,p1) \ - do { \ - int num_tabs=l; \ - char format[256]; \ - snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ - m,PNG_STRING_NEWLINE); \ - fprintf(PNG_DEBUG_FILE,format,p1); \ - } while (0) -# endif -# ifndef png_debug2 -# define png_debug2(l,m,p1,p2) \ - do { \ - int num_tabs=l; \ - char format[256]; \ - snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ - m,PNG_STRING_NEWLINE); \ - fprintf(PNG_DEBUG_FILE,format,p1,p2); \ - } while (0) -# endif -# endif /* __STDC __ */ -# endif /* (PNG_DEBUG > 1) */ - -# endif /* _MSC_VER */ -# endif /* (PNG_DEBUG > 0) */ -#endif /* PNG_DEBUG */ -#ifndef png_debug -# define png_debug(l, m) ((void)0) -#endif -#ifndef png_debug1 -# define png_debug1(l, m, p1) ((void)0) -#endif -#ifndef png_debug2 -# define png_debug2(l, m, p1, p2) ((void)0) -#endif -#endif /* PNGDEBUG_H */ diff --git a/oversampling/WDL/libpng/pngerror.c b/oversampling/WDL/libpng/pngerror.c deleted file mode 100644 index ec3a709..0000000 --- a/oversampling/WDL/libpng/pngerror.c +++ /dev/null @@ -1,963 +0,0 @@ - -/* pngerror.c - stub functions for i/o and memory allocation - * - * Copyright (c) 2018 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * - * This file provides a location for all error handling. Users who - * need special error handling are expected to write replacement functions - * and use png_set_error_fn() to use those functions. See the instructions - * at each function. - */ - -#include "pngpriv.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) - -static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr, - png_const_charp error_message)),PNG_NORETURN); - -#ifdef PNG_WARNINGS_SUPPORTED -static void /* PRIVATE */ -png_default_warning PNGARG((png_const_structrp png_ptr, - png_const_charp warning_message)); -#endif /* WARNINGS */ - -/* This function is called whenever there is a fatal error. This function - * should not be changed. If there is a need to handle errors differently, - * you should supply a replacement error function and use png_set_error_fn() - * to replace the error function at run-time. - */ -#ifdef PNG_ERROR_TEXT_SUPPORTED -PNG_FUNCTION(void,PNGAPI -png_error,(png_const_structrp png_ptr, png_const_charp error_message), - PNG_NORETURN) -{ -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - char msg[16]; - if (png_ptr != NULL) - { - if ((png_ptr->flags & - (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0) - { - if (*error_message == PNG_LITERAL_SHARP) - { - /* Strip "#nnnn " from beginning of error message. */ - int offset; - for (offset = 1; offset<15; offset++) - if (error_message[offset] == ' ') - break; - - if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0) - { - int i; - for (i = 0; i < offset - 1; i++) - msg[i] = error_message[i + 1]; - msg[i - 1] = '\0'; - error_message = msg; - } - - else - error_message += offset; - } - - else - { - if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0) - { - msg[0] = '0'; - msg[1] = '\0'; - error_message = msg; - } - } - } - } -#endif - if (png_ptr != NULL && png_ptr->error_fn != NULL) - (*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), - error_message); - - /* If the custom handler doesn't exist, or if it returns, - use the default handler, which will not return. */ - png_default_error(png_ptr, error_message); -} -#else -PNG_FUNCTION(void,PNGAPI -png_err,(png_const_structrp png_ptr),PNG_NORETURN) -{ - /* Prior to 1.5.2 the error_fn received a NULL pointer, expressed - * erroneously as '\0', instead of the empty string "". This was - * apparently an error, introduced in libpng-1.2.20, and png_default_error - * will crash in this case. - */ - if (png_ptr != NULL && png_ptr->error_fn != NULL) - (*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr), ""); - - /* If the custom handler doesn't exist, or if it returns, - use the default handler, which will not return. */ - png_default_error(png_ptr, ""); -} -#endif /* ERROR_TEXT */ - -/* Utility to safely appends strings to a buffer. This never errors out so - * error checking is not required in the caller. - */ -size_t -png_safecat(png_charp buffer, size_t bufsize, size_t pos, - png_const_charp string) -{ - if (buffer != NULL && pos < bufsize) - { - if (string != NULL) - while (*string != '\0' && pos < bufsize-1) - buffer[pos++] = *string++; - - buffer[pos] = '\0'; - } - - return pos; -} - -#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED) -/* Utility to dump an unsigned value into a buffer, given a start pointer and - * and end pointer (which should point just *beyond* the end of the buffer!) - * Returns the pointer to the start of the formatted string. - */ -png_charp -png_format_number(png_const_charp start, png_charp end, int format, - png_alloc_size_t number) -{ - int count = 0; /* number of digits output */ - int mincount = 1; /* minimum number required */ - int output = 0; /* digit output (for the fixed point format) */ - - *--end = '\0'; - - /* This is written so that the loop always runs at least once, even with - * number zero. - */ - while (end > start && (number != 0 || count < mincount)) - { - - static const char digits[] = "0123456789ABCDEF"; - - switch (format) - { - case PNG_NUMBER_FORMAT_fixed: - /* Needs five digits (the fraction) */ - mincount = 5; - if (output != 0 || number % 10 != 0) - { - *--end = digits[number % 10]; - output = 1; - } - number /= 10; - break; - - case PNG_NUMBER_FORMAT_02u: - /* Expects at least 2 digits. */ - mincount = 2; - /* FALLTHROUGH */ - - case PNG_NUMBER_FORMAT_u: - *--end = digits[number % 10]; - number /= 10; - break; - - case PNG_NUMBER_FORMAT_02x: - /* This format expects at least two digits */ - mincount = 2; - /* FALLTHROUGH */ - - case PNG_NUMBER_FORMAT_x: - *--end = digits[number & 0xf]; - number >>= 4; - break; - - default: /* an error */ - number = 0; - break; - } - - /* Keep track of the number of digits added */ - ++count; - - /* Float a fixed number here: */ - if ((format == PNG_NUMBER_FORMAT_fixed) && (count == 5) && (end > start)) - { - /* End of the fraction, but maybe nothing was output? In that case - * drop the decimal point. If the number is a true zero handle that - * here. - */ - if (output != 0) - *--end = '.'; - else if (number == 0) /* and !output */ - *--end = '0'; - } - } - - return end; -} -#endif - -#ifdef PNG_WARNINGS_SUPPORTED -/* This function is called whenever there is a non-fatal error. This function - * should not be changed. If there is a need to handle warnings differently, - * you should supply a replacement warning function and use - * png_set_error_fn() to replace the warning function at run-time. - */ -void PNGAPI -png_warning(png_const_structrp png_ptr, png_const_charp warning_message) -{ - int offset = 0; - if (png_ptr != NULL) - { -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - if ((png_ptr->flags & - (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0) -#endif - { - if (*warning_message == PNG_LITERAL_SHARP) - { - for (offset = 1; offset < 15; offset++) - if (warning_message[offset] == ' ') - break; - } - } - } - if (png_ptr != NULL && png_ptr->warning_fn != NULL) - (*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr), - warning_message + offset); - else - png_default_warning(png_ptr, warning_message + offset); -} - -/* These functions support 'formatted' warning messages with up to - * PNG_WARNING_PARAMETER_COUNT parameters. In the format string the parameter - * is introduced by @, where 'number' starts at 1. This follows the - * standard established by X/Open for internationalizable error messages. - */ -void -png_warning_parameter(png_warning_parameters p, int number, - png_const_charp string) -{ - if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT) - (void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string); -} - -void -png_warning_parameter_unsigned(png_warning_parameters p, int number, int format, - png_alloc_size_t value) -{ - char buffer[PNG_NUMBER_BUFFER_SIZE]; - png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value)); -} - -void -png_warning_parameter_signed(png_warning_parameters p, int number, int format, - png_int_32 value) -{ - png_alloc_size_t u; - png_charp str; - char buffer[PNG_NUMBER_BUFFER_SIZE]; - - /* Avoid overflow by doing the negate in a png_alloc_size_t: */ - u = (png_alloc_size_t)value; - if (value < 0) - u = ~u + 1; - - str = PNG_FORMAT_NUMBER(buffer, format, u); - - if (value < 0 && str > buffer) - *--str = '-'; - - png_warning_parameter(p, number, str); -} - -void -png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p, - png_const_charp message) -{ - /* The internal buffer is just 192 bytes - enough for all our messages, - * overflow doesn't happen because this code checks! If someone figures - * out how to send us a message longer than 192 bytes, all that will - * happen is that the message will be truncated appropriately. - */ - size_t i = 0; /* Index in the msg[] buffer: */ - char msg[192]; - - /* Each iteration through the following loop writes at most one character - * to msg[i++] then returns here to validate that there is still space for - * the trailing '\0'. It may (in the case of a parameter) read more than - * one character from message[]; it must check for '\0' and continue to the - * test if it finds the end of string. - */ - while (i<(sizeof msg)-1 && *message != '\0') - { - /* '@' at end of string is now just printed (previously it was skipped); - * it is an error in the calling code to terminate the string with @. - */ - if (p != NULL && *message == '@' && message[1] != '\0') - { - int parameter_char = *++message; /* Consume the '@' */ - static const char valid_parameters[] = "123456789"; - int parameter = 0; - - /* Search for the parameter digit, the index in the string is the - * parameter to use. - */ - while (valid_parameters[parameter] != parameter_char && - valid_parameters[parameter] != '\0') - ++parameter; - - /* If the parameter digit is out of range it will just get printed. */ - if (parameter < PNG_WARNING_PARAMETER_COUNT) - { - /* Append this parameter */ - png_const_charp parm = p[parameter]; - png_const_charp pend = p[parameter] + (sizeof p[parameter]); - - /* No need to copy the trailing '\0' here, but there is no guarantee - * that parm[] has been initialized, so there is no guarantee of a - * trailing '\0': - */ - while (i<(sizeof msg)-1 && *parm != '\0' && parm < pend) - msg[i++] = *parm++; - - /* Consume the parameter digit too: */ - ++message; - continue; - } - - /* else not a parameter and there is a character after the @ sign; just - * copy that. This is known not to be '\0' because of the test above. - */ - } - - /* At this point *message can't be '\0', even in the bad parameter case - * above where there is a lone '@' at the end of the message string. - */ - msg[i++] = *message++; - } - - /* i is always less than (sizeof msg), so: */ - msg[i] = '\0'; - - /* And this is the formatted message. It may be larger than - * PNG_MAX_ERROR_TEXT, but that is only used for 'chunk' errors and these - * are not (currently) formatted. - */ - png_warning(png_ptr, msg); -} -#endif /* WARNINGS */ - -#ifdef PNG_BENIGN_ERRORS_SUPPORTED -void PNGAPI -png_benign_error(png_const_structrp png_ptr, png_const_charp error_message) -{ - if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0) - { -# ifdef PNG_READ_SUPPORTED - if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 && - png_ptr->chunk_name != 0) - png_chunk_warning(png_ptr, error_message); - else -# endif - png_warning(png_ptr, error_message); - } - - else - { -# ifdef PNG_READ_SUPPORTED - if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 && - png_ptr->chunk_name != 0) - png_chunk_error(png_ptr, error_message); - else -# endif - png_error(png_ptr, error_message); - } - -# ifndef PNG_ERROR_TEXT_SUPPORTED - PNG_UNUSED(error_message) -# endif -} - -void /* PRIVATE */ -png_app_warning(png_const_structrp png_ptr, png_const_charp error_message) -{ - if ((png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) != 0) - png_warning(png_ptr, error_message); - else - png_error(png_ptr, error_message); - -# ifndef PNG_ERROR_TEXT_SUPPORTED - PNG_UNUSED(error_message) -# endif -} - -void /* PRIVATE */ -png_app_error(png_const_structrp png_ptr, png_const_charp error_message) -{ - if ((png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) != 0) - png_warning(png_ptr, error_message); - else - png_error(png_ptr, error_message); - -# ifndef PNG_ERROR_TEXT_SUPPORTED - PNG_UNUSED(error_message) -# endif -} -#endif /* BENIGN_ERRORS */ - -#define PNG_MAX_ERROR_TEXT 196 /* Currently limited by profile_error in png.c */ -#if defined(PNG_WARNINGS_SUPPORTED) || \ - (defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)) -/* These utilities are used internally to build an error message that relates - * to the current chunk. The chunk name comes from png_ptr->chunk_name, - * which is used to prefix the message. The message is limited in length - * to 63 bytes. The name characters are output as hex digits wrapped in [] - * if the character is invalid. - */ -#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) -static const char png_digit[16] = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'A', 'B', 'C', 'D', 'E', 'F' -}; - -static void /* PRIVATE */ -png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp - error_message) -{ - png_uint_32 chunk_name = png_ptr->chunk_name; - int iout = 0, ishift = 24; - - while (ishift >= 0) - { - int c = (int)(chunk_name >> ishift) & 0xff; - - ishift -= 8; - if (isnonalpha(c) != 0) - { - buffer[iout++] = PNG_LITERAL_LEFT_SQUARE_BRACKET; - buffer[iout++] = png_digit[(c & 0xf0) >> 4]; - buffer[iout++] = png_digit[c & 0x0f]; - buffer[iout++] = PNG_LITERAL_RIGHT_SQUARE_BRACKET; - } - - else - { - buffer[iout++] = (char)c; - } - } - - if (error_message == NULL) - buffer[iout] = '\0'; - - else - { - int iin = 0; - - buffer[iout++] = ':'; - buffer[iout++] = ' '; - - while (iin < PNG_MAX_ERROR_TEXT-1 && error_message[iin] != '\0') - buffer[iout++] = error_message[iin++]; - - /* iin < PNG_MAX_ERROR_TEXT, so the following is safe: */ - buffer[iout] = '\0'; - } -} -#endif /* WARNINGS || ERROR_TEXT */ - -#if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED) -PNG_FUNCTION(void,PNGAPI -png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message), - PNG_NORETURN) -{ - char msg[18+PNG_MAX_ERROR_TEXT]; - if (png_ptr == NULL) - png_error(png_ptr, error_message); - - else - { - png_format_buffer(png_ptr, msg, error_message); - png_error(png_ptr, msg); - } -} -#endif /* READ && ERROR_TEXT */ - -#ifdef PNG_WARNINGS_SUPPORTED -void PNGAPI -png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message) -{ - char msg[18+PNG_MAX_ERROR_TEXT]; - if (png_ptr == NULL) - png_warning(png_ptr, warning_message); - - else - { - png_format_buffer(png_ptr, msg, warning_message); - png_warning(png_ptr, msg); - } -} -#endif /* WARNINGS */ - -#ifdef PNG_READ_SUPPORTED -#ifdef PNG_BENIGN_ERRORS_SUPPORTED -void PNGAPI -png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp - error_message) -{ - if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0) - png_chunk_warning(png_ptr, error_message); - - else - png_chunk_error(png_ptr, error_message); - -# ifndef PNG_ERROR_TEXT_SUPPORTED - PNG_UNUSED(error_message) -# endif -} -#endif -#endif /* READ */ - -void /* PRIVATE */ -png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error) -{ -# ifndef PNG_WARNINGS_SUPPORTED - PNG_UNUSED(message) -# endif - - /* This is always supported, but for just read or just write it - * unconditionally does the right thing. - */ -# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED) - if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) -# endif - -# ifdef PNG_READ_SUPPORTED - { - if (error < PNG_CHUNK_ERROR) - png_chunk_warning(png_ptr, message); - - else - png_chunk_benign_error(png_ptr, message); - } -# endif - -# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED) - else if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0) -# endif - -# ifdef PNG_WRITE_SUPPORTED - { - if (error < PNG_CHUNK_WRITE_ERROR) - png_app_warning(png_ptr, message); - - else - png_app_error(png_ptr, message); - } -# endif -} - -#ifdef PNG_ERROR_TEXT_SUPPORTED -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_FUNCTION(void, -png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN) -{ -# define fixed_message "fixed point overflow in " -# define fixed_message_ln ((sizeof fixed_message)-1) - unsigned int iin; - char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT]; - memcpy(msg, fixed_message, fixed_message_ln); - iin = 0; - if (name != NULL) - while (iin < (PNG_MAX_ERROR_TEXT-1) && name[iin] != 0) - { - msg[fixed_message_ln + iin] = name[iin]; - ++iin; - } - msg[fixed_message_ln + iin] = 0; - png_error(png_ptr, msg); -} -#endif -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* This API only exists if ANSI-C style error handling is used, - * otherwise it is necessary for png_default_error to be overridden. - */ -jmp_buf* PNGAPI -png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn, - size_t jmp_buf_size) -{ - /* From libpng 1.6.0 the app gets one chance to set a 'jmpbuf_size' value - * and it must not change after that. Libpng doesn't care how big the - * buffer is, just that it doesn't change. - * - * If the buffer size is no *larger* than the size of jmp_buf when libpng is - * compiled a built in jmp_buf is returned; this preserves the pre-1.6.0 - * semantics that this call will not fail. If the size is larger, however, - * the buffer is allocated and this may fail, causing the function to return - * NULL. - */ - if (png_ptr == NULL) - return NULL; - - if (png_ptr->jmp_buf_ptr == NULL) - { - png_ptr->jmp_buf_size = 0; /* not allocated */ - - if (jmp_buf_size <= (sizeof png_ptr->jmp_buf_local)) - png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; - - else - { - png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *, - png_malloc_warn(png_ptr, jmp_buf_size)); - - if (png_ptr->jmp_buf_ptr == NULL) - return NULL; /* new NULL return on OOM */ - - png_ptr->jmp_buf_size = jmp_buf_size; - } - } - - else /* Already allocated: check the size */ - { - size_t size = png_ptr->jmp_buf_size; - - if (size == 0) - { - size = (sizeof png_ptr->jmp_buf_local); - if (png_ptr->jmp_buf_ptr != &png_ptr->jmp_buf_local) - { - /* This is an internal error in libpng: somehow we have been left - * with a stack allocated jmp_buf when the application regained - * control. It's always possible to fix this up, but for the moment - * this is a png_error because that makes it easy to detect. - */ - png_error(png_ptr, "Libpng jmp_buf still allocated"); - /* png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local; */ - } - } - - if (size != jmp_buf_size) - { - png_warning(png_ptr, "Application jmp_buf size changed"); - return NULL; /* caller will probably crash: no choice here */ - } - } - - /* Finally fill in the function, now we have a satisfactory buffer. It is - * valid to change the function on every call. - */ - png_ptr->longjmp_fn = longjmp_fn; - return png_ptr->jmp_buf_ptr; -} - -void /* PRIVATE */ -png_free_jmpbuf(png_structrp png_ptr) -{ - if (png_ptr != NULL) - { - jmp_buf *jb = png_ptr->jmp_buf_ptr; - - /* A size of 0 is used to indicate a local, stack, allocation of the - * pointer; used here and in png.c - */ - if (jb != NULL && png_ptr->jmp_buf_size > 0) - { - - /* This stuff is so that a failure to free the error control structure - * does not leave libpng in a state with no valid error handling: the - * free always succeeds, if there is an error it gets ignored. - */ - if (jb != &png_ptr->jmp_buf_local) - { - /* Make an internal, libpng, jmp_buf to return here */ - jmp_buf free_jmp_buf; - - if (!setjmp(free_jmp_buf)) - { - png_ptr->jmp_buf_ptr = &free_jmp_buf; /* come back here */ - png_ptr->jmp_buf_size = 0; /* stack allocation */ - png_ptr->longjmp_fn = longjmp; - png_free(png_ptr, jb); /* Return to setjmp on error */ - } - } - } - - /* *Always* cancel everything out: */ - png_ptr->jmp_buf_size = 0; - png_ptr->jmp_buf_ptr = NULL; - png_ptr->longjmp_fn = 0; - } -} -#endif - -/* This is the default error handling function. Note that replacements for - * this function MUST NOT RETURN, or the program will likely crash. This - * function is used by default, or if the program supplies NULL for the - * error function pointer in png_set_error_fn(). - */ -static PNG_FUNCTION(void /* PRIVATE */, -png_default_error,(png_const_structrp png_ptr, png_const_charp error_message), - PNG_NORETURN) -{ -#ifdef PNG_CONSOLE_IO_SUPPORTED -#ifdef PNG_ERROR_NUMBERS_SUPPORTED - /* Check on NULL only added in 1.5.4 */ - if (error_message != NULL && *error_message == PNG_LITERAL_SHARP) - { - /* Strip "#nnnn " from beginning of error message. */ - int offset; - char error_number[16]; - for (offset = 0; offset<15; offset++) - { - error_number[offset] = error_message[offset + 1]; - if (error_message[offset] == ' ') - break; - } - - if ((offset > 1) && (offset < 15)) - { - error_number[offset - 1] = '\0'; - fprintf(stderr, "libpng error no. %s: %s", - error_number, error_message + offset + 1); - fprintf(stderr, PNG_STRING_NEWLINE); - } - - else - { - fprintf(stderr, "libpng error: %s, offset=%d", - error_message, offset); - fprintf(stderr, PNG_STRING_NEWLINE); - } - } - else -#endif - { - fprintf(stderr, "libpng error: %s", error_message ? error_message : - "undefined"); - fprintf(stderr, PNG_STRING_NEWLINE); - } -#else - PNG_UNUSED(error_message) /* Make compiler happy */ -#endif - png_longjmp(png_ptr, 1); -} - -PNG_FUNCTION(void,PNGAPI -png_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN) -{ -#ifdef PNG_SETJMP_SUPPORTED - if (png_ptr != NULL && png_ptr->longjmp_fn != NULL && - png_ptr->jmp_buf_ptr != NULL) - png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val); -#else - PNG_UNUSED(png_ptr) - PNG_UNUSED(val) -#endif - - /* If control reaches this point, png_longjmp() must not return. The only - * choice is to terminate the whole process (or maybe the thread); to do - * this the ANSI-C abort() function is used unless a different method is - * implemented by overriding the default configuration setting for - * PNG_ABORT(). - */ - PNG_ABORT(); -} - -#ifdef PNG_WARNINGS_SUPPORTED -/* This function is called when there is a warning, but the library thinks - * it can continue anyway. Replacement functions don't have to do anything - * here if you don't want them to. In the default configuration, png_ptr is - * not used, but it is passed in case it may be useful. - */ -static void /* PRIVATE */ -png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message) -{ -#ifdef PNG_CONSOLE_IO_SUPPORTED -# ifdef PNG_ERROR_NUMBERS_SUPPORTED - if (*warning_message == PNG_LITERAL_SHARP) - { - int offset; - char warning_number[16]; - for (offset = 0; offset < 15; offset++) - { - warning_number[offset] = warning_message[offset + 1]; - if (warning_message[offset] == ' ') - break; - } - - if ((offset > 1) && (offset < 15)) - { - warning_number[offset + 1] = '\0'; - fprintf(stderr, "libpng warning no. %s: %s", - warning_number, warning_message + offset); - fprintf(stderr, PNG_STRING_NEWLINE); - } - - else - { - fprintf(stderr, "libpng warning: %s", - warning_message); - fprintf(stderr, PNG_STRING_NEWLINE); - } - } - else -# endif - - { - fprintf(stderr, "libpng warning: %s", warning_message); - fprintf(stderr, PNG_STRING_NEWLINE); - } -#else - PNG_UNUSED(warning_message) /* Make compiler happy */ -#endif - PNG_UNUSED(png_ptr) /* Make compiler happy */ -} -#endif /* WARNINGS */ - -/* This function is called when the application wants to use another method - * of handling errors and warnings. Note that the error function MUST NOT - * return to the calling routine or serious problems will occur. The return - * method used in the default routine calls longjmp(png_ptr->jmp_buf_ptr, 1) - */ -void PNGAPI -png_set_error_fn(png_structrp png_ptr, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warning_fn) -{ - if (png_ptr == NULL) - return; - - png_ptr->error_ptr = error_ptr; - png_ptr->error_fn = error_fn; -#ifdef PNG_WARNINGS_SUPPORTED - png_ptr->warning_fn = warning_fn; -#else - PNG_UNUSED(warning_fn) -#endif -} - - -/* This function returns a pointer to the error_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy and png_read_destroy are called. - */ -png_voidp PNGAPI -png_get_error_ptr(png_const_structrp png_ptr) -{ - if (png_ptr == NULL) - return NULL; - - return ((png_voidp)png_ptr->error_ptr); -} - - -#ifdef PNG_ERROR_NUMBERS_SUPPORTED -void PNGAPI -png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode) -{ - if (png_ptr != NULL) - { - png_ptr->flags &= - ((~(PNG_FLAG_STRIP_ERROR_NUMBERS | - PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); - } -} -#endif - -#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ - defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) - /* Currently the above both depend on SETJMP_SUPPORTED, however it would be - * possible to implement without setjmp support just so long as there is some - * way to handle the error return here: - */ -PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI -png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message), - PNG_NORETURN) -{ - png_const_structrp png_ptr = png_nonconst_ptr; - png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr); - - /* An error is always logged here, overwriting anything (typically a warning) - * that is already there: - */ - if (image != NULL) - { - png_safecat(image->message, (sizeof image->message), 0, error_message); - image->warning_or_error |= PNG_IMAGE_ERROR; - - /* Retrieve the jmp_buf from within the png_control, making this work for - * C++ compilation too is pretty tricky: C++ wants a pointer to the first - * element of a jmp_buf, but C doesn't tell us the type of that. - */ - if (image->opaque != NULL && image->opaque->error_buf != NULL) - longjmp(png_control_jmp_buf(image->opaque), 1); - - /* Missing longjmp buffer, the following is to help debugging: */ - { - size_t pos = png_safecat(image->message, (sizeof image->message), 0, - "bad longjmp: "); - png_safecat(image->message, (sizeof image->message), pos, - error_message); - } - } - - /* Here on an internal programming error. */ - abort(); -} - -#ifdef PNG_WARNINGS_SUPPORTED -void /* PRIVATE */ PNGCBAPI -png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message) -{ - png_const_structrp png_ptr = png_nonconst_ptr; - png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr); - - /* A warning is only logged if there is no prior warning or error. */ - if (image->warning_or_error == 0) - { - png_safecat(image->message, (sizeof image->message), 0, warning_message); - image->warning_or_error |= PNG_IMAGE_WARNING; - } -} -#endif - -int /* PRIVATE */ -png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg) -{ - volatile png_imagep image = image_in; - volatile int result; - volatile png_voidp saved_error_buf; - jmp_buf safe_jmpbuf; - - /* Safely execute function(arg) with png_error returning to this function. */ - saved_error_buf = image->opaque->error_buf; - result = setjmp(safe_jmpbuf) == 0; - - if (result != 0) - { - - image->opaque->error_buf = safe_jmpbuf; - result = function(arg); - } - - image->opaque->error_buf = saved_error_buf; - - /* And do the cleanup prior to any failure return. */ - if (result == 0) - png_image_free(image); - - return result; -} -#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */ -#endif /* READ || WRITE */ diff --git a/oversampling/WDL/libpng/pngget.c b/oversampling/WDL/libpng/pngget.c deleted file mode 100644 index 5abf1ef..0000000 --- a/oversampling/WDL/libpng/pngget.c +++ /dev/null @@ -1,1249 +0,0 @@ - -/* pngget.c - retrieval of values from info struct - * - * Copyright (c) 2018 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * - */ - -#include "pngpriv.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) - -png_uint_32 PNGAPI -png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_uint_32 flag) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->valid & flag); - - return(0); -} - -size_t PNGAPI -png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->rowbytes); - - return(0); -} - -#ifdef PNG_INFO_IMAGE_SUPPORTED -png_bytepp PNGAPI -png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->row_pointers); - - return(0); -} -#endif - -#ifdef PNG_EASY_ACCESS_SUPPORTED -/* Easy access to info, added in libpng-0.99 */ -png_uint_32 PNGAPI -png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return info_ptr->width; - - return (0); -} - -png_uint_32 PNGAPI -png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return info_ptr->height; - - return (0); -} - -png_byte PNGAPI -png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return info_ptr->bit_depth; - - return (0); -} - -png_byte PNGAPI -png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return info_ptr->color_type; - - return (0); -} - -png_byte PNGAPI -png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return info_ptr->filter_type; - - return (0); -} - -png_byte PNGAPI -png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return info_ptr->interlace_type; - - return (0); -} - -png_byte PNGAPI -png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return info_ptr->compression_type; - - return (0); -} - -png_uint_32 PNGAPI -png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp - info_ptr) -{ -#ifdef PNG_pHYs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_pHYs) != 0) - { - png_debug1(1, "in %s retrieval function", - "png_get_x_pixels_per_meter"); - - if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) - return (info_ptr->x_pixels_per_unit); - } -#else - PNG_UNUSED(png_ptr) - PNG_UNUSED(info_ptr) -#endif - - return (0); -} - -png_uint_32 PNGAPI -png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp - info_ptr) -{ -#ifdef PNG_pHYs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_pHYs) != 0) - { - png_debug1(1, "in %s retrieval function", - "png_get_y_pixels_per_meter"); - - if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER) - return (info_ptr->y_pixels_per_unit); - } -#else - PNG_UNUSED(png_ptr) - PNG_UNUSED(info_ptr) -#endif - - return (0); -} - -png_uint_32 PNGAPI -png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ -#ifdef PNG_pHYs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_pHYs) != 0) - { - png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter"); - - if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER && - info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit) - return (info_ptr->x_pixels_per_unit); - } -#else - PNG_UNUSED(png_ptr) - PNG_UNUSED(info_ptr) -#endif - - return (0); -} - -#ifdef PNG_FLOATING_POINT_SUPPORTED -float PNGAPI -png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp - info_ptr) -{ -#ifdef PNG_READ_pHYs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_pHYs) != 0) - { - png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); - - if (info_ptr->x_pixels_per_unit != 0) - return ((float)((float)info_ptr->y_pixels_per_unit - /(float)info_ptr->x_pixels_per_unit)); - } -#else - PNG_UNUSED(png_ptr) - PNG_UNUSED(info_ptr) -#endif - - return ((float)0.0); -} -#endif - -#ifdef PNG_FIXED_POINT_SUPPORTED -png_fixed_point PNGAPI -png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr, - png_const_inforp info_ptr) -{ -#ifdef PNG_READ_pHYs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_pHYs) != 0 && - info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 && - info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX && - info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX) - { - png_fixed_point res; - - png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed"); - - /* The following casts work because a PNG 4 byte integer only has a valid - * range of 0..2^31-1; otherwise the cast might overflow. - */ - if (png_muldiv(&res, (png_int_32)info_ptr->y_pixels_per_unit, PNG_FP_1, - (png_int_32)info_ptr->x_pixels_per_unit) != 0) - return res; - } -#else - PNG_UNUSED(png_ptr) - PNG_UNUSED(info_ptr) -#endif - - return 0; -} -#endif - -png_int_32 PNGAPI -png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ -#ifdef PNG_oFFs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_oFFs) != 0) - { - png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); - - if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) - return (info_ptr->x_offset); - } -#else - PNG_UNUSED(png_ptr) - PNG_UNUSED(info_ptr) -#endif - - return (0); -} - -png_int_32 PNGAPI -png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ -#ifdef PNG_oFFs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_oFFs) != 0) - { - png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); - - if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER) - return (info_ptr->y_offset); - } -#else - PNG_UNUSED(png_ptr) - PNG_UNUSED(info_ptr) -#endif - - return (0); -} - -png_int_32 PNGAPI -png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ -#ifdef PNG_oFFs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_oFFs) != 0) - { - png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels"); - - if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) - return (info_ptr->x_offset); - } -#else - PNG_UNUSED(png_ptr) - PNG_UNUSED(info_ptr) -#endif - - return (0); -} - -png_int_32 PNGAPI -png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ -#ifdef PNG_oFFs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_oFFs) != 0) - { - png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels"); - - if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL) - return (info_ptr->y_offset); - } -#else - PNG_UNUSED(png_ptr) - PNG_UNUSED(info_ptr) -#endif - - return (0); -} - -#ifdef PNG_INCH_CONVERSIONS_SUPPORTED -static png_uint_32 -ppi_from_ppm(png_uint_32 ppm) -{ -#if 0 - /* The conversion is *(2.54/100), in binary (32 digits): - * .00000110100000001001110101001001 - */ - png_uint_32 t1001, t1101; - ppm >>= 1; /* .1 */ - t1001 = ppm + (ppm >> 3); /* .1001 */ - t1101 = t1001 + (ppm >> 1); /* .1101 */ - ppm >>= 20; /* .000000000000000000001 */ - t1101 += t1101 >> 15; /* .1101000000000001101 */ - t1001 >>= 11; /* .000000000001001 */ - t1001 += t1001 >> 12; /* .000000000001001000000001001 */ - ppm += t1001; /* .000000000001001000001001001 */ - ppm += t1101; /* .110100000001001110101001001 */ - return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */ -#else - /* The argument is a PNG unsigned integer, so it is not permitted - * to be bigger than 2^31. - */ - png_fixed_point result; - if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127, - 5000) != 0) - return (png_uint_32)result; - - /* Overflow. */ - return 0; -#endif -} - -png_uint_32 PNGAPI -png_get_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - return ppi_from_ppm(png_get_pixels_per_meter(png_ptr, info_ptr)); -} - -png_uint_32 PNGAPI -png_get_x_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - return ppi_from_ppm(png_get_x_pixels_per_meter(png_ptr, info_ptr)); -} - -png_uint_32 PNGAPI -png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - return ppi_from_ppm(png_get_y_pixels_per_meter(png_ptr, info_ptr)); -} - -#ifdef PNG_FIXED_POINT_SUPPORTED -static png_fixed_point -png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns) -{ - /* Convert from meters * 1,000,000 to inches * 100,000, meters to - * inches is simply *(100/2.54), so we want *(10/2.54) == 500/127. - * Notice that this can overflow - a warning is output and 0 is - * returned. - */ - return png_muldiv_warn(png_ptr, microns, 500, 127); -} - -png_fixed_point PNGAPI -png_get_x_offset_inches_fixed(png_const_structrp png_ptr, - png_const_inforp info_ptr) -{ - return png_fixed_inches_from_microns(png_ptr, - png_get_x_offset_microns(png_ptr, info_ptr)); -} -#endif - -#ifdef PNG_FIXED_POINT_SUPPORTED -png_fixed_point PNGAPI -png_get_y_offset_inches_fixed(png_const_structrp png_ptr, - png_const_inforp info_ptr) -{ - return png_fixed_inches_from_microns(png_ptr, - png_get_y_offset_microns(png_ptr, info_ptr)); -} -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -float PNGAPI -png_get_x_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - /* To avoid the overflow do the conversion directly in floating - * point. - */ - return (float)(png_get_x_offset_microns(png_ptr, info_ptr) * .00003937); -} -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -float PNGAPI -png_get_y_offset_inches(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - /* To avoid the overflow do the conversion directly in floating - * point. - */ - return (float)(png_get_y_offset_microns(png_ptr, info_ptr) * .00003937); -} -#endif - -#ifdef PNG_pHYs_SUPPORTED -png_uint_32 PNGAPI -png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) -{ - png_uint_32 retval = 0; - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_pHYs) != 0) - { - png_debug1(1, "in %s retrieval function", "pHYs"); - - if (res_x != NULL) - { - *res_x = info_ptr->x_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - - if (res_y != NULL) - { - *res_y = info_ptr->y_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - - if (unit_type != NULL) - { - *unit_type = (int)info_ptr->phys_unit_type; - retval |= PNG_INFO_pHYs; - - if (*unit_type == 1) - { - if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); - if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); - } - } - } - - return (retval); -} -#endif /* pHYs */ -#endif /* INCH_CONVERSIONS */ - -/* png_get_channels really belongs in here, too, but it's been around longer */ - -#endif /* EASY_ACCESS */ - - -png_byte PNGAPI -png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->channels); - - return (0); -} - -#ifdef PNG_READ_SUPPORTED -png_const_bytep PNGAPI -png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return(info_ptr->signature); - - return (NULL); -} -#endif - -#ifdef PNG_bKGD_SUPPORTED -png_uint_32 PNGAPI -png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, - png_color_16p *background) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_bKGD) != 0 && - background != NULL) - { - png_debug1(1, "in %s retrieval function", "bKGD"); - - *background = &(info_ptr->background); - return (PNG_INFO_bKGD); - } - - return (0); -} -#endif - -#ifdef PNG_cHRM_SUPPORTED -/* The XYZ APIs were added in 1.5.5 to take advantage of the code added at the - * same time to correct the rgb grayscale coefficient defaults obtained from the - * cHRM chunk in 1.5.4 - */ -# ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr, - double *white_x, double *white_y, double *red_x, double *red_y, - double *green_x, double *green_y, double *blue_x, double *blue_y) -{ - /* Quiet API change: this code used to only return the end points if a cHRM - * chunk was present, but the end points can also come from iCCP or sRGB - * chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and - * the png_set_ APIs merely check that set end points are mutually - * consistent. - */ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) - { - png_debug1(1, "in %s retrieval function", "cHRM"); - - if (white_x != NULL) - *white_x = png_float(png_ptr, - info_ptr->colorspace.end_points_xy.whitex, "cHRM white X"); - if (white_y != NULL) - *white_y = png_float(png_ptr, - info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y"); - if (red_x != NULL) - *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx, - "cHRM red X"); - if (red_y != NULL) - *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy, - "cHRM red Y"); - if (green_x != NULL) - *green_x = png_float(png_ptr, - info_ptr->colorspace.end_points_xy.greenx, "cHRM green X"); - if (green_y != NULL) - *green_y = png_float(png_ptr, - info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y"); - if (blue_x != NULL) - *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex, - "cHRM blue X"); - if (blue_y != NULL) - *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey, - "cHRM blue Y"); - return (PNG_INFO_cHRM); - } - - return (0); -} - -png_uint_32 PNGAPI -png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr, - double *red_X, double *red_Y, double *red_Z, double *green_X, - double *green_Y, double *green_Z, double *blue_X, double *blue_Y, - double *blue_Z) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) - { - png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)"); - - if (red_X != NULL) - *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X, - "cHRM red X"); - if (red_Y != NULL) - *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y, - "cHRM red Y"); - if (red_Z != NULL) - *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z, - "cHRM red Z"); - if (green_X != NULL) - *green_X = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X"); - if (green_Y != NULL) - *green_Y = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y"); - if (green_Z != NULL) - *green_Z = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z"); - if (blue_X != NULL) - *blue_X = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X"); - if (blue_Y != NULL) - *blue_Y = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y"); - if (blue_Z != NULL) - *blue_Z = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z"); - return (PNG_INFO_cHRM); - } - - return (0); -} -# endif - -# ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_fixed_point *int_red_X, png_fixed_point *int_red_Y, - png_fixed_point *int_red_Z, png_fixed_point *int_green_X, - png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, - png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, - png_fixed_point *int_blue_Z) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) - { - png_debug1(1, "in %s retrieval function", "cHRM_XYZ"); - - if (int_red_X != NULL) - *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X; - if (int_red_Y != NULL) - *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y; - if (int_red_Z != NULL) - *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z; - if (int_green_X != NULL) - *int_green_X = info_ptr->colorspace.end_points_XYZ.green_X; - if (int_green_Y != NULL) - *int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y; - if (int_green_Z != NULL) - *int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z; - if (int_blue_X != NULL) - *int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X; - if (int_blue_Y != NULL) - *int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y; - if (int_blue_Z != NULL) - *int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z; - return (PNG_INFO_cHRM); - } - - return (0); -} - -png_uint_32 PNGAPI -png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x, - png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y, - png_fixed_point *blue_x, png_fixed_point *blue_y) -{ - png_debug1(1, "in %s retrieval function", "cHRM"); - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) - { - if (white_x != NULL) - *white_x = info_ptr->colorspace.end_points_xy.whitex; - if (white_y != NULL) - *white_y = info_ptr->colorspace.end_points_xy.whitey; - if (red_x != NULL) - *red_x = info_ptr->colorspace.end_points_xy.redx; - if (red_y != NULL) - *red_y = info_ptr->colorspace.end_points_xy.redy; - if (green_x != NULL) - *green_x = info_ptr->colorspace.end_points_xy.greenx; - if (green_y != NULL) - *green_y = info_ptr->colorspace.end_points_xy.greeny; - if (blue_x != NULL) - *blue_x = info_ptr->colorspace.end_points_xy.bluex; - if (blue_y != NULL) - *blue_y = info_ptr->colorspace.end_points_xy.bluey; - return (PNG_INFO_cHRM); - } - - return (0); -} -# endif -#endif - -#ifdef PNG_gAMA_SUPPORTED -# ifdef PNG_FIXED_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_fixed_point *file_gamma) -{ - png_debug1(1, "in %s retrieval function", "gAMA"); - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 && - file_gamma != NULL) - { - *file_gamma = info_ptr->colorspace.gamma; - return (PNG_INFO_gAMA); - } - - return (0); -} -# endif - -# ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr, - double *file_gamma) -{ - png_debug1(1, "in %s retrieval function", "gAMA(float)"); - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 && - file_gamma != NULL) - { - *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma, - "png_get_gAMA"); - return (PNG_INFO_gAMA); - } - - return (0); -} -# endif -#endif - -#ifdef PNG_sRGB_SUPPORTED -png_uint_32 PNGAPI -png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr, - int *file_srgb_intent) -{ - png_debug1(1, "in %s retrieval function", "sRGB"); - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sRGB) != 0 && file_srgb_intent != NULL) - { - *file_srgb_intent = info_ptr->colorspace.rendering_intent; - return (PNG_INFO_sRGB); - } - - return (0); -} -#endif - -#ifdef PNG_iCCP_SUPPORTED -png_uint_32 PNGAPI -png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, - png_charpp name, int *compression_type, - png_bytepp profile, png_uint_32 *proflen) -{ - png_debug1(1, "in %s retrieval function", "iCCP"); - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_iCCP) != 0 && - name != NULL && profile != NULL && proflen != NULL) - { - *name = info_ptr->iccp_name; - *profile = info_ptr->iccp_profile; - *proflen = png_get_uint_32(info_ptr->iccp_profile); - /* This is somewhat irrelevant since the profile data returned has - * actually been uncompressed. - */ - if (compression_type != NULL) - *compression_type = PNG_COMPRESSION_TYPE_BASE; - return (PNG_INFO_iCCP); - } - - return (0); - -} -#endif - -#ifdef PNG_sPLT_SUPPORTED -int PNGAPI -png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr, - png_sPLT_tpp spalettes) -{ - if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL) - { - *spalettes = info_ptr->splt_palettes; - return info_ptr->splt_palettes_num; - } - - return (0); -} -#endif - -#ifdef PNG_eXIf_SUPPORTED -png_uint_32 PNGAPI -png_get_eXIf(png_const_structrp png_ptr, png_inforp info_ptr, - png_bytep *exif) -{ - png_warning(png_ptr, "png_get_eXIf does not work; use png_get_eXIf_1"); - PNG_UNUSED(info_ptr) - PNG_UNUSED(exif) - return 0; -} - -png_uint_32 PNGAPI -png_get_eXIf_1(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_uint_32 *num_exif, png_bytep *exif) -{ - png_debug1(1, "in %s retrieval function", "eXIf"); - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_eXIf) != 0 && exif != NULL) - { - *num_exif = info_ptr->num_exif; - *exif = info_ptr->exif; - return (PNG_INFO_eXIf); - } - - return (0); -} -#endif - -#ifdef PNG_hIST_SUPPORTED -png_uint_32 PNGAPI -png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr, - png_uint_16p *hist) -{ - png_debug1(1, "in %s retrieval function", "hIST"); - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_hIST) != 0 && hist != NULL) - { - *hist = info_ptr->hist; - return (PNG_INFO_hIST); - } - - return (0); -} -#endif - -png_uint_32 PNGAPI -png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_uint_32 *width, png_uint_32 *height, int *bit_depth, - int *color_type, int *interlace_type, int *compression_type, - int *filter_type) -{ - png_debug1(1, "in %s retrieval function", "IHDR"); - - if (png_ptr == NULL || info_ptr == NULL) - return (0); - - if (width != NULL) - *width = info_ptr->width; - - if (height != NULL) - *height = info_ptr->height; - - if (bit_depth != NULL) - *bit_depth = info_ptr->bit_depth; - - if (color_type != NULL) - *color_type = info_ptr->color_type; - - if (compression_type != NULL) - *compression_type = info_ptr->compression_type; - - if (filter_type != NULL) - *filter_type = info_ptr->filter_type; - - if (interlace_type != NULL) - *interlace_type = info_ptr->interlace_type; - - /* This is redundant if we can be sure that the info_ptr values were all - * assigned in png_set_IHDR(). We do the check anyhow in case an - * application has ignored our advice not to mess with the members - * of info_ptr directly. - */ - png_check_IHDR(png_ptr, info_ptr->width, info_ptr->height, - info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, - info_ptr->compression_type, info_ptr->filter_type); - - return (1); -} - -#ifdef PNG_oFFs_SUPPORTED -png_uint_32 PNGAPI -png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type) -{ - png_debug1(1, "in %s retrieval function", "oFFs"); - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_oFFs) != 0 && - offset_x != NULL && offset_y != NULL && unit_type != NULL) - { - *offset_x = info_ptr->x_offset; - *offset_y = info_ptr->y_offset; - *unit_type = (int)info_ptr->offset_unit_type; - return (PNG_INFO_oFFs); - } - - return (0); -} -#endif - -#ifdef PNG_pCAL_SUPPORTED -png_uint_32 PNGAPI -png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, - png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams, - png_charp *units, png_charpp *params) -{ - png_debug1(1, "in %s retrieval function", "pCAL"); - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_pCAL) != 0 && - purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && - nparams != NULL && units != NULL && params != NULL) - { - *purpose = info_ptr->pcal_purpose; - *X0 = info_ptr->pcal_X0; - *X1 = info_ptr->pcal_X1; - *type = (int)info_ptr->pcal_type; - *nparams = (int)info_ptr->pcal_nparams; - *units = info_ptr->pcal_units; - *params = info_ptr->pcal_params; - return (PNG_INFO_pCAL); - } - - return (0); -} -#endif - -#ifdef PNG_sCAL_SUPPORTED -# ifdef PNG_FIXED_POINT_SUPPORTED -# if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ - defined(PNG_FLOATING_POINT_SUPPORTED) -png_uint_32 PNGAPI -png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, - int *unit, png_fixed_point *width, png_fixed_point *height) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sCAL) != 0) - { - *unit = info_ptr->scal_unit; - /*TODO: make this work without FP support; the API is currently eliminated - * if neither floating point APIs nor internal floating point arithmetic - * are enabled. - */ - *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width"); - *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height), - "sCAL height"); - return (PNG_INFO_sCAL); - } - - return(0); -} -# endif /* FLOATING_ARITHMETIC */ -# endif /* FIXED_POINT */ -# ifdef PNG_FLOATING_POINT_SUPPORTED -png_uint_32 PNGAPI -png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr, - int *unit, double *width, double *height) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sCAL) != 0) - { - *unit = info_ptr->scal_unit; - *width = atof(info_ptr->scal_s_width); - *height = atof(info_ptr->scal_s_height); - return (PNG_INFO_sCAL); - } - - return(0); -} -# endif /* FLOATING POINT */ -png_uint_32 PNGAPI -png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr, - int *unit, png_charpp width, png_charpp height) -{ - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sCAL) != 0) - { - *unit = info_ptr->scal_unit; - *width = info_ptr->scal_s_width; - *height = info_ptr->scal_s_height; - return (PNG_INFO_sCAL); - } - - return(0); -} -#endif /* sCAL */ - -#ifdef PNG_pHYs_SUPPORTED -png_uint_32 PNGAPI -png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type) -{ - png_uint_32 retval = 0; - - png_debug1(1, "in %s retrieval function", "pHYs"); - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_pHYs) != 0) - { - if (res_x != NULL) - { - *res_x = info_ptr->x_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - - if (res_y != NULL) - { - *res_y = info_ptr->y_pixels_per_unit; - retval |= PNG_INFO_pHYs; - } - - if (unit_type != NULL) - { - *unit_type = (int)info_ptr->phys_unit_type; - retval |= PNG_INFO_pHYs; - } - } - - return (retval); -} -#endif /* pHYs */ - -png_uint_32 PNGAPI -png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr, - png_colorp *palette, int *num_palette) -{ - png_debug1(1, "in %s retrieval function", "PLTE"); - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_PLTE) != 0 && palette != NULL) - { - *palette = info_ptr->palette; - *num_palette = info_ptr->num_palette; - png_debug1(3, "num_palette = %d", *num_palette); - return (PNG_INFO_PLTE); - } - - return (0); -} - -#ifdef PNG_sBIT_SUPPORTED -png_uint_32 PNGAPI -png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr, - png_color_8p *sig_bit) -{ - png_debug1(1, "in %s retrieval function", "sBIT"); - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sBIT) != 0 && sig_bit != NULL) - { - *sig_bit = &(info_ptr->sig_bit); - return (PNG_INFO_sBIT); - } - - return (0); -} -#endif - -#ifdef PNG_TEXT_SUPPORTED -int PNGAPI -png_get_text(png_const_structrp png_ptr, png_inforp info_ptr, - png_textp *text_ptr, int *num_text) -{ - if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) - { - png_debug1(1, "in 0x%lx retrieval function", - (unsigned long)png_ptr->chunk_name); - - if (text_ptr != NULL) - *text_ptr = info_ptr->text; - - if (num_text != NULL) - *num_text = info_ptr->num_text; - - return info_ptr->num_text; - } - - if (num_text != NULL) - *num_text = 0; - - return(0); -} -#endif - -#ifdef PNG_tIME_SUPPORTED -png_uint_32 PNGAPI -png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr, - png_timep *mod_time) -{ - png_debug1(1, "in %s retrieval function", "tIME"); - - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_tIME) != 0 && mod_time != NULL) - { - *mod_time = &(info_ptr->mod_time); - return (PNG_INFO_tIME); - } - - return (0); -} -#endif - -#ifdef PNG_tRNS_SUPPORTED -png_uint_32 PNGAPI -png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr, - png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color) -{ - png_uint_32 retval = 0; - if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_tRNS) != 0) - { - png_debug1(1, "in %s retrieval function", "tRNS"); - - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (trans_alpha != NULL) - { - *trans_alpha = info_ptr->trans_alpha; - retval |= PNG_INFO_tRNS; - } - - if (trans_color != NULL) - *trans_color = &(info_ptr->trans_color); - } - - else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */ - { - if (trans_color != NULL) - { - *trans_color = &(info_ptr->trans_color); - retval |= PNG_INFO_tRNS; - } - - if (trans_alpha != NULL) - *trans_alpha = NULL; - } - - if (num_trans != NULL) - { - *num_trans = info_ptr->num_trans; - retval |= PNG_INFO_tRNS; - } - } - - return (retval); -} -#endif - -#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED -int PNGAPI -png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr, - png_unknown_chunkpp unknowns) -{ - if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL) - { - *unknowns = info_ptr->unknown_chunks; - return info_ptr->unknown_chunks_num; - } - - return (0); -} -#endif - -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED -png_byte PNGAPI -png_get_rgb_to_gray_status (png_const_structrp png_ptr) -{ - return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0); -} -#endif - -#ifdef PNG_USER_CHUNKS_SUPPORTED -png_voidp PNGAPI -png_get_user_chunk_ptr(png_const_structrp png_ptr) -{ - return (png_ptr ? png_ptr->user_chunk_ptr : NULL); -} -#endif - -size_t PNGAPI -png_get_compression_buffer_size(png_const_structrp png_ptr) -{ - if (png_ptr == NULL) - return 0; - -#ifdef PNG_WRITE_SUPPORTED - if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) -#endif - { -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED - return png_ptr->IDAT_read_size; -#else - return PNG_IDAT_READ_SIZE; -#endif - } - -#ifdef PNG_WRITE_SUPPORTED - else - return png_ptr->zbuffer_size; -#endif -} - -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -/* These functions were added to libpng 1.2.6 and were enabled - * by default in libpng-1.4.0 */ -png_uint_32 PNGAPI -png_get_user_width_max (png_const_structrp png_ptr) -{ - return (png_ptr ? png_ptr->user_width_max : 0); -} - -png_uint_32 PNGAPI -png_get_user_height_max (png_const_structrp png_ptr) -{ - return (png_ptr ? png_ptr->user_height_max : 0); -} - -/* This function was added to libpng 1.4.0 */ -png_uint_32 PNGAPI -png_get_chunk_cache_max (png_const_structrp png_ptr) -{ - return (png_ptr ? png_ptr->user_chunk_cache_max : 0); -} - -/* This function was added to libpng 1.4.1 */ -png_alloc_size_t PNGAPI -png_get_chunk_malloc_max (png_const_structrp png_ptr) -{ - return (png_ptr ? png_ptr->user_chunk_malloc_max : 0); -} -#endif /* SET_USER_LIMITS */ - -/* These functions were added to libpng 1.4.0 */ -#ifdef PNG_IO_STATE_SUPPORTED -png_uint_32 PNGAPI -png_get_io_state (png_const_structrp png_ptr) -{ - return png_ptr->io_state; -} - -png_uint_32 PNGAPI -png_get_io_chunk_type (png_const_structrp png_ptr) -{ - return png_ptr->chunk_name; -} -#endif /* IO_STATE */ - -#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED -# ifdef PNG_GET_PALETTE_MAX_SUPPORTED -int PNGAPI -png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr) -{ - if (png_ptr != NULL && info_ptr != NULL) - return png_ptr->num_palette_max; - - return (-1); -} -# endif -#endif - -#endif /* READ || WRITE */ diff --git a/oversampling/WDL/libpng/pnginfo.h b/oversampling/WDL/libpng/pnginfo.h deleted file mode 100644 index 1f98ded..0000000 --- a/oversampling/WDL/libpng/pnginfo.h +++ /dev/null @@ -1,267 +0,0 @@ - -/* pnginfo.h - header file for PNG reference library - * - * Copyright (c) 2018 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2013,2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - */ - - /* png_info is a structure that holds the information in a PNG file so - * that the application can find out the characteristics of the image. - * If you are reading the file, this structure will tell you what is - * in the PNG file. If you are writing the file, fill in the information - * you want to put into the PNG file, using png_set_*() functions, then - * call png_write_info(). - * - * The names chosen should be very close to the PNG specification, so - * consult that document for information about the meaning of each field. - * - * With libpng < 0.95, it was only possible to directly set and read the - * the values in the png_info_struct, which meant that the contents and - * order of the values had to remain fixed. With libpng 0.95 and later, - * however, there are now functions that abstract the contents of - * png_info_struct from the application, so this makes it easier to use - * libpng with dynamic libraries, and even makes it possible to use - * libraries that don't have all of the libpng ancillary chunk-handing - * functionality. In libpng-1.5.0 this was moved into a separate private - * file that is not visible to applications. - * - * The following members may have allocated storage attached that should be - * cleaned up before the structure is discarded: palette, trans, text, - * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, - * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these - * are automatically freed when the info structure is deallocated, if they were - * allocated internally by libpng. This behavior can be changed by means - * of the png_data_freer() function. - * - * More allocation details: all the chunk-reading functions that - * change these members go through the corresponding png_set_* - * functions. A function to clear these members is available: see - * png_free_data(). The png_set_* functions do not depend on being - * able to point info structure members to any of the storage they are - * passed (they make their own copies), EXCEPT that the png_set_text - * functions use the same storage passed to them in the text_ptr or - * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns - * functions do not make their own copies. - */ -#ifndef PNGINFO_H -#define PNGINFO_H - -struct png_info_def -{ - /* The following are necessary for every PNG file */ - png_uint_32 width; /* width of image in pixels (from IHDR) */ - png_uint_32 height; /* height of image in pixels (from IHDR) */ - png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ - size_t rowbytes; /* bytes needed to hold an untransformed row */ - png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */ - png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */ - png_uint_16 num_trans; /* number of transparent palette color (tRNS) */ - png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */ - png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */ - /* The following three should have been named *_method not *_type */ - png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */ - png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */ - png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ - - /* The following are set by png_set_IHDR, called from the application on - * write, but the are never actually used by the write code. - */ - png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */ - png_byte pixel_depth; /* number of bits per pixel */ - png_byte spare_byte; /* to align the data, and for future use */ - -#ifdef PNG_READ_SUPPORTED - /* This is never set during write */ - png_byte signature[8]; /* magic bytes read by libpng from start of file */ -#endif - - /* The rest of the data is optional. If you are reading, check the - * valid field to see if the information in these are valid. If you - * are writing, set the valid field to those chunks you want written, - * and initialize the appropriate fields below. - */ - -#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED) - /* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are - * defined. When COLORSPACE is switched on all the colorspace-defining - * chunks should be enabled, when GAMMA is switched on all the gamma-defining - * chunks should be enabled. If this is not done it becomes possible to read - * inconsistent PNG files and assign a probably incorrect interpretation to - * the information. (In other words, by carefully choosing which chunks to - * recognize the system configuration can select an interpretation for PNG - * files containing ambiguous data and this will result in inconsistent - * behavior between different libpng builds!) - */ - png_colorspace colorspace; -#endif - -#ifdef PNG_iCCP_SUPPORTED - /* iCCP chunk data. */ - png_charp iccp_name; /* profile name */ - png_bytep iccp_profile; /* International Color Consortium profile data */ - png_uint_32 iccp_proflen; /* ICC profile data length */ -#endif - -#ifdef PNG_TEXT_SUPPORTED - /* The tEXt, and zTXt chunks contain human-readable textual data in - * uncompressed, compressed, and optionally compressed forms, respectively. - * The data in "text" is an array of pointers to uncompressed, - * null-terminated C strings. Each chunk has a keyword that describes the - * textual data contained in that chunk. Keywords are not required to be - * unique, and the text string may be empty. Any number of text chunks may - * be in an image. - */ - int num_text; /* number of comments read or comments to write */ - int max_text; /* current size of text array */ - png_textp text; /* array of comments read or comments to write */ -#endif /* TEXT */ - -#ifdef PNG_tIME_SUPPORTED - /* The tIME chunk holds the last time the displayed image data was - * modified. See the png_time struct for the contents of this struct. - */ - png_time mod_time; -#endif - -#ifdef PNG_sBIT_SUPPORTED - /* The sBIT chunk specifies the number of significant high-order bits - * in the pixel data. Values are in the range [1, bit_depth], and are - * only specified for the channels in the pixel data. The contents of - * the low-order bits is not specified. Data is valid if - * (valid & PNG_INFO_sBIT) is non-zero. - */ - png_color_8 sig_bit; /* significant bits in color channels */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \ -defined(PNG_READ_BACKGROUND_SUPPORTED) - /* The tRNS chunk supplies transparency data for paletted images and - * other image types that don't need a full alpha channel. There are - * "num_trans" transparency values for a paletted image, stored in the - * same order as the palette colors, starting from index 0. Values - * for the data are in the range [0, 255], ranging from fully transparent - * to fully opaque, respectively. For non-paletted images, there is a - * single color specified that should be treated as fully transparent. - * Data is valid if (valid & PNG_INFO_tRNS) is non-zero. - */ - png_bytep trans_alpha; /* alpha values for paletted image */ - png_color_16 trans_color; /* transparent color for non-palette image */ -#endif - -#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - /* The bKGD chunk gives the suggested image background color if the - * display program does not have its own background color and the image - * is needs to composited onto a background before display. The colors - * in "background" are normally in the same color space/depth as the - * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero. - */ - png_color_16 background; -#endif - -#ifdef PNG_oFFs_SUPPORTED - /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards - * and downwards from the top-left corner of the display, page, or other - * application-specific co-ordinate space. See the PNG_OFFSET_ defines - * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero. - */ - png_int_32 x_offset; /* x offset on page */ - png_int_32 y_offset; /* y offset on page */ - png_byte offset_unit_type; /* offset units type */ -#endif - -#ifdef PNG_pHYs_SUPPORTED - /* The pHYs chunk gives the physical pixel density of the image for - * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_ - * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero. - */ - png_uint_32 x_pixels_per_unit; /* horizontal pixel density */ - png_uint_32 y_pixels_per_unit; /* vertical pixel density */ - png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */ -#endif - -#ifdef PNG_eXIf_SUPPORTED - int num_exif; /* Added at libpng-1.6.31 */ - png_bytep exif; -# ifdef PNG_READ_eXIf_SUPPORTED - png_bytep eXIf_buf; /* Added at libpng-1.6.32 */ -# endif -#endif - -#ifdef PNG_hIST_SUPPORTED - /* The hIST chunk contains the relative frequency or importance of the - * various palette entries, so that a viewer can intelligently select a - * reduced-color palette, if required. Data is an array of "num_palette" - * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST) - * is non-zero. - */ - png_uint_16p hist; -#endif - -#ifdef PNG_pCAL_SUPPORTED - /* The pCAL chunk describes a transformation between the stored pixel - * values and original physical data values used to create the image. - * The integer range [0, 2^bit_depth - 1] maps to the floating-point - * range given by [pcal_X0, pcal_X1], and are further transformed by a - * (possibly non-linear) transformation function given by "pcal_type" - * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_ - * defines below, and the PNG-Group's PNG extensions document for a - * complete description of the transformations and how they should be - * implemented, and for a description of the ASCII parameter strings. - * Data values are valid if (valid & PNG_INFO_pCAL) non-zero. - */ - png_charp pcal_purpose; /* pCAL chunk description string */ - png_int_32 pcal_X0; /* minimum value */ - png_int_32 pcal_X1; /* maximum value */ - png_charp pcal_units; /* Latin-1 string giving physical units */ - png_charpp pcal_params; /* ASCII strings containing parameter values */ - png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */ - png_byte pcal_nparams; /* number of parameters given in pcal_params */ -#endif - -/* New members added in libpng-1.0.6 */ - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ - -#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED - /* Storage for unknown chunks that the library doesn't recognize. */ - png_unknown_chunkp unknown_chunks; - - /* The type of this field is limited by the type of - * png_struct::user_chunk_cache_max, else overflow can occur. - */ - int unknown_chunks_num; -#endif - -#ifdef PNG_sPLT_SUPPORTED - /* Data on sPLT chunks (there may be more than one). */ - png_sPLT_tp splt_palettes; - int splt_palettes_num; /* Match type returned by png_get API */ -#endif - -#ifdef PNG_sCAL_SUPPORTED - /* The sCAL chunk describes the actual physical dimensions of the - * subject matter of the graphic. The chunk contains a unit specification - * a byte value, and two ASCII strings representing floating-point - * values. The values are width and height corresponding to one pixel - * in the image. Data values are valid if (valid & PNG_INFO_sCAL) is - * non-zero. - */ - png_byte scal_unit; /* unit of physical scale */ - png_charp scal_s_width; /* string containing height */ - png_charp scal_s_height; /* string containing width */ -#endif - -#ifdef PNG_INFO_IMAGE_SUPPORTED - /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) - non-zero */ - /* Data valid if (valid & PNG_INFO_IDAT) non-zero */ - png_bytepp row_pointers; /* the image bits */ -#endif - -}; -#endif /* PNGINFO_H */ diff --git a/oversampling/WDL/libpng/pnglibconf.h b/oversampling/WDL/libpng/pnglibconf.h deleted file mode 100644 index f77a01c..0000000 --- a/oversampling/WDL/libpng/pnglibconf.h +++ /dev/null @@ -1,224 +0,0 @@ -/* libpng 1.6.17 STANDARD API DEFINITION */ - -/* pnglibconf.h - library build configuration */ - -/* Libpng version 1.6.17 - March 26, 2015 */ - -/* Copyright (c) 1998-2014 Glenn Randers-Pehrson */ - -/* This code is released under the libpng license. */ -/* For conditions of distribution and use, see the disclaimer */ -/* and license in png.h */ - -/* pnglibconf.h */ -/* Machine generated file: DO NOT EDIT */ -/* Derived from: scripts/pnglibconf.dfa */ -#ifndef PNGLCONF_H -#define PNGLCONF_H -/* options */ -#define PNG_16BIT_SUPPORTED -#define PNG_ALIGNED_MEMORY_SUPPORTED -/*#undef PNG_ARM_NEON_API_SUPPORTED*/ -/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/ -#define PNG_BENIGN_ERRORS_SUPPORTED -#define PNG_BENIGN_READ_ERRORS_SUPPORTED -/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/ -#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED -#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED -#define PNG_COLORSPACE_SUPPORTED -/*#undef PNG_CONSOLE_IO_SUPPORTED*/ -#define PNG_CONVERT_tIME_SUPPORTED -#define PNG_EASY_ACCESS_SUPPORTED -/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ -/*#undef PNG_ERROR_TEXT_SUPPORTED*/ -#define PNG_FIXED_POINT_SUPPORTED -#define PNG_FLOATING_ARITHMETIC_SUPPORTED -#define PNG_FLOATING_POINT_SUPPORTED -#define PNG_FORMAT_AFIRST_SUPPORTED -#define PNG_FORMAT_BGR_SUPPORTED -#define PNG_GAMMA_SUPPORTED -#define PNG_GET_PALETTE_MAX_SUPPORTED -#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -#define PNG_INCH_CONVERSIONS_SUPPORTED -#define PNG_INFO_IMAGE_SUPPORTED -#define PNG_IO_STATE_SUPPORTED -#define PNG_MNG_FEATURES_SUPPORTED -#define PNG_POINTER_INDEXING_SUPPORTED -#define PNG_PROGRESSIVE_READ_SUPPORTED -#define PNG_READ_16BIT_SUPPORTED -#define PNG_READ_ALPHA_MODE_SUPPORTED -#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED -#define PNG_READ_BACKGROUND_SUPPORTED -#define PNG_READ_BGR_SUPPORTED -#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED -#define PNG_READ_COMPOSITE_NODIV_SUPPORTED -#define PNG_READ_COMPRESSED_TEXT_SUPPORTED -#define PNG_READ_EXPAND_16_SUPPORTED -#define PNG_READ_EXPAND_SUPPORTED -#define PNG_READ_FILLER_SUPPORTED -#define PNG_READ_GAMMA_SUPPORTED -#define PNG_READ_GET_PALETTE_MAX_SUPPORTED -#define PNG_READ_GRAY_TO_RGB_SUPPORTED -#define PNG_READ_INTERLACING_SUPPORTED -#define PNG_READ_INT_FUNCTIONS_SUPPORTED -#define PNG_READ_INVERT_ALPHA_SUPPORTED -#define PNG_READ_INVERT_SUPPORTED -#define PNG_READ_OPT_PLTE_SUPPORTED -#define PNG_READ_PACKSWAP_SUPPORTED -#define PNG_READ_PACK_SUPPORTED -#define PNG_READ_QUANTIZE_SUPPORTED -#define PNG_READ_RGB_TO_GRAY_SUPPORTED -#define PNG_READ_SCALE_16_TO_8_SUPPORTED -#define PNG_READ_SHIFT_SUPPORTED -#define PNG_READ_STRIP_16_TO_8_SUPPORTED -#define PNG_READ_STRIP_ALPHA_SUPPORTED -#define PNG_READ_SUPPORTED -#define PNG_READ_SWAP_ALPHA_SUPPORTED -#define PNG_READ_SWAP_SUPPORTED -#define PNG_READ_TEXT_SUPPORTED -#define PNG_READ_TRANSFORMS_SUPPORTED -#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_READ_USER_CHUNKS_SUPPORTED -#define PNG_READ_USER_TRANSFORM_SUPPORTED -#define PNG_READ_bKGD_SUPPORTED -#define PNG_READ_cHRM_SUPPORTED -#define PNG_READ_gAMA_SUPPORTED -#define PNG_READ_hIST_SUPPORTED -#define PNG_READ_iCCP_SUPPORTED -#define PNG_READ_iTXt_SUPPORTED -#define PNG_READ_oFFs_SUPPORTED -#define PNG_READ_pCAL_SUPPORTED -#define PNG_READ_pHYs_SUPPORTED -#define PNG_READ_sBIT_SUPPORTED -#define PNG_READ_sCAL_SUPPORTED -#define PNG_READ_sPLT_SUPPORTED -#define PNG_READ_sRGB_SUPPORTED -#define PNG_READ_tEXt_SUPPORTED -#define PNG_READ_tIME_SUPPORTED -#define PNG_READ_tRNS_SUPPORTED -#define PNG_READ_zTXt_SUPPORTED -/*#undef PNG_SAVE_INT_32_SUPPORTED*/ -#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_SEQUENTIAL_READ_SUPPORTED -#define PNG_SETJMP_SUPPORTED -#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED -#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED -#define PNG_SET_OPTION_SUPPORTED -#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_SET_USER_LIMITS_SUPPORTED -/*#undef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED*/ -/*#undef PNG_SIMPLIFIED_READ_BGR_SUPPORTED*/ -/*#undef PNG_SIMPLIFIED_READ_SUPPORTED*/ -/*#undef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED*/ -/*#undef PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED*/ -/*#undef PNG_SIMPLIFIED_WRITE_SUPPORTED*/ -#define PNG_STDIO_SUPPORTED -#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_TEXT_SUPPORTED -#define PNG_TIME_RFC1123_SUPPORTED -#define PNG_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_USER_CHUNKS_SUPPORTED -#define PNG_USER_LIMITS_SUPPORTED -#define PNG_USER_MEM_SUPPORTED -#define PNG_USER_TRANSFORM_INFO_SUPPORTED -#define PNG_USER_TRANSFORM_PTR_SUPPORTED -/*#undef PNG_WARNINGS_SUPPORTED*/ -/*#undef PNG_WRITE_16BIT_SUPPORTED*/ -/*#undef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED*/ -/*#undef PNG_WRITE_BGR_SUPPORTED*/ -/*#undef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED*/ -/*#undef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED*/ -/*#undef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED*/ -/*#undef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED*/ -/*#undef PNG_WRITE_FILLER_SUPPORTED*/ -/*#undef PNG_WRITE_FILTER_SUPPORTED*/ -/*#undef PNG_WRITE_FLUSH_SUPPORTED*/ -/*#undef PNG_WRITE_GET_PALETTE_MAX_SUPPORTED*/ -/*#undef PNG_WRITE_INTERLACING_SUPPORTED*/ -/*#undef PNG_WRITE_INT_FUNCTIONS_SUPPORTED*/ -/*#undef PNG_WRITE_INVERT_ALPHA_SUPPORTED*/ -/*#undef PNG_WRITE_INVERT_SUPPORTED*/ -/*#undef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED*/ -/*#undef PNG_WRITE_PACKSWAP_SUPPORTED*/ -/*#undef PNG_WRITE_PACK_SUPPORTED*/ -/*#undef PNG_WRITE_SHIFT_SUPPORTED*/ -/*#undef PNG_WRITE_SUPPORTED*/ -/*#undef PNG_WRITE_SWAP_ALPHA_SUPPORTED*/ -/*#undef PNG_WRITE_SWAP_SUPPORTED*/ -/*#undef PNG_WRITE_TEXT_SUPPORTED*/ -/*#undef PNG_WRITE_TRANSFORMS_SUPPORTED*/ -/*#undef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED*/ -/*#undef PNG_WRITE_USER_TRANSFORM_SUPPORTED*/ -/*#undef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED*/ -/*#undef PNG_WRITE_bKGD_SUPPORTED*/ -/*#undef PNG_WRITE_cHRM_SUPPORTED*/ -/*#undef PNG_WRITE_gAMA_SUPPORTED*/ -/*#undef PNG_WRITE_hIST_SUPPORTED*/ -/*#undef PNG_WRITE_iCCP_SUPPORTED*/ -/*#undef PNG_WRITE_iTXt_SUPPORTED*/ -/*#undef PNG_WRITE_oFFs_SUPPORTED*/ -/*#undef PNG_WRITE_pCAL_SUPPORTED*/ -/*#undef PNG_WRITE_pHYs_SUPPORTED*/ -/*#undef PNG_WRITE_sBIT_SUPPORTED*/ -/*#undef PNG_WRITE_sCAL_SUPPORTED*/ -/*#undef PNG_WRITE_sPLT_SUPPORTED*/ -/*#undef PNG_WRITE_sRGB_SUPPORTED*/ -/*#undef PNG_WRITE_tEXt_SUPPORTED*/ -/*#undef PNG_WRITE_tIME_SUPPORTED*/ -/*#undef PNG_WRITE_tRNS_SUPPORTED*/ -/*#undef PNG_WRITE_zTXt_SUPPORTED*/ -#define PNG_bKGD_SUPPORTED -#define PNG_cHRM_SUPPORTED -#define PNG_gAMA_SUPPORTED -#define PNG_hIST_SUPPORTED -#define PNG_iCCP_SUPPORTED -#define PNG_iTXt_SUPPORTED -#define PNG_oFFs_SUPPORTED -#define PNG_pCAL_SUPPORTED -#define PNG_pHYs_SUPPORTED -#define PNG_sBIT_SUPPORTED -#define PNG_sCAL_SUPPORTED -#define PNG_sPLT_SUPPORTED -#define PNG_sRGB_SUPPORTED -#define PNG_tEXt_SUPPORTED -#define PNG_tIME_SUPPORTED -#define PNG_tRNS_SUPPORTED -#define PNG_zTXt_SUPPORTED -/* end of options */ -/* settings */ -#define PNG_API_RULE 0 -#define PNG_COST_SHIFT 3 -#define PNG_DEFAULT_READ_MACROS 1 -#define PNG_GAMMA_THRESHOLD_FIXED 5000 -#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE -#define PNG_INFLATE_BUF_SIZE 1024 -#define PNG_MAX_GAMMA_8 11 -#define PNG_QUANTIZE_BLUE_BITS 5 -#define PNG_QUANTIZE_GREEN_BITS 5 -#define PNG_QUANTIZE_RED_BITS 5 -#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1) -#define PNG_TEXT_Z_DEFAULT_STRATEGY 0 -#define PNG_USER_CHUNK_CACHE_MAX 1000 -#define PNG_USER_CHUNK_MALLOC_MAX 8000000 -#define PNG_USER_HEIGHT_MAX 1000000 -#define PNG_USER_WIDTH_MAX 1000000 -#define PNG_WEIGHT_SHIFT 8 -#define PNG_ZBUF_SIZE 8192 -#define PNG_ZLIB_VERNUM 0 /* unknown */ -#define PNG_Z_DEFAULT_COMPRESSION (-1) -#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0 -#define PNG_Z_DEFAULT_STRATEGY 1 -#define PNG_sCAL_PRECISION 5 -#define PNG_sRGB_PROFILE_CHECKS 2 -/* end of settings */ - -#define PNG_LINKAGE_API -#define PNG_LINKAGE_FUNCTION - -#ifdef PNG_WRITE_SUPPORTED -#define PNG_SAVE_INT_32_SUPPORTED -#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED -#endif - - -#endif /* PNGLCONF_H */ diff --git a/oversampling/WDL/libpng/pnglibconf.h.prebuilt b/oversampling/WDL/libpng/pnglibconf.h.prebuilt deleted file mode 100644 index 1962067..0000000 --- a/oversampling/WDL/libpng/pnglibconf.h.prebuilt +++ /dev/null @@ -1,214 +0,0 @@ -/* libpng 1.6.17 STANDARD API DEFINITION */ - -/* pnglibconf.h - library build configuration */ - -/* Libpng version 1.6.17 - March 26, 2015 */ - -/* Copyright (c) 1998-2014 Glenn Randers-Pehrson */ - -/* This code is released under the libpng license. */ -/* For conditions of distribution and use, see the disclaimer */ -/* and license in png.h */ - -/* pnglibconf.h */ -/* Machine generated file: DO NOT EDIT */ -/* Derived from: scripts/pnglibconf.dfa */ -#ifndef PNGLCONF_H -#define PNGLCONF_H -/* options */ -#define PNG_16BIT_SUPPORTED -#define PNG_ALIGNED_MEMORY_SUPPORTED -/*#undef PNG_ARM_NEON_API_SUPPORTED*/ -/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/ -#define PNG_BENIGN_ERRORS_SUPPORTED -#define PNG_BENIGN_READ_ERRORS_SUPPORTED -/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/ -#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED -#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED -#define PNG_COLORSPACE_SUPPORTED -#define PNG_CONSOLE_IO_SUPPORTED -#define PNG_CONVERT_tIME_SUPPORTED -#define PNG_EASY_ACCESS_SUPPORTED -/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ -#define PNG_ERROR_TEXT_SUPPORTED -#define PNG_FIXED_POINT_SUPPORTED -#define PNG_FLOATING_ARITHMETIC_SUPPORTED -#define PNG_FLOATING_POINT_SUPPORTED -#define PNG_FORMAT_AFIRST_SUPPORTED -#define PNG_FORMAT_BGR_SUPPORTED -#define PNG_GAMMA_SUPPORTED -#define PNG_GET_PALETTE_MAX_SUPPORTED -#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -#define PNG_INCH_CONVERSIONS_SUPPORTED -#define PNG_INFO_IMAGE_SUPPORTED -#define PNG_IO_STATE_SUPPORTED -#define PNG_MNG_FEATURES_SUPPORTED -#define PNG_POINTER_INDEXING_SUPPORTED -#define PNG_PROGRESSIVE_READ_SUPPORTED -#define PNG_READ_16BIT_SUPPORTED -#define PNG_READ_ALPHA_MODE_SUPPORTED -#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED -#define PNG_READ_BACKGROUND_SUPPORTED -#define PNG_READ_BGR_SUPPORTED -#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED -#define PNG_READ_COMPOSITE_NODIV_SUPPORTED -#define PNG_READ_COMPRESSED_TEXT_SUPPORTED -#define PNG_READ_EXPAND_16_SUPPORTED -#define PNG_READ_EXPAND_SUPPORTED -#define PNG_READ_FILLER_SUPPORTED -#define PNG_READ_GAMMA_SUPPORTED -#define PNG_READ_GET_PALETTE_MAX_SUPPORTED -#define PNG_READ_GRAY_TO_RGB_SUPPORTED -#define PNG_READ_INTERLACING_SUPPORTED -#define PNG_READ_INT_FUNCTIONS_SUPPORTED -#define PNG_READ_INVERT_ALPHA_SUPPORTED -#define PNG_READ_INVERT_SUPPORTED -#define PNG_READ_OPT_PLTE_SUPPORTED -#define PNG_READ_PACKSWAP_SUPPORTED -#define PNG_READ_PACK_SUPPORTED -#define PNG_READ_QUANTIZE_SUPPORTED -#define PNG_READ_RGB_TO_GRAY_SUPPORTED -#define PNG_READ_SCALE_16_TO_8_SUPPORTED -#define PNG_READ_SHIFT_SUPPORTED -#define PNG_READ_STRIP_16_TO_8_SUPPORTED -#define PNG_READ_STRIP_ALPHA_SUPPORTED -#define PNG_READ_SUPPORTED -#define PNG_READ_SWAP_ALPHA_SUPPORTED -#define PNG_READ_SWAP_SUPPORTED -#define PNG_READ_TEXT_SUPPORTED -#define PNG_READ_TRANSFORMS_SUPPORTED -#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_READ_USER_CHUNKS_SUPPORTED -#define PNG_READ_USER_TRANSFORM_SUPPORTED -#define PNG_READ_bKGD_SUPPORTED -#define PNG_READ_cHRM_SUPPORTED -#define PNG_READ_gAMA_SUPPORTED -#define PNG_READ_hIST_SUPPORTED -#define PNG_READ_iCCP_SUPPORTED -#define PNG_READ_iTXt_SUPPORTED -#define PNG_READ_oFFs_SUPPORTED -#define PNG_READ_pCAL_SUPPORTED -#define PNG_READ_pHYs_SUPPORTED -#define PNG_READ_sBIT_SUPPORTED -#define PNG_READ_sCAL_SUPPORTED -#define PNG_READ_sPLT_SUPPORTED -#define PNG_READ_sRGB_SUPPORTED -#define PNG_READ_tEXt_SUPPORTED -#define PNG_READ_tIME_SUPPORTED -#define PNG_READ_tRNS_SUPPORTED -#define PNG_READ_zTXt_SUPPORTED -#define PNG_SAVE_INT_32_SUPPORTED -#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_SEQUENTIAL_READ_SUPPORTED -#define PNG_SETJMP_SUPPORTED -#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED -#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED -#define PNG_SET_OPTION_SUPPORTED -#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_SET_USER_LIMITS_SUPPORTED -#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED -#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED -#define PNG_SIMPLIFIED_READ_SUPPORTED -#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED -#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED -#define PNG_SIMPLIFIED_WRITE_SUPPORTED -#define PNG_STDIO_SUPPORTED -#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_TEXT_SUPPORTED -#define PNG_TIME_RFC1123_SUPPORTED -#define PNG_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_USER_CHUNKS_SUPPORTED -#define PNG_USER_LIMITS_SUPPORTED -#define PNG_USER_MEM_SUPPORTED -#define PNG_USER_TRANSFORM_INFO_SUPPORTED -#define PNG_USER_TRANSFORM_PTR_SUPPORTED -#define PNG_WARNINGS_SUPPORTED -#define PNG_WRITE_16BIT_SUPPORTED -#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED -#define PNG_WRITE_BGR_SUPPORTED -#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED -#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED -#define PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED -#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED -#define PNG_WRITE_FILLER_SUPPORTED -#define PNG_WRITE_FILTER_SUPPORTED -#define PNG_WRITE_FLUSH_SUPPORTED -#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED -#define PNG_WRITE_INTERLACING_SUPPORTED -#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED -#define PNG_WRITE_INVERT_ALPHA_SUPPORTED -#define PNG_WRITE_INVERT_SUPPORTED -#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED -#define PNG_WRITE_PACKSWAP_SUPPORTED -#define PNG_WRITE_PACK_SUPPORTED -#define PNG_WRITE_SHIFT_SUPPORTED -#define PNG_WRITE_SUPPORTED -#define PNG_WRITE_SWAP_ALPHA_SUPPORTED -#define PNG_WRITE_SWAP_SUPPORTED -#define PNG_WRITE_TEXT_SUPPORTED -#define PNG_WRITE_TRANSFORMS_SUPPORTED -#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_WRITE_USER_TRANSFORM_SUPPORTED -#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED -#define PNG_WRITE_bKGD_SUPPORTED -#define PNG_WRITE_cHRM_SUPPORTED -#define PNG_WRITE_gAMA_SUPPORTED -#define PNG_WRITE_hIST_SUPPORTED -#define PNG_WRITE_iCCP_SUPPORTED -#define PNG_WRITE_iTXt_SUPPORTED -#define PNG_WRITE_oFFs_SUPPORTED -#define PNG_WRITE_pCAL_SUPPORTED -#define PNG_WRITE_pHYs_SUPPORTED -#define PNG_WRITE_sBIT_SUPPORTED -#define PNG_WRITE_sCAL_SUPPORTED -#define PNG_WRITE_sPLT_SUPPORTED -#define PNG_WRITE_sRGB_SUPPORTED -#define PNG_WRITE_tEXt_SUPPORTED -#define PNG_WRITE_tIME_SUPPORTED -#define PNG_WRITE_tRNS_SUPPORTED -#define PNG_WRITE_zTXt_SUPPORTED -#define PNG_bKGD_SUPPORTED -#define PNG_cHRM_SUPPORTED -#define PNG_gAMA_SUPPORTED -#define PNG_hIST_SUPPORTED -#define PNG_iCCP_SUPPORTED -#define PNG_iTXt_SUPPORTED -#define PNG_oFFs_SUPPORTED -#define PNG_pCAL_SUPPORTED -#define PNG_pHYs_SUPPORTED -#define PNG_sBIT_SUPPORTED -#define PNG_sCAL_SUPPORTED -#define PNG_sPLT_SUPPORTED -#define PNG_sRGB_SUPPORTED -#define PNG_tEXt_SUPPORTED -#define PNG_tIME_SUPPORTED -#define PNG_tRNS_SUPPORTED -#define PNG_zTXt_SUPPORTED -/* end of options */ -/* settings */ -#define PNG_API_RULE 0 -#define PNG_COST_SHIFT 3 -#define PNG_DEFAULT_READ_MACROS 1 -#define PNG_GAMMA_THRESHOLD_FIXED 5000 -#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE -#define PNG_INFLATE_BUF_SIZE 1024 -#define PNG_MAX_GAMMA_8 11 -#define PNG_QUANTIZE_BLUE_BITS 5 -#define PNG_QUANTIZE_GREEN_BITS 5 -#define PNG_QUANTIZE_RED_BITS 5 -#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1) -#define PNG_TEXT_Z_DEFAULT_STRATEGY 0 -#define PNG_USER_CHUNK_CACHE_MAX 1000 -#define PNG_USER_CHUNK_MALLOC_MAX 8000000 -#define PNG_USER_HEIGHT_MAX 1000000 -#define PNG_USER_WIDTH_MAX 1000000 -#define PNG_WEIGHT_SHIFT 8 -#define PNG_ZBUF_SIZE 8192 -#define PNG_ZLIB_VERNUM 0 /* unknown */ -#define PNG_Z_DEFAULT_COMPRESSION (-1) -#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0 -#define PNG_Z_DEFAULT_STRATEGY 1 -#define PNG_sCAL_PRECISION 5 -#define PNG_sRGB_PROFILE_CHECKS 2 -/* end of settings */ -#endif /* PNGLCONF_H */ diff --git a/oversampling/WDL/libpng/pngmem.c b/oversampling/WDL/libpng/pngmem.c deleted file mode 100644 index 09ed9c1..0000000 --- a/oversampling/WDL/libpng/pngmem.c +++ /dev/null @@ -1,284 +0,0 @@ - -/* pngmem.c - stub functions for memory allocation - * - * Copyright (c) 2018 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * - * This file provides a location for all memory allocation. Users who - * need special memory handling are expected to supply replacement - * functions for png_malloc() and png_free(), and to use - * png_create_read_struct_2() and png_create_write_struct_2() to - * identify the replacement functions. - */ - -#include "pngpriv.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) -/* Free a png_struct */ -void /* PRIVATE */ -png_destroy_png_struct(png_structrp png_ptr) -{ - if (png_ptr != NULL) - { - /* png_free might call png_error and may certainly call - * png_get_mem_ptr, so fake a temporary png_struct to support this. - */ - png_struct dummy_struct = *png_ptr; - memset(png_ptr, 0, (sizeof *png_ptr)); - png_free(&dummy_struct, png_ptr); - -# ifdef PNG_SETJMP_SUPPORTED - /* We may have a jmp_buf left to deallocate. */ - png_free_jmpbuf(&dummy_struct); -# endif - } -} - -/* Allocate memory. For reasonable files, size should never exceed - * 64K. However, zlib may allocate more than 64K if you don't tell - * it not to. See zconf.h and png.h for more information. zlib does - * need to allocate exactly 64K, so whatever you call here must - * have the ability to do that. - */ -PNG_FUNCTION(png_voidp,PNGAPI -png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) -{ - png_voidp ret; - - ret = png_malloc(png_ptr, size); - - if (ret != NULL) - memset(ret, 0, size); - - return ret; -} - -/* png_malloc_base, an internal function added at libpng 1.6.0, does the work of - * allocating memory, taking into account limits and PNG_USER_MEM_SUPPORTED. - * Checking and error handling must happen outside this routine; it returns NULL - * if the allocation cannot be done (for any reason.) - */ -PNG_FUNCTION(png_voidp /* PRIVATE */, -png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size), - PNG_ALLOCATED) -{ - /* Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS - * allocators have also been removed in 1.6.0, so any 16-bit system now has - * to implement a user memory handler. This checks to be sure it isn't - * called with big numbers. - */ -#ifndef PNG_USER_MEM_SUPPORTED - PNG_UNUSED(png_ptr) -#endif - - /* Some compilers complain that this is always true. However, it - * can be false when integer overflow happens. - */ - if (size > 0 && size <= PNG_SIZE_MAX -# ifdef PNG_MAX_MALLOC_64K - && size <= 65536U -# endif - ) - { -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr != NULL && png_ptr->malloc_fn != NULL) - return png_ptr->malloc_fn(png_constcast(png_structrp,png_ptr), size); - - else -#endif - return malloc((size_t)size); /* checked for truncation above */ - } - - else - return NULL; -} - -#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\ - defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) -/* This is really here only to work round a spurious warning in GCC 4.6 and 4.7 - * that arises because of the checks in png_realloc_array that are repeated in - * png_malloc_array. - */ -static png_voidp -png_malloc_array_checked(png_const_structrp png_ptr, int nelements, - size_t element_size) -{ - png_alloc_size_t req = (png_alloc_size_t)nelements; /* known to be > 0 */ - - if (req <= PNG_SIZE_MAX/element_size) - return png_malloc_base(png_ptr, req * element_size); - - /* The failure case when the request is too large */ - return NULL; -} - -PNG_FUNCTION(png_voidp /* PRIVATE */, -png_malloc_array,(png_const_structrp png_ptr, int nelements, - size_t element_size),PNG_ALLOCATED) -{ - if (nelements <= 0 || element_size == 0) - png_error(png_ptr, "internal error: array alloc"); - - return png_malloc_array_checked(png_ptr, nelements, element_size); -} - -PNG_FUNCTION(png_voidp /* PRIVATE */, -png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array, - int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED) -{ - /* These are internal errors: */ - if (add_elements <= 0 || element_size == 0 || old_elements < 0 || - (old_array == NULL && old_elements > 0)) - png_error(png_ptr, "internal error: array realloc"); - - /* Check for overflow on the elements count (so the caller does not have to - * check.) - */ - if (add_elements <= INT_MAX - old_elements) - { - png_voidp new_array = png_malloc_array_checked(png_ptr, - old_elements+add_elements, element_size); - - if (new_array != NULL) - { - /* Because png_malloc_array worked the size calculations below cannot - * overflow. - */ - if (old_elements > 0) - memcpy(new_array, old_array, element_size*(unsigned)old_elements); - - memset((char*)new_array + element_size*(unsigned)old_elements, 0, - element_size*(unsigned)add_elements); - - return new_array; - } - } - - return NULL; /* error */ -} -#endif /* TEXT || sPLT || STORE_UNKNOWN_CHUNKS */ - -/* Various functions that have different error handling are derived from this. - * png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate - * function png_malloc_default is also provided. - */ -PNG_FUNCTION(png_voidp,PNGAPI -png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) -{ - png_voidp ret; - - if (png_ptr == NULL) - return NULL; - - ret = png_malloc_base(png_ptr, size); - - if (ret == NULL) - png_error(png_ptr, "Out of memory"); /* 'm' means png_malloc */ - - return ret; -} - -#ifdef PNG_USER_MEM_SUPPORTED -PNG_FUNCTION(png_voidp,PNGAPI -png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size), - PNG_ALLOCATED PNG_DEPRECATED) -{ - png_voidp ret; - - if (png_ptr == NULL) - return NULL; - - /* Passing 'NULL' here bypasses the application provided memory handler. */ - ret = png_malloc_base(NULL/*use malloc*/, size); - - if (ret == NULL) - png_error(png_ptr, "Out of Memory"); /* 'M' means png_malloc_default */ - - return ret; -} -#endif /* USER_MEM */ - -/* This function was added at libpng version 1.2.3. The png_malloc_warn() - * function will issue a png_warning and return NULL instead of issuing a - * png_error, if it fails to allocate the requested memory. - */ -PNG_FUNCTION(png_voidp,PNGAPI -png_malloc_warn,(png_const_structrp png_ptr, png_alloc_size_t size), - PNG_ALLOCATED) -{ - if (png_ptr != NULL) - { - png_voidp ret = png_malloc_base(png_ptr, size); - - if (ret != NULL) - return ret; - - png_warning(png_ptr, "Out of memory"); - } - - return NULL; -} - -/* Free a pointer allocated by png_malloc(). If ptr is NULL, return - * without taking any action. - */ -void PNGAPI -png_free(png_const_structrp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL || ptr == NULL) - return; - -#ifdef PNG_USER_MEM_SUPPORTED - if (png_ptr->free_fn != NULL) - png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr); - - else - png_free_default(png_ptr, ptr); -} - -PNG_FUNCTION(void,PNGAPI -png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED) -{ - if (png_ptr == NULL || ptr == NULL) - return; -#endif /* USER_MEM */ - - free(ptr); -} - -#ifdef PNG_USER_MEM_SUPPORTED -/* This function is called when the application wants to use another method - * of allocating and freeing memory. - */ -void PNGAPI -png_set_mem_fn(png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr - malloc_fn, png_free_ptr free_fn) -{ - if (png_ptr != NULL) - { - png_ptr->mem_ptr = mem_ptr; - png_ptr->malloc_fn = malloc_fn; - png_ptr->free_fn = free_fn; - } -} - -/* This function returns a pointer to the mem_ptr associated with the user - * functions. The application should free any memory associated with this - * pointer before png_write_destroy and png_read_destroy are called. - */ -png_voidp PNGAPI -png_get_mem_ptr(png_const_structrp png_ptr) -{ - if (png_ptr == NULL) - return NULL; - - return png_ptr->mem_ptr; -} -#endif /* USER_MEM */ -#endif /* READ || WRITE */ diff --git a/oversampling/WDL/libpng/pngpread.c b/oversampling/WDL/libpng/pngpread.c deleted file mode 100644 index e283627..0000000 --- a/oversampling/WDL/libpng/pngpread.c +++ /dev/null @@ -1,1096 +0,0 @@ - -/* pngpread.c - read a png file in push mode - * - * Copyright (c) 2018 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - */ - -#include "pngpriv.h" - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - -/* Push model modes */ -#define PNG_READ_SIG_MODE 0 -#define PNG_READ_CHUNK_MODE 1 -#define PNG_READ_IDAT_MODE 2 -#define PNG_READ_tEXt_MODE 4 -#define PNG_READ_zTXt_MODE 5 -#define PNG_READ_DONE_MODE 6 -#define PNG_READ_iTXt_MODE 7 -#define PNG_ERROR_MODE 8 - -#define PNG_PUSH_SAVE_BUFFER_IF_FULL \ -if (png_ptr->push_length + 4 > png_ptr->buffer_size) \ - { png_push_save_buffer(png_ptr); return; } -#define PNG_PUSH_SAVE_BUFFER_IF_LT(N) \ -if (png_ptr->buffer_size < N) \ - { png_push_save_buffer(png_ptr); return; } - -void PNGAPI -png_process_data(png_structrp png_ptr, png_inforp info_ptr, - png_bytep buffer, size_t buffer_size) -{ - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_push_restore_buffer(png_ptr, buffer, buffer_size); - - while (png_ptr->buffer_size) - { - png_process_some_data(png_ptr, info_ptr); - } -} - -size_t PNGAPI -png_process_data_pause(png_structrp png_ptr, int save) -{ - if (png_ptr != NULL) - { - /* It's easiest for the caller if we do the save; then the caller doesn't - * have to supply the same data again: - */ - if (save != 0) - png_push_save_buffer(png_ptr); - else - { - /* This includes any pending saved bytes: */ - size_t remaining = png_ptr->buffer_size; - png_ptr->buffer_size = 0; - - /* So subtract the saved buffer size, unless all the data - * is actually 'saved', in which case we just return 0 - */ - if (png_ptr->save_buffer_size < remaining) - return remaining - png_ptr->save_buffer_size; - } - } - - return 0; -} - -png_uint_32 PNGAPI -png_process_data_skip(png_structrp png_ptr) -{ -/* TODO: Deprecate and remove this API. - * Somewhere the implementation of this seems to have been lost, - * or abandoned. It was only to support some internal back-door access - * to png_struct) in libpng-1.4.x. - */ - png_app_warning(png_ptr, -"png_process_data_skip is not implemented in any current version of libpng"); - return 0; -} - -/* What we do with the incoming data depends on what we were previously - * doing before we ran out of data... - */ -void /* PRIVATE */ -png_process_some_data(png_structrp png_ptr, png_inforp info_ptr) -{ - if (png_ptr == NULL) - return; - - switch (png_ptr->process_mode) - { - case PNG_READ_SIG_MODE: - { - png_push_read_sig(png_ptr, info_ptr); - break; - } - - case PNG_READ_CHUNK_MODE: - { - png_push_read_chunk(png_ptr, info_ptr); - break; - } - - case PNG_READ_IDAT_MODE: - { - png_push_read_IDAT(png_ptr); - break; - } - - default: - { - png_ptr->buffer_size = 0; - break; - } - } -} - -/* Read any remaining signature bytes from the stream and compare them with - * the correct PNG signature. It is possible that this routine is called - * with bytes already read from the signature, either because they have been - * checked by the calling application, or because of multiple calls to this - * routine. - */ -void /* PRIVATE */ -png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr) -{ - size_t num_checked = png_ptr->sig_bytes; /* SAFE, does not exceed 8 */ - size_t num_to_check = 8 - num_checked; - - if (png_ptr->buffer_size < num_to_check) - { - num_to_check = png_ptr->buffer_size; - } - - png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]), - num_to_check); - png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes + num_to_check); - - if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) - { - if (num_checked < 4 && - png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) - png_error(png_ptr, "Not a PNG file"); - - else - png_error(png_ptr, "PNG file corrupted by ASCII conversion"); - } - else - { - if (png_ptr->sig_bytes >= 8) - { - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - } - } -} - -void /* PRIVATE */ -png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) -{ - png_uint_32 chunk_name; -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - int keep; /* unknown handling method */ -#endif - - /* First we make sure we have enough data for the 4-byte chunk name - * and the 4-byte chunk length before proceeding with decoding the - * chunk data. To fully decode each of these chunks, we also make - * sure we have enough data in the buffer for the 4-byte CRC at the - * end of every chunk (except IDAT, which is handled separately). - */ - if ((png_ptr->mode & PNG_HAVE_CHUNK_HEADER) == 0) - { - png_byte chunk_length[4]; - png_byte chunk_tag[4]; - - PNG_PUSH_SAVE_BUFFER_IF_LT(8) - png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, chunk_tag, 4); - png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag); - png_check_chunk_name(png_ptr, png_ptr->chunk_name); - png_check_chunk_length(png_ptr, png_ptr->push_length); - png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; - } - - chunk_name = png_ptr->chunk_name; - - if (chunk_name == png_IDAT) - { - if ((png_ptr->mode & PNG_AFTER_IDAT) != 0) - png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; - - /* If we reach an IDAT chunk, this means we have read all of the - * header chunks, and we can start reading the image (or if this - * is called after the image has been read - we have an error). - */ - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_error(png_ptr, "Missing IHDR before IDAT"); - - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - (png_ptr->mode & PNG_HAVE_PLTE) == 0) - png_error(png_ptr, "Missing PLTE before IDAT"); - - png_ptr->process_mode = PNG_READ_IDAT_MODE; - - if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) - if ((png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) == 0) - if (png_ptr->push_length == 0) - return; - - png_ptr->mode |= PNG_HAVE_IDAT; - - if ((png_ptr->mode & PNG_AFTER_IDAT) != 0) - png_benign_error(png_ptr, "Too many IDATs found"); - } - - if (chunk_name == png_IHDR) - { - if (png_ptr->push_length != 13) - png_error(png_ptr, "Invalid IHDR length"); - - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length); - } - - else if (chunk_name == png_IEND) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length); - - png_ptr->process_mode = PNG_READ_DONE_MODE; - png_push_have_end(png_ptr, info_ptr); - } - -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, keep); - - if (chunk_name == png_PLTE) - png_ptr->mode |= PNG_HAVE_PLTE; - } -#endif - - else if (chunk_name == png_PLTE) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length); - } - - else if (chunk_name == png_IDAT) - { - png_ptr->idat_size = png_ptr->push_length; - png_ptr->process_mode = PNG_READ_IDAT_MODE; - png_push_have_info(png_ptr, info_ptr); - png_ptr->zstream.avail_out = - (uInt) PNG_ROWBYTES(png_ptr->pixel_depth, - png_ptr->iwidth) + 1; - png_ptr->zstream.next_out = png_ptr->row_buf; - return; - } - -#ifdef PNG_READ_gAMA_SUPPORTED - else if (png_ptr->chunk_name == png_gAMA) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length); - } - -#endif -#ifdef PNG_READ_sBIT_SUPPORTED - else if (png_ptr->chunk_name == png_sBIT) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length); - } - -#endif -#ifdef PNG_READ_cHRM_SUPPORTED - else if (png_ptr->chunk_name == png_cHRM) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); - } - -#endif -#ifdef PNG_READ_sRGB_SUPPORTED - else if (chunk_name == png_sRGB) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length); - } - -#endif -#ifdef PNG_READ_iCCP_SUPPORTED - else if (png_ptr->chunk_name == png_iCCP) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length); - } - -#endif -#ifdef PNG_READ_sPLT_SUPPORTED - else if (chunk_name == png_sPLT) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length); - } - -#endif -#ifdef PNG_READ_tRNS_SUPPORTED - else if (chunk_name == png_tRNS) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length); - } - -#endif -#ifdef PNG_READ_bKGD_SUPPORTED - else if (chunk_name == png_bKGD) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length); - } - -#endif -#ifdef PNG_READ_hIST_SUPPORTED - else if (chunk_name == png_hIST) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length); - } - -#endif -#ifdef PNG_READ_pHYs_SUPPORTED - else if (chunk_name == png_pHYs) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length); - } - -#endif -#ifdef PNG_READ_oFFs_SUPPORTED - else if (chunk_name == png_oFFs) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length); - } -#endif - -#ifdef PNG_READ_pCAL_SUPPORTED - else if (chunk_name == png_pCAL) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length); - } - -#endif -#ifdef PNG_READ_sCAL_SUPPORTED - else if (chunk_name == png_sCAL) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length); - } - -#endif -#ifdef PNG_READ_tIME_SUPPORTED - else if (chunk_name == png_tIME) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length); - } - -#endif -#ifdef PNG_READ_tEXt_SUPPORTED - else if (chunk_name == png_tEXt) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); - } - -#endif -#ifdef PNG_READ_zTXt_SUPPORTED - else if (chunk_name == png_zTXt) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); - } - -#endif -#ifdef PNG_READ_iTXt_SUPPORTED - else if (chunk_name == png_iTXt) - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); - } -#endif - - else - { - PNG_PUSH_SAVE_BUFFER_IF_FULL - png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, - PNG_HANDLE_CHUNK_AS_DEFAULT); - } - - png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; -} - -void PNGCBAPI -png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, size_t length) -{ - png_bytep ptr; - - if (png_ptr == NULL) - return; - - ptr = buffer; - if (png_ptr->save_buffer_size != 0) - { - size_t save_size; - - if (length < png_ptr->save_buffer_size) - save_size = length; - - else - save_size = png_ptr->save_buffer_size; - - memcpy(ptr, png_ptr->save_buffer_ptr, save_size); - length -= save_size; - ptr += save_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - if (length != 0 && png_ptr->current_buffer_size != 0) - { - size_t save_size; - - if (length < png_ptr->current_buffer_size) - save_size = length; - - else - save_size = png_ptr->current_buffer_size; - - memcpy(ptr, png_ptr->current_buffer_ptr, save_size); - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } -} - -void /* PRIVATE */ -png_push_save_buffer(png_structrp png_ptr) -{ - if (png_ptr->save_buffer_size != 0) - { - if (png_ptr->save_buffer_ptr != png_ptr->save_buffer) - { - size_t i, istop; - png_bytep sp; - png_bytep dp; - - istop = png_ptr->save_buffer_size; - for (i = 0, sp = png_ptr->save_buffer_ptr, dp = png_ptr->save_buffer; - i < istop; i++, sp++, dp++) - { - *dp = *sp; - } - } - } - if (png_ptr->save_buffer_size + png_ptr->current_buffer_size > - png_ptr->save_buffer_max) - { - size_t new_max; - png_bytep old_buffer; - - if (png_ptr->save_buffer_size > PNG_SIZE_MAX - - (png_ptr->current_buffer_size + 256)) - { - png_error(png_ptr, "Potential overflow of save_buffer"); - } - - new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256; - old_buffer = png_ptr->save_buffer; - png_ptr->save_buffer = (png_bytep)png_malloc_warn(png_ptr, - (size_t)new_max); - - if (png_ptr->save_buffer == NULL) - { - png_free(png_ptr, old_buffer); - png_error(png_ptr, "Insufficient memory for save_buffer"); - } - - if (old_buffer) - memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); - else if (png_ptr->save_buffer_size) - png_error(png_ptr, "save_buffer error"); - png_free(png_ptr, old_buffer); - png_ptr->save_buffer_max = new_max; - } - if (png_ptr->current_buffer_size) - { - memcpy(png_ptr->save_buffer + png_ptr->save_buffer_size, - png_ptr->current_buffer_ptr, png_ptr->current_buffer_size); - png_ptr->save_buffer_size += png_ptr->current_buffer_size; - png_ptr->current_buffer_size = 0; - } - png_ptr->save_buffer_ptr = png_ptr->save_buffer; - png_ptr->buffer_size = 0; -} - -void /* PRIVATE */ -png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer, - size_t buffer_length) -{ - png_ptr->current_buffer = buffer; - png_ptr->current_buffer_size = buffer_length; - png_ptr->buffer_size = buffer_length + png_ptr->save_buffer_size; - png_ptr->current_buffer_ptr = png_ptr->current_buffer; -} - -void /* PRIVATE */ -png_push_read_IDAT(png_structrp png_ptr) -{ - if ((png_ptr->mode & PNG_HAVE_CHUNK_HEADER) == 0) - { - png_byte chunk_length[4]; - png_byte chunk_tag[4]; - - /* TODO: this code can be commoned up with the same code in push_read */ - PNG_PUSH_SAVE_BUFFER_IF_LT(8) - png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length); - png_reset_crc(png_ptr); - png_crc_read(png_ptr, chunk_tag, 4); - png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag); - png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; - - if (png_ptr->chunk_name != png_IDAT) - { - png_ptr->process_mode = PNG_READ_CHUNK_MODE; - - if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0) - png_error(png_ptr, "Not enough compressed data"); - - return; - } - - png_ptr->idat_size = png_ptr->push_length; - } - - if (png_ptr->idat_size != 0 && png_ptr->save_buffer_size != 0) - { - size_t save_size = png_ptr->save_buffer_size; - png_uint_32 idat_size = png_ptr->idat_size; - - /* We want the smaller of 'idat_size' and 'current_buffer_size', but they - * are of different types and we don't know which variable has the fewest - * bits. Carefully select the smaller and cast it to the type of the - * larger - this cannot overflow. Do not cast in the following test - it - * will break on either 16-bit or 64-bit platforms. - */ - if (idat_size < save_size) - save_size = (size_t)idat_size; - - else - idat_size = (png_uint_32)save_size; - - png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); - - png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size); - - png_ptr->idat_size -= idat_size; - png_ptr->buffer_size -= save_size; - png_ptr->save_buffer_size -= save_size; - png_ptr->save_buffer_ptr += save_size; - } - - if (png_ptr->idat_size != 0 && png_ptr->current_buffer_size != 0) - { - size_t save_size = png_ptr->current_buffer_size; - png_uint_32 idat_size = png_ptr->idat_size; - - /* We want the smaller of 'idat_size' and 'current_buffer_size', but they - * are of different types and we don't know which variable has the fewest - * bits. Carefully select the smaller and cast it to the type of the - * larger - this cannot overflow. - */ - if (idat_size < save_size) - save_size = (size_t)idat_size; - - else - idat_size = (png_uint_32)save_size; - - png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size); - - png_process_IDAT_data(png_ptr, png_ptr->current_buffer_ptr, save_size); - - png_ptr->idat_size -= idat_size; - png_ptr->buffer_size -= save_size; - png_ptr->current_buffer_size -= save_size; - png_ptr->current_buffer_ptr += save_size; - } - - if (png_ptr->idat_size == 0) - { - PNG_PUSH_SAVE_BUFFER_IF_LT(4) - png_crc_finish(png_ptr, 0); - png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->zowner = 0; - } -} - -void /* PRIVATE */ -png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer, - size_t buffer_length) -{ - /* The caller checks for a non-zero buffer length. */ - if (!(buffer_length > 0) || buffer == NULL) - png_error(png_ptr, "No IDAT data (internal error)"); - - /* This routine must process all the data it has been given - * before returning, calling the row callback as required to - * handle the uncompressed results. - */ - png_ptr->zstream.next_in = buffer; - /* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */ - png_ptr->zstream.avail_in = (uInt)buffer_length; - - /* Keep going until the decompressed data is all processed - * or the stream marked as finished. - */ - while (png_ptr->zstream.avail_in > 0 && - (png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0) - { - int ret; - - /* We have data for zlib, but we must check that zlib - * has someplace to put the results. It doesn't matter - * if we don't expect any results -- it may be the input - * data is just the LZ end code. - */ - if (!(png_ptr->zstream.avail_out > 0)) - { - /* TODO: WARNING: TRUNCATION ERROR: DANGER WILL ROBINSON: */ - png_ptr->zstream.avail_out = (uInt)(PNG_ROWBYTES(png_ptr->pixel_depth, - png_ptr->iwidth) + 1); - - png_ptr->zstream.next_out = png_ptr->row_buf; - } - - /* Using Z_SYNC_FLUSH here means that an unterminated - * LZ stream (a stream with a missing end code) can still - * be handled, otherwise (Z_NO_FLUSH) a future zlib - * implementation might defer output and therefore - * change the current behavior (see comments in inflate.c - * for why this doesn't happen at present with zlib 1.2.5). - */ - ret = PNG_INFLATE(png_ptr, Z_SYNC_FLUSH); - - /* Check for any failure before proceeding. */ - if (ret != Z_OK && ret != Z_STREAM_END) - { - /* Terminate the decompression. */ - png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; - png_ptr->zowner = 0; - - /* This may be a truncated stream (missing or - * damaged end code). Treat that as a warning. - */ - if (png_ptr->row_number >= png_ptr->num_rows || - png_ptr->pass > 6) - png_warning(png_ptr, "Truncated compressed data in IDAT"); - - else - { - if (ret == Z_DATA_ERROR) - png_benign_error(png_ptr, "IDAT: ADLER32 checksum mismatch"); - else - png_error(png_ptr, "Decompression error in IDAT"); - } - - /* Skip the check on unprocessed input */ - return; - } - - /* Did inflate output any data? */ - if (png_ptr->zstream.next_out != png_ptr->row_buf) - { - /* Is this unexpected data after the last row? - * If it is, artificially terminate the LZ output - * here. - */ - if (png_ptr->row_number >= png_ptr->num_rows || - png_ptr->pass > 6) - { - /* Extra data. */ - png_warning(png_ptr, "Extra compressed data in IDAT"); - png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; - png_ptr->zowner = 0; - - /* Do no more processing; skip the unprocessed - * input check below. - */ - return; - } - - /* Do we have a complete row? */ - if (png_ptr->zstream.avail_out == 0) - png_push_process_row(png_ptr); - } - - /* And check for the end of the stream. */ - if (ret == Z_STREAM_END) - png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; - } - - /* All the data should have been processed, if anything - * is left at this point we have bytes of IDAT data - * after the zlib end code. - */ - if (png_ptr->zstream.avail_in > 0) - png_warning(png_ptr, "Extra compression data in IDAT"); -} - -void /* PRIVATE */ -png_push_process_row(png_structrp png_ptr) -{ - /* 1.5.6: row_info moved out of png_struct to a local here. */ - png_row_info row_info; - - row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */ - row_info.color_type = png_ptr->color_type; - row_info.bit_depth = png_ptr->bit_depth; - row_info.channels = png_ptr->channels; - row_info.pixel_depth = png_ptr->pixel_depth; - row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width); - - if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE) - { - if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST) - png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1, - png_ptr->prev_row + 1, png_ptr->row_buf[0]); - else - png_error(png_ptr, "bad adaptive filter value"); - } - - /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before - * 1.5.6, while the buffer really is this big in current versions of libpng - * it may not be in the future, so this was changed just to copy the - * interlaced row count: - */ - memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1); - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED - if (png_ptr->transformations != 0) - png_do_read_transformations(png_ptr, &row_info); -#endif - - /* The transformed pixel depth should match the depth now in row_info. */ - if (png_ptr->transformed_pixel_depth == 0) - { - png_ptr->transformed_pixel_depth = row_info.pixel_depth; - if (row_info.pixel_depth > png_ptr->maximum_pixel_depth) - png_error(png_ptr, "progressive row overflow"); - } - - else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth) - png_error(png_ptr, "internal progressive row size calculation error"); - - -#ifdef PNG_READ_INTERLACING_SUPPORTED - /* Expand interlaced rows to full size */ - if (png_ptr->interlaced != 0 && - (png_ptr->transformations & PNG_INTERLACE) != 0) - { - if (png_ptr->pass < 6) - png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass, - png_ptr->transformations); - - switch (png_ptr->pass) - { - case 0: - { - int i; - for (i = 0; i < 8 && png_ptr->pass == 0; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); /* Updates png_ptr->pass */ - } - - if (png_ptr->pass == 2) /* Pass 1 might be empty */ - { - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - } - - if (png_ptr->pass == 4 && png_ptr->height <= 4) - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - } - - if (png_ptr->pass == 6 && png_ptr->height <= 4) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - - break; - } - - case 1: - { - int i; - for (i = 0; i < 8 && png_ptr->pass == 1; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - - if (png_ptr->pass == 2) /* Skip top 4 generated rows */ - { - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - } - - break; - } - - case 2: - { - int i; - - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - - for (i = 0; i < 4 && png_ptr->pass == 2; i++) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - - if (png_ptr->pass == 4) /* Pass 3 might be empty */ - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - } - - break; - } - - case 3: - { - int i; - - for (i = 0; i < 4 && png_ptr->pass == 3; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - - if (png_ptr->pass == 4) /* Skip top two generated rows */ - { - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - } - - break; - } - - case 4: - { - int i; - - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - - for (i = 0; i < 2 && png_ptr->pass == 4; i++) - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - - if (png_ptr->pass == 6) /* Pass 5 might be empty */ - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - - break; - } - - case 5: - { - int i; - - for (i = 0; i < 2 && png_ptr->pass == 5; i++) - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } - - if (png_ptr->pass == 6) /* Skip top generated row */ - { - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - - break; - } - - default: - case 6: - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - - if (png_ptr->pass != 6) - break; - - png_push_have_row(png_ptr, NULL); - png_read_push_finish_row(png_ptr); - } - } - } - else -#endif - { - png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); - } -} - -void /* PRIVATE */ -png_read_push_finish_row(png_structrp png_ptr) -{ -#ifdef PNG_READ_INTERLACING_SUPPORTED - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* Start of interlace block */ - static const png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; - - /* Offset to next interlace block */ - static const png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - - /* Start of interlace block in the y direction */ - static const png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; - - /* Offset to next interlace block in the y direction */ - static const png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; - - /* Height of interlace block. This is not currently used - if you need - * it, uncomment it here and in png.h - static const png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1}; - */ -#endif - - png_ptr->row_number++; - if (png_ptr->row_number < png_ptr->num_rows) - return; - -#ifdef PNG_READ_INTERLACING_SUPPORTED - if (png_ptr->interlaced != 0) - { - png_ptr->row_number = 0; - memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - - do - { - png_ptr->pass++; - if ((png_ptr->pass == 1 && png_ptr->width < 5) || - (png_ptr->pass == 3 && png_ptr->width < 3) || - (png_ptr->pass == 5 && png_ptr->width < 2)) - png_ptr->pass++; - - if (png_ptr->pass > 7) - png_ptr->pass--; - - if (png_ptr->pass >= 7) - break; - - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - if ((png_ptr->transformations & PNG_INTERLACE) != 0) - break; - - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - - } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); - } -#endif /* READ_INTERLACING */ -} - -void /* PRIVATE */ -png_push_have_info(png_structrp png_ptr, png_inforp info_ptr) -{ - if (png_ptr->info_fn != NULL) - (*(png_ptr->info_fn))(png_ptr, info_ptr); -} - -void /* PRIVATE */ -png_push_have_end(png_structrp png_ptr, png_inforp info_ptr) -{ - if (png_ptr->end_fn != NULL) - (*(png_ptr->end_fn))(png_ptr, info_ptr); -} - -void /* PRIVATE */ -png_push_have_row(png_structrp png_ptr, png_bytep row) -{ - if (png_ptr->row_fn != NULL) - (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number, - (int)png_ptr->pass); -} - -#ifdef PNG_READ_INTERLACING_SUPPORTED -void PNGAPI -png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row, - png_const_bytep new_row) -{ - if (png_ptr == NULL) - return; - - /* new_row is a flag here - if it is NULL then the app callback was called - * from an empty row (see the calls to png_struct::row_fn below), otherwise - * it must be png_ptr->row_buf+1 - */ - if (new_row != NULL) - png_combine_row(png_ptr, old_row, 1/*blocky display*/); -} -#endif /* READ_INTERLACING */ - -void PNGAPI -png_set_progressive_read_fn(png_structrp png_ptr, png_voidp progressive_ptr, - png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, - png_progressive_end_ptr end_fn) -{ - if (png_ptr == NULL) - return; - - png_ptr->info_fn = info_fn; - png_ptr->row_fn = row_fn; - png_ptr->end_fn = end_fn; - - png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer); -} - -png_voidp PNGAPI -png_get_progressive_ptr(png_const_structrp png_ptr) -{ - if (png_ptr == NULL) - return (NULL); - - return png_ptr->io_ptr; -} -#endif /* PROGRESSIVE_READ */ diff --git a/oversampling/WDL/libpng/pngpriv.h b/oversampling/WDL/libpng/pngpriv.h deleted file mode 100644 index 76502f2..0000000 --- a/oversampling/WDL/libpng/pngpriv.h +++ /dev/null @@ -1,2152 +0,0 @@ - -/* pngpriv.h - private declarations for use inside libpng - * - * Copyright (c) 2018-2019 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - */ - -/* The symbols declared in this file (including the functions declared - * as extern) are PRIVATE. They are not part of the libpng public - * interface, and are not recommended for use by regular applications. - * Some of them may become public in the future; others may stay private, - * change in an incompatible way, or even disappear. - * Although the libpng users are not forbidden to include this header, - * they should be well aware of the issues that may arise from doing so. - */ - -#ifndef PNGPRIV_H -#define PNGPRIV_H - -/* Feature Test Macros. The following are defined here to ensure that correctly - * implemented libraries reveal the APIs libpng needs to build and hide those - * that are not needed and potentially damaging to the compilation. - * - * Feature Test Macros must be defined before any system header is included (see - * POSIX 1003.1 2.8.2 "POSIX Symbols." - * - * These macros only have an effect if the operating system supports either - * POSIX 1003.1 or C99, or both. On other operating systems (particularly - * Windows/Visual Studio) there is no effect; the OS specific tests below are - * still required (as of 2011-05-02.) - */ -#ifndef _POSIX_SOURCE -# define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */ -#endif - -#ifndef PNG_VERSION_INFO_ONLY -/* Standard library headers not required by png.h: */ -# include -# include -#endif - -#define PNGLIB_BUILD /*libpng is being built, not used*/ - -/* If HAVE_CONFIG_H is defined during the build then the build system must - * provide an appropriate "config.h" file on the include path. The header file - * must provide definitions as required below (search for "HAVE_CONFIG_H"); - * see configure.ac for more details of the requirements. The macro - * "PNG_NO_CONFIG_H" is provided for maintainers to test for dependencies on - * 'configure'; define this macro to prevent the configure build including the - * configure generated config.h. Libpng is expected to compile without *any* - * special build system support on a reasonably ANSI-C compliant system. - */ -#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H) -# include - - /* Pick up the definition of 'restrict' from config.h if it was read: */ -# define PNG_RESTRICT restrict -#endif - -/* To support symbol prefixing it is necessary to know *before* including png.h - * whether the fixed point (and maybe other) APIs are exported, because if they - * are not internal definitions may be required. This is handled below just - * before png.h is included, but load the configuration now if it is available. - */ -#ifndef PNGLCONF_H -# include "pnglibconf.h" -#endif - -/* Local renames may change non-exported API functions from png.h */ -#if defined(PNG_PREFIX) && !defined(PNGPREFIX_H) -# include "pngprefix.h" -#endif - -#ifdef PNG_USER_CONFIG -# include "pngusr.h" - /* These should have been defined in pngusr.h */ -# ifndef PNG_USER_PRIVATEBUILD -# define PNG_USER_PRIVATEBUILD "Custom libpng build" -# endif -# ifndef PNG_USER_DLLFNAME_POSTFIX -# define PNG_USER_DLLFNAME_POSTFIX "Cb" -# endif -#endif - -/* Compile time options. - * ===================== - * In a multi-arch build the compiler may compile the code several times for the - * same object module, producing different binaries for different architectures. - * When this happens configure-time setting of the target host options cannot be - * done and this interferes with the handling of the ARM NEON optimizations, and - * possibly other similar optimizations. Put additional tests here; in general - * this is needed when the same option can be changed at both compile time and - * run time depending on the target OS (i.e. iOS vs Android.) - * - * NOTE: symbol prefixing does not pass $(CFLAGS) to the preprocessor, because - * this is not possible with certain compilers (Oracle SUN OS CC), as a result - * it is necessary to ensure that all extern functions that *might* be used - * regardless of $(CFLAGS) get declared in this file. The test on __ARM_NEON__ - * below is one example of this behavior because it is controlled by the - * presence or not of -mfpu=neon on the GCC command line, it is possible to do - * this in $(CC), e.g. "CC=gcc -mfpu=neon", but people who build libpng rarely - * do this. - */ -#ifndef PNG_ARM_NEON_OPT - /* ARM NEON optimizations are being controlled by the compiler settings, - * typically the target FPU. If the FPU has been set to NEON (-mfpu=neon - * with GCC) then the compiler will define __ARM_NEON__ and we can rely - * unconditionally on NEON instructions not crashing, otherwise we must - * disable use of NEON instructions. - * - * NOTE: at present these optimizations depend on 'ALIGNED_MEMORY', so they - * can only be turned on automatically if that is supported too. If - * PNG_ARM_NEON_OPT is set in CPPFLAGS (to >0) then arm/arm_init.c will fail - * to compile with an appropriate #error if ALIGNED_MEMORY has been turned - * off. - * - * Note that gcc-4.9 defines __ARM_NEON instead of the deprecated - * __ARM_NEON__, so we check both variants. - * - * To disable ARM_NEON optimizations entirely, and skip compiling the - * associated assembler code, pass --enable-arm-neon=no to configure - * or put -DPNG_ARM_NEON_OPT=0 in CPPFLAGS. - */ -# if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && \ - defined(PNG_ALIGNED_MEMORY_SUPPORTED) && 0 // disabled -# define PNG_ARM_NEON_OPT 2 -# else -# define PNG_ARM_NEON_OPT 0 -# endif -#endif - -#if PNG_ARM_NEON_OPT > 0 - /* NEON optimizations are to be at least considered by libpng, so enable the - * callbacks to do this. - */ -# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon - - /* By default the 'intrinsics' code in arm/filter_neon_intrinsics.c is used - * if possible - if __ARM_NEON__ is set and the compiler version is not known - * to be broken. This is controlled by PNG_ARM_NEON_IMPLEMENTATION which can - * be: - * - * 1 The intrinsics code (the default with __ARM_NEON__) - * 2 The hand coded assembler (the default without __ARM_NEON__) - * - * It is possible to set PNG_ARM_NEON_IMPLEMENTATION in CPPFLAGS, however - * this is *NOT* supported and may cease to work even after a minor revision - * to libpng. It *is* valid to do this for testing purposes, e.g. speed - * testing or a new compiler, but the results should be communicated to the - * libpng implementation list for incorporation in the next minor release. - */ -# ifndef PNG_ARM_NEON_IMPLEMENTATION -# if defined(__ARM_NEON__) || defined(__ARM_NEON) -# if defined(__clang__) - /* At present it is unknown by the libpng developers which versions - * of clang support the intrinsics, however some or perhaps all - * versions do not work with the assembler so this may be - * irrelevant, so just use the default (do nothing here.) - */ -# elif defined(__GNUC__) - /* GCC 4.5.4 NEON support is known to be broken. 4.6.3 is known to - * work, so if this *is* GCC, or G++, look for a version >4.5 - */ -# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6) -# define PNG_ARM_NEON_IMPLEMENTATION 2 -# endif /* no GNUC support */ -# endif /* __GNUC__ */ -# else /* !defined __ARM_NEON__ */ - /* The 'intrinsics' code simply won't compile without this -mfpu=neon: - */ -# if !defined(__aarch64__) - /* The assembler code currently does not work on ARM64 */ -# define PNG_ARM_NEON_IMPLEMENTATION 2 -# endif /* __aarch64__ */ -# endif /* __ARM_NEON__ */ -# endif /* !PNG_ARM_NEON_IMPLEMENTATION */ - -# ifndef PNG_ARM_NEON_IMPLEMENTATION - /* Use the intrinsics code by default. */ -# define PNG_ARM_NEON_IMPLEMENTATION 1 -# endif -#endif /* PNG_ARM_NEON_OPT > 0 */ - -#ifndef PNG_MIPS_MSA_OPT -# if defined(__mips_msa) && (__mips_isa_rev >= 5) && defined(PNG_ALIGNED_MEMORY_SUPPORTED) -# define PNG_MIPS_MSA_OPT 2 -# else -# define PNG_MIPS_MSA_OPT 0 -# endif -#endif - -#ifndef PNG_POWERPC_VSX_OPT -# if defined(__PPC64__) && defined(__ALTIVEC__) && defined(__VSX__) -# define PNG_POWERPC_VSX_OPT 2 -# else -# define PNG_POWERPC_VSX_OPT 0 -# endif -#endif - -#ifndef PNG_INTEL_SSE_OPT -# ifdef PNG_INTEL_SSE - /* Only check for SSE if the build configuration has been modified to - * enable SSE optimizations. This means that these optimizations will - * be off by default. See contrib/intel for more details. - */ -# if defined(__SSE4_1__) || defined(__AVX__) || defined(__SSSE3__) || \ - defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \ - (defined(_M_IX86_FP) && _M_IX86_FP >= 2) -# define PNG_INTEL_SSE_OPT 1 -# else -# define PNG_INTEL_SSE_OPT 0 -# endif -# else -# define PNG_INTEL_SSE_OPT 0 -# endif -#endif - -#if PNG_INTEL_SSE_OPT > 0 -# ifndef PNG_INTEL_SSE_IMPLEMENTATION -# if defined(__SSE4_1__) || defined(__AVX__) - /* We are not actually using AVX, but checking for AVX is the best - way we can detect SSE4.1 and SSSE3 on MSVC. - */ -# define PNG_INTEL_SSE_IMPLEMENTATION 3 -# elif defined(__SSSE3__) -# define PNG_INTEL_SSE_IMPLEMENTATION 2 -# elif defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \ - (defined(_M_IX86_FP) && _M_IX86_FP >= 2) -# define PNG_INTEL_SSE_IMPLEMENTATION 1 -# else -# define PNG_INTEL_SSE_IMPLEMENTATION 0 -# endif -# endif - -# if PNG_INTEL_SSE_IMPLEMENTATION > 0 -# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_sse2 -# endif -#else -# define PNG_INTEL_SSE_IMPLEMENTATION 0 -#endif - -#if PNG_MIPS_MSA_OPT > 0 -# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_msa -# ifndef PNG_MIPS_MSA_IMPLEMENTATION -# if defined(__mips_msa) -# if defined(__clang__) -# elif defined(__GNUC__) -# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) -# define PNG_MIPS_MSA_IMPLEMENTATION 2 -# endif /* no GNUC support */ -# endif /* __GNUC__ */ -# else /* !defined __mips_msa */ -# define PNG_MIPS_MSA_IMPLEMENTATION 2 -# endif /* __mips_msa */ -# endif /* !PNG_MIPS_MSA_IMPLEMENTATION */ - -# ifndef PNG_MIPS_MSA_IMPLEMENTATION -# define PNG_MIPS_MSA_IMPLEMENTATION 1 -# endif -#endif /* PNG_MIPS_MSA_OPT > 0 */ - -#if PNG_POWERPC_VSX_OPT > 0 -# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_vsx -# define PNG_POWERPC_VSX_IMPLEMENTATION 1 -#endif - - -/* Is this a build of a DLL where compilation of the object modules requires - * different preprocessor settings to those required for a simple library? If - * so PNG_BUILD_DLL must be set. - * - * If libpng is used inside a DLL but that DLL does not export the libpng APIs - * PNG_BUILD_DLL must not be set. To avoid the code below kicking in build a - * static library of libpng then link the DLL against that. - */ -#ifndef PNG_BUILD_DLL -# ifdef DLL_EXPORT - /* This is set by libtool when files are compiled for a DLL; libtool - * always compiles twice, even on systems where it isn't necessary. Set - * PNG_BUILD_DLL in case it is necessary: - */ -# define PNG_BUILD_DLL -# else -# ifdef _WINDLL - /* This is set by the Microsoft Visual Studio IDE in projects that - * build a DLL. It can't easily be removed from those projects (it - * isn't visible in the Visual Studio UI) so it is a fairly reliable - * indication that PNG_IMPEXP needs to be set to the DLL export - * attributes. - */ -# define PNG_BUILD_DLL -# else -# ifdef __DLL__ - /* This is set by the Borland C system when compiling for a DLL - * (as above.) - */ -# define PNG_BUILD_DLL -# else - /* Add additional compiler cases here. */ -# endif -# endif -# endif -#endif /* Setting PNG_BUILD_DLL if required */ - -/* See pngconf.h for more details: the builder of the library may set this on - * the command line to the right thing for the specific compilation system or it - * may be automagically set above (at present we know of no system where it does - * need to be set on the command line.) - * - * PNG_IMPEXP must be set here when building the library to prevent pngconf.h - * setting it to the "import" setting for a DLL build. - */ -#ifndef PNG_IMPEXP -# ifdef PNG_BUILD_DLL -# define PNG_IMPEXP PNG_DLL_EXPORT -# else - /* Not building a DLL, or the DLL doesn't require specific export - * definitions. - */ -# define PNG_IMPEXP -# endif -#endif - -/* No warnings for private or deprecated functions in the build: */ -#ifndef PNG_DEPRECATED -# define PNG_DEPRECATED -#endif -#ifndef PNG_PRIVATE -# define PNG_PRIVATE -#endif - -/* Symbol preprocessing support. - * - * To enable listing global, but internal, symbols the following macros should - * always be used to declare an extern data or function object in this file. - */ -#ifndef PNG_INTERNAL_DATA -# define PNG_INTERNAL_DATA(type, name, array) PNG_LINKAGE_DATA type name array -#endif - -#ifndef PNG_INTERNAL_FUNCTION -# define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\ - PNG_LINKAGE_FUNCTION PNG_FUNCTION(type, name, args, PNG_EMPTY attributes) -#endif - -#ifndef PNG_INTERNAL_CALLBACK -# define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\ - PNG_LINKAGE_CALLBACK PNG_FUNCTION(type, (PNGCBAPI name), args,\ - PNG_EMPTY attributes) -#endif - -/* If floating or fixed point APIs are disabled they may still be compiled - * internally. To handle this make sure they are declared as the appropriate - * internal extern function (otherwise the symbol prefixing stuff won't work and - * the functions will be used without definitions.) - * - * NOTE: although all the API functions are declared here they are not all - * actually built! Because the declarations are still made it is necessary to - * fake out types that they depend on. - */ -#ifndef PNG_FP_EXPORT -# ifndef PNG_FLOATING_POINT_SUPPORTED -# define PNG_FP_EXPORT(ordinal, type, name, args)\ - PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY); -# ifndef PNG_VERSION_INFO_ONLY - typedef struct png_incomplete png_double; - typedef png_double* png_doublep; - typedef const png_double* png_const_doublep; - typedef png_double** png_doublepp; -# endif -# endif -#endif -#ifndef PNG_FIXED_EXPORT -# ifndef PNG_FIXED_POINT_SUPPORTED -# define PNG_FIXED_EXPORT(ordinal, type, name, args)\ - PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY); -# endif -#endif - -#include "png.h" - -/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */ -#ifndef PNG_DLL_EXPORT -# define PNG_DLL_EXPORT -#endif - -/* This is a global switch to set the compilation for an installed system - * (a release build). It can be set for testing debug builds to ensure that - * they will compile when the build type is switched to RC or STABLE, the - * default is just to use PNG_LIBPNG_BUILD_BASE_TYPE. Set this in CPPFLAGS - * with either: - * - * -DPNG_RELEASE_BUILD Turns on the release compile path - * -DPNG_RELEASE_BUILD=0 Turns it off - * or in your pngusr.h with - * #define PNG_RELEASE_BUILD=1 Turns on the release compile path - * #define PNG_RELEASE_BUILD=0 Turns it off - */ -#ifndef PNG_RELEASE_BUILD -# define PNG_RELEASE_BUILD (PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC) -#endif - -/* SECURITY and SAFETY: - * - * libpng is built with support for internal limits on image dimensions and - * memory usage. These are documented in scripts/pnglibconf.dfa of the - * source and recorded in the machine generated header file pnglibconf.h. - */ - -/* If you are running on a machine where you cannot allocate more - * than 64K of memory at once, uncomment this. While libpng will not - * normally need that much memory in a chunk (unless you load up a very - * large file), zlib needs to know how big of a chunk it can use, and - * libpng thus makes sure to check any memory allocation to verify it - * will fit into memory. - * - * zlib provides 'MAXSEG_64K' which, if defined, indicates the - * same limit and pngconf.h (already included) sets the limit - * if certain operating systems are detected. - */ -#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) -# define PNG_MAX_MALLOC_64K -#endif - -#ifndef PNG_UNUSED -/* Unused formal parameter warnings are silenced using the following macro - * which is expected to have no bad effects on performance (optimizing - * compilers will probably remove it entirely). Note that if you replace - * it with something other than whitespace, you must include the terminating - * semicolon. - */ -# define PNG_UNUSED(param) (void)param; -#endif - -/* Just a little check that someone hasn't tried to define something - * contradictory. - */ -#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K) -# undef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 65536L -#endif - -/* If warnings or errors are turned off the code is disabled or redirected here. - * From 1.5.4 functions have been added to allow very limited formatting of - * error and warning messages - this code will also be disabled here. - */ -#ifdef PNG_WARNINGS_SUPPORTED -# define PNG_WARNING_PARAMETERS(p) png_warning_parameters p; -#else -# define png_warning_parameter(p,number,string) ((void)0) -# define png_warning_parameter_unsigned(p,number,format,value) ((void)0) -# define png_warning_parameter_signed(p,number,format,value) ((void)0) -# define png_formatted_warning(pp,p,message) ((void)(pp)) -# define PNG_WARNING_PARAMETERS(p) -#endif -#ifndef PNG_ERROR_TEXT_SUPPORTED -# define png_fixed_error(s1,s2) png_err(s1) -#endif - -/* Some fixed point APIs are still required even if not exported because - * they get used by the corresponding floating point APIs. This magic - * deals with this: - */ -#ifdef PNG_FIXED_POINT_SUPPORTED -# define PNGFAPI PNGAPI -#else -# define PNGFAPI /* PRIVATE */ -#endif - -#ifndef PNG_VERSION_INFO_ONLY -/* Other defines specific to compilers can go here. Try to keep - * them inside an appropriate ifdef/endif pair for portability. - */ - -/* C allows up-casts from (void*) to any pointer and (const void*) to any - * pointer to a const object. C++ regards this as a type error and requires an - * explicit, static, cast and provides the static_cast<> rune to ensure that - * const is not cast away. - */ -#ifdef __cplusplus -# define png_voidcast(type, value) static_cast(value) -# define png_constcast(type, value) const_cast(value) -# define png_aligncast(type, value) \ - static_cast(static_cast(value)) -# define png_aligncastconst(type, value) \ - static_cast(static_cast(value)) -#else -# define png_voidcast(type, value) (value) -# ifdef _WIN64 -# ifdef __GNUC__ - typedef unsigned long long png_ptruint; -# else - typedef unsigned __int64 png_ptruint; -# endif -# else - typedef unsigned long png_ptruint; -# endif -# define png_constcast(type, value) ((type)(png_ptruint)(const void*)(value)) -# define png_aligncast(type, value) ((void*)(value)) -# define png_aligncastconst(type, value) ((const void*)(value)) -#endif /* __cplusplus */ - -#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\ - defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) - /* png.c requires the following ANSI-C constants if the conversion of - * floating point to ASCII is implemented therein: - * - * DBL_DIG Maximum number of decimal digits (can be set to any constant) - * DBL_MIN Smallest normalized fp number (can be set to an arbitrary value) - * DBL_MAX Maximum floating point number (can be set to an arbitrary value) - */ -# include - -# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ - defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) - /* We need to check that hasn't already been included earlier - * as it seems it doesn't agree with , yet we should really use - * if possible. - */ -# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) -# include -# endif -# else -# include -# endif -# if defined(_AMIGA) && defined(__SASC) && defined(_M68881) - /* Amiga SAS/C: We must include builtin FPU functions when compiling using - * MATH=68881 - */ -# include -# endif -#endif - -/* This provides the non-ANSI (far) memory allocation routines. */ -#if defined(__TURBOC__) && defined(__MSDOS__) -# include -# include -#endif - -#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \ - defined(_WIN32) || defined(__WIN32__) -# include /* defines _WINDOWS_ macro */ -#endif -#endif /* PNG_VERSION_INFO_ONLY */ - -/* Moved here around 1.5.0beta36 from pngconf.h */ -/* Users may want to use these so they are not private. Any library - * functions that are passed far data must be model-independent. - */ - -/* Memory model/platform independent fns */ -#ifndef PNG_ABORT -# ifdef _WINDOWS_ -# define PNG_ABORT() ExitProcess(0) -# else -# define PNG_ABORT() abort() -# endif -#endif - -/* These macros may need to be architecture dependent. */ -#define PNG_ALIGN_NONE 0 /* do not use data alignment */ -#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */ -#ifdef offsetof -# define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */ -#else -# define PNG_ALIGN_OFFSET -1 /* prevent the use of this */ -#endif -#define PNG_ALIGN_SIZE 3 /* use sizeof to determine alignment */ - -#ifndef PNG_ALIGN_TYPE - /* Default to using aligned access optimizations and requiring alignment to a - * multiple of the data type size. Override in a compiler specific fashion - * if necessary by inserting tests here: - */ -# define PNG_ALIGN_TYPE PNG_ALIGN_SIZE -#endif - -#if PNG_ALIGN_TYPE == PNG_ALIGN_SIZE - /* This is used because in some compiler implementations non-aligned - * structure members are supported, so the offsetof approach below fails. - * Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access - * is good for performance. Do not do this unless you have tested the result - * and understand it. - */ -# define png_alignof(type) (sizeof (type)) -#else -# if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET -# define png_alignof(type) offsetof(struct{char c; type t;}, t) -# else -# if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS -# define png_alignof(type) (1) -# endif - /* Else leave png_alignof undefined to prevent use thereof */ -# endif -#endif - -/* This implicitly assumes alignment is always to a power of 2. */ -#ifdef png_alignof -# define png_isaligned(ptr, type)\ - (((type)((const char*)ptr-(const char*)0) & \ - (type)(png_alignof(type)-1)) == 0) -#else -# define png_isaligned(ptr, type) 0 -#endif - -/* End of memory model/platform independent support */ -/* End of 1.5.0beta36 move from pngconf.h */ - -/* CONSTANTS and UTILITY MACROS - * These are used internally by libpng and not exposed in the API - */ - -/* Various modes of operation. Note that after an init, mode is set to - * zero automatically when the structure is created. Three of these - * are defined in png.h because they need to be visible to applications - * that call png_set_unknown_chunk(). - */ -/* #define PNG_HAVE_IHDR 0x01U (defined in png.h) */ -/* #define PNG_HAVE_PLTE 0x02U (defined in png.h) */ -#define PNG_HAVE_IDAT 0x04U -/* #define PNG_AFTER_IDAT 0x08U (defined in png.h) */ -#define PNG_HAVE_IEND 0x10U - /* 0x20U (unused) */ - /* 0x40U (unused) */ - /* 0x80U (unused) */ -#define PNG_HAVE_CHUNK_HEADER 0x100U -#define PNG_WROTE_tIME 0x200U -#define PNG_WROTE_INFO_BEFORE_PLTE 0x400U -#define PNG_BACKGROUND_IS_GRAY 0x800U -#define PNG_HAVE_PNG_SIGNATURE 0x1000U -#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */ - /* 0x4000U (unused) */ -#define PNG_IS_READ_STRUCT 0x8000U /* Else is a write struct */ - -/* Flags for the transformations the PNG library does on the image data */ -#define PNG_BGR 0x0001U -#define PNG_INTERLACE 0x0002U -#define PNG_PACK 0x0004U -#define PNG_SHIFT 0x0008U -#define PNG_SWAP_BYTES 0x0010U -#define PNG_INVERT_MONO 0x0020U -#define PNG_QUANTIZE 0x0040U -#define PNG_COMPOSE 0x0080U /* Was PNG_BACKGROUND */ -#define PNG_BACKGROUND_EXPAND 0x0100U -#define PNG_EXPAND_16 0x0200U /* Added to libpng 1.5.2 */ -#define PNG_16_TO_8 0x0400U /* Becomes 'chop' in 1.5.4 */ -#define PNG_RGBA 0x0800U -#define PNG_EXPAND 0x1000U -#define PNG_GAMMA 0x2000U -#define PNG_GRAY_TO_RGB 0x4000U -#define PNG_FILLER 0x8000U -#define PNG_PACKSWAP 0x10000U -#define PNG_SWAP_ALPHA 0x20000U -#define PNG_STRIP_ALPHA 0x40000U -#define PNG_INVERT_ALPHA 0x80000U -#define PNG_USER_TRANSFORM 0x100000U -#define PNG_RGB_TO_GRAY_ERR 0x200000U -#define PNG_RGB_TO_GRAY_WARN 0x400000U -#define PNG_RGB_TO_GRAY 0x600000U /* two bits, RGB_TO_GRAY_ERR|WARN */ -#define PNG_ENCODE_ALPHA 0x800000U /* Added to libpng-1.5.4 */ -#define PNG_ADD_ALPHA 0x1000000U /* Added to libpng-1.2.7 */ -#define PNG_EXPAND_tRNS 0x2000000U /* Added to libpng-1.2.9 */ -#define PNG_SCALE_16_TO_8 0x4000000U /* Added to libpng-1.5.4 */ - /* 0x8000000U unused */ - /* 0x10000000U unused */ - /* 0x20000000U unused */ - /* 0x40000000U unused */ -/* Flags for png_create_struct */ -#define PNG_STRUCT_PNG 0x0001U -#define PNG_STRUCT_INFO 0x0002U - -/* Flags for the png_ptr->flags rather than declaring a byte for each one */ -#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001U -#define PNG_FLAG_ZSTREAM_INITIALIZED 0x0002U /* Added to libpng-1.6.0 */ - /* 0x0004U unused */ -#define PNG_FLAG_ZSTREAM_ENDED 0x0008U /* Added to libpng-1.6.0 */ - /* 0x0010U unused */ - /* 0x0020U unused */ -#define PNG_FLAG_ROW_INIT 0x0040U -#define PNG_FLAG_FILLER_AFTER 0x0080U -#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100U -#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200U -#define PNG_FLAG_CRC_CRITICAL_USE 0x0400U -#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800U -#define PNG_FLAG_ASSUME_sRGB 0x1000U /* Added to libpng-1.5.4 */ -#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000U /* Added to libpng-1.5.4 */ -#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000U /* Added to libpng-1.5.4 */ -/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000U */ -/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000U */ -#define PNG_FLAG_LIBRARY_MISMATCH 0x20000U -#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000U -#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000U -#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000U /* Added to libpng-1.4.0 */ -#define PNG_FLAG_APP_WARNINGS_WARN 0x200000U /* Added to libpng-1.6.0 */ -#define PNG_FLAG_APP_ERRORS_WARN 0x400000U /* Added to libpng-1.6.0 */ - /* 0x800000U unused */ - /* 0x1000000U unused */ - /* 0x2000000U unused */ - /* 0x4000000U unused */ - /* 0x8000000U unused */ - /* 0x10000000U unused */ - /* 0x20000000U unused */ - /* 0x40000000U unused */ - -#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ - PNG_FLAG_CRC_ANCILLARY_NOWARN) - -#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \ - PNG_FLAG_CRC_CRITICAL_IGNORE) - -#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ - PNG_FLAG_CRC_CRITICAL_MASK) - -/* Save typing and make code easier to understand */ - -#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ - abs((int)((c1).green) - (int)((c2).green)) + \ - abs((int)((c1).blue) - (int)((c2).blue))) - -/* Added to libpng-1.6.0: scale a 16-bit value in the range 0..65535 to 0..255 - * by dividing by 257 *with rounding*. This macro is exact for the given range. - * See the discourse in pngrtran.c png_do_scale_16_to_8. The values in the - * macro were established by experiment (modifying the added value). The macro - * has a second variant that takes a value already scaled by 255 and divides by - * 65535 - this has a maximum error of .502. Over the range 0..65535*65535 it - * only gives off-by-one errors and only for 0.5% (1 in 200) of the values. - */ -#define PNG_DIV65535(v24) (((v24) + 32895) >> 16) -#define PNG_DIV257(v16) PNG_DIV65535((png_uint_32)(v16) * 255) - -/* Added to libpng-1.2.6 JB */ -#define PNG_ROWBYTES(pixel_bits, width) \ - ((pixel_bits) >= 8 ? \ - ((size_t)(width) * (((size_t)(pixel_bits)) >> 3)) : \ - (( ((size_t)(width) * ((size_t)(pixel_bits))) + 7) >> 3) ) - -/* This returns the number of trailing bits in the last byte of a row, 0 if the - * last byte is completely full of pixels. It is, in principle, (pixel_bits x - * width) % 8, but that would overflow for large 'width'. The second macro is - * the same except that it returns the number of unused bits in the last byte; - * (8-TRAILBITS), but 0 when TRAILBITS is 0. - * - * NOTE: these macros are intended to be self-evidently correct and never - * overflow on the assumption that pixel_bits is in the range 0..255. The - * arguments are evaluated only once and they can be signed (e.g. as a result of - * the integral promotions). The result of the expression always has type - * (png_uint_32), however the compiler always knows it is in the range 0..7. - */ -#define PNG_TRAILBITS(pixel_bits, width) \ - (((pixel_bits) * ((width) % (png_uint_32)8)) % 8) - -#define PNG_PADBITS(pixel_bits, width) \ - ((8 - PNG_TRAILBITS(pixel_bits, width)) % 8) - -/* PNG_OUT_OF_RANGE returns true if value is outside the range - * ideal-delta..ideal+delta. Each argument is evaluated twice. - * "ideal" and "delta" should be constants, normally simple - * integers, "value" a variable. Added to libpng-1.2.6 JB - */ -#define PNG_OUT_OF_RANGE(value, ideal, delta) \ - ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) - -/* Conversions between fixed and floating point, only defined if - * required (to make sure the code doesn't accidentally use float - * when it is supposedly disabled.) - */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -/* The floating point conversion can't overflow, though it can and - * does lose accuracy relative to the original fixed point value. - * In practice this doesn't matter because png_fixed_point only - * stores numbers with very low precision. The png_ptr and s - * arguments are unused by default but are there in case error - * checking becomes a requirement. - */ -#define png_float(png_ptr, fixed, s) (.00001 * (fixed)) - -/* The fixed point conversion performs range checking and evaluates - * its argument multiple times, so must be used with care. The - * range checking uses the PNG specification values for a signed - * 32-bit fixed point value except that the values are deliberately - * rounded-to-zero to an integral value - 21474 (21474.83 is roughly - * (2^31-1) * 100000). 's' is a string that describes the value being - * converted. - * - * NOTE: this macro will raise a png_error if the range check fails, - * therefore it is normally only appropriate to use this on values - * that come from API calls or other sources where an out of range - * error indicates a programming error, not a data error! - * - * NOTE: by default this is off - the macro is not used - because the - * function call saves a lot of code. - */ -#ifdef PNG_FIXED_POINT_MACRO_SUPPORTED -#define png_fixed(png_ptr, fp, s) ((fp) <= 21474 && (fp) >= -21474 ?\ - ((png_fixed_point)(100000 * (fp))) : (png_fixed_error(png_ptr, s),0)) -#endif -/* else the corresponding function is defined below, inside the scope of the - * cplusplus test. - */ -#endif - -/* Constants for known chunk types. If you need to add a chunk, define the name - * here. For historical reasons these constants have the form png_; i.e. - * the prefix is lower case. Please use decimal values as the parameters to - * match the ISO PNG specification and to avoid relying on the C locale - * interpretation of character values. - * - * Prior to 1.5.6 these constants were strings, as of 1.5.6 png_uint_32 values - * are computed and a new macro (PNG_STRING_FROM_CHUNK) added to allow a string - * to be generated if required. - * - * PNG_32b correctly produces a value shifted by up to 24 bits, even on - * architectures where (int) is only 16 bits. - */ -#define PNG_32b(b,s) ((png_uint_32)(b) << (s)) -#define PNG_U32(b1,b2,b3,b4) \ - (PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0)) - -/* Constants for known chunk types. - * - * MAINTAINERS: If you need to add a chunk, define the name here. - * For historical reasons these constants have the form png_; i.e. - * the prefix is lower case. Please use decimal values as the parameters to - * match the ISO PNG specification and to avoid relying on the C locale - * interpretation of character values. Please keep the list sorted. - * - * Notice that PNG_U32 is used to define a 32-bit value for the 4 byte chunk - * type. In fact the specification does not express chunk types this way, - * however using a 32-bit value means that the chunk type can be read from the - * stream using exactly the same code as used for a 32-bit unsigned value and - * can be examined far more efficiently (using one arithmetic compare). - * - * Prior to 1.5.6 the chunk type constants were expressed as C strings. The - * libpng API still uses strings for 'unknown' chunks and a macro, - * PNG_STRING_FROM_CHUNK, allows a string to be generated if required. Notice - * that for portable code numeric values must still be used; the string "IHDR" - * is not portable and neither is PNG_U32('I', 'H', 'D', 'R'). - * - * In 1.7.0 the definitions will be made public in png.h to avoid having to - * duplicate the same definitions in application code. - */ -#define png_IDAT PNG_U32( 73, 68, 65, 84) -#define png_IEND PNG_U32( 73, 69, 78, 68) -#define png_IHDR PNG_U32( 73, 72, 68, 82) -#define png_PLTE PNG_U32( 80, 76, 84, 69) -#define png_bKGD PNG_U32( 98, 75, 71, 68) -#define png_cHRM PNG_U32( 99, 72, 82, 77) -#define png_eXIf PNG_U32(101, 88, 73, 102) /* registered July 2017 */ -#define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */ -#define png_gAMA PNG_U32(103, 65, 77, 65) -#define png_gIFg PNG_U32(103, 73, 70, 103) -#define png_gIFt PNG_U32(103, 73, 70, 116) /* deprecated */ -#define png_gIFx PNG_U32(103, 73, 70, 120) -#define png_hIST PNG_U32(104, 73, 83, 84) -#define png_iCCP PNG_U32(105, 67, 67, 80) -#define png_iTXt PNG_U32(105, 84, 88, 116) -#define png_oFFs PNG_U32(111, 70, 70, 115) -#define png_pCAL PNG_U32(112, 67, 65, 76) -#define png_pHYs PNG_U32(112, 72, 89, 115) -#define png_sBIT PNG_U32(115, 66, 73, 84) -#define png_sCAL PNG_U32(115, 67, 65, 76) -#define png_sPLT PNG_U32(115, 80, 76, 84) -#define png_sRGB PNG_U32(115, 82, 71, 66) -#define png_sTER PNG_U32(115, 84, 69, 82) -#define png_tEXt PNG_U32(116, 69, 88, 116) -#define png_tIME PNG_U32(116, 73, 77, 69) -#define png_tRNS PNG_U32(116, 82, 78, 83) -#define png_zTXt PNG_U32(122, 84, 88, 116) - -/* The following will work on (signed char*) strings, whereas the get_uint_32 - * macro will fail on top-bit-set values because of the sign extension. - */ -#define PNG_CHUNK_FROM_STRING(s)\ - PNG_U32(0xff & (s)[0], 0xff & (s)[1], 0xff & (s)[2], 0xff & (s)[3]) - -/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is - * signed and the argument is a (char[]) This macro will fail miserably on - * systems where (char) is more than 8 bits. - */ -#define PNG_STRING_FROM_CHUNK(s,c)\ - (void)(((char*)(s))[0]=(char)(((c)>>24) & 0xff), \ - ((char*)(s))[1]=(char)(((c)>>16) & 0xff),\ - ((char*)(s))[2]=(char)(((c)>>8) & 0xff), \ - ((char*)(s))[3]=(char)((c & 0xff))) - -/* Do the same but terminate with a null character. */ -#define PNG_CSTRING_FROM_CHUNK(s,c)\ - (void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0) - -/* Test on flag values as defined in the spec (section 5.4): */ -#define PNG_CHUNK_ANCILLARY(c) (1 & ((c) >> 29)) -#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLARY(c)) -#define PNG_CHUNK_PRIVATE(c) (1 & ((c) >> 21)) -#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13)) -#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5)) - -/* Gamma values (new at libpng-1.5.4): */ -#define PNG_GAMMA_MAC_OLD 151724 /* Assume '1.8' is really 2.2/1.45! */ -#define PNG_GAMMA_MAC_INVERSE 65909 -#define PNG_GAMMA_sRGB_INVERSE 45455 - -/* Almost everything below is C specific; the #defines above can be used in - * non-C code (so long as it is C-preprocessed) the rest of this stuff cannot. - */ -#ifndef PNG_VERSION_INFO_ONLY - -#include "pngstruct.h" -#include "pnginfo.h" - -/* Validate the include paths - the include path used to generate pnglibconf.h - * must match that used in the build, or we must be using pnglibconf.h.prebuilt: - */ -#if PNG_ZLIB_VERNUM != 0 && PNG_ZLIB_VERNUM != ZLIB_VERNUM -# error ZLIB_VERNUM != PNG_ZLIB_VERNUM \ - "-I (include path) error: see the notes in pngpriv.h" - /* This means that when pnglibconf.h was built the copy of zlib.h that it - * used is not the same as the one being used here. Because the build of - * libpng makes decisions to use inflateInit2 and inflateReset2 based on the - * zlib version number and because this affects handling of certain broken - * PNG files the -I directives must match. - * - * The most likely explanation is that you passed a -I in CFLAGS. This will - * not work; all the preprocessor directives and in particular all the -I - * directives must be in CPPFLAGS. - */ -#endif - -/* This is used for 16-bit gamma tables -- only the top level pointers are - * const; this could be changed: - */ -typedef const png_uint_16p * png_const_uint_16pp; - -/* Added to libpng-1.5.7: sRGB conversion tables */ -#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ - defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) -#ifdef PNG_SIMPLIFIED_READ_SUPPORTED -PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]); - /* Convert from an sRGB encoded value 0..255 to a 16-bit linear value, - * 0..65535. This table gives the closest 16-bit answers (no errors). - */ -#endif - -PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]); -PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]); - -#define PNG_sRGB_FROM_LINEAR(linear) \ - ((png_byte)(0xff & ((png_sRGB_base[(linear)>>15] \ - + ((((linear) & 0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))) - /* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB - * encoded value with maximum error 0.646365. Note that the input is not a - * 16-bit value; it has been multiplied by 255! */ -#endif /* SIMPLIFIED_READ/WRITE */ - - -/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Internal functions; these are not exported from a DLL however because they - * are used within several of the C source files they have to be C extern. - * - * All of these functions must be declared with PNG_INTERNAL_FUNCTION. - */ - -/* Zlib support */ -#define PNG_UNEXPECTED_ZLIB_RETURN (-7) -PNG_INTERNAL_FUNCTION(void, png_zstream_error,(png_structrp png_ptr, int ret), - PNG_EMPTY); - /* Used by the zlib handling functions to ensure that z_stream::msg is always - * set before they return. - */ - -#ifdef PNG_WRITE_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_free_buffer_list,(png_structrp png_ptr, - png_compression_bufferp *list),PNG_EMPTY); - /* Free the buffer list used by the compressed write code. */ -#endif - -#if defined(PNG_FLOATING_POINT_SUPPORTED) && \ - !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \ - (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \ - defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \ - (defined(PNG_sCAL_SUPPORTED) && \ - defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)) -PNG_INTERNAL_FUNCTION(png_fixed_point,png_fixed,(png_const_structrp png_ptr, - double fp, png_const_charp text),PNG_EMPTY); -#endif - -/* Check the user version string for compatibility, returns false if the version - * numbers aren't compatible. - */ -PNG_INTERNAL_FUNCTION(int,png_user_version_check,(png_structrp png_ptr, - png_const_charp user_png_ver),PNG_EMPTY); - -/* Internal base allocator - no messages, NULL on failure to allocate. This - * does, however, call the application provided allocator and that could call - * png_error (although that would be a bug in the application implementation.) - */ -PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr, - png_alloc_size_t size),PNG_ALLOCATED); - -#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\ - defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) -/* Internal array allocator, outputs no error or warning messages on failure, - * just returns NULL. - */ -PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr, - int nelements, size_t element_size),PNG_ALLOCATED); - -/* The same but an existing array is extended by add_elements. This function - * also memsets the new elements to 0 and copies the old elements. The old - * array is not freed or altered. - */ -PNG_INTERNAL_FUNCTION(png_voidp,png_realloc_array,(png_const_structrp png_ptr, - png_const_voidp array, int old_elements, int add_elements, - size_t element_size),PNG_ALLOCATED); -#endif /* text, sPLT or unknown chunks */ - -/* Magic to create a struct when there is no struct to call the user supplied - * memory allocators. Because error handling has not been set up the memory - * handlers can't safely call png_error, but this is an obscure and undocumented - * restriction so libpng has to assume that the 'free' handler, at least, might - * call png_error. - */ -PNG_INTERNAL_FUNCTION(png_structp,png_create_png_struct, - (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn, - png_free_ptr free_fn),PNG_ALLOCATED); - -/* Free memory from internal libpng struct */ -PNG_INTERNAL_FUNCTION(void,png_destroy_png_struct,(png_structrp png_ptr), - PNG_EMPTY); - -/* Free an allocated jmp_buf (always succeeds) */ -PNG_INTERNAL_FUNCTION(void,png_free_jmpbuf,(png_structrp png_ptr),PNG_EMPTY); - -/* Function to allocate memory for zlib. PNGAPI is disallowed. */ -PNG_INTERNAL_FUNCTION(voidpf,png_zalloc,(voidpf png_ptr, uInt items, uInt size), - PNG_ALLOCATED); - -/* Function to free memory for zlib. PNGAPI is disallowed. */ -PNG_INTERNAL_FUNCTION(void,png_zfree,(voidpf png_ptr, voidpf ptr),PNG_EMPTY); - -/* Next four functions are used internally as callbacks. PNGCBAPI is required - * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3, changed to - * PNGCBAPI at 1.5.0 - */ - -PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_read_data,(png_structp png_ptr, - png_bytep data, size_t length),PNG_EMPTY); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_push_fill_buffer,(png_structp png_ptr, - png_bytep buffer, size_t length),PNG_EMPTY); -#endif - -PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_write_data,(png_structp png_ptr, - png_bytep data, size_t length),PNG_EMPTY); - -#ifdef PNG_WRITE_FLUSH_SUPPORTED -# ifdef PNG_STDIO_SUPPORTED -PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_flush,(png_structp png_ptr), - PNG_EMPTY); -# endif -#endif - -/* Reset the CRC variable */ -PNG_INTERNAL_FUNCTION(void,png_reset_crc,(png_structrp png_ptr),PNG_EMPTY); - -/* Write the "data" buffer to whatever output you are using */ -PNG_INTERNAL_FUNCTION(void,png_write_data,(png_structrp png_ptr, - png_const_bytep data, size_t length),PNG_EMPTY); - -/* Read and check the PNG file signature */ -PNG_INTERNAL_FUNCTION(void,png_read_sig,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); - -/* Read the chunk header (length + type name) */ -PNG_INTERNAL_FUNCTION(png_uint_32,png_read_chunk_header,(png_structrp png_ptr), - PNG_EMPTY); - -/* Read data from whatever input you are using into the "data" buffer */ -PNG_INTERNAL_FUNCTION(void,png_read_data,(png_structrp png_ptr, png_bytep data, - size_t length),PNG_EMPTY); - -/* Read bytes into buf, and update png_ptr->crc */ -PNG_INTERNAL_FUNCTION(void,png_crc_read,(png_structrp png_ptr, png_bytep buf, - png_uint_32 length),PNG_EMPTY); - -/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */ -PNG_INTERNAL_FUNCTION(int,png_crc_finish,(png_structrp png_ptr, - png_uint_32 skip),PNG_EMPTY); - -/* Read the CRC from the file and compare it to the libpng calculated CRC */ -PNG_INTERNAL_FUNCTION(int,png_crc_error,(png_structrp png_ptr),PNG_EMPTY); - -/* Calculate the CRC over a section of data. Note that we are only - * passing a maximum of 64K on systems that have this as a memory limit, - * since this is the maximum buffer size we can specify. - */ -PNG_INTERNAL_FUNCTION(void,png_calculate_crc,(png_structrp png_ptr, - png_const_bytep ptr, size_t length),PNG_EMPTY); - -#ifdef PNG_WRITE_FLUSH_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_flush,(png_structrp png_ptr),PNG_EMPTY); -#endif - -/* Write various chunks */ - -/* Write the IHDR chunk, and update the png_struct with the necessary - * information. - */ -PNG_INTERNAL_FUNCTION(void,png_write_IHDR,(png_structrp png_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, - int compression_method, int filter_method, int interlace_method),PNG_EMPTY); - -PNG_INTERNAL_FUNCTION(void,png_write_PLTE,(png_structrp png_ptr, - png_const_colorp palette, png_uint_32 num_pal),PNG_EMPTY); - -PNG_INTERNAL_FUNCTION(void,png_compress_IDAT,(png_structrp png_ptr, - png_const_bytep row_data, png_alloc_size_t row_data_length, int flush), - PNG_EMPTY); - -PNG_INTERNAL_FUNCTION(void,png_write_IEND,(png_structrp png_ptr),PNG_EMPTY); - -#ifdef PNG_WRITE_gAMA_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_gAMA_fixed,(png_structrp png_ptr, - png_fixed_point file_gamma),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_sBIT_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_sBIT,(png_structrp png_ptr, - png_const_color_8p sbit, int color_type),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_cHRM_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr, - const png_xy *xy), PNG_EMPTY); - /* The xy value must have been previously validated */ -#endif - -#ifdef PNG_WRITE_sRGB_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr, - int intent),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_eXIf_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_eXIf,(png_structrp png_ptr, - png_bytep exif, int num_exif),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_iCCP_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_iCCP,(png_structrp png_ptr, - png_const_charp name, png_const_bytep profile), PNG_EMPTY); - /* The profile must have been previously validated for correctness, the - * length comes from the first four bytes. Only the base, deflate, - * compression is supported. - */ -#endif - -#ifdef PNG_WRITE_sPLT_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_sPLT,(png_structrp png_ptr, - png_const_sPLT_tp palette),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_tRNS_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_tRNS,(png_structrp png_ptr, - png_const_bytep trans, png_const_color_16p values, int number, - int color_type),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_bKGD_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_bKGD,(png_structrp png_ptr, - png_const_color_16p values, int color_type),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_hIST_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_hIST,(png_structrp png_ptr, - png_const_uint_16p hist, int num_hist),PNG_EMPTY); -#endif - -/* Chunks that have keywords */ -#ifdef PNG_WRITE_tEXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr, - png_const_charp key, png_const_charp text, size_t text_len),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_zTXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp - key, png_const_charp text, int compression),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_iTXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_iTXt,(png_structrp png_ptr, - int compression, png_const_charp key, png_const_charp lang, - png_const_charp lang_key, png_const_charp text),PNG_EMPTY); -#endif - -#ifdef PNG_TEXT_SUPPORTED /* Added at version 1.0.14 and 1.2.4 */ -PNG_INTERNAL_FUNCTION(int,png_set_text_2,(png_const_structrp png_ptr, - png_inforp info_ptr, png_const_textp text_ptr, int num_text),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_oFFs_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_oFFs,(png_structrp png_ptr, - png_int_32 x_offset, png_int_32 y_offset, int unit_type),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_pCAL_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_pCAL,(png_structrp png_ptr, - png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, - png_const_charp units, png_charpp params),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_pHYs_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_pHYs,(png_structrp png_ptr, - png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, - int unit_type),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_tIME_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_tIME,(png_structrp png_ptr, - png_const_timep mod_time),PNG_EMPTY); -#endif - -#ifdef PNG_WRITE_sCAL_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_write_sCAL_s,(png_structrp png_ptr, - int unit, png_const_charp width, png_const_charp height),PNG_EMPTY); -#endif - -/* Called when finished processing a row of data */ -PNG_INTERNAL_FUNCTION(void,png_write_finish_row,(png_structrp png_ptr), - PNG_EMPTY); - -/* Internal use only. Called before first row of data */ -PNG_INTERNAL_FUNCTION(void,png_write_start_row,(png_structrp png_ptr), - PNG_EMPTY); - -/* Combine a row of data, dealing with alpha, etc. if requested. 'row' is an - * array of png_ptr->width pixels. If the image is not interlaced or this - * is the final pass this just does a memcpy, otherwise the "display" flag - * is used to determine whether to copy pixels that are not in the current pass. - * - * Because 'png_do_read_interlace' (below) replicates pixels this allows this - * function to achieve the documented 'blocky' appearance during interlaced read - * if display is 1 and the 'sparkle' appearance, where existing pixels in 'row' - * are not changed if they are not in the current pass, when display is 0. - * - * 'display' must be 0 or 1, otherwise the memcpy will be done regardless. - * - * The API always reads from the png_struct row buffer and always assumes that - * it is full width (png_do_read_interlace has already been called.) - * - * This function is only ever used to write to row buffers provided by the - * caller of the relevant libpng API and the row must have already been - * transformed by the read transformations. - * - * The PNG_USE_COMPILE_TIME_MASKS option causes generation of pre-computed - * bitmasks for use within the code, otherwise runtime generated masks are used. - * The default is compile time masks. - */ -#ifndef PNG_USE_COMPILE_TIME_MASKS -# define PNG_USE_COMPILE_TIME_MASKS 1 -#endif -PNG_INTERNAL_FUNCTION(void,png_combine_row,(png_const_structrp png_ptr, - png_bytep row, int display),PNG_EMPTY); - -#ifdef PNG_READ_INTERLACING_SUPPORTED -/* Expand an interlaced row: the 'row_info' describes the pass data that has - * been read in and must correspond to the pixels in 'row', the pixels are - * expanded (moved apart) in 'row' to match the final layout, when doing this - * the pixels are *replicated* to the intervening space. This is essential for - * the correct operation of png_combine_row, above. - */ -PNG_INTERNAL_FUNCTION(void,png_do_read_interlace,(png_row_infop row_info, - png_bytep row, int pass, png_uint_32 transformations),PNG_EMPTY); -#endif - -/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED -/* Grab pixels out of a row for an interlaced pass */ -PNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info, - png_bytep row, int pass),PNG_EMPTY); -#endif - -/* Unfilter a row: check the filter value before calling this, there is no point - * calling it for PNG_FILTER_VALUE_NONE. - */ -PNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop - row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY); - -#if PNG_ARM_NEON_OPT > 0 -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info, - png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_neon,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_neon,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_neon,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -#endif - -#if PNG_MIPS_MSA_OPT > 0 -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_msa,(png_row_infop row_info, - png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_msa,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_msa,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_msa,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_msa,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_msa,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_msa,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -#endif - -#if PNG_POWERPC_VSX_OPT > 0 -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_vsx,(png_row_infop row_info, - png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_vsx,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_vsx,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_vsx,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_vsx,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_vsx,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_vsx,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -#endif - -#if PNG_INTEL_SSE_IMPLEMENTATION > 0 -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_sse2,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_sse2,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_sse2,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_sse2,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_sse2,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_sse2,(png_row_infop - row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); -#endif - -/* Choose the best filter to use and filter the row data */ -PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr, - png_row_infop row_info),PNG_EMPTY); - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_read_IDAT_data,(png_structrp png_ptr, - png_bytep output, png_alloc_size_t avail_out),PNG_EMPTY); - /* Read 'avail_out' bytes of data from the IDAT stream. If the output buffer - * is NULL the function checks, instead, for the end of the stream. In this - * case a benign error will be issued if the stream end is not found or if - * extra data has to be consumed. - */ -PNG_INTERNAL_FUNCTION(void,png_read_finish_IDAT,(png_structrp png_ptr), - PNG_EMPTY); - /* This cleans up when the IDAT LZ stream does not end when the last image - * byte is read; there is still some pending input. - */ - -PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr), - PNG_EMPTY); - /* Finish a row while reading, dealing with interlacing passes, etc. */ -#endif /* SEQUENTIAL_READ */ - -/* Initialize the row buffers, etc. */ -PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY); - -#if ZLIB_VERNUM >= 0x1240 -PNG_INTERNAL_FUNCTION(int,png_zlib_inflate,(png_structrp png_ptr, int flush), - PNG_EMPTY); -# define PNG_INFLATE(pp, flush) png_zlib_inflate(pp, flush) -#else /* Zlib < 1.2.4 */ -# define PNG_INFLATE(pp, flush) inflate(&(pp)->zstream, flush) -#endif /* Zlib < 1.2.4 */ - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -/* Optional call to update the users info structure */ -PNG_INTERNAL_FUNCTION(void,png_read_transform_info,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -#endif - -/* Shared transform functions, defined in pngtran.c */ -#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ - defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -PNG_INTERNAL_FUNCTION(void,png_do_strip_channel,(png_row_infop row_info, - png_bytep row, int at_start),PNG_EMPTY); -#endif - -#ifdef PNG_16BIT_SUPPORTED -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -PNG_INTERNAL_FUNCTION(void,png_do_swap,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ - defined(PNG_WRITE_PACKSWAP_SUPPORTED) -PNG_INTERNAL_FUNCTION(void,png_do_packswap,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -PNG_INTERNAL_FUNCTION(void,png_do_invert,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -PNG_INTERNAL_FUNCTION(void,png_do_bgr,(png_row_infop row_info, - png_bytep row),PNG_EMPTY); -#endif - -/* The following decodes the appropriate chunks, and does error correction, - * then calls the appropriate callback for the chunk if it is valid. - */ - -/* Decode the IHDR chunk */ -PNG_INTERNAL_FUNCTION(void,png_handle_IHDR,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_handle_PLTE,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_handle_IEND,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); - -#ifdef PNG_READ_bKGD_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_bKGD,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_cHRM_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_cHRM,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_eXIf_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_eXIf,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_gAMA_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_gAMA,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_hIST_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_hIST,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_iCCP_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_iCCP,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif /* READ_iCCP */ - -#ifdef PNG_READ_iTXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_iTXt,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_oFFs_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_oFFs,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_pCAL_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_pCAL,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_pHYs_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_pHYs,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_sBIT_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_sBIT,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_sCAL_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_sCAL,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_sPLT_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_sPLT,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif /* READ_sPLT */ - -#ifdef PNG_READ_sRGB_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_sRGB,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_tEXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_tEXt,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_tIME_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_tIME,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_tRNS_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_tRNS,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -#ifdef PNG_READ_zTXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -#endif - -PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_const_structrp png_ptr, - png_uint_32 chunk_name),PNG_EMPTY); - -PNG_INTERNAL_FUNCTION(void,png_check_chunk_length,(png_const_structrp png_ptr, - png_uint_32 chunk_length),PNG_EMPTY); - -PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY); - /* This is the function that gets called for unknown chunks. The 'keep' - * argument is either non-zero for a known chunk that has been set to be - * handled as unknown or zero for an unknown chunk. By default the function - * just skips the chunk or errors out if it is critical. - */ - -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\ - defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) -PNG_INTERNAL_FUNCTION(int,png_chunk_unknown_handling, - (png_const_structrp png_ptr, png_uint_32 chunk_name),PNG_EMPTY); - /* Exactly as the API png_handle_as_unknown() except that the argument is a - * 32-bit chunk name, not a string. - */ -#endif /* READ_UNKNOWN_CHUNKS || HANDLE_AS_UNKNOWN */ - -/* Handle the transformations for reading and writing */ -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_read_transformations,(png_structrp png_ptr, - png_row_infop row_info),PNG_EMPTY); -#endif -#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_do_write_transformations,(png_structrp png_ptr, - png_row_infop row_info),PNG_EMPTY); -#endif - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_init_read_transformations,(png_structrp png_ptr), - PNG_EMPTY); -#endif - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_push_read_chunk,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_read_sig,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr), - PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr, - png_bytep buffer, size_t buffer_length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_read_IDAT,(png_structrp png_ptr),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_process_IDAT_data,(png_structrp png_ptr, - png_bytep buffer, size_t buffer_length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_process_row,(png_structrp png_ptr), - PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_handle_unknown,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_have_info,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_have_end,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_have_row,(png_structrp png_ptr, - png_bytep row),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_read_end,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_process_some_data,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_read_push_finish_row,(png_structrp png_ptr), - PNG_EMPTY); -# ifdef PNG_READ_tEXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_push_handle_tEXt,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_read_tEXt,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -# endif -# ifdef PNG_READ_zTXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_push_handle_zTXt,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_read_zTXt,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -# endif -# ifdef PNG_READ_iTXt_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_push_handle_iTXt,(png_structrp png_ptr, - png_inforp info_ptr, png_uint_32 length),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_push_read_iTXt,(png_structrp png_ptr, - png_inforp info_ptr),PNG_EMPTY); -# endif - -#endif /* PROGRESSIVE_READ */ - -/* Added at libpng version 1.6.0 */ -#ifdef PNG_GAMMA_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_fixed_point gAMA), PNG_EMPTY); - /* Set the colorspace gamma with a value provided by the application or by - * the gAMA chunk on read. The value will override anything set by an ICC - * profile. - */ - -PNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr, - png_inforp info_ptr), PNG_EMPTY); - /* Synchronize the info 'valid' flags with the colorspace */ - -PNG_INTERNAL_FUNCTION(void,png_colorspace_sync,(png_const_structrp png_ptr, - png_inforp info_ptr), PNG_EMPTY); - /* Copy the png_struct colorspace to the info_struct and call the above to - * synchronize the flags. Checks for NULL info_ptr and does nothing. - */ -#endif - -/* Added at libpng version 1.4.0 */ -#ifdef PNG_COLORSPACE_SUPPORTED -/* These internal functions are for maintaining the colorspace structure within - * a png_info or png_struct (or, indeed, both). - */ -PNG_INTERNAL_FUNCTION(int,png_colorspace_set_chromaticities, - (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_xy *xy, - int preferred), PNG_EMPTY); - -PNG_INTERNAL_FUNCTION(int,png_colorspace_set_endpoints, - (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_XYZ *XYZ, - int preferred), PNG_EMPTY); - -#ifdef PNG_sRGB_SUPPORTED -PNG_INTERNAL_FUNCTION(int,png_colorspace_set_sRGB,(png_const_structrp png_ptr, - png_colorspacerp colorspace, int intent), PNG_EMPTY); - /* This does set the colorspace gAMA and cHRM values too, but doesn't set the - * flags to write them, if it returns false there was a problem and an error - * message has already been output (but the colorspace may still need to be - * synced to record the invalid flag). - */ -#endif /* sRGB */ - -#ifdef PNG_iCCP_SUPPORTED -PNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_const_charp name, - png_uint_32 profile_length, png_const_bytep profile, int color_type), - PNG_EMPTY); - /* The 'name' is used for information only */ - -/* Routines for checking parts of an ICC profile. */ -#ifdef PNG_READ_iCCP_SUPPORTED -PNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_const_charp name, - png_uint_32 profile_length), PNG_EMPTY); -#endif /* READ_iCCP */ -PNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_const_charp name, - png_uint_32 profile_length, - png_const_bytep profile /* first 132 bytes only */, int color_type), - PNG_EMPTY); -PNG_INTERNAL_FUNCTION(int,png_icc_check_tag_table,(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_const_charp name, - png_uint_32 profile_length, - png_const_bytep profile /* header plus whole tag table */), PNG_EMPTY); -#ifdef PNG_sRGB_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_icc_set_sRGB,( - png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_bytep profile, uLong adler), PNG_EMPTY); - /* 'adler' is the Adler32 checksum of the uncompressed profile data. It may - * be zero to indicate that it is not available. It is used, if provided, - * as a fast check on the profile when checking to see if it is sRGB. - */ -#endif -#endif /* iCCP */ - -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_colorspace_set_rgb_coefficients, - (png_structrp png_ptr), PNG_EMPTY); - /* Set the rgb_to_gray coefficients from the colorspace Y values */ -#endif /* READ_RGB_TO_GRAY */ -#endif /* COLORSPACE */ - -/* Added at libpng version 1.4.0 */ -PNG_INTERNAL_FUNCTION(void,png_check_IHDR,(png_const_structrp png_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_type, int compression_type, - int filter_type),PNG_EMPTY); - -/* Added at libpng version 1.5.10 */ -#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \ - defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED) -PNG_INTERNAL_FUNCTION(void,png_do_check_palette_indexes, - (png_structrp png_ptr, png_row_infop row_info),PNG_EMPTY); -#endif - -#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED) -PNG_INTERNAL_FUNCTION(void,png_fixed_error,(png_const_structrp png_ptr, - png_const_charp name),PNG_NORETURN); -#endif - -/* Puts 'string' into 'buffer' at buffer[pos], taking care never to overwrite - * the end. Always leaves the buffer nul terminated. Never errors out (and - * there is no error code.) - */ -PNG_INTERNAL_FUNCTION(size_t,png_safecat,(png_charp buffer, size_t bufsize, - size_t pos, png_const_charp string),PNG_EMPTY); - -/* Various internal functions to handle formatted warning messages, currently - * only implemented for warnings. - */ -#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_TIME_RFC1123_SUPPORTED) -/* Utility to dump an unsigned value into a buffer, given a start pointer and - * and end pointer (which should point just *beyond* the end of the buffer!) - * Returns the pointer to the start of the formatted string. This utility only - * does unsigned values. - */ -PNG_INTERNAL_FUNCTION(png_charp,png_format_number,(png_const_charp start, - png_charp end, int format, png_alloc_size_t number),PNG_EMPTY); - -/* Convenience macro that takes an array: */ -#define PNG_FORMAT_NUMBER(buffer,format,number) \ - png_format_number(buffer, buffer + (sizeof buffer), format, number) - -/* Suggested size for a number buffer (enough for 64 bits and a sign!) */ -#define PNG_NUMBER_BUFFER_SIZE 24 - -/* These are the integer formats currently supported, the name is formed from - * the standard printf(3) format string. - */ -#define PNG_NUMBER_FORMAT_u 1 /* chose unsigned API! */ -#define PNG_NUMBER_FORMAT_02u 2 -#define PNG_NUMBER_FORMAT_d 1 /* chose signed API! */ -#define PNG_NUMBER_FORMAT_02d 2 -#define PNG_NUMBER_FORMAT_x 3 -#define PNG_NUMBER_FORMAT_02x 4 -#define PNG_NUMBER_FORMAT_fixed 5 /* choose the signed API */ -#endif - -#ifdef PNG_WARNINGS_SUPPORTED -/* New defines and members adding in libpng-1.5.4 */ -# define PNG_WARNING_PARAMETER_SIZE 32 -# define PNG_WARNING_PARAMETER_COUNT 8 /* Maximum 9; see pngerror.c */ - -/* An l-value of this type has to be passed to the APIs below to cache the - * values of the parameters to a formatted warning message. - */ -typedef char png_warning_parameters[PNG_WARNING_PARAMETER_COUNT][ - PNG_WARNING_PARAMETER_SIZE]; - -PNG_INTERNAL_FUNCTION(void,png_warning_parameter,(png_warning_parameters p, - int number, png_const_charp string),PNG_EMPTY); - /* Parameters are limited in size to PNG_WARNING_PARAMETER_SIZE characters, - * including the trailing '\0'. - */ -PNG_INTERNAL_FUNCTION(void,png_warning_parameter_unsigned, - (png_warning_parameters p, int number, int format, png_alloc_size_t value), - PNG_EMPTY); - /* Use png_alloc_size_t because it is an unsigned type as big as any we - * need to output. Use the following for a signed value. - */ -PNG_INTERNAL_FUNCTION(void,png_warning_parameter_signed, - (png_warning_parameters p, int number, int format, png_int_32 value), - PNG_EMPTY); - -PNG_INTERNAL_FUNCTION(void,png_formatted_warning,(png_const_structrp png_ptr, - png_warning_parameters p, png_const_charp message),PNG_EMPTY); - /* 'message' follows the X/Open approach of using @1, @2 to insert - * parameters previously supplied using the above functions. Errors in - * specifying the parameters will simply result in garbage substitutions. - */ -#endif - -#ifdef PNG_BENIGN_ERRORS_SUPPORTED -/* Application errors (new in 1.6); use these functions (declared below) for - * errors in the parameters or order of API function calls on read. The - * 'warning' should be used for an error that can be handled completely; the - * 'error' for one which can be handled safely but which may lose application - * information or settings. - * - * By default these both result in a png_error call prior to release, while in a - * released version the 'warning' is just a warning. However if the application - * explicitly disables benign errors (explicitly permitting the code to lose - * information) they both turn into warnings. - * - * If benign errors aren't supported they end up as the corresponding base call - * (png_warning or png_error.) - */ -PNG_INTERNAL_FUNCTION(void,png_app_warning,(png_const_structrp png_ptr, - png_const_charp message),PNG_EMPTY); - /* The application provided invalid parameters to an API function or called - * an API function at the wrong time, libpng can completely recover. - */ - -PNG_INTERNAL_FUNCTION(void,png_app_error,(png_const_structrp png_ptr, - png_const_charp message),PNG_EMPTY); - /* As above but libpng will ignore the call, or attempt some other partial - * recovery from the error. - */ -#else -# define png_app_warning(pp,s) png_warning(pp,s) -# define png_app_error(pp,s) png_error(pp,s) -#endif - -PNG_INTERNAL_FUNCTION(void,png_chunk_report,(png_const_structrp png_ptr, - png_const_charp message, int error),PNG_EMPTY); - /* Report a recoverable issue in chunk data. On read this is used to report - * a problem found while reading a particular chunk and the - * png_chunk_benign_error or png_chunk_warning function is used as - * appropriate. On write this is used to report an error that comes from - * data set via an application call to a png_set_ API and png_app_error or - * png_app_warning is used as appropriate. - * - * The 'error' parameter must have one of the following values: - */ -#define PNG_CHUNK_WARNING 0 /* never an error */ -#define PNG_CHUNK_WRITE_ERROR 1 /* an error only on write */ -#define PNG_CHUNK_ERROR 2 /* always an error */ - -/* ASCII to FP interfaces, currently only implemented if sCAL - * support is required. - */ -#if defined(PNG_sCAL_SUPPORTED) -/* MAX_DIGITS is actually the maximum number of characters in an sCAL - * width or height, derived from the precision (number of significant - * digits - a build time settable option) and assumptions about the - * maximum ridiculous exponent. - */ -#define PNG_sCAL_MAX_DIGITS (PNG_sCAL_PRECISION+1/*.*/+1/*E*/+10/*exponent*/) - -#ifdef PNG_FLOATING_POINT_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_ascii_from_fp,(png_const_structrp png_ptr, - png_charp ascii, size_t size, double fp, unsigned int precision), - PNG_EMPTY); -#endif /* FLOATING_POINT */ - -#ifdef PNG_FIXED_POINT_SUPPORTED -PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr, - png_charp ascii, size_t size, png_fixed_point fp),PNG_EMPTY); -#endif /* FIXED_POINT */ -#endif /* sCAL */ - -#if defined(PNG_sCAL_SUPPORTED) || defined(PNG_pCAL_SUPPORTED) -/* An internal API to validate the format of a floating point number. - * The result is the index of the next character. If the number is - * not valid it will be the index of a character in the supposed number. - * - * The format of a number is defined in the PNG extensions specification - * and this API is strictly conformant to that spec, not anyone elses! - * - * The format as a regular expression is: - * - * [+-]?[0-9]+.?([Ee][+-]?[0-9]+)? - * - * or: - * - * [+-]?.[0-9]+(.[0-9]+)?([Ee][+-]?[0-9]+)? - * - * The complexity is that either integer or fraction must be present and the - * fraction is permitted to have no digits only if the integer is present. - * - * NOTE: The dangling E problem. - * There is a PNG valid floating point number in the following: - * - * PNG floating point numbers are not greedy. - * - * Working this out requires *TWO* character lookahead (because of the - * sign), the parser does not do this - it will fail at the 'r' - this - * doesn't matter for PNG sCAL chunk values, but it requires more care - * if the value were ever to be embedded in something more complex. Use - * ANSI-C strtod if you need the lookahead. - */ -/* State table for the parser. */ -#define PNG_FP_INTEGER 0 /* before or in integer */ -#define PNG_FP_FRACTION 1 /* before or in fraction */ -#define PNG_FP_EXPONENT 2 /* before or in exponent */ -#define PNG_FP_STATE 3 /* mask for the above */ -#define PNG_FP_SAW_SIGN 4 /* Saw +/- in current state */ -#define PNG_FP_SAW_DIGIT 8 /* Saw a digit in current state */ -#define PNG_FP_SAW_DOT 16 /* Saw a dot in current state */ -#define PNG_FP_SAW_E 32 /* Saw an E (or e) in current state */ -#define PNG_FP_SAW_ANY 60 /* Saw any of the above 4 */ - -/* These three values don't affect the parser. They are set but not used. - */ -#define PNG_FP_WAS_VALID 64 /* Preceding substring is a valid fp number */ -#define PNG_FP_NEGATIVE 128 /* A negative number, including "-0" */ -#define PNG_FP_NONZERO 256 /* A non-zero value */ -#define PNG_FP_STICKY 448 /* The above three flags */ - -/* This is available for the caller to store in 'state' if required. Do not - * call the parser after setting it (the parser sometimes clears it.) - */ -#define PNG_FP_INVALID 512 /* Available for callers as a distinct value */ - -/* Result codes for the parser (boolean - true meants ok, false means - * not ok yet.) - */ -#define PNG_FP_MAYBE 0 /* The number may be valid in the future */ -#define PNG_FP_OK 1 /* The number is valid */ - -/* Tests on the sticky non-zero and negative flags. To pass these checks - * the state must also indicate that the whole number is valid - this is - * achieved by testing PNG_FP_SAW_DIGIT (see the implementation for why this - * is equivalent to PNG_FP_OK above.) - */ -#define PNG_FP_NZ_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NEGATIVE | PNG_FP_NONZERO) - /* NZ_MASK: the string is valid and a non-zero negative value */ -#define PNG_FP_Z_MASK (PNG_FP_SAW_DIGIT | PNG_FP_NONZERO) - /* Z MASK: the string is valid and a non-zero value. */ - /* PNG_FP_SAW_DIGIT: the string is valid. */ -#define PNG_FP_IS_ZERO(state) (((state) & PNG_FP_Z_MASK) == PNG_FP_SAW_DIGIT) -#define PNG_FP_IS_POSITIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_Z_MASK) -#define PNG_FP_IS_NEGATIVE(state) (((state) & PNG_FP_NZ_MASK) == PNG_FP_NZ_MASK) - -/* The actual parser. This can be called repeatedly. It updates - * the index into the string and the state variable (which must - * be initialized to 0). It returns a result code, as above. There - * is no point calling the parser any more if it fails to advance to - * the end of the string - it is stuck on an invalid character (or - * terminated by '\0'). - * - * Note that the pointer will consume an E or even an E+ and then leave - * a 'maybe' state even though a preceding integer.fraction is valid. - * The PNG_FP_WAS_VALID flag indicates that a preceding substring was - * a valid number. It's possible to recover from this by calling - * the parser again (from the start, with state 0) but with a string - * that omits the last character (i.e. set the size to the index of - * the problem character.) This has not been tested within libpng. - */ -PNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string, - size_t size, int *statep, png_size_tp whereami),PNG_EMPTY); - -/* This is the same but it checks a complete string and returns true - * only if it just contains a floating point number. As of 1.5.4 this - * function also returns the state at the end of parsing the number if - * it was valid (otherwise it returns 0.) This can be used for testing - * for negative or zero values using the sticky flag. - */ -PNG_INTERNAL_FUNCTION(int,png_check_fp_string,(png_const_charp string, - size_t size),PNG_EMPTY); -#endif /* pCAL || sCAL */ - -#if defined(PNG_GAMMA_SUPPORTED) ||\ - defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED) -/* Added at libpng version 1.5.0 */ -/* This is a utility to provide a*times/div (rounded) and indicate - * if there is an overflow. The result is a boolean - false (0) - * for overflow, true (1) if no overflow, in which case *res - * holds the result. - */ -PNG_INTERNAL_FUNCTION(int,png_muldiv,(png_fixed_point_p res, png_fixed_point a, - png_int_32 multiplied_by, png_int_32 divided_by),PNG_EMPTY); -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED) -/* Same deal, but issue a warning on overflow and return 0. */ -PNG_INTERNAL_FUNCTION(png_fixed_point,png_muldiv_warn, - (png_const_structrp png_ptr, png_fixed_point a, png_int_32 multiplied_by, - png_int_32 divided_by),PNG_EMPTY); -#endif - -#ifdef PNG_GAMMA_SUPPORTED -/* Calculate a reciprocal - used for gamma values. This returns - * 0 if the argument is 0 in order to maintain an undefined value; - * there are no warnings. - */ -PNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal,(png_fixed_point a), - PNG_EMPTY); - -#ifdef PNG_READ_GAMMA_SUPPORTED -/* The same but gives a reciprocal of the product of two fixed point - * values. Accuracy is suitable for gamma calculations but this is - * not exact - use png_muldiv for that. Only required at present on read. - */ -PNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal2,(png_fixed_point a, - png_fixed_point b),PNG_EMPTY); -#endif - -/* Return true if the gamma value is significantly different from 1.0 */ -PNG_INTERNAL_FUNCTION(int,png_gamma_significant,(png_fixed_point gamma_value), - PNG_EMPTY); -#endif - -#ifdef PNG_READ_GAMMA_SUPPORTED -/* Internal fixed point gamma correction. These APIs are called as - * required to convert single values - they don't need to be fast, - * they are not used when processing image pixel values. - * - * While the input is an 'unsigned' value it must actually be the - * correct bit value - 0..255 or 0..65535 as required. - */ -PNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_correct,(png_structrp png_ptr, - unsigned int value, png_fixed_point gamma_value),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_16bit_correct,(unsigned int value, - png_fixed_point gamma_value),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(png_byte,png_gamma_8bit_correct,(unsigned int value, - png_fixed_point gamma_value),PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_destroy_gamma_table,(png_structrp png_ptr), - PNG_EMPTY); -PNG_INTERNAL_FUNCTION(void,png_build_gamma_table,(png_structrp png_ptr, - int bit_depth),PNG_EMPTY); -#endif - -/* SIMPLIFIED READ/WRITE SUPPORT */ -#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\ - defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) -/* The internal structure that png_image::opaque points to. */ -typedef struct png_control -{ - png_structp png_ptr; - png_infop info_ptr; - png_voidp error_buf; /* Always a jmp_buf at present. */ - - png_const_bytep memory; /* Memory buffer. */ - size_t size; /* Size of the memory buffer. */ - - unsigned int for_write :1; /* Otherwise it is a read structure */ - unsigned int owned_file :1; /* We own the file in io_ptr */ -} png_control; - -/* Return the pointer to the jmp_buf from a png_control: necessary because C - * does not reveal the type of the elements of jmp_buf. - */ -#ifdef __cplusplus -# define png_control_jmp_buf(pc) (((jmp_buf*)((pc)->error_buf))[0]) -#else -# define png_control_jmp_buf(pc) ((pc)->error_buf) -#endif - -/* Utility to safely execute a piece of libpng code catching and logging any - * errors that might occur. Returns true on success, false on failure (either - * of the function or as a result of a png_error.) - */ -PNG_INTERNAL_CALLBACK(void,png_safe_error,(png_structp png_ptr, - png_const_charp error_message),PNG_NORETURN); - -#ifdef PNG_WARNINGS_SUPPORTED -PNG_INTERNAL_CALLBACK(void,png_safe_warning,(png_structp png_ptr, - png_const_charp warning_message),PNG_EMPTY); -#else -# define png_safe_warning 0/*dummy argument*/ -#endif - -PNG_INTERNAL_FUNCTION(int,png_safe_execute,(png_imagep image, - int (*function)(png_voidp), png_voidp arg),PNG_EMPTY); - -/* Utility to log an error; this also cleans up the png_image; the function - * always returns 0 (false). - */ -PNG_INTERNAL_FUNCTION(int,png_image_error,(png_imagep image, - png_const_charp error_message),PNG_EMPTY); - -#ifndef PNG_SIMPLIFIED_READ_SUPPORTED -/* png_image_free is used by the write code but not exported */ -PNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY); -#endif /* !SIMPLIFIED_READ */ - -#endif /* SIMPLIFIED READ/WRITE */ - -/* These are initialization functions for hardware specific PNG filter - * optimizations; list these here then select the appropriate one at compile - * time using the macro PNG_FILTER_OPTIMIZATIONS. If the macro is not defined - * the generic code is used. - */ -#ifdef PNG_FILTER_OPTIMIZATIONS -PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr, - unsigned int bpp), PNG_EMPTY); - /* Just declare the optimization that will be used */ -#else - /* List *all* the possible optimizations here - this branch is required if - * the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in - * CFLAGS in place of CPPFLAGS *and* uses symbol prefixing. - */ -# if PNG_ARM_NEON_OPT > 0 -PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon, - (png_structp png_ptr, unsigned int bpp), PNG_EMPTY); -#endif - -#if PNG_MIPS_MSA_OPT > 0 -PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_msa, - (png_structp png_ptr, unsigned int bpp), PNG_EMPTY); -#endif - -# if PNG_INTEL_SSE_IMPLEMENTATION > 0 -PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_sse2, - (png_structp png_ptr, unsigned int bpp), PNG_EMPTY); -# endif -#endif - -PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr, - png_const_charp key, png_bytep new_key), PNG_EMPTY); - -#if PNG_ARM_NEON_IMPLEMENTATION == 1 -PNG_INTERNAL_FUNCTION(void, - png_riffle_palette_neon, - (png_structrp), - PNG_EMPTY); -PNG_INTERNAL_FUNCTION(int, - png_do_expand_palette_rgba8_neon, - (png_structrp, - png_row_infop, - png_const_bytep, - const png_bytepp, - const png_bytepp), - PNG_EMPTY); -PNG_INTERNAL_FUNCTION(int, - png_do_expand_palette_rgb8_neon, - (png_structrp, - png_row_infop, - png_const_bytep, - const png_bytepp, - const png_bytepp), - PNG_EMPTY); -#endif - -/* Maintainer: Put new private prototypes here ^ */ - -#include "pngdebug.h" - -#ifdef __cplusplus -} -#endif - -#endif /* PNG_VERSION_INFO_ONLY */ -#endif /* PNGPRIV_H */ diff --git a/oversampling/WDL/libpng/pngread.c b/oversampling/WDL/libpng/pngread.c deleted file mode 100644 index 8fa7d9f..0000000 --- a/oversampling/WDL/libpng/pngread.c +++ /dev/null @@ -1,4225 +0,0 @@ - -/* pngread.c - read a PNG file - * - * Copyright (c) 2018-2019 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * - * This file contains routines that an application calls directly to - * read a PNG file or stream. - */ - -#include "pngpriv.h" -#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) -# include -#endif - -#ifdef PNG_READ_SUPPORTED - -/* Create a PNG structure for reading, and allocate any memory needed. */ -PNG_FUNCTION(png_structp,PNGAPI -png_create_read_struct,(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED) -{ -#ifndef PNG_USER_MEM_SUPPORTED - png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr, - error_fn, warn_fn, NULL, NULL, NULL); -#else - return png_create_read_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, NULL, NULL, NULL); -} - -/* Alternate create PNG structure for reading, and allocate any memory - * needed. - */ -PNG_FUNCTION(png_structp,PNGAPI -png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) -{ - png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr, - error_fn, warn_fn, mem_ptr, malloc_fn, free_fn); -#endif /* USER_MEM */ - - if (png_ptr != NULL) - { - png_ptr->mode = PNG_IS_READ_STRUCT; - - /* Added in libpng-1.6.0; this can be used to detect a read structure if - * required (it will be zero in a write structure.) - */ -# ifdef PNG_SEQUENTIAL_READ_SUPPORTED - png_ptr->IDAT_read_size = PNG_IDAT_READ_SIZE; -# endif - -# ifdef PNG_BENIGN_READ_ERRORS_SUPPORTED - png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN; - - /* In stable builds only warn if an application error can be completely - * handled. - */ -# if PNG_RELEASE_BUILD - png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN; -# endif -# endif - - /* TODO: delay this, it can be done in png_init_io (if the app doesn't - * do it itself) avoiding setting the default function if it is not - * required. - */ - png_set_read_fn(png_ptr, NULL, NULL); - } - - return png_ptr; -} - - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read the information before the actual image data. This has been - * changed in v0.90 to allow reading a file that already has the magic - * bytes read from the stream. You can tell libpng how many bytes have - * been read from the beginning of the stream (up to the maximum of 8) - * via png_set_sig_bytes(), and we will only check the remaining bytes - * here. The application can then have access to the signature bytes we - * read if it is determined that this isn't a valid PNG file. - */ -void PNGAPI -png_read_info(png_structrp png_ptr, png_inforp info_ptr) -{ -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - int keep; -#endif - - png_debug(1, "in png_read_info"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - /* Read and check the PNG file signature. */ - png_read_sig(png_ptr, info_ptr); - - for (;;) - { - png_uint_32 length = png_read_chunk_header(png_ptr); - png_uint_32 chunk_name = png_ptr->chunk_name; - - /* IDAT logic needs to happen here to simplify getting the two flags - * right. - */ - if (chunk_name == png_IDAT) - { - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "Missing IHDR before IDAT"); - - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - (png_ptr->mode & PNG_HAVE_PLTE) == 0) - png_chunk_error(png_ptr, "Missing PLTE before IDAT"); - - else if ((png_ptr->mode & PNG_AFTER_IDAT) != 0) - png_chunk_benign_error(png_ptr, "Too many IDATs found"); - - png_ptr->mode |= PNG_HAVE_IDAT; - } - - else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) - { - png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; - png_ptr->mode |= PNG_AFTER_IDAT; - } - - /* This should be a binary subdivision search or a hash for - * matching the chunk name rather than a linear search. - */ - if (chunk_name == png_IHDR) - png_handle_IHDR(png_ptr, info_ptr, length); - - else if (chunk_name == png_IEND) - png_handle_IEND(png_ptr, info_ptr, length); - -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0) - { - png_handle_unknown(png_ptr, info_ptr, length, keep); - - if (chunk_name == png_PLTE) - png_ptr->mode |= PNG_HAVE_PLTE; - - else if (chunk_name == png_IDAT) - { - png_ptr->idat_size = 0; /* It has been consumed */ - break; - } - } -#endif - else if (chunk_name == png_PLTE) - png_handle_PLTE(png_ptr, info_ptr, length); - - else if (chunk_name == png_IDAT) - { - png_ptr->idat_size = length; - break; - } - -#ifdef PNG_READ_bKGD_SUPPORTED - else if (chunk_name == png_bKGD) - png_handle_bKGD(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_cHRM_SUPPORTED - else if (chunk_name == png_cHRM) - png_handle_cHRM(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_eXIf_SUPPORTED - else if (chunk_name == png_eXIf) - png_handle_eXIf(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_gAMA_SUPPORTED - else if (chunk_name == png_gAMA) - png_handle_gAMA(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_hIST_SUPPORTED - else if (chunk_name == png_hIST) - png_handle_hIST(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_oFFs_SUPPORTED - else if (chunk_name == png_oFFs) - png_handle_oFFs(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_pCAL_SUPPORTED - else if (chunk_name == png_pCAL) - png_handle_pCAL(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_sCAL_SUPPORTED - else if (chunk_name == png_sCAL) - png_handle_sCAL(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_pHYs_SUPPORTED - else if (chunk_name == png_pHYs) - png_handle_pHYs(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_sBIT_SUPPORTED - else if (chunk_name == png_sBIT) - png_handle_sBIT(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_sRGB_SUPPORTED - else if (chunk_name == png_sRGB) - png_handle_sRGB(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_iCCP_SUPPORTED - else if (chunk_name == png_iCCP) - png_handle_iCCP(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_sPLT_SUPPORTED - else if (chunk_name == png_sPLT) - png_handle_sPLT(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_tEXt_SUPPORTED - else if (chunk_name == png_tEXt) - png_handle_tEXt(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_tIME_SUPPORTED - else if (chunk_name == png_tIME) - png_handle_tIME(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_tRNS_SUPPORTED - else if (chunk_name == png_tRNS) - png_handle_tRNS(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_zTXt_SUPPORTED - else if (chunk_name == png_zTXt) - png_handle_zTXt(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_iTXt_SUPPORTED - else if (chunk_name == png_iTXt) - png_handle_iTXt(png_ptr, info_ptr, length); -#endif - - else - png_handle_unknown(png_ptr, info_ptr, length, - PNG_HANDLE_CHUNK_AS_DEFAULT); - } -} -#endif /* SEQUENTIAL_READ */ - -/* Optional call to update the users info_ptr structure */ -void PNGAPI -png_read_update_info(png_structrp png_ptr, png_inforp info_ptr) -{ - png_debug(1, "in png_read_update_info"); - - if (png_ptr != NULL) - { - if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) - { - png_read_start_row(png_ptr); - -# ifdef PNG_READ_TRANSFORMS_SUPPORTED - png_read_transform_info(png_ptr, info_ptr); -# else - PNG_UNUSED(info_ptr) -# endif - } - - /* New in 1.6.0 this avoids the bug of doing the initializations twice */ - else - png_app_error(png_ptr, - "png_read_update_info/png_start_read_image: duplicate call"); - } -} - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Initialize palette, background, etc, after transformations - * are set, but before any reading takes place. This allows - * the user to obtain a gamma-corrected palette, for example. - * If the user doesn't call this, we will do it ourselves. - */ -void PNGAPI -png_start_read_image(png_structrp png_ptr) -{ - png_debug(1, "in png_start_read_image"); - - if (png_ptr != NULL) - { - if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) - png_read_start_row(png_ptr); - - /* New in 1.6.0 this avoids the bug of doing the initializations twice */ - else - png_app_error(png_ptr, - "png_start_read_image/png_read_update_info: duplicate call"); - } -} -#endif /* SEQUENTIAL_READ */ - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -#ifdef PNG_MNG_FEATURES_SUPPORTED -/* Undoes intrapixel differencing, - * NOTE: this is apparently only supported in the 'sequential' reader. - */ -static void -png_do_read_intrapixel(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_read_intrapixel"); - - if ( - (row_info->color_type & PNG_COLOR_MASK_COLOR) != 0) - { - int bytes_per_pixel; - png_uint_32 row_width = row_info->width; - - if (row_info->bit_depth == 8) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 3; - - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 4; - - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - *(rp) = (png_byte)((256 + *rp + *(rp + 1)) & 0xff); - *(rp+2) = (png_byte)((256 + *(rp + 2) + *(rp + 1)) & 0xff); - } - } - else if (row_info->bit_depth == 16) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 6; - - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 8; - - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - png_uint_32 s0 = (png_uint_32)(*(rp ) << 8) | *(rp + 1); - png_uint_32 s1 = (png_uint_32)(*(rp + 2) << 8) | *(rp + 3); - png_uint_32 s2 = (png_uint_32)(*(rp + 4) << 8) | *(rp + 5); - png_uint_32 red = (s0 + s1 + 65536) & 0xffff; - png_uint_32 blue = (s2 + s1 + 65536) & 0xffff; - *(rp ) = (png_byte)((red >> 8) & 0xff); - *(rp + 1) = (png_byte)(red & 0xff); - *(rp + 4) = (png_byte)((blue >> 8) & 0xff); - *(rp + 5) = (png_byte)(blue & 0xff); - } - } - } -} -#endif /* MNG_FEATURES */ - -void PNGAPI -png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) -{ - png_row_info row_info; - - if (png_ptr == NULL) - return; - - png_debug2(1, "in png_read_row (row %lu, pass %d)", - (unsigned long)png_ptr->row_number, png_ptr->pass); - - /* png_read_start_row sets the information (in particular iwidth) for this - * interlace pass. - */ - if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) - png_read_start_row(png_ptr); - - /* 1.5.6: row_info moved out of png_struct to a local here. */ - row_info.width = png_ptr->iwidth; /* NOTE: width of current interlaced row */ - row_info.color_type = png_ptr->color_type; - row_info.bit_depth = png_ptr->bit_depth; - row_info.channels = png_ptr->channels; - row_info.pixel_depth = png_ptr->pixel_depth; - row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width); - -#ifdef PNG_WARNINGS_SUPPORTED - if (png_ptr->row_number == 0 && png_ptr->pass == 0) - { - /* Check for transforms that have been set but were defined out */ -#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) - if ((png_ptr->transformations & PNG_INVERT_MONO) != 0) - png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined"); -#endif - -#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED) - if ((png_ptr->transformations & PNG_FILLER) != 0) - png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined"); -#endif - -#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \ - !defined(PNG_READ_PACKSWAP_SUPPORTED) - if ((png_ptr->transformations & PNG_PACKSWAP) != 0) - png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined"); -#endif - -#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED) - if ((png_ptr->transformations & PNG_PACK) != 0) - png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined"); -#endif - -#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) - if ((png_ptr->transformations & PNG_SHIFT) != 0) - png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined"); -#endif - -#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED) - if ((png_ptr->transformations & PNG_BGR) != 0) - png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined"); -#endif - -#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED) - if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0) - png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined"); -#endif - } -#endif /* WARNINGS */ - -#ifdef PNG_READ_INTERLACING_SUPPORTED - /* If interlaced and we do not need a new row, combine row and return. - * Notice that the pixels we have from previous rows have been transformed - * already; we can only combine like with like (transformed or - * untransformed) and, because of the libpng API for interlaced images, this - * means we must transform before de-interlacing. - */ - if (png_ptr->interlaced != 0 && - (png_ptr->transformations & PNG_INTERLACE) != 0) - { - switch (png_ptr->pass) - { - case 0: - if (png_ptr->row_number & 0x07) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, 1/*display*/); - png_read_finish_row(png_ptr); - return; - } - break; - - case 1: - if ((png_ptr->row_number & 0x07) || png_ptr->width < 5) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, 1/*display*/); - - png_read_finish_row(png_ptr); - return; - } - break; - - case 2: - if ((png_ptr->row_number & 0x07) != 4) - { - if (dsp_row != NULL && (png_ptr->row_number & 4)) - png_combine_row(png_ptr, dsp_row, 1/*display*/); - - png_read_finish_row(png_ptr); - return; - } - break; - - case 3: - if ((png_ptr->row_number & 3) || png_ptr->width < 3) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, 1/*display*/); - - png_read_finish_row(png_ptr); - return; - } - break; - - case 4: - if ((png_ptr->row_number & 3) != 2) - { - if (dsp_row != NULL && (png_ptr->row_number & 2)) - png_combine_row(png_ptr, dsp_row, 1/*display*/); - - png_read_finish_row(png_ptr); - return; - } - break; - - case 5: - if ((png_ptr->row_number & 1) || png_ptr->width < 2) - { - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, 1/*display*/); - - png_read_finish_row(png_ptr); - return; - } - break; - - default: - case 6: - if ((png_ptr->row_number & 1) == 0) - { - png_read_finish_row(png_ptr); - return; - } - break; - } - } -#endif - - if ((png_ptr->mode & PNG_HAVE_IDAT) == 0) - png_error(png_ptr, "Invalid attempt to read row data"); - - /* Fill the row with IDAT data: */ - png_ptr->row_buf[0]=255; /* to force error if no data was found */ - png_read_IDAT_data(png_ptr, png_ptr->row_buf, row_info.rowbytes + 1); - - if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE) - { - if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST) - png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1, - png_ptr->prev_row + 1, png_ptr->row_buf[0]); - else - png_error(png_ptr, "bad adaptive filter value"); - } - - /* libpng 1.5.6: the following line was copying png_ptr->rowbytes before - * 1.5.6, while the buffer really is this big in current versions of libpng - * it may not be in the future, so this was changed just to copy the - * interlaced count: - */ - memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1); - -#ifdef PNG_MNG_FEATURES_SUPPORTED - if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 && - (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) - { - /* Intrapixel differencing */ - png_do_read_intrapixel(&row_info, png_ptr->row_buf + 1); - } -#endif - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED - if (png_ptr->transformations) - png_do_read_transformations(png_ptr, &row_info); -#endif - - /* The transformed pixel depth should match the depth now in row_info. */ - if (png_ptr->transformed_pixel_depth == 0) - { - png_ptr->transformed_pixel_depth = row_info.pixel_depth; - if (row_info.pixel_depth > png_ptr->maximum_pixel_depth) - png_error(png_ptr, "sequential row overflow"); - } - - else if (png_ptr->transformed_pixel_depth != row_info.pixel_depth) - png_error(png_ptr, "internal sequential row size calculation error"); - -#ifdef PNG_READ_INTERLACING_SUPPORTED - /* Expand interlaced rows to full size */ - if (png_ptr->interlaced != 0 && - (png_ptr->transformations & PNG_INTERLACE) != 0) - { - if (png_ptr->pass < 6) - png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass, - png_ptr->transformations); - - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, 1/*display*/); - - if (row != NULL) - png_combine_row(png_ptr, row, 0/*row*/); - } - - else -#endif - { - if (row != NULL) - png_combine_row(png_ptr, row, -1/*ignored*/); - - if (dsp_row != NULL) - png_combine_row(png_ptr, dsp_row, -1/*ignored*/); - } - png_read_finish_row(png_ptr); - - if (png_ptr->read_row_fn != NULL) - (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); - -} -#endif /* SEQUENTIAL_READ */ - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read one or more rows of image data. If the image is interlaced, - * and png_set_interlace_handling() has been called, the rows need to - * contain the contents of the rows from the previous pass. If the - * image has alpha or transparency, and png_handle_alpha()[*] has been - * called, the rows contents must be initialized to the contents of the - * screen. - * - * "row" holds the actual image, and pixels are placed in it - * as they arrive. If the image is displayed after each pass, it will - * appear to "sparkle" in. "display_row" can be used to display a - * "chunky" progressive image, with finer detail added as it becomes - * available. If you do not want this "chunky" display, you may pass - * NULL for display_row. If you do not want the sparkle display, and - * you have not called png_handle_alpha(), you may pass NULL for rows. - * If you have called png_handle_alpha(), and the image has either an - * alpha channel or a transparency chunk, you must provide a buffer for - * rows. In this case, you do not have to provide a display_row buffer - * also, but you may. If the image is not interlaced, or if you have - * not called png_set_interlace_handling(), the display_row buffer will - * be ignored, so pass NULL to it. - * - * [*] png_handle_alpha() does not exist yet, as of this version of libpng - */ - -void PNGAPI -png_read_rows(png_structrp png_ptr, png_bytepp row, - png_bytepp display_row, png_uint_32 num_rows) -{ - png_uint_32 i; - png_bytepp rp; - png_bytepp dp; - - png_debug(1, "in png_read_rows"); - - if (png_ptr == NULL) - return; - - rp = row; - dp = display_row; - if (rp != NULL && dp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep rptr = *rp++; - png_bytep dptr = *dp++; - - png_read_row(png_ptr, rptr, dptr); - } - - else if (rp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep rptr = *rp; - png_read_row(png_ptr, rptr, NULL); - rp++; - } - - else if (dp != NULL) - for (i = 0; i < num_rows; i++) - { - png_bytep dptr = *dp; - png_read_row(png_ptr, NULL, dptr); - dp++; - } -} -#endif /* SEQUENTIAL_READ */ - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read the entire image. If the image has an alpha channel or a tRNS - * chunk, and you have called png_handle_alpha()[*], you will need to - * initialize the image to the current image that PNG will be overlaying. - * We set the num_rows again here, in case it was incorrectly set in - * png_read_start_row() by a call to png_read_update_info() or - * png_start_read_image() if png_set_interlace_handling() wasn't called - * prior to either of these functions like it should have been. You can - * only call this function once. If you desire to have an image for - * each pass of a interlaced image, use png_read_rows() instead. - * - * [*] png_handle_alpha() does not exist yet, as of this version of libpng - */ -void PNGAPI -png_read_image(png_structrp png_ptr, png_bytepp image) -{ - png_uint_32 i, image_height; - int pass, j; - png_bytepp rp; - - png_debug(1, "in png_read_image"); - - if (png_ptr == NULL) - return; - -#ifdef PNG_READ_INTERLACING_SUPPORTED - if ((png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) - { - pass = png_set_interlace_handling(png_ptr); - /* And make sure transforms are initialized. */ - png_start_read_image(png_ptr); - } - else - { - if (png_ptr->interlaced != 0 && - (png_ptr->transformations & PNG_INTERLACE) == 0) - { - /* Caller called png_start_read_image or png_read_update_info without - * first turning on the PNG_INTERLACE transform. We can fix this here, - * but the caller should do it! - */ - png_warning(png_ptr, "Interlace handling should be turned on when " - "using png_read_image"); - /* Make sure this is set correctly */ - png_ptr->num_rows = png_ptr->height; - } - - /* Obtain the pass number, which also turns on the PNG_INTERLACE flag in - * the above error case. - */ - pass = png_set_interlace_handling(png_ptr); - } -#else - if (png_ptr->interlaced) - png_error(png_ptr, - "Cannot read interlaced image -- interlace handler disabled"); - - pass = 1; -#endif - - image_height=png_ptr->height; - - for (j = 0; j < pass; j++) - { - rp = image; - for (i = 0; i < image_height; i++) - { - png_read_row(png_ptr, *rp, NULL); - rp++; - } - } -} -#endif /* SEQUENTIAL_READ */ - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read the end of the PNG file. Will not read past the end of the - * file, will verify the end is accurate, and will read any comments - * or time information at the end of the file, if info is not NULL. - */ -void PNGAPI -png_read_end(png_structrp png_ptr, png_inforp info_ptr) -{ -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - int keep; -#endif - - png_debug(1, "in png_read_end"); - - if (png_ptr == NULL) - return; - - /* If png_read_end is called in the middle of reading the rows there may - * still be pending IDAT data and an owned zstream. Deal with this here. - */ -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - if (png_chunk_unknown_handling(png_ptr, png_IDAT) == 0) -#endif - png_read_finish_IDAT(png_ptr); - -#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED - /* Report invalid palette index; added at libng-1.5.10 */ - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - png_ptr->num_palette_max > png_ptr->num_palette) - png_benign_error(png_ptr, "Read palette index exceeding num_palette"); -#endif - - do - { - png_uint_32 length = png_read_chunk_header(png_ptr); - png_uint_32 chunk_name = png_ptr->chunk_name; - - if (chunk_name != png_IDAT) - png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; - - if (chunk_name == png_IEND) - png_handle_IEND(png_ptr, info_ptr, length); - - else if (chunk_name == png_IHDR) - png_handle_IHDR(png_ptr, info_ptr, length); - - else if (info_ptr == NULL) - png_crc_finish(png_ptr, length); - -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0) - { - if (chunk_name == png_IDAT) - { - if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)) - || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0) - png_benign_error(png_ptr, ".Too many IDATs found"); - } - png_handle_unknown(png_ptr, info_ptr, length, keep); - if (chunk_name == png_PLTE) - png_ptr->mode |= PNG_HAVE_PLTE; - } -#endif - - else if (chunk_name == png_IDAT) - { - /* Zero length IDATs are legal after the last IDAT has been - * read, but not after other chunks have been read. 1.6 does not - * always read all the deflate data; specifically it cannot be relied - * upon to read the Adler32 at the end. If it doesn't ignore IDAT - * chunks which are longer than zero as well: - */ - if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)) - || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0) - png_benign_error(png_ptr, "..Too many IDATs found"); - - png_crc_finish(png_ptr, length); - } - else if (chunk_name == png_PLTE) - png_handle_PLTE(png_ptr, info_ptr, length); - -#ifdef PNG_READ_bKGD_SUPPORTED - else if (chunk_name == png_bKGD) - png_handle_bKGD(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_cHRM_SUPPORTED - else if (chunk_name == png_cHRM) - png_handle_cHRM(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_eXIf_SUPPORTED - else if (chunk_name == png_eXIf) - png_handle_eXIf(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_gAMA_SUPPORTED - else if (chunk_name == png_gAMA) - png_handle_gAMA(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_hIST_SUPPORTED - else if (chunk_name == png_hIST) - png_handle_hIST(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_oFFs_SUPPORTED - else if (chunk_name == png_oFFs) - png_handle_oFFs(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_pCAL_SUPPORTED - else if (chunk_name == png_pCAL) - png_handle_pCAL(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_sCAL_SUPPORTED - else if (chunk_name == png_sCAL) - png_handle_sCAL(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_pHYs_SUPPORTED - else if (chunk_name == png_pHYs) - png_handle_pHYs(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_sBIT_SUPPORTED - else if (chunk_name == png_sBIT) - png_handle_sBIT(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_sRGB_SUPPORTED - else if (chunk_name == png_sRGB) - png_handle_sRGB(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_iCCP_SUPPORTED - else if (chunk_name == png_iCCP) - png_handle_iCCP(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_sPLT_SUPPORTED - else if (chunk_name == png_sPLT) - png_handle_sPLT(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_tEXt_SUPPORTED - else if (chunk_name == png_tEXt) - png_handle_tEXt(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_tIME_SUPPORTED - else if (chunk_name == png_tIME) - png_handle_tIME(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_tRNS_SUPPORTED - else if (chunk_name == png_tRNS) - png_handle_tRNS(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_zTXt_SUPPORTED - else if (chunk_name == png_zTXt) - png_handle_zTXt(png_ptr, info_ptr, length); -#endif - -#ifdef PNG_READ_iTXt_SUPPORTED - else if (chunk_name == png_iTXt) - png_handle_iTXt(png_ptr, info_ptr, length); -#endif - - else - png_handle_unknown(png_ptr, info_ptr, length, - PNG_HANDLE_CHUNK_AS_DEFAULT); - } while ((png_ptr->mode & PNG_HAVE_IEND) == 0); -} -#endif /* SEQUENTIAL_READ */ - -/* Free all memory used in the read struct */ -static void -png_read_destroy(png_structrp png_ptr) -{ - png_debug(1, "in png_read_destroy"); - -#ifdef PNG_READ_GAMMA_SUPPORTED - png_destroy_gamma_table(png_ptr); -#endif - - png_free(png_ptr, png_ptr->big_row_buf); - png_ptr->big_row_buf = NULL; - png_free(png_ptr, png_ptr->big_prev_row); - png_ptr->big_prev_row = NULL; - png_free(png_ptr, png_ptr->read_buffer); - png_ptr->read_buffer = NULL; - -#ifdef PNG_READ_QUANTIZE_SUPPORTED - png_free(png_ptr, png_ptr->palette_lookup); - png_ptr->palette_lookup = NULL; - png_free(png_ptr, png_ptr->quantize_index); - png_ptr->quantize_index = NULL; -#endif - - if ((png_ptr->free_me & PNG_FREE_PLTE) != 0) - { - png_zfree(png_ptr, png_ptr->palette); - png_ptr->palette = NULL; - } - png_ptr->free_me &= ~PNG_FREE_PLTE; - -#if defined(PNG_tRNS_SUPPORTED) || \ - defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - if ((png_ptr->free_me & PNG_FREE_TRNS) != 0) - { - png_free(png_ptr, png_ptr->trans_alpha); - png_ptr->trans_alpha = NULL; - } - png_ptr->free_me &= ~PNG_FREE_TRNS; -#endif - - inflateEnd(&png_ptr->zstream); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - png_free(png_ptr, png_ptr->save_buffer); - png_ptr->save_buffer = NULL; -#endif - -#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) && \ - defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - png_free(png_ptr, png_ptr->unknown_chunk.data); - png_ptr->unknown_chunk.data = NULL; -#endif - -#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list = NULL; -#endif - -#if defined(PNG_READ_EXPAND_SUPPORTED) && \ - defined(PNG_ARM_NEON_IMPLEMENTATION) - png_free(png_ptr, png_ptr->riffled_palette); - png_ptr->riffled_palette = NULL; -#endif - - /* NOTE: the 'setjmp' buffer may still be allocated and the memory and error - * callbacks are still set at this point. They are required to complete the - * destruction of the png_struct itself. - */ -} - -/* Free all memory used by the read */ -void PNGAPI -png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, - png_infopp end_info_ptr_ptr) -{ - png_structrp png_ptr = NULL; - - png_debug(1, "in png_destroy_read_struct"); - - if (png_ptr_ptr != NULL) - png_ptr = *png_ptr_ptr; - - if (png_ptr == NULL) - return; - - /* libpng 1.6.0: use the API to destroy info structs to ensure consistent - * behavior. Prior to 1.6.0 libpng did extra 'info' destruction in this API. - * The extra was, apparently, unnecessary yet this hides memory leak bugs. - */ - png_destroy_info_struct(png_ptr, end_info_ptr_ptr); - png_destroy_info_struct(png_ptr, info_ptr_ptr); - - *png_ptr_ptr = NULL; - png_read_destroy(png_ptr); - png_destroy_png_struct(png_ptr); -} - -void PNGAPI -png_set_read_status_fn(png_structrp png_ptr, png_read_status_ptr read_row_fn) -{ - if (png_ptr == NULL) - return; - - png_ptr->read_row_fn = read_row_fn; -} - - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -#ifdef PNG_INFO_IMAGE_SUPPORTED -void PNGAPI -png_read_png(png_structrp png_ptr, png_inforp info_ptr, - int transforms, voidp params) -{ - if (png_ptr == NULL || info_ptr == NULL) - return; - - /* png_read_info() gives us all of the information from the - * PNG file before the first IDAT (image data chunk). - */ - png_read_info(png_ptr, info_ptr); - if (info_ptr->height > PNG_UINT_32_MAX/(sizeof (png_bytep))) - png_error(png_ptr, "Image is too high to process with png_read_png()"); - - /* -------------- image transformations start here ------------------- */ - /* libpng 1.6.10: add code to cause a png_app_error if a selected TRANSFORM - * is not implemented. This will only happen in de-configured (non-default) - * libpng builds. The results can be unexpected - png_read_png may return - * short or mal-formed rows because the transform is skipped. - */ - - /* Tell libpng to strip 16-bit/color files down to 8 bits per color. - */ - if ((transforms & PNG_TRANSFORM_SCALE_16) != 0) - /* Added at libpng-1.5.4. "strip_16" produces the same result that it - * did in earlier versions, while "scale_16" is now more accurate. - */ -#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED - png_set_scale_16(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_SCALE_16 not supported"); -#endif - - /* If both SCALE and STRIP are required pngrtran will effectively cancel the - * latter by doing SCALE first. This is ok and allows apps not to check for - * which is supported to get the right answer. - */ - if ((transforms & PNG_TRANSFORM_STRIP_16) != 0) -#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED - png_set_strip_16(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_16 not supported"); -#endif - - /* Strip alpha bytes from the input data without combining with - * the background (not recommended). - */ - if ((transforms & PNG_TRANSFORM_STRIP_ALPHA) != 0) -#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED - png_set_strip_alpha(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_ALPHA not supported"); -#endif - - /* Extract multiple pixels with bit depths of 1, 2, or 4 from a single - * byte into separate bytes (useful for paletted and grayscale images). - */ - if ((transforms & PNG_TRANSFORM_PACKING) != 0) -#ifdef PNG_READ_PACK_SUPPORTED - png_set_packing(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_PACKING not supported"); -#endif - - /* Change the order of packed pixels to least significant bit first - * (not useful if you are using png_set_packing). - */ - if ((transforms & PNG_TRANSFORM_PACKSWAP) != 0) -#ifdef PNG_READ_PACKSWAP_SUPPORTED - png_set_packswap(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_PACKSWAP not supported"); -#endif - - /* Expand paletted colors into true RGB triplets - * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel - * Expand paletted or RGB images with transparency to full alpha - * channels so the data will be available as RGBA quartets. - */ - if ((transforms & PNG_TRANSFORM_EXPAND) != 0) -#ifdef PNG_READ_EXPAND_SUPPORTED - png_set_expand(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_EXPAND not supported"); -#endif - - /* We don't handle background color or gamma transformation or quantizing. - */ - - /* Invert monochrome files to have 0 as white and 1 as black - */ - if ((transforms & PNG_TRANSFORM_INVERT_MONO) != 0) -#ifdef PNG_READ_INVERT_SUPPORTED - png_set_invert_mono(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_MONO not supported"); -#endif - - /* If you want to shift the pixel values from the range [0,255] or - * [0,65535] to the original [0,7] or [0,31], or whatever range the - * colors were originally in: - */ - if ((transforms & PNG_TRANSFORM_SHIFT) != 0) -#ifdef PNG_READ_SHIFT_SUPPORTED - if ((info_ptr->valid & PNG_INFO_sBIT) != 0) - png_set_shift(png_ptr, &info_ptr->sig_bit); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_SHIFT not supported"); -#endif - - /* Flip the RGB pixels to BGR (or RGBA to BGRA) */ - if ((transforms & PNG_TRANSFORM_BGR) != 0) -#ifdef PNG_READ_BGR_SUPPORTED - png_set_bgr(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_BGR not supported"); -#endif - - /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ - if ((transforms & PNG_TRANSFORM_SWAP_ALPHA) != 0) -#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED - png_set_swap_alpha(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ALPHA not supported"); -#endif - - /* Swap bytes of 16-bit files to least significant byte first */ - if ((transforms & PNG_TRANSFORM_SWAP_ENDIAN) != 0) -#ifdef PNG_READ_SWAP_SUPPORTED - png_set_swap(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ENDIAN not supported"); -#endif - -/* Added at libpng-1.2.41 */ - /* Invert the alpha channel from opacity to transparency */ - if ((transforms & PNG_TRANSFORM_INVERT_ALPHA) != 0) -#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED - png_set_invert_alpha(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_ALPHA not supported"); -#endif - -/* Added at libpng-1.2.41 */ - /* Expand grayscale image to RGB */ - if ((transforms & PNG_TRANSFORM_GRAY_TO_RGB) != 0) -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED - png_set_gray_to_rgb(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_GRAY_TO_RGB not supported"); -#endif - -/* Added at libpng-1.5.4 */ - if ((transforms & PNG_TRANSFORM_EXPAND_16) != 0) -#ifdef PNG_READ_EXPAND_16_SUPPORTED - png_set_expand_16(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_EXPAND_16 not supported"); -#endif - - /* We don't handle adding filler bytes */ - - /* We use png_read_image and rely on that for interlace handling, but we also - * call png_read_update_info therefore must turn on interlace handling now: - */ - (void)png_set_interlace_handling(png_ptr); - - /* Optional call to gamma correct and add the background to the palette - * and update info structure. REQUIRED if you are expecting libpng to - * update the palette for you (i.e., you selected such a transform above). - */ - png_read_update_info(png_ptr, info_ptr); - - /* -------------- image transformations end here ------------------- */ - - png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); - if (info_ptr->row_pointers == NULL) - { - png_uint_32 iptr; - - info_ptr->row_pointers = png_voidcast(png_bytepp, png_malloc(png_ptr, - info_ptr->height * (sizeof (png_bytep)))); - - for (iptr=0; iptrheight; iptr++) - info_ptr->row_pointers[iptr] = NULL; - - info_ptr->free_me |= PNG_FREE_ROWS; - - for (iptr = 0; iptr < info_ptr->height; iptr++) - info_ptr->row_pointers[iptr] = png_voidcast(png_bytep, - png_malloc(png_ptr, info_ptr->rowbytes)); - } - - png_read_image(png_ptr, info_ptr->row_pointers); - info_ptr->valid |= PNG_INFO_IDAT; - - /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */ - png_read_end(png_ptr, info_ptr); - - PNG_UNUSED(params) -} -#endif /* INFO_IMAGE */ -#endif /* SEQUENTIAL_READ */ - -#ifdef PNG_SIMPLIFIED_READ_SUPPORTED -/* SIMPLIFIED READ - * - * This code currently relies on the sequential reader, though it could easily - * be made to work with the progressive one. - */ -/* Arguments to png_image_finish_read: */ - -/* Encoding of PNG data (used by the color-map code) */ -# define P_NOTSET 0 /* File encoding not yet known */ -# define P_sRGB 1 /* 8-bit encoded to sRGB gamma */ -# define P_LINEAR 2 /* 16-bit linear: not encoded, NOT pre-multiplied! */ -# define P_FILE 3 /* 8-bit encoded to file gamma, not sRGB or linear */ -# define P_LINEAR8 4 /* 8-bit linear: only from a file value */ - -/* Color-map processing: after libpng has run on the PNG image further - * processing may be needed to convert the data to color-map indices. - */ -#define PNG_CMAP_NONE 0 -#define PNG_CMAP_GA 1 /* Process GA data to a color-map with alpha */ -#define PNG_CMAP_TRANS 2 /* Process GA data to a background index */ -#define PNG_CMAP_RGB 3 /* Process RGB data */ -#define PNG_CMAP_RGB_ALPHA 4 /* Process RGBA data */ - -/* The following document where the background is for each processing case. */ -#define PNG_CMAP_NONE_BACKGROUND 256 -#define PNG_CMAP_GA_BACKGROUND 231 -#define PNG_CMAP_TRANS_BACKGROUND 254 -#define PNG_CMAP_RGB_BACKGROUND 256 -#define PNG_CMAP_RGB_ALPHA_BACKGROUND 216 - -typedef struct -{ - /* Arguments: */ - png_imagep image; - png_voidp buffer; - png_int_32 row_stride; - png_voidp colormap; - png_const_colorp background; - /* Local variables: */ - png_voidp local_row; - png_voidp first_row; - ptrdiff_t row_bytes; /* step between rows */ - int file_encoding; /* E_ values above */ - png_fixed_point gamma_to_linear; /* For P_FILE, reciprocal of gamma */ - int colormap_processing; /* PNG_CMAP_ values above */ -} png_image_read_control; - -/* Do all the *safe* initialization - 'safe' means that png_error won't be - * called, so setting up the jmp_buf is not required. This means that anything - * called from here must *not* call png_malloc - it has to call png_malloc_warn - * instead so that control is returned safely back to this routine. - */ -static int -png_image_read_init(png_imagep image) -{ - if (image->opaque == NULL) - { - png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, image, - png_safe_error, png_safe_warning); - - /* And set the rest of the structure to NULL to ensure that the various - * fields are consistent. - */ - memset(image, 0, (sizeof *image)); - image->version = PNG_IMAGE_VERSION; - - if (png_ptr != NULL) - { - png_infop info_ptr = png_create_info_struct(png_ptr); - - if (info_ptr != NULL) - { - png_controlp control = png_voidcast(png_controlp, - png_malloc_warn(png_ptr, (sizeof *control))); - - if (control != NULL) - { - memset(control, 0, (sizeof *control)); - - control->png_ptr = png_ptr; - control->info_ptr = info_ptr; - control->for_write = 0; - - image->opaque = control; - return 1; - } - - /* Error clean up */ - png_destroy_info_struct(png_ptr, &info_ptr); - } - - png_destroy_read_struct(&png_ptr, NULL, NULL); - } - - return png_image_error(image, "png_image_read: out of memory"); - } - - return png_image_error(image, "png_image_read: opaque pointer not NULL"); -} - -/* Utility to find the base format of a PNG file from a png_struct. */ -static png_uint_32 -png_image_format(png_structrp png_ptr) -{ - png_uint_32 format = 0; - - if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) - format |= PNG_FORMAT_FLAG_COLOR; - - if ((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0) - format |= PNG_FORMAT_FLAG_ALPHA; - - /* Use png_ptr here, not info_ptr, because by examination png_handle_tRNS - * sets the png_struct fields; that's all we are interested in here. The - * precise interaction with an app call to png_set_tRNS and PNG file reading - * is unclear. - */ - else if (png_ptr->num_trans > 0) - format |= PNG_FORMAT_FLAG_ALPHA; - - if (png_ptr->bit_depth == 16) - format |= PNG_FORMAT_FLAG_LINEAR; - - if ((png_ptr->color_type & PNG_COLOR_MASK_PALETTE) != 0) - format |= PNG_FORMAT_FLAG_COLORMAP; - - return format; -} - -/* Is the given gamma significantly different from sRGB? The test is the same - * one used in pngrtran.c when deciding whether to do gamma correction. The - * arithmetic optimizes the division by using the fact that the inverse of the - * file sRGB gamma is 2.2 - */ -static int -png_gamma_not_sRGB(png_fixed_point g) -{ - if (g < PNG_FP_1) - { - /* An uninitialized gamma is assumed to be sRGB for the simplified API. */ - if (g == 0) - return 0; - - return png_gamma_significant((g * 11 + 2)/5 /* i.e. *2.2, rounded */); - } - - return 1; -} - -/* Do the main body of a 'png_image_begin_read' function; read the PNG file - * header and fill in all the information. This is executed in a safe context, - * unlike the init routine above. - */ -static int -png_image_read_header(png_voidp argument) -{ - png_imagep image = png_voidcast(png_imagep, argument); - png_structrp png_ptr = image->opaque->png_ptr; - png_inforp info_ptr = image->opaque->info_ptr; - -#ifdef PNG_BENIGN_ERRORS_SUPPORTED - png_set_benign_errors(png_ptr, 1/*warn*/); -#endif - png_read_info(png_ptr, info_ptr); - - /* Do this the fast way; just read directly out of png_struct. */ - image->width = png_ptr->width; - image->height = png_ptr->height; - - { - png_uint_32 format = png_image_format(png_ptr); - - image->format = format; - -#ifdef PNG_COLORSPACE_SUPPORTED - /* Does the colorspace match sRGB? If there is no color endpoint - * (colorant) information assume yes, otherwise require the - * 'ENDPOINTS_MATCHP_sRGB' colorspace flag to have been set. If the - * colorspace has been determined to be invalid ignore it. - */ - if ((format & PNG_FORMAT_FLAG_COLOR) != 0 && ((png_ptr->colorspace.flags - & (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB| - PNG_COLORSPACE_INVALID)) == PNG_COLORSPACE_HAVE_ENDPOINTS)) - image->flags |= PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB; -#endif - } - - /* We need the maximum number of entries regardless of the format the - * application sets here. - */ - { - png_uint_32 cmap_entries; - - switch (png_ptr->color_type) - { - case PNG_COLOR_TYPE_GRAY: - cmap_entries = 1U << png_ptr->bit_depth; - break; - - case PNG_COLOR_TYPE_PALETTE: - cmap_entries = (png_uint_32)png_ptr->num_palette; - break; - - default: - cmap_entries = 256; - break; - } - - if (cmap_entries > 256) - cmap_entries = 256; - - image->colormap_entries = cmap_entries; - } - - return 1; -} - -#ifdef PNG_STDIO_SUPPORTED -int PNGAPI -png_image_begin_read_from_stdio(png_imagep image, FILE* file) -{ - if (image != NULL && image->version == PNG_IMAGE_VERSION) - { - if (file != NULL) - { - if (png_image_read_init(image) != 0) - { - /* This is slightly evil, but png_init_io doesn't do anything other - * than this and we haven't changed the standard IO functions so - * this saves a 'safe' function. - */ - image->opaque->png_ptr->io_ptr = file; - return png_safe_execute(image, png_image_read_header, image); - } - } - - else - return png_image_error(image, - "png_image_begin_read_from_stdio: invalid argument"); - } - - else if (image != NULL) - return png_image_error(image, - "png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION"); - - return 0; -} - -int PNGAPI -png_image_begin_read_from_file(png_imagep image, const char *file_name) -{ - if (image != NULL && image->version == PNG_IMAGE_VERSION) - { - if (file_name != NULL) - { - FILE *fp = fopen(file_name, "rb"); - - if (fp != NULL) - { - if (png_image_read_init(image) != 0) - { - image->opaque->png_ptr->io_ptr = fp; - image->opaque->owned_file = 1; - return png_safe_execute(image, png_image_read_header, image); - } - - /* Clean up: just the opened file. */ - (void)fclose(fp); - } - - else - return png_image_error(image, strerror(errno)); - } - - else - return png_image_error(image, - "png_image_begin_read_from_file: invalid argument"); - } - - else if (image != NULL) - return png_image_error(image, - "png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION"); - - return 0; -} -#endif /* STDIO */ - -static void PNGCBAPI -png_image_memory_read(png_structp png_ptr, png_bytep out, size_t need) -{ - if (png_ptr != NULL) - { - png_imagep image = png_voidcast(png_imagep, png_ptr->io_ptr); - if (image != NULL) - { - png_controlp cp = image->opaque; - if (cp != NULL) - { - png_const_bytep memory = cp->memory; - size_t size = cp->size; - - if (memory != NULL && size >= need) - { - memcpy(out, memory, need); - cp->memory = memory + need; - cp->size = size - need; - return; - } - - png_error(png_ptr, "read beyond end of data"); - } - } - - png_error(png_ptr, "invalid memory read"); - } -} - -int PNGAPI png_image_begin_read_from_memory(png_imagep image, - png_const_voidp memory, size_t size) -{ - if (image != NULL && image->version == PNG_IMAGE_VERSION) - { - if (memory != NULL && size > 0) - { - if (png_image_read_init(image) != 0) - { - /* Now set the IO functions to read from the memory buffer and - * store it into io_ptr. Again do this in-place to avoid calling a - * libpng function that requires error handling. - */ - image->opaque->memory = png_voidcast(png_const_bytep, memory); - image->opaque->size = size; - image->opaque->png_ptr->io_ptr = image; - image->opaque->png_ptr->read_data_fn = png_image_memory_read; - - return png_safe_execute(image, png_image_read_header, image); - } - } - - else - return png_image_error(image, - "png_image_begin_read_from_memory: invalid argument"); - } - - else if (image != NULL) - return png_image_error(image, - "png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION"); - - return 0; -} - -/* Utility function to skip chunks that are not used by the simplified image - * read functions and an appropriate macro to call it. - */ -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -static void -png_image_skip_unused_chunks(png_structrp png_ptr) -{ - /* Prepare the reader to ignore all recognized chunks whose data will not - * be used, i.e., all chunks recognized by libpng except for those - * involved in basic image reading: - * - * IHDR, PLTE, IDAT, IEND - * - * Or image data handling: - * - * tRNS, bKGD, gAMA, cHRM, sRGB, [iCCP] and sBIT. - * - * This provides a small performance improvement and eliminates any - * potential vulnerability to security problems in the unused chunks. - * - * At present the iCCP chunk data isn't used, so iCCP chunk can be ignored - * too. This allows the simplified API to be compiled without iCCP support, - * however if the support is there the chunk is still checked to detect - * errors (which are unfortunately quite common.) - */ - { - static const png_byte chunks_to_process[] = { - 98, 75, 71, 68, '\0', /* bKGD */ - 99, 72, 82, 77, '\0', /* cHRM */ - 103, 65, 77, 65, '\0', /* gAMA */ -# ifdef PNG_READ_iCCP_SUPPORTED - 105, 67, 67, 80, '\0', /* iCCP */ -# endif - 115, 66, 73, 84, '\0', /* sBIT */ - 115, 82, 71, 66, '\0', /* sRGB */ - }; - - /* Ignore unknown chunks and all other chunks except for the - * IHDR, PLTE, tRNS, IDAT, and IEND chunks. - */ - png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_NEVER, - NULL, -1); - - /* But do not ignore image data handling chunks */ - png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_AS_DEFAULT, - chunks_to_process, (int)/*SAFE*/(sizeof chunks_to_process)/5); - } -} - -# define PNG_SKIP_CHUNKS(p) png_image_skip_unused_chunks(p) -#else -# define PNG_SKIP_CHUNKS(p) ((void)0) -#endif /* HANDLE_AS_UNKNOWN */ - -/* The following macro gives the exact rounded answer for all values in the - * range 0..255 (it actually divides by 51.2, but the rounding still generates - * the correct numbers 0..5 - */ -#define PNG_DIV51(v8) (((v8) * 5 + 130) >> 8) - -/* Utility functions to make particular color-maps */ -static void -set_file_encoding(png_image_read_control *display) -{ - png_fixed_point g = display->image->opaque->png_ptr->colorspace.gamma; - if (png_gamma_significant(g) != 0) - { - if (png_gamma_not_sRGB(g) != 0) - { - display->file_encoding = P_FILE; - display->gamma_to_linear = png_reciprocal(g); - } - - else - display->file_encoding = P_sRGB; - } - - else - display->file_encoding = P_LINEAR8; -} - -static unsigned int -decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding) -{ - if (encoding == P_FILE) /* double check */ - encoding = display->file_encoding; - - if (encoding == P_NOTSET) /* must be the file encoding */ - { - set_file_encoding(display); - encoding = display->file_encoding; - } - - switch (encoding) - { - case P_FILE: - value = png_gamma_16bit_correct(value*257, display->gamma_to_linear); - break; - - case P_sRGB: - value = png_sRGB_table[value]; - break; - - case P_LINEAR: - break; - - case P_LINEAR8: - value *= 257; - break; - -#ifdef __GNUC__ - default: - png_error(display->image->opaque->png_ptr, - "unexpected encoding (internal error)"); -#endif - } - - return value; -} - -static png_uint_32 -png_colormap_compose(png_image_read_control *display, - png_uint_32 foreground, int foreground_encoding, png_uint_32 alpha, - png_uint_32 background, int encoding) -{ - /* The file value is composed on the background, the background has the given - * encoding and so does the result, the file is encoded with P_FILE and the - * file and alpha are 8-bit values. The (output) encoding will always be - * P_LINEAR or P_sRGB. - */ - png_uint_32 f = decode_gamma(display, foreground, foreground_encoding); - png_uint_32 b = decode_gamma(display, background, encoding); - - /* The alpha is always an 8-bit value (it comes from the palette), the value - * scaled by 255 is what PNG_sRGB_FROM_LINEAR requires. - */ - f = f * alpha + b * (255-alpha); - - if (encoding == P_LINEAR) - { - /* Scale to 65535; divide by 255, approximately (in fact this is extremely - * accurate, it divides by 255.00000005937181414556, with no overflow.) - */ - f *= 257; /* Now scaled by 65535 */ - f += f >> 16; - f = (f+32768) >> 16; - } - - else /* P_sRGB */ - f = PNG_sRGB_FROM_LINEAR(f); - - return f; -} - -/* NOTE: P_LINEAR values to this routine must be 16-bit, but P_FILE values must - * be 8-bit. - */ -static void -png_create_colormap_entry(png_image_read_control *display, - png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue, - png_uint_32 alpha, int encoding) -{ - png_imagep image = display->image; - int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ? - P_LINEAR : P_sRGB; - int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 && - (red != green || green != blue); - - if (ip > 255) - png_error(image->opaque->png_ptr, "color-map index out of range"); - - /* Update the cache with whether the file gamma is significantly different - * from sRGB. - */ - if (encoding == P_FILE) - { - if (display->file_encoding == P_NOTSET) - set_file_encoding(display); - - /* Note that the cached value may be P_FILE too, but if it is then the - * gamma_to_linear member has been set. - */ - encoding = display->file_encoding; - } - - if (encoding == P_FILE) - { - png_fixed_point g = display->gamma_to_linear; - - red = png_gamma_16bit_correct(red*257, g); - green = png_gamma_16bit_correct(green*257, g); - blue = png_gamma_16bit_correct(blue*257, g); - - if (convert_to_Y != 0 || output_encoding == P_LINEAR) - { - alpha *= 257; - encoding = P_LINEAR; - } - - else - { - red = PNG_sRGB_FROM_LINEAR(red * 255); - green = PNG_sRGB_FROM_LINEAR(green * 255); - blue = PNG_sRGB_FROM_LINEAR(blue * 255); - encoding = P_sRGB; - } - } - - else if (encoding == P_LINEAR8) - { - /* This encoding occurs quite frequently in test cases because PngSuite - * includes a gAMA 1.0 chunk with most images. - */ - red *= 257; - green *= 257; - blue *= 257; - alpha *= 257; - encoding = P_LINEAR; - } - - else if (encoding == P_sRGB && - (convert_to_Y != 0 || output_encoding == P_LINEAR)) - { - /* The values are 8-bit sRGB values, but must be converted to 16-bit - * linear. - */ - red = png_sRGB_table[red]; - green = png_sRGB_table[green]; - blue = png_sRGB_table[blue]; - alpha *= 257; - encoding = P_LINEAR; - } - - /* This is set if the color isn't gray but the output is. */ - if (encoding == P_LINEAR) - { - if (convert_to_Y != 0) - { - /* NOTE: these values are copied from png_do_rgb_to_gray */ - png_uint_32 y = (png_uint_32)6968 * red + (png_uint_32)23434 * green + - (png_uint_32)2366 * blue; - - if (output_encoding == P_LINEAR) - y = (y + 16384) >> 15; - - else - { - /* y is scaled by 32768, we need it scaled by 255: */ - y = (y + 128) >> 8; - y *= 255; - y = PNG_sRGB_FROM_LINEAR((y + 64) >> 7); - alpha = PNG_DIV257(alpha); - encoding = P_sRGB; - } - - blue = red = green = y; - } - - else if (output_encoding == P_sRGB) - { - red = PNG_sRGB_FROM_LINEAR(red * 255); - green = PNG_sRGB_FROM_LINEAR(green * 255); - blue = PNG_sRGB_FROM_LINEAR(blue * 255); - alpha = PNG_DIV257(alpha); - encoding = P_sRGB; - } - } - - if (encoding != output_encoding) - png_error(image->opaque->png_ptr, "bad encoding (internal error)"); - - /* Store the value. */ - { -# ifdef PNG_FORMAT_AFIRST_SUPPORTED - int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 && - (image->format & PNG_FORMAT_FLAG_ALPHA) != 0; -# else -# define afirst 0 -# endif -# ifdef PNG_FORMAT_BGR_SUPPORTED - int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0; -# else -# define bgr 0 -# endif - - if (output_encoding == P_LINEAR) - { - png_uint_16p entry = png_voidcast(png_uint_16p, display->colormap); - - entry += ip * PNG_IMAGE_SAMPLE_CHANNELS(image->format); - - /* The linear 16-bit values must be pre-multiplied by the alpha channel - * value, if less than 65535 (this is, effectively, composite on black - * if the alpha channel is removed.) - */ - switch (PNG_IMAGE_SAMPLE_CHANNELS(image->format)) - { - case 4: - entry[afirst ? 0 : 3] = (png_uint_16)alpha; - /* FALLTHROUGH */ - - case 3: - if (alpha < 65535) - { - if (alpha > 0) - { - blue = (blue * alpha + 32767U)/65535U; - green = (green * alpha + 32767U)/65535U; - red = (red * alpha + 32767U)/65535U; - } - - else - red = green = blue = 0; - } - entry[afirst + (2 ^ bgr)] = (png_uint_16)blue; - entry[afirst + 1] = (png_uint_16)green; - entry[afirst + bgr] = (png_uint_16)red; - break; - - case 2: - entry[1 ^ afirst] = (png_uint_16)alpha; - /* FALLTHROUGH */ - - case 1: - if (alpha < 65535) - { - if (alpha > 0) - green = (green * alpha + 32767U)/65535U; - - else - green = 0; - } - entry[afirst] = (png_uint_16)green; - break; - - default: - break; - } - } - - else /* output encoding is P_sRGB */ - { - png_bytep entry = png_voidcast(png_bytep, display->colormap); - - entry += ip * PNG_IMAGE_SAMPLE_CHANNELS(image->format); - - switch (PNG_IMAGE_SAMPLE_CHANNELS(image->format)) - { - case 4: - entry[afirst ? 0 : 3] = (png_byte)alpha; - /* FALLTHROUGH */ - case 3: - entry[afirst + (2 ^ bgr)] = (png_byte)blue; - entry[afirst + 1] = (png_byte)green; - entry[afirst + bgr] = (png_byte)red; - break; - - case 2: - entry[1 ^ afirst] = (png_byte)alpha; - /* FALLTHROUGH */ - case 1: - entry[afirst] = (png_byte)green; - break; - - default: - break; - } - } - -# ifdef afirst -# undef afirst -# endif -# ifdef bgr -# undef bgr -# endif - } -} - -static int -make_gray_file_colormap(png_image_read_control *display) -{ - unsigned int i; - - for (i=0; i<256; ++i) - png_create_colormap_entry(display, i, i, i, i, 255, P_FILE); - - return (int)i; -} - -static int -make_gray_colormap(png_image_read_control *display) -{ - unsigned int i; - - for (i=0; i<256; ++i) - png_create_colormap_entry(display, i, i, i, i, 255, P_sRGB); - - return (int)i; -} -#define PNG_GRAY_COLORMAP_ENTRIES 256 - -static int -make_ga_colormap(png_image_read_control *display) -{ - unsigned int i, a; - - /* Alpha is retained, the output will be a color-map with entries - * selected by six levels of alpha. One transparent entry, 6 gray - * levels for all the intermediate alpha values, leaving 230 entries - * for the opaque grays. The color-map entries are the six values - * [0..5]*51, the GA processing uses PNG_DIV51(value) to find the - * relevant entry. - * - * if (alpha > 229) // opaque - * { - * // The 231 entries are selected to make the math below work: - * base = 0; - * entry = (231 * gray + 128) >> 8; - * } - * else if (alpha < 26) // transparent - * { - * base = 231; - * entry = 0; - * } - * else // partially opaque - * { - * base = 226 + 6 * PNG_DIV51(alpha); - * entry = PNG_DIV51(gray); - * } - */ - i = 0; - while (i < 231) - { - unsigned int gray = (i * 256 + 115) / 231; - png_create_colormap_entry(display, i++, gray, gray, gray, 255, P_sRGB); - } - - /* 255 is used here for the component values for consistency with the code - * that undoes premultiplication in pngwrite.c. - */ - png_create_colormap_entry(display, i++, 255, 255, 255, 0, P_sRGB); - - for (a=1; a<5; ++a) - { - unsigned int g; - - for (g=0; g<6; ++g) - png_create_colormap_entry(display, i++, g*51, g*51, g*51, a*51, - P_sRGB); - } - - return (int)i; -} - -#define PNG_GA_COLORMAP_ENTRIES 256 - -static int -make_rgb_colormap(png_image_read_control *display) -{ - unsigned int i, r; - - /* Build a 6x6x6 opaque RGB cube */ - for (i=r=0; r<6; ++r) - { - unsigned int g; - - for (g=0; g<6; ++g) - { - unsigned int b; - - for (b=0; b<6; ++b) - png_create_colormap_entry(display, i++, r*51, g*51, b*51, 255, - P_sRGB); - } - } - - return (int)i; -} - -#define PNG_RGB_COLORMAP_ENTRIES 216 - -/* Return a palette index to the above palette given three 8-bit sRGB values. */ -#define PNG_RGB_INDEX(r,g,b) \ - ((png_byte)(6 * (6 * PNG_DIV51(r) + PNG_DIV51(g)) + PNG_DIV51(b))) - -static int -png_image_read_colormap(png_voidp argument) -{ - png_image_read_control *display = - png_voidcast(png_image_read_control*, argument); - png_imagep image = display->image; - - png_structrp png_ptr = image->opaque->png_ptr; - png_uint_32 output_format = image->format; - int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ? - P_LINEAR : P_sRGB; - - unsigned int cmap_entries; - unsigned int output_processing; /* Output processing option */ - unsigned int data_encoding = P_NOTSET; /* Encoding libpng must produce */ - - /* Background information; the background color and the index of this color - * in the color-map if it exists (else 256). - */ - unsigned int background_index = 256; - png_uint_32 back_r, back_g, back_b; - - /* Flags to accumulate things that need to be done to the input. */ - int expand_tRNS = 0; - - /* Exclude the NYI feature of compositing onto a color-mapped buffer; it is - * very difficult to do, the results look awful, and it is difficult to see - * what possible use it is because the application can't control the - * color-map. - */ - if (((png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0 || - png_ptr->num_trans > 0) /* alpha in input */ && - ((output_format & PNG_FORMAT_FLAG_ALPHA) == 0) /* no alpha in output */) - { - if (output_encoding == P_LINEAR) /* compose on black */ - back_b = back_g = back_r = 0; - - else if (display->background == NULL /* no way to remove it */) - png_error(png_ptr, - "background color must be supplied to remove alpha/transparency"); - - /* Get a copy of the background color (this avoids repeating the checks - * below.) The encoding is 8-bit sRGB or 16-bit linear, depending on the - * output format. - */ - else - { - back_g = display->background->green; - if ((output_format & PNG_FORMAT_FLAG_COLOR) != 0) - { - back_r = display->background->red; - back_b = display->background->blue; - } - else - back_b = back_r = back_g; - } - } - - else if (output_encoding == P_LINEAR) - back_b = back_r = back_g = 65535; - - else - back_b = back_r = back_g = 255; - - /* Default the input file gamma if required - this is necessary because - * libpng assumes that if no gamma information is present the data is in the - * output format, but the simplified API deduces the gamma from the input - * format. - */ - if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) == 0) - { - /* Do this directly, not using the png_colorspace functions, to ensure - * that it happens even if the colorspace is invalid (though probably if - * it is the setting will be ignored) Note that the same thing can be - * achieved at the application interface with png_set_gAMA. - */ - if (png_ptr->bit_depth == 16 && - (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0) - png_ptr->colorspace.gamma = PNG_GAMMA_LINEAR; - - else - png_ptr->colorspace.gamma = PNG_GAMMA_sRGB_INVERSE; - - png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; - } - - /* Decide what to do based on the PNG color type of the input data. The - * utility function png_create_colormap_entry deals with most aspects of the - * output transformations; this code works out how to produce bytes of - * color-map entries from the original format. - */ - switch (png_ptr->color_type) - { - case PNG_COLOR_TYPE_GRAY: - if (png_ptr->bit_depth <= 8) - { - /* There at most 256 colors in the output, regardless of - * transparency. - */ - unsigned int step, i, val, trans = 256/*ignore*/, back_alpha = 0; - - cmap_entries = 1U << png_ptr->bit_depth; - if (cmap_entries > image->colormap_entries) - png_error(png_ptr, "gray[8] color-map: too few entries"); - - step = 255 / (cmap_entries - 1); - output_processing = PNG_CMAP_NONE; - - /* If there is a tRNS chunk then this either selects a transparent - * value or, if the output has no alpha, the background color. - */ - if (png_ptr->num_trans > 0) - { - trans = png_ptr->trans_color.gray; - - if ((output_format & PNG_FORMAT_FLAG_ALPHA) == 0) - back_alpha = output_encoding == P_LINEAR ? 65535 : 255; - } - - /* png_create_colormap_entry just takes an RGBA and writes the - * corresponding color-map entry using the format from 'image', - * including the required conversion to sRGB or linear as - * appropriate. The input values are always either sRGB (if the - * gamma correction flag is 0) or 0..255 scaled file encoded values - * (if the function must gamma correct them). - */ - for (i=val=0; ibit_depth < 8) - png_set_packing(png_ptr); - } - - else /* bit depth is 16 */ - { - /* The 16-bit input values can be converted directly to 8-bit gamma - * encoded values; however, if a tRNS chunk is present 257 color-map - * entries are required. This means that the extra entry requires - * special processing; add an alpha channel, sacrifice gray level - * 254 and convert transparent (alpha==0) entries to that. - * - * Use libpng to chop the data to 8 bits. Convert it to sRGB at the - * same time to minimize quality loss. If a tRNS chunk is present - * this means libpng must handle it too; otherwise it is impossible - * to do the exact match on the 16-bit value. - * - * If the output has no alpha channel *and* the background color is - * gray then it is possible to let libpng handle the substitution by - * ensuring that the corresponding gray level matches the background - * color exactly. - */ - data_encoding = P_sRGB; - - if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) - png_error(png_ptr, "gray[16] color-map: too few entries"); - - cmap_entries = (unsigned int)make_gray_colormap(display); - - if (png_ptr->num_trans > 0) - { - unsigned int back_alpha; - - if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0) - back_alpha = 0; - - else - { - if (back_r == back_g && back_g == back_b) - { - /* Background is gray; no special processing will be - * required. - */ - png_color_16 c; - png_uint_32 gray = back_g; - - if (output_encoding == P_LINEAR) - { - gray = PNG_sRGB_FROM_LINEAR(gray * 255); - - /* And make sure the corresponding palette entry - * matches. - */ - png_create_colormap_entry(display, gray, back_g, back_g, - back_g, 65535, P_LINEAR); - } - - /* The background passed to libpng, however, must be the - * sRGB value. - */ - c.index = 0; /*unused*/ - c.gray = c.red = c.green = c.blue = (png_uint_16)gray; - - /* NOTE: does this work without expanding tRNS to alpha? - * It should be the color->gray case below apparently - * doesn't. - */ - png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); - - output_processing = PNG_CMAP_NONE; - break; - } -#ifdef __COVERITY__ - /* Coverity claims that output_encoding cannot be 2 (P_LINEAR) - * here. - */ - back_alpha = 255; -#else - back_alpha = output_encoding == P_LINEAR ? 65535 : 255; -#endif - } - - /* output_processing means that the libpng-processed row will be - * 8-bit GA and it has to be processing to single byte color-map - * values. Entry 254 is replaced by either a completely - * transparent entry or by the background color at full - * precision (and the background color is not a simple gray - * level in this case.) - */ - expand_tRNS = 1; - output_processing = PNG_CMAP_TRANS; - background_index = 254; - - /* And set (overwrite) color-map entry 254 to the actual - * background color at full precision. - */ - png_create_colormap_entry(display, 254, back_r, back_g, back_b, - back_alpha, output_encoding); - } - - else - output_processing = PNG_CMAP_NONE; - } - break; - - case PNG_COLOR_TYPE_GRAY_ALPHA: - /* 8-bit or 16-bit PNG with two channels - gray and alpha. A minimum - * of 65536 combinations. If, however, the alpha channel is to be - * removed there are only 256 possibilities if the background is gray. - * (Otherwise there is a subset of the 65536 possibilities defined by - * the triangle between black, white and the background color.) - * - * Reduce 16-bit files to 8-bit and sRGB encode the result. No need to - * worry about tRNS matching - tRNS is ignored if there is an alpha - * channel. - */ - data_encoding = P_sRGB; - - if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0) - { - if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) - png_error(png_ptr, "gray+alpha color-map: too few entries"); - - cmap_entries = (unsigned int)make_ga_colormap(display); - - background_index = PNG_CMAP_GA_BACKGROUND; - output_processing = PNG_CMAP_GA; - } - - else /* alpha is removed */ - { - /* Alpha must be removed as the PNG data is processed when the - * background is a color because the G and A channels are - * independent and the vector addition (non-parallel vectors) is a - * 2-D problem. - * - * This can be reduced to the same algorithm as above by making a - * colormap containing gray levels (for the opaque grays), a - * background entry (for a transparent pixel) and a set of four six - * level color values, one set for each intermediate alpha value. - * See the comments in make_ga_colormap for how this works in the - * per-pixel processing. - * - * If the background is gray, however, we only need a 256 entry gray - * level color map. It is sufficient to make the entry generated - * for the background color be exactly the color specified. - */ - if ((output_format & PNG_FORMAT_FLAG_COLOR) == 0 || - (back_r == back_g && back_g == back_b)) - { - /* Background is gray; no special processing will be required. */ - png_color_16 c; - png_uint_32 gray = back_g; - - if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) - png_error(png_ptr, "gray-alpha color-map: too few entries"); - - cmap_entries = (unsigned int)make_gray_colormap(display); - - if (output_encoding == P_LINEAR) - { - gray = PNG_sRGB_FROM_LINEAR(gray * 255); - - /* And make sure the corresponding palette entry matches. */ - png_create_colormap_entry(display, gray, back_g, back_g, - back_g, 65535, P_LINEAR); - } - - /* The background passed to libpng, however, must be the sRGB - * value. - */ - c.index = 0; /*unused*/ - c.gray = c.red = c.green = c.blue = (png_uint_16)gray; - - png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); - - output_processing = PNG_CMAP_NONE; - } - - else - { - png_uint_32 i, a; - - /* This is the same as png_make_ga_colormap, above, except that - * the entries are all opaque. - */ - if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) - png_error(png_ptr, "ga-alpha color-map: too few entries"); - - i = 0; - while (i < 231) - { - png_uint_32 gray = (i * 256 + 115) / 231; - png_create_colormap_entry(display, i++, gray, gray, gray, - 255, P_sRGB); - } - - /* NOTE: this preserves the full precision of the application - * background color. - */ - background_index = i; - png_create_colormap_entry(display, i++, back_r, back_g, back_b, -#ifdef __COVERITY__ - /* Coverity claims that output_encoding - * cannot be 2 (P_LINEAR) here. - */ 255U, -#else - output_encoding == P_LINEAR ? 65535U : 255U, -#endif - output_encoding); - - /* For non-opaque input composite on the sRGB background - this - * requires inverting the encoding for each component. The input - * is still converted to the sRGB encoding because this is a - * reasonable approximate to the logarithmic curve of human - * visual sensitivity, at least over the narrow range which PNG - * represents. Consequently 'G' is always sRGB encoded, while - * 'A' is linear. We need the linear background colors. - */ - if (output_encoding == P_sRGB) /* else already linear */ - { - /* This may produce a value not exactly matching the - * background, but that's ok because these numbers are only - * used when alpha != 0 - */ - back_r = png_sRGB_table[back_r]; - back_g = png_sRGB_table[back_g]; - back_b = png_sRGB_table[back_b]; - } - - for (a=1; a<5; ++a) - { - unsigned int g; - - /* PNG_sRGB_FROM_LINEAR expects a 16-bit linear value scaled - * by an 8-bit alpha value (0..255). - */ - png_uint_32 alpha = 51 * a; - png_uint_32 back_rx = (255-alpha) * back_r; - png_uint_32 back_gx = (255-alpha) * back_g; - png_uint_32 back_bx = (255-alpha) * back_b; - - for (g=0; g<6; ++g) - { - png_uint_32 gray = png_sRGB_table[g*51] * alpha; - - png_create_colormap_entry(display, i++, - PNG_sRGB_FROM_LINEAR(gray + back_rx), - PNG_sRGB_FROM_LINEAR(gray + back_gx), - PNG_sRGB_FROM_LINEAR(gray + back_bx), 255, P_sRGB); - } - } - - cmap_entries = i; - output_processing = PNG_CMAP_GA; - } - } - break; - - case PNG_COLOR_TYPE_RGB: - case PNG_COLOR_TYPE_RGB_ALPHA: - /* Exclude the case where the output is gray; we can always handle this - * with the cases above. - */ - if ((output_format & PNG_FORMAT_FLAG_COLOR) == 0) - { - /* The color-map will be grayscale, so we may as well convert the - * input RGB values to a simple grayscale and use the grayscale - * code above. - * - * NOTE: calling this apparently damages the recognition of the - * transparent color in background color handling; call - * png_set_tRNS_to_alpha before png_set_background_fixed. - */ - png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, -1, - -1); - data_encoding = P_sRGB; - - /* The output will now be one or two 8-bit gray or gray+alpha - * channels. The more complex case arises when the input has alpha. - */ - if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || - png_ptr->num_trans > 0) && - (output_format & PNG_FORMAT_FLAG_ALPHA) != 0) - { - /* Both input and output have an alpha channel, so no background - * processing is required; just map the GA bytes to the right - * color-map entry. - */ - expand_tRNS = 1; - - if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) - png_error(png_ptr, "rgb[ga] color-map: too few entries"); - - cmap_entries = (unsigned int)make_ga_colormap(display); - background_index = PNG_CMAP_GA_BACKGROUND; - output_processing = PNG_CMAP_GA; - } - - else - { - /* Either the input or the output has no alpha channel, so there - * will be no non-opaque pixels in the color-map; it will just be - * grayscale. - */ - if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) - png_error(png_ptr, "rgb[gray] color-map: too few entries"); - - /* Ideally this code would use libpng to do the gamma correction, - * but if an input alpha channel is to be removed we will hit the - * libpng bug in gamma+compose+rgb-to-gray (the double gamma - * correction bug). Fix this by dropping the gamma correction in - * this case and doing it in the palette; this will result in - * duplicate palette entries, but that's better than the - * alternative of double gamma correction. - */ - if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || - png_ptr->num_trans > 0) && - png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0) - { - cmap_entries = (unsigned int)make_gray_file_colormap(display); - data_encoding = P_FILE; - } - - else - cmap_entries = (unsigned int)make_gray_colormap(display); - - /* But if the input has alpha or transparency it must be removed - */ - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || - png_ptr->num_trans > 0) - { - png_color_16 c; - png_uint_32 gray = back_g; - - /* We need to ensure that the application background exists in - * the colormap and that completely transparent pixels map to - * it. Achieve this simply by ensuring that the entry - * selected for the background really is the background color. - */ - if (data_encoding == P_FILE) /* from the fixup above */ - { - /* The app supplied a gray which is in output_encoding, we - * need to convert it to a value of the input (P_FILE) - * encoding then set this palette entry to the required - * output encoding. - */ - if (output_encoding == P_sRGB) - gray = png_sRGB_table[gray]; /* now P_LINEAR */ - - gray = PNG_DIV257(png_gamma_16bit_correct(gray, - png_ptr->colorspace.gamma)); /* now P_FILE */ - - /* And make sure the corresponding palette entry contains - * exactly the required sRGB value. - */ - png_create_colormap_entry(display, gray, back_g, back_g, - back_g, 0/*unused*/, output_encoding); - } - - else if (output_encoding == P_LINEAR) - { - gray = PNG_sRGB_FROM_LINEAR(gray * 255); - - /* And make sure the corresponding palette entry matches. - */ - png_create_colormap_entry(display, gray, back_g, back_g, - back_g, 0/*unused*/, P_LINEAR); - } - - /* The background passed to libpng, however, must be the - * output (normally sRGB) value. - */ - c.index = 0; /*unused*/ - c.gray = c.red = c.green = c.blue = (png_uint_16)gray; - - /* NOTE: the following is apparently a bug in libpng. Without - * it the transparent color recognition in - * png_set_background_fixed seems to go wrong. - */ - expand_tRNS = 1; - png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); - } - - output_processing = PNG_CMAP_NONE; - } - } - - else /* output is color */ - { - /* We could use png_quantize here so long as there is no transparent - * color or alpha; png_quantize ignores alpha. Easier overall just - * to do it once and using PNG_DIV51 on the 6x6x6 reduced RGB cube. - * Consequently we always want libpng to produce sRGB data. - */ - data_encoding = P_sRGB; - - /* Is there any transparency or alpha? */ - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || - png_ptr->num_trans > 0) - { - /* Is there alpha in the output too? If so all four channels are - * processed into a special RGB cube with alpha support. - */ - if ((output_format & PNG_FORMAT_FLAG_ALPHA) != 0) - { - png_uint_32 r; - - if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries) - png_error(png_ptr, "rgb+alpha color-map: too few entries"); - - cmap_entries = (unsigned int)make_rgb_colormap(display); - - /* Add a transparent entry. */ - png_create_colormap_entry(display, cmap_entries, 255, 255, - 255, 0, P_sRGB); - - /* This is stored as the background index for the processing - * algorithm. - */ - background_index = cmap_entries++; - - /* Add 27 r,g,b entries each with alpha 0.5. */ - for (r=0; r<256; r = (r << 1) | 0x7f) - { - png_uint_32 g; - - for (g=0; g<256; g = (g << 1) | 0x7f) - { - png_uint_32 b; - - /* This generates components with the values 0, 127 and - * 255 - */ - for (b=0; b<256; b = (b << 1) | 0x7f) - png_create_colormap_entry(display, cmap_entries++, - r, g, b, 128, P_sRGB); - } - } - - expand_tRNS = 1; - output_processing = PNG_CMAP_RGB_ALPHA; - } - - else - { - /* Alpha/transparency must be removed. The background must - * exist in the color map (achieved by setting adding it after - * the 666 color-map). If the standard processing code will - * pick up this entry automatically that's all that is - * required; libpng can be called to do the background - * processing. - */ - unsigned int sample_size = - PNG_IMAGE_SAMPLE_SIZE(output_format); - png_uint_32 r, g, b; /* sRGB background */ - - if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries) - png_error(png_ptr, "rgb-alpha color-map: too few entries"); - - cmap_entries = (unsigned int)make_rgb_colormap(display); - - png_create_colormap_entry(display, cmap_entries, back_r, - back_g, back_b, 0/*unused*/, output_encoding); - - if (output_encoding == P_LINEAR) - { - r = PNG_sRGB_FROM_LINEAR(back_r * 255); - g = PNG_sRGB_FROM_LINEAR(back_g * 255); - b = PNG_sRGB_FROM_LINEAR(back_b * 255); - } - - else - { - r = back_r; - g = back_g; - b = back_g; - } - - /* Compare the newly-created color-map entry with the one the - * PNG_CMAP_RGB algorithm will use. If the two entries don't - * match, add the new one and set this as the background - * index. - */ - if (memcmp((png_const_bytep)display->colormap + - sample_size * cmap_entries, - (png_const_bytep)display->colormap + - sample_size * PNG_RGB_INDEX(r,g,b), - sample_size) != 0) - { - /* The background color must be added. */ - background_index = cmap_entries++; - - /* Add 27 r,g,b entries each with created by composing with - * the background at alpha 0.5. - */ - for (r=0; r<256; r = (r << 1) | 0x7f) - { - for (g=0; g<256; g = (g << 1) | 0x7f) - { - /* This generates components with the values 0, 127 - * and 255 - */ - for (b=0; b<256; b = (b << 1) | 0x7f) - png_create_colormap_entry(display, cmap_entries++, - png_colormap_compose(display, r, P_sRGB, 128, - back_r, output_encoding), - png_colormap_compose(display, g, P_sRGB, 128, - back_g, output_encoding), - png_colormap_compose(display, b, P_sRGB, 128, - back_b, output_encoding), - 0/*unused*/, output_encoding); - } - } - - expand_tRNS = 1; - output_processing = PNG_CMAP_RGB_ALPHA; - } - - else /* background color is in the standard color-map */ - { - png_color_16 c; - - c.index = 0; /*unused*/ - c.red = (png_uint_16)back_r; - c.gray = c.green = (png_uint_16)back_g; - c.blue = (png_uint_16)back_b; - - png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); - - output_processing = PNG_CMAP_RGB; - } - } - } - - else /* no alpha or transparency in the input */ - { - /* Alpha in the output is irrelevant, simply map the opaque input - * pixels to the 6x6x6 color-map. - */ - if (PNG_RGB_COLORMAP_ENTRIES > image->colormap_entries) - png_error(png_ptr, "rgb color-map: too few entries"); - - cmap_entries = (unsigned int)make_rgb_colormap(display); - output_processing = PNG_CMAP_RGB; - } - } - break; - - case PNG_COLOR_TYPE_PALETTE: - /* It's already got a color-map. It may be necessary to eliminate the - * tRNS entries though. - */ - { - unsigned int num_trans = png_ptr->num_trans; - png_const_bytep trans = num_trans > 0 ? png_ptr->trans_alpha : NULL; - png_const_colorp colormap = png_ptr->palette; - int do_background = trans != NULL && - (output_format & PNG_FORMAT_FLAG_ALPHA) == 0; - unsigned int i; - - /* Just in case: */ - if (trans == NULL) - num_trans = 0; - - output_processing = PNG_CMAP_NONE; - data_encoding = P_FILE; /* Don't change from color-map indices */ - cmap_entries = (unsigned int)png_ptr->num_palette; - if (cmap_entries > 256) - cmap_entries = 256; - - if (cmap_entries > (unsigned int)image->colormap_entries) - png_error(png_ptr, "palette color-map: too few entries"); - - for (i=0; i < cmap_entries; ++i) - { - if (do_background != 0 && i < num_trans && trans[i] < 255) - { - if (trans[i] == 0) - png_create_colormap_entry(display, i, back_r, back_g, - back_b, 0, output_encoding); - - else - { - /* Must compose the PNG file color in the color-map entry - * on the sRGB color in 'back'. - */ - png_create_colormap_entry(display, i, - png_colormap_compose(display, colormap[i].red, - P_FILE, trans[i], back_r, output_encoding), - png_colormap_compose(display, colormap[i].green, - P_FILE, trans[i], back_g, output_encoding), - png_colormap_compose(display, colormap[i].blue, - P_FILE, trans[i], back_b, output_encoding), - output_encoding == P_LINEAR ? trans[i] * 257U : - trans[i], - output_encoding); - } - } - - else - png_create_colormap_entry(display, i, colormap[i].red, - colormap[i].green, colormap[i].blue, - i < num_trans ? trans[i] : 255U, P_FILE/*8-bit*/); - } - - /* The PNG data may have indices packed in fewer than 8 bits, it - * must be expanded if so. - */ - if (png_ptr->bit_depth < 8) - png_set_packing(png_ptr); - } - break; - - default: - png_error(png_ptr, "invalid PNG color type"); - /*NOT REACHED*/ - } - - /* Now deal with the output processing */ - if (expand_tRNS != 0 && png_ptr->num_trans > 0 && - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) == 0) - png_set_tRNS_to_alpha(png_ptr); - - switch (data_encoding) - { - case P_sRGB: - /* Change to 8-bit sRGB */ - png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, PNG_GAMMA_sRGB); - /* FALLTHROUGH */ - - case P_FILE: - if (png_ptr->bit_depth > 8) - png_set_scale_16(png_ptr); - break; - -#ifdef __GNUC__ - default: - png_error(png_ptr, "bad data option (internal error)"); -#endif - } - - if (cmap_entries > 256 || cmap_entries > image->colormap_entries) - png_error(png_ptr, "color map overflow (BAD internal error)"); - - image->colormap_entries = cmap_entries; - - /* Double check using the recorded background index */ - switch (output_processing) - { - case PNG_CMAP_NONE: - if (background_index != PNG_CMAP_NONE_BACKGROUND) - goto bad_background; - break; - - case PNG_CMAP_GA: - if (background_index != PNG_CMAP_GA_BACKGROUND) - goto bad_background; - break; - - case PNG_CMAP_TRANS: - if (background_index >= cmap_entries || - background_index != PNG_CMAP_TRANS_BACKGROUND) - goto bad_background; - break; - - case PNG_CMAP_RGB: - if (background_index != PNG_CMAP_RGB_BACKGROUND) - goto bad_background; - break; - - case PNG_CMAP_RGB_ALPHA: - if (background_index != PNG_CMAP_RGB_ALPHA_BACKGROUND) - goto bad_background; - break; - - default: - png_error(png_ptr, "bad processing option (internal error)"); - - bad_background: - png_error(png_ptr, "bad background index (internal error)"); - } - - display->colormap_processing = (int)output_processing; - - return 1/*ok*/; -} - -/* The final part of the color-map read called from png_image_finish_read. */ -static int -png_image_read_and_map(png_voidp argument) -{ - png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); - png_imagep image = display->image; - png_structrp png_ptr = image->opaque->png_ptr; - int passes; - - /* Called when the libpng data must be transformed into the color-mapped - * form. There is a local row buffer in display->local and this routine must - * do the interlace handling. - */ - switch (png_ptr->interlaced) - { - case PNG_INTERLACE_NONE: - passes = 1; - break; - - case PNG_INTERLACE_ADAM7: - passes = PNG_INTERLACE_ADAM7_PASSES; - break; - - default: - png_error(png_ptr, "unknown interlace type"); - } - - { - png_uint_32 height = image->height; - png_uint_32 width = image->width; - int proc = display->colormap_processing; - png_bytep first_row = png_voidcast(png_bytep, display->first_row); - ptrdiff_t step_row = display->row_bytes; - int pass; - - for (pass = 0; pass < passes; ++pass) - { - unsigned int startx, stepx, stepy; - png_uint_32 y; - - if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) - { - /* The row may be empty for a short image: */ - if (PNG_PASS_COLS(width, pass) == 0) - continue; - - startx = PNG_PASS_START_COL(pass); - stepx = PNG_PASS_COL_OFFSET(pass); - y = PNG_PASS_START_ROW(pass); - stepy = PNG_PASS_ROW_OFFSET(pass); - } - - else - { - y = 0; - startx = 0; - stepx = stepy = 1; - } - - for (; ylocal_row); - png_bytep outrow = first_row + y * step_row; - png_const_bytep end_row = outrow + width; - - /* Read read the libpng data into the temporary buffer. */ - png_read_row(png_ptr, inrow, NULL); - - /* Now process the row according to the processing option, note - * that the caller verifies that the format of the libpng output - * data is as required. - */ - outrow += startx; - switch (proc) - { - case PNG_CMAP_GA: - for (; outrow < end_row; outrow += stepx) - { - /* The data is always in the PNG order */ - unsigned int gray = *inrow++; - unsigned int alpha = *inrow++; - unsigned int entry; - - /* NOTE: this code is copied as a comment in - * make_ga_colormap above. Please update the - * comment if you change this code! - */ - if (alpha > 229) /* opaque */ - { - entry = (231 * gray + 128) >> 8; - } - else if (alpha < 26) /* transparent */ - { - entry = 231; - } - else /* partially opaque */ - { - entry = 226 + 6 * PNG_DIV51(alpha) + PNG_DIV51(gray); - } - - *outrow = (png_byte)entry; - } - break; - - case PNG_CMAP_TRANS: - for (; outrow < end_row; outrow += stepx) - { - png_byte gray = *inrow++; - png_byte alpha = *inrow++; - - if (alpha == 0) - *outrow = PNG_CMAP_TRANS_BACKGROUND; - - else if (gray != PNG_CMAP_TRANS_BACKGROUND) - *outrow = gray; - - else - *outrow = (png_byte)(PNG_CMAP_TRANS_BACKGROUND+1); - } - break; - - case PNG_CMAP_RGB: - for (; outrow < end_row; outrow += stepx) - { - *outrow = PNG_RGB_INDEX(inrow[0], inrow[1], inrow[2]); - inrow += 3; - } - break; - - case PNG_CMAP_RGB_ALPHA: - for (; outrow < end_row; outrow += stepx) - { - unsigned int alpha = inrow[3]; - - /* Because the alpha entries only hold alpha==0.5 values - * split the processing at alpha==0.25 (64) and 0.75 - * (196). - */ - - if (alpha >= 196) - *outrow = PNG_RGB_INDEX(inrow[0], inrow[1], - inrow[2]); - - else if (alpha < 64) - *outrow = PNG_CMAP_RGB_ALPHA_BACKGROUND; - - else - { - /* Likewise there are three entries for each of r, g - * and b. We could select the entry by popcount on - * the top two bits on those architectures that - * support it, this is what the code below does, - * crudely. - */ - unsigned int back_i = PNG_CMAP_RGB_ALPHA_BACKGROUND+1; - - /* Here are how the values map: - * - * 0x00 .. 0x3f -> 0 - * 0x40 .. 0xbf -> 1 - * 0xc0 .. 0xff -> 2 - * - * So, as above with the explicit alpha checks, the - * breakpoints are at 64 and 196. - */ - if (inrow[0] & 0x80) back_i += 9; /* red */ - if (inrow[0] & 0x40) back_i += 9; - if (inrow[0] & 0x80) back_i += 3; /* green */ - if (inrow[0] & 0x40) back_i += 3; - if (inrow[0] & 0x80) back_i += 1; /* blue */ - if (inrow[0] & 0x40) back_i += 1; - - *outrow = (png_byte)back_i; - } - - inrow += 4; - } - break; - - default: - break; - } - } - } - } - - return 1; -} - -static int -png_image_read_colormapped(png_voidp argument) -{ - png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); - png_imagep image = display->image; - png_controlp control = image->opaque; - png_structrp png_ptr = control->png_ptr; - png_inforp info_ptr = control->info_ptr; - - int passes = 0; /* As a flag */ - - PNG_SKIP_CHUNKS(png_ptr); - - /* Update the 'info' structure and make sure the result is as required; first - * make sure to turn on the interlace handling if it will be required - * (because it can't be turned on *after* the call to png_read_update_info!) - */ - if (display->colormap_processing == PNG_CMAP_NONE) - passes = png_set_interlace_handling(png_ptr); - - png_read_update_info(png_ptr, info_ptr); - - /* The expected output can be deduced from the colormap_processing option. */ - switch (display->colormap_processing) - { - case PNG_CMAP_NONE: - /* Output must be one channel and one byte per pixel, the output - * encoding can be anything. - */ - if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE || - info_ptr->color_type == PNG_COLOR_TYPE_GRAY) && - info_ptr->bit_depth == 8) - break; - - goto bad_output; - - case PNG_CMAP_TRANS: - case PNG_CMAP_GA: - /* Output must be two channels and the 'G' one must be sRGB, the latter - * can be checked with an exact number because it should have been set - * to this number above! - */ - if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && - info_ptr->bit_depth == 8 && - png_ptr->screen_gamma == PNG_GAMMA_sRGB && - image->colormap_entries == 256) - break; - - goto bad_output; - - case PNG_CMAP_RGB: - /* Output must be 8-bit sRGB encoded RGB */ - if (info_ptr->color_type == PNG_COLOR_TYPE_RGB && - info_ptr->bit_depth == 8 && - png_ptr->screen_gamma == PNG_GAMMA_sRGB && - image->colormap_entries == 216) - break; - - goto bad_output; - - case PNG_CMAP_RGB_ALPHA: - /* Output must be 8-bit sRGB encoded RGBA */ - if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA && - info_ptr->bit_depth == 8 && - png_ptr->screen_gamma == PNG_GAMMA_sRGB && - image->colormap_entries == 244 /* 216 + 1 + 27 */) - break; - - goto bad_output; - - default: - bad_output: - png_error(png_ptr, "bad color-map processing (internal error)"); - } - - /* Now read the rows. Do this here if it is possible to read directly into - * the output buffer, otherwise allocate a local row buffer of the maximum - * size libpng requires and call the relevant processing routine safely. - */ - { - png_voidp first_row = display->buffer; - ptrdiff_t row_bytes = display->row_stride; - - /* The following expression is designed to work correctly whether it gives - * a signed or an unsigned result. - */ - if (row_bytes < 0) - { - char *ptr = png_voidcast(char*, first_row); - ptr += (image->height-1) * (-row_bytes); - first_row = png_voidcast(png_voidp, ptr); - } - - display->first_row = first_row; - display->row_bytes = row_bytes; - } - - if (passes == 0) - { - int result; - png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); - - display->local_row = row; - result = png_safe_execute(image, png_image_read_and_map, display); - display->local_row = NULL; - png_free(png_ptr, row); - - return result; - } - - else - { - png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes; - - while (--passes >= 0) - { - png_uint_32 y = image->height; - png_bytep row = png_voidcast(png_bytep, display->first_row); - - for (; y > 0; --y) - { - png_read_row(png_ptr, row, NULL); - row += row_bytes; - } - } - - return 1; - } -} - -/* Just the row reading part of png_image_read. */ -static int -png_image_read_composite(png_voidp argument) -{ - png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); - png_imagep image = display->image; - png_structrp png_ptr = image->opaque->png_ptr; - int passes; - - switch (png_ptr->interlaced) - { - case PNG_INTERLACE_NONE: - passes = 1; - break; - - case PNG_INTERLACE_ADAM7: - passes = PNG_INTERLACE_ADAM7_PASSES; - break; - - default: - png_error(png_ptr, "unknown interlace type"); - } - - { - png_uint_32 height = image->height; - png_uint_32 width = image->width; - ptrdiff_t step_row = display->row_bytes; - unsigned int channels = - (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1; - int pass; - - for (pass = 0; pass < passes; ++pass) - { - unsigned int startx, stepx, stepy; - png_uint_32 y; - - if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) - { - /* The row may be empty for a short image: */ - if (PNG_PASS_COLS(width, pass) == 0) - continue; - - startx = PNG_PASS_START_COL(pass) * channels; - stepx = PNG_PASS_COL_OFFSET(pass) * channels; - y = PNG_PASS_START_ROW(pass); - stepy = PNG_PASS_ROW_OFFSET(pass); - } - - else - { - y = 0; - startx = 0; - stepx = channels; - stepy = 1; - } - - for (; ylocal_row); - png_bytep outrow; - png_const_bytep end_row; - - /* Read the row, which is packed: */ - png_read_row(png_ptr, inrow, NULL); - - outrow = png_voidcast(png_bytep, display->first_row); - outrow += y * step_row; - end_row = outrow + width * channels; - - /* Now do the composition on each pixel in this row. */ - outrow += startx; - for (; outrow < end_row; outrow += stepx) - { - png_byte alpha = inrow[channels]; - - if (alpha > 0) /* else no change to the output */ - { - unsigned int c; - - for (c=0; cimage; - png_structrp png_ptr = image->opaque->png_ptr; - png_inforp info_ptr = image->opaque->info_ptr; - png_uint_32 height = image->height; - png_uint_32 width = image->width; - int pass, passes; - - /* Double check the convoluted logic below. We expect to get here with - * libpng doing rgb to gray and gamma correction but background processing - * left to the png_image_read_background function. The rows libpng produce - * might be 8 or 16-bit but should always have two channels; gray plus alpha. - */ - if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == 0) - png_error(png_ptr, "lost rgb to gray"); - - if ((png_ptr->transformations & PNG_COMPOSE) != 0) - png_error(png_ptr, "unexpected compose"); - - if (png_get_channels(png_ptr, info_ptr) != 2) - png_error(png_ptr, "lost/gained channels"); - - /* Expect the 8-bit case to always remove the alpha channel */ - if ((image->format & PNG_FORMAT_FLAG_LINEAR) == 0 && - (image->format & PNG_FORMAT_FLAG_ALPHA) != 0) - png_error(png_ptr, "unexpected 8-bit transformation"); - - switch (png_ptr->interlaced) - { - case PNG_INTERLACE_NONE: - passes = 1; - break; - - case PNG_INTERLACE_ADAM7: - passes = PNG_INTERLACE_ADAM7_PASSES; - break; - - default: - png_error(png_ptr, "unknown interlace type"); - } - - /* Use direct access to info_ptr here because otherwise the simplified API - * would require PNG_EASY_ACCESS_SUPPORTED (just for this.) Note this is - * checking the value after libpng expansions, not the original value in the - * PNG. - */ - switch (info_ptr->bit_depth) - { - case 8: - /* 8-bit sRGB gray values with an alpha channel; the alpha channel is - * to be removed by composing on a background: either the row if - * display->background is NULL or display->background->green if not. - * Unlike the code above ALPHA_OPTIMIZED has *not* been done. - */ - { - png_bytep first_row = png_voidcast(png_bytep, display->first_row); - ptrdiff_t step_row = display->row_bytes; - - for (pass = 0; pass < passes; ++pass) - { - png_bytep row = png_voidcast(png_bytep, display->first_row); - unsigned int startx, stepx, stepy; - png_uint_32 y; - - if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) - { - /* The row may be empty for a short image: */ - if (PNG_PASS_COLS(width, pass) == 0) - continue; - - startx = PNG_PASS_START_COL(pass); - stepx = PNG_PASS_COL_OFFSET(pass); - y = PNG_PASS_START_ROW(pass); - stepy = PNG_PASS_ROW_OFFSET(pass); - } - - else - { - y = 0; - startx = 0; - stepx = stepy = 1; - } - - if (display->background == NULL) - { - for (; ylocal_row); - png_bytep outrow = first_row + y * step_row; - png_const_bytep end_row = outrow + width; - - /* Read the row, which is packed: */ - png_read_row(png_ptr, inrow, NULL); - - /* Now do the composition on each pixel in this row. */ - outrow += startx; - for (; outrow < end_row; outrow += stepx) - { - png_byte alpha = inrow[1]; - - if (alpha > 0) /* else no change to the output */ - { - png_uint_32 component = inrow[0]; - - if (alpha < 255) /* else just use component */ - { - /* Since PNG_OPTIMIZED_ALPHA was not set it is - * necessary to invert the sRGB transfer - * function and multiply the alpha out. - */ - component = png_sRGB_table[component] * alpha; - component += png_sRGB_table[outrow[0]] * - (255-alpha); - component = PNG_sRGB_FROM_LINEAR(component); - } - - outrow[0] = (png_byte)component; - } - - inrow += 2; /* gray and alpha channel */ - } - } - } - - else /* constant background value */ - { - png_byte background8 = display->background->green; - png_uint_16 background = png_sRGB_table[background8]; - - for (; ylocal_row); - png_bytep outrow = first_row + y * step_row; - png_const_bytep end_row = outrow + width; - - /* Read the row, which is packed: */ - png_read_row(png_ptr, inrow, NULL); - - /* Now do the composition on each pixel in this row. */ - outrow += startx; - for (; outrow < end_row; outrow += stepx) - { - png_byte alpha = inrow[1]; - - if (alpha > 0) /* else use background */ - { - png_uint_32 component = inrow[0]; - - if (alpha < 255) /* else just use component */ - { - component = png_sRGB_table[component] * alpha; - component += background * (255-alpha); - component = PNG_sRGB_FROM_LINEAR(component); - } - - outrow[0] = (png_byte)component; - } - - else - outrow[0] = background8; - - inrow += 2; /* gray and alpha channel */ - } - - row += display->row_bytes; - } - } - } - } - break; - - case 16: - /* 16-bit linear with pre-multiplied alpha; the pre-multiplication must - * still be done and, maybe, the alpha channel removed. This code also - * handles the alpha-first option. - */ - { - png_uint_16p first_row = png_voidcast(png_uint_16p, - display->first_row); - /* The division by two is safe because the caller passed in a - * stride which was multiplied by 2 (below) to get row_bytes. - */ - ptrdiff_t step_row = display->row_bytes / 2; - unsigned int preserve_alpha = (image->format & - PNG_FORMAT_FLAG_ALPHA) != 0; - unsigned int outchannels = 1U+preserve_alpha; - int swap_alpha = 0; - -# ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED - if (preserve_alpha != 0 && - (image->format & PNG_FORMAT_FLAG_AFIRST) != 0) - swap_alpha = 1; -# endif - - for (pass = 0; pass < passes; ++pass) - { - unsigned int startx, stepx, stepy; - png_uint_32 y; - - /* The 'x' start and step are adjusted to output components here. - */ - if (png_ptr->interlaced == PNG_INTERLACE_ADAM7) - { - /* The row may be empty for a short image: */ - if (PNG_PASS_COLS(width, pass) == 0) - continue; - - startx = PNG_PASS_START_COL(pass) * outchannels; - stepx = PNG_PASS_COL_OFFSET(pass) * outchannels; - y = PNG_PASS_START_ROW(pass); - stepy = PNG_PASS_ROW_OFFSET(pass); - } - - else - { - y = 0; - startx = 0; - stepx = outchannels; - stepy = 1; - } - - for (; ylocal_row), NULL); - inrow = png_voidcast(png_const_uint_16p, display->local_row); - - /* Now do the pre-multiplication on each pixel in this row. - */ - outrow += startx; - for (; outrow < end_row; outrow += stepx) - { - png_uint_32 component = inrow[0]; - png_uint_16 alpha = inrow[1]; - - if (alpha > 0) /* else 0 */ - { - if (alpha < 65535) /* else just use component */ - { - component *= alpha; - component += 32767; - component /= 65535; - } - } - - else - component = 0; - - outrow[swap_alpha] = (png_uint_16)component; - if (preserve_alpha != 0) - outrow[1 ^ swap_alpha] = alpha; - - inrow += 2; /* components and alpha channel */ - } - } - } - } - break; - -#ifdef __GNUC__ - default: - png_error(png_ptr, "unexpected bit depth"); -#endif - } - - return 1; -} - -/* The guts of png_image_finish_read as a png_safe_execute callback. */ -static int -png_image_read_direct(png_voidp argument) -{ - png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); - png_imagep image = display->image; - png_structrp png_ptr = image->opaque->png_ptr; - png_inforp info_ptr = image->opaque->info_ptr; - - png_uint_32 format = image->format; - int linear = (format & PNG_FORMAT_FLAG_LINEAR) != 0; - int do_local_compose = 0; - int do_local_background = 0; /* to avoid double gamma correction bug */ - int passes = 0; - - /* Add transforms to ensure the correct output format is produced then check - * that the required implementation support is there. Always expand; always - * need 8 bits minimum, no palette and expanded tRNS. - */ - png_set_expand(png_ptr); - - /* Now check the format to see if it was modified. */ - { - png_uint_32 base_format = png_image_format(png_ptr) & - ~PNG_FORMAT_FLAG_COLORMAP /* removed by png_set_expand */; - png_uint_32 change = format ^ base_format; - png_fixed_point output_gamma; - int mode; /* alpha mode */ - - /* Do this first so that we have a record if rgb to gray is happening. */ - if ((change & PNG_FORMAT_FLAG_COLOR) != 0) - { - /* gray<->color transformation required. */ - if ((format & PNG_FORMAT_FLAG_COLOR) != 0) - png_set_gray_to_rgb(png_ptr); - - else - { - /* libpng can't do both rgb to gray and - * background/pre-multiplication if there is also significant gamma - * correction, because both operations require linear colors and - * the code only supports one transform doing the gamma correction. - * Handle this by doing the pre-multiplication or background - * operation in this code, if necessary. - * - * TODO: fix this by rewriting pngrtran.c (!) - * - * For the moment (given that fixing this in pngrtran.c is an - * enormous change) 'do_local_background' is used to indicate that - * the problem exists. - */ - if ((base_format & PNG_FORMAT_FLAG_ALPHA) != 0) - do_local_background = 1/*maybe*/; - - png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, - PNG_RGB_TO_GRAY_DEFAULT, PNG_RGB_TO_GRAY_DEFAULT); - } - - change &= ~PNG_FORMAT_FLAG_COLOR; - } - - /* Set the gamma appropriately, linear for 16-bit input, sRGB otherwise. - */ - { - png_fixed_point input_gamma_default; - - if ((base_format & PNG_FORMAT_FLAG_LINEAR) != 0 && - (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0) - input_gamma_default = PNG_GAMMA_LINEAR; - else - input_gamma_default = PNG_DEFAULT_sRGB; - - /* Call png_set_alpha_mode to set the default for the input gamma; the - * output gamma is set by a second call below. - */ - png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, input_gamma_default); - } - - if (linear != 0) - { - /* If there *is* an alpha channel in the input it must be multiplied - * out; use PNG_ALPHA_STANDARD, otherwise just use PNG_ALPHA_PNG. - */ - if ((base_format & PNG_FORMAT_FLAG_ALPHA) != 0) - mode = PNG_ALPHA_STANDARD; /* associated alpha */ - - else - mode = PNG_ALPHA_PNG; - - output_gamma = PNG_GAMMA_LINEAR; - } - - else - { - mode = PNG_ALPHA_PNG; - output_gamma = PNG_DEFAULT_sRGB; - } - - if ((change & PNG_FORMAT_FLAG_ASSOCIATED_ALPHA) != 0) - { - mode = PNG_ALPHA_OPTIMIZED; - change &= ~PNG_FORMAT_FLAG_ASSOCIATED_ALPHA; - } - - /* If 'do_local_background' is set check for the presence of gamma - * correction; this is part of the work-round for the libpng bug - * described above. - * - * TODO: fix libpng and remove this. - */ - if (do_local_background != 0) - { - png_fixed_point gtest; - - /* This is 'png_gamma_threshold' from pngrtran.c; the test used for - * gamma correction, the screen gamma hasn't been set on png_struct - * yet; it's set below. png_struct::gamma, however, is set to the - * final value. - */ - if (png_muldiv(>est, output_gamma, png_ptr->colorspace.gamma, - PNG_FP_1) != 0 && png_gamma_significant(gtest) == 0) - do_local_background = 0; - - else if (mode == PNG_ALPHA_STANDARD) - { - do_local_background = 2/*required*/; - mode = PNG_ALPHA_PNG; /* prevent libpng doing it */ - } - - /* else leave as 1 for the checks below */ - } - - /* If the bit-depth changes then handle that here. */ - if ((change & PNG_FORMAT_FLAG_LINEAR) != 0) - { - if (linear != 0 /*16-bit output*/) - png_set_expand_16(png_ptr); - - else /* 8-bit output */ - png_set_scale_16(png_ptr); - - change &= ~PNG_FORMAT_FLAG_LINEAR; - } - - /* Now the background/alpha channel changes. */ - if ((change & PNG_FORMAT_FLAG_ALPHA) != 0) - { - /* Removing an alpha channel requires composition for the 8-bit - * formats; for the 16-bit it is already done, above, by the - * pre-multiplication and the channel just needs to be stripped. - */ - if ((base_format & PNG_FORMAT_FLAG_ALPHA) != 0) - { - /* If RGB->gray is happening the alpha channel must be left and the - * operation completed locally. - * - * TODO: fix libpng and remove this. - */ - if (do_local_background != 0) - do_local_background = 2/*required*/; - - /* 16-bit output: just remove the channel */ - else if (linear != 0) /* compose on black (well, pre-multiply) */ - png_set_strip_alpha(png_ptr); - - /* 8-bit output: do an appropriate compose */ - else if (display->background != NULL) - { - png_color_16 c; - - c.index = 0; /*unused*/ - c.red = display->background->red; - c.green = display->background->green; - c.blue = display->background->blue; - c.gray = display->background->green; - - /* This is always an 8-bit sRGB value, using the 'green' channel - * for gray is much better than calculating the luminance here; - * we can get off-by-one errors in that calculation relative to - * the app expectations and that will show up in transparent - * pixels. - */ - png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); - } - - else /* compose on row: implemented below. */ - { - do_local_compose = 1; - /* This leaves the alpha channel in the output, so it has to be - * removed by the code below. Set the encoding to the 'OPTIMIZE' - * one so the code only has to hack on the pixels that require - * composition. - */ - mode = PNG_ALPHA_OPTIMIZED; - } - } - - else /* output needs an alpha channel */ - { - /* This is tricky because it happens before the swap operation has - * been accomplished; however, the swap does *not* swap the added - * alpha channel (weird API), so it must be added in the correct - * place. - */ - png_uint_32 filler; /* opaque filler */ - int where; - - if (linear != 0) - filler = 65535; - - else - filler = 255; - -#ifdef PNG_FORMAT_AFIRST_SUPPORTED - if ((format & PNG_FORMAT_FLAG_AFIRST) != 0) - { - where = PNG_FILLER_BEFORE; - change &= ~PNG_FORMAT_FLAG_AFIRST; - } - - else -#endif - where = PNG_FILLER_AFTER; - - png_set_add_alpha(png_ptr, filler, where); - } - - /* This stops the (irrelevant) call to swap_alpha below. */ - change &= ~PNG_FORMAT_FLAG_ALPHA; - } - - /* Now set the alpha mode correctly; this is always done, even if there is - * no alpha channel in either the input or the output because it correctly - * sets the output gamma. - */ - png_set_alpha_mode_fixed(png_ptr, mode, output_gamma); - -# ifdef PNG_FORMAT_BGR_SUPPORTED - if ((change & PNG_FORMAT_FLAG_BGR) != 0) - { - /* Check only the output format; PNG is never BGR; don't do this if - * the output is gray, but fix up the 'format' value in that case. - */ - if ((format & PNG_FORMAT_FLAG_COLOR) != 0) - png_set_bgr(png_ptr); - - else - format &= ~PNG_FORMAT_FLAG_BGR; - - change &= ~PNG_FORMAT_FLAG_BGR; - } -# endif - -# ifdef PNG_FORMAT_AFIRST_SUPPORTED - if ((change & PNG_FORMAT_FLAG_AFIRST) != 0) - { - /* Only relevant if there is an alpha channel - it's particularly - * important to handle this correctly because do_local_compose may - * be set above and then libpng will keep the alpha channel for this - * code to remove. - */ - if ((format & PNG_FORMAT_FLAG_ALPHA) != 0) - { - /* Disable this if doing a local background, - * TODO: remove this when local background is no longer required. - */ - if (do_local_background != 2) - png_set_swap_alpha(png_ptr); - } - - else - format &= ~PNG_FORMAT_FLAG_AFIRST; - - change &= ~PNG_FORMAT_FLAG_AFIRST; - } -# endif - - /* If the *output* is 16-bit then we need to check for a byte-swap on this - * architecture. - */ - if (linear != 0) - { - png_uint_16 le = 0x0001; - - if ((*(png_const_bytep) & le) != 0) - png_set_swap(png_ptr); - } - - /* If change is not now 0 some transformation is missing - error out. */ - if (change != 0) - png_error(png_ptr, "png_read_image: unsupported transformation"); - } - - PNG_SKIP_CHUNKS(png_ptr); - - /* Update the 'info' structure and make sure the result is as required; first - * make sure to turn on the interlace handling if it will be required - * (because it can't be turned on *after* the call to png_read_update_info!) - * - * TODO: remove the do_local_background fixup below. - */ - if (do_local_compose == 0 && do_local_background != 2) - passes = png_set_interlace_handling(png_ptr); - - png_read_update_info(png_ptr, info_ptr); - - { - png_uint_32 info_format = 0; - - if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) - info_format |= PNG_FORMAT_FLAG_COLOR; - - if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0) - { - /* do_local_compose removes this channel below. */ - if (do_local_compose == 0) - { - /* do_local_background does the same if required. */ - if (do_local_background != 2 || - (format & PNG_FORMAT_FLAG_ALPHA) != 0) - info_format |= PNG_FORMAT_FLAG_ALPHA; - } - } - - else if (do_local_compose != 0) /* internal error */ - png_error(png_ptr, "png_image_read: alpha channel lost"); - - if ((format & PNG_FORMAT_FLAG_ASSOCIATED_ALPHA) != 0) { - info_format |= PNG_FORMAT_FLAG_ASSOCIATED_ALPHA; - } - - if (info_ptr->bit_depth == 16) - info_format |= PNG_FORMAT_FLAG_LINEAR; - -#ifdef PNG_FORMAT_BGR_SUPPORTED - if ((png_ptr->transformations & PNG_BGR) != 0) - info_format |= PNG_FORMAT_FLAG_BGR; -#endif - -#ifdef PNG_FORMAT_AFIRST_SUPPORTED - if (do_local_background == 2) - { - if ((format & PNG_FORMAT_FLAG_AFIRST) != 0) - info_format |= PNG_FORMAT_FLAG_AFIRST; - } - - if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0 || - ((png_ptr->transformations & PNG_ADD_ALPHA) != 0 && - (png_ptr->flags & PNG_FLAG_FILLER_AFTER) == 0)) - { - if (do_local_background == 2) - png_error(png_ptr, "unexpected alpha swap transformation"); - - info_format |= PNG_FORMAT_FLAG_AFIRST; - } -# endif - - /* This is actually an internal error. */ - if (info_format != format) - png_error(png_ptr, "png_read_image: invalid transformations"); - } - - /* Now read the rows. If do_local_compose is set then it is necessary to use - * a local row buffer. The output will be GA, RGBA or BGRA and must be - * converted to G, RGB or BGR as appropriate. The 'local_row' member of the - * display acts as a flag. - */ - { - png_voidp first_row = display->buffer; - ptrdiff_t row_bytes = display->row_stride; - - if (linear != 0) - row_bytes *= 2; - - /* The following expression is designed to work correctly whether it gives - * a signed or an unsigned result. - */ - if (row_bytes < 0) - { - char *ptr = png_voidcast(char*, first_row); - ptr += (image->height-1) * (-row_bytes); - first_row = png_voidcast(png_voidp, ptr); - } - - display->first_row = first_row; - display->row_bytes = row_bytes; - } - - if (do_local_compose != 0) - { - int result; - png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); - - display->local_row = row; - result = png_safe_execute(image, png_image_read_composite, display); - display->local_row = NULL; - png_free(png_ptr, row); - - return result; - } - - else if (do_local_background == 2) - { - int result; - png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); - - display->local_row = row; - result = png_safe_execute(image, png_image_read_background, display); - display->local_row = NULL; - png_free(png_ptr, row); - - return result; - } - - else - { - png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes; - - while (--passes >= 0) - { - png_uint_32 y = image->height; - png_bytep row = png_voidcast(png_bytep, display->first_row); - - for (; y > 0; --y) - { - png_read_row(png_ptr, row, NULL); - row += row_bytes; - } - } - - return 1; - } -} - -int PNGAPI -png_image_finish_read(png_imagep image, png_const_colorp background, - void *buffer, png_int_32 row_stride, void *colormap) -{ - if (image != NULL && image->version == PNG_IMAGE_VERSION) - { - /* Check for row_stride overflow. This check is not performed on the - * original PNG format because it may not occur in the output PNG format - * and libpng deals with the issues of reading the original. - */ - unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format); - - /* The following checks just the 'row_stride' calculation to ensure it - * fits in a signed 32-bit value. Because channels/components can be - * either 1 or 2 bytes in size the length of a row can still overflow 32 - * bits; this is just to verify that the 'row_stride' argument can be - * represented. - */ - if (image->width <= 0x7fffffffU/channels) /* no overflow */ - { - png_uint_32 check; - png_uint_32 png_row_stride = image->width * channels; - - if (row_stride == 0) - row_stride = (png_int_32)/*SAFE*/png_row_stride; - - if (row_stride < 0) - check = (png_uint_32)(-row_stride); - - else - check = (png_uint_32)row_stride; - - /* This verifies 'check', the absolute value of the actual stride - * passed in and detects overflow in the application calculation (i.e. - * if the app did actually pass in a non-zero 'row_stride'. - */ - if (image->opaque != NULL && buffer != NULL && check >= png_row_stride) - { - /* Now check for overflow of the image buffer calculation; this - * limits the whole image size to 32 bits for API compatibility with - * the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro. - * - * The PNG_IMAGE_BUFFER_SIZE macro is: - * - * (PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)*height*(row_stride)) - * - * And the component size is always 1 or 2, so make sure that the - * number of *bytes* that the application is saying are available - * does actually fit into a 32-bit number. - * - * NOTE: this will be changed in 1.7 because PNG_IMAGE_BUFFER_SIZE - * will be changed to use png_alloc_size_t; bigger images can be - * accommodated on 64-bit systems. - */ - if (image->height <= - 0xffffffffU/PNG_IMAGE_PIXEL_COMPONENT_SIZE(image->format)/check) - { - if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 || - (image->colormap_entries > 0 && colormap != NULL)) - { - int result; - png_image_read_control display; - - memset(&display, 0, (sizeof display)); - display.image = image; - display.buffer = buffer; - display.row_stride = row_stride; - display.colormap = colormap; - display.background = background; - display.local_row = NULL; - - /* Choose the correct 'end' routine; for the color-map case - * all the setup has already been done. - */ - if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0) - result = - png_safe_execute(image, - png_image_read_colormap, &display) && - png_safe_execute(image, - png_image_read_colormapped, &display); - - else - result = - png_safe_execute(image, - png_image_read_direct, &display); - - png_image_free(image); - return result; - } - - else - return png_image_error(image, - "png_image_finish_read[color-map]: no color-map"); - } - - else - return png_image_error(image, - "png_image_finish_read: image too large"); - } - - else - return png_image_error(image, - "png_image_finish_read: invalid argument"); - } - - else - return png_image_error(image, - "png_image_finish_read: row_stride too large"); - } - - else if (image != NULL) - return png_image_error(image, - "png_image_finish_read: damaged PNG_IMAGE_VERSION"); - - return 0; -} - -#endif /* SIMPLIFIED_READ */ -#endif /* READ */ diff --git a/oversampling/WDL/libpng/pngrio.c b/oversampling/WDL/libpng/pngrio.c deleted file mode 100644 index 7946358..0000000 --- a/oversampling/WDL/libpng/pngrio.c +++ /dev/null @@ -1,120 +0,0 @@ - -/* pngrio.c - functions for data input - * - * Copyright (c) 2018 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * - * This file provides a location for all input. Users who need - * special handling are expected to write a function that has the same - * arguments as this and performs a similar function, but that possibly - * has a different input method. Note that you shouldn't change this - * function, but rather write a replacement function and then make - * libpng use it at run time with png_set_read_fn(...). - */ - -#include "pngpriv.h" - -#ifdef PNG_READ_SUPPORTED - -/* Read the data from whatever input you are using. The default routine - * reads from a file pointer. Note that this routine sometimes gets called - * with very small lengths, so you should implement some kind of simple - * buffering if you are using unbuffered reads. This should never be asked - * to read more than 64K on a 16-bit machine. - */ -void /* PRIVATE */ -png_read_data(png_structrp png_ptr, png_bytep data, size_t length) -{ - png_debug1(4, "reading %d bytes", (int)length); - - if (png_ptr->read_data_fn != NULL) - (*(png_ptr->read_data_fn))(png_ptr, data, length); - - else - png_error(png_ptr, "Call to NULL read function"); -} - -#ifdef PNG_STDIO_SUPPORTED -/* This is the function that does the actual reading of data. If you are - * not reading from a standard C stream, you should create a replacement - * read_data function and use it at run time with png_set_read_fn(), rather - * than changing the library. - */ -void PNGCBAPI -png_default_read_data(png_structp png_ptr, png_bytep data, size_t length) -{ - size_t check; - - if (png_ptr == NULL) - return; - - /* fread() returns 0 on error, so it is OK to store this in a size_t - * instead of an int, which is what fread() actually returns. - */ - check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr)); - - if (check != length) - png_error(png_ptr, "Read Error"); -} -#endif - -/* This function allows the application to supply a new input function - * for libpng if standard C streams aren't being used. - * - * This function takes as its arguments: - * - * png_ptr - pointer to a png input data structure - * - * io_ptr - pointer to user supplied structure containing info about - * the input functions. May be NULL. - * - * read_data_fn - pointer to a new input function that takes as its - * arguments a pointer to a png_struct, a pointer to - * a location where input data can be stored, and a 32-bit - * unsigned int that is the number of bytes to be read. - * To exit and output any fatal error messages the new write - * function should call png_error(png_ptr, "Error msg"). - * May be NULL, in which case libpng's default function will - * be used. - */ -void PNGAPI -png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr, - png_rw_ptr read_data_fn) -{ - if (png_ptr == NULL) - return; - - png_ptr->io_ptr = io_ptr; - -#ifdef PNG_STDIO_SUPPORTED - if (read_data_fn != NULL) - png_ptr->read_data_fn = read_data_fn; - - else - png_ptr->read_data_fn = png_default_read_data; -#else - png_ptr->read_data_fn = read_data_fn; -#endif - -#ifdef PNG_WRITE_SUPPORTED - /* It is an error to write to a read device */ - if (png_ptr->write_data_fn != NULL) - { - png_ptr->write_data_fn = NULL; - png_warning(png_ptr, - "Can't set both read_data_fn and write_data_fn in the" - " same structure"); - } -#endif - -#ifdef PNG_WRITE_FLUSH_SUPPORTED - png_ptr->output_flush_fn = NULL; -#endif -} -#endif /* READ */ diff --git a/oversampling/WDL/libpng/pngrtran.c b/oversampling/WDL/libpng/pngrtran.c deleted file mode 100644 index 1725631..0000000 --- a/oversampling/WDL/libpng/pngrtran.c +++ /dev/null @@ -1,5044 +0,0 @@ - -/* pngrtran.c - transforms the data in a row for PNG readers - * - * Copyright (c) 2018-2019 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * - * This file contains functions optionally called by an application - * in order to tell libpng how to handle data when reading a PNG. - * Transformations that are used in both reading and writing are - * in pngtrans.c. - */ - -#include "pngpriv.h" - -#ifdef PNG_ARM_NEON_IMPLEMENTATION -# if PNG_ARM_NEON_IMPLEMENTATION == 1 -# define PNG_ARM_NEON_INTRINSICS_AVAILABLE -# if defined(_MSC_VER) && (defined(_M_ARM64) || defined(_M_ARM64EC)) -# include -# else -# include -# endif -# endif -#endif - -#ifdef PNG_READ_SUPPORTED - -/* Set the action on getting a CRC error for an ancillary or critical chunk. */ -void PNGAPI -png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action) -{ - png_debug(1, "in png_set_crc_action"); - - if (png_ptr == NULL) - return; - - /* Tell libpng how we react to CRC errors in critical chunks */ - switch (crit_action) - { - case PNG_CRC_NO_CHANGE: /* Leave setting as is */ - break; - - case PNG_CRC_WARN_USE: /* Warn/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; - break; - - case PNG_CRC_QUIET_USE: /* Quiet/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | - PNG_FLAG_CRC_CRITICAL_IGNORE; - break; - - case PNG_CRC_WARN_DISCARD: /* Not a valid action for critical data */ - png_warning(png_ptr, - "Can't discard critical data on CRC error"); - /* FALLTHROUGH */ - case PNG_CRC_ERROR_QUIT: /* Error/quit */ - - case PNG_CRC_DEFAULT: - default: - png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; - break; - } - - /* Tell libpng how we react to CRC errors in ancillary chunks */ - switch (ancil_action) - { - case PNG_CRC_NO_CHANGE: /* Leave setting as is */ - break; - - case PNG_CRC_WARN_USE: /* Warn/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; - break; - - case PNG_CRC_QUIET_USE: /* Quiet/use data */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | - PNG_FLAG_CRC_ANCILLARY_NOWARN; - break; - - case PNG_CRC_ERROR_QUIT: /* Error/quit */ - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN; - break; - - case PNG_CRC_WARN_DISCARD: /* Warn/discard data */ - - case PNG_CRC_DEFAULT: - default: - png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; - break; - } -} - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -/* Is it OK to set a transformation now? Only if png_start_read_image or - * png_read_update_info have not been called. It is not necessary for the IHDR - * to have been read in all cases; the need_IHDR parameter allows for this - * check too. - */ -static int -png_rtran_ok(png_structrp png_ptr, int need_IHDR) -{ - if (png_ptr != NULL) - { - if ((png_ptr->flags & PNG_FLAG_ROW_INIT) != 0) - png_app_error(png_ptr, - "invalid after png_start_read_image or png_read_update_info"); - - else if (need_IHDR && (png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_app_error(png_ptr, "invalid before the PNG header has been read"); - - else - { - /* Turn on failure to initialize correctly for all transforms. */ - png_ptr->flags |= PNG_FLAG_DETECT_UNINITIALIZED; - - return 1; /* Ok */ - } - } - - return 0; /* no png_error possible! */ -} -#endif - -#ifdef PNG_READ_BACKGROUND_SUPPORTED -/* Handle alpha and tRNS via a background color */ -void PNGFAPI -png_set_background_fixed(png_structrp png_ptr, - png_const_color_16p background_color, int background_gamma_code, - int need_expand, png_fixed_point background_gamma) -{ - png_debug(1, "in png_set_background_fixed"); - - if (png_rtran_ok(png_ptr, 0) == 0 || background_color == NULL) - return; - - if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN) - { - png_warning(png_ptr, "Application must supply a known background gamma"); - return; - } - - png_ptr->transformations |= PNG_COMPOSE | PNG_STRIP_ALPHA; - png_ptr->transformations &= ~PNG_ENCODE_ALPHA; - png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; - - png_ptr->background = *background_color; - png_ptr->background_gamma = background_gamma; - png_ptr->background_gamma_type = (png_byte)(background_gamma_code); - if (need_expand != 0) - png_ptr->transformations |= PNG_BACKGROUND_EXPAND; - else - png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND; -} - -# ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_background(png_structrp png_ptr, - png_const_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma) -{ - png_set_background_fixed(png_ptr, background_color, background_gamma_code, - need_expand, png_fixed(png_ptr, background_gamma, "png_set_background")); -} -# endif /* FLOATING_POINT */ -#endif /* READ_BACKGROUND */ - -/* Scale 16-bit depth files to 8-bit depth. If both of these are set then the - * one that pngrtran does first (scale) happens. This is necessary to allow the - * TRANSFORM and API behavior to be somewhat consistent, and it's simpler. - */ -#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED -void PNGAPI -png_set_scale_16(png_structrp png_ptr) -{ - png_debug(1, "in png_set_scale_16"); - - if (png_rtran_ok(png_ptr, 0) == 0) - return; - - png_ptr->transformations |= PNG_SCALE_16_TO_8; -} -#endif - -#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED -/* Chop 16-bit depth files to 8-bit depth */ -void PNGAPI -png_set_strip_16(png_structrp png_ptr) -{ - png_debug(1, "in png_set_strip_16"); - - if (png_rtran_ok(png_ptr, 0) == 0) - return; - - png_ptr->transformations |= PNG_16_TO_8; -} -#endif - -#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED -void PNGAPI -png_set_strip_alpha(png_structrp png_ptr) -{ - png_debug(1, "in png_set_strip_alpha"); - - if (png_rtran_ok(png_ptr, 0) == 0) - return; - - png_ptr->transformations |= PNG_STRIP_ALPHA; -} -#endif - -#if defined(PNG_READ_ALPHA_MODE_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED) -static png_fixed_point -translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma, - int is_screen) -{ - /* Check for flag values. The main reason for having the old Mac value as a - * flag is that it is pretty near impossible to work out what the correct - * value is from Apple documentation - a working Mac system is needed to - * discover the value! - */ - if (output_gamma == PNG_DEFAULT_sRGB || - output_gamma == PNG_FP_1 / PNG_DEFAULT_sRGB) - { - /* If there is no sRGB support this just sets the gamma to the standard - * sRGB value. (This is a side effect of using this function!) - */ -# ifdef PNG_READ_sRGB_SUPPORTED - png_ptr->flags |= PNG_FLAG_ASSUME_sRGB; -# else - PNG_UNUSED(png_ptr) -# endif - if (is_screen != 0) - output_gamma = PNG_GAMMA_sRGB; - else - output_gamma = PNG_GAMMA_sRGB_INVERSE; - } - - else if (output_gamma == PNG_GAMMA_MAC_18 || - output_gamma == PNG_FP_1 / PNG_GAMMA_MAC_18) - { - if (is_screen != 0) - output_gamma = PNG_GAMMA_MAC_OLD; - else - output_gamma = PNG_GAMMA_MAC_INVERSE; - } - - return output_gamma; -} - -# ifdef PNG_FLOATING_POINT_SUPPORTED -static png_fixed_point -convert_gamma_value(png_structrp png_ptr, double output_gamma) -{ - /* The following silently ignores cases where fixed point (times 100,000) - * gamma values are passed to the floating point API. This is safe and it - * means the fixed point constants work just fine with the floating point - * API. The alternative would just lead to undetected errors and spurious - * bug reports. Negative values fail inside the _fixed API unless they - * correspond to the flag values. - */ - if (output_gamma > 0 && output_gamma < 128) - output_gamma *= PNG_FP_1; - - /* This preserves -1 and -2 exactly: */ - output_gamma = floor(output_gamma + .5); - - if (output_gamma > PNG_FP_MAX || output_gamma < PNG_FP_MIN) - png_fixed_error(png_ptr, "gamma value"); - - return (png_fixed_point)output_gamma; -} -# endif -#endif /* READ_ALPHA_MODE || READ_GAMMA */ - -#ifdef PNG_READ_ALPHA_MODE_SUPPORTED -void PNGFAPI -png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, - png_fixed_point output_gamma) -{ - int compose = 0; - png_fixed_point file_gamma; - - png_debug(1, "in png_set_alpha_mode"); - - if (png_rtran_ok(png_ptr, 0) == 0) - return; - - output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/); - - /* Validate the value to ensure it is in a reasonable range. The value - * is expected to be 1 or greater, but this range test allows for some - * viewing correction values. The intent is to weed out users of this API - * who use the inverse of the gamma value accidentally! Since some of these - * values are reasonable this may have to be changed: - * - * 1.6.x: changed from 0.07..3 to 0.01..100 (to accommodate the optimal 16-bit - * gamma of 36, and its reciprocal.) - */ - if (output_gamma < 1000 || output_gamma > 10000000) - png_error(png_ptr, "output gamma out of expected range"); - - /* The default file gamma is the inverse of the output gamma; the output - * gamma may be changed below so get the file value first: - */ - file_gamma = png_reciprocal(output_gamma); - - /* There are really 8 possibilities here, composed of any combination - * of: - * - * premultiply the color channels - * do not encode non-opaque pixels - * encode the alpha as well as the color channels - * - * The differences disappear if the input/output ('screen') gamma is 1.0, - * because then the encoding is a no-op and there is only the choice of - * premultiplying the color channels or not. - * - * png_set_alpha_mode and png_set_background interact because both use - * png_compose to do the work. Calling both is only useful when - * png_set_alpha_mode is used to set the default mode - PNG_ALPHA_PNG - along - * with a default gamma value. Otherwise PNG_COMPOSE must not be set. - */ - switch (mode) - { - case PNG_ALPHA_PNG: /* default: png standard */ - /* No compose, but it may be set by png_set_background! */ - png_ptr->transformations &= ~PNG_ENCODE_ALPHA; - png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; - break; - - case PNG_ALPHA_ASSOCIATED: /* color channels premultiplied */ - compose = 1; - png_ptr->transformations &= ~PNG_ENCODE_ALPHA; - png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; - /* The output is linear: */ - output_gamma = PNG_FP_1; - break; - - case PNG_ALPHA_OPTIMIZED: /* associated, non-opaque pixels linear */ - compose = 1; - png_ptr->transformations &= ~PNG_ENCODE_ALPHA; - png_ptr->flags |= PNG_FLAG_OPTIMIZE_ALPHA; - /* output_gamma records the encoding of opaque pixels! */ - break; - - case PNG_ALPHA_BROKEN: /* associated, non-linear, alpha encoded */ - compose = 1; - png_ptr->transformations |= PNG_ENCODE_ALPHA; - png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; - break; - - default: - png_error(png_ptr, "invalid alpha mode"); - } - - /* Only set the default gamma if the file gamma has not been set (this has - * the side effect that the gamma in a second call to png_set_alpha_mode will - * be ignored.) - */ - if (png_ptr->colorspace.gamma == 0) - { - png_ptr->colorspace.gamma = file_gamma; - png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; - } - - /* But always set the output gamma: */ - png_ptr->screen_gamma = output_gamma; - - /* Finally, if pre-multiplying, set the background fields to achieve the - * desired result. - */ - if (compose != 0) - { - /* And obtain alpha pre-multiplication by composing on black: */ - memset(&png_ptr->background, 0, (sizeof png_ptr->background)); - png_ptr->background_gamma = png_ptr->colorspace.gamma; /* just in case */ - png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE; - png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND; - - if ((png_ptr->transformations & PNG_COMPOSE) != 0) - png_error(png_ptr, - "conflicting calls to set alpha mode and background"); - - png_ptr->transformations |= PNG_COMPOSE; - } -} - -# ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma) -{ - png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr, - output_gamma)); -} -# endif -#endif - -#ifdef PNG_READ_QUANTIZE_SUPPORTED -/* Dither file to 8-bit. Supply a palette, the current number - * of elements in the palette, the maximum number of elements - * allowed, and a histogram if possible. If the current number - * of colors is greater than the maximum number, the palette will be - * modified to fit in the maximum number. "full_quantize" indicates - * whether we need a quantizing cube set up for RGB images, or if we - * simply are reducing the number of colors in a paletted image. - */ - -typedef struct png_dsort_struct -{ - struct png_dsort_struct * next; - png_byte left; - png_byte right; -} png_dsort; -typedef png_dsort * png_dsortp; -typedef png_dsort * * png_dsortpp; - -void PNGAPI -png_set_quantize(png_structrp png_ptr, png_colorp palette, - int num_palette, int maximum_colors, png_const_uint_16p histogram, - int full_quantize) -{ - png_debug(1, "in png_set_quantize"); - - if (png_rtran_ok(png_ptr, 0) == 0) - return; - - png_ptr->transformations |= PNG_QUANTIZE; - - if (full_quantize == 0) - { - int i; - - png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr, - (png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte)))); - for (i = 0; i < num_palette; i++) - png_ptr->quantize_index[i] = (png_byte)i; - } - - if (num_palette > maximum_colors) - { - if (histogram != NULL) - { - /* This is easy enough, just throw out the least used colors. - * Perhaps not the best solution, but good enough. - */ - - int i; - - /* Initialize an array to sort colors */ - png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr, - (png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte)))); - - /* Initialize the quantize_sort array */ - for (i = 0; i < num_palette; i++) - png_ptr->quantize_sort[i] = (png_byte)i; - - /* Find the least used palette entries by starting a - * bubble sort, and running it until we have sorted - * out enough colors. Note that we don't care about - * sorting all the colors, just finding which are - * least used. - */ - - for (i = num_palette - 1; i >= maximum_colors; i--) - { - int done; /* To stop early if the list is pre-sorted */ - int j; - - done = 1; - for (j = 0; j < i; j++) - { - if (histogram[png_ptr->quantize_sort[j]] - < histogram[png_ptr->quantize_sort[j + 1]]) - { - png_byte t; - - t = png_ptr->quantize_sort[j]; - png_ptr->quantize_sort[j] = png_ptr->quantize_sort[j + 1]; - png_ptr->quantize_sort[j + 1] = t; - done = 0; - } - } - - if (done != 0) - break; - } - - /* Swap the palette around, and set up a table, if necessary */ - if (full_quantize != 0) - { - int j = num_palette; - - /* Put all the useful colors within the max, but don't - * move the others. - */ - for (i = 0; i < maximum_colors; i++) - { - if ((int)png_ptr->quantize_sort[i] >= maximum_colors) - { - do - j--; - while ((int)png_ptr->quantize_sort[j] >= maximum_colors); - - palette[i] = palette[j]; - } - } - } - else - { - int j = num_palette; - - /* Move all the used colors inside the max limit, and - * develop a translation table. - */ - for (i = 0; i < maximum_colors; i++) - { - /* Only move the colors we need to */ - if ((int)png_ptr->quantize_sort[i] >= maximum_colors) - { - png_color tmp_color; - - do - j--; - while ((int)png_ptr->quantize_sort[j] >= maximum_colors); - - tmp_color = palette[j]; - palette[j] = palette[i]; - palette[i] = tmp_color; - /* Indicate where the color went */ - png_ptr->quantize_index[j] = (png_byte)i; - png_ptr->quantize_index[i] = (png_byte)j; - } - } - - /* Find closest color for those colors we are not using */ - for (i = 0; i < num_palette; i++) - { - if ((int)png_ptr->quantize_index[i] >= maximum_colors) - { - int min_d, k, min_k, d_index; - - /* Find the closest color to one we threw out */ - d_index = png_ptr->quantize_index[i]; - min_d = PNG_COLOR_DIST(palette[d_index], palette[0]); - for (k = 1, min_k = 0; k < maximum_colors; k++) - { - int d; - - d = PNG_COLOR_DIST(palette[d_index], palette[k]); - - if (d < min_d) - { - min_d = d; - min_k = k; - } - } - /* Point to closest color */ - png_ptr->quantize_index[i] = (png_byte)min_k; - } - } - } - png_free(png_ptr, png_ptr->quantize_sort); - png_ptr->quantize_sort = NULL; - } - else - { - /* This is much harder to do simply (and quickly). Perhaps - * we need to go through a median cut routine, but those - * don't always behave themselves with only a few colors - * as input. So we will just find the closest two colors, - * and throw out one of them (chosen somewhat randomly). - * [We don't understand this at all, so if someone wants to - * work on improving it, be our guest - AED, GRP] - */ - int i; - int max_d; - int num_new_palette; - png_dsortp t; - png_dsortpp hash; - - t = NULL; - - /* Initialize palette index arrays */ - png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, - (png_alloc_size_t)((png_uint_32)num_palette * - (sizeof (png_byte)))); - png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, - (png_alloc_size_t)((png_uint_32)num_palette * - (sizeof (png_byte)))); - - /* Initialize the sort array */ - for (i = 0; i < num_palette; i++) - { - png_ptr->index_to_palette[i] = (png_byte)i; - png_ptr->palette_to_index[i] = (png_byte)i; - } - - hash = (png_dsortpp)png_calloc(png_ptr, (png_alloc_size_t)(769 * - (sizeof (png_dsortp)))); - - num_new_palette = num_palette; - - /* Initial wild guess at how far apart the farthest pixel - * pair we will be eliminating will be. Larger - * numbers mean more areas will be allocated, Smaller - * numbers run the risk of not saving enough data, and - * having to do this all over again. - * - * I have not done extensive checking on this number. - */ - max_d = 96; - - while (num_new_palette > maximum_colors) - { - for (i = 0; i < num_new_palette - 1; i++) - { - int j; - - for (j = i + 1; j < num_new_palette; j++) - { - int d; - - d = PNG_COLOR_DIST(palette[i], palette[j]); - - if (d <= max_d) - { - - t = (png_dsortp)png_malloc_warn(png_ptr, - (png_alloc_size_t)(sizeof (png_dsort))); - - if (t == NULL) - break; - - t->next = hash[d]; - t->left = (png_byte)i; - t->right = (png_byte)j; - hash[d] = t; - } - } - if (t == NULL) - break; - } - - if (t != NULL) - for (i = 0; i <= max_d; i++) - { - if (hash[i] != NULL) - { - png_dsortp p; - - for (p = hash[i]; p; p = p->next) - { - if ((int)png_ptr->index_to_palette[p->left] - < num_new_palette && - (int)png_ptr->index_to_palette[p->right] - < num_new_palette) - { - int j, next_j; - - if (num_new_palette & 0x01) - { - j = p->left; - next_j = p->right; - } - else - { - j = p->right; - next_j = p->left; - } - - num_new_palette--; - palette[png_ptr->index_to_palette[j]] - = palette[num_new_palette]; - if (full_quantize == 0) - { - int k; - - for (k = 0; k < num_palette; k++) - { - if (png_ptr->quantize_index[k] == - png_ptr->index_to_palette[j]) - png_ptr->quantize_index[k] = - png_ptr->index_to_palette[next_j]; - - if ((int)png_ptr->quantize_index[k] == - num_new_palette) - png_ptr->quantize_index[k] = - png_ptr->index_to_palette[j]; - } - } - - png_ptr->index_to_palette[png_ptr->palette_to_index - [num_new_palette]] = png_ptr->index_to_palette[j]; - - png_ptr->palette_to_index[png_ptr->index_to_palette[j]] - = png_ptr->palette_to_index[num_new_palette]; - - png_ptr->index_to_palette[j] = - (png_byte)num_new_palette; - - png_ptr->palette_to_index[num_new_palette] = - (png_byte)j; - } - if (num_new_palette <= maximum_colors) - break; - } - if (num_new_palette <= maximum_colors) - break; - } - } - - for (i = 0; i < 769; i++) - { - if (hash[i] != NULL) - { - png_dsortp p = hash[i]; - while (p) - { - t = p->next; - png_free(png_ptr, p); - p = t; - } - } - hash[i] = 0; - } - max_d += 96; - } - png_free(png_ptr, hash); - png_free(png_ptr, png_ptr->palette_to_index); - png_free(png_ptr, png_ptr->index_to_palette); - png_ptr->palette_to_index = NULL; - png_ptr->index_to_palette = NULL; - } - num_palette = maximum_colors; - } - if (png_ptr->palette == NULL) - { - png_ptr->palette = palette; - } - png_ptr->num_palette = (png_uint_16)num_palette; - - if (full_quantize != 0) - { - int i; - png_bytep distance; - int total_bits = PNG_QUANTIZE_RED_BITS + PNG_QUANTIZE_GREEN_BITS + - PNG_QUANTIZE_BLUE_BITS; - int num_red = (1 << PNG_QUANTIZE_RED_BITS); - int num_green = (1 << PNG_QUANTIZE_GREEN_BITS); - int num_blue = (1 << PNG_QUANTIZE_BLUE_BITS); - size_t num_entries = ((size_t)1 << total_bits); - - png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr, - (png_alloc_size_t)(num_entries * (sizeof (png_byte)))); - - distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)(num_entries * - (sizeof (png_byte)))); - - memset(distance, 0xff, num_entries * (sizeof (png_byte))); - - for (i = 0; i < num_palette; i++) - { - int ir, ig, ib; - int r = (palette[i].red >> (8 - PNG_QUANTIZE_RED_BITS)); - int g = (palette[i].green >> (8 - PNG_QUANTIZE_GREEN_BITS)); - int b = (palette[i].blue >> (8 - PNG_QUANTIZE_BLUE_BITS)); - - for (ir = 0; ir < num_red; ir++) - { - /* int dr = abs(ir - r); */ - int dr = ((ir > r) ? ir - r : r - ir); - int index_r = (ir << (PNG_QUANTIZE_BLUE_BITS + - PNG_QUANTIZE_GREEN_BITS)); - - for (ig = 0; ig < num_green; ig++) - { - /* int dg = abs(ig - g); */ - int dg = ((ig > g) ? ig - g : g - ig); - int dt = dr + dg; - int dm = ((dr > dg) ? dr : dg); - int index_g = index_r | (ig << PNG_QUANTIZE_BLUE_BITS); - - for (ib = 0; ib < num_blue; ib++) - { - int d_index = index_g | ib; - /* int db = abs(ib - b); */ - int db = ((ib > b) ? ib - b : b - ib); - int dmax = ((dm > db) ? dm : db); - int d = dmax + dt + db; - - if (d < (int)distance[d_index]) - { - distance[d_index] = (png_byte)d; - png_ptr->palette_lookup[d_index] = (png_byte)i; - } - } - } - } - } - - png_free(png_ptr, distance); - } -} -#endif /* READ_QUANTIZE */ - -#ifdef PNG_READ_GAMMA_SUPPORTED -void PNGFAPI -png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma, - png_fixed_point file_gamma) -{ - png_debug(1, "in png_set_gamma_fixed"); - - if (png_rtran_ok(png_ptr, 0) == 0) - return; - - /* New in libpng-1.5.4 - reserve particular negative values as flags. */ - scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/); - file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/); - - /* Checking the gamma values for being >0 was added in 1.5.4 along with the - * premultiplied alpha support; this actually hides an undocumented feature - * of the previous implementation which allowed gamma processing to be - * disabled in background handling. There is no evidence (so far) that this - * was being used; however, png_set_background itself accepted and must still - * accept '0' for the gamma value it takes, because it isn't always used. - * - * Since this is an API change (albeit a very minor one that removes an - * undocumented API feature) the following checks were only enabled in - * libpng-1.6.0. - */ - if (file_gamma <= 0) - png_error(png_ptr, "invalid file gamma in png_set_gamma"); - - if (scrn_gamma <= 0) - png_error(png_ptr, "invalid screen gamma in png_set_gamma"); - - /* Set the gamma values unconditionally - this overrides the value in the PNG - * file if a gAMA chunk was present. png_set_alpha_mode provides a - * different, easier, way to default the file gamma. - */ - png_ptr->colorspace.gamma = file_gamma; - png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; - png_ptr->screen_gamma = scrn_gamma; -} - -# ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_gamma(png_structrp png_ptr, double scrn_gamma, double file_gamma) -{ - png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma), - convert_gamma_value(png_ptr, file_gamma)); -} -# endif /* FLOATING_POINT */ -#endif /* READ_GAMMA */ - -#ifdef PNG_READ_EXPAND_SUPPORTED -/* Expand paletted images to RGB, expand grayscale images of - * less than 8-bit depth to 8-bit depth, and expand tRNS chunks - * to alpha channels. - */ -void PNGAPI -png_set_expand(png_structrp png_ptr) -{ - png_debug(1, "in png_set_expand"); - - if (png_rtran_ok(png_ptr, 0) == 0) - return; - - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} - -/* GRR 19990627: the following three functions currently are identical - * to png_set_expand(). However, it is entirely reasonable that someone - * might wish to expand an indexed image to RGB but *not* expand a single, - * fully transparent palette entry to a full alpha channel--perhaps instead - * convert tRNS to the grayscale/RGB format (16-bit RGB value), or replace - * the transparent color with a particular RGB value, or drop tRNS entirely. - * IOW, a future version of the library may make the transformations flag - * a bit more fine-grained, with separate bits for each of these three - * functions. - * - * More to the point, these functions make it obvious what libpng will be - * doing, whereas "expand" can (and does) mean any number of things. - * - * GRP 20060307: In libpng-1.2.9, png_set_gray_1_2_4_to_8() was modified - * to expand only the sample depth but not to expand the tRNS to alpha - * and its name was changed to png_set_expand_gray_1_2_4_to_8(). - */ - -/* Expand paletted images to RGB. */ -void PNGAPI -png_set_palette_to_rgb(png_structrp png_ptr) -{ - png_debug(1, "in png_set_palette_to_rgb"); - - if (png_rtran_ok(png_ptr, 0) == 0) - return; - - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} - -/* Expand grayscale images of less than 8-bit depth to 8 bits. */ -void PNGAPI -png_set_expand_gray_1_2_4_to_8(png_structrp png_ptr) -{ - png_debug(1, "in png_set_expand_gray_1_2_4_to_8"); - - if (png_rtran_ok(png_ptr, 0) == 0) - return; - - png_ptr->transformations |= PNG_EXPAND; -} - -/* Expand tRNS chunks to alpha channels. */ -void PNGAPI -png_set_tRNS_to_alpha(png_structrp png_ptr) -{ - png_debug(1, "in png_set_tRNS_to_alpha"); - - if (png_rtran_ok(png_ptr, 0) == 0) - return; - - png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); -} -#endif /* READ_EXPAND */ - -#ifdef PNG_READ_EXPAND_16_SUPPORTED -/* Expand to 16-bit channels, expand the tRNS chunk too (because otherwise - * it may not work correctly.) - */ -void PNGAPI -png_set_expand_16(png_structrp png_ptr) -{ - png_debug(1, "in png_set_expand_16"); - - if (png_rtran_ok(png_ptr, 0) == 0) - return; - - png_ptr->transformations |= (PNG_EXPAND_16 | PNG_EXPAND | PNG_EXPAND_tRNS); -} -#endif - -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED -void PNGAPI -png_set_gray_to_rgb(png_structrp png_ptr) -{ - png_debug(1, "in png_set_gray_to_rgb"); - - if (png_rtran_ok(png_ptr, 0) == 0) - return; - - /* Because rgb must be 8 bits or more: */ - png_set_expand_gray_1_2_4_to_8(png_ptr); - png_ptr->transformations |= PNG_GRAY_TO_RGB; -} -#endif - -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED -void PNGFAPI -png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, - png_fixed_point red, png_fixed_point green) -{ - png_debug(1, "in png_set_rgb_to_gray"); - - /* Need the IHDR here because of the check on color_type below. */ - /* TODO: fix this */ - if (png_rtran_ok(png_ptr, 1) == 0) - return; - - switch (error_action) - { - case PNG_ERROR_ACTION_NONE: - png_ptr->transformations |= PNG_RGB_TO_GRAY; - break; - - case PNG_ERROR_ACTION_WARN: - png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; - break; - - case PNG_ERROR_ACTION_ERROR: - png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; - break; - - default: - png_error(png_ptr, "invalid error action to rgb_to_gray"); - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) -#ifdef PNG_READ_EXPAND_SUPPORTED - png_ptr->transformations |= PNG_EXPAND; -#else - { - /* Make this an error in 1.6 because otherwise the application may assume - * that it just worked and get a memory overwrite. - */ - png_error(png_ptr, - "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED"); - - /* png_ptr->transformations &= ~PNG_RGB_TO_GRAY; */ - } -#endif - { - if (red >= 0 && green >= 0 && red + green <= PNG_FP_1) - { - png_uint_16 red_int, green_int; - - /* NOTE: this calculation does not round, but this behavior is retained - * for consistency; the inaccuracy is very small. The code here always - * overwrites the coefficients, regardless of whether they have been - * defaulted or set already. - */ - red_int = (png_uint_16)(((png_uint_32)red*32768)/100000); - green_int = (png_uint_16)(((png_uint_32)green*32768)/100000); - - png_ptr->rgb_to_gray_red_coeff = red_int; - png_ptr->rgb_to_gray_green_coeff = green_int; - png_ptr->rgb_to_gray_coefficients_set = 1; - } - - else - { - if (red >= 0 && green >= 0) - png_app_warning(png_ptr, - "ignoring out of range rgb_to_gray coefficients"); - - /* Use the defaults, from the cHRM chunk if set, else the historical - * values which are close to the sRGB/HDTV/ITU-Rec 709 values. See - * png_do_rgb_to_gray for more discussion of the values. In this case - * the coefficients are not marked as 'set' and are not overwritten if - * something has already provided a default. - */ - if (png_ptr->rgb_to_gray_red_coeff == 0 && - png_ptr->rgb_to_gray_green_coeff == 0) - { - png_ptr->rgb_to_gray_red_coeff = 6968; - png_ptr->rgb_to_gray_green_coeff = 23434; - /* png_ptr->rgb_to_gray_blue_coeff = 2366; */ - } - } - } -} - -#ifdef PNG_FLOATING_POINT_SUPPORTED -/* Convert a RGB image to a grayscale of the same width. This allows us, - * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image. - */ - -void PNGAPI -png_set_rgb_to_gray(png_structrp png_ptr, int error_action, double red, - double green) -{ - png_set_rgb_to_gray_fixed(png_ptr, error_action, - png_fixed(png_ptr, red, "rgb to gray red coefficient"), - png_fixed(png_ptr, green, "rgb to gray green coefficient")); -} -#endif /* FLOATING POINT */ - -#endif /* RGB_TO_GRAY */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -void PNGAPI -png_set_read_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr - read_user_transform_fn) -{ - png_debug(1, "in png_set_read_user_transform_fn"); - -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED - png_ptr->transformations |= PNG_USER_TRANSFORM; - png_ptr->read_user_transform_fn = read_user_transform_fn; -#endif -} -#endif - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED -#ifdef PNG_READ_GAMMA_SUPPORTED -/* In the case of gamma transformations only do transformations on images where - * the [file] gamma and screen_gamma are not close reciprocals, otherwise it - * slows things down slightly, and also needlessly introduces small errors. - */ -static int /* PRIVATE */ -png_gamma_threshold(png_fixed_point screen_gamma, png_fixed_point file_gamma) -{ - /* PNG_GAMMA_THRESHOLD is the threshold for performing gamma - * correction as a difference of the overall transform from 1.0 - * - * We want to compare the threshold with s*f - 1, if we get - * overflow here it is because of wacky gamma values so we - * turn on processing anyway. - */ - png_fixed_point gtest; - return !png_muldiv(>est, screen_gamma, file_gamma, PNG_FP_1) || - png_gamma_significant(gtest); -} -#endif - -/* Initialize everything needed for the read. This includes modifying - * the palette. - */ - -/* For the moment 'png_init_palette_transformations' and - * 'png_init_rgb_transformations' only do some flag canceling optimizations. - * The intent is that these two routines should have palette or rgb operations - * extracted from 'png_init_read_transformations'. - */ -static void /* PRIVATE */ -png_init_palette_transformations(png_structrp png_ptr) -{ - /* Called to handle the (input) palette case. In png_do_read_transformations - * the first step is to expand the palette if requested, so this code must - * take care to only make changes that are invariant with respect to the - * palette expansion, or only do them if there is no expansion. - * - * STRIP_ALPHA has already been handled in the caller (by setting num_trans - * to 0.) - */ - int input_has_alpha = 0; - int input_has_transparency = 0; - - if (png_ptr->num_trans > 0) - { - int i; - - /* Ignore if all the entries are opaque (unlikely!) */ - for (i=0; inum_trans; ++i) - { - if (png_ptr->trans_alpha[i] == 255) - continue; - else if (png_ptr->trans_alpha[i] == 0) - input_has_transparency = 1; - else - { - input_has_transparency = 1; - input_has_alpha = 1; - break; - } - } - } - - /* If no alpha we can optimize. */ - if (input_has_alpha == 0) - { - /* Any alpha means background and associative alpha processing is - * required, however if the alpha is 0 or 1 throughout OPTIMIZE_ALPHA - * and ENCODE_ALPHA are irrelevant. - */ - png_ptr->transformations &= ~PNG_ENCODE_ALPHA; - png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; - - if (input_has_transparency == 0) - png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND); - } - -#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) - /* png_set_background handling - deals with the complexity of whether the - * background color is in the file format or the screen format in the case - * where an 'expand' will happen. - */ - - /* The following code cannot be entered in the alpha pre-multiplication case - * because PNG_BACKGROUND_EXPAND is cancelled below. - */ - if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0 && - (png_ptr->transformations & PNG_EXPAND) != 0) - { - { - png_ptr->background.red = - png_ptr->palette[png_ptr->background.index].red; - png_ptr->background.green = - png_ptr->palette[png_ptr->background.index].green; - png_ptr->background.blue = - png_ptr->palette[png_ptr->background.index].blue; - -#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED - if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0) - { - if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0) - { - /* Invert the alpha channel (in tRNS) unless the pixels are - * going to be expanded, in which case leave it for later - */ - int i, istop = png_ptr->num_trans; - - for (i = 0; i < istop; i++) - png_ptr->trans_alpha[i] = - (png_byte)(255 - png_ptr->trans_alpha[i]); - } - } -#endif /* READ_INVERT_ALPHA */ - } - } /* background expand and (therefore) no alpha association. */ -#endif /* READ_EXPAND && READ_BACKGROUND */ -} - -static void /* PRIVATE */ -png_init_rgb_transformations(png_structrp png_ptr) -{ - /* Added to libpng-1.5.4: check the color type to determine whether there - * is any alpha or transparency in the image and simply cancel the - * background and alpha mode stuff if there isn't. - */ - int input_has_alpha = (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0; - int input_has_transparency = png_ptr->num_trans > 0; - - /* If no alpha we can optimize. */ - if (input_has_alpha == 0) - { - /* Any alpha means background and associative alpha processing is - * required, however if the alpha is 0 or 1 throughout OPTIMIZE_ALPHA - * and ENCODE_ALPHA are irrelevant. - */ -# ifdef PNG_READ_ALPHA_MODE_SUPPORTED - png_ptr->transformations &= ~PNG_ENCODE_ALPHA; - png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; -# endif - - if (input_has_transparency == 0) - png_ptr->transformations &= ~(PNG_COMPOSE | PNG_BACKGROUND_EXPAND); - } - -#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) - /* png_set_background handling - deals with the complexity of whether the - * background color is in the file format or the screen format in the case - * where an 'expand' will happen. - */ - - /* The following code cannot be entered in the alpha pre-multiplication case - * because PNG_BACKGROUND_EXPAND is cancelled below. - */ - if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0 && - (png_ptr->transformations & PNG_EXPAND) != 0 && - (png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) - /* i.e., GRAY or GRAY_ALPHA */ - { - { - /* Expand background and tRNS chunks */ - int gray = png_ptr->background.gray; - int trans_gray = png_ptr->trans_color.gray; - - switch (png_ptr->bit_depth) - { - case 1: - gray *= 0xff; - trans_gray *= 0xff; - break; - - case 2: - gray *= 0x55; - trans_gray *= 0x55; - break; - - case 4: - gray *= 0x11; - trans_gray *= 0x11; - break; - - default: - - case 8: - /* FALLTHROUGH */ /* (Already 8 bits) */ - - case 16: - /* Already a full 16 bits */ - break; - } - - png_ptr->background.red = png_ptr->background.green = - png_ptr->background.blue = (png_uint_16)gray; - - if ((png_ptr->transformations & PNG_EXPAND_tRNS) == 0) - { - png_ptr->trans_color.red = png_ptr->trans_color.green = - png_ptr->trans_color.blue = (png_uint_16)trans_gray; - } - } - } /* background expand and (therefore) no alpha association. */ -#endif /* READ_EXPAND && READ_BACKGROUND */ -} - -void /* PRIVATE */ -png_init_read_transformations(png_structrp png_ptr) -{ - png_debug(1, "in png_init_read_transformations"); - - /* This internal function is called from png_read_start_row in pngrutil.c - * and it is called before the 'rowbytes' calculation is done, so the code - * in here can change or update the transformations flags. - * - * First do updates that do not depend on the details of the PNG image data - * being processed. - */ - -#ifdef PNG_READ_GAMMA_SUPPORTED - /* Prior to 1.5.4 these tests were performed from png_set_gamma, 1.5.4 adds - * png_set_alpha_mode and this is another source for a default file gamma so - * the test needs to be performed later - here. In addition prior to 1.5.4 - * the tests were repeated for the PALETTE color type here - this is no - * longer necessary (and doesn't seem to have been necessary before.) - */ - { - /* The following temporary indicates if overall gamma correction is - * required. - */ - int gamma_correction = 0; - - if (png_ptr->colorspace.gamma != 0) /* has been set */ - { - if (png_ptr->screen_gamma != 0) /* screen set too */ - gamma_correction = png_gamma_threshold(png_ptr->colorspace.gamma, - png_ptr->screen_gamma); - - else - /* Assume the output matches the input; a long time default behavior - * of libpng, although the standard has nothing to say about this. - */ - png_ptr->screen_gamma = png_reciprocal(png_ptr->colorspace.gamma); - } - - else if (png_ptr->screen_gamma != 0) - /* The converse - assume the file matches the screen, note that this - * perhaps undesirable default can (from 1.5.4) be changed by calling - * png_set_alpha_mode (even if the alpha handling mode isn't required - * or isn't changed from the default.) - */ - png_ptr->colorspace.gamma = png_reciprocal(png_ptr->screen_gamma); - - else /* neither are set */ - /* Just in case the following prevents any processing - file and screen - * are both assumed to be linear and there is no way to introduce a - * third gamma value other than png_set_background with 'UNIQUE', and, - * prior to 1.5.4 - */ - png_ptr->screen_gamma = png_ptr->colorspace.gamma = PNG_FP_1; - - /* We have a gamma value now. */ - png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA; - - /* Now turn the gamma transformation on or off as appropriate. Notice - * that PNG_GAMMA just refers to the file->screen correction. Alpha - * composition may independently cause gamma correction because it needs - * linear data (e.g. if the file has a gAMA chunk but the screen gamma - * hasn't been specified.) In any case this flag may get turned off in - * the code immediately below if the transform can be handled outside the - * row loop. - */ - if (gamma_correction != 0) - png_ptr->transformations |= PNG_GAMMA; - - else - png_ptr->transformations &= ~PNG_GAMMA; - } -#endif - - /* Certain transformations have the effect of preventing other - * transformations that happen afterward in png_do_read_transformations; - * resolve the interdependencies here. From the code of - * png_do_read_transformations the order is: - * - * 1) PNG_EXPAND (including PNG_EXPAND_tRNS) - * 2) PNG_STRIP_ALPHA (if no compose) - * 3) PNG_RGB_TO_GRAY - * 4) PNG_GRAY_TO_RGB iff !PNG_BACKGROUND_IS_GRAY - * 5) PNG_COMPOSE - * 6) PNG_GAMMA - * 7) PNG_STRIP_ALPHA (if compose) - * 8) PNG_ENCODE_ALPHA - * 9) PNG_SCALE_16_TO_8 - * 10) PNG_16_TO_8 - * 11) PNG_QUANTIZE (converts to palette) - * 12) PNG_EXPAND_16 - * 13) PNG_GRAY_TO_RGB iff PNG_BACKGROUND_IS_GRAY - * 14) PNG_INVERT_MONO - * 15) PNG_INVERT_ALPHA - * 16) PNG_SHIFT - * 17) PNG_PACK - * 18) PNG_BGR - * 19) PNG_PACKSWAP - * 20) PNG_FILLER (includes PNG_ADD_ALPHA) - * 21) PNG_SWAP_ALPHA - * 22) PNG_SWAP_BYTES - * 23) PNG_USER_TRANSFORM [must be last] - */ -#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED - if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 && - (png_ptr->transformations & PNG_COMPOSE) == 0) - { - /* Stripping the alpha channel happens immediately after the 'expand' - * transformations, before all other transformation, so it cancels out - * the alpha handling. It has the side effect negating the effect of - * PNG_EXPAND_tRNS too: - */ - png_ptr->transformations &= ~(PNG_BACKGROUND_EXPAND | PNG_ENCODE_ALPHA | - PNG_EXPAND_tRNS); - png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; - - /* Kill the tRNS chunk itself too. Prior to 1.5.4 this did not happen - * so transparency information would remain just so long as it wasn't - * expanded. This produces unexpected API changes if the set of things - * that do PNG_EXPAND_tRNS changes (perfectly possible given the - * documentation - which says ask for what you want, accept what you - * get.) This makes the behavior consistent from 1.5.4: - */ - png_ptr->num_trans = 0; - } -#endif /* STRIP_ALPHA supported, no COMPOSE */ - -#ifdef PNG_READ_ALPHA_MODE_SUPPORTED - /* If the screen gamma is about 1.0 then the OPTIMIZE_ALPHA and ENCODE_ALPHA - * settings will have no effect. - */ - if (png_gamma_significant(png_ptr->screen_gamma) == 0) - { - png_ptr->transformations &= ~PNG_ENCODE_ALPHA; - png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA; - } -#endif - -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED - /* Make sure the coefficients for the rgb to gray conversion are set - * appropriately. - */ - if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0) - png_colorspace_set_rgb_coefficients(png_ptr); -#endif - -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED -#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED) - /* Detect gray background and attempt to enable optimization for - * gray --> RGB case. - * - * Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or - * RGB_ALPHA (in which case need_expand is superfluous anyway), the - * background color might actually be gray yet not be flagged as such. - * This is not a problem for the current code, which uses - * PNG_BACKGROUND_IS_GRAY only to decide when to do the - * png_do_gray_to_rgb() transformation. - * - * TODO: this code needs to be revised to avoid the complexity and - * interdependencies. The color type of the background should be recorded in - * png_set_background, along with the bit depth, then the code has a record - * of exactly what color space the background is currently in. - */ - if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) != 0) - { - /* PNG_BACKGROUND_EXPAND: the background is in the file color space, so if - * the file was grayscale the background value is gray. - */ - if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) - png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; - } - - else if ((png_ptr->transformations & PNG_COMPOSE) != 0) - { - /* PNG_COMPOSE: png_set_background was called with need_expand false, - * so the color is in the color space of the output or png_set_alpha_mode - * was called and the color is black. Ignore RGB_TO_GRAY because that - * happens before GRAY_TO_RGB. - */ - if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0) - { - if (png_ptr->background.red == png_ptr->background.green && - png_ptr->background.red == png_ptr->background.blue) - { - png_ptr->mode |= PNG_BACKGROUND_IS_GRAY; - png_ptr->background.gray = png_ptr->background.red; - } - } - } -#endif /* READ_EXPAND && READ_BACKGROUND */ -#endif /* READ_GRAY_TO_RGB */ - - /* For indexed PNG data (PNG_COLOR_TYPE_PALETTE) many of the transformations - * can be performed directly on the palette, and some (such as rgb to gray) - * can be optimized inside the palette. This is particularly true of the - * composite (background and alpha) stuff, which can be pretty much all done - * in the palette even if the result is expanded to RGB or gray afterward. - * - * NOTE: this is Not Yet Implemented, the code behaves as in 1.5.1 and - * earlier and the palette stuff is actually handled on the first row. This - * leads to the reported bug that the palette returned by png_get_PLTE is not - * updated. - */ - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - png_init_palette_transformations(png_ptr); - - else - png_init_rgb_transformations(png_ptr); - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - defined(PNG_READ_EXPAND_16_SUPPORTED) - if ((png_ptr->transformations & PNG_EXPAND_16) != 0 && - (png_ptr->transformations & PNG_COMPOSE) != 0 && - (png_ptr->transformations & PNG_BACKGROUND_EXPAND) == 0 && - png_ptr->bit_depth != 16) - { - /* TODO: fix this. Because the expand_16 operation is after the compose - * handling the background color must be 8, not 16, bits deep, but the - * application will supply a 16-bit value so reduce it here. - * - * The PNG_BACKGROUND_EXPAND code above does not expand to 16 bits at - * present, so that case is ok (until do_expand_16 is moved.) - * - * NOTE: this discards the low 16 bits of the user supplied background - * color, but until expand_16 works properly there is no choice! - */ -# define CHOP(x) (x)=((png_uint_16)PNG_DIV257(x)) - CHOP(png_ptr->background.red); - CHOP(png_ptr->background.green); - CHOP(png_ptr->background.blue); - CHOP(png_ptr->background.gray); -# undef CHOP - } -#endif /* READ_BACKGROUND && READ_EXPAND_16 */ - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ - (defined(PNG_READ_SCALE_16_TO_8_SUPPORTED) || \ - defined(PNG_READ_STRIP_16_TO_8_SUPPORTED)) - if ((png_ptr->transformations & (PNG_16_TO_8|PNG_SCALE_16_TO_8)) != 0 && - (png_ptr->transformations & PNG_COMPOSE) != 0 && - (png_ptr->transformations & PNG_BACKGROUND_EXPAND) == 0 && - png_ptr->bit_depth == 16) - { - /* On the other hand, if a 16-bit file is to be reduced to 8-bits per - * component this will also happen after PNG_COMPOSE and so the background - * color must be pre-expanded here. - * - * TODO: fix this too. - */ - png_ptr->background.red = (png_uint_16)(png_ptr->background.red * 257); - png_ptr->background.green = - (png_uint_16)(png_ptr->background.green * 257); - png_ptr->background.blue = (png_uint_16)(png_ptr->background.blue * 257); - png_ptr->background.gray = (png_uint_16)(png_ptr->background.gray * 257); - } -#endif - - /* NOTE: below 'PNG_READ_ALPHA_MODE_SUPPORTED' is presumed to also enable the - * background support (see the comments in scripts/pnglibconf.dfa), this - * allows pre-multiplication of the alpha channel to be implemented as - * compositing on black. This is probably sub-optimal and has been done in - * 1.5.4 betas simply to enable external critique and testing (i.e. to - * implement the new API quickly, without lots of internal changes.) - */ - -#ifdef PNG_READ_GAMMA_SUPPORTED -# ifdef PNG_READ_BACKGROUND_SUPPORTED - /* Includes ALPHA_MODE */ - png_ptr->background_1 = png_ptr->background; -# endif - - /* This needs to change - in the palette image case a whole set of tables are - * built when it would be quicker to just calculate the correct value for - * each palette entry directly. Also, the test is too tricky - why check - * PNG_RGB_TO_GRAY if PNG_GAMMA is not set? The answer seems to be that - * PNG_GAMMA is cancelled even if the gamma is known? The test excludes the - * PNG_COMPOSE case, so apparently if there is no *overall* gamma correction - * the gamma tables will not be built even if composition is required on a - * gamma encoded value. - * - * In 1.5.4 this is addressed below by an additional check on the individual - * file gamma - if it is not 1.0 both RGB_TO_GRAY and COMPOSE need the - * tables. - */ - if ((png_ptr->transformations & PNG_GAMMA) != 0 || - ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0 && - (png_gamma_significant(png_ptr->colorspace.gamma) != 0 || - png_gamma_significant(png_ptr->screen_gamma) != 0)) || - ((png_ptr->transformations & PNG_COMPOSE) != 0 && - (png_gamma_significant(png_ptr->colorspace.gamma) != 0 || - png_gamma_significant(png_ptr->screen_gamma) != 0 -# ifdef PNG_READ_BACKGROUND_SUPPORTED - || (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE && - png_gamma_significant(png_ptr->background_gamma) != 0) -# endif - )) || ((png_ptr->transformations & PNG_ENCODE_ALPHA) != 0 && - png_gamma_significant(png_ptr->screen_gamma) != 0)) - { - png_build_gamma_table(png_ptr, png_ptr->bit_depth); - -#ifdef PNG_READ_BACKGROUND_SUPPORTED - if ((png_ptr->transformations & PNG_COMPOSE) != 0) - { - /* Issue a warning about this combination: because RGB_TO_GRAY is - * optimized to do the gamma transform if present yet do_background has - * to do the same thing if both options are set a - * double-gamma-correction happens. This is true in all versions of - * libpng to date. - */ - if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0) - png_warning(png_ptr, - "libpng does not support gamma+background+rgb_to_gray"); - - if ((png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) != 0) - { - /* We don't get to here unless there is a tRNS chunk with non-opaque - * entries - see the checking code at the start of this function. - */ - png_color back, back_1; - png_colorp palette = png_ptr->palette; - int num_palette = png_ptr->num_palette; - int i; - if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE) - { - - back.red = png_ptr->gamma_table[png_ptr->background.red]; - back.green = png_ptr->gamma_table[png_ptr->background.green]; - back.blue = png_ptr->gamma_table[png_ptr->background.blue]; - - back_1.red = png_ptr->gamma_to_1[png_ptr->background.red]; - back_1.green = png_ptr->gamma_to_1[png_ptr->background.green]; - back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue]; - } - else - { - png_fixed_point g, gs; - - switch (png_ptr->background_gamma_type) - { - case PNG_BACKGROUND_GAMMA_SCREEN: - g = (png_ptr->screen_gamma); - gs = PNG_FP_1; - break; - - case PNG_BACKGROUND_GAMMA_FILE: - g = png_reciprocal(png_ptr->colorspace.gamma); - gs = png_reciprocal2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma); - break; - - case PNG_BACKGROUND_GAMMA_UNIQUE: - g = png_reciprocal(png_ptr->background_gamma); - gs = png_reciprocal2(png_ptr->background_gamma, - png_ptr->screen_gamma); - break; - default: - g = PNG_FP_1; /* back_1 */ - gs = PNG_FP_1; /* back */ - break; - } - - if (png_gamma_significant(gs) != 0) - { - back.red = png_gamma_8bit_correct(png_ptr->background.red, - gs); - back.green = png_gamma_8bit_correct(png_ptr->background.green, - gs); - back.blue = png_gamma_8bit_correct(png_ptr->background.blue, - gs); - } - - else - { - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - } - - if (png_gamma_significant(g) != 0) - { - back_1.red = png_gamma_8bit_correct(png_ptr->background.red, - g); - back_1.green = png_gamma_8bit_correct( - png_ptr->background.green, g); - back_1.blue = png_gamma_8bit_correct(png_ptr->background.blue, - g); - } - - else - { - back_1.red = (png_byte)png_ptr->background.red; - back_1.green = (png_byte)png_ptr->background.green; - back_1.blue = (png_byte)png_ptr->background.blue; - } - } - - for (i = 0; i < num_palette; i++) - { - if (i < (int)png_ptr->num_trans && - png_ptr->trans_alpha[i] != 0xff) - { - if (png_ptr->trans_alpha[i] == 0) - { - palette[i] = back; - } - else /* if (png_ptr->trans_alpha[i] != 0xff) */ - { - png_byte v, w; - - v = png_ptr->gamma_to_1[palette[i].red]; - png_composite(w, v, png_ptr->trans_alpha[i], back_1.red); - palette[i].red = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[palette[i].green]; - png_composite(w, v, png_ptr->trans_alpha[i], back_1.green); - palette[i].green = png_ptr->gamma_from_1[w]; - - v = png_ptr->gamma_to_1[palette[i].blue]; - png_composite(w, v, png_ptr->trans_alpha[i], back_1.blue); - palette[i].blue = png_ptr->gamma_from_1[w]; - } - } - else - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - } - - /* Prevent the transformations being done again. - * - * NOTE: this is highly dubious; it removes the transformations in - * place. This seems inconsistent with the general treatment of the - * transformations elsewhere. - */ - png_ptr->transformations &= ~(PNG_COMPOSE | PNG_GAMMA); - } /* color_type == PNG_COLOR_TYPE_PALETTE */ - - /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */ - else /* color_type != PNG_COLOR_TYPE_PALETTE */ - { - int gs_sig, g_sig; - png_fixed_point g = PNG_FP_1; /* Correction to linear */ - png_fixed_point gs = PNG_FP_1; /* Correction to screen */ - - switch (png_ptr->background_gamma_type) - { - case PNG_BACKGROUND_GAMMA_SCREEN: - g = png_ptr->screen_gamma; - /* gs = PNG_FP_1; */ - break; - - case PNG_BACKGROUND_GAMMA_FILE: - g = png_reciprocal(png_ptr->colorspace.gamma); - gs = png_reciprocal2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma); - break; - - case PNG_BACKGROUND_GAMMA_UNIQUE: - g = png_reciprocal(png_ptr->background_gamma); - gs = png_reciprocal2(png_ptr->background_gamma, - png_ptr->screen_gamma); - break; - - default: - png_error(png_ptr, "invalid background gamma type"); - } - - g_sig = png_gamma_significant(g); - gs_sig = png_gamma_significant(gs); - - if (g_sig != 0) - png_ptr->background_1.gray = png_gamma_correct(png_ptr, - png_ptr->background.gray, g); - - if (gs_sig != 0) - png_ptr->background.gray = png_gamma_correct(png_ptr, - png_ptr->background.gray, gs); - - if ((png_ptr->background.red != png_ptr->background.green) || - (png_ptr->background.red != png_ptr->background.blue) || - (png_ptr->background.red != png_ptr->background.gray)) - { - /* RGB or RGBA with color background */ - if (g_sig != 0) - { - png_ptr->background_1.red = png_gamma_correct(png_ptr, - png_ptr->background.red, g); - - png_ptr->background_1.green = png_gamma_correct(png_ptr, - png_ptr->background.green, g); - - png_ptr->background_1.blue = png_gamma_correct(png_ptr, - png_ptr->background.blue, g); - } - - if (gs_sig != 0) - { - png_ptr->background.red = png_gamma_correct(png_ptr, - png_ptr->background.red, gs); - - png_ptr->background.green = png_gamma_correct(png_ptr, - png_ptr->background.green, gs); - - png_ptr->background.blue = png_gamma_correct(png_ptr, - png_ptr->background.blue, gs); - } - } - - else - { - /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */ - png_ptr->background_1.red = png_ptr->background_1.green - = png_ptr->background_1.blue = png_ptr->background_1.gray; - - png_ptr->background.red = png_ptr->background.green - = png_ptr->background.blue = png_ptr->background.gray; - } - - /* The background is now in screen gamma: */ - png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_SCREEN; - } /* color_type != PNG_COLOR_TYPE_PALETTE */ - }/* png_ptr->transformations & PNG_BACKGROUND */ - - else - /* Transformation does not include PNG_BACKGROUND */ -#endif /* READ_BACKGROUND */ - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED - /* RGB_TO_GRAY needs to have non-gamma-corrected values! */ - && ((png_ptr->transformations & PNG_EXPAND) == 0 || - (png_ptr->transformations & PNG_RGB_TO_GRAY) == 0) -#endif - ) - { - png_colorp palette = png_ptr->palette; - int num_palette = png_ptr->num_palette; - int i; - - /* NOTE: there are other transformations that should probably be in - * here too. - */ - for (i = 0; i < num_palette; i++) - { - palette[i].red = png_ptr->gamma_table[palette[i].red]; - palette[i].green = png_ptr->gamma_table[palette[i].green]; - palette[i].blue = png_ptr->gamma_table[palette[i].blue]; - } - - /* Done the gamma correction. */ - png_ptr->transformations &= ~PNG_GAMMA; - } /* color_type == PALETTE && !PNG_BACKGROUND transformation */ - } -#ifdef PNG_READ_BACKGROUND_SUPPORTED - else -#endif -#endif /* READ_GAMMA */ - -#ifdef PNG_READ_BACKGROUND_SUPPORTED - /* No GAMMA transformation (see the hanging else 4 lines above) */ - if ((png_ptr->transformations & PNG_COMPOSE) != 0 && - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) - { - int i; - int istop = (int)png_ptr->num_trans; - png_color back; - png_colorp palette = png_ptr->palette; - - back.red = (png_byte)png_ptr->background.red; - back.green = (png_byte)png_ptr->background.green; - back.blue = (png_byte)png_ptr->background.blue; - - for (i = 0; i < istop; i++) - { - if (png_ptr->trans_alpha[i] == 0) - { - palette[i] = back; - } - - else if (png_ptr->trans_alpha[i] != 0xff) - { - /* The png_composite() macro is defined in png.h */ - png_composite(palette[i].red, palette[i].red, - png_ptr->trans_alpha[i], back.red); - - png_composite(palette[i].green, palette[i].green, - png_ptr->trans_alpha[i], back.green); - - png_composite(palette[i].blue, palette[i].blue, - png_ptr->trans_alpha[i], back.blue); - } - } - - png_ptr->transformations &= ~PNG_COMPOSE; - } -#endif /* READ_BACKGROUND */ - -#ifdef PNG_READ_SHIFT_SUPPORTED - if ((png_ptr->transformations & PNG_SHIFT) != 0 && - (png_ptr->transformations & PNG_EXPAND) == 0 && - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) - { - int i; - int istop = png_ptr->num_palette; - int shift = 8 - png_ptr->sig_bit.red; - - png_ptr->transformations &= ~PNG_SHIFT; - - /* significant bits can be in the range 1 to 7 for a meaningful result, if - * the number of significant bits is 0 then no shift is done (this is an - * error condition which is silently ignored.) - */ - if (shift > 0 && shift < 8) - for (i=0; ipalette[i].red; - - component >>= shift; - png_ptr->palette[i].red = (png_byte)component; - } - - shift = 8 - png_ptr->sig_bit.green; - if (shift > 0 && shift < 8) - for (i=0; ipalette[i].green; - - component >>= shift; - png_ptr->palette[i].green = (png_byte)component; - } - - shift = 8 - png_ptr->sig_bit.blue; - if (shift > 0 && shift < 8) - for (i=0; ipalette[i].blue; - - component >>= shift; - png_ptr->palette[i].blue = (png_byte)component; - } - } -#endif /* READ_SHIFT */ -} - -/* Modify the info structure to reflect the transformations. The - * info should be updated so a PNG file could be written with it, - * assuming the transformations result in valid PNG data. - */ -void /* PRIVATE */ -png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr) -{ - png_debug(1, "in png_read_transform_info"); - -#ifdef PNG_READ_EXPAND_SUPPORTED - if ((png_ptr->transformations & PNG_EXPAND) != 0) - { - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - /* This check must match what actually happens in - * png_do_expand_palette; if it ever checks the tRNS chunk to see if - * it is all opaque we must do the same (at present it does not.) - */ - if (png_ptr->num_trans > 0) - info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA; - - else - info_ptr->color_type = PNG_COLOR_TYPE_RGB; - - info_ptr->bit_depth = 8; - info_ptr->num_trans = 0; - - if (png_ptr->palette == NULL) - png_error (png_ptr, "Palette is NULL in indexed image"); - } - else - { - if (png_ptr->num_trans != 0) - { - if ((png_ptr->transformations & PNG_EXPAND_tRNS) != 0) - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; - } - if (info_ptr->bit_depth < 8) - info_ptr->bit_depth = 8; - - info_ptr->num_trans = 0; - } - } -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) - /* The following is almost certainly wrong unless the background value is in - * the screen space! - */ - if ((png_ptr->transformations & PNG_COMPOSE) != 0) - info_ptr->background = png_ptr->background; -#endif - -#ifdef PNG_READ_GAMMA_SUPPORTED - /* The following used to be conditional on PNG_GAMMA (prior to 1.5.4), - * however it seems that the code in png_init_read_transformations, which has - * been called before this from png_read_update_info->png_read_start_row - * sometimes does the gamma transform and cancels the flag. - * - * TODO: this looks wrong; the info_ptr should end up with a gamma equal to - * the screen_gamma value. The following probably results in weirdness if - * the info_ptr is used by the app after the rows have been read. - */ - info_ptr->colorspace.gamma = png_ptr->colorspace.gamma; -#endif - - if (info_ptr->bit_depth == 16) - { -# ifdef PNG_READ_16BIT_SUPPORTED -# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED - if ((png_ptr->transformations & PNG_SCALE_16_TO_8) != 0) - info_ptr->bit_depth = 8; -# endif - -# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED - if ((png_ptr->transformations & PNG_16_TO_8) != 0) - info_ptr->bit_depth = 8; -# endif - -# else - /* No 16-bit support: force chopping 16-bit input down to 8, in this case - * the app program can chose if both APIs are available by setting the - * correct scaling to use. - */ -# ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED - /* For compatibility with previous versions use the strip method by - * default. This code works because if PNG_SCALE_16_TO_8 is already - * set the code below will do that in preference to the chop. - */ - png_ptr->transformations |= PNG_16_TO_8; - info_ptr->bit_depth = 8; -# else - -# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED - png_ptr->transformations |= PNG_SCALE_16_TO_8; - info_ptr->bit_depth = 8; -# else - - CONFIGURATION ERROR: you must enable at least one 16 to 8 method -# endif -# endif -#endif /* !READ_16BIT */ - } - -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED - if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0) - info_ptr->color_type = (png_byte)(info_ptr->color_type | - PNG_COLOR_MASK_COLOR); -#endif - -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED - if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0) - info_ptr->color_type = (png_byte)(info_ptr->color_type & - ~PNG_COLOR_MASK_COLOR); -#endif - -#ifdef PNG_READ_QUANTIZE_SUPPORTED - if ((png_ptr->transformations & PNG_QUANTIZE) != 0) - { - if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || - (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && - png_ptr->palette_lookup != 0 && info_ptr->bit_depth == 8) - { - info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; - } - } -#endif - -#ifdef PNG_READ_EXPAND_16_SUPPORTED - if ((png_ptr->transformations & PNG_EXPAND_16) != 0 && - info_ptr->bit_depth == 8 && - info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) - { - info_ptr->bit_depth = 16; - } -#endif - -#ifdef PNG_READ_PACK_SUPPORTED - if ((png_ptr->transformations & PNG_PACK) != 0 && - (info_ptr->bit_depth < 8)) - info_ptr->bit_depth = 8; -#endif - - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - info_ptr->channels = 1; - - else if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) - info_ptr->channels = 3; - - else - info_ptr->channels = 1; - -#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED - if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0) - { - info_ptr->color_type = (png_byte)(info_ptr->color_type & - ~PNG_COLOR_MASK_ALPHA); - info_ptr->num_trans = 0; - } -#endif - - if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0) - info_ptr->channels++; - -#ifdef PNG_READ_FILLER_SUPPORTED - /* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */ - if ((png_ptr->transformations & PNG_FILLER) != 0 && - (info_ptr->color_type == PNG_COLOR_TYPE_RGB || - info_ptr->color_type == PNG_COLOR_TYPE_GRAY)) - { - info_ptr->channels++; - /* If adding a true alpha channel not just filler */ - if ((png_ptr->transformations & PNG_ADD_ALPHA) != 0) - info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; - } -#endif - -#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \ -defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0) - { - if (png_ptr->user_transform_depth != 0) - info_ptr->bit_depth = png_ptr->user_transform_depth; - - if (png_ptr->user_transform_channels != 0) - info_ptr->channels = png_ptr->user_transform_channels; - } -#endif - - info_ptr->pixel_depth = (png_byte)(info_ptr->channels * - info_ptr->bit_depth); - - info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width); - - /* Adding in 1.5.4: cache the above value in png_struct so that we can later - * check in png_rowbytes that the user buffer won't get overwritten. Note - * that the field is not always set - if png_read_update_info isn't called - * the application has to either not do any transforms or get the calculation - * right itself. - */ - png_ptr->info_rowbytes = info_ptr->rowbytes; - -#ifndef PNG_READ_EXPAND_SUPPORTED - if (png_ptr != NULL) - return; -#endif -} - -#ifdef PNG_READ_PACK_SUPPORTED -/* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel, - * without changing the actual values. Thus, if you had a row with - * a bit depth of 1, you would end up with bytes that only contained - * the numbers 0 or 1. If you would rather they contain 0 and 255, use - * png_do_shift() after this. - */ -static void -png_do_unpack(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_unpack"); - - if (row_info->bit_depth < 8) - { - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - switch (row_info->bit_depth) - { - case 1: - { - png_bytep sp = row + (size_t)((row_width - 1) >> 3); - png_bytep dp = row + (size_t)row_width - 1; - png_uint_32 shift = 7U - ((row_width + 7U) & 0x07); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x01); - - if (shift == 7) - { - shift = 0; - sp--; - } - - else - shift++; - - dp--; - } - break; - } - - case 2: - { - - png_bytep sp = row + (size_t)((row_width - 1) >> 2); - png_bytep dp = row + (size_t)row_width - 1; - png_uint_32 shift = ((3U - ((row_width + 3U) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x03); - - if (shift == 6) - { - shift = 0; - sp--; - } - - else - shift += 2; - - dp--; - } - break; - } - - case 4: - { - png_bytep sp = row + (size_t)((row_width - 1) >> 1); - png_bytep dp = row + (size_t)row_width - 1; - png_uint_32 shift = ((1U - ((row_width + 1U) & 0x01)) << 2); - for (i = 0; i < row_width; i++) - { - *dp = (png_byte)((*sp >> shift) & 0x0f); - - if (shift == 4) - { - shift = 0; - sp--; - } - - else - shift = 4; - - dp--; - } - break; - } - - default: - break; - } - row_info->bit_depth = 8; - row_info->pixel_depth = (png_byte)(8 * row_info->channels); - row_info->rowbytes = row_width * row_info->channels; - } -} -#endif - -#ifdef PNG_READ_SHIFT_SUPPORTED -/* Reverse the effects of png_do_shift. This routine merely shifts the - * pixels back to their significant bits values. Thus, if you have - * a row of bit depth 8, but only 5 are significant, this will shift - * the values back to 0 through 31. - */ -static void -png_do_unshift(png_row_infop row_info, png_bytep row, - png_const_color_8p sig_bits) -{ - int color_type; - - png_debug(1, "in png_do_unshift"); - - /* The palette case has already been handled in the _init routine. */ - color_type = row_info->color_type; - - if (color_type != PNG_COLOR_TYPE_PALETTE) - { - int shift[4]; - int channels = 0; - int bit_depth = row_info->bit_depth; - - if ((color_type & PNG_COLOR_MASK_COLOR) != 0) - { - shift[channels++] = bit_depth - sig_bits->red; - shift[channels++] = bit_depth - sig_bits->green; - shift[channels++] = bit_depth - sig_bits->blue; - } - - else - { - shift[channels++] = bit_depth - sig_bits->gray; - } - - if ((color_type & PNG_COLOR_MASK_ALPHA) != 0) - { - shift[channels++] = bit_depth - sig_bits->alpha; - } - - { - int c, have_shift; - - for (c = have_shift = 0; c < channels; ++c) - { - /* A shift of more than the bit depth is an error condition but it - * gets ignored here. - */ - if (shift[c] <= 0 || shift[c] >= bit_depth) - shift[c] = 0; - - else - have_shift = 1; - } - - if (have_shift == 0) - return; - } - - switch (bit_depth) - { - default: - /* Must be 1bpp gray: should not be here! */ - /* NOTREACHED */ - break; - - case 2: - /* Must be 2bpp gray */ - /* assert(channels == 1 && shift[0] == 1) */ - { - png_bytep bp = row; - png_bytep bp_end = bp + row_info->rowbytes; - - while (bp < bp_end) - { - int b = (*bp >> 1) & 0x55; - *bp++ = (png_byte)b; - } - break; - } - - case 4: - /* Must be 4bpp gray */ - /* assert(channels == 1) */ - { - png_bytep bp = row; - png_bytep bp_end = bp + row_info->rowbytes; - int gray_shift = shift[0]; - int mask = 0xf >> gray_shift; - - mask |= mask << 4; - - while (bp < bp_end) - { - int b = (*bp >> gray_shift) & mask; - *bp++ = (png_byte)b; - } - break; - } - - case 8: - /* Single byte components, G, GA, RGB, RGBA */ - { - png_bytep bp = row; - png_bytep bp_end = bp + row_info->rowbytes; - int channel = 0; - - while (bp < bp_end) - { - int b = *bp >> shift[channel]; - if (++channel >= channels) - channel = 0; - *bp++ = (png_byte)b; - } - break; - } - -#ifdef PNG_READ_16BIT_SUPPORTED - case 16: - /* Double byte components, G, GA, RGB, RGBA */ - { - png_bytep bp = row; - png_bytep bp_end = bp + row_info->rowbytes; - int channel = 0; - - while (bp < bp_end) - { - int value = (bp[0] << 8) + bp[1]; - - value >>= shift[channel]; - if (++channel >= channels) - channel = 0; - *bp++ = (png_byte)(value >> 8); - *bp++ = (png_byte)value; - } - break; - } -#endif - } - } -} -#endif - -#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED -/* Scale rows of bit depth 16 down to 8 accurately */ -static void -png_do_scale_16_to_8(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_scale_16_to_8"); - - if (row_info->bit_depth == 16) - { - png_bytep sp = row; /* source */ - png_bytep dp = row; /* destination */ - png_bytep ep = sp + row_info->rowbytes; /* end+1 */ - - while (sp < ep) - { - /* The input is an array of 16-bit components, these must be scaled to - * 8 bits each. For a 16-bit value V the required value (from the PNG - * specification) is: - * - * (V * 255) / 65535 - * - * This reduces to round(V / 257), or floor((V + 128.5)/257) - * - * Represent V as the two byte value vhi.vlo. Make a guess that the - * result is the top byte of V, vhi, then the correction to this value - * is: - * - * error = floor(((V-vhi.vhi) + 128.5) / 257) - * = floor(((vlo-vhi) + 128.5) / 257) - * - * This can be approximated using integer arithmetic (and a signed - * shift): - * - * error = (vlo-vhi+128) >> 8; - * - * The approximate differs from the exact answer only when (vlo-vhi) is - * 128; it then gives a correction of +1 when the exact correction is - * 0. This gives 128 errors. The exact answer (correct for all 16-bit - * input values) is: - * - * error = (vlo-vhi+128)*65535 >> 24; - * - * An alternative arithmetic calculation which also gives no errors is: - * - * (V * 255 + 32895) >> 16 - */ - - png_int_32 tmp = *sp++; /* must be signed! */ - tmp += (((int)*sp++ - tmp + 128) * 65535) >> 24; - *dp++ = (png_byte)tmp; - } - - row_info->bit_depth = 8; - row_info->pixel_depth = (png_byte)(8 * row_info->channels); - row_info->rowbytes = row_info->width * row_info->channels; - } -} -#endif - -#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED -static void -/* Simply discard the low byte. This was the default behavior prior - * to libpng-1.5.4. - */ -png_do_chop(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_chop"); - - if (row_info->bit_depth == 16) - { - png_bytep sp = row; /* source */ - png_bytep dp = row; /* destination */ - png_bytep ep = sp + row_info->rowbytes; /* end+1 */ - - while (sp < ep) - { - *dp++ = *sp; - sp += 2; /* skip low byte */ - } - - row_info->bit_depth = 8; - row_info->pixel_depth = (png_byte)(8 * row_info->channels); - row_info->rowbytes = row_info->width * row_info->channels; - } -} -#endif - -#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED -static void -png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) -{ - png_uint_32 row_width = row_info->width; - - png_debug(1, "in png_do_read_swap_alpha"); - - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - /* This converts from RGBA to ARGB */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save; - } - } - -#ifdef PNG_READ_16BIT_SUPPORTED - /* This converts from RRGGBBAA to AARRGGBB */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save[2]; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save[0] = *(--sp); - save[1] = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save[0]; - *(--dp) = save[1]; - } - } -#endif - } - - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - /* This converts from GA to AG */ - if (row_info->bit_depth == 8) - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save; - } - } - -#ifdef PNG_READ_16BIT_SUPPORTED - /* This converts from GGAA to AAGG */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_byte save[2]; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - save[0] = *(--sp); - save[1] = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = save[0]; - *(--dp) = save[1]; - } - } -#endif - } -} -#endif - -#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED -static void -png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) -{ - png_uint_32 row_width; - png_debug(1, "in png_do_read_invert_alpha"); - - row_width = row_info->width; - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - if (row_info->bit_depth == 8) - { - /* This inverts the alpha channel in RGBA */ - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - -/* This does nothing: - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - We can replace it with: -*/ - sp-=3; - dp=sp; - } - } - -#ifdef PNG_READ_16BIT_SUPPORTED - /* This inverts the alpha channel in RRGGBBAA */ - else - { - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = (png_byte)(255 - *(--sp)); - -/* This does nothing: - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - We can replace it with: -*/ - sp-=6; - dp=sp; - } - } -#endif - } - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - if (row_info->bit_depth == 8) - { - /* This inverts the alpha channel in GA */ - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = *(--sp); - } - } - -#ifdef PNG_READ_16BIT_SUPPORTED - else - { - /* This inverts the alpha channel in GGAA */ - png_bytep sp = row + row_info->rowbytes; - png_bytep dp = sp; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - *(--dp) = (png_byte)(255 - *(--sp)); - *(--dp) = (png_byte)(255 - *(--sp)); -/* - *(--dp) = *(--sp); - *(--dp) = *(--sp); -*/ - sp-=2; - dp=sp; - } - } -#endif - } -} -#endif - -#ifdef PNG_READ_FILLER_SUPPORTED -/* Add filler channel if we have RGB color */ -static void -png_do_read_filler(png_row_infop row_info, png_bytep row, - png_uint_32 filler, png_uint_32 flags) -{ - png_uint_32 i; - png_uint_32 row_width = row_info->width; - -#ifdef PNG_READ_16BIT_SUPPORTED - png_byte hi_filler = (png_byte)(filler>>8); -#endif - png_byte lo_filler = (png_byte)filler; - - png_debug(1, "in png_do_read_filler"); - - if ( - row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - if (row_info->bit_depth == 8) - { - if ((flags & PNG_FLAG_FILLER_AFTER) != 0) - { - /* This changes the data from G to GX */ - png_bytep sp = row + (size_t)row_width; - png_bytep dp = sp + (size_t)row_width; - for (i = 1; i < row_width; i++) - { - *(--dp) = lo_filler; - *(--dp) = *(--sp); - } - *(--dp) = lo_filler; - row_info->channels = 2; - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - - else - { - /* This changes the data from G to XG */ - png_bytep sp = row + (size_t)row_width; - png_bytep dp = sp + (size_t)row_width; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = lo_filler; - } - row_info->channels = 2; - row_info->pixel_depth = 16; - row_info->rowbytes = row_width * 2; - } - } - -#ifdef PNG_READ_16BIT_SUPPORTED - else if (row_info->bit_depth == 16) - { - if ((flags & PNG_FLAG_FILLER_AFTER) != 0) - { - /* This changes the data from GG to GGXX */ - png_bytep sp = row + (size_t)row_width * 2; - png_bytep dp = sp + (size_t)row_width * 2; - for (i = 1; i < row_width; i++) - { - *(--dp) = lo_filler; - *(--dp) = hi_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = lo_filler; - *(--dp) = hi_filler; - row_info->channels = 2; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - - else - { - /* This changes the data from GG to XXGG */ - png_bytep sp = row + (size_t)row_width * 2; - png_bytep dp = sp + (size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = lo_filler; - *(--dp) = hi_filler; - } - row_info->channels = 2; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - } -#endif - } /* COLOR_TYPE == GRAY */ - else if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - if (row_info->bit_depth == 8) - { - if ((flags & PNG_FLAG_FILLER_AFTER) != 0) - { - /* This changes the data from RGB to RGBX */ - png_bytep sp = row + (size_t)row_width * 3; - png_bytep dp = sp + (size_t)row_width; - for (i = 1; i < row_width; i++) - { - *(--dp) = lo_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = lo_filler; - row_info->channels = 4; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - - else - { - /* This changes the data from RGB to XRGB */ - png_bytep sp = row + (size_t)row_width * 3; - png_bytep dp = sp + (size_t)row_width; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = lo_filler; - } - row_info->channels = 4; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - } - } - -#ifdef PNG_READ_16BIT_SUPPORTED - else if (row_info->bit_depth == 16) - { - if ((flags & PNG_FLAG_FILLER_AFTER) != 0) - { - /* This changes the data from RRGGBB to RRGGBBXX */ - png_bytep sp = row + (size_t)row_width * 6; - png_bytep dp = sp + (size_t)row_width * 2; - for (i = 1; i < row_width; i++) - { - *(--dp) = lo_filler; - *(--dp) = hi_filler; - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - } - *(--dp) = lo_filler; - *(--dp) = hi_filler; - row_info->channels = 4; - row_info->pixel_depth = 64; - row_info->rowbytes = row_width * 8; - } - - else - { - /* This changes the data from RRGGBB to XXRRGGBB */ - png_bytep sp = row + (size_t)row_width * 6; - png_bytep dp = sp + (size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = *(--sp); - *(--dp) = lo_filler; - *(--dp) = hi_filler; - } - - row_info->channels = 4; - row_info->pixel_depth = 64; - row_info->rowbytes = row_width * 8; - } - } -#endif - } /* COLOR_TYPE == RGB */ -} -#endif - -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED -/* Expand grayscale files to RGB, with or without alpha */ -static void -png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) -{ - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - png_debug(1, "in png_do_gray_to_rgb"); - - if (row_info->bit_depth >= 8 && - (row_info->color_type & PNG_COLOR_MASK_COLOR) == 0) - { - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - if (row_info->bit_depth == 8) - { - /* This changes G to RGB */ - png_bytep sp = row + (size_t)row_width - 1; - png_bytep dp = sp + (size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(dp--) = *sp; - *(dp--) = *sp; - *(dp--) = *(sp--); - } - } - - else - { - /* This changes GG to RRGGBB */ - png_bytep sp = row + (size_t)row_width * 2 - 1; - png_bytep dp = sp + (size_t)row_width * 4; - for (i = 0; i < row_width; i++) - { - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *(sp--); - *(dp--) = *(sp--); - } - } - } - - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - if (row_info->bit_depth == 8) - { - /* This changes GA to RGBA */ - png_bytep sp = row + (size_t)row_width * 2 - 1; - png_bytep dp = sp + (size_t)row_width * 2; - for (i = 0; i < row_width; i++) - { - *(dp--) = *(sp--); - *(dp--) = *sp; - *(dp--) = *sp; - *(dp--) = *(sp--); - } - } - - else - { - /* This changes GGAA to RRGGBBAA */ - png_bytep sp = row + (size_t)row_width * 4 - 1; - png_bytep dp = sp + (size_t)row_width * 4; - for (i = 0; i < row_width; i++) - { - *(dp--) = *(sp--); - *(dp--) = *(sp--); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *sp; - *(dp--) = *(sp - 1); - *(dp--) = *(sp--); - *(dp--) = *(sp--); - } - } - } - row_info->channels = (png_byte)(row_info->channels + 2); - row_info->color_type |= PNG_COLOR_MASK_COLOR; - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); - } -} -#endif - -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED -/* Reduce RGB files to grayscale, with or without alpha - * using the equation given in Poynton's ColorFAQ of 1998-01-04 at - * (THIS LINK IS DEAD June 2008 but - * versions dated 1998 through November 2002 have been archived at - * https://web.archive.org/web/20000816232553/www.inforamp.net/ - * ~poynton/notes/colour_and_gamma/ColorFAQ.txt ) - * Charles Poynton poynton at poynton.com - * - * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - * - * which can be expressed with integers as - * - * Y = (6969 * R + 23434 * G + 2365 * B)/32768 - * - * Poynton's current link (as of January 2003 through July 2011): - * - * has changed the numbers slightly: - * - * Y = 0.2126*R + 0.7152*G + 0.0722*B - * - * which can be expressed with integers as - * - * Y = (6966 * R + 23436 * G + 2366 * B)/32768 - * - * Historically, however, libpng uses numbers derived from the ITU-R Rec 709 - * end point chromaticities and the D65 white point. Depending on the - * precision used for the D65 white point this produces a variety of different - * numbers, however if the four decimal place value used in ITU-R Rec 709 is - * used (0.3127,0.3290) the Y calculation would be: - * - * Y = (6968 * R + 23435 * G + 2366 * B)/32768 - * - * While this is correct the rounding results in an overflow for white, because - * the sum of the rounded coefficients is 32769, not 32768. Consequently - * libpng uses, instead, the closest non-overflowing approximation: - * - * Y = (6968 * R + 23434 * G + 2366 * B)/32768 - * - * Starting with libpng-1.5.5, if the image being converted has a cHRM chunk - * (including an sRGB chunk) then the chromaticities are used to calculate the - * coefficients. See the chunk handling in pngrutil.c for more information. - * - * In all cases the calculation is to be done in a linear colorspace. If no - * gamma information is available to correct the encoding of the original RGB - * values this results in an implicit assumption that the original PNG RGB - * values were linear. - * - * Other integer coefficients can be used via png_set_rgb_to_gray(). Because - * the API takes just red and green coefficients the blue coefficient is - * calculated to make the sum 32768. This will result in different rounding - * to that used above. - */ -static int -png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) -{ - int rgb_error = 0; - - png_debug(1, "in png_do_rgb_to_gray"); - - if ((row_info->color_type & PNG_COLOR_MASK_PALETTE) == 0 && - (row_info->color_type & PNG_COLOR_MASK_COLOR) != 0) - { - png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff; - png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff; - png_uint_32 bc = 32768 - rc - gc; - png_uint_32 row_width = row_info->width; - int have_alpha = (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0; - - if (row_info->bit_depth == 8) - { -#ifdef PNG_READ_GAMMA_SUPPORTED - /* Notice that gamma to/from 1 are not necessarily inverses (if - * there is an overall gamma correction). Prior to 1.5.5 this code - * checked the linearized values for equality; this doesn't match - * the documentation, the original values must be checked. - */ - if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - png_byte red = *(sp++); - png_byte green = *(sp++); - png_byte blue = *(sp++); - - if (red != green || red != blue) - { - red = png_ptr->gamma_to_1[red]; - green = png_ptr->gamma_to_1[green]; - blue = png_ptr->gamma_to_1[blue]; - - rgb_error |= 1; - *(dp++) = png_ptr->gamma_from_1[ - (rc*red + gc*green + bc*blue + 16384)>>15]; - } - - else - { - /* If there is no overall correction the table will not be - * set. - */ - if (png_ptr->gamma_table != NULL) - red = png_ptr->gamma_table[red]; - - *(dp++) = red; - } - - if (have_alpha != 0) - *(dp++) = *(sp++); - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - png_byte red = *(sp++); - png_byte green = *(sp++); - png_byte blue = *(sp++); - - if (red != green || red != blue) - { - rgb_error |= 1; - /* NOTE: this is the historical approach which simply - * truncates the results. - */ - *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15); - } - - else - *(dp++) = red; - - if (have_alpha != 0) - *(dp++) = *(sp++); - } - } - } - - else /* RGB bit_depth == 16 */ - { -#ifdef PNG_READ_GAMMA_SUPPORTED - if (png_ptr->gamma_16_to_1 != NULL && png_ptr->gamma_16_from_1 != NULL) - { - png_bytep sp = row; - png_bytep dp = row; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, w; - png_byte hi,lo; - - hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo)); - hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo)); - hi=*(sp)++; lo=*(sp)++; blue = (png_uint_16)((hi << 8) | (lo)); - - if (red == green && red == blue) - { - if (png_ptr->gamma_16_table != NULL) - w = png_ptr->gamma_16_table[(red & 0xff) - >> png_ptr->gamma_shift][red >> 8]; - - else - w = red; - } - - else - { - png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red & 0xff) - >> png_ptr->gamma_shift][red>>8]; - png_uint_16 green_1 = - png_ptr->gamma_16_to_1[(green & 0xff) >> - png_ptr->gamma_shift][green>>8]; - png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue & 0xff) - >> png_ptr->gamma_shift][blue>>8]; - png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1 - + bc*blue_1 + 16384)>>15); - w = png_ptr->gamma_16_from_1[(gray16 & 0xff) >> - png_ptr->gamma_shift][gray16 >> 8]; - rgb_error |= 1; - } - - *(dp++) = (png_byte)((w>>8) & 0xff); - *(dp++) = (png_byte)(w & 0xff); - - if (have_alpha != 0) - { - *(dp++) = *(sp++); - *(dp++) = *(sp++); - } - } - } - else -#endif - { - png_bytep sp = row; - png_bytep dp = row; - png_uint_32 i; - - for (i = 0; i < row_width; i++) - { - png_uint_16 red, green, blue, gray16; - png_byte hi,lo; - - hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo)); - hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo)); - hi=*(sp)++; lo=*(sp)++; blue = (png_uint_16)((hi << 8) | (lo)); - - if (red != green || red != blue) - rgb_error |= 1; - - /* From 1.5.5 in the 16-bit case do the accurate conversion even - * in the 'fast' case - this is because this is where the code - * ends up when handling linear 16-bit data. - */ - gray16 = (png_uint_16)((rc*red + gc*green + bc*blue + 16384) >> - 15); - *(dp++) = (png_byte)((gray16 >> 8) & 0xff); - *(dp++) = (png_byte)(gray16 & 0xff); - - if (have_alpha != 0) - { - *(dp++) = *(sp++); - *(dp++) = *(sp++); - } - } - } - } - - row_info->channels = (png_byte)(row_info->channels - 2); - row_info->color_type = (png_byte)(row_info->color_type & - ~PNG_COLOR_MASK_COLOR); - row_info->pixel_depth = (png_byte)(row_info->channels * - row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); - } - return rgb_error; -} -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) -/* Replace any alpha or transparency with the supplied background color. - * "background" is already in the screen gamma, while "background_1" is - * at a gamma of 1.0. Paletted files have already been taken care of. - */ -static void -png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) -{ -#ifdef PNG_READ_GAMMA_SUPPORTED - png_const_bytep gamma_table = png_ptr->gamma_table; - png_const_bytep gamma_from_1 = png_ptr->gamma_from_1; - png_const_bytep gamma_to_1 = png_ptr->gamma_to_1; - png_const_uint_16pp gamma_16 = png_ptr->gamma_16_table; - png_const_uint_16pp gamma_16_from_1 = png_ptr->gamma_16_from_1; - png_const_uint_16pp gamma_16_to_1 = png_ptr->gamma_16_to_1; - int gamma_shift = png_ptr->gamma_shift; - int optimize = (png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0; -#endif - - png_bytep sp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - int shift; - - png_debug(1, "in png_do_compose"); - - switch (row_info->color_type) - { - case PNG_COLOR_TYPE_GRAY: - { - switch (row_info->bit_depth) - { - case 1: - { - sp = row; - shift = 7; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x01) - == png_ptr->trans_color.gray) - { - unsigned int tmp = *sp & (0x7f7f >> (7 - shift)); - tmp |= - (unsigned int)(png_ptr->background.gray << shift); - *sp = (png_byte)(tmp & 0xff); - } - - if (shift == 0) - { - shift = 7; - sp++; - } - - else - shift--; - } - break; - } - - case 2: - { -#ifdef PNG_READ_GAMMA_SUPPORTED - if (gamma_table != NULL) - { - sp = row; - shift = 6; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x03) - == png_ptr->trans_color.gray) - { - unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); - tmp |= - (unsigned int)png_ptr->background.gray << shift; - *sp = (png_byte)(tmp & 0xff); - } - - else - { - unsigned int p = (*sp >> shift) & 0x03; - unsigned int g = (gamma_table [p | (p << 2) | - (p << 4) | (p << 6)] >> 6) & 0x03; - unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); - tmp |= (unsigned int)(g << shift); - *sp = (png_byte)(tmp & 0xff); - } - - if (shift == 0) - { - shift = 6; - sp++; - } - - else - shift -= 2; - } - } - - else -#endif - { - sp = row; - shift = 6; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x03) - == png_ptr->trans_color.gray) - { - unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); - tmp |= - (unsigned int)png_ptr->background.gray << shift; - *sp = (png_byte)(tmp & 0xff); - } - - if (shift == 0) - { - shift = 6; - sp++; - } - - else - shift -= 2; - } - } - break; - } - - case 4: - { -#ifdef PNG_READ_GAMMA_SUPPORTED - if (gamma_table != NULL) - { - sp = row; - shift = 4; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x0f) - == png_ptr->trans_color.gray) - { - unsigned int tmp = *sp & (0x0f0f >> (4 - shift)); - tmp |= - (unsigned int)(png_ptr->background.gray << shift); - *sp = (png_byte)(tmp & 0xff); - } - - else - { - unsigned int p = (*sp >> shift) & 0x0f; - unsigned int g = (gamma_table[p | (p << 4)] >> 4) & - 0x0f; - unsigned int tmp = *sp & (0x0f0f >> (4 - shift)); - tmp |= (unsigned int)(g << shift); - *sp = (png_byte)(tmp & 0xff); - } - - if (shift == 0) - { - shift = 4; - sp++; - } - - else - shift -= 4; - } - } - - else -#endif - { - sp = row; - shift = 4; - for (i = 0; i < row_width; i++) - { - if ((png_uint_16)((*sp >> shift) & 0x0f) - == png_ptr->trans_color.gray) - { - unsigned int tmp = *sp & (0x0f0f >> (4 - shift)); - tmp |= - (unsigned int)(png_ptr->background.gray << shift); - *sp = (png_byte)(tmp & 0xff); - } - - if (shift == 0) - { - shift = 4; - sp++; - } - - else - shift -= 4; - } - } - break; - } - - case 8: - { -#ifdef PNG_READ_GAMMA_SUPPORTED - if (gamma_table != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - if (*sp == png_ptr->trans_color.gray) - *sp = (png_byte)png_ptr->background.gray; - - else - *sp = gamma_table[*sp]; - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp++) - { - if (*sp == png_ptr->trans_color.gray) - *sp = (png_byte)png_ptr->background.gray; - } - } - break; - } - - case 16: - { -#ifdef PNG_READ_GAMMA_SUPPORTED - if (gamma_16 != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 2) - { - png_uint_16 v; - - v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - - if (v == png_ptr->trans_color.gray) - { - /* Background is already in screen gamma */ - *sp = (png_byte)((png_ptr->background.gray >> 8) - & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.gray - & 0xff); - } - - else - { - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 2) - { - png_uint_16 v; - - v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - - if (v == png_ptr->trans_color.gray) - { - *sp = (png_byte)((png_ptr->background.gray >> 8) - & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.gray - & 0xff); - } - } - } - break; - } - - default: - break; - } - break; - } - - case PNG_COLOR_TYPE_RGB: - { - if (row_info->bit_depth == 8) - { -#ifdef PNG_READ_GAMMA_SUPPORTED - if (gamma_table != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 3) - { - if (*sp == png_ptr->trans_color.red && - *(sp + 1) == png_ptr->trans_color.green && - *(sp + 2) == png_ptr->trans_color.blue) - { - *sp = (png_byte)png_ptr->background.red; - *(sp + 1) = (png_byte)png_ptr->background.green; - *(sp + 2) = (png_byte)png_ptr->background.blue; - } - - else - { - *sp = gamma_table[*sp]; - *(sp + 1) = gamma_table[*(sp + 1)]; - *(sp + 2) = gamma_table[*(sp + 2)]; - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 3) - { - if (*sp == png_ptr->trans_color.red && - *(sp + 1) == png_ptr->trans_color.green && - *(sp + 2) == png_ptr->trans_color.blue) - { - *sp = (png_byte)png_ptr->background.red; - *(sp + 1) = (png_byte)png_ptr->background.green; - *(sp + 2) = (png_byte)png_ptr->background.blue; - } - } - } - } - else /* if (row_info->bit_depth == 16) */ - { -#ifdef PNG_READ_GAMMA_SUPPORTED - if (gamma_16 != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 6) - { - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - - png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) - + *(sp + 3)); - - png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) - + *(sp + 5)); - - if (r == png_ptr->trans_color.red && - g == png_ptr->trans_color.green && - b == png_ptr->trans_color.blue) - { - /* Background is already in screen gamma */ - *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); - *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) - & 0xff); - *(sp + 3) = (png_byte)(png_ptr->background.green - & 0xff); - *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) - & 0xff); - *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); - } - - else - { - png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - - v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; - *(sp + 2) = (png_byte)((v >> 8) & 0xff); - *(sp + 3) = (png_byte)(v & 0xff); - - v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; - *(sp + 4) = (png_byte)((v >> 8) & 0xff); - *(sp + 5) = (png_byte)(v & 0xff); - } - } - } - - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 6) - { - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - - png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) - + *(sp + 3)); - - png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) - + *(sp + 5)); - - if (r == png_ptr->trans_color.red && - g == png_ptr->trans_color.green && - b == png_ptr->trans_color.blue) - { - *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); - *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) - & 0xff); - *(sp + 3) = (png_byte)(png_ptr->background.green - & 0xff); - *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) - & 0xff); - *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); - } - } - } - } - break; - } - - case PNG_COLOR_TYPE_GRAY_ALPHA: - { - if (row_info->bit_depth == 8) - { -#ifdef PNG_READ_GAMMA_SUPPORTED - if (gamma_to_1 != NULL && gamma_from_1 != NULL && - gamma_table != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 2) - { - png_uint_16 a = *(sp + 1); - - if (a == 0xff) - *sp = gamma_table[*sp]; - - else if (a == 0) - { - /* Background is already in screen gamma */ - *sp = (png_byte)png_ptr->background.gray; - } - - else - { - png_byte v, w; - - v = gamma_to_1[*sp]; - png_composite(w, v, a, png_ptr->background_1.gray); - if (optimize == 0) - w = gamma_from_1[w]; - *sp = w; - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 2) - { - png_byte a = *(sp + 1); - - if (a == 0) - *sp = (png_byte)png_ptr->background.gray; - - else if (a < 0xff) - png_composite(*sp, *sp, a, png_ptr->background.gray); - } - } - } - else /* if (png_ptr->bit_depth == 16) */ - { -#ifdef PNG_READ_GAMMA_SUPPORTED - if (gamma_16 != NULL && gamma_16_from_1 != NULL && - gamma_16_to_1 != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 4) - { - png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8) - + *(sp + 3)); - - if (a == (png_uint_16)0xffff) - { - png_uint_16 v; - - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - } - - else if (a == 0) - { - /* Background is already in screen gamma */ - *sp = (png_byte)((png_ptr->background.gray >> 8) - & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff); - } - - else - { - png_uint_16 g, v, w; - - g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; - png_composite_16(v, g, a, png_ptr->background_1.gray); - if (optimize != 0) - w = v; - else - w = gamma_16_from_1[(v & 0xff) >> - gamma_shift][v >> 8]; - *sp = (png_byte)((w >> 8) & 0xff); - *(sp + 1) = (png_byte)(w & 0xff); - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 4) - { - png_uint_16 a = (png_uint_16)(((*(sp + 2)) << 8) - + *(sp + 3)); - - if (a == 0) - { - *sp = (png_byte)((png_ptr->background.gray >> 8) - & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.gray & 0xff); - } - - else if (a < 0xffff) - { - png_uint_16 g, v; - - g = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_composite_16(v, g, a, png_ptr->background.gray); - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - } - } - } - } - break; - } - - case PNG_COLOR_TYPE_RGB_ALPHA: - { - if (row_info->bit_depth == 8) - { -#ifdef PNG_READ_GAMMA_SUPPORTED - if (gamma_to_1 != NULL && gamma_from_1 != NULL && - gamma_table != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 4) - { - png_byte a = *(sp + 3); - - if (a == 0xff) - { - *sp = gamma_table[*sp]; - *(sp + 1) = gamma_table[*(sp + 1)]; - *(sp + 2) = gamma_table[*(sp + 2)]; - } - - else if (a == 0) - { - /* Background is already in screen gamma */ - *sp = (png_byte)png_ptr->background.red; - *(sp + 1) = (png_byte)png_ptr->background.green; - *(sp + 2) = (png_byte)png_ptr->background.blue; - } - - else - { - png_byte v, w; - - v = gamma_to_1[*sp]; - png_composite(w, v, a, png_ptr->background_1.red); - if (optimize == 0) w = gamma_from_1[w]; - *sp = w; - - v = gamma_to_1[*(sp + 1)]; - png_composite(w, v, a, png_ptr->background_1.green); - if (optimize == 0) w = gamma_from_1[w]; - *(sp + 1) = w; - - v = gamma_to_1[*(sp + 2)]; - png_composite(w, v, a, png_ptr->background_1.blue); - if (optimize == 0) w = gamma_from_1[w]; - *(sp + 2) = w; - } - } - } - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 4) - { - png_byte a = *(sp + 3); - - if (a == 0) - { - *sp = (png_byte)png_ptr->background.red; - *(sp + 1) = (png_byte)png_ptr->background.green; - *(sp + 2) = (png_byte)png_ptr->background.blue; - } - - else if (a < 0xff) - { - png_composite(*sp, *sp, a, png_ptr->background.red); - - png_composite(*(sp + 1), *(sp + 1), a, - png_ptr->background.green); - - png_composite(*(sp + 2), *(sp + 2), a, - png_ptr->background.blue); - } - } - } - } - else /* if (row_info->bit_depth == 16) */ - { -#ifdef PNG_READ_GAMMA_SUPPORTED - if (gamma_16 != NULL && gamma_16_from_1 != NULL && - gamma_16_to_1 != NULL) - { - sp = row; - for (i = 0; i < row_width; i++, sp += 8) - { - png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) - << 8) + (png_uint_16)(*(sp + 7))); - - if (a == (png_uint_16)0xffff) - { - png_uint_16 v; - - v = gamma_16[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - - v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)]; - *(sp + 2) = (png_byte)((v >> 8) & 0xff); - *(sp + 3) = (png_byte)(v & 0xff); - - v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)]; - *(sp + 4) = (png_byte)((v >> 8) & 0xff); - *(sp + 5) = (png_byte)(v & 0xff); - } - - else if (a == 0) - { - /* Background is already in screen gamma */ - *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); - *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) - & 0xff); - *(sp + 3) = (png_byte)(png_ptr->background.green - & 0xff); - *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) - & 0xff); - *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); - } - - else - { - png_uint_16 v, w; - - v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp]; - png_composite_16(w, v, a, png_ptr->background_1.red); - if (optimize == 0) - w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >> - 8]; - *sp = (png_byte)((w >> 8) & 0xff); - *(sp + 1) = (png_byte)(w & 0xff); - - v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)]; - png_composite_16(w, v, a, png_ptr->background_1.green); - if (optimize == 0) - w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >> - 8]; - - *(sp + 2) = (png_byte)((w >> 8) & 0xff); - *(sp + 3) = (png_byte)(w & 0xff); - - v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)]; - png_composite_16(w, v, a, png_ptr->background_1.blue); - if (optimize == 0) - w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >> - 8]; - - *(sp + 4) = (png_byte)((w >> 8) & 0xff); - *(sp + 5) = (png_byte)(w & 0xff); - } - } - } - - else -#endif - { - sp = row; - for (i = 0; i < row_width; i++, sp += 8) - { - png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6)) - << 8) + (png_uint_16)(*(sp + 7))); - - if (a == 0) - { - *sp = (png_byte)((png_ptr->background.red >> 8) & 0xff); - *(sp + 1) = (png_byte)(png_ptr->background.red & 0xff); - *(sp + 2) = (png_byte)((png_ptr->background.green >> 8) - & 0xff); - *(sp + 3) = (png_byte)(png_ptr->background.green - & 0xff); - *(sp + 4) = (png_byte)((png_ptr->background.blue >> 8) - & 0xff); - *(sp + 5) = (png_byte)(png_ptr->background.blue & 0xff); - } - - else if (a < 0xffff) - { - png_uint_16 v; - - png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1)); - png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8) - + *(sp + 3)); - png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8) - + *(sp + 5)); - - png_composite_16(v, r, a, png_ptr->background.red); - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - - png_composite_16(v, g, a, png_ptr->background.green); - *(sp + 2) = (png_byte)((v >> 8) & 0xff); - *(sp + 3) = (png_byte)(v & 0xff); - - png_composite_16(v, b, a, png_ptr->background.blue); - *(sp + 4) = (png_byte)((v >> 8) & 0xff); - *(sp + 5) = (png_byte)(v & 0xff); - } - } - } - } - break; - } - - default: - break; - } -} -#endif /* READ_BACKGROUND || READ_ALPHA_MODE */ - -#ifdef PNG_READ_GAMMA_SUPPORTED -/* Gamma correct the image, avoiding the alpha channel. Make sure - * you do this after you deal with the transparency issue on grayscale - * or RGB images. If your bit depth is 8, use gamma_table, if it - * is 16, use gamma_16_table and gamma_shift. Build these with - * build_gamma_table(). - */ -static void -png_do_gamma(png_row_infop row_info, png_bytep row, png_structrp png_ptr) -{ - png_const_bytep gamma_table = png_ptr->gamma_table; - png_const_uint_16pp gamma_16_table = png_ptr->gamma_16_table; - int gamma_shift = png_ptr->gamma_shift; - - png_bytep sp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_gamma"); - - if (((row_info->bit_depth <= 8 && gamma_table != NULL) || - (row_info->bit_depth == 16 && gamma_16_table != NULL))) - { - switch (row_info->color_type) - { - case PNG_COLOR_TYPE_RGB: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - *sp = gamma_table[*sp]; - sp++; - } - } - - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v; - - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - } - } - break; - } - - case PNG_COLOR_TYPE_RGB_ALPHA: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - - *sp = gamma_table[*sp]; - sp++; - - *sp = gamma_table[*sp]; - sp++; - - sp++; - } - } - - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - - v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 4; - } - } - break; - } - - case PNG_COLOR_TYPE_GRAY_ALPHA: - { - if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp += 2; - } - } - - else /* if (row_info->bit_depth == 16) */ - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 4; - } - } - break; - } - - case PNG_COLOR_TYPE_GRAY: - { - if (row_info->bit_depth == 2) - { - sp = row; - for (i = 0; i < row_width; i += 4) - { - int a = *sp & 0xc0; - int b = *sp & 0x30; - int c = *sp & 0x0c; - int d = *sp & 0x03; - - *sp = (png_byte)( - ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)| - ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)| - ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)| - ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) )); - sp++; - } - } - - if (row_info->bit_depth == 4) - { - sp = row; - for (i = 0; i < row_width; i += 2) - { - int msb = *sp & 0xf0; - int lsb = *sp & 0x0f; - - *sp = (png_byte)((((int)gamma_table[msb | (msb >> 4)]) & 0xf0) - | (((int)gamma_table[(lsb << 4) | lsb]) >> 4)); - sp++; - } - } - - else if (row_info->bit_depth == 8) - { - sp = row; - for (i = 0; i < row_width; i++) - { - *sp = gamma_table[*sp]; - sp++; - } - } - - else if (row_info->bit_depth == 16) - { - sp = row; - for (i = 0; i < row_width; i++) - { - png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp]; - *sp = (png_byte)((v >> 8) & 0xff); - *(sp + 1) = (png_byte)(v & 0xff); - sp += 2; - } - } - break; - } - - default: - break; - } - } -} -#endif - -#ifdef PNG_READ_ALPHA_MODE_SUPPORTED -/* Encode the alpha channel to the output gamma (the input channel is always - * linear.) Called only with color types that have an alpha channel. Needs the - * from_1 tables. - */ -static void -png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr) -{ - png_uint_32 row_width = row_info->width; - - png_debug(1, "in png_do_encode_alpha"); - - if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0) - { - if (row_info->bit_depth == 8) - { - png_bytep table = png_ptr->gamma_from_1; - - if (table != NULL) - { - int step = (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2; - - /* The alpha channel is the last component: */ - row += step - 1; - - for (; row_width > 0; --row_width, row += step) - *row = table[*row]; - - return; - } - } - - else if (row_info->bit_depth == 16) - { - png_uint_16pp table = png_ptr->gamma_16_from_1; - int gamma_shift = png_ptr->gamma_shift; - - if (table != NULL) - { - int step = (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4; - - /* The alpha channel is the last component: */ - row += step - 2; - - for (; row_width > 0; --row_width, row += step) - { - png_uint_16 v; - - v = table[*(row + 1) >> gamma_shift][*row]; - *row = (png_byte)((v >> 8) & 0xff); - *(row + 1) = (png_byte)(v & 0xff); - } - - return; - } - } - } - - /* Only get to here if called with a weird row_info; no harm has been done, - * so just issue a warning. - */ - png_warning(png_ptr, "png_do_encode_alpha: unexpected call"); -} -#endif - -#ifdef PNG_READ_EXPAND_SUPPORTED -/* Expands a palette row to an RGB or RGBA row depending - * upon whether you supply trans and num_trans. - */ -static void -png_do_expand_palette(png_structrp png_ptr, png_row_infop row_info, - png_bytep row, png_const_colorp palette, png_const_bytep trans_alpha, - int num_trans) -{ - int shift, value; - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_expand_palette"); - - if (row_info->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (row_info->bit_depth < 8) - { - switch (row_info->bit_depth) - { - case 1: - { - sp = row + (size_t)((row_width - 1) >> 3); - dp = row + (size_t)row_width - 1; - shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - if ((*sp >> shift) & 0x01) - *dp = 1; - - else - *dp = 0; - - if (shift == 7) - { - shift = 0; - sp--; - } - - else - shift++; - - dp--; - } - break; - } - - case 2: - { - sp = row + (size_t)((row_width - 1) >> 2); - dp = row + (size_t)row_width - 1; - shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x03; - *dp = (png_byte)value; - if (shift == 6) - { - shift = 0; - sp--; - } - - else - shift += 2; - - dp--; - } - break; - } - - case 4: - { - sp = row + (size_t)((row_width - 1) >> 1); - dp = row + (size_t)row_width - 1; - shift = (int)((row_width & 0x01) << 2); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x0f; - *dp = (png_byte)value; - if (shift == 4) - { - shift = 0; - sp--; - } - - else - shift += 4; - - dp--; - } - break; - } - - default: - break; - } - row_info->bit_depth = 8; - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - - if (row_info->bit_depth == 8) - { - { - if (num_trans > 0) - { - sp = row + (size_t)row_width - 1; - dp = row + ((size_t)row_width << 2) - 1; - - i = 0; -#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE - if (png_ptr->riffled_palette != NULL) - { - /* The RGBA optimization works with png_ptr->bit_depth == 8 - * but sometimes row_info->bit_depth has been changed to 8. - * In these cases, the palette hasn't been riffled. - */ - i = png_do_expand_palette_rgba8_neon(png_ptr, row_info, row, - &sp, &dp); - } -#else - PNG_UNUSED(png_ptr) -#endif - - for (; i < row_width; i++) - { - if ((int)(*sp) >= num_trans) - *dp-- = 0xff; - else - *dp-- = trans_alpha[*sp]; - *dp-- = palette[*sp].blue; - *dp-- = palette[*sp].green; - *dp-- = palette[*sp].red; - sp--; - } - row_info->bit_depth = 8; - row_info->pixel_depth = 32; - row_info->rowbytes = row_width * 4; - row_info->color_type = 6; - row_info->channels = 4; - } - - else - { - sp = row + (size_t)row_width - 1; - dp = row + (size_t)(row_width * 3) - 1; - i = 0; -#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE - i = png_do_expand_palette_rgb8_neon(png_ptr, row_info, row, - &sp, &dp); -#else - PNG_UNUSED(png_ptr) -#endif - - for (; i < row_width; i++) - { - *dp-- = palette[*sp].blue; - *dp-- = palette[*sp].green; - *dp-- = palette[*sp].red; - sp--; - } - - row_info->bit_depth = 8; - row_info->pixel_depth = 24; - row_info->rowbytes = row_width * 3; - row_info->color_type = 2; - row_info->channels = 3; - } - } - } - } -} - -/* If the bit depth < 8, it is expanded to 8. Also, if the already - * expanded transparency value is supplied, an alpha channel is built. - */ -static void -png_do_expand(png_row_infop row_info, png_bytep row, - png_const_color_16p trans_color) -{ - int shift, value; - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_expand"); - - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - unsigned int gray = trans_color != NULL ? trans_color->gray : 0; - - if (row_info->bit_depth < 8) - { - switch (row_info->bit_depth) - { - case 1: - { - gray = (gray & 0x01) * 0xff; - sp = row + (size_t)((row_width - 1) >> 3); - dp = row + (size_t)row_width - 1; - shift = 7 - (int)((row_width + 7) & 0x07); - for (i = 0; i < row_width; i++) - { - if ((*sp >> shift) & 0x01) - *dp = 0xff; - - else - *dp = 0; - - if (shift == 7) - { - shift = 0; - sp--; - } - - else - shift++; - - dp--; - } - break; - } - - case 2: - { - gray = (gray & 0x03) * 0x55; - sp = row + (size_t)((row_width - 1) >> 2); - dp = row + (size_t)row_width - 1; - shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x03; - *dp = (png_byte)(value | (value << 2) | (value << 4) | - (value << 6)); - if (shift == 6) - { - shift = 0; - sp--; - } - - else - shift += 2; - - dp--; - } - break; - } - - case 4: - { - gray = (gray & 0x0f) * 0x11; - sp = row + (size_t)((row_width - 1) >> 1); - dp = row + (size_t)row_width - 1; - shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); - for (i = 0; i < row_width; i++) - { - value = (*sp >> shift) & 0x0f; - *dp = (png_byte)(value | (value << 4)); - if (shift == 4) - { - shift = 0; - sp--; - } - - else - shift = 4; - - dp--; - } - break; - } - - default: - break; - } - - row_info->bit_depth = 8; - row_info->pixel_depth = 8; - row_info->rowbytes = row_width; - } - - if (trans_color != NULL) - { - if (row_info->bit_depth == 8) - { - gray = gray & 0xff; - sp = row + (size_t)row_width - 1; - dp = row + ((size_t)row_width << 1) - 1; - - for (i = 0; i < row_width; i++) - { - if ((*sp & 0xffU) == gray) - *dp-- = 0; - - else - *dp-- = 0xff; - - *dp-- = *sp--; - } - } - - else if (row_info->bit_depth == 16) - { - unsigned int gray_high = (gray >> 8) & 0xff; - unsigned int gray_low = gray & 0xff; - sp = row + row_info->rowbytes - 1; - dp = row + (row_info->rowbytes << 1) - 1; - for (i = 0; i < row_width; i++) - { - if ((*(sp - 1) & 0xffU) == gray_high && - (*(sp) & 0xffU) == gray_low) - { - *dp-- = 0; - *dp-- = 0; - } - - else - { - *dp-- = 0xff; - *dp-- = 0xff; - } - - *dp-- = *sp--; - *dp-- = *sp--; - } - } - - row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA; - row_info->channels = 2; - row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_width); - } - } - else if (row_info->color_type == PNG_COLOR_TYPE_RGB && - trans_color != NULL) - { - if (row_info->bit_depth == 8) - { - png_byte red = (png_byte)(trans_color->red & 0xff); - png_byte green = (png_byte)(trans_color->green & 0xff); - png_byte blue = (png_byte)(trans_color->blue & 0xff); - sp = row + (size_t)row_info->rowbytes - 1; - dp = row + ((size_t)row_width << 2) - 1; - for (i = 0; i < row_width; i++) - { - if (*(sp - 2) == red && *(sp - 1) == green && *(sp) == blue) - *dp-- = 0; - - else - *dp-- = 0xff; - - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - } - } - else if (row_info->bit_depth == 16) - { - png_byte red_high = (png_byte)((trans_color->red >> 8) & 0xff); - png_byte green_high = (png_byte)((trans_color->green >> 8) & 0xff); - png_byte blue_high = (png_byte)((trans_color->blue >> 8) & 0xff); - png_byte red_low = (png_byte)(trans_color->red & 0xff); - png_byte green_low = (png_byte)(trans_color->green & 0xff); - png_byte blue_low = (png_byte)(trans_color->blue & 0xff); - sp = row + row_info->rowbytes - 1; - dp = row + ((size_t)row_width << 3) - 1; - for (i = 0; i < row_width; i++) - { - if (*(sp - 5) == red_high && - *(sp - 4) == red_low && - *(sp - 3) == green_high && - *(sp - 2) == green_low && - *(sp - 1) == blue_high && - *(sp ) == blue_low) - { - *dp-- = 0; - *dp-- = 0; - } - - else - { - *dp-- = 0xff; - *dp-- = 0xff; - } - - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - *dp-- = *sp--; - } - } - row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA; - row_info->channels = 4; - row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); - } -} -#endif - -#ifdef PNG_READ_EXPAND_16_SUPPORTED -/* If the bit depth is 8 and the color type is not a palette type expand the - * whole row to 16 bits. Has no effect otherwise. - */ -static void -png_do_expand_16(png_row_infop row_info, png_bytep row) -{ - if (row_info->bit_depth == 8 && - row_info->color_type != PNG_COLOR_TYPE_PALETTE) - { - /* The row have a sequence of bytes containing [0..255] and we need - * to turn it into another row containing [0..65535], to do this we - * calculate: - * - * (input / 255) * 65535 - * - * Which happens to be exactly input * 257 and this can be achieved - * simply by byte replication in place (copying backwards). - */ - png_byte *sp = row + row_info->rowbytes; /* source, last byte + 1 */ - png_byte *dp = sp + row_info->rowbytes; /* destination, end + 1 */ - while (dp > sp) - { - dp[-2] = dp[-1] = *--sp; dp -= 2; - } - - row_info->rowbytes *= 2; - row_info->bit_depth = 16; - row_info->pixel_depth = (png_byte)(row_info->channels * 16); - } -} -#endif - -#ifdef PNG_READ_QUANTIZE_SUPPORTED -static void -png_do_quantize(png_row_infop row_info, png_bytep row, - png_const_bytep palette_lookup, png_const_bytep quantize_lookup) -{ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width=row_info->width; - - png_debug(1, "in png_do_quantize"); - - if (row_info->bit_depth == 8) - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB && palette_lookup) - { - int r, g, b, p; - sp = row; - dp = row; - for (i = 0; i < row_width; i++) - { - r = *sp++; - g = *sp++; - b = *sp++; - - /* This looks real messy, but the compiler will reduce - * it down to a reasonable formula. For example, with - * 5 bits per color, we get: - * p = (((r >> 3) & 0x1f) << 10) | - * (((g >> 3) & 0x1f) << 5) | - * ((b >> 3) & 0x1f); - */ - p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) & - ((1 << PNG_QUANTIZE_RED_BITS) - 1)) << - (PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) | - (((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) & - ((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) << - (PNG_QUANTIZE_BLUE_BITS)) | - ((b >> (8 - PNG_QUANTIZE_BLUE_BITS)) & - ((1 << PNG_QUANTIZE_BLUE_BITS) - 1)); - - *dp++ = palette_lookup[p]; - } - - row_info->color_type = PNG_COLOR_TYPE_PALETTE; - row_info->channels = 1; - row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); - } - - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && - palette_lookup != NULL) - { - int r, g, b, p; - sp = row; - dp = row; - for (i = 0; i < row_width; i++) - { - r = *sp++; - g = *sp++; - b = *sp++; - sp++; - - p = (((r >> (8 - PNG_QUANTIZE_RED_BITS)) & - ((1 << PNG_QUANTIZE_RED_BITS) - 1)) << - (PNG_QUANTIZE_GREEN_BITS + PNG_QUANTIZE_BLUE_BITS)) | - (((g >> (8 - PNG_QUANTIZE_GREEN_BITS)) & - ((1 << PNG_QUANTIZE_GREEN_BITS) - 1)) << - (PNG_QUANTIZE_BLUE_BITS)) | - ((b >> (8 - PNG_QUANTIZE_BLUE_BITS)) & - ((1 << PNG_QUANTIZE_BLUE_BITS) - 1)); - - *dp++ = palette_lookup[p]; - } - - row_info->color_type = PNG_COLOR_TYPE_PALETTE; - row_info->channels = 1; - row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); - } - - else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && - quantize_lookup) - { - sp = row; - - for (i = 0; i < row_width; i++, sp++) - { - *sp = quantize_lookup[*sp]; - } - } - } -} -#endif /* READ_QUANTIZE */ - -/* Transform the row. The order of transformations is significant, - * and is very touchy. If you add a transformation, take care to - * decide how it fits in with the other transformations here. - */ -void /* PRIVATE */ -png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) -{ - png_debug(1, "in png_do_read_transformations"); - - if (png_ptr->row_buf == NULL) - { - /* Prior to 1.5.4 this output row/pass where the NULL pointer is, but this - * error is incredibly rare and incredibly easy to debug without this - * information. - */ - png_error(png_ptr, "NULL row buffer"); - } - - /* The following is debugging; prior to 1.5.4 the code was never compiled in; - * in 1.5.4 PNG_FLAG_DETECT_UNINITIALIZED was added and the macro - * PNG_WARN_UNINITIALIZED_ROW removed. In 1.6 the new flag is set only for - * all transformations, however in practice the ROW_INIT always gets done on - * demand, if necessary. - */ - if ((png_ptr->flags & PNG_FLAG_DETECT_UNINITIALIZED) != 0 && - (png_ptr->flags & PNG_FLAG_ROW_INIT) == 0) - { - /* Application has failed to call either png_read_start_image() or - * png_read_update_info() after setting transforms that expand pixels. - * This check added to libpng-1.2.19 (but not enabled until 1.5.4). - */ - png_error(png_ptr, "Uninitialized row"); - } - -#ifdef PNG_READ_EXPAND_SUPPORTED - if ((png_ptr->transformations & PNG_EXPAND) != 0) - { - if (row_info->color_type == PNG_COLOR_TYPE_PALETTE) - { -#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE - if ((png_ptr->num_trans > 0) && (png_ptr->bit_depth == 8)) - { - if (png_ptr->riffled_palette == NULL) - { - /* Initialize the accelerated palette expansion. */ - png_ptr->riffled_palette = - (png_bytep)png_malloc(png_ptr, 256 * 4); - png_riffle_palette_neon(png_ptr); - } - } -#endif - png_do_expand_palette(png_ptr, row_info, png_ptr->row_buf + 1, - png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans); - } - - else - { - if (png_ptr->num_trans != 0 && - (png_ptr->transformations & PNG_EXPAND_tRNS) != 0) - png_do_expand(row_info, png_ptr->row_buf + 1, - &(png_ptr->trans_color)); - - else - png_do_expand(row_info, png_ptr->row_buf + 1, NULL); - } - } -#endif - -#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED - if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 && - (png_ptr->transformations & PNG_COMPOSE) == 0 && - (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA || - row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) - png_do_strip_channel(row_info, png_ptr->row_buf + 1, - 0 /* at_start == false, because SWAP_ALPHA happens later */); -#endif - -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED - if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0) - { - int rgb_error = - png_do_rgb_to_gray(png_ptr, row_info, - png_ptr->row_buf + 1); - - if (rgb_error != 0) - { - png_ptr->rgb_to_gray_status=1; - if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == - PNG_RGB_TO_GRAY_WARN) - png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel"); - - if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == - PNG_RGB_TO_GRAY_ERR) - png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); - } - } -#endif - -/* From Andreas Dilger e-mail to png-implement, 26 March 1998: - * - * In most cases, the "simple transparency" should be done prior to doing - * gray-to-RGB, or you will have to test 3x as many bytes to check if a - * pixel is transparent. You would also need to make sure that the - * transparency information is upgraded to RGB. - * - * To summarize, the current flow is: - * - Gray + simple transparency -> compare 1 or 2 gray bytes and composite - * with background "in place" if transparent, - * convert to RGB if necessary - * - Gray + alpha -> composite with gray background and remove alpha bytes, - * convert to RGB if necessary - * - * To support RGB backgrounds for gray images we need: - * - Gray + simple transparency -> convert to RGB + simple transparency, - * compare 3 or 6 bytes and composite with - * background "in place" if transparent - * (3x compare/pixel compared to doing - * composite with gray bkgrnd) - * - Gray + alpha -> convert to RGB + alpha, composite with background and - * remove alpha bytes (3x float - * operations/pixel compared with composite - * on gray background) - * - * Greg's change will do this. The reason it wasn't done before is for - * performance, as this increases the per-pixel operations. If we would check - * in advance if the background was gray or RGB, and position the gray-to-RGB - * transform appropriately, then it would save a lot of work/time. - */ - -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED - /* If gray -> RGB, do so now only if background is non-gray; else do later - * for performance reasons - */ - if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0 && - (png_ptr->mode & PNG_BACKGROUND_IS_GRAY) == 0) - png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1); -#endif - -#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) - if ((png_ptr->transformations & PNG_COMPOSE) != 0) - png_do_compose(row_info, png_ptr->row_buf + 1, png_ptr); -#endif - -#ifdef PNG_READ_GAMMA_SUPPORTED - if ((png_ptr->transformations & PNG_GAMMA) != 0 && -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED - /* Because RGB_TO_GRAY does the gamma transform. */ - (png_ptr->transformations & PNG_RGB_TO_GRAY) == 0 && -#endif -#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) - /* Because PNG_COMPOSE does the gamma transform if there is something to - * do (if there is an alpha channel or transparency.) - */ - !((png_ptr->transformations & PNG_COMPOSE) != 0 && - ((png_ptr->num_trans != 0) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)) && -#endif - /* Because png_init_read_transformations transforms the palette, unless - * RGB_TO_GRAY will do the transform. - */ - (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) - png_do_gamma(row_info, png_ptr->row_buf + 1, png_ptr); -#endif - -#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED - if ((png_ptr->transformations & PNG_STRIP_ALPHA) != 0 && - (png_ptr->transformations & PNG_COMPOSE) != 0 && - (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA || - row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) - png_do_strip_channel(row_info, png_ptr->row_buf + 1, - 0 /* at_start == false, because SWAP_ALPHA happens later */); -#endif - -#ifdef PNG_READ_ALPHA_MODE_SUPPORTED - if ((png_ptr->transformations & PNG_ENCODE_ALPHA) != 0 && - (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0) - png_do_encode_alpha(row_info, png_ptr->row_buf + 1, png_ptr); -#endif - -#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED - if ((png_ptr->transformations & PNG_SCALE_16_TO_8) != 0) - png_do_scale_16_to_8(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED - /* There is no harm in doing both of these because only one has any effect, - * by putting the 'scale' option first if the app asks for scale (either by - * calling the API or in a TRANSFORM flag) this is what happens. - */ - if ((png_ptr->transformations & PNG_16_TO_8) != 0) - png_do_chop(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_READ_QUANTIZE_SUPPORTED - if ((png_ptr->transformations & PNG_QUANTIZE) != 0) - { - png_do_quantize(row_info, png_ptr->row_buf + 1, - png_ptr->palette_lookup, png_ptr->quantize_index); - - if (row_info->rowbytes == 0) - png_error(png_ptr, "png_do_quantize returned rowbytes=0"); - } -#endif /* READ_QUANTIZE */ - -#ifdef PNG_READ_EXPAND_16_SUPPORTED - /* Do the expansion now, after all the arithmetic has been done. Notice - * that previous transformations can handle the PNG_EXPAND_16 flag if this - * is efficient (particularly true in the case of gamma correction, where - * better accuracy results faster!) - */ - if ((png_ptr->transformations & PNG_EXPAND_16) != 0) - png_do_expand_16(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED - /* NOTE: moved here in 1.5.4 (from much later in this list.) */ - if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0 && - (png_ptr->mode & PNG_BACKGROUND_IS_GRAY) != 0) - png_do_gray_to_rgb(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_READ_INVERT_SUPPORTED - if ((png_ptr->transformations & PNG_INVERT_MONO) != 0) - png_do_invert(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_READ_INVERT_ALPHA_SUPPORTED - if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0) - png_do_read_invert_alpha(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_READ_SHIFT_SUPPORTED - if ((png_ptr->transformations & PNG_SHIFT) != 0) - png_do_unshift(row_info, png_ptr->row_buf + 1, - &(png_ptr->shift)); -#endif - -#ifdef PNG_READ_PACK_SUPPORTED - if ((png_ptr->transformations & PNG_PACK) != 0) - png_do_unpack(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED - /* Added at libpng-1.5.10 */ - if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && - png_ptr->num_palette_max >= 0) - png_do_check_palette_indexes(png_ptr, row_info); -#endif - -#ifdef PNG_READ_BGR_SUPPORTED - if ((png_ptr->transformations & PNG_BGR) != 0) - png_do_bgr(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_READ_PACKSWAP_SUPPORTED - if ((png_ptr->transformations & PNG_PACKSWAP) != 0) - png_do_packswap(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_READ_FILLER_SUPPORTED - if ((png_ptr->transformations & PNG_FILLER) != 0) - png_do_read_filler(row_info, png_ptr->row_buf + 1, - (png_uint_32)png_ptr->filler, png_ptr->flags); -#endif - -#ifdef PNG_READ_SWAP_ALPHA_SUPPORTED - if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0) - png_do_read_swap_alpha(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_READ_16BIT_SUPPORTED -#ifdef PNG_READ_SWAP_SUPPORTED - if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0) - png_do_swap(row_info, png_ptr->row_buf + 1); -#endif -#endif - -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED - if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0) - { - if (png_ptr->read_user_transform_fn != NULL) - (*(png_ptr->read_user_transform_fn)) /* User read transform function */ - (png_ptr, /* png_ptr */ - row_info, /* row_info: */ - /* png_uint_32 width; width of row */ - /* size_t rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ -#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED - if (png_ptr->user_transform_depth != 0) - row_info->bit_depth = png_ptr->user_transform_depth; - - if (png_ptr->user_transform_channels != 0) - row_info->channels = png_ptr->user_transform_channels; -#endif - row_info->pixel_depth = (png_byte)(row_info->bit_depth * - row_info->channels); - - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_info->width); - } -#endif -} - -#endif /* READ_TRANSFORMS */ -#endif /* READ */ diff --git a/oversampling/WDL/libpng/pngrutil.c b/oversampling/WDL/libpng/pngrutil.c deleted file mode 100644 index d5fa08c..0000000 --- a/oversampling/WDL/libpng/pngrutil.c +++ /dev/null @@ -1,4681 +0,0 @@ - -/* pngrutil.c - utilities to read a PNG file - * - * Copyright (c) 2018 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * - * This file contains routines that are only called from within - * libpng itself during the course of reading an image. - */ - -#include "pngpriv.h" - -#ifdef PNG_READ_SUPPORTED - -png_uint_32 PNGAPI -png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf) -{ - png_uint_32 uval = png_get_uint_32(buf); - - if (uval > PNG_UINT_31_MAX) - png_error(png_ptr, "PNG unsigned integer out of range"); - - return (uval); -} - -#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_READ_cHRM_SUPPORTED) -/* The following is a variation on the above for use with the fixed - * point values used for gAMA and cHRM. Instead of png_error it - * issues a warning and returns (-1) - an invalid value because both - * gAMA and cHRM use *unsigned* integers for fixed point values. - */ -#define PNG_FIXED_ERROR (-1) - -static png_fixed_point /* PRIVATE */ -png_get_fixed_point(png_structrp png_ptr, png_const_bytep buf) -{ - png_uint_32 uval = png_get_uint_32(buf); - - if (uval <= PNG_UINT_31_MAX) - return (png_fixed_point)uval; /* known to be in range */ - - /* The caller can turn off the warning by passing NULL. */ - if (png_ptr != NULL) - png_warning(png_ptr, "PNG fixed point integer out of range"); - - return PNG_FIXED_ERROR; -} -#endif - -#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED -/* NOTE: the read macros will obscure these definitions, so that if - * PNG_USE_READ_MACROS is set the library will not use them internally, - * but the APIs will still be available externally. - * - * The parentheses around "PNGAPI function_name" in the following three - * functions are necessary because they allow the macros to co-exist with - * these (unused but exported) functions. - */ - -/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */ -png_uint_32 (PNGAPI -png_get_uint_32)(png_const_bytep buf) -{ - png_uint_32 uval = - ((png_uint_32)(*(buf )) << 24) + - ((png_uint_32)(*(buf + 1)) << 16) + - ((png_uint_32)(*(buf + 2)) << 8) + - ((png_uint_32)(*(buf + 3)) ) ; - - return uval; -} - -/* Grab a signed 32-bit integer from a buffer in big-endian format. The - * data is stored in the PNG file in two's complement format and there - * is no guarantee that a 'png_int_32' is exactly 32 bits, therefore - * the following code does a two's complement to native conversion. - */ -png_int_32 (PNGAPI -png_get_int_32)(png_const_bytep buf) -{ - png_uint_32 uval = png_get_uint_32(buf); - if ((uval & 0x80000000) == 0) /* non-negative */ - return (png_int_32)uval; - - uval = (uval ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */ - if ((uval & 0x80000000) == 0) /* no overflow */ - return -(png_int_32)uval; - /* The following has to be safe; this function only gets called on PNG data - * and if we get here that data is invalid. 0 is the most safe value and - * if not then an attacker would surely just generate a PNG with 0 instead. - */ - return 0; -} - -/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */ -png_uint_16 (PNGAPI -png_get_uint_16)(png_const_bytep buf) -{ - /* ANSI-C requires an int value to accommodate at least 16 bits so this - * works and allows the compiler not to worry about possible narrowing - * on 32-bit systems. (Pre-ANSI systems did not make integers smaller - * than 16 bits either.) - */ - unsigned int val = - ((unsigned int)(*buf) << 8) + - ((unsigned int)(*(buf + 1))); - - return (png_uint_16)val; -} - -#endif /* READ_INT_FUNCTIONS */ - -/* Read and check the PNG file signature */ -void /* PRIVATE */ -png_read_sig(png_structrp png_ptr, png_inforp info_ptr) -{ - size_t num_checked, num_to_check; - - /* Exit if the user application does not expect a signature. */ - if (png_ptr->sig_bytes >= 8) - return; - - num_checked = png_ptr->sig_bytes; - num_to_check = 8 - num_checked; - -#ifdef PNG_IO_STATE_SUPPORTED - png_ptr->io_state = PNG_IO_READING | PNG_IO_SIGNATURE; -#endif - - /* The signature must be serialized in a single I/O call. */ - png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); - png_ptr->sig_bytes = 8; - - if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check) != 0) - { - if (num_checked < 4 && - png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4)) - png_error(png_ptr, "Not a PNG file"); - else - png_error(png_ptr, "PNG file corrupted by ASCII conversion"); - } - if (num_checked < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; -} - -/* Read the chunk header (length + type name). - * Put the type name into png_ptr->chunk_name, and return the length. - */ -png_uint_32 /* PRIVATE */ -png_read_chunk_header(png_structrp png_ptr) -{ - png_byte buf[8]; - png_uint_32 length; - -#ifdef PNG_IO_STATE_SUPPORTED - png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_HDR; -#endif - - /* Read the length and the chunk name. - * This must be performed in a single I/O call. - */ - png_read_data(png_ptr, buf, 8); - length = png_get_uint_31(png_ptr, buf); - - /* Put the chunk name into png_ptr->chunk_name. */ - png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(buf+4); - - png_debug2(0, "Reading %lx chunk, length = %lu", - (unsigned long)png_ptr->chunk_name, (unsigned long)length); - - /* Reset the crc and run it over the chunk name. */ - png_reset_crc(png_ptr); - png_calculate_crc(png_ptr, buf + 4, 4); - - /* Check to see if chunk name is valid. */ - png_check_chunk_name(png_ptr, png_ptr->chunk_name); - - /* Check for too-large chunk length */ - png_check_chunk_length(png_ptr, length); - -#ifdef PNG_IO_STATE_SUPPORTED - png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA; -#endif - - return length; -} - -/* Read data, and (optionally) run it through the CRC. */ -void /* PRIVATE */ -png_crc_read(png_structrp png_ptr, png_bytep buf, png_uint_32 length) -{ - if (png_ptr == NULL) - return; - - png_read_data(png_ptr, buf, length); - png_calculate_crc(png_ptr, buf, length); -} - -/* Optionally skip data and then check the CRC. Depending on whether we - * are reading an ancillary or critical chunk, and how the program has set - * things up, we may calculate the CRC on the data and print a message. - * Returns '1' if there was a CRC error, '0' otherwise. - */ -int /* PRIVATE */ -png_crc_finish(png_structrp png_ptr, png_uint_32 skip) -{ - /* The size of the local buffer for inflate is a good guess as to a - * reasonable size to use for buffering reads from the application. - */ - while (skip > 0) - { - png_uint_32 len; - png_byte tmpbuf[PNG_INFLATE_BUF_SIZE]; - - len = (sizeof tmpbuf); - if (len > skip) - len = skip; - skip -= len; - - png_crc_read(png_ptr, tmpbuf, len); - } - - if (png_crc_error(png_ptr) != 0) - { - if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0 ? - (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) == 0 : - (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE) != 0) - { - png_chunk_warning(png_ptr, "CRC error"); - } - - else - png_chunk_error(png_ptr, "CRC error"); - - return (1); - } - - return (0); -} - -/* Compare the CRC stored in the PNG file with that calculated by libpng from - * the data it has read thus far. - */ -int /* PRIVATE */ -png_crc_error(png_structrp png_ptr) -{ - png_byte crc_bytes[4]; - png_uint_32 crc; - int need_crc = 1; - - if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0) - { - if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) == - (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN)) - need_crc = 0; - } - - else /* critical */ - { - if ((png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) != 0) - need_crc = 0; - } - -#ifdef PNG_IO_STATE_SUPPORTED - png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_CRC; -#endif - - /* The chunk CRC must be serialized in a single I/O call. */ - png_read_data(png_ptr, crc_bytes, 4); - - if (need_crc != 0) - { - crc = png_get_uint_32(crc_bytes); - return ((int)(crc != png_ptr->crc)); - } - - else - return (0); -} - -#if defined(PNG_READ_iCCP_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) ||\ - defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_sCAL_SUPPORTED) ||\ - defined(PNG_READ_sPLT_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) ||\ - defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_SEQUENTIAL_READ_SUPPORTED) -/* Manage the read buffer; this simply reallocates the buffer if it is not small - * enough (or if it is not allocated). The routine returns a pointer to the - * buffer; if an error occurs and 'warn' is set the routine returns NULL, else - * it will call png_error (via png_malloc) on failure. (warn == 2 means - * 'silent'). - */ -static png_bytep -png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn) -{ - png_bytep buffer = png_ptr->read_buffer; - - if (buffer != NULL && new_size > png_ptr->read_buffer_size) - { - png_ptr->read_buffer = NULL; - png_ptr->read_buffer = NULL; - png_ptr->read_buffer_size = 0; - png_free(png_ptr, buffer); - buffer = NULL; - } - - if (buffer == NULL) - { - buffer = png_voidcast(png_bytep, png_malloc_base(png_ptr, new_size)); - - if (buffer != NULL) - { - memset(buffer, 0, new_size); /* just in case */ - png_ptr->read_buffer = buffer; - png_ptr->read_buffer_size = new_size; - } - - else if (warn < 2) /* else silent */ - { - if (warn != 0) - png_chunk_warning(png_ptr, "insufficient memory to read chunk"); - - else - png_chunk_error(png_ptr, "insufficient memory to read chunk"); - } - } - - return buffer; -} -#endif /* READ_iCCP|iTXt|pCAL|sCAL|sPLT|tEXt|zTXt|SEQUENTIAL_READ */ - -/* png_inflate_claim: claim the zstream for some nefarious purpose that involves - * decompression. Returns Z_OK on success, else a zlib error code. It checks - * the owner but, in final release builds, just issues a warning if some other - * chunk apparently owns the stream. Prior to release it does a png_error. - */ -static int -png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) -{ - if (png_ptr->zowner != 0) - { - char msg[64]; - - PNG_STRING_FROM_CHUNK(msg, png_ptr->zowner); - /* So the message that results is " using zstream"; this is an - * internal error, but is very useful for debugging. i18n requirements - * are minimal. - */ - (void)png_safecat(msg, (sizeof msg), 4, " using zstream"); -#if PNG_RELEASE_BUILD - png_chunk_warning(png_ptr, msg); - png_ptr->zowner = 0; -#else - png_chunk_error(png_ptr, msg); -#endif - } - - /* Implementation note: unlike 'png_deflate_claim' this internal function - * does not take the size of the data as an argument. Some efficiency could - * be gained by using this when it is known *if* the zlib stream itself does - * not record the number; however, this is an illusion: the original writer - * of the PNG may have selected a lower window size, and we really must - * follow that because, for systems with with limited capabilities, we - * would otherwise reject the application's attempts to use a smaller window - * size (zlib doesn't have an interface to say "this or lower"!). - * - * inflateReset2 was added to zlib 1.2.4; before this the window could not be - * reset, therefore it is necessary to always allocate the maximum window - * size with earlier zlibs just in case later compressed chunks need it. - */ - { - int ret; /* zlib return code */ -#if ZLIB_VERNUM >= 0x1240 - int window_bits = 0; - -# if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW) - if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) == - PNG_OPTION_ON) - { - window_bits = 15; - png_ptr->zstream_start = 0; /* fixed window size */ - } - - else - { - png_ptr->zstream_start = 1; - } -# endif - -#endif /* ZLIB_VERNUM >= 0x1240 */ - - /* Set this for safety, just in case the previous owner left pointers to - * memory allocations. - */ - png_ptr->zstream.next_in = NULL; - png_ptr->zstream.avail_in = 0; - png_ptr->zstream.next_out = NULL; - png_ptr->zstream.avail_out = 0; - - if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0) - { -#if ZLIB_VERNUM >= 0x1240 - ret = inflateReset2(&png_ptr->zstream, window_bits); -#else - ret = inflateReset(&png_ptr->zstream); -#endif - } - - else - { -#if ZLIB_VERNUM >= 0x1240 - ret = inflateInit2(&png_ptr->zstream, window_bits); -#else - ret = inflateInit(&png_ptr->zstream); -#endif - - if (ret == Z_OK) - png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED; - } - -#if ZLIB_VERNUM >= 0x1290 && \ - defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_IGNORE_ADLER32) - if (((png_ptr->options >> PNG_IGNORE_ADLER32) & 3) == PNG_OPTION_ON) - /* Turn off validation of the ADLER32 checksum in IDAT chunks */ - ret = inflateValidate(&png_ptr->zstream, 0); -#endif - - if (ret == Z_OK) - png_ptr->zowner = owner; - - else - png_zstream_error(png_ptr, ret); - - return ret; - } - -#ifdef window_bits -# undef window_bits -#endif -} - -#if ZLIB_VERNUM >= 0x1240 -/* Handle the start of the inflate stream if we called inflateInit2(strm,0); - * in this case some zlib versions skip validation of the CINFO field and, in - * certain circumstances, libpng may end up displaying an invalid image, in - * contrast to implementations that call zlib in the normal way (e.g. libpng - * 1.5). - */ -int /* PRIVATE */ -png_zlib_inflate(png_structrp png_ptr, int flush) -{ - if (png_ptr->zstream_start && png_ptr->zstream.avail_in > 0) - { - if ((*png_ptr->zstream.next_in >> 4) > 7) - { - png_ptr->zstream.msg = "invalid window size (libpng)"; - return Z_DATA_ERROR; - } - - png_ptr->zstream_start = 0; - } - - return inflate(&png_ptr->zstream, flush); -} -#endif /* Zlib >= 1.2.4 */ - -#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED -#if defined(PNG_READ_zTXt_SUPPORTED) || defined (PNG_READ_iTXt_SUPPORTED) -/* png_inflate now returns zlib error codes including Z_OK and Z_STREAM_END to - * allow the caller to do multiple calls if required. If the 'finish' flag is - * set Z_FINISH will be passed to the final inflate() call and Z_STREAM_END must - * be returned or there has been a problem, otherwise Z_SYNC_FLUSH is used and - * Z_OK or Z_STREAM_END will be returned on success. - * - * The input and output sizes are updated to the actual amounts of data consumed - * or written, not the amount available (as in a z_stream). The data pointers - * are not changed, so the next input is (data+input_size) and the next - * available output is (output+output_size). - */ -static int -png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish, - /* INPUT: */ png_const_bytep input, png_uint_32p input_size_ptr, - /* OUTPUT: */ png_bytep output, png_alloc_size_t *output_size_ptr) -{ - if (png_ptr->zowner == owner) /* Else not claimed */ - { - int ret; - png_alloc_size_t avail_out = *output_size_ptr; - png_uint_32 avail_in = *input_size_ptr; - - /* zlib can't necessarily handle more than 65535 bytes at once (i.e. it - * can't even necessarily handle 65536 bytes) because the type uInt is - * "16 bits or more". Consequently it is necessary to chunk the input to - * zlib. This code uses ZLIB_IO_MAX, from pngpriv.h, as the maximum (the - * maximum value that can be stored in a uInt.) It is possible to set - * ZLIB_IO_MAX to a lower value in pngpriv.h and this may sometimes have - * a performance advantage, because it reduces the amount of data accessed - * at each step and that may give the OS more time to page it in. - */ - png_ptr->zstream.next_in = PNGZ_INPUT_CAST(input); - /* avail_in and avail_out are set below from 'size' */ - png_ptr->zstream.avail_in = 0; - png_ptr->zstream.avail_out = 0; - - /* Read directly into the output if it is available (this is set to - * a local buffer below if output is NULL). - */ - if (output != NULL) - png_ptr->zstream.next_out = output; - - do - { - uInt avail; - Byte local_buffer[PNG_INFLATE_BUF_SIZE]; - - /* zlib INPUT BUFFER */ - /* The setting of 'avail_in' used to be outside the loop; by setting it - * inside it is possible to chunk the input to zlib and simply rely on - * zlib to advance the 'next_in' pointer. This allows arbitrary - * amounts of data to be passed through zlib at the unavoidable cost of - * requiring a window save (memcpy of up to 32768 output bytes) - * every ZLIB_IO_MAX input bytes. - */ - avail_in += png_ptr->zstream.avail_in; /* not consumed last time */ - - avail = ZLIB_IO_MAX; - - if (avail_in < avail) - avail = (uInt)avail_in; /* safe: < than ZLIB_IO_MAX */ - - avail_in -= avail; - png_ptr->zstream.avail_in = avail; - - /* zlib OUTPUT BUFFER */ - avail_out += png_ptr->zstream.avail_out; /* not written last time */ - - avail = ZLIB_IO_MAX; /* maximum zlib can process */ - - if (output == NULL) - { - /* Reset the output buffer each time round if output is NULL and - * make available the full buffer, up to 'remaining_space' - */ - png_ptr->zstream.next_out = local_buffer; - if ((sizeof local_buffer) < avail) - avail = (sizeof local_buffer); - } - - if (avail_out < avail) - avail = (uInt)avail_out; /* safe: < ZLIB_IO_MAX */ - - png_ptr->zstream.avail_out = avail; - avail_out -= avail; - - /* zlib inflate call */ - /* In fact 'avail_out' may be 0 at this point, that happens at the end - * of the read when the final LZ end code was not passed at the end of - * the previous chunk of input data. Tell zlib if we have reached the - * end of the output buffer. - */ - ret = PNG_INFLATE(png_ptr, avail_out > 0 ? Z_NO_FLUSH : - (finish ? Z_FINISH : Z_SYNC_FLUSH)); - } while (ret == Z_OK); - - /* For safety kill the local buffer pointer now */ - if (output == NULL) - png_ptr->zstream.next_out = NULL; - - /* Claw back the 'size' and 'remaining_space' byte counts. */ - avail_in += png_ptr->zstream.avail_in; - avail_out += png_ptr->zstream.avail_out; - - /* Update the input and output sizes; the updated values are the amount - * consumed or written, effectively the inverse of what zlib uses. - */ - if (avail_out > 0) - *output_size_ptr -= avail_out; - - if (avail_in > 0) - *input_size_ptr -= avail_in; - - /* Ensure png_ptr->zstream.msg is set (even in the success case!) */ - png_zstream_error(png_ptr, ret); - return ret; - } - - else - { - /* This is a bad internal error. The recovery assigns to the zstream msg - * pointer, which is not owned by the caller, but this is safe; it's only - * used on errors! - */ - png_ptr->zstream.msg = PNGZ_MSG_CAST("zstream unclaimed"); - return Z_STREAM_ERROR; - } -} - -/* - * Decompress trailing data in a chunk. The assumption is that read_buffer - * points at an allocated area holding the contents of a chunk with a - * trailing compressed part. What we get back is an allocated area - * holding the original prefix part and an uncompressed version of the - * trailing part (the malloc area passed in is freed). - */ -static int -png_decompress_chunk(png_structrp png_ptr, - png_uint_32 chunklength, png_uint_32 prefix_size, - png_alloc_size_t *newlength /* must be initialized to the maximum! */, - int terminate /*add a '\0' to the end of the uncompressed data*/) -{ - /* TODO: implement different limits for different types of chunk. - * - * The caller supplies *newlength set to the maximum length of the - * uncompressed data, but this routine allocates space for the prefix and - * maybe a '\0' terminator too. We have to assume that 'prefix_size' is - * limited only by the maximum chunk size. - */ - png_alloc_size_t limit = PNG_SIZE_MAX; - -# ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (png_ptr->user_chunk_malloc_max > 0 && - png_ptr->user_chunk_malloc_max < limit) - limit = png_ptr->user_chunk_malloc_max; -# elif PNG_USER_CHUNK_MALLOC_MAX > 0 - if (PNG_USER_CHUNK_MALLOC_MAX < limit) - limit = PNG_USER_CHUNK_MALLOC_MAX; -# endif - - if (limit >= prefix_size + (terminate != 0)) - { - int ret; - - limit -= prefix_size + (terminate != 0); - - if (limit < *newlength) - *newlength = limit; - - /* Now try to claim the stream. */ - ret = png_inflate_claim(png_ptr, png_ptr->chunk_name); - - if (ret == Z_OK) - { - png_uint_32 lzsize = chunklength - prefix_size; - - ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/, - /* input: */ png_ptr->read_buffer + prefix_size, &lzsize, - /* output: */ NULL, newlength); - - if (ret == Z_STREAM_END) - { - /* Use 'inflateReset' here, not 'inflateReset2' because this - * preserves the previously decided window size (otherwise it would - * be necessary to store the previous window size.) In practice - * this doesn't matter anyway, because png_inflate will call inflate - * with Z_FINISH in almost all cases, so the window will not be - * maintained. - */ - if (inflateReset(&png_ptr->zstream) == Z_OK) - { - /* Because of the limit checks above we know that the new, - * expanded, size will fit in a size_t (let alone an - * png_alloc_size_t). Use png_malloc_base here to avoid an - * extra OOM message. - */ - png_alloc_size_t new_size = *newlength; - png_alloc_size_t buffer_size = prefix_size + new_size + - (terminate != 0); - png_bytep text = png_voidcast(png_bytep, png_malloc_base(png_ptr, - buffer_size)); - - if (text != NULL) - { - memset(text, 0, buffer_size); - - ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/, - png_ptr->read_buffer + prefix_size, &lzsize, - text + prefix_size, newlength); - - if (ret == Z_STREAM_END) - { - if (new_size == *newlength) - { - if (terminate != 0) - text[prefix_size + *newlength] = 0; - - if (prefix_size > 0) - memcpy(text, png_ptr->read_buffer, prefix_size); - - { - png_bytep old_ptr = png_ptr->read_buffer; - - png_ptr->read_buffer = text; - png_ptr->read_buffer_size = buffer_size; - text = old_ptr; /* freed below */ - } - } - - else - { - /* The size changed on the second read, there can be no - * guarantee that anything is correct at this point. - * The 'msg' pointer has been set to "unexpected end of - * LZ stream", which is fine, but return an error code - * that the caller won't accept. - */ - ret = PNG_UNEXPECTED_ZLIB_RETURN; - } - } - - else if (ret == Z_OK) - ret = PNG_UNEXPECTED_ZLIB_RETURN; /* for safety */ - - /* Free the text pointer (this is the old read_buffer on - * success) - */ - png_free(png_ptr, text); - - /* This really is very benign, but it's still an error because - * the extra space may otherwise be used as a Trojan Horse. - */ - if (ret == Z_STREAM_END && - chunklength - prefix_size != lzsize) - png_chunk_benign_error(png_ptr, "extra compressed data"); - } - - else - { - /* Out of memory allocating the buffer */ - ret = Z_MEM_ERROR; - png_zstream_error(png_ptr, Z_MEM_ERROR); - } - } - - else - { - /* inflateReset failed, store the error message */ - png_zstream_error(png_ptr, ret); - ret = PNG_UNEXPECTED_ZLIB_RETURN; - } - } - - else if (ret == Z_OK) - ret = PNG_UNEXPECTED_ZLIB_RETURN; - - /* Release the claimed stream */ - png_ptr->zowner = 0; - } - - else /* the claim failed */ if (ret == Z_STREAM_END) /* impossible! */ - ret = PNG_UNEXPECTED_ZLIB_RETURN; - - return ret; - } - - else - { - /* Application/configuration limits exceeded */ - png_zstream_error(png_ptr, Z_MEM_ERROR); - return Z_MEM_ERROR; - } -} -#endif /* READ_zTXt || READ_iTXt */ -#endif /* READ_COMPRESSED_TEXT */ - -#ifdef PNG_READ_iCCP_SUPPORTED -/* Perform a partial read and decompress, producing 'avail_out' bytes and - * reading from the current chunk as required. - */ -static int -png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size, - png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size, - int finish) -{ - if (png_ptr->zowner == png_ptr->chunk_name) - { - int ret; - - /* next_in and avail_in must have been initialized by the caller. */ - png_ptr->zstream.next_out = next_out; - png_ptr->zstream.avail_out = 0; /* set in the loop */ - - do - { - if (png_ptr->zstream.avail_in == 0) - { - if (read_size > *chunk_bytes) - read_size = (uInt)*chunk_bytes; - *chunk_bytes -= read_size; - - if (read_size > 0) - png_crc_read(png_ptr, read_buffer, read_size); - - png_ptr->zstream.next_in = read_buffer; - png_ptr->zstream.avail_in = read_size; - } - - if (png_ptr->zstream.avail_out == 0) - { - uInt avail = ZLIB_IO_MAX; - if (avail > *out_size) - avail = (uInt)*out_size; - *out_size -= avail; - - png_ptr->zstream.avail_out = avail; - } - - /* Use Z_SYNC_FLUSH when there is no more chunk data to ensure that all - * the available output is produced; this allows reading of truncated - * streams. - */ - ret = PNG_INFLATE(png_ptr, *chunk_bytes > 0 ? - Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH)); - } - while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0)); - - *out_size += png_ptr->zstream.avail_out; - png_ptr->zstream.avail_out = 0; /* Should not be required, but is safe */ - - /* Ensure the error message pointer is always set: */ - png_zstream_error(png_ptr, ret); - return ret; - } - - else - { - png_ptr->zstream.msg = PNGZ_MSG_CAST("zstream unclaimed"); - return Z_STREAM_ERROR; - } -} -#endif /* READ_iCCP */ - -/* Read and check the IDHR chunk */ - -void /* PRIVATE */ -png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - png_byte buf[13]; - png_uint_32 width, height; - int bit_depth, color_type, compression_type, filter_type; - int interlace_type; - - png_debug(1, "in png_handle_IHDR"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) != 0) - png_chunk_error(png_ptr, "out of place"); - - /* Check the length */ - if (length != 13) - png_chunk_error(png_ptr, "invalid"); - - png_ptr->mode |= PNG_HAVE_IHDR; - - png_crc_read(png_ptr, buf, 13); - png_crc_finish(png_ptr, 0); - - width = png_get_uint_31(png_ptr, buf); - height = png_get_uint_31(png_ptr, buf + 4); - bit_depth = buf[8]; - color_type = buf[9]; - compression_type = buf[10]; - filter_type = buf[11]; - interlace_type = buf[12]; - - /* Set internal variables */ - png_ptr->width = width; - png_ptr->height = height; - png_ptr->bit_depth = (png_byte)bit_depth; - png_ptr->interlaced = (png_byte)interlace_type; - png_ptr->color_type = (png_byte)color_type; -#ifdef PNG_MNG_FEATURES_SUPPORTED - png_ptr->filter_type = (png_byte)filter_type; -#endif - png_ptr->compression_type = (png_byte)compression_type; - - /* Find number of channels */ - switch (png_ptr->color_type) - { - default: /* invalid, png_set_IHDR calls png_error */ - case PNG_COLOR_TYPE_GRAY: - case PNG_COLOR_TYPE_PALETTE: - png_ptr->channels = 1; - break; - - case PNG_COLOR_TYPE_RGB: - png_ptr->channels = 3; - break; - - case PNG_COLOR_TYPE_GRAY_ALPHA: - png_ptr->channels = 2; - break; - - case PNG_COLOR_TYPE_RGB_ALPHA: - png_ptr->channels = 4; - break; - } - - /* Set up other useful info */ - png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * png_ptr->channels); - png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width); - png_debug1(3, "bit_depth = %d", png_ptr->bit_depth); - png_debug1(3, "channels = %d", png_ptr->channels); - png_debug1(3, "rowbytes = %lu", (unsigned long)png_ptr->rowbytes); - png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, - color_type, interlace_type, compression_type, filter_type); -} - -/* Read and check the palette */ -void /* PRIVATE */ -png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - png_color palette[PNG_MAX_PALETTE_LENGTH]; - int max_palette_length, num, i; -#ifdef PNG_POINTER_INDEXING_SUPPORTED - png_colorp pal_ptr; -#endif - - png_debug(1, "in png_handle_PLTE"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - /* Moved to before the 'after IDAT' check below because otherwise duplicate - * PLTE chunks are potentially ignored (the spec says there shall not be more - * than one PLTE, the error is not treated as benign, so this check trumps - * the requirement that PLTE appears before IDAT.) - */ - else if ((png_ptr->mode & PNG_HAVE_PLTE) != 0) - png_chunk_error(png_ptr, "duplicate"); - - else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) - { - /* This is benign because the non-benign error happened before, when an - * IDAT was encountered in a color-mapped image with no PLTE. - */ - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; - } - - png_ptr->mode |= PNG_HAVE_PLTE; - - if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "ignored in grayscale PNG"); - return; - } - -#ifndef PNG_READ_OPT_PLTE_SUPPORTED - if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) - { - png_crc_finish(png_ptr, length); - return; - } -#endif - - if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3) - { - png_crc_finish(png_ptr, length); - - if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE) - png_chunk_benign_error(png_ptr, "invalid"); - - else - png_chunk_error(png_ptr, "invalid"); - - return; - } - - /* The cast is safe because 'length' is less than 3*PNG_MAX_PALETTE_LENGTH */ - num = (int)length / 3; - - /* If the palette has 256 or fewer entries but is too large for the bit - * depth, we don't issue an error, to preserve the behavior of previous - * libpng versions. We silently truncate the unused extra palette entries - * here. - */ - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - max_palette_length = (1 << png_ptr->bit_depth); - else - max_palette_length = PNG_MAX_PALETTE_LENGTH; - - if (num > max_palette_length) - num = max_palette_length; - -#ifdef PNG_POINTER_INDEXING_SUPPORTED - for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++) - { - png_byte buf[3]; - - png_crc_read(png_ptr, buf, 3); - pal_ptr->red = buf[0]; - pal_ptr->green = buf[1]; - pal_ptr->blue = buf[2]; - } -#else - for (i = 0; i < num; i++) - { - png_byte buf[3]; - - png_crc_read(png_ptr, buf, 3); - /* Don't depend upon png_color being any order */ - palette[i].red = buf[0]; - palette[i].green = buf[1]; - palette[i].blue = buf[2]; - } -#endif - - /* If we actually need the PLTE chunk (ie for a paletted image), we do - * whatever the normal CRC configuration tells us. However, if we - * have an RGB image, the PLTE can be considered ancillary, so - * we will act as though it is. - */ -#ifndef PNG_READ_OPT_PLTE_SUPPORTED - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) -#endif - { - png_crc_finish(png_ptr, (png_uint_32) (length - (unsigned int)num * 3)); - } - -#ifndef PNG_READ_OPT_PLTE_SUPPORTED - else if (png_crc_error(png_ptr) != 0) /* Only if we have a CRC error */ - { - /* If we don't want to use the data from an ancillary chunk, - * we have two options: an error abort, or a warning and we - * ignore the data in this chunk (which should be OK, since - * it's considered ancillary for a RGB or RGBA image). - * - * IMPLEMENTATION NOTE: this is only here because png_crc_finish uses the - * chunk type to determine whether to check the ancillary or the critical - * flags. - */ - if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE) == 0) - { - if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) != 0) - return; - - else - png_chunk_error(png_ptr, "CRC error"); - } - - /* Otherwise, we (optionally) emit a warning and use the chunk. */ - else if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) == 0) - png_chunk_warning(png_ptr, "CRC error"); - } -#endif - - /* TODO: png_set_PLTE has the side effect of setting png_ptr->palette to its - * own copy of the palette. This has the side effect that when png_start_row - * is called (this happens after any call to png_read_update_info) the - * info_ptr palette gets changed. This is extremely unexpected and - * confusing. - * - * Fix this by not sharing the palette in this way. - */ - png_set_PLTE(png_ptr, info_ptr, palette, num); - - /* The three chunks, bKGD, hIST and tRNS *must* appear after PLTE and before - * IDAT. Prior to 1.6.0 this was not checked; instead the code merely - * checked the apparent validity of a tRNS chunk inserted before PLTE on a - * palette PNG. 1.6.0 attempts to rigorously follow the standard and - * therefore does a benign error if the erroneous condition is detected *and* - * cancels the tRNS if the benign error returns. The alternative is to - * amend the standard since it would be rather hypocritical of the standards - * maintainers to ignore it. - */ -#ifdef PNG_READ_tRNS_SUPPORTED - if (png_ptr->num_trans > 0 || - (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0)) - { - /* Cancel this because otherwise it would be used if the transforms - * require it. Don't cancel the 'valid' flag because this would prevent - * detection of duplicate chunks. - */ - png_ptr->num_trans = 0; - - if (info_ptr != NULL) - info_ptr->num_trans = 0; - - png_chunk_benign_error(png_ptr, "tRNS must be after"); - } -#endif - -#ifdef PNG_READ_hIST_SUPPORTED - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) != 0) - png_chunk_benign_error(png_ptr, "hIST must be after"); -#endif - -#ifdef PNG_READ_bKGD_SUPPORTED - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) != 0) - png_chunk_benign_error(png_ptr, "bKGD must be after"); -#endif -} - -void /* PRIVATE */ -png_handle_IEND(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - png_debug(1, "in png_handle_IEND"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0 || - (png_ptr->mode & PNG_HAVE_IDAT) == 0) - png_chunk_error(png_ptr, "out of place"); - - png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND); - - png_crc_finish(png_ptr, length); - - if (length != 0) - png_chunk_benign_error(png_ptr, "invalid"); - - PNG_UNUSED(info_ptr) -} - -#ifdef PNG_READ_gAMA_SUPPORTED -void /* PRIVATE */ -png_handle_gAMA(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - png_fixed_point igamma; - png_byte buf[4]; - - png_debug(1, "in png_handle_gAMA"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; - } - - if (length != 4) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); - return; - } - - png_crc_read(png_ptr, buf, 4); - - if (png_crc_finish(png_ptr, 0) != 0) - return; - - igamma = png_get_fixed_point(NULL, buf); - - png_colorspace_set_gamma(png_ptr, &png_ptr->colorspace, igamma); - png_colorspace_sync(png_ptr, info_ptr); -} -#endif - -#ifdef PNG_READ_sBIT_SUPPORTED -void /* PRIVATE */ -png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - unsigned int truelen, i; - png_byte sample_depth; - png_byte buf[4]; - - png_debug(1, "in png_handle_sBIT"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; - } - - if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - truelen = 3; - sample_depth = 8; - } - - else - { - truelen = png_ptr->channels; - sample_depth = png_ptr->bit_depth; - } - - if (length != truelen || length > 4) - { - png_chunk_benign_error(png_ptr, "invalid"); - png_crc_finish(png_ptr, length); - return; - } - - buf[0] = buf[1] = buf[2] = buf[3] = sample_depth; - png_crc_read(png_ptr, buf, truelen); - - if (png_crc_finish(png_ptr, 0) != 0) - return; - - for (i=0; i sample_depth) - { - png_chunk_benign_error(png_ptr, "invalid"); - return; - } - } - - if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) - { - png_ptr->sig_bit.red = buf[0]; - png_ptr->sig_bit.green = buf[1]; - png_ptr->sig_bit.blue = buf[2]; - png_ptr->sig_bit.alpha = buf[3]; - } - - else - { - png_ptr->sig_bit.gray = buf[0]; - png_ptr->sig_bit.red = buf[0]; - png_ptr->sig_bit.green = buf[0]; - png_ptr->sig_bit.blue = buf[0]; - png_ptr->sig_bit.alpha = buf[1]; - } - - png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit)); -} -#endif - -#ifdef PNG_READ_cHRM_SUPPORTED -void /* PRIVATE */ -png_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - png_byte buf[32]; - png_xy xy; - - png_debug(1, "in png_handle_cHRM"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; - } - - if (length != 32) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); - return; - } - - png_crc_read(png_ptr, buf, 32); - - if (png_crc_finish(png_ptr, 0) != 0) - return; - - xy.whitex = png_get_fixed_point(NULL, buf); - xy.whitey = png_get_fixed_point(NULL, buf + 4); - xy.redx = png_get_fixed_point(NULL, buf + 8); - xy.redy = png_get_fixed_point(NULL, buf + 12); - xy.greenx = png_get_fixed_point(NULL, buf + 16); - xy.greeny = png_get_fixed_point(NULL, buf + 20); - xy.bluex = png_get_fixed_point(NULL, buf + 24); - xy.bluey = png_get_fixed_point(NULL, buf + 28); - - if (xy.whitex == PNG_FIXED_ERROR || - xy.whitey == PNG_FIXED_ERROR || - xy.redx == PNG_FIXED_ERROR || - xy.redy == PNG_FIXED_ERROR || - xy.greenx == PNG_FIXED_ERROR || - xy.greeny == PNG_FIXED_ERROR || - xy.bluex == PNG_FIXED_ERROR || - xy.bluey == PNG_FIXED_ERROR) - { - png_chunk_benign_error(png_ptr, "invalid values"); - return; - } - - /* If a colorspace error has already been output skip this chunk */ - if ((png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0) - return; - - if ((png_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0) - { - png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID; - png_colorspace_sync(png_ptr, info_ptr); - png_chunk_benign_error(png_ptr, "duplicate"); - return; - } - - png_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM; - (void)png_colorspace_set_chromaticities(png_ptr, &png_ptr->colorspace, &xy, - 1/*prefer cHRM values*/); - png_colorspace_sync(png_ptr, info_ptr); -} -#endif - -#ifdef PNG_READ_sRGB_SUPPORTED -void /* PRIVATE */ -png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - png_byte intent; - - png_debug(1, "in png_handle_sRGB"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; - } - - if (length != 1) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); - return; - } - - png_crc_read(png_ptr, &intent, 1); - - if (png_crc_finish(png_ptr, 0) != 0) - return; - - /* If a colorspace error has already been output skip this chunk */ - if ((png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0) - return; - - /* Only one sRGB or iCCP chunk is allowed, use the HAVE_INTENT flag to detect - * this. - */ - if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT) != 0) - { - png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID; - png_colorspace_sync(png_ptr, info_ptr); - png_chunk_benign_error(png_ptr, "too many profiles"); - return; - } - - (void)png_colorspace_set_sRGB(png_ptr, &png_ptr->colorspace, intent); - png_colorspace_sync(png_ptr, info_ptr); -} -#endif /* READ_sRGB */ - -#ifdef PNG_READ_iCCP_SUPPORTED -void /* PRIVATE */ -png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -/* Note: this does not properly handle profiles that are > 64K under DOS */ -{ - png_const_charp errmsg = NULL; /* error message output, or no error */ - int finished = 0; /* crc checked */ - - png_debug(1, "in png_handle_iCCP"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; - } - - /* Consistent with all the above colorspace handling an obviously *invalid* - * chunk is just ignored, so does not invalidate the color space. An - * alternative is to set the 'invalid' flags at the start of this routine - * and only clear them in they were not set before and all the tests pass. - */ - - /* The keyword must be at least one character and there is a - * terminator (0) byte and the compression method byte, and the - * 'zlib' datastream is at least 11 bytes. - */ - if (length < 14) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "too short"); - return; - } - - /* If a colorspace error has already been output skip this chunk */ - if ((png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0) - { - png_crc_finish(png_ptr, length); - return; - } - - /* Only one sRGB or iCCP chunk is allowed, use the HAVE_INTENT flag to detect - * this. - */ - if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT) == 0) - { - uInt read_length, keyword_length; - char keyword[81]; - - /* Find the keyword; the keyword plus separator and compression method - * bytes can be at most 81 characters long. - */ - read_length = 81; /* maximum */ - if (read_length > length) - read_length = (uInt)length; - - png_crc_read(png_ptr, (png_bytep)keyword, read_length); - length -= read_length; - - /* The minimum 'zlib' stream is assumed to be just the 2 byte header, - * 5 bytes minimum 'deflate' stream, and the 4 byte checksum. - */ - if (length < 11) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "too short"); - return; - } - - keyword_length = 0; - while (keyword_length < 80 && keyword_length < read_length && - keyword[keyword_length] != 0) - ++keyword_length; - - /* TODO: make the keyword checking common */ - if (keyword_length >= 1 && keyword_length <= 79) - { - /* We only understand '0' compression - deflate - so if we get a - * different value we can't safely decode the chunk. - */ - if (keyword_length+1 < read_length && - keyword[keyword_length+1] == PNG_COMPRESSION_TYPE_BASE) - { - read_length -= keyword_length+2; - - if (png_inflate_claim(png_ptr, png_iCCP) == Z_OK) - { - Byte profile_header[132]={0}; - Byte local_buffer[PNG_INFLATE_BUF_SIZE]; - png_alloc_size_t size = (sizeof profile_header); - - png_ptr->zstream.next_in = (Bytef*)keyword + (keyword_length+2); - png_ptr->zstream.avail_in = read_length; - (void)png_inflate_read(png_ptr, local_buffer, - (sizeof local_buffer), &length, profile_header, &size, - 0/*finish: don't, because the output is too small*/); - - if (size == 0) - { - /* We have the ICC profile header; do the basic header checks. - */ - png_uint_32 profile_length = png_get_uint_32(profile_header); - - if (png_icc_check_length(png_ptr, &png_ptr->colorspace, - keyword, profile_length) != 0) - { - /* The length is apparently ok, so we can check the 132 - * byte header. - */ - if (png_icc_check_header(png_ptr, &png_ptr->colorspace, - keyword, profile_length, profile_header, - png_ptr->color_type) != 0) - { - /* Now read the tag table; a variable size buffer is - * needed at this point, allocate one for the whole - * profile. The header check has already validated - * that none of this stuff will overflow. - */ - png_uint_32 tag_count = - png_get_uint_32(profile_header + 128); - png_bytep profile = png_read_buffer(png_ptr, - profile_length, 2/*silent*/); - - if (profile != NULL) - { - memcpy(profile, profile_header, - (sizeof profile_header)); - - size = 12 * tag_count; - - (void)png_inflate_read(png_ptr, local_buffer, - (sizeof local_buffer), &length, - profile + (sizeof profile_header), &size, 0); - - /* Still expect a buffer error because we expect - * there to be some tag data! - */ - if (size == 0) - { - if (png_icc_check_tag_table(png_ptr, - &png_ptr->colorspace, keyword, profile_length, - profile) != 0) - { - /* The profile has been validated for basic - * security issues, so read the whole thing in. - */ - size = profile_length - (sizeof profile_header) - - 12 * tag_count; - - (void)png_inflate_read(png_ptr, local_buffer, - (sizeof local_buffer), &length, - profile + (sizeof profile_header) + - 12 * tag_count, &size, 1/*finish*/); - - if (length > 0 && !(png_ptr->flags & - PNG_FLAG_BENIGN_ERRORS_WARN)) - errmsg = "extra compressed data"; - - /* But otherwise allow extra data: */ - else if (size == 0) - { - if (length > 0) - { - /* This can be handled completely, so - * keep going. - */ - png_chunk_warning(png_ptr, - "extra compressed data"); - } - - png_crc_finish(png_ptr, length); - finished = 1; - -# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0 - /* Check for a match against sRGB */ - png_icc_set_sRGB(png_ptr, - &png_ptr->colorspace, profile, - png_ptr->zstream.adler); -# endif - - /* Steal the profile for info_ptr. */ - if (info_ptr != NULL) - { - png_free_data(png_ptr, info_ptr, - PNG_FREE_ICCP, 0); - - info_ptr->iccp_name = png_voidcast(char*, - png_malloc_base(png_ptr, - keyword_length+1)); - if (info_ptr->iccp_name != NULL) - { - memcpy(info_ptr->iccp_name, keyword, - keyword_length+1); - info_ptr->iccp_proflen = - profile_length; - info_ptr->iccp_profile = profile; - png_ptr->read_buffer = NULL; /*steal*/ - info_ptr->free_me |= PNG_FREE_ICCP; - info_ptr->valid |= PNG_INFO_iCCP; - } - - else - { - png_ptr->colorspace.flags |= - PNG_COLORSPACE_INVALID; - errmsg = "out of memory"; - } - } - - /* else the profile remains in the read - * buffer which gets reused for subsequent - * chunks. - */ - - if (info_ptr != NULL) - png_colorspace_sync(png_ptr, info_ptr); - - if (errmsg == NULL) - { - png_ptr->zowner = 0; - return; - } - } - if (errmsg == NULL) - errmsg = png_ptr->zstream.msg; - } - /* else png_icc_check_tag_table output an error */ - } - else /* profile truncated */ - errmsg = png_ptr->zstream.msg; - } - - else - errmsg = "out of memory"; - } - - /* else png_icc_check_header output an error */ - } - - /* else png_icc_check_length output an error */ - } - - else /* profile truncated */ - errmsg = png_ptr->zstream.msg; - - /* Release the stream */ - png_ptr->zowner = 0; - } - - else /* png_inflate_claim failed */ - errmsg = png_ptr->zstream.msg; - } - - else - errmsg = "bad compression method"; /* or missing */ - } - - else - errmsg = "bad keyword"; - } - - else - errmsg = "too many profiles"; - - /* Failure: the reason is in 'errmsg' */ - if (finished == 0) - png_crc_finish(png_ptr, length); - - png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID; - png_colorspace_sync(png_ptr, info_ptr); - if (errmsg != NULL) /* else already output */ - png_chunk_benign_error(png_ptr, errmsg); -} -#endif /* READ_iCCP */ - -#ifdef PNG_READ_sPLT_SUPPORTED -void /* PRIVATE */ -png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -/* Note: this does not properly handle chunks that are > 64K under DOS */ -{ - png_bytep entry_start, buffer; - png_sPLT_t new_palette; - png_sPLT_entryp pp; - png_uint_32 data_length; - int entry_size, i; - png_uint_32 skip = 0; - png_uint_32 dl; - size_t max_dl; - - png_debug(1, "in png_handle_sPLT"); - -#ifdef PNG_USER_LIMITS_SUPPORTED - if (png_ptr->user_chunk_cache_max != 0) - { - if (png_ptr->user_chunk_cache_max == 1) - { - png_crc_finish(png_ptr, length); - return; - } - - if (--png_ptr->user_chunk_cache_max == 1) - { - png_warning(png_ptr, "No space in chunk cache for sPLT"); - png_crc_finish(png_ptr, length); - return; - } - } -#endif - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; - } - -#ifdef PNG_MAX_MALLOC_64K - if (length > 65535U) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "too large to fit in memory"); - return; - } -#endif - - buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/); - if (buffer == NULL) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of memory"); - return; - } - - - /* WARNING: this may break if size_t is less than 32 bits; it is assumed - * that the PNG_MAX_MALLOC_64K test is enabled in this case, but this is a - * potential breakage point if the types in pngconf.h aren't exactly right. - */ - png_crc_read(png_ptr, buffer, length); - - if (png_crc_finish(png_ptr, skip) != 0) - return; - - buffer[length] = 0; - - for (entry_start = buffer; *entry_start; entry_start++) - /* Empty loop to find end of name */ ; - - ++entry_start; - - /* A sample depth should follow the separator, and we should be on it */ - if (length < 2U || entry_start > buffer + (length - 2U)) - { - png_warning(png_ptr, "malformed sPLT chunk"); - return; - } - - new_palette.depth = *entry_start++; - entry_size = (new_palette.depth == 8 ? 6 : 10); - /* This must fit in a png_uint_32 because it is derived from the original - * chunk data length. - */ - data_length = length - (png_uint_32)(entry_start - buffer); - - /* Integrity-check the data length */ - if ((data_length % (unsigned int)entry_size) != 0) - { - png_warning(png_ptr, "sPLT chunk has bad length"); - return; - } - - dl = (png_uint_32)(data_length / (unsigned int)entry_size); - max_dl = PNG_SIZE_MAX / (sizeof (png_sPLT_entry)); - - if (dl > max_dl) - { - png_warning(png_ptr, "sPLT chunk too long"); - return; - } - - new_palette.nentries = (png_int_32)(data_length / (unsigned int)entry_size); - - new_palette.entries = (png_sPLT_entryp)png_malloc_warn(png_ptr, - (png_alloc_size_t) new_palette.nentries * (sizeof (png_sPLT_entry))); - - if (new_palette.entries == NULL) - { - png_warning(png_ptr, "sPLT chunk requires too much memory"); - return; - } - -#ifdef PNG_POINTER_INDEXING_SUPPORTED - for (i = 0; i < new_palette.nentries; i++) - { - pp = new_palette.entries + i; - - if (new_palette.depth == 8) - { - pp->red = *entry_start++; - pp->green = *entry_start++; - pp->blue = *entry_start++; - pp->alpha = *entry_start++; - } - - else - { - pp->red = png_get_uint_16(entry_start); entry_start += 2; - pp->green = png_get_uint_16(entry_start); entry_start += 2; - pp->blue = png_get_uint_16(entry_start); entry_start += 2; - pp->alpha = png_get_uint_16(entry_start); entry_start += 2; - } - - pp->frequency = png_get_uint_16(entry_start); entry_start += 2; - } -#else - pp = new_palette.entries; - - for (i = 0; i < new_palette.nentries; i++) - { - - if (new_palette.depth == 8) - { - pp[i].red = *entry_start++; - pp[i].green = *entry_start++; - pp[i].blue = *entry_start++; - pp[i].alpha = *entry_start++; - } - - else - { - pp[i].red = png_get_uint_16(entry_start); entry_start += 2; - pp[i].green = png_get_uint_16(entry_start); entry_start += 2; - pp[i].blue = png_get_uint_16(entry_start); entry_start += 2; - pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2; - } - - pp[i].frequency = png_get_uint_16(entry_start); entry_start += 2; - } -#endif - - /* Discard all chunk data except the name and stash that */ - new_palette.name = (png_charp)buffer; - - png_set_sPLT(png_ptr, info_ptr, &new_palette, 1); - - png_free(png_ptr, new_palette.entries); -} -#endif /* READ_sPLT */ - -#ifdef PNG_READ_tRNS_SUPPORTED -void /* PRIVATE */ -png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - png_byte readbuf[PNG_MAX_PALETTE_LENGTH]; - - png_debug(1, "in png_handle_tRNS"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; - } - - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - png_byte buf[2]; - - if (length != 2) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); - return; - } - - png_crc_read(png_ptr, buf, 2); - png_ptr->num_trans = 1; - png_ptr->trans_color.gray = png_get_uint_16(buf); - } - - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - png_byte buf[6]; - - if (length != 6) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); - return; - } - - png_crc_read(png_ptr, buf, length); - png_ptr->num_trans = 1; - png_ptr->trans_color.red = png_get_uint_16(buf); - png_ptr->trans_color.green = png_get_uint_16(buf + 2); - png_ptr->trans_color.blue = png_get_uint_16(buf + 4); - } - - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if ((png_ptr->mode & PNG_HAVE_PLTE) == 0) - { - /* TODO: is this actually an error in the ISO spec? */ - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; - } - - if (length > (unsigned int) png_ptr->num_palette || - length > (unsigned int) PNG_MAX_PALETTE_LENGTH || - length == 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); - return; - } - - png_crc_read(png_ptr, readbuf, length); - png_ptr->num_trans = (png_uint_16)length; - } - - else - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid with alpha channel"); - return; - } - - if (png_crc_finish(png_ptr, 0) != 0) - { - png_ptr->num_trans = 0; - return; - } - - /* TODO: this is a horrible side effect in the palette case because the - * png_struct ends up with a pointer to the tRNS buffer owned by the - * png_info. Fix this. - */ - png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans, - &(png_ptr->trans_color)); -} -#endif - -#ifdef PNG_READ_bKGD_SUPPORTED -void /* PRIVATE */ -png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - unsigned int truelen; - png_byte buf[6]; - png_color_16 background; - - png_debug(1, "in png_handle_bKGD"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0 || - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - (png_ptr->mode & PNG_HAVE_PLTE) == 0)) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; - } - - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); - return; - } - - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - truelen = 1; - - else if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) - truelen = 6; - - else - truelen = 2; - - if (length != truelen) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); - return; - } - - png_crc_read(png_ptr, buf, truelen); - - if (png_crc_finish(png_ptr, 0) != 0) - return; - - /* We convert the index value into RGB components so that we can allow - * arbitrary RGB values for background when we have transparency, and - * so it is easy to determine the RGB values of the background color - * from the info_ptr struct. - */ - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - background.index = buf[0]; - - if (info_ptr != NULL && info_ptr->num_palette != 0) - { - if (buf[0] >= info_ptr->num_palette) - { - png_chunk_benign_error(png_ptr, "invalid index"); - return; - } - - background.red = (png_uint_16)png_ptr->palette[buf[0]].red; - background.green = (png_uint_16)png_ptr->palette[buf[0]].green; - background.blue = (png_uint_16)png_ptr->palette[buf[0]].blue; - } - - else - background.red = background.green = background.blue = 0; - - background.gray = 0; - } - - else if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) /* GRAY */ - { - if (png_ptr->bit_depth <= 8) - { - if (buf[0] != 0 || buf[1] >= (unsigned int)(1 << png_ptr->bit_depth)) - { - png_chunk_benign_error(png_ptr, "invalid gray level"); - return; - } - } - - background.index = 0; - background.red = - background.green = - background.blue = - background.gray = png_get_uint_16(buf); - } - - else - { - if (png_ptr->bit_depth <= 8) - { - if (buf[0] != 0 || buf[2] != 0 || buf[4] != 0) - { - png_chunk_benign_error(png_ptr, "invalid color"); - return; - } - } - - background.index = 0; - background.red = png_get_uint_16(buf); - background.green = png_get_uint_16(buf + 2); - background.blue = png_get_uint_16(buf + 4); - background.gray = 0; - } - - png_set_bKGD(png_ptr, info_ptr, &background); -} -#endif - -#ifdef PNG_READ_eXIf_SUPPORTED -void /* PRIVATE */ -png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - unsigned int i; - - png_debug(1, "in png_handle_eXIf"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - if (length < 2) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "too short"); - return; - } - - else if (info_ptr == NULL || (info_ptr->valid & PNG_INFO_eXIf) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); - return; - } - - info_ptr->free_me |= PNG_FREE_EXIF; - - info_ptr->eXIf_buf = png_voidcast(png_bytep, - png_malloc_warn(png_ptr, length)); - - if (info_ptr->eXIf_buf == NULL) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of memory"); - return; - } - - for (i = 0; i < length; i++) - { - png_byte buf[1]; - png_crc_read(png_ptr, buf, 1); - info_ptr->eXIf_buf[i] = buf[0]; - if (i == 1 && buf[0] != 'M' && buf[0] != 'I' - && info_ptr->eXIf_buf[0] != buf[0]) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "incorrect byte-order specifier"); - png_free(png_ptr, info_ptr->eXIf_buf); - info_ptr->eXIf_buf = NULL; - return; - } - } - - if (png_crc_finish(png_ptr, 0) != 0) - return; - - png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf); - - png_free(png_ptr, info_ptr->eXIf_buf); - info_ptr->eXIf_buf = NULL; -} -#endif - -#ifdef PNG_READ_hIST_SUPPORTED -void /* PRIVATE */ -png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - unsigned int num, i; - png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH]; - - png_debug(1, "in png_handle_hIST"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0 || - (png_ptr->mode & PNG_HAVE_PLTE) == 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; - } - - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); - return; - } - - num = length / 2 ; - - if (num != (unsigned int) png_ptr->num_palette || - num > (unsigned int) PNG_MAX_PALETTE_LENGTH) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); - return; - } - - for (i = 0; i < num; i++) - { - png_byte buf[2]; - - png_crc_read(png_ptr, buf, 2); - readbuf[i] = png_get_uint_16(buf); - } - - if (png_crc_finish(png_ptr, 0) != 0) - return; - - png_set_hIST(png_ptr, info_ptr, readbuf); -} -#endif - -#ifdef PNG_READ_pHYs_SUPPORTED -void /* PRIVATE */ -png_handle_pHYs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - png_byte buf[9]; - png_uint_32 res_x, res_y; - int unit_type; - - png_debug(1, "in png_handle_pHYs"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; - } - - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); - return; - } - - if (length != 9) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); - return; - } - - png_crc_read(png_ptr, buf, 9); - - if (png_crc_finish(png_ptr, 0) != 0) - return; - - res_x = png_get_uint_32(buf); - res_y = png_get_uint_32(buf + 4); - unit_type = buf[8]; - png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type); -} -#endif - -#ifdef PNG_READ_oFFs_SUPPORTED -void /* PRIVATE */ -png_handle_oFFs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - png_byte buf[9]; - png_int_32 offset_x, offset_y; - int unit_type; - - png_debug(1, "in png_handle_oFFs"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; - } - - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); - return; - } - - if (length != 9) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); - return; - } - - png_crc_read(png_ptr, buf, 9); - - if (png_crc_finish(png_ptr, 0) != 0) - return; - - offset_x = png_get_int_32(buf); - offset_y = png_get_int_32(buf + 4); - unit_type = buf[8]; - png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type); -} -#endif - -#ifdef PNG_READ_pCAL_SUPPORTED -/* Read the pCAL chunk (described in the PNG Extensions document) */ -void /* PRIVATE */ -png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - png_int_32 X0, X1; - png_byte type, nparams; - png_bytep buffer, buf, units, endptr; - png_charpp params; - int i; - - png_debug(1, "in png_handle_pCAL"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; - } - - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); - return; - } - - png_debug1(2, "Allocating and reading pCAL chunk data (%u bytes)", - length + 1); - - buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/); - - if (buffer == NULL) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of memory"); - return; - } - - png_crc_read(png_ptr, buffer, length); - - if (png_crc_finish(png_ptr, 0) != 0) - return; - - buffer[length] = 0; /* Null terminate the last string */ - - png_debug(3, "Finding end of pCAL purpose string"); - for (buf = buffer; *buf; buf++) - /* Empty loop */ ; - - endptr = buffer + length; - - /* We need to have at least 12 bytes after the purpose string - * in order to get the parameter information. - */ - if (endptr - buf <= 12) - { - png_chunk_benign_error(png_ptr, "invalid"); - return; - } - - png_debug(3, "Reading pCAL X0, X1, type, nparams, and units"); - X0 = png_get_int_32((png_bytep)buf+1); - X1 = png_get_int_32((png_bytep)buf+5); - type = buf[9]; - nparams = buf[10]; - units = buf + 11; - - png_debug(3, "Checking pCAL equation type and number of parameters"); - /* Check that we have the right number of parameters for known - * equation types. - */ - if ((type == PNG_EQUATION_LINEAR && nparams != 2) || - (type == PNG_EQUATION_BASE_E && nparams != 3) || - (type == PNG_EQUATION_ARBITRARY && nparams != 3) || - (type == PNG_EQUATION_HYPERBOLIC && nparams != 4)) - { - png_chunk_benign_error(png_ptr, "invalid parameter count"); - return; - } - - else if (type >= PNG_EQUATION_LAST) - { - png_chunk_benign_error(png_ptr, "unrecognized equation type"); - } - - for (buf = units; *buf; buf++) - /* Empty loop to move past the units string. */ ; - - png_debug(3, "Allocating pCAL parameters array"); - - params = png_voidcast(png_charpp, png_malloc_warn(png_ptr, - nparams * (sizeof (png_charp)))); - - if (params == NULL) - { - png_chunk_benign_error(png_ptr, "out of memory"); - return; - } - - /* Get pointers to the start of each parameter string. */ - for (i = 0; i < nparams; i++) - { - buf++; /* Skip the null string terminator from previous parameter. */ - - png_debug1(3, "Reading pCAL parameter %d", i); - - for (params[i] = (png_charp)buf; buf <= endptr && *buf != 0; buf++) - /* Empty loop to move past each parameter string */ ; - - /* Make sure we haven't run out of data yet */ - if (buf > endptr) - { - png_free(png_ptr, params); - png_chunk_benign_error(png_ptr, "invalid data"); - return; - } - } - - png_set_pCAL(png_ptr, info_ptr, (png_charp)buffer, X0, X1, type, nparams, - (png_charp)units, params); - - png_free(png_ptr, params); -} -#endif - -#ifdef PNG_READ_sCAL_SUPPORTED -/* Read the sCAL chunk */ -void /* PRIVATE */ -png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - png_bytep buffer; - size_t i; - int state; - - png_debug(1, "in png_handle_sCAL"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of place"); - return; - } - - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); - return; - } - - /* Need unit type, width, \0, height: minimum 4 bytes */ - else if (length < 4) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); - return; - } - - png_debug1(2, "Allocating and reading sCAL chunk data (%u bytes)", - length + 1); - - buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/); - - if (buffer == NULL) - { - png_chunk_benign_error(png_ptr, "out of memory"); - png_crc_finish(png_ptr, length); - return; - } - - png_crc_read(png_ptr, buffer, length); - buffer[length] = 0; /* Null terminate the last string */ - - if (png_crc_finish(png_ptr, 0) != 0) - return; - - /* Validate the unit. */ - if (buffer[0] != 1 && buffer[0] != 2) - { - png_chunk_benign_error(png_ptr, "invalid unit"); - return; - } - - /* Validate the ASCII numbers, need two ASCII numbers separated by - * a '\0' and they need to fit exactly in the chunk data. - */ - i = 1; - state = 0; - - if (png_check_fp_number((png_const_charp)buffer, length, &state, &i) == 0 || - i >= length || buffer[i++] != 0) - png_chunk_benign_error(png_ptr, "bad width format"); - - else if (PNG_FP_IS_POSITIVE(state) == 0) - png_chunk_benign_error(png_ptr, "non-positive width"); - - else - { - size_t heighti = i; - - state = 0; - if (png_check_fp_number((png_const_charp)buffer, length, - &state, &i) == 0 || i != length) - png_chunk_benign_error(png_ptr, "bad height format"); - - else if (PNG_FP_IS_POSITIVE(state) == 0) - png_chunk_benign_error(png_ptr, "non-positive height"); - - else - /* This is the (only) success case. */ - png_set_sCAL_s(png_ptr, info_ptr, buffer[0], - (png_charp)buffer+1, (png_charp)buffer+heighti); - } -} -#endif - -#ifdef PNG_READ_tIME_SUPPORTED -void /* PRIVATE */ -png_handle_tIME(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - png_byte buf[7]; - png_time mod_time; - - png_debug(1, "in png_handle_tIME"); - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) != 0) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "duplicate"); - return; - } - - if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) - png_ptr->mode |= PNG_AFTER_IDAT; - - if (length != 7) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "invalid"); - return; - } - - png_crc_read(png_ptr, buf, 7); - - if (png_crc_finish(png_ptr, 0) != 0) - return; - - mod_time.second = buf[6]; - mod_time.minute = buf[5]; - mod_time.hour = buf[4]; - mod_time.day = buf[3]; - mod_time.month = buf[2]; - mod_time.year = png_get_uint_16(buf); - - png_set_tIME(png_ptr, info_ptr, &mod_time); -} -#endif - -#ifdef PNG_READ_tEXt_SUPPORTED -/* Note: this does not properly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - png_text text_info; - png_bytep buffer; - png_charp key; - png_charp text; - png_uint_32 skip = 0; - - png_debug(1, "in png_handle_tEXt"); - -#ifdef PNG_USER_LIMITS_SUPPORTED - if (png_ptr->user_chunk_cache_max != 0) - { - if (png_ptr->user_chunk_cache_max == 1) - { - png_crc_finish(png_ptr, length); - return; - } - - if (--png_ptr->user_chunk_cache_max == 1) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "no space in chunk cache"); - return; - } - } -#endif - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) - png_ptr->mode |= PNG_AFTER_IDAT; - -#ifdef PNG_MAX_MALLOC_64K - if (length > 65535U) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "too large to fit in memory"); - return; - } -#endif - - buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/); - - if (buffer == NULL) - { - png_chunk_benign_error(png_ptr, "out of memory"); - return; - } - - png_crc_read(png_ptr, buffer, length); - - if (png_crc_finish(png_ptr, skip) != 0) - return; - - key = (png_charp)buffer; - key[length] = 0; - - for (text = key; *text; text++) - /* Empty loop to find end of key */ ; - - if (text != key + length) - text++; - - text_info.compression = PNG_TEXT_COMPRESSION_NONE; - text_info.key = key; - text_info.lang = NULL; - text_info.lang_key = NULL; - text_info.itxt_length = 0; - text_info.text = text; - text_info.text_length = strlen(text); - - if (png_set_text_2(png_ptr, info_ptr, &text_info, 1) != 0) - png_warning(png_ptr, "Insufficient memory to process text chunk"); -} -#endif - -#ifdef PNG_READ_zTXt_SUPPORTED -/* Note: this does not correctly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - png_const_charp errmsg = NULL; - png_bytep buffer; - png_uint_32 keyword_length; - - png_debug(1, "in png_handle_zTXt"); - -#ifdef PNG_USER_LIMITS_SUPPORTED - if (png_ptr->user_chunk_cache_max != 0) - { - if (png_ptr->user_chunk_cache_max == 1) - { - png_crc_finish(png_ptr, length); - return; - } - - if (--png_ptr->user_chunk_cache_max == 1) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "no space in chunk cache"); - return; - } - } -#endif - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) - png_ptr->mode |= PNG_AFTER_IDAT; - - /* Note, "length" is sufficient here; we won't be adding - * a null terminator later. - */ - buffer = png_read_buffer(png_ptr, length, 2/*silent*/); - - if (buffer == NULL) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of memory"); - return; - } - - png_crc_read(png_ptr, buffer, length); - - if (png_crc_finish(png_ptr, 0) != 0) - return; - - /* TODO: also check that the keyword contents match the spec! */ - for (keyword_length = 0; - keyword_length < length && buffer[keyword_length] != 0; - ++keyword_length) - /* Empty loop to find end of name */ ; - - if (keyword_length > 79 || keyword_length < 1) - errmsg = "bad keyword"; - - /* zTXt must have some LZ data after the keyword, although it may expand to - * zero bytes; we need a '\0' at the end of the keyword, the compression type - * then the LZ data: - */ - else if (keyword_length + 3 > length) - errmsg = "truncated"; - - else if (buffer[keyword_length+1] != PNG_COMPRESSION_TYPE_BASE) - errmsg = "unknown compression type"; - - else - { - png_alloc_size_t uncompressed_length = PNG_SIZE_MAX; - - /* TODO: at present png_decompress_chunk imposes a single application - * level memory limit, this should be split to different values for iCCP - * and text chunks. - */ - if (png_decompress_chunk(png_ptr, length, keyword_length+2, - &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) - { - png_text text; - - if (png_ptr->read_buffer == NULL) - errmsg="Read failure in png_handle_zTXt"; - else - { - /* It worked; png_ptr->read_buffer now looks like a tEXt chunk - * except for the extra compression type byte and the fact that - * it isn't necessarily '\0' terminated. - */ - buffer = png_ptr->read_buffer; - buffer[uncompressed_length+(keyword_length+2)] = 0; - - text.compression = PNG_TEXT_COMPRESSION_zTXt; - text.key = (png_charp)buffer; - text.text = (png_charp)(buffer + keyword_length+2); - text.text_length = uncompressed_length; - text.itxt_length = 0; - text.lang = NULL; - text.lang_key = NULL; - - if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0) - errmsg = "insufficient memory"; - } - } - - else - errmsg = png_ptr->zstream.msg; - } - - if (errmsg != NULL) - png_chunk_benign_error(png_ptr, errmsg); -} -#endif - -#ifdef PNG_READ_iTXt_SUPPORTED -/* Note: this does not correctly handle chunks that are > 64K under DOS */ -void /* PRIVATE */ -png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) -{ - png_const_charp errmsg = NULL; - png_bytep buffer; - png_uint_32 prefix_length; - - png_debug(1, "in png_handle_iTXt"); - -#ifdef PNG_USER_LIMITS_SUPPORTED - if (png_ptr->user_chunk_cache_max != 0) - { - if (png_ptr->user_chunk_cache_max == 1) - { - png_crc_finish(png_ptr, length); - return; - } - - if (--png_ptr->user_chunk_cache_max == 1) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "no space in chunk cache"); - return; - } - } -#endif - - if ((png_ptr->mode & PNG_HAVE_IHDR) == 0) - png_chunk_error(png_ptr, "missing IHDR"); - - if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) - png_ptr->mode |= PNG_AFTER_IDAT; - - buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/); - - if (buffer == NULL) - { - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "out of memory"); - return; - } - - png_crc_read(png_ptr, buffer, length); - - if (png_crc_finish(png_ptr, 0) != 0) - return; - - /* First the keyword. */ - for (prefix_length=0; - prefix_length < length && buffer[prefix_length] != 0; - ++prefix_length) - /* Empty loop */ ; - - /* Perform a basic check on the keyword length here. */ - if (prefix_length > 79 || prefix_length < 1) - errmsg = "bad keyword"; - - /* Expect keyword, compression flag, compression type, language, translated - * keyword (both may be empty but are 0 terminated) then the text, which may - * be empty. - */ - else if (prefix_length + 5 > length) - errmsg = "truncated"; - - else if (buffer[prefix_length+1] == 0 || - (buffer[prefix_length+1] == 1 && - buffer[prefix_length+2] == PNG_COMPRESSION_TYPE_BASE)) - { - int compressed = buffer[prefix_length+1] != 0; - png_uint_32 language_offset, translated_keyword_offset; - png_alloc_size_t uncompressed_length = 0; - - /* Now the language tag */ - prefix_length += 3; - language_offset = prefix_length; - - for (; prefix_length < length && buffer[prefix_length] != 0; - ++prefix_length) - /* Empty loop */ ; - - /* WARNING: the length may be invalid here, this is checked below. */ - translated_keyword_offset = ++prefix_length; - - for (; prefix_length < length && buffer[prefix_length] != 0; - ++prefix_length) - /* Empty loop */ ; - - /* prefix_length should now be at the trailing '\0' of the translated - * keyword, but it may already be over the end. None of this arithmetic - * can overflow because chunks are at most 2^31 bytes long, but on 16-bit - * systems the available allocation may overflow. - */ - ++prefix_length; - - if (compressed == 0 && prefix_length <= length) - uncompressed_length = length - prefix_length; - - else if (compressed != 0 && prefix_length < length) - { - uncompressed_length = PNG_SIZE_MAX; - - /* TODO: at present png_decompress_chunk imposes a single application - * level memory limit, this should be split to different values for - * iCCP and text chunks. - */ - if (png_decompress_chunk(png_ptr, length, prefix_length, - &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) - buffer = png_ptr->read_buffer; - - else - errmsg = png_ptr->zstream.msg; - } - - else - errmsg = "truncated"; - - if (errmsg == NULL) - { - png_text text; - - buffer[uncompressed_length+prefix_length] = 0; - - if (compressed == 0) - text.compression = PNG_ITXT_COMPRESSION_NONE; - - else - text.compression = PNG_ITXT_COMPRESSION_zTXt; - - text.key = (png_charp)buffer; - text.lang = (png_charp)buffer + language_offset; - text.lang_key = (png_charp)buffer + translated_keyword_offset; - text.text = (png_charp)buffer + prefix_length; - text.text_length = 0; - text.itxt_length = uncompressed_length; - - if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0) - errmsg = "insufficient memory"; - } - } - - else - errmsg = "bad compression info"; - - if (errmsg != NULL) - png_chunk_benign_error(png_ptr, errmsg); -} -#endif - -#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -/* Utility function for png_handle_unknown; set up png_ptr::unknown_chunk */ -static int -png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length) -{ - png_alloc_size_t limit = PNG_SIZE_MAX; - - if (png_ptr->unknown_chunk.data != NULL) - { - png_free(png_ptr, png_ptr->unknown_chunk.data); - png_ptr->unknown_chunk.data = NULL; - } - -# ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (png_ptr->user_chunk_malloc_max > 0 && - png_ptr->user_chunk_malloc_max < limit) - limit = png_ptr->user_chunk_malloc_max; - -# elif PNG_USER_CHUNK_MALLOC_MAX > 0 - if (PNG_USER_CHUNK_MALLOC_MAX < limit) - limit = PNG_USER_CHUNK_MALLOC_MAX; -# endif - - if (length <= limit) - { - PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name); - /* The following is safe because of the PNG_SIZE_MAX init above */ - png_ptr->unknown_chunk.size = (size_t)length/*SAFE*/; - /* 'mode' is a flag array, only the bottom four bits matter here */ - png_ptr->unknown_chunk.location = (png_byte)png_ptr->mode/*SAFE*/; - - if (length == 0) - png_ptr->unknown_chunk.data = NULL; - - else - { - /* Do a 'warn' here - it is handled below. */ - png_ptr->unknown_chunk.data = png_voidcast(png_bytep, - png_malloc_warn(png_ptr, length)); - } - } - - if (png_ptr->unknown_chunk.data == NULL && length > 0) - { - /* This is benign because we clean up correctly */ - png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "unknown chunk exceeds memory limits"); - return 0; - } - - else - { - if (length > 0) - png_crc_read(png_ptr, png_ptr->unknown_chunk.data, length); - png_crc_finish(png_ptr, 0); - return 1; - } -} -#endif /* READ_UNKNOWN_CHUNKS */ - -/* Handle an unknown, or known but disabled, chunk */ -void /* PRIVATE */ -png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, - png_uint_32 length, int keep) -{ - int handled = 0; /* the chunk was handled */ - - png_debug(1, "in png_handle_unknown"); - -#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED - /* NOTE: this code is based on the code in libpng-1.4.12 except for fixing - * the bug which meant that setting a non-default behavior for a specific - * chunk would be ignored (the default was always used unless a user - * callback was installed). - * - * 'keep' is the value from the png_chunk_unknown_handling, the setting for - * this specific chunk_name, if PNG_HANDLE_AS_UNKNOWN_SUPPORTED, if not it - * will always be PNG_HANDLE_CHUNK_AS_DEFAULT and it needs to be set here. - * This is just an optimization to avoid multiple calls to the lookup - * function. - */ -# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED - keep = png_chunk_unknown_handling(png_ptr, png_ptr->chunk_name); -# endif -# endif - - /* One of the following methods will read the chunk or skip it (at least one - * of these is always defined because this is the only way to switch on - * PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - */ -# ifdef PNG_READ_USER_CHUNKS_SUPPORTED - /* The user callback takes precedence over the chunk keep value, but the - * keep value is still required to validate a save of a critical chunk. - */ - if (png_ptr->read_user_chunk_fn != NULL) - { - if (png_cache_unknown_chunk(png_ptr, length) != 0) - { - /* Callback to user unknown chunk handler */ - int ret = (*(png_ptr->read_user_chunk_fn))(png_ptr, - &png_ptr->unknown_chunk); - - /* ret is: - * negative: An error occurred; png_chunk_error will be called. - * zero: The chunk was not handled, the chunk will be discarded - * unless png_set_keep_unknown_chunks has been used to set - * a 'keep' behavior for this particular chunk, in which - * case that will be used. A critical chunk will cause an - * error at this point unless it is to be saved. - * positive: The chunk was handled, libpng will ignore/discard it. - */ - if (ret < 0) - png_chunk_error(png_ptr, "error in user chunk"); - - else if (ret == 0) - { - /* If the keep value is 'default' or 'never' override it, but - * still error out on critical chunks unless the keep value is - * 'always' While this is weird it is the behavior in 1.4.12. - * A possible improvement would be to obey the value set for the - * chunk, but this would be an API change that would probably - * damage some applications. - * - * The png_app_warning below catches the case that matters, where - * the application has not set specific save or ignore for this - * chunk or global save or ignore. - */ - if (keep < PNG_HANDLE_CHUNK_IF_SAFE) - { -# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED - if (png_ptr->unknown_default < PNG_HANDLE_CHUNK_IF_SAFE) - { - png_chunk_warning(png_ptr, "Saving unknown chunk:"); - png_app_warning(png_ptr, - "forcing save of an unhandled chunk;" - " please call png_set_keep_unknown_chunks"); - /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */ - } -# endif - keep = PNG_HANDLE_CHUNK_IF_SAFE; - } - } - - else /* chunk was handled */ - { - handled = 1; - /* Critical chunks can be safely discarded at this point. */ - keep = PNG_HANDLE_CHUNK_NEVER; - } - } - - else - keep = PNG_HANDLE_CHUNK_NEVER; /* insufficient memory */ - } - - else - /* Use the SAVE_UNKNOWN_CHUNKS code or skip the chunk */ -# endif /* READ_USER_CHUNKS */ - -# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED - { - /* keep is currently just the per-chunk setting, if there was no - * setting change it to the global default now (not that this may - * still be AS_DEFAULT) then obtain the cache of the chunk if required, - * if not simply skip the chunk. - */ - if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT) - keep = png_ptr->unknown_default; - - if (keep == PNG_HANDLE_CHUNK_ALWAYS || - (keep == PNG_HANDLE_CHUNK_IF_SAFE && - PNG_CHUNK_ANCILLARY(png_ptr->chunk_name))) - { - if (png_cache_unknown_chunk(png_ptr, length) == 0) - keep = PNG_HANDLE_CHUNK_NEVER; - } - - else - png_crc_finish(png_ptr, length); - } -# else -# ifndef PNG_READ_USER_CHUNKS_SUPPORTED -# error no method to support READ_UNKNOWN_CHUNKS -# endif - - { - /* If here there is no read callback pointer set and no support is - * compiled in to just save the unknown chunks, so simply skip this - * chunk. If 'keep' is something other than AS_DEFAULT or NEVER then - * the app has erroneously asked for unknown chunk saving when there - * is no support. - */ - if (keep > PNG_HANDLE_CHUNK_NEVER) - png_app_error(png_ptr, "no unknown chunk support available"); - - png_crc_finish(png_ptr, length); - } -# endif - -# ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED - /* Now store the chunk in the chunk list if appropriate, and if the limits - * permit it. - */ - if (keep == PNG_HANDLE_CHUNK_ALWAYS || - (keep == PNG_HANDLE_CHUNK_IF_SAFE && - PNG_CHUNK_ANCILLARY(png_ptr->chunk_name))) - { -# ifdef PNG_USER_LIMITS_SUPPORTED - switch (png_ptr->user_chunk_cache_max) - { - case 2: - png_ptr->user_chunk_cache_max = 1; - png_chunk_benign_error(png_ptr, "no space in chunk cache"); - /* FALLTHROUGH */ - case 1: - /* NOTE: prior to 1.6.0 this case resulted in an unknown critical - * chunk being skipped, now there will be a hard error below. - */ - break; - - default: /* not at limit */ - --(png_ptr->user_chunk_cache_max); - /* FALLTHROUGH */ - case 0: /* no limit */ -# endif /* USER_LIMITS */ - /* Here when the limit isn't reached or when limits are compiled - * out; store the chunk. - */ - png_set_unknown_chunks(png_ptr, info_ptr, - &png_ptr->unknown_chunk, 1); - handled = 1; -# ifdef PNG_USER_LIMITS_SUPPORTED - break; - } -# endif - } -# else /* no store support: the chunk must be handled by the user callback */ - PNG_UNUSED(info_ptr) -# endif - - /* Regardless of the error handling below the cached data (if any) can be - * freed now. Notice that the data is not freed if there is a png_error, but - * it will be freed by destroy_read_struct. - */ - if (png_ptr->unknown_chunk.data != NULL) - png_free(png_ptr, png_ptr->unknown_chunk.data); - png_ptr->unknown_chunk.data = NULL; - -#else /* !PNG_READ_UNKNOWN_CHUNKS_SUPPORTED */ - /* There is no support to read an unknown chunk, so just skip it. */ - png_crc_finish(png_ptr, length); - PNG_UNUSED(info_ptr) - PNG_UNUSED(keep) -#endif /* !READ_UNKNOWN_CHUNKS */ - - /* Check for unhandled critical chunks */ - if (handled == 0 && PNG_CHUNK_CRITICAL(png_ptr->chunk_name)) - png_chunk_error(png_ptr, "unhandled critical chunk"); -} - -/* This function is called to verify that a chunk name is valid. - * This function can't have the "critical chunk check" incorporated - * into it, since in the future we will need to be able to call user - * functions to handle unknown critical chunks after we check that - * the chunk name itself is valid. - */ - -/* Bit hacking: the test for an invalid byte in the 4 byte chunk name is: - * - * ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97)) - */ - -void /* PRIVATE */ -png_check_chunk_name(png_const_structrp png_ptr, png_uint_32 chunk_name) -{ - int i; - png_uint_32 cn=chunk_name; - - png_debug(1, "in png_check_chunk_name"); - - for (i=1; i<=4; ++i) - { - int c = cn & 0xff; - - if (c < 65 || c > 122 || (c > 90 && c < 97)) - png_chunk_error(png_ptr, "invalid chunk type"); - - cn >>= 8; - } -} - -void /* PRIVATE */ -png_check_chunk_length(png_const_structrp png_ptr, png_uint_32 length) -{ - png_alloc_size_t limit = PNG_UINT_31_MAX; - -# ifdef PNG_SET_USER_LIMITS_SUPPORTED - if (png_ptr->user_chunk_malloc_max > 0 && - png_ptr->user_chunk_malloc_max < limit) - limit = png_ptr->user_chunk_malloc_max; -# elif PNG_USER_CHUNK_MALLOC_MAX > 0 - if (PNG_USER_CHUNK_MALLOC_MAX < limit) - limit = PNG_USER_CHUNK_MALLOC_MAX; -# endif - if (png_ptr->chunk_name == png_IDAT) - { - png_alloc_size_t idat_limit = PNG_UINT_31_MAX; - size_t row_factor = - (size_t)png_ptr->width - * (size_t)png_ptr->channels - * (png_ptr->bit_depth > 8? 2: 1) - + 1 - + (png_ptr->interlaced? 6: 0); - if (png_ptr->height > PNG_UINT_32_MAX/row_factor) - idat_limit = PNG_UINT_31_MAX; - else - idat_limit = png_ptr->height * row_factor; - row_factor = row_factor > 32566? 32566 : row_factor; - idat_limit += 6 + 5*(idat_limit/row_factor+1); /* zlib+deflate overhead */ - idat_limit=idat_limit < PNG_UINT_31_MAX? idat_limit : PNG_UINT_31_MAX; - limit = limit < idat_limit? idat_limit : limit; - } - - if (length > limit) - { - png_debug2(0," length = %lu, limit = %lu", - (unsigned long)length,(unsigned long)limit); - png_chunk_error(png_ptr, "chunk data is too large"); - } -} - -/* Combines the row recently read in with the existing pixels in the row. This - * routine takes care of alpha and transparency if requested. This routine also - * handles the two methods of progressive display of interlaced images, - * depending on the 'display' value; if 'display' is true then the whole row - * (dp) is filled from the start by replicating the available pixels. If - * 'display' is false only those pixels present in the pass are filled in. - */ -void /* PRIVATE */ -png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) -{ - unsigned int pixel_depth = png_ptr->transformed_pixel_depth; - png_const_bytep sp = png_ptr->row_buf + 1; - png_alloc_size_t row_width = png_ptr->width; - unsigned int pass = png_ptr->pass; - png_bytep end_ptr = 0; - png_byte end_byte = 0; - unsigned int end_mask; - - png_debug(1, "in png_combine_row"); - - /* Added in 1.5.6: it should not be possible to enter this routine until at - * least one row has been read from the PNG data and transformed. - */ - if (pixel_depth == 0) - png_error(png_ptr, "internal row logic error"); - - /* Added in 1.5.4: the pixel depth should match the information returned by - * any call to png_read_update_info at this point. Do not continue if we got - * this wrong. - */ - if (png_ptr->info_rowbytes != 0 && png_ptr->info_rowbytes != - PNG_ROWBYTES(pixel_depth, row_width)) - png_error(png_ptr, "internal row size calculation error"); - - /* Don't expect this to ever happen: */ - if (row_width == 0) - png_error(png_ptr, "internal row width error"); - - /* Preserve the last byte in cases where only part of it will be overwritten, - * the multiply below may overflow, we don't care because ANSI-C guarantees - * we get the low bits. - */ - end_mask = (pixel_depth * row_width) & 7; - if (end_mask != 0) - { - /* end_ptr == NULL is a flag to say do nothing */ - end_ptr = dp + PNG_ROWBYTES(pixel_depth, row_width) - 1; - end_byte = *end_ptr; -# ifdef PNG_READ_PACKSWAP_SUPPORTED - if ((png_ptr->transformations & PNG_PACKSWAP) != 0) - /* little-endian byte */ - end_mask = (unsigned int)(0xff << end_mask); - - else /* big-endian byte */ -# endif - end_mask = 0xff >> end_mask; - /* end_mask is now the bits to *keep* from the destination row */ - } - - /* For non-interlaced images this reduces to a memcpy(). A memcpy() - * will also happen if interlacing isn't supported or if the application - * does not call png_set_interlace_handling(). In the latter cases the - * caller just gets a sequence of the unexpanded rows from each interlace - * pass. - */ -#ifdef PNG_READ_INTERLACING_SUPPORTED - if (png_ptr->interlaced != 0 && - (png_ptr->transformations & PNG_INTERLACE) != 0 && - pass < 6 && (display == 0 || - /* The following copies everything for 'display' on passes 0, 2 and 4. */ - (display == 1 && (pass & 1) != 0))) - { - /* Narrow images may have no bits in a pass; the caller should handle - * this, but this test is cheap: - */ - if (row_width <= PNG_PASS_START_COL(pass)) - return; - - if (pixel_depth < 8) - { - /* For pixel depths up to 4 bpp the 8-pixel mask can be expanded to fit - * into 32 bits, then a single loop over the bytes using the four byte - * values in the 32-bit mask can be used. For the 'display' option the - * expanded mask may also not require any masking within a byte. To - * make this work the PACKSWAP option must be taken into account - it - * simply requires the pixels to be reversed in each byte. - * - * The 'regular' case requires a mask for each of the first 6 passes, - * the 'display' case does a copy for the even passes in the range - * 0..6. This has already been handled in the test above. - * - * The masks are arranged as four bytes with the first byte to use in - * the lowest bits (little-endian) regardless of the order (PACKSWAP or - * not) of the pixels in each byte. - * - * NOTE: the whole of this logic depends on the caller of this function - * only calling it on rows appropriate to the pass. This function only - * understands the 'x' logic; the 'y' logic is handled by the caller. - * - * The following defines allow generation of compile time constant bit - * masks for each pixel depth and each possibility of swapped or not - * swapped bytes. Pass 'p' is in the range 0..6; 'x', a pixel index, - * is in the range 0..7; and the result is 1 if the pixel is to be - * copied in the pass, 0 if not. 'S' is for the sparkle method, 'B' - * for the block method. - * - * With some compilers a compile time expression of the general form: - * - * (shift >= 32) ? (a >> (shift-32)) : (b >> shift) - * - * Produces warnings with values of 'shift' in the range 33 to 63 - * because the right hand side of the ?: expression is evaluated by - * the compiler even though it isn't used. Microsoft Visual C (various - * versions) and the Intel C compiler are known to do this. To avoid - * this the following macros are used in 1.5.6. This is a temporary - * solution to avoid destabilizing the code during the release process. - */ -# if PNG_USE_COMPILE_TIME_MASKS -# define PNG_LSR(x,s) ((x)>>((s) & 0x1f)) -# define PNG_LSL(x,s) ((x)<<((s) & 0x1f)) -# else -# define PNG_LSR(x,s) ((x)>>(s)) -# define PNG_LSL(x,s) ((x)<<(s)) -# endif -# define S_COPY(p,x) (((p)<4 ? PNG_LSR(0x80088822,(3-(p))*8+(7-(x))) :\ - PNG_LSR(0xaa55ff00,(7-(p))*8+(7-(x)))) & 1) -# define B_COPY(p,x) (((p)<4 ? PNG_LSR(0xff0fff33,(3-(p))*8+(7-(x))) :\ - PNG_LSR(0xff55ff00,(7-(p))*8+(7-(x)))) & 1) - - /* Return a mask for pass 'p' pixel 'x' at depth 'd'. The mask is - * little endian - the first pixel is at bit 0 - however the extra - * parameter 's' can be set to cause the mask position to be swapped - * within each byte, to match the PNG format. This is done by XOR of - * the shift with 7, 6 or 4 for bit depths 1, 2 and 4. - */ -# define PIXEL_MASK(p,x,d,s) \ - (PNG_LSL(((PNG_LSL(1U,(d)))-1),(((x)*(d))^((s)?8-(d):0)))) - - /* Hence generate the appropriate 'block' or 'sparkle' pixel copy mask. - */ -# define S_MASKx(p,x,d,s) (S_COPY(p,x)?PIXEL_MASK(p,x,d,s):0) -# define B_MASKx(p,x,d,s) (B_COPY(p,x)?PIXEL_MASK(p,x,d,s):0) - - /* Combine 8 of these to get the full mask. For the 1-bpp and 2-bpp - * cases the result needs replicating, for the 4-bpp case the above - * generates a full 32 bits. - */ -# define MASK_EXPAND(m,d) ((m)*((d)==1?0x01010101:((d)==2?0x00010001:1))) - -# define S_MASK(p,d,s) MASK_EXPAND(S_MASKx(p,0,d,s) + S_MASKx(p,1,d,s) +\ - S_MASKx(p,2,d,s) + S_MASKx(p,3,d,s) + S_MASKx(p,4,d,s) +\ - S_MASKx(p,5,d,s) + S_MASKx(p,6,d,s) + S_MASKx(p,7,d,s), d) - -# define B_MASK(p,d,s) MASK_EXPAND(B_MASKx(p,0,d,s) + B_MASKx(p,1,d,s) +\ - B_MASKx(p,2,d,s) + B_MASKx(p,3,d,s) + B_MASKx(p,4,d,s) +\ - B_MASKx(p,5,d,s) + B_MASKx(p,6,d,s) + B_MASKx(p,7,d,s), d) - -#if PNG_USE_COMPILE_TIME_MASKS - /* Utility macros to construct all the masks for a depth/swap - * combination. The 's' parameter says whether the format is PNG - * (big endian bytes) or not. Only the three odd-numbered passes are - * required for the display/block algorithm. - */ -# define S_MASKS(d,s) { S_MASK(0,d,s), S_MASK(1,d,s), S_MASK(2,d,s),\ - S_MASK(3,d,s), S_MASK(4,d,s), S_MASK(5,d,s) } - -# define B_MASKS(d,s) { B_MASK(1,d,s), B_MASK(3,d,s), B_MASK(5,d,s) } - -# define DEPTH_INDEX(d) ((d)==1?0:((d)==2?1:2)) - - /* Hence the pre-compiled masks indexed by PACKSWAP (or not), depth and - * then pass: - */ - static const png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] = - { - /* Little-endian byte masks for PACKSWAP */ - { S_MASKS(1,0), S_MASKS(2,0), S_MASKS(4,0) }, - /* Normal (big-endian byte) masks - PNG format */ - { S_MASKS(1,1), S_MASKS(2,1), S_MASKS(4,1) } - }; - - /* display_mask has only three entries for the odd passes, so index by - * pass>>1. - */ - static const png_uint_32 display_mask[2][3][3] = - { - /* Little-endian byte masks for PACKSWAP */ - { B_MASKS(1,0), B_MASKS(2,0), B_MASKS(4,0) }, - /* Normal (big-endian byte) masks - PNG format */ - { B_MASKS(1,1), B_MASKS(2,1), B_MASKS(4,1) } - }; - -# define MASK(pass,depth,display,png)\ - ((display)?display_mask[png][DEPTH_INDEX(depth)][pass>>1]:\ - row_mask[png][DEPTH_INDEX(depth)][pass]) - -#else /* !PNG_USE_COMPILE_TIME_MASKS */ - /* This is the runtime alternative: it seems unlikely that this will - * ever be either smaller or faster than the compile time approach. - */ -# define MASK(pass,depth,display,png)\ - ((display)?B_MASK(pass,depth,png):S_MASK(pass,depth,png)) -#endif /* !USE_COMPILE_TIME_MASKS */ - - /* Use the appropriate mask to copy the required bits. In some cases - * the byte mask will be 0 or 0xff; optimize these cases. row_width is - * the number of pixels, but the code copies bytes, so it is necessary - * to special case the end. - */ - png_uint_32 pixels_per_byte = 8 / pixel_depth; - png_uint_32 mask; - -# ifdef PNG_READ_PACKSWAP_SUPPORTED - if ((png_ptr->transformations & PNG_PACKSWAP) != 0) - mask = MASK(pass, pixel_depth, display, 0); - - else -# endif - mask = MASK(pass, pixel_depth, display, 1); - - for (;;) - { - png_uint_32 m; - - /* It doesn't matter in the following if png_uint_32 has more than - * 32 bits because the high bits always match those in m<<24; it is, - * however, essential to use OR here, not +, because of this. - */ - m = mask; - mask = (m >> 8) | (m << 24); /* rotate right to good compilers */ - m &= 0xff; - - if (m != 0) /* something to copy */ - { - if (m != 0xff) - *dp = (png_byte)((*dp & ~m) | (*sp & m)); - else - *dp = *sp; - } - - /* NOTE: this may overwrite the last byte with garbage if the image - * is not an exact number of bytes wide; libpng has always done - * this. - */ - if (row_width <= pixels_per_byte) - break; /* May need to restore part of the last byte */ - - row_width -= pixels_per_byte; - ++dp; - ++sp; - } - } - - else /* pixel_depth >= 8 */ - { - unsigned int bytes_to_copy, bytes_to_jump; - - /* Validate the depth - it must be a multiple of 8 */ - if (pixel_depth & 7) - png_error(png_ptr, "invalid user transform pixel depth"); - - pixel_depth >>= 3; /* now in bytes */ - row_width *= pixel_depth; - - /* Regardless of pass number the Adam 7 interlace always results in a - * fixed number of pixels to copy then to skip. There may be a - * different number of pixels to skip at the start though. - */ - { - unsigned int offset = PNG_PASS_START_COL(pass) * pixel_depth; - - row_width -= offset; - dp += offset; - sp += offset; - } - - /* Work out the bytes to copy. */ - if (display != 0) - { - /* When doing the 'block' algorithm the pixel in the pass gets - * replicated to adjacent pixels. This is why the even (0,2,4,6) - * passes are skipped above - the entire expanded row is copied. - */ - bytes_to_copy = (1<<((6-pass)>>1)) * pixel_depth; - - /* But don't allow this number to exceed the actual row width. */ - if (bytes_to_copy > row_width) - bytes_to_copy = (unsigned int)/*SAFE*/row_width; - } - - else /* normal row; Adam7 only ever gives us one pixel to copy. */ - bytes_to_copy = pixel_depth; - - /* In Adam7 there is a constant offset between where the pixels go. */ - bytes_to_jump = PNG_PASS_COL_OFFSET(pass) * pixel_depth; - - /* And simply copy these bytes. Some optimization is possible here, - * depending on the value of 'bytes_to_copy'. Special case the low - * byte counts, which we know to be frequent. - * - * Notice that these cases all 'return' rather than 'break' - this - * avoids an unnecessary test on whether to restore the last byte - * below. - */ - switch (bytes_to_copy) - { - case 1: - for (;;) - { - *dp = *sp; - - if (row_width <= bytes_to_jump) - return; - - dp += bytes_to_jump; - sp += bytes_to_jump; - row_width -= bytes_to_jump; - } - - case 2: - /* There is a possibility of a partial copy at the end here; this - * slows the code down somewhat. - */ - do - { - dp[0] = sp[0]; dp[1] = sp[1]; - - if (row_width <= bytes_to_jump) - return; - - sp += bytes_to_jump; - dp += bytes_to_jump; - row_width -= bytes_to_jump; - } - while (row_width > 1); - - /* And there can only be one byte left at this point: */ - *dp = *sp; - return; - - case 3: - /* This can only be the RGB case, so each copy is exactly one - * pixel and it is not necessary to check for a partial copy. - */ - for (;;) - { - dp[0] = sp[0]; dp[1] = sp[1]; dp[2] = sp[2]; - - if (row_width <= bytes_to_jump) - return; - - sp += bytes_to_jump; - dp += bytes_to_jump; - row_width -= bytes_to_jump; - } - - default: -#if PNG_ALIGN_TYPE != PNG_ALIGN_NONE - /* Check for double byte alignment and, if possible, use a - * 16-bit copy. Don't attempt this for narrow images - ones that - * are less than an interlace panel wide. Don't attempt it for - * wide bytes_to_copy either - use the memcpy there. - */ - if (bytes_to_copy < 16 /*else use memcpy*/ && - png_isaligned(dp, png_uint_16) && - png_isaligned(sp, png_uint_16) && - bytes_to_copy % (sizeof (png_uint_16)) == 0 && - bytes_to_jump % (sizeof (png_uint_16)) == 0) - { - /* Everything is aligned for png_uint_16 copies, but try for - * png_uint_32 first. - */ - if (png_isaligned(dp, png_uint_32) && - png_isaligned(sp, png_uint_32) && - bytes_to_copy % (sizeof (png_uint_32)) == 0 && - bytes_to_jump % (sizeof (png_uint_32)) == 0) - { - png_uint_32p dp32 = png_aligncast(png_uint_32p,dp); - png_const_uint_32p sp32 = png_aligncastconst( - png_const_uint_32p, sp); - size_t skip = (bytes_to_jump-bytes_to_copy) / - (sizeof (png_uint_32)); - - do - { - size_t c = bytes_to_copy; - do - { - *dp32++ = *sp32++; - c -= (sizeof (png_uint_32)); - } - while (c > 0); - - if (row_width <= bytes_to_jump) - return; - - dp32 += skip; - sp32 += skip; - row_width -= bytes_to_jump; - } - while (bytes_to_copy <= row_width); - - /* Get to here when the row_width truncates the final copy. - * There will be 1-3 bytes left to copy, so don't try the - * 16-bit loop below. - */ - dp = (png_bytep)dp32; - sp = (png_const_bytep)sp32; - do - *dp++ = *sp++; - while (--row_width > 0); - return; - } - - /* Else do it in 16-bit quantities, but only if the size is - * not too large. - */ - else - { - png_uint_16p dp16 = png_aligncast(png_uint_16p, dp); - png_const_uint_16p sp16 = png_aligncastconst( - png_const_uint_16p, sp); - size_t skip = (bytes_to_jump-bytes_to_copy) / - (sizeof (png_uint_16)); - - do - { - size_t c = bytes_to_copy; - do - { - *dp16++ = *sp16++; - c -= (sizeof (png_uint_16)); - } - while (c > 0); - - if (row_width <= bytes_to_jump) - return; - - dp16 += skip; - sp16 += skip; - row_width -= bytes_to_jump; - } - while (bytes_to_copy <= row_width); - - /* End of row - 1 byte left, bytes_to_copy > row_width: */ - dp = (png_bytep)dp16; - sp = (png_const_bytep)sp16; - do - *dp++ = *sp++; - while (--row_width > 0); - return; - } - } -#endif /* ALIGN_TYPE code */ - - /* The true default - use a memcpy: */ - for (;;) - { - memcpy(dp, sp, bytes_to_copy); - - if (row_width <= bytes_to_jump) - return; - - sp += bytes_to_jump; - dp += bytes_to_jump; - row_width -= bytes_to_jump; - if (bytes_to_copy > row_width) - bytes_to_copy = (unsigned int)/*SAFE*/row_width; - } - } - - /* NOT REACHED*/ - } /* pixel_depth >= 8 */ - - /* Here if pixel_depth < 8 to check 'end_ptr' below. */ - } - else -#endif /* READ_INTERLACING */ - - /* If here then the switch above wasn't used so just memcpy the whole row - * from the temporary row buffer (notice that this overwrites the end of the - * destination row if it is a partial byte.) - */ - memcpy(dp, sp, PNG_ROWBYTES(pixel_depth, row_width)); - - /* Restore the overwritten bits from the last byte if necessary. */ - if (end_ptr != NULL) - *end_ptr = (png_byte)((end_byte & end_mask) | (*end_ptr & ~end_mask)); -} - -#ifdef PNG_READ_INTERLACING_SUPPORTED -void /* PRIVATE */ -png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, - png_uint_32 transformations /* Because these may affect the byte layout */) -{ - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* Offset to next interlace block */ - static const unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - png_debug(1, "in png_do_read_interlace"); - if (row != NULL && row_info != NULL) - { - png_uint_32 final_width; - - final_width = row_info->width * png_pass_inc[pass]; - - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp = row + (size_t)((row_info->width - 1) >> 3); - png_bytep dp = row + (size_t)((final_width - 1) >> 3); - unsigned int sshift, dshift; - unsigned int s_start, s_end; - int s_inc; - int jstop = (int)png_pass_inc[pass]; - png_byte v; - png_uint_32 i; - int j; - -#ifdef PNG_READ_PACKSWAP_SUPPORTED - if ((transformations & PNG_PACKSWAP) != 0) - { - sshift = ((row_info->width + 7) & 0x07); - dshift = ((final_width + 7) & 0x07); - s_start = 7; - s_end = 0; - s_inc = -1; - } - - else -#endif - { - sshift = 7 - ((row_info->width + 7) & 0x07); - dshift = 7 - ((final_width + 7) & 0x07); - s_start = 0; - s_end = 7; - s_inc = 1; - } - - for (i = 0; i < row_info->width; i++) - { - v = (png_byte)((*sp >> sshift) & 0x01); - for (j = 0; j < jstop; j++) - { - unsigned int tmp = *dp & (0x7f7f >> (7 - dshift)); - tmp |= (unsigned int)(v << dshift); - *dp = (png_byte)(tmp & 0xff); - - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - - else - dshift = (unsigned int)((int)dshift + s_inc); - } - - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - - else - sshift = (unsigned int)((int)sshift + s_inc); - } - break; - } - - case 2: - { - png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2); - png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2); - unsigned int sshift, dshift; - unsigned int s_start, s_end; - int s_inc; - int jstop = (int)png_pass_inc[pass]; - png_uint_32 i; - -#ifdef PNG_READ_PACKSWAP_SUPPORTED - if ((transformations & PNG_PACKSWAP) != 0) - { - sshift = (((row_info->width + 3) & 0x03) << 1); - dshift = (((final_width + 3) & 0x03) << 1); - s_start = 6; - s_end = 0; - s_inc = -2; - } - - else -#endif - { - sshift = ((3 - ((row_info->width + 3) & 0x03)) << 1); - dshift = ((3 - ((final_width + 3) & 0x03)) << 1); - s_start = 0; - s_end = 6; - s_inc = 2; - } - - for (i = 0; i < row_info->width; i++) - { - png_byte v; - int j; - - v = (png_byte)((*sp >> sshift) & 0x03); - for (j = 0; j < jstop; j++) - { - unsigned int tmp = *dp & (0x3f3f >> (6 - dshift)); - tmp |= (unsigned int)(v << dshift); - *dp = (png_byte)(tmp & 0xff); - - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - - else - dshift = (unsigned int)((int)dshift + s_inc); - } - - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - - else - sshift = (unsigned int)((int)sshift + s_inc); - } - break; - } - - case 4: - { - png_bytep sp = row + (size_t)((row_info->width - 1) >> 1); - png_bytep dp = row + (size_t)((final_width - 1) >> 1); - unsigned int sshift, dshift; - unsigned int s_start, s_end; - int s_inc; - png_uint_32 i; - int jstop = (int)png_pass_inc[pass]; - -#ifdef PNG_READ_PACKSWAP_SUPPORTED - if ((transformations & PNG_PACKSWAP) != 0) - { - sshift = (((row_info->width + 1) & 0x01) << 2); - dshift = (((final_width + 1) & 0x01) << 2); - s_start = 4; - s_end = 0; - s_inc = -4; - } - - else -#endif - { - sshift = ((1 - ((row_info->width + 1) & 0x01)) << 2); - dshift = ((1 - ((final_width + 1) & 0x01)) << 2); - s_start = 0; - s_end = 4; - s_inc = 4; - } - - for (i = 0; i < row_info->width; i++) - { - png_byte v = (png_byte)((*sp >> sshift) & 0x0f); - int j; - - for (j = 0; j < jstop; j++) - { - unsigned int tmp = *dp & (0xf0f >> (4 - dshift)); - tmp |= (unsigned int)(v << dshift); - *dp = (png_byte)(tmp & 0xff); - - if (dshift == s_end) - { - dshift = s_start; - dp--; - } - - else - dshift = (unsigned int)((int)dshift + s_inc); - } - - if (sshift == s_end) - { - sshift = s_start; - sp--; - } - - else - sshift = (unsigned int)((int)sshift + s_inc); - } - break; - } - - default: - { - size_t pixel_bytes = (row_info->pixel_depth >> 3); - - png_bytep sp = row + (size_t)(row_info->width - 1) - * pixel_bytes; - - png_bytep dp = row + (size_t)(final_width - 1) * pixel_bytes; - - int jstop = (int)png_pass_inc[pass]; - png_uint_32 i; - - for (i = 0; i < row_info->width; i++) - { - png_byte v[8]; /* SAFE; pixel_depth does not exceed 64 */ - int j; - - memcpy(v, sp, pixel_bytes); - - for (j = 0; j < jstop; j++) - { - memcpy(dp, v, pixel_bytes); - dp -= pixel_bytes; - } - - sp -= pixel_bytes; - } - break; - } - } - - row_info->width = final_width; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width); - } -#ifndef PNG_READ_PACKSWAP_SUPPORTED - PNG_UNUSED(transformations) /* Silence compiler warning */ -#endif -} -#endif /* READ_INTERLACING */ - -static void -png_read_filter_row_sub(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) -{ - size_t i; - size_t istop = row_info->rowbytes; - unsigned int bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp = row + bpp; - - PNG_UNUSED(prev_row) - - for (i = bpp; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*(rp-bpp))) & 0xff); - rp++; - } -} - -static void -png_read_filter_row_up(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) -{ - size_t i; - size_t istop = row_info->rowbytes; - png_bytep rp = row; - png_const_bytep pp = prev_row; - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff); - rp++; - } -} - -static void -png_read_filter_row_avg(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) -{ - size_t i; - png_bytep rp = row; - png_const_bytep pp = prev_row; - unsigned int bpp = (row_info->pixel_depth + 7) >> 3; - size_t istop = row_info->rowbytes - bpp; - - for (i = 0; i < bpp; i++) - { - *rp = (png_byte)(((int)(*rp) + - ((int)(*pp++) / 2 )) & 0xff); - - rp++; - } - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(((int)(*rp) + - (int)(*pp++ + *(rp-bpp)) / 2 ) & 0xff); - - rp++; - } -} - -static void -png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) -{ - png_bytep rp_end = row + row_info->rowbytes; - int a, c; - - /* First pixel/byte */ - c = *prev_row++; - a = *row + c; - *row++ = (png_byte)a; - - /* Remainder */ - while (row < rp_end) - { - int b, pa, pb, pc, p; - - a &= 0xff; /* From previous iteration or start */ - b = *prev_row++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - /* Find the best predictor, the least of pa, pb, pc favoring the earlier - * ones in the case of a tie. - */ - if (pb < pa) - { - pa = pb; a = b; - } - if (pc < pa) a = c; - - /* Calculate the current pixel in a, and move the previous row pixel to c - * for the next time round the loop - */ - c = b; - a += *row; - *row++ = (png_byte)a; - } -} - -static void -png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) -{ - unsigned int bpp = (row_info->pixel_depth + 7) >> 3; - png_bytep rp_end = row + bpp; - - /* Process the first pixel in the row completely (this is the same as 'up' - * because there is only one candidate predictor for the first row). - */ - while (row < rp_end) - { - int a = *row + *prev_row++; - *row++ = (png_byte)a; - } - - /* Remainder */ - rp_end = rp_end + (row_info->rowbytes - bpp); - - while (row < rp_end) - { - int a, b, c, pa, pb, pc, p; - - c = *(prev_row - bpp); - a = *(row - bpp); - b = *prev_row++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - if (pb < pa) - { - pa = pb; a = b; - } - if (pc < pa) a = c; - - a += *row; - *row++ = (png_byte)a; - } -} - -static void -png_init_filter_functions(png_structrp pp) - /* This function is called once for every PNG image (except for PNG images - * that only use PNG_FILTER_VALUE_NONE for all rows) to set the - * implementations required to reverse the filtering of PNG rows. Reversing - * the filter is the first transformation performed on the row data. It is - * performed in place, therefore an implementation can be selected based on - * the image pixel format. If the implementation depends on image width then - * take care to ensure that it works correctly if the image is interlaced - - * interlacing causes the actual row width to vary. - */ -{ - unsigned int bpp = (pp->pixel_depth + 7) >> 3; - - pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub; - pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up; - pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg; - if (bpp == 1) - pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = - png_read_filter_row_paeth_1byte_pixel; - else - pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = - png_read_filter_row_paeth_multibyte_pixel; - -#ifdef PNG_FILTER_OPTIMIZATIONS - /* To use this define PNG_FILTER_OPTIMIZATIONS as the name of a function to - * call to install hardware optimizations for the above functions; simply - * replace whatever elements of the pp->read_filter[] array with a hardware - * specific (or, for that matter, generic) optimization. - * - * To see an example of this examine what configure.ac does when - * --enable-arm-neon is specified on the command line. - */ - PNG_FILTER_OPTIMIZATIONS(pp, bpp); -#endif -} - -void /* PRIVATE */ -png_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row, - png_const_bytep prev_row, int filter) -{ - /* OPTIMIZATION: DO NOT MODIFY THIS FUNCTION, instead #define - * PNG_FILTER_OPTIMIZATIONS to a function that overrides the generic - * implementations. See png_init_filter_functions above. - */ - if (filter > PNG_FILTER_VALUE_NONE && filter < PNG_FILTER_VALUE_LAST) - { - if (pp->read_filter[0] == NULL) - png_init_filter_functions(pp); - - pp->read_filter[filter-1](row_info, row, prev_row); - } -} - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -void /* PRIVATE */ -png_read_IDAT_data(png_structrp png_ptr, png_bytep output, - png_alloc_size_t avail_out) -{ - /* Loop reading IDATs and decompressing the result into output[avail_out] */ - png_ptr->zstream.next_out = output; - png_ptr->zstream.avail_out = 0; /* safety: set below */ - - if (output == NULL) - avail_out = 0; - - do - { - int ret; - png_byte tmpbuf[PNG_INFLATE_BUF_SIZE]; - - if (png_ptr->zstream.avail_in == 0) - { - uInt avail_in; - png_bytep buffer; - - while (png_ptr->idat_size == 0) - { - png_crc_finish(png_ptr, 0); - - png_ptr->idat_size = png_read_chunk_header(png_ptr); - /* This is an error even in the 'check' case because the code just - * consumed a non-IDAT header. - */ - if (png_ptr->chunk_name != png_IDAT) - png_error(png_ptr, "Not enough image data"); - } - - avail_in = png_ptr->IDAT_read_size; - - if (avail_in > png_ptr->idat_size) - avail_in = (uInt)png_ptr->idat_size; - - /* A PNG with a gradually increasing IDAT size will defeat this attempt - * to minimize memory usage by causing lots of re-allocs, but - * realistically doing IDAT_read_size re-allocs is not likely to be a - * big problem. - */ - buffer = png_read_buffer(png_ptr, avail_in, 0/*error*/); - - png_crc_read(png_ptr, buffer, avail_in); - png_ptr->idat_size -= avail_in; - - png_ptr->zstream.next_in = buffer; - png_ptr->zstream.avail_in = avail_in; - } - - /* And set up the output side. */ - if (output != NULL) /* standard read */ - { - uInt out = ZLIB_IO_MAX; - - if (out > avail_out) - out = (uInt)avail_out; - - avail_out -= out; - png_ptr->zstream.avail_out = out; - } - - else /* after last row, checking for end */ - { - png_ptr->zstream.next_out = tmpbuf; - png_ptr->zstream.avail_out = (sizeof tmpbuf); - } - - /* Use NO_FLUSH; this gives zlib the maximum opportunity to optimize the - * process. If the LZ stream is truncated the sequential reader will - * terminally damage the stream, above, by reading the chunk header of the - * following chunk (it then exits with png_error). - * - * TODO: deal more elegantly with truncated IDAT lists. - */ - ret = PNG_INFLATE(png_ptr, Z_NO_FLUSH); - - /* Take the unconsumed output back. */ - if (output != NULL) - avail_out += png_ptr->zstream.avail_out; - - else /* avail_out counts the extra bytes */ - avail_out += (sizeof tmpbuf) - png_ptr->zstream.avail_out; - - png_ptr->zstream.avail_out = 0; - - if (ret == Z_STREAM_END) - { - /* Do this for safety; we won't read any more into this row. */ - png_ptr->zstream.next_out = NULL; - - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; - - if (png_ptr->zstream.avail_in > 0 || png_ptr->idat_size > 0) - png_chunk_benign_error(png_ptr, "Extra compressed data"); - break; - } - - if (ret != Z_OK) - { - png_zstream_error(png_ptr, ret); - - if (output != NULL) - png_chunk_error(png_ptr, png_ptr->zstream.msg); - - else /* checking */ - { - png_chunk_benign_error(png_ptr, png_ptr->zstream.msg); - return; - } - } - } while (avail_out > 0); - - if (avail_out > 0) - { - /* The stream ended before the image; this is the same as too few IDATs so - * should be handled the same way. - */ - if (output != NULL) - png_error(png_ptr, "Not enough image data"); - - else /* the deflate stream contained extra data */ - png_chunk_benign_error(png_ptr, "Too much image data"); - } -} - -void /* PRIVATE */ -png_read_finish_IDAT(png_structrp png_ptr) -{ - /* We don't need any more data and the stream should have ended, however the - * LZ end code may actually not have been processed. In this case we must - * read it otherwise stray unread IDAT data or, more likely, an IDAT chunk - * may still remain to be consumed. - */ - if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0) - { - /* The NULL causes png_read_IDAT_data to swallow any remaining bytes in - * the compressed stream, but the stream may be damaged too, so even after - * this call we may need to terminate the zstream ownership. - */ - png_read_IDAT_data(png_ptr, NULL, 0); - png_ptr->zstream.next_out = NULL; /* safety */ - - /* Now clear everything out for safety; the following may not have been - * done. - */ - if ((png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0) - { - png_ptr->mode |= PNG_AFTER_IDAT; - png_ptr->flags |= PNG_FLAG_ZSTREAM_ENDED; - } - } - - /* If the zstream has not been released do it now *and* terminate the reading - * of the final IDAT chunk. - */ - if (png_ptr->zowner == png_IDAT) - { - /* Always do this; the pointers otherwise point into the read buffer. */ - png_ptr->zstream.next_in = NULL; - png_ptr->zstream.avail_in = 0; - - /* Now we no longer own the zstream. */ - png_ptr->zowner = 0; - - /* The slightly weird semantics of the sequential IDAT reading is that we - * are always in or at the end of an IDAT chunk, so we always need to do a - * crc_finish here. If idat_size is non-zero we also need to read the - * spurious bytes at the end of the chunk now. - */ - (void)png_crc_finish(png_ptr, png_ptr->idat_size); - } -} - -void /* PRIVATE */ -png_read_finish_row(png_structrp png_ptr) -{ - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* Start of interlace block */ - static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* Offset to next interlace block */ - static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* Start of interlace block in the y direction */ - static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* Offset to next interlace block in the y direction */ - static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; - - png_debug(1, "in png_read_finish_row"); - png_ptr->row_number++; - if (png_ptr->row_number < png_ptr->num_rows) - return; - - if (png_ptr->interlaced != 0) - { - png_ptr->row_number = 0; - - /* TO DO: don't do this if prev_row isn't needed (requires - * read-ahead of the next row's filter byte. - */ - memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - - do - { - png_ptr->pass++; - - if (png_ptr->pass >= 7) - break; - - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - if ((png_ptr->transformations & PNG_INTERLACE) == 0) - { - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - } - - else /* if (png_ptr->transformations & PNG_INTERLACE) */ - break; /* libpng deinterlacing sees every row */ - - } while (png_ptr->num_rows == 0 || png_ptr->iwidth == 0); - - if (png_ptr->pass < 7) - return; - } - - /* Here after at the end of the last row of the last pass. */ - png_read_finish_IDAT(png_ptr); -} -#endif /* SEQUENTIAL_READ */ - -void /* PRIVATE */ -png_read_start_row(png_structrp png_ptr) -{ - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* Start of interlace block */ - static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* Offset to next interlace block */ - static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* Start of interlace block in the y direction */ - static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* Offset to next interlace block in the y direction */ - static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; - - unsigned int max_pixel_depth; - size_t row_bytes; - - png_debug(1, "in png_read_start_row"); - -#ifdef PNG_READ_TRANSFORMS_SUPPORTED - png_init_read_transformations(png_ptr); -#endif - if (png_ptr->interlaced != 0) - { - if ((png_ptr->transformations & PNG_INTERLACE) == 0) - png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - - png_pass_ystart[0]) / png_pass_yinc[0]; - - else - png_ptr->num_rows = png_ptr->height; - - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - } - - else - { - png_ptr->num_rows = png_ptr->height; - png_ptr->iwidth = png_ptr->width; - } - - max_pixel_depth = (unsigned int)png_ptr->pixel_depth; - - /* WARNING: * png_read_transform_info (pngrtran.c) performs a simpler set of - * calculations to calculate the final pixel depth, then - * png_do_read_transforms actually does the transforms. This means that the - * code which effectively calculates this value is actually repeated in three - * separate places. They must all match. Innocent changes to the order of - * transformations can and will break libpng in a way that causes memory - * overwrites. - * - * TODO: fix this. - */ -#ifdef PNG_READ_PACK_SUPPORTED - if ((png_ptr->transformations & PNG_PACK) != 0 && png_ptr->bit_depth < 8) - max_pixel_depth = 8; -#endif - -#ifdef PNG_READ_EXPAND_SUPPORTED - if ((png_ptr->transformations & PNG_EXPAND) != 0) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (png_ptr->num_trans != 0) - max_pixel_depth = 32; - - else - max_pixel_depth = 24; - } - - else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - if (max_pixel_depth < 8) - max_pixel_depth = 8; - - if (png_ptr->num_trans != 0) - max_pixel_depth *= 2; - } - - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB) - { - if (png_ptr->num_trans != 0) - { - max_pixel_depth *= 4; - max_pixel_depth /= 3; - } - } - } -#endif - -#ifdef PNG_READ_EXPAND_16_SUPPORTED - if ((png_ptr->transformations & PNG_EXPAND_16) != 0) - { -# ifdef PNG_READ_EXPAND_SUPPORTED - /* In fact it is an error if it isn't supported, but checking is - * the safe way. - */ - if ((png_ptr->transformations & PNG_EXPAND) != 0) - { - if (png_ptr->bit_depth < 16) - max_pixel_depth *= 2; - } - else -# endif - png_ptr->transformations &= ~PNG_EXPAND_16; - } -#endif - -#ifdef PNG_READ_FILLER_SUPPORTED - if ((png_ptr->transformations & (PNG_FILLER)) != 0) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { - if (max_pixel_depth <= 8) - max_pixel_depth = 16; - - else - max_pixel_depth = 32; - } - - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB || - png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - if (max_pixel_depth <= 32) - max_pixel_depth = 32; - - else - max_pixel_depth = 64; - } - } -#endif - -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED - if ((png_ptr->transformations & PNG_GRAY_TO_RGB) != 0) - { - if ( -#ifdef PNG_READ_EXPAND_SUPPORTED - (png_ptr->num_trans != 0 && - (png_ptr->transformations & PNG_EXPAND) != 0) || -#endif -#ifdef PNG_READ_FILLER_SUPPORTED - (png_ptr->transformations & (PNG_FILLER)) != 0 || -#endif - png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - if (max_pixel_depth <= 16) - max_pixel_depth = 32; - - else - max_pixel_depth = 64; - } - - else - { - if (max_pixel_depth <= 8) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - max_pixel_depth = 32; - - else - max_pixel_depth = 24; - } - - else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - max_pixel_depth = 64; - - else - max_pixel_depth = 48; - } - } -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \ -defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0) - { - unsigned int user_pixel_depth = png_ptr->user_transform_depth * - png_ptr->user_transform_channels; - - if (user_pixel_depth > max_pixel_depth) - max_pixel_depth = user_pixel_depth; - } -#endif - - /* This value is stored in png_struct and double checked in the row read - * code. - */ - png_ptr->maximum_pixel_depth = (png_byte)max_pixel_depth; - png_ptr->transformed_pixel_depth = 0; /* calculated on demand */ - - /* Align the width on the next larger 8 pixels. Mainly used - * for interlacing - */ - row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7)); - /* Calculate the maximum bytes needed, adding a byte and a pixel - * for safety's sake - */ - row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) + - 1 + ((max_pixel_depth + 7) >> 3U); - -#ifdef PNG_MAX_MALLOC_64K - if (row_bytes > (png_uint_32)65536L) - png_error(png_ptr, "This image requires a row greater than 64KB"); -#endif - - if (row_bytes + 48 > png_ptr->old_big_row_buf_size) - { - png_free(png_ptr, png_ptr->big_row_buf); - png_free(png_ptr, png_ptr->big_prev_row); - - if (png_ptr->interlaced != 0) - png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr, - row_bytes + 48); - - else - png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 48); - - png_ptr->big_prev_row = (png_bytep)png_malloc(png_ptr, row_bytes + 48); - -#ifdef PNG_ALIGNED_MEMORY_SUPPORTED - /* Use 16-byte aligned memory for row_buf with at least 16 bytes - * of padding before and after row_buf; treat prev_row similarly. - * NOTE: the alignment is to the start of the pixels, one beyond the start - * of the buffer, because of the filter byte. Prior to libpng 1.5.6 this - * was incorrect; the filter byte was aligned, which had the exact - * opposite effect of that intended. - */ - { - png_bytep temp = png_ptr->big_row_buf + 32; - int extra = (int)((temp - (png_bytep)0) & 0x0f); - png_ptr->row_buf = temp - extra - 1/*filter byte*/; - - temp = png_ptr->big_prev_row + 32; - extra = (int)((temp - (png_bytep)0) & 0x0f); - png_ptr->prev_row = temp - extra - 1/*filter byte*/; - } - -#else - /* Use 31 bytes of padding before and 17 bytes after row_buf. */ - png_ptr->row_buf = png_ptr->big_row_buf + 31; - png_ptr->prev_row = png_ptr->big_prev_row + 31; -#endif - png_ptr->old_big_row_buf_size = row_bytes + 48; - } - -#ifdef PNG_MAX_MALLOC_64K - if (png_ptr->rowbytes > 65535) - png_error(png_ptr, "This image requires a row greater than 64KB"); - -#endif - if (png_ptr->rowbytes > (PNG_SIZE_MAX - 1)) - png_error(png_ptr, "Row has too many bytes to allocate in memory"); - - memset(png_ptr->prev_row, 0, png_ptr->rowbytes + 1); - - png_debug1(3, "width = %u,", png_ptr->width); - png_debug1(3, "height = %u,", png_ptr->height); - png_debug1(3, "iwidth = %u,", png_ptr->iwidth); - png_debug1(3, "num_rows = %u,", png_ptr->num_rows); - png_debug1(3, "rowbytes = %lu,", (unsigned long)png_ptr->rowbytes); - png_debug1(3, "irowbytes = %lu", - (unsigned long)PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1); - - /* The sequential reader needs a buffer for IDAT, but the progressive reader - * does not, so free the read buffer now regardless; the sequential reader - * reallocates it on demand. - */ - if (png_ptr->read_buffer != NULL) - { - png_bytep buffer = png_ptr->read_buffer; - - png_ptr->read_buffer_size = 0; - png_ptr->read_buffer = NULL; - png_free(png_ptr, buffer); - } - - /* Finally claim the zstream for the inflate of the IDAT data, use the bits - * value from the stream (note that this will result in a fatal error if the - * IDAT stream has a bogus deflate header window_bits value, but this should - * not be happening any longer!) - */ - if (png_inflate_claim(png_ptr, png_IDAT) != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg); - - png_ptr->flags |= PNG_FLAG_ROW_INIT; -} -#endif /* READ */ diff --git a/oversampling/WDL/libpng/pngset.c b/oversampling/WDL/libpng/pngset.c deleted file mode 100644 index ec75dbe..0000000 --- a/oversampling/WDL/libpng/pngset.c +++ /dev/null @@ -1,1802 +0,0 @@ - -/* pngset.c - storage of image information into info struct - * - * Copyright (c) 2018 Cosmin Truta - * Copyright (c) 1998-2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * - * The functions here are used during reads to store data from the file - * into the info struct, and during writes to store application data - * into the info struct for writing into the file. This abstracts the - * info struct and allows us to change the structure in the future. - */ - -#include "pngpriv.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) - -#ifdef PNG_bKGD_SUPPORTED -void PNGAPI -png_set_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, - png_const_color_16p background) -{ - png_debug1(1, "in %s storage function", "bKGD"); - - if (png_ptr == NULL || info_ptr == NULL || background == NULL) - return; - - info_ptr->background = *background; - info_ptr->valid |= PNG_INFO_bKGD; -} -#endif - -#ifdef PNG_cHRM_SUPPORTED -void PNGFAPI -png_set_cHRM_fixed(png_const_structrp png_ptr, png_inforp info_ptr, - png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, - png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, - png_fixed_point blue_x, png_fixed_point blue_y) -{ - png_xy xy; - - png_debug1(1, "in %s storage function", "cHRM fixed"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - xy.redx = red_x; - xy.redy = red_y; - xy.greenx = green_x; - xy.greeny = green_y; - xy.bluex = blue_x; - xy.bluey = blue_y; - xy.whitex = white_x; - xy.whitey = white_y; - - if (png_colorspace_set_chromaticities(png_ptr, &info_ptr->colorspace, &xy, - 2/* override with app values*/) != 0) - info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM; - - png_colorspace_sync_info(png_ptr, info_ptr); -} - -void PNGFAPI -png_set_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_inforp info_ptr, - png_fixed_point int_red_X, png_fixed_point int_red_Y, - png_fixed_point int_red_Z, png_fixed_point int_green_X, - png_fixed_point int_green_Y, png_fixed_point int_green_Z, - png_fixed_point int_blue_X, png_fixed_point int_blue_Y, - png_fixed_point int_blue_Z) -{ - png_XYZ XYZ; - - png_debug1(1, "in %s storage function", "cHRM XYZ fixed"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - XYZ.red_X = int_red_X; - XYZ.red_Y = int_red_Y; - XYZ.red_Z = int_red_Z; - XYZ.green_X = int_green_X; - XYZ.green_Y = int_green_Y; - XYZ.green_Z = int_green_Z; - XYZ.blue_X = int_blue_X; - XYZ.blue_Y = int_blue_Y; - XYZ.blue_Z = int_blue_Z; - - if (png_colorspace_set_endpoints(png_ptr, &info_ptr->colorspace, - &XYZ, 2) != 0) - info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM; - - png_colorspace_sync_info(png_ptr, info_ptr); -} - -# ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_cHRM(png_const_structrp png_ptr, png_inforp info_ptr, - double white_x, double white_y, double red_x, double red_y, - double green_x, double green_y, double blue_x, double blue_y) -{ - png_set_cHRM_fixed(png_ptr, info_ptr, - png_fixed(png_ptr, white_x, "cHRM White X"), - png_fixed(png_ptr, white_y, "cHRM White Y"), - png_fixed(png_ptr, red_x, "cHRM Red X"), - png_fixed(png_ptr, red_y, "cHRM Red Y"), - png_fixed(png_ptr, green_x, "cHRM Green X"), - png_fixed(png_ptr, green_y, "cHRM Green Y"), - png_fixed(png_ptr, blue_x, "cHRM Blue X"), - png_fixed(png_ptr, blue_y, "cHRM Blue Y")); -} - -void PNGAPI -png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X, - double red_Y, double red_Z, double green_X, double green_Y, double green_Z, - double blue_X, double blue_Y, double blue_Z) -{ - png_set_cHRM_XYZ_fixed(png_ptr, info_ptr, - png_fixed(png_ptr, red_X, "cHRM Red X"), - png_fixed(png_ptr, red_Y, "cHRM Red Y"), - png_fixed(png_ptr, red_Z, "cHRM Red Z"), - png_fixed(png_ptr, green_X, "cHRM Green X"), - png_fixed(png_ptr, green_Y, "cHRM Green Y"), - png_fixed(png_ptr, green_Z, "cHRM Green Z"), - png_fixed(png_ptr, blue_X, "cHRM Blue X"), - png_fixed(png_ptr, blue_Y, "cHRM Blue Y"), - png_fixed(png_ptr, blue_Z, "cHRM Blue Z")); -} -# endif /* FLOATING_POINT */ - -#endif /* cHRM */ - -#ifdef PNG_eXIf_SUPPORTED -void PNGAPI -png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr, - png_bytep eXIf_buf) -{ - png_warning(png_ptr, "png_set_eXIf does not work; use png_set_eXIf_1"); - PNG_UNUSED(info_ptr) - PNG_UNUSED(eXIf_buf) -} - -void PNGAPI -png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr, - png_uint_32 num_exif, png_bytep eXIf_buf) -{ - int i; - - png_debug1(1, "in %s storage function", "eXIf"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (info_ptr->exif) - { - png_free(png_ptr, info_ptr->exif); - info_ptr->exif = NULL; - } - - info_ptr->num_exif = num_exif; - - info_ptr->exif = png_voidcast(png_bytep, png_malloc_warn(png_ptr, - info_ptr->num_exif)); - - if (info_ptr->exif == NULL) - { - png_warning(png_ptr, "Insufficient memory for eXIf chunk data"); - return; - } - - info_ptr->free_me |= PNG_FREE_EXIF; - - for (i = 0; i < (int) info_ptr->num_exif; i++) - info_ptr->exif[i] = eXIf_buf[i]; - - info_ptr->valid |= PNG_INFO_eXIf; -} -#endif /* eXIf */ - -#ifdef PNG_gAMA_SUPPORTED -void PNGFAPI -png_set_gAMA_fixed(png_const_structrp png_ptr, png_inforp info_ptr, - png_fixed_point file_gamma) -{ - png_debug1(1, "in %s storage function", "gAMA"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_colorspace_set_gamma(png_ptr, &info_ptr->colorspace, file_gamma); - png_colorspace_sync_info(png_ptr, info_ptr); -} - -# ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_gAMA(png_const_structrp png_ptr, png_inforp info_ptr, double file_gamma) -{ - png_set_gAMA_fixed(png_ptr, info_ptr, png_fixed(png_ptr, file_gamma, - "png_set_gAMA")); -} -# endif -#endif - -#ifdef PNG_hIST_SUPPORTED -void PNGAPI -png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr, - png_const_uint_16p hist) -{ - int i; - - png_debug1(1, "in %s storage function", "hIST"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (info_ptr->num_palette == 0 || info_ptr->num_palette - > PNG_MAX_PALETTE_LENGTH) - { - png_warning(png_ptr, - "Invalid palette size, hIST allocation skipped"); - - return; - } - - png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); - - /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in - * version 1.2.1 - */ - info_ptr->hist = png_voidcast(png_uint_16p, png_malloc_warn(png_ptr, - PNG_MAX_PALETTE_LENGTH * (sizeof (png_uint_16)))); - - if (info_ptr->hist == NULL) - { - png_warning(png_ptr, "Insufficient memory for hIST chunk data"); - - return; - } - - info_ptr->free_me |= PNG_FREE_HIST; - - for (i = 0; i < info_ptr->num_palette; i++) - info_ptr->hist[i] = hist[i]; - - info_ptr->valid |= PNG_INFO_hIST; -} -#endif - -void PNGAPI -png_set_IHDR(png_const_structrp png_ptr, png_inforp info_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_type, int compression_type, - int filter_type) -{ - png_debug1(1, "in %s storage function", "IHDR"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->width = width; - info_ptr->height = height; - info_ptr->bit_depth = (png_byte)bit_depth; - info_ptr->color_type = (png_byte)color_type; - info_ptr->compression_type = (png_byte)compression_type; - info_ptr->filter_type = (png_byte)filter_type; - info_ptr->interlace_type = (png_byte)interlace_type; - - png_check_IHDR (png_ptr, info_ptr->width, info_ptr->height, - info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type, - info_ptr->compression_type, info_ptr->filter_type); - - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - info_ptr->channels = 1; - - else if ((info_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) - info_ptr->channels = 3; - - else - info_ptr->channels = 1; - - if ((info_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0) - info_ptr->channels++; - - info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); - - info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width); -} - -#ifdef PNG_oFFs_SUPPORTED -void PNGAPI -png_set_oFFs(png_const_structrp png_ptr, png_inforp info_ptr, - png_int_32 offset_x, png_int_32 offset_y, int unit_type) -{ - png_debug1(1, "in %s storage function", "oFFs"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->x_offset = offset_x; - info_ptr->y_offset = offset_y; - info_ptr->offset_unit_type = (png_byte)unit_type; - info_ptr->valid |= PNG_INFO_oFFs; -} -#endif - -#ifdef PNG_pCAL_SUPPORTED -void PNGAPI -png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, - png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, - int nparams, png_const_charp units, png_charpp params) -{ - size_t length; - int i; - - png_debug1(1, "in %s storage function", "pCAL"); - - if (png_ptr == NULL || info_ptr == NULL || purpose == NULL || units == NULL - || (nparams > 0 && params == NULL)) - return; - - length = strlen(purpose) + 1; - png_debug1(3, "allocating purpose for info (%lu bytes)", - (unsigned long)length); - - /* TODO: validate format of calibration name and unit name */ - - /* Check that the type matches the specification. */ - if (type < 0 || type > 3) - { - png_chunk_report(png_ptr, "Invalid pCAL equation type", - PNG_CHUNK_WRITE_ERROR); - return; - } - - if (nparams < 0 || nparams > 255) - { - png_chunk_report(png_ptr, "Invalid pCAL parameter count", - PNG_CHUNK_WRITE_ERROR); - return; - } - - /* Validate params[nparams] */ - for (i=0; ipcal_purpose = png_voidcast(png_charp, - png_malloc_warn(png_ptr, length)); - - if (info_ptr->pcal_purpose == NULL) - { - png_chunk_report(png_ptr, "Insufficient memory for pCAL purpose", - PNG_CHUNK_WRITE_ERROR); - return; - } - - memcpy(info_ptr->pcal_purpose, purpose, length); - - png_debug(3, "storing X0, X1, type, and nparams in info"); - info_ptr->pcal_X0 = X0; - info_ptr->pcal_X1 = X1; - info_ptr->pcal_type = (png_byte)type; - info_ptr->pcal_nparams = (png_byte)nparams; - - length = strlen(units) + 1; - png_debug1(3, "allocating units for info (%lu bytes)", - (unsigned long)length); - - info_ptr->pcal_units = png_voidcast(png_charp, - png_malloc_warn(png_ptr, length)); - - if (info_ptr->pcal_units == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL units"); - - return; - } - - memcpy(info_ptr->pcal_units, units, length); - - info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr, - (size_t)(((unsigned int)nparams + 1) * (sizeof (png_charp))))); - - if (info_ptr->pcal_params == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL params"); - - return; - } - - memset(info_ptr->pcal_params, 0, ((unsigned int)nparams + 1) * - (sizeof (png_charp))); - - for (i = 0; i < nparams; i++) - { - length = strlen(params[i]) + 1; - png_debug2(3, "allocating parameter %d for info (%lu bytes)", i, - (unsigned long)length); - - info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); - - if (info_ptr->pcal_params[i] == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL parameter"); - - return; - } - - memcpy(info_ptr->pcal_params[i], params[i], length); - } - - info_ptr->valid |= PNG_INFO_pCAL; - info_ptr->free_me |= PNG_FREE_PCAL; -} -#endif - -#ifdef PNG_sCAL_SUPPORTED -void PNGAPI -png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr, - int unit, png_const_charp swidth, png_const_charp sheight) -{ - size_t lengthw = 0, lengthh = 0; - - png_debug1(1, "in %s storage function", "sCAL"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - /* Double check the unit (should never get here with an invalid - * unit unless this is an API call.) - */ - if (unit != 1 && unit != 2) - png_error(png_ptr, "Invalid sCAL unit"); - - if (swidth == NULL || (lengthw = strlen(swidth)) == 0 || - swidth[0] == 45 /* '-' */ || !png_check_fp_string(swidth, lengthw)) - png_error(png_ptr, "Invalid sCAL width"); - - if (sheight == NULL || (lengthh = strlen(sheight)) == 0 || - sheight[0] == 45 /* '-' */ || !png_check_fp_string(sheight, lengthh)) - png_error(png_ptr, "Invalid sCAL height"); - - info_ptr->scal_unit = (png_byte)unit; - - ++lengthw; - - png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthw); - - info_ptr->scal_s_width = png_voidcast(png_charp, - png_malloc_warn(png_ptr, lengthw)); - - if (info_ptr->scal_s_width == NULL) - { - png_warning(png_ptr, "Memory allocation failed while processing sCAL"); - - return; - } - - memcpy(info_ptr->scal_s_width, swidth, lengthw); - - ++lengthh; - - png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthh); - - info_ptr->scal_s_height = png_voidcast(png_charp, - png_malloc_warn(png_ptr, lengthh)); - - if (info_ptr->scal_s_height == NULL) - { - png_free (png_ptr, info_ptr->scal_s_width); - info_ptr->scal_s_width = NULL; - - png_warning(png_ptr, "Memory allocation failed while processing sCAL"); - - return; - } - - memcpy(info_ptr->scal_s_height, sheight, lengthh); - - info_ptr->valid |= PNG_INFO_sCAL; - info_ptr->free_me |= PNG_FREE_SCAL; -} - -# ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit, - double width, double height) -{ - png_debug1(1, "in %s storage function", "sCAL"); - - /* Check the arguments. */ - if (width <= 0) - png_warning(png_ptr, "Invalid sCAL width ignored"); - - else if (height <= 0) - png_warning(png_ptr, "Invalid sCAL height ignored"); - - else - { - /* Convert 'width' and 'height' to ASCII. */ - char swidth[PNG_sCAL_MAX_DIGITS+1]; - char sheight[PNG_sCAL_MAX_DIGITS+1]; - - png_ascii_from_fp(png_ptr, swidth, (sizeof swidth), width, - PNG_sCAL_PRECISION); - png_ascii_from_fp(png_ptr, sheight, (sizeof sheight), height, - PNG_sCAL_PRECISION); - - png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight); - } -} -# endif - -# ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_sCAL_fixed(png_const_structrp png_ptr, png_inforp info_ptr, int unit, - png_fixed_point width, png_fixed_point height) -{ - png_debug1(1, "in %s storage function", "sCAL"); - - /* Check the arguments. */ - if (width <= 0) - png_warning(png_ptr, "Invalid sCAL width ignored"); - - else if (height <= 0) - png_warning(png_ptr, "Invalid sCAL height ignored"); - - else - { - /* Convert 'width' and 'height' to ASCII. */ - char swidth[PNG_sCAL_MAX_DIGITS+1]; - char sheight[PNG_sCAL_MAX_DIGITS+1]; - - png_ascii_from_fixed(png_ptr, swidth, (sizeof swidth), width); - png_ascii_from_fixed(png_ptr, sheight, (sizeof sheight), height); - - png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight); - } -} -# endif -#endif - -#ifdef PNG_pHYs_SUPPORTED -void PNGAPI -png_set_pHYs(png_const_structrp png_ptr, png_inforp info_ptr, - png_uint_32 res_x, png_uint_32 res_y, int unit_type) -{ - png_debug1(1, "in %s storage function", "pHYs"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - info_ptr->x_pixels_per_unit = res_x; - info_ptr->y_pixels_per_unit = res_y; - info_ptr->phys_unit_type = (png_byte)unit_type; - info_ptr->valid |= PNG_INFO_pHYs; -} -#endif - -void PNGAPI -png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, - png_const_colorp palette, int num_palette) -{ - - png_uint_32 max_palette_length; - - png_debug1(1, "in %s storage function", "PLTE"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - max_palette_length = (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ? - (1 << info_ptr->bit_depth) : PNG_MAX_PALETTE_LENGTH; - - if (num_palette < 0 || num_palette > (int) max_palette_length) - { - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - png_error(png_ptr, "Invalid palette length"); - - else - { - png_warning(png_ptr, "Invalid palette length"); - - return; - } - } - - if ((num_palette > 0 && palette == NULL) || - (num_palette == 0 -# ifdef PNG_MNG_FEATURES_SUPPORTED - && (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0 -# endif - )) - { - png_error(png_ptr, "Invalid palette"); - } - - /* It may not actually be necessary to set png_ptr->palette here; - * we do it for backward compatibility with the way the png_handle_tRNS - * function used to do the allocation. - * - * 1.6.0: the above statement appears to be incorrect; something has to set - * the palette inside png_struct on read. - */ - png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0); - - /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead - * of num_palette entries, in case of an invalid PNG file or incorrect - * call to png_set_PLTE() with too-large sample values. - */ - png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr, - PNG_MAX_PALETTE_LENGTH * (sizeof (png_color)))); - - if (num_palette > 0) - memcpy(png_ptr->palette, palette, (unsigned int)num_palette * - (sizeof (png_color))); - info_ptr->palette = png_ptr->palette; - info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; - - info_ptr->free_me |= PNG_FREE_PLTE; - - info_ptr->valid |= PNG_INFO_PLTE; -} - -#ifdef PNG_sBIT_SUPPORTED -void PNGAPI -png_set_sBIT(png_const_structrp png_ptr, png_inforp info_ptr, - png_const_color_8p sig_bit) -{ - png_debug1(1, "in %s storage function", "sBIT"); - - if (png_ptr == NULL || info_ptr == NULL || sig_bit == NULL) - return; - - info_ptr->sig_bit = *sig_bit; - info_ptr->valid |= PNG_INFO_sBIT; -} -#endif - -#ifdef PNG_sRGB_SUPPORTED -void PNGAPI -png_set_sRGB(png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent) -{ - png_debug1(1, "in %s storage function", "sRGB"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - (void)png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent); - png_colorspace_sync_info(png_ptr, info_ptr); -} - -void PNGAPI -png_set_sRGB_gAMA_and_cHRM(png_const_structrp png_ptr, png_inforp info_ptr, - int srgb_intent) -{ - png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, - srgb_intent) != 0) - { - /* This causes the gAMA and cHRM to be written too */ - info_ptr->colorspace.flags |= - PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM; - } - - png_colorspace_sync_info(png_ptr, info_ptr); -} -#endif /* sRGB */ - - -#ifdef PNG_iCCP_SUPPORTED -void PNGAPI -png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, - png_const_charp name, int compression_type, - png_const_bytep profile, png_uint_32 proflen) -{ - png_charp new_iccp_name; - png_bytep new_iccp_profile; - size_t length; - - png_debug1(1, "in %s storage function", "iCCP"); - - if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) - return; - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - png_app_error(png_ptr, "Invalid iCCP compression method"); - - /* Set the colorspace first because this validates the profile; do not - * override previously set app cHRM or gAMA here (because likely as not the - * application knows better than libpng what the correct values are.) Pass - * the info_ptr color_type field to png_colorspace_set_ICC because in the - * write case it has not yet been stored in png_ptr. - */ - { - int result = png_colorspace_set_ICC(png_ptr, &info_ptr->colorspace, name, - proflen, profile, info_ptr->color_type); - - png_colorspace_sync_info(png_ptr, info_ptr); - - /* Don't do any of the copying if the profile was bad, or inconsistent. */ - if (result == 0) - return; - - /* But do write the gAMA and cHRM chunks from the profile. */ - info_ptr->colorspace.flags |= - PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM; - } - - length = strlen(name)+1; - new_iccp_name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length)); - - if (new_iccp_name == NULL) - { - png_benign_error(png_ptr, "Insufficient memory to process iCCP chunk"); - - return; - } - - memcpy(new_iccp_name, name, length); - new_iccp_profile = png_voidcast(png_bytep, - png_malloc_warn(png_ptr, proflen)); - - if (new_iccp_profile == NULL) - { - png_free(png_ptr, new_iccp_name); - png_benign_error(png_ptr, - "Insufficient memory to process iCCP profile"); - - return; - } - - memcpy(new_iccp_profile, profile, proflen); - - png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0); - - info_ptr->iccp_proflen = proflen; - info_ptr->iccp_name = new_iccp_name; - info_ptr->iccp_profile = new_iccp_profile; - info_ptr->free_me |= PNG_FREE_ICCP; - info_ptr->valid |= PNG_INFO_iCCP; -} -#endif - -#ifdef PNG_TEXT_SUPPORTED -void PNGAPI -png_set_text(png_const_structrp png_ptr, png_inforp info_ptr, - png_const_textp text_ptr, int num_text) -{ - int ret; - ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); - - if (ret != 0) - png_error(png_ptr, "Insufficient memory to store text"); -} - -int /* PRIVATE */ -png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, - png_const_textp text_ptr, int num_text) -{ - int i; - - png_debug1(1, "in %lx storage function", png_ptr == NULL ? 0xabadca11U : - (unsigned long)png_ptr->chunk_name); - - if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL) - return(0); - - /* Make sure we have enough space in the "text" array in info_struct - * to hold all of the incoming text_ptr objects. This compare can't overflow - * because max_text >= num_text (anyway, subtract of two positive integers - * can't overflow in any case.) - */ - if (num_text > info_ptr->max_text - info_ptr->num_text) - { - int old_num_text = info_ptr->num_text; - int max_text; - png_textp new_text = NULL; - - /* Calculate an appropriate max_text, checking for overflow. */ - max_text = old_num_text; - if (num_text <= INT_MAX - max_text) - { - max_text += num_text; - - /* Round up to a multiple of 8 */ - if (max_text < INT_MAX-8) - max_text = (max_text + 8) & ~0x7; - - else - max_text = INT_MAX; - - /* Now allocate a new array and copy the old members in; this does all - * the overflow checks. - */ - new_text = png_voidcast(png_textp,png_realloc_array(png_ptr, - info_ptr->text, old_num_text, max_text-old_num_text, - sizeof *new_text)); - } - - if (new_text == NULL) - { - png_chunk_report(png_ptr, "too many text chunks", - PNG_CHUNK_WRITE_ERROR); - - return 1; - } - - png_free(png_ptr, info_ptr->text); - - info_ptr->text = new_text; - info_ptr->free_me |= PNG_FREE_TEXT; - info_ptr->max_text = max_text; - /* num_text is adjusted below as the entries are copied in */ - - png_debug1(3, "allocated %d entries for info_ptr->text", max_text); - } - - for (i = 0; i < num_text; i++) - { - size_t text_length, key_len; - size_t lang_len, lang_key_len; - png_textp textp = &(info_ptr->text[info_ptr->num_text]); - - if (text_ptr[i].key == NULL) - continue; - - if (text_ptr[i].compression < PNG_TEXT_COMPRESSION_NONE || - text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST) - { - png_chunk_report(png_ptr, "text compression mode is out of range", - PNG_CHUNK_WRITE_ERROR); - continue; - } - - key_len = strlen(text_ptr[i].key); - - if (text_ptr[i].compression <= 0) - { - lang_len = 0; - lang_key_len = 0; - } - - else -# ifdef PNG_iTXt_SUPPORTED - { - /* Set iTXt data */ - - if (text_ptr[i].lang != NULL) - lang_len = strlen(text_ptr[i].lang); - - else - lang_len = 0; - - if (text_ptr[i].lang_key != NULL) - lang_key_len = strlen(text_ptr[i].lang_key); - - else - lang_key_len = 0; - } -# else /* iTXt */ - { - png_chunk_report(png_ptr, "iTXt chunk not supported", - PNG_CHUNK_WRITE_ERROR); - continue; - } -# endif - - if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0') - { - text_length = 0; -# ifdef PNG_iTXt_SUPPORTED - if (text_ptr[i].compression > 0) - textp->compression = PNG_ITXT_COMPRESSION_NONE; - - else -# endif - textp->compression = PNG_TEXT_COMPRESSION_NONE; - } - - else - { - text_length = strlen(text_ptr[i].text); - textp->compression = text_ptr[i].compression; - } - - textp->key = png_voidcast(png_charp,png_malloc_base(png_ptr, - key_len + text_length + lang_len + lang_key_len + 4)); - - if (textp->key == NULL) - { - png_chunk_report(png_ptr, "text chunk: out of memory", - PNG_CHUNK_WRITE_ERROR); - - return 1; - } - - png_debug2(2, "Allocated %lu bytes at %p in png_set_text", - (unsigned long)(png_uint_32) - (key_len + lang_len + lang_key_len + text_length + 4), - textp->key); - - memcpy(textp->key, text_ptr[i].key, key_len); - *(textp->key + key_len) = '\0'; - - if (text_ptr[i].compression > 0) - { - textp->lang = textp->key + key_len + 1; - memcpy(textp->lang, text_ptr[i].lang, lang_len); - *(textp->lang + lang_len) = '\0'; - textp->lang_key = textp->lang + lang_len + 1; - memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); - *(textp->lang_key + lang_key_len) = '\0'; - textp->text = textp->lang_key + lang_key_len + 1; - } - - else - { - textp->lang=NULL; - textp->lang_key=NULL; - textp->text = textp->key + key_len + 1; - } - - if (text_length != 0) - memcpy(textp->text, text_ptr[i].text, text_length); - - *(textp->text + text_length) = '\0'; - -# ifdef PNG_iTXt_SUPPORTED - if (textp->compression > 0) - { - textp->text_length = 0; - textp->itxt_length = text_length; - } - - else -# endif - { - textp->text_length = text_length; - textp->itxt_length = 0; - } - - info_ptr->num_text++; - png_debug1(3, "transferred text chunk %d", info_ptr->num_text); - } - - return(0); -} -#endif - -#ifdef PNG_tIME_SUPPORTED -void PNGAPI -png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr, - png_const_timep mod_time) -{ - png_debug1(1, "in %s storage function", "tIME"); - - if (png_ptr == NULL || info_ptr == NULL || mod_time == NULL || - (png_ptr->mode & PNG_WROTE_tIME) != 0) - return; - - if (mod_time->month == 0 || mod_time->month > 12 || - mod_time->day == 0 || mod_time->day > 31 || - mod_time->hour > 23 || mod_time->minute > 59 || - mod_time->second > 60) - { - png_warning(png_ptr, "Ignoring invalid time value"); - - return; - } - - info_ptr->mod_time = *mod_time; - info_ptr->valid |= PNG_INFO_tIME; -} -#endif - -#ifdef PNG_tRNS_SUPPORTED -void PNGAPI -png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, - png_const_bytep trans_alpha, int num_trans, png_const_color_16p trans_color) -{ - png_debug1(1, "in %s storage function", "tRNS"); - - if (png_ptr == NULL || info_ptr == NULL) - - return; - - if (trans_alpha != NULL) - { - /* It may not actually be necessary to set png_ptr->trans_alpha here; - * we do it for backward compatibility with the way the png_handle_tRNS - * function used to do the allocation. - * - * 1.6.0: The above statement is incorrect; png_handle_tRNS effectively - * relies on png_set_tRNS storing the information in png_struct - * (otherwise it won't be there for the code in pngrtran.c). - */ - - png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); - - if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH) - { - /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ - info_ptr->trans_alpha = png_voidcast(png_bytep, - png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH)); - memcpy(info_ptr->trans_alpha, trans_alpha, (size_t)num_trans); - } - png_ptr->trans_alpha = info_ptr->trans_alpha; - } - - if (trans_color != NULL) - { -#ifdef PNG_WARNINGS_SUPPORTED - if (info_ptr->bit_depth < 16) - { - int sample_max = (1 << info_ptr->bit_depth) - 1; - - if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY && - trans_color->gray > sample_max) || - (info_ptr->color_type == PNG_COLOR_TYPE_RGB && - (trans_color->red > sample_max || - trans_color->green > sample_max || - trans_color->blue > sample_max))) - png_warning(png_ptr, - "tRNS chunk has out-of-range samples for bit_depth"); - } -#endif - - info_ptr->trans_color = *trans_color; - - if (num_trans == 0) - num_trans = 1; - } - - info_ptr->num_trans = (png_uint_16)num_trans; - - if (num_trans != 0) - { - info_ptr->valid |= PNG_INFO_tRNS; - info_ptr->free_me |= PNG_FREE_TRNS; - } -} -#endif - -#ifdef PNG_sPLT_SUPPORTED -void PNGAPI -png_set_sPLT(png_const_structrp png_ptr, - png_inforp info_ptr, png_const_sPLT_tp entries, int nentries) -/* - * entries - array of png_sPLT_t structures - * to be added to the list of palettes - * in the info structure. - * - * nentries - number of palette structures to be - * added. - */ -{ - png_sPLT_tp np; - - if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 || entries == NULL) - return; - - /* Use the internal realloc function, which checks for all the possible - * overflows. Notice that the parameters are (int) and (size_t) - */ - np = png_voidcast(png_sPLT_tp,png_realloc_array(png_ptr, - info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries, - sizeof *np)); - - if (np == NULL) - { - /* Out of memory or too many chunks */ - png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR); - - return; - } - - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes = np; - info_ptr->free_me |= PNG_FREE_SPLT; - - np += info_ptr->splt_palettes_num; - - do - { - size_t length; - - /* Skip invalid input entries */ - if (entries->name == NULL || entries->entries == NULL) - { - /* png_handle_sPLT doesn't do this, so this is an app error */ - png_app_error(png_ptr, "png_set_sPLT: invalid sPLT"); - /* Just skip the invalid entry */ - continue; - } - - np->depth = entries->depth; - - /* In the event of out-of-memory just return - there's no point keeping - * on trying to add sPLT chunks. - */ - length = strlen(entries->name) + 1; - np->name = png_voidcast(png_charp, png_malloc_base(png_ptr, length)); - - if (np->name == NULL) - break; - - memcpy(np->name, entries->name, length); - - /* IMPORTANT: we have memory now that won't get freed if something else - * goes wrong; this code must free it. png_malloc_array produces no - * warnings; use a png_chunk_report (below) if there is an error. - */ - np->entries = png_voidcast(png_sPLT_entryp, png_malloc_array(png_ptr, - entries->nentries, sizeof (png_sPLT_entry))); - - if (np->entries == NULL) - { - png_free(png_ptr, np->name); - np->name = NULL; - break; - } - - np->nentries = entries->nentries; - /* This multiply can't overflow because png_malloc_array has already - * checked it when doing the allocation. - */ - memcpy(np->entries, entries->entries, - (unsigned int)entries->nentries * sizeof (png_sPLT_entry)); - - /* Note that 'continue' skips the advance of the out pointer and out - * count, so an invalid entry is not added. - */ - info_ptr->valid |= PNG_INFO_sPLT; - ++(info_ptr->splt_palettes_num); - ++np; - ++entries; - } - while (--nentries); - - if (nentries > 0) - png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR); -} -#endif /* sPLT */ - -#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED -static png_byte -check_location(png_const_structrp png_ptr, int location) -{ - location &= (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT); - - /* New in 1.6.0; copy the location and check it. This is an API - * change; previously the app had to use the - * png_set_unknown_chunk_location API below for each chunk. - */ - if (location == 0 && (png_ptr->mode & PNG_IS_READ_STRUCT) == 0) - { - /* Write struct, so unknown chunks come from the app */ - png_app_warning(png_ptr, - "png_set_unknown_chunks now expects a valid location"); - /* Use the old behavior */ - location = (png_byte)(png_ptr->mode & - (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)); - } - - /* This need not be an internal error - if the app calls - * png_set_unknown_chunks on a read pointer it must get the location right. - */ - if (location == 0) - png_error(png_ptr, "invalid location in png_set_unknown_chunks"); - - /* Now reduce the location to the top-most set bit by removing each least - * significant bit in turn. - */ - while (location != (location & -location)) - location &= ~(location & -location); - - /* The cast is safe because 'location' is a bit mask and only the low four - * bits are significant. - */ - return (png_byte)location; -} - -void PNGAPI -png_set_unknown_chunks(png_const_structrp png_ptr, - png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns) -{ - png_unknown_chunkp np; - - if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0 || - unknowns == NULL) - return; - - /* Check for the failure cases where support has been disabled at compile - * time. This code is hardly ever compiled - it's here because - * STORE_UNKNOWN_CHUNKS is set by both read and write code (compiling in this - * code) but may be meaningless if the read or write handling of unknown - * chunks is not compiled in. - */ -# if !defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \ - defined(PNG_READ_SUPPORTED) - if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) - { - png_app_error(png_ptr, "no unknown chunk support on read"); - - return; - } -# endif -# if !defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \ - defined(PNG_WRITE_SUPPORTED) - if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0) - { - png_app_error(png_ptr, "no unknown chunk support on write"); - - return; - } -# endif - - /* Prior to 1.6.0 this code used png_malloc_warn; however, this meant that - * unknown critical chunks could be lost with just a warning resulting in - * undefined behavior. Now png_chunk_report is used to provide behavior - * appropriate to read or write. - */ - np = png_voidcast(png_unknown_chunkp, png_realloc_array(png_ptr, - info_ptr->unknown_chunks, info_ptr->unknown_chunks_num, num_unknowns, - sizeof *np)); - - if (np == NULL) - { - png_chunk_report(png_ptr, "too many unknown chunks", - PNG_CHUNK_WRITE_ERROR); - - return; - } - - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks = np; /* safe because it is initialized */ - info_ptr->free_me |= PNG_FREE_UNKN; - - np += info_ptr->unknown_chunks_num; - - /* Increment unknown_chunks_num each time round the loop to protect the - * just-allocated chunk data. - */ - for (; num_unknowns > 0; --num_unknowns, ++unknowns) - { - memcpy(np->name, unknowns->name, (sizeof np->name)); - np->name[(sizeof np->name)-1] = '\0'; - np->location = check_location(png_ptr, unknowns->location); - - if (unknowns->size == 0) - { - np->data = NULL; - np->size = 0; - } - - else - { - np->data = png_voidcast(png_bytep, - png_malloc_base(png_ptr, unknowns->size)); - - if (np->data == NULL) - { - png_chunk_report(png_ptr, "unknown chunk: out of memory", - PNG_CHUNK_WRITE_ERROR); - /* But just skip storing the unknown chunk */ - continue; - } - - memcpy(np->data, unknowns->data, unknowns->size); - np->size = unknowns->size; - } - - /* These increments are skipped on out-of-memory for the data - the - * unknown chunk entry gets overwritten if the png_chunk_report returns. - * This is correct in the read case (the chunk is just dropped.) - */ - ++np; - ++(info_ptr->unknown_chunks_num); - } -} - -void PNGAPI -png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr, - int chunk, int location) -{ - /* This API is pretty pointless in 1.6.0 because the location can be set - * before the call to png_set_unknown_chunks. - * - * TODO: add a png_app_warning in 1.7 - */ - if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && - chunk < info_ptr->unknown_chunks_num) - { - if ((location & (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)) == 0) - { - png_app_error(png_ptr, "invalid unknown chunk location"); - /* Fake out the pre 1.6.0 behavior: */ - if (((unsigned int)location & PNG_HAVE_IDAT) != 0) /* undocumented! */ - location = PNG_AFTER_IDAT; - - else - location = PNG_HAVE_IHDR; /* also undocumented */ - } - - info_ptr->unknown_chunks[chunk].location = - check_location(png_ptr, location); - } -} -#endif /* STORE_UNKNOWN_CHUNKS */ - -#ifdef PNG_MNG_FEATURES_SUPPORTED -png_uint_32 PNGAPI -png_permit_mng_features (png_structrp png_ptr, png_uint_32 mng_features) -{ - png_debug(1, "in png_permit_mng_features"); - - if (png_ptr == NULL) - return 0; - - png_ptr->mng_features_permitted = mng_features & PNG_ALL_MNG_FEATURES; - - return png_ptr->mng_features_permitted; -} -#endif - -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -static unsigned int -add_one_chunk(png_bytep list, unsigned int count, png_const_bytep add, int keep) -{ - unsigned int i; - - /* Utility function: update the 'keep' state of a chunk if it is already in - * the list, otherwise add it to the list. - */ - for (i=0; i= PNG_HANDLE_CHUNK_LAST) - { - png_app_error(png_ptr, "png_set_keep_unknown_chunks: invalid keep"); - - return; - } - - if (num_chunks_in <= 0) - { - png_ptr->unknown_default = keep; - - /* '0' means just set the flags, so stop here */ - if (num_chunks_in == 0) - return; - } - - if (num_chunks_in < 0) - { - /* Ignore all unknown chunks and all chunks recognized by - * libpng except for IHDR, PLTE, tRNS, IDAT, and IEND - */ - static const png_byte chunks_to_ignore[] = { - 98, 75, 71, 68, '\0', /* bKGD */ - 99, 72, 82, 77, '\0', /* cHRM */ - 101, 88, 73, 102, '\0', /* eXIf */ - 103, 65, 77, 65, '\0', /* gAMA */ - 104, 73, 83, 84, '\0', /* hIST */ - 105, 67, 67, 80, '\0', /* iCCP */ - 105, 84, 88, 116, '\0', /* iTXt */ - 111, 70, 70, 115, '\0', /* oFFs */ - 112, 67, 65, 76, '\0', /* pCAL */ - 112, 72, 89, 115, '\0', /* pHYs */ - 115, 66, 73, 84, '\0', /* sBIT */ - 115, 67, 65, 76, '\0', /* sCAL */ - 115, 80, 76, 84, '\0', /* sPLT */ - 115, 84, 69, 82, '\0', /* sTER */ - 115, 82, 71, 66, '\0', /* sRGB */ - 116, 69, 88, 116, '\0', /* tEXt */ - 116, 73, 77, 69, '\0', /* tIME */ - 122, 84, 88, 116, '\0' /* zTXt */ - }; - - chunk_list = chunks_to_ignore; - num_chunks = (unsigned int)/*SAFE*/(sizeof chunks_to_ignore)/5U; - } - - else /* num_chunks_in > 0 */ - { - if (chunk_list == NULL) - { - /* Prior to 1.6.0 this was silently ignored, now it is an app_error - * which can be switched off. - */ - png_app_error(png_ptr, "png_set_keep_unknown_chunks: no chunk list"); - - return; - } - - num_chunks = (unsigned int)num_chunks_in; - } - - old_num_chunks = png_ptr->num_chunk_list; - if (png_ptr->chunk_list == NULL) - old_num_chunks = 0; - - /* Since num_chunks is always restricted to UINT_MAX/5 this can't overflow. - */ - if (num_chunks + old_num_chunks > UINT_MAX/5) - { - png_app_error(png_ptr, "png_set_keep_unknown_chunks: too many chunks"); - - return; - } - - /* If these chunks are being reset to the default then no more memory is - * required because add_one_chunk above doesn't extend the list if the 'keep' - * parameter is the default. - */ - if (keep != 0) - { - new_list = png_voidcast(png_bytep, png_malloc(png_ptr, - 5 * (num_chunks + old_num_chunks))); - - if (old_num_chunks > 0) - memcpy(new_list, png_ptr->chunk_list, 5*old_num_chunks); - } - - else if (old_num_chunks > 0) - new_list = png_ptr->chunk_list; - - else - new_list = NULL; - - /* Add the new chunks together with each one's handling code. If the chunk - * already exists the code is updated, otherwise the chunk is added to the - * end. (In libpng 1.6.0 order no longer matters because this code enforces - * the earlier convention that the last setting is the one that is used.) - */ - if (new_list != NULL) - { - png_const_bytep inlist; - png_bytep outlist; - unsigned int i; - - for (i=0; ichunk_list != new_list) - png_free(png_ptr, new_list); - - new_list = NULL; - } - } - - else - num_chunks = 0; - - png_ptr->num_chunk_list = num_chunks; - - if (png_ptr->chunk_list != new_list) - { - if (png_ptr->chunk_list != NULL) - png_free(png_ptr, png_ptr->chunk_list); - - png_ptr->chunk_list = new_list; - } -} -#endif - -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED -void PNGAPI -png_set_read_user_chunk_fn(png_structrp png_ptr, png_voidp user_chunk_ptr, - png_user_chunk_ptr read_user_chunk_fn) -{ - png_debug(1, "in png_set_read_user_chunk_fn"); - - if (png_ptr == NULL) - return; - - png_ptr->read_user_chunk_fn = read_user_chunk_fn; - png_ptr->user_chunk_ptr = user_chunk_ptr; -} -#endif - -#ifdef PNG_INFO_IMAGE_SUPPORTED -void PNGAPI -png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr, - png_bytepp row_pointers) -{ - png_debug1(1, "in %s storage function", "rows"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - if (info_ptr->row_pointers != NULL && - (info_ptr->row_pointers != row_pointers)) - png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); - - info_ptr->row_pointers = row_pointers; - - if (row_pointers != NULL) - info_ptr->valid |= PNG_INFO_IDAT; -} -#endif - -void PNGAPI -png_set_compression_buffer_size(png_structrp png_ptr, size_t size) -{ - if (png_ptr == NULL) - return; - - if (size == 0 || size > PNG_UINT_31_MAX) - png_error(png_ptr, "invalid compression buffer size"); - -# ifdef PNG_SEQUENTIAL_READ_SUPPORTED - if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) - { - png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */ - return; - } -# endif - -# ifdef PNG_WRITE_SUPPORTED - if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0) - { - if (png_ptr->zowner != 0) - { - png_warning(png_ptr, - "Compression buffer size cannot be changed because it is in use"); - - return; - } - -#ifndef __COVERITY__ - /* Some compilers complain that this is always false. However, it - * can be true when integer overflow happens. - */ - if (size > ZLIB_IO_MAX) - { - png_warning(png_ptr, - "Compression buffer size limited to system maximum"); - size = ZLIB_IO_MAX; /* must fit */ - } -#endif - - if (size < 6) - { - /* Deflate will potentially go into an infinite loop on a SYNC_FLUSH - * if this is permitted. - */ - png_warning(png_ptr, - "Compression buffer size cannot be reduced below 6"); - - return; - } - - if (png_ptr->zbuffer_size != size) - { - png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list); - png_ptr->zbuffer_size = (uInt)size; - } - } -# endif -} - -void PNGAPI -png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask) -{ - if (png_ptr != NULL && info_ptr != NULL) - info_ptr->valid &= (unsigned int)(~mask); -} - - -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -/* This function was added to libpng 1.2.6 */ -void PNGAPI -png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max, - png_uint_32 user_height_max) -{ - /* Images with dimensions larger than these limits will be - * rejected by png_set_IHDR(). To accept any PNG datastream - * regardless of dimensions, set both limits to 0x7fffffff. - */ - if (png_ptr == NULL) - return; - - png_ptr->user_width_max = user_width_max; - png_ptr->user_height_max = user_height_max; -} - -/* This function was added to libpng 1.4.0 */ -void PNGAPI -png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max) -{ - if (png_ptr != NULL) - png_ptr->user_chunk_cache_max = user_chunk_cache_max; -} - -/* This function was added to libpng 1.4.1 */ -void PNGAPI -png_set_chunk_malloc_max (png_structrp png_ptr, - png_alloc_size_t user_chunk_malloc_max) -{ - if (png_ptr != NULL) - png_ptr->user_chunk_malloc_max = user_chunk_malloc_max; -} -#endif /* ?SET_USER_LIMITS */ - - -#ifdef PNG_BENIGN_ERRORS_SUPPORTED -void PNGAPI -png_set_benign_errors(png_structrp png_ptr, int allowed) -{ - png_debug(1, "in png_set_benign_errors"); - - /* If allowed is 1, png_benign_error() is treated as a warning. - * - * If allowed is 0, png_benign_error() is treated as an error (which - * is the default behavior if png_set_benign_errors() is not called). - */ - - if (allowed != 0) - png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN | - PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN; - - else - png_ptr->flags &= ~(PNG_FLAG_BENIGN_ERRORS_WARN | - PNG_FLAG_APP_WARNINGS_WARN | PNG_FLAG_APP_ERRORS_WARN); -} -#endif /* BENIGN_ERRORS */ - -#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED - /* Whether to report invalid palette index; added at libng-1.5.10. - * It is possible for an indexed (color-type==3) PNG file to contain - * pixels with invalid (out-of-range) indexes if the PLTE chunk has - * fewer entries than the image's bit-depth would allow. We recover - * from this gracefully by filling any incomplete palette with zeros - * (opaque black). By default, when this occurs libpng will issue - * a benign error. This API can be used to override that behavior. - */ -void PNGAPI -png_set_check_for_invalid_index(png_structrp png_ptr, int allowed) -{ - png_debug(1, "in png_set_check_for_invalid_index"); - - if (allowed > 0) - png_ptr->num_palette_max = 0; - - else - png_ptr->num_palette_max = -1; -} -#endif - -#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_pCAL_SUPPORTED) || \ - defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) -/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification, - * and if invalid, correct the keyword rather than discarding the entire - * chunk. The PNG 1.0 specification requires keywords 1-79 characters in - * length, forbids leading or trailing whitespace, multiple internal spaces, - * and the non-break space (0x80) from ISO 8859-1. Returns keyword length. - * - * The 'new_key' buffer must be 80 characters in size (for the keyword plus a - * trailing '\0'). If this routine returns 0 then there was no keyword, or a - * valid one could not be generated, and the caller must png_error. - */ -png_uint_32 /* PRIVATE */ -png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key) -{ -#ifdef PNG_WARNINGS_SUPPORTED - png_const_charp orig_key = key; -#endif - png_uint_32 key_len = 0; - int bad_character = 0; - int space = 1; - - png_debug(1, "in png_check_keyword"); - - if (key == NULL) - { - *new_key = 0; - return 0; - } - - while (*key && key_len < 79) - { - png_byte ch = (png_byte)*key++; - - if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/)) - { - *new_key++ = ch; ++key_len; space = 0; - } - - else if (space == 0) - { - /* A space or an invalid character when one wasn't seen immediately - * before; output just a space. - */ - *new_key++ = 32; ++key_len; space = 1; - - /* If the character was not a space then it is invalid. */ - if (ch != 32) - bad_character = ch; - } - - else if (bad_character == 0) - bad_character = ch; /* just skip it, record the first error */ - } - - if (key_len > 0 && space != 0) /* trailing space */ - { - --key_len; --new_key; - if (bad_character == 0) - bad_character = 32; - } - - /* Terminate the keyword */ - *new_key = 0; - - if (key_len == 0) - return 0; - -#ifdef PNG_WARNINGS_SUPPORTED - /* Try to only output one warning per keyword: */ - if (*key != 0) /* keyword too long */ - png_warning(png_ptr, "keyword truncated"); - - else if (bad_character != 0) - { - PNG_WARNING_PARAMETERS(p) - - png_warning_parameter(p, 1, orig_key); - png_warning_parameter_signed(p, 2, PNG_NUMBER_FORMAT_02x, bad_character); - - png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'"); - } -#else /* !WARNINGS */ - PNG_UNUSED(png_ptr) -#endif /* !WARNINGS */ - - return key_len; -} -#endif /* TEXT || pCAL || iCCP || sPLT */ -#endif /* READ || WRITE */ diff --git a/oversampling/WDL/libpng/pngstruct.h b/oversampling/WDL/libpng/pngstruct.h deleted file mode 100644 index 2873d09..0000000 --- a/oversampling/WDL/libpng/pngstruct.h +++ /dev/null @@ -1,489 +0,0 @@ - -/* pngstruct.h - header file for PNG reference library - * - * Copyright (c) 2018-2019 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - */ - -/* The structure that holds the information to read and write PNG files. - * The only people who need to care about what is inside of this are the - * people who will be modifying the library for their own special needs. - * It should NOT be accessed directly by an application. - */ - -#ifndef PNGSTRUCT_H -#define PNGSTRUCT_H -/* zlib.h defines the structure z_stream, an instance of which is included - * in this structure and is required for decompressing the LZ compressed - * data in PNG files. - */ -#ifndef ZLIB_CONST - /* We must ensure that zlib uses 'const' in declarations. */ -# define ZLIB_CONST -#endif -#include "../zlib/zlib.h" -#ifdef const - /* zlib.h sometimes #defines const to nothing, undo this. */ -# undef const -#endif - -/* zlib.h has mediocre z_const use before 1.2.6, this stuff is for compatibility - * with older builds. - */ -#if ZLIB_VERNUM < 0x1260 -# define PNGZ_MSG_CAST(s) png_constcast(char*,s) -# define PNGZ_INPUT_CAST(b) png_constcast(png_bytep,b) -#else -# define PNGZ_MSG_CAST(s) (s) -# define PNGZ_INPUT_CAST(b) (b) -#endif - -/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib - * can handle at once. This type need be no larger than 16 bits (so maximum of - * 65535), this define allows us to discover how big it is, but limited by the - * maximum for size_t. The value can be overridden in a library build - * (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably - * lower value (e.g. 255 works). A lower value may help memory usage (slightly) - * and may even improve performance on some systems (and degrade it on others.) - */ -#ifndef ZLIB_IO_MAX -# define ZLIB_IO_MAX ((uInt)-1) -#endif - -#ifdef PNG_WRITE_SUPPORTED -/* The type of a compression buffer list used by the write code. */ -typedef struct png_compression_buffer -{ - struct png_compression_buffer *next; - png_byte output[1]; /* actually zbuf_size */ -} png_compression_buffer, *png_compression_bufferp; - -#define PNG_COMPRESSION_BUFFER_SIZE(pp)\ - (offsetof(png_compression_buffer, output) + (pp)->zbuffer_size) -#endif - -/* Colorspace support; structures used in png_struct, png_info and in internal - * functions to hold and communicate information about the color space. - * - * PNG_COLORSPACE_SUPPORTED is only required if the application will perform - * colorspace corrections, otherwise all the colorspace information can be - * skipped and the size of libpng can be reduced (significantly) by compiling - * out the colorspace support. - */ -#ifdef PNG_COLORSPACE_SUPPORTED -/* The chromaticities of the red, green and blue colorants and the chromaticity - * of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)). - */ -typedef struct png_xy -{ - png_fixed_point redx, redy; - png_fixed_point greenx, greeny; - png_fixed_point bluex, bluey; - png_fixed_point whitex, whitey; -} png_xy; - -/* The same data as above but encoded as CIE XYZ values. When this data comes - * from chromaticities the sum of the Y values is assumed to be 1.0 - */ -typedef struct png_XYZ -{ - png_fixed_point red_X, red_Y, red_Z; - png_fixed_point green_X, green_Y, green_Z; - png_fixed_point blue_X, blue_Y, blue_Z; -} png_XYZ; -#endif /* COLORSPACE */ - -#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED) -/* A colorspace is all the above plus, potentially, profile information; - * however at present libpng does not use the profile internally so it is only - * stored in the png_info struct (if iCCP is supported.) The rendering intent - * is retained here and is checked. - * - * The file gamma encoding information is also stored here and gamma correction - * is done by libpng, whereas color correction must currently be done by the - * application. - */ -typedef struct png_colorspace -{ -#ifdef PNG_GAMMA_SUPPORTED - png_fixed_point gamma; /* File gamma */ -#endif - -#ifdef PNG_COLORSPACE_SUPPORTED - png_xy end_points_xy; /* End points as chromaticities */ - png_XYZ end_points_XYZ; /* End points as CIE XYZ colorant values */ - png_uint_16 rendering_intent; /* Rendering intent of a profile */ -#endif - - /* Flags are always defined to simplify the code. */ - png_uint_16 flags; /* As defined below */ -} png_colorspace, * PNG_RESTRICT png_colorspacerp; - -typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp; - -/* General flags for the 'flags' field */ -#define PNG_COLORSPACE_HAVE_GAMMA 0x0001 -#define PNG_COLORSPACE_HAVE_ENDPOINTS 0x0002 -#define PNG_COLORSPACE_HAVE_INTENT 0x0004 -#define PNG_COLORSPACE_FROM_gAMA 0x0008 -#define PNG_COLORSPACE_FROM_cHRM 0x0010 -#define PNG_COLORSPACE_FROM_sRGB 0x0020 -#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040 -#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */ -#define PNG_COLORSPACE_INVALID 0x8000 -#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags)) -#endif /* COLORSPACE || GAMMA */ - -struct png_struct_def -{ -#ifdef PNG_SETJMP_SUPPORTED - jmp_buf jmp_buf_local; /* New name in 1.6.0 for jmp_buf in png_struct */ - png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */ - jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */ - size_t jmp_buf_size; /* size of the above, if allocated */ -#endif - png_error_ptr error_fn; /* function for printing errors and aborting */ -#ifdef PNG_WARNINGS_SUPPORTED - png_error_ptr warning_fn; /* function for printing warnings */ -#endif - png_voidp error_ptr; /* user supplied struct for error functions */ - png_rw_ptr write_data_fn; /* function for writing output data */ - png_rw_ptr read_data_fn; /* function for reading input data */ - png_voidp io_ptr; /* ptr to application struct for I/O functions */ - -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED - png_user_transform_ptr read_user_transform_fn; /* user read transform */ -#endif - -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED - png_user_transform_ptr write_user_transform_fn; /* user write transform */ -#endif - -/* These were added in libpng-1.0.2 */ -#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - png_voidp user_transform_ptr; /* user supplied struct for user transform */ - png_byte user_transform_depth; /* bit depth of user transformed pixels */ - png_byte user_transform_channels; /* channels in user transformed pixels */ -#endif -#endif - - png_uint_32 mode; /* tells us where we are in the PNG file */ - png_uint_32 flags; /* flags indicating various things to libpng */ - png_uint_32 transformations; /* which transformations to perform */ - - png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */ - z_stream zstream; /* decompression structure */ - -#ifdef PNG_WRITE_SUPPORTED - png_compression_bufferp zbuffer_list; /* Created on demand during write */ - uInt zbuffer_size; /* size of the actual buffer */ - - int zlib_level; /* holds zlib compression level */ - int zlib_method; /* holds zlib compression method */ - int zlib_window_bits; /* holds zlib compression window bits */ - int zlib_mem_level; /* holds zlib compression memory level */ - int zlib_strategy; /* holds zlib compression strategy */ -#endif -/* Added at libpng 1.5.4 */ -#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED - int zlib_text_level; /* holds zlib compression level */ - int zlib_text_method; /* holds zlib compression method */ - int zlib_text_window_bits; /* holds zlib compression window bits */ - int zlib_text_mem_level; /* holds zlib compression memory level */ - int zlib_text_strategy; /* holds zlib compression strategy */ -#endif -/* End of material added at libpng 1.5.4 */ -/* Added at libpng 1.6.0 */ -#ifdef PNG_WRITE_SUPPORTED - int zlib_set_level; /* Actual values set into the zstream on write */ - int zlib_set_method; - int zlib_set_window_bits; - int zlib_set_mem_level; - int zlib_set_strategy; -#endif - - png_uint_32 width; /* width of image in pixels */ - png_uint_32 height; /* height of image in pixels */ - png_uint_32 num_rows; /* number of rows in current pass */ - png_uint_32 usr_width; /* width of row at start of write */ - size_t rowbytes; /* size of row in bytes */ - png_uint_32 iwidth; /* width of current interlaced row in pixels */ - png_uint_32 row_number; /* current row in interlace pass */ - png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */ - png_bytep prev_row; /* buffer to save previous (unfiltered) row. - * While reading this is a pointer into - * big_prev_row; while writing it is separately - * allocated if needed. - */ - png_bytep row_buf; /* buffer to save current (unfiltered) row. - * While reading, this is a pointer into - * big_row_buf; while writing it is separately - * allocated. - */ -#ifdef PNG_WRITE_FILTER_SUPPORTED - png_bytep try_row; /* buffer to save trial row when filtering */ - png_bytep tst_row; /* buffer to save best trial row when filtering */ -#endif - size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */ - - png_uint_32 idat_size; /* current IDAT size for read */ - png_uint_32 crc; /* current chunk CRC value */ - png_colorp palette; /* palette from the input file */ - png_uint_16 num_palette; /* number of color entries in palette */ - -/* Added at libpng-1.5.10 */ -#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED - int num_palette_max; /* maximum palette index found in IDAT */ -#endif - - png_uint_16 num_trans; /* number of transparency values */ - png_byte compression; /* file compression type (always 0) */ - png_byte filter; /* file filter type (always 0) */ - png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ - png_byte pass; /* current interlace pass (0 - 6) */ - png_byte do_filter; /* row filter flags (see PNG_FILTER_ in png.h ) */ - png_byte color_type; /* color type of file */ - png_byte bit_depth; /* bit depth of file */ - png_byte usr_bit_depth; /* bit depth of users row: write only */ - png_byte pixel_depth; /* number of bits per pixel */ - png_byte channels; /* number of channels in file */ -#ifdef PNG_WRITE_SUPPORTED - png_byte usr_channels; /* channels at start of write: write only */ -#endif - png_byte sig_bytes; /* magic bytes read/written from start of file */ - png_byte maximum_pixel_depth; - /* pixel depth used for the row buffers */ - png_byte transformed_pixel_depth; - /* pixel depth after read/write transforms */ -#if ZLIB_VERNUM >= 0x1240 - png_byte zstream_start; /* at start of an input zlib stream */ -#endif /* Zlib >= 1.2.4 */ -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) - png_uint_16 filler; /* filler bytes for pixel expansion */ -#endif - -#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) - png_byte background_gamma_type; - png_fixed_point background_gamma; - png_color_16 background; /* background color in screen gamma space */ -#ifdef PNG_READ_GAMMA_SUPPORTED - png_color_16 background_1; /* background normalized to gamma 1.0 */ -#endif -#endif /* bKGD */ - -#ifdef PNG_WRITE_FLUSH_SUPPORTED - png_flush_ptr output_flush_fn; /* Function for flushing output */ - png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ - png_uint_32 flush_rows; /* number of rows written since last flush */ -#endif - -#ifdef PNG_READ_GAMMA_SUPPORTED - int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */ - png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */ - - png_bytep gamma_table; /* gamma table for 8-bit depth files */ - png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */ -#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ - defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ - defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - png_bytep gamma_from_1; /* converts from 1.0 to screen */ - png_bytep gamma_to_1; /* converts from file to 1.0 */ - png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */ - png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */ -#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED) - png_color_8 sig_bit; /* significant bits in each available channel */ -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) - png_color_8 shift; /* shift for significant bit transformation */ -#endif - -#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \ - || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) - png_bytep trans_alpha; /* alpha values for paletted files */ - png_color_16 trans_color; /* transparent color for non-paletted files */ -#endif - - png_read_status_ptr read_row_fn; /* called after each row is decoded */ - png_write_status_ptr write_row_fn; /* called after each row is encoded */ -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED - png_progressive_info_ptr info_fn; /* called after header data fully read */ - png_progressive_row_ptr row_fn; /* called after a prog. row is decoded */ - png_progressive_end_ptr end_fn; /* called after image is complete */ - png_bytep save_buffer_ptr; /* current location in save_buffer */ - png_bytep save_buffer; /* buffer for previously read data */ - png_bytep current_buffer_ptr; /* current location in current_buffer */ - png_bytep current_buffer; /* buffer for recently used data */ - png_uint_32 push_length; /* size of current input chunk */ - png_uint_32 skip_length; /* bytes to skip in input data */ - size_t save_buffer_size; /* amount of data now in save_buffer */ - size_t save_buffer_max; /* total size of save_buffer */ - size_t buffer_size; /* total amount of available input data */ - size_t current_buffer_size; /* amount of data now in current_buffer */ - int process_mode; /* what push library is currently doing */ - int cur_palette; /* current push library palette index */ - -#endif /* PROGRESSIVE_READ */ - -#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* For the Borland special 64K segment handler */ - png_bytepp offset_table_ptr; - png_bytep offset_table; - png_uint_16 offset_table_number; - png_uint_16 offset_table_count; - png_uint_16 offset_table_count_free; -#endif - -#ifdef PNG_READ_QUANTIZE_SUPPORTED - png_bytep palette_lookup; /* lookup table for quantizing */ - png_bytep quantize_index; /* index translation for palette files */ -#endif - -/* Options */ -#ifdef PNG_SET_OPTION_SUPPORTED - png_uint_32 options; /* On/off state (up to 16 options) */ -#endif - -#if PNG_LIBPNG_VER < 10700 -/* To do: remove this from libpng-1.7 */ -#ifdef PNG_TIME_RFC1123_SUPPORTED - char time_buffer[29]; /* String to hold RFC 1123 time text */ -#endif -#endif - -/* New members added in libpng-1.0.6 */ - - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ - -#ifdef PNG_USER_CHUNKS_SUPPORTED - png_voidp user_chunk_ptr; -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED - png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ -#endif -#endif - -#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED - int unknown_default; /* As PNG_HANDLE_* */ - unsigned int num_chunk_list; /* Number of entries in the list */ - png_bytep chunk_list; /* List of png_byte[5]; the textual chunk name - * followed by a PNG_HANDLE_* byte */ -#endif - -/* New members added in libpng-1.0.3 */ -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED - png_byte rgb_to_gray_status; - /* Added in libpng 1.5.5 to record setting of coefficients: */ - png_byte rgb_to_gray_coefficients_set; - /* These were changed from png_byte in libpng-1.0.6 */ - png_uint_16 rgb_to_gray_red_coeff; - png_uint_16 rgb_to_gray_green_coeff; - /* deleted in 1.5.5: rgb_to_gray_blue_coeff; */ -#endif - -/* New member added in libpng-1.6.36 */ -#if defined(PNG_READ_EXPAND_SUPPORTED) && \ - defined(PNG_ARM_NEON_IMPLEMENTATION) - png_bytep riffled_palette; /* buffer for accelerated palette expansion */ -#endif - -/* New member added in libpng-1.0.4 (renamed in 1.0.9) */ -#if defined(PNG_MNG_FEATURES_SUPPORTED) -/* Changed from png_byte to png_uint_32 at version 1.2.0 */ - png_uint_32 mng_features_permitted; -#endif - -/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */ -#ifdef PNG_MNG_FEATURES_SUPPORTED - png_byte filter_type; -#endif - -/* New members added in libpng-1.2.0 */ - -/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ -#ifdef PNG_USER_MEM_SUPPORTED - png_voidp mem_ptr; /* user supplied struct for mem functions */ - png_malloc_ptr malloc_fn; /* function for allocating memory */ - png_free_ptr free_fn; /* function for freeing memory */ -#endif - -/* New member added in libpng-1.0.13 and 1.2.0 */ - png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ - -#ifdef PNG_READ_QUANTIZE_SUPPORTED -/* The following three members were added at version 1.0.14 and 1.2.4 */ - png_bytep quantize_sort; /* working sort array */ - png_bytep index_to_palette; /* where the original index currently is - in the palette */ - png_bytep palette_to_index; /* which original index points to this - palette color */ -#endif - -/* New members added in libpng-1.0.16 and 1.2.6 */ - png_byte compression_type; - -#ifdef PNG_USER_LIMITS_SUPPORTED - png_uint_32 user_width_max; - png_uint_32 user_height_max; - - /* Added in libpng-1.4.0: Total number of sPLT, text, and unknown - * chunks that can be stored (0 means unlimited). - */ - png_uint_32 user_chunk_cache_max; - - /* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk - * can occupy when decompressed. 0 means unlimited. - */ - png_alloc_size_t user_chunk_malloc_max; -#endif - -/* New member added in libpng-1.0.25 and 1.2.17 */ -#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED - /* Temporary storage for unknown chunk that the library doesn't recognize, - * used while reading the chunk. - */ - png_unknown_chunk unknown_chunk; -#endif - -/* New member added in libpng-1.2.26 */ - size_t old_big_row_buf_size; - -#ifdef PNG_READ_SUPPORTED -/* New member added in libpng-1.2.30 */ - png_bytep read_buffer; /* buffer for reading chunk data */ - png_alloc_size_t read_buffer_size; /* current size of the buffer */ -#endif -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED - uInt IDAT_read_size; /* limit on read buffer size for IDAT */ -#endif - -#ifdef PNG_IO_STATE_SUPPORTED -/* New member added in libpng-1.4.0 */ - png_uint_32 io_state; -#endif - -/* New member added in libpng-1.5.6 */ - png_bytep big_prev_row; - -/* New member added in libpng-1.5.7 */ - void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info, - png_bytep row, png_const_bytep prev_row); - -#ifdef PNG_READ_SUPPORTED -#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED) - png_colorspace colorspace; -#endif -#endif -}; -#endif /* PNGSTRUCT_H */ diff --git a/oversampling/WDL/libpng/pngtest.c b/oversampling/WDL/libpng/pngtest.c deleted file mode 100644 index a715ae1..0000000 --- a/oversampling/WDL/libpng/pngtest.c +++ /dev/null @@ -1,2158 +0,0 @@ - -/* pngtest.c - a simple test program to test libpng - * - * Copyright (c) 2018-2019 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * - * This program reads in a PNG image, writes it out again, and then - * compares the two files. If the files are identical, this shows that - * the basic chunk handling, filtering, and (de)compression code is working - * properly. It does not currently test all of the transforms, although - * it probably should. - * - * The program will report "FAIL" in certain legitimate cases: - * 1) when the compression level or filter selection method is changed. - * 2) when the maximum IDAT size (PNG_ZBUF_SIZE in pngconf.h) is not 8192. - * 3) unknown unsafe-to-copy ancillary chunks or unknown critical chunks - * exist in the input file. - * 4) others not listed here... - * In these cases, it is best to check with another tool such as "pngcheck" - * to see what the differences between the two files are. - * - * If a filename is given on the command-line, then this file is used - * for the input, rather than the default "pngtest.png". This allows - * testing a wide variety of files easily. You can also test a number - * of files at once by typing "pngtest -m file1.png file2.png ..." - */ - -#define _POSIX_SOURCE 1 - -#include -#include -#include - -/* Defined so I can write to a file on gui/windowing platforms */ -/* #define STDERR stderr */ -#define STDERR stdout /* For DOS */ - -#include "png.h" - -/* Known chunks that exist in pngtest.png must be supported or pngtest will fail - * simply as a result of re-ordering them. This may be fixed in 1.7 - * - * pngtest allocates a single row buffer for each row and overwrites it, - * therefore if the write side doesn't support the writing of interlaced images - * nothing can be done for an interlaced image (and the code below will fail - * horribly trying to write extra data after writing garbage). - */ -#if defined PNG_READ_SUPPORTED && /* else nothing can be done */\ - defined PNG_READ_bKGD_SUPPORTED &&\ - defined PNG_READ_cHRM_SUPPORTED &&\ - defined PNG_READ_gAMA_SUPPORTED &&\ - defined PNG_READ_oFFs_SUPPORTED &&\ - defined PNG_READ_pCAL_SUPPORTED &&\ - defined PNG_READ_pHYs_SUPPORTED &&\ - defined PNG_READ_sBIT_SUPPORTED &&\ - defined PNG_READ_sCAL_SUPPORTED &&\ - defined PNG_READ_sRGB_SUPPORTED &&\ - defined PNG_READ_sPLT_SUPPORTED &&\ - defined PNG_READ_tEXt_SUPPORTED &&\ - defined PNG_READ_tIME_SUPPORTED &&\ - defined PNG_READ_zTXt_SUPPORTED &&\ - (defined PNG_WRITE_INTERLACING_SUPPORTED || PNG_LIBPNG_VER >= 10700) - -#ifdef PNG_ZLIB_HEADER -# include PNG_ZLIB_HEADER /* defined by pnglibconf.h from 1.7 */ -#else -# include "zlib.h" -#endif - -/* Copied from pngpriv.h but only used in error messages below. */ -#ifndef PNG_ZBUF_SIZE -# define PNG_ZBUF_SIZE 8192 -#endif -#define FCLOSE(file) fclose(file) - -#ifndef PNG_STDIO_SUPPORTED -typedef FILE * png_FILE_p; -#endif - -/* Makes pngtest verbose so we can find problems. */ -#ifndef PNG_DEBUG -# define PNG_DEBUG 0 -#endif - -#if PNG_DEBUG > 1 -# define pngtest_debug(m) ((void)fprintf(stderr, m "\n")) -# define pngtest_debug1(m,p1) ((void)fprintf(stderr, m "\n", p1)) -# define pngtest_debug2(m,p1,p2) ((void)fprintf(stderr, m "\n", p1, p2)) -#else -# define pngtest_debug(m) ((void)0) -# define pngtest_debug1(m,p1) ((void)0) -# define pngtest_debug2(m,p1,p2) ((void)0) -#endif - -#if !PNG_DEBUG -# define SINGLE_ROWBUF_ALLOC /* Makes buffer overruns easier to nail */ -#endif - -#ifndef PNG_UNUSED -# define PNG_UNUSED(param) (void)param; -#endif - -/* Turn on CPU timing -#define PNGTEST_TIMING -*/ - -#ifndef PNG_FLOATING_POINT_SUPPORTED -#undef PNGTEST_TIMING -#endif - -#ifdef PNGTEST_TIMING -static float t_start, t_stop, t_decode, t_encode, t_misc; -#include -#endif - -#ifdef PNG_TIME_RFC1123_SUPPORTED -#define PNG_tIME_STRING_LENGTH 29 -static int tIME_chunk_present = 0; -static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present"; - -#if PNG_LIBPNG_VER < 10619 -#define png_convert_to_rfc1123_buffer(ts, t) tIME_to_str(read_ptr, ts, t) - -static int -tIME_to_str(png_structp png_ptr, png_charp ts, png_const_timep t) -{ - png_const_charp str = png_convert_to_rfc1123(png_ptr, t); - - if (str == NULL) - return 0; - - strcpy(ts, str); - return 1; -} -#endif /* older libpng */ -#endif - -static int verbose = 0; -static int strict = 0; -static int relaxed = 0; -static int xfail = 0; -static int unsupported_chunks = 0; /* chunk unsupported by libpng in input */ -static int error_count = 0; /* count calls to png_error */ -static int warning_count = 0; /* count calls to png_warning */ - -/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */ -#ifndef png_jmpbuf -# define png_jmpbuf(png_ptr) png_ptr->jmpbuf -#endif - -/* Defines for unknown chunk handling if required. */ -#ifndef PNG_HANDLE_CHUNK_ALWAYS -# define PNG_HANDLE_CHUNK_ALWAYS 3 -#endif -#ifndef PNG_HANDLE_CHUNK_IF_SAFE -# define PNG_HANDLE_CHUNK_IF_SAFE 2 -#endif - -/* Utility to save typing/errors, the argument must be a name */ -#define MEMZERO(var) ((void)memset(&var, 0, sizeof var)) - -/* Example of using row callbacks to make a simple progress meter */ -static int status_pass = 1; -static int status_dots_requested = 0; -static int status_dots = 1; - -static void PNGCBAPI -read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) -{ - if (png_ptr == NULL || row_number > PNG_UINT_31_MAX) - return; - - if (status_pass != pass) - { - fprintf(stdout, "\n Pass %d: ", pass); - status_pass = pass; - status_dots = 31; - } - - status_dots--; - - if (status_dots == 0) - { - fprintf(stdout, "\n "); - status_dots=30; - } - - fprintf(stdout, "r"); -} - -#ifdef PNG_WRITE_SUPPORTED -static void PNGCBAPI -write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) -{ - if (png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7) - return; - - fprintf(stdout, "w"); -} -#endif - - -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED -/* Example of using a user transform callback (doesn't do anything at present). - */ -static void PNGCBAPI -read_user_callback(png_structp png_ptr, png_row_infop row_info, png_bytep data) -{ - PNG_UNUSED(png_ptr) - PNG_UNUSED(row_info) - PNG_UNUSED(data) -} -#endif - -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED -/* Example of using user transform callback (we don't transform anything, - * but merely count the zero samples) - */ - -static png_uint_32 zero_samples; - -static void PNGCBAPI -count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) -{ - png_bytep dp = data; - if (png_ptr == NULL) - return; - - /* Contents of row_info: - * png_uint_32 width width of row - * png_uint_32 rowbytes number of bytes in row - * png_byte color_type color type of pixels - * png_byte bit_depth bit depth of samples - * png_byte channels number of channels (1-4) - * png_byte pixel_depth bits per pixel (depth*channels) - */ - - /* Counts the number of zero samples (or zero pixels if color_type is 3 */ - - if (row_info->color_type == 0 || row_info->color_type == 3) - { - int pos = 0; - png_uint_32 n, nstop; - - for (n = 0, nstop=row_info->width; nbit_depth == 1) - { - if (((*dp << pos++ ) & 0x80) == 0) - zero_samples++; - - if (pos == 8) - { - pos = 0; - dp++; - } - } - - if (row_info->bit_depth == 2) - { - if (((*dp << (pos+=2)) & 0xc0) == 0) - zero_samples++; - - if (pos == 8) - { - pos = 0; - dp++; - } - } - - if (row_info->bit_depth == 4) - { - if (((*dp << (pos+=4)) & 0xf0) == 0) - zero_samples++; - - if (pos == 8) - { - pos = 0; - dp++; - } - } - - if (row_info->bit_depth == 8) - if (*dp++ == 0) - zero_samples++; - - if (row_info->bit_depth == 16) - { - if ((*dp | *(dp+1)) == 0) - zero_samples++; - dp+=2; - } - } - } - else /* Other color types */ - { - png_uint_32 n, nstop; - int channel; - int color_channels = row_info->channels; - if (row_info->color_type > 3) - color_channels--; - - for (n = 0, nstop=row_info->width; nbit_depth == 8) - if (*dp++ == 0) - zero_samples++; - - if (row_info->bit_depth == 16) - { - if ((*dp | *(dp+1)) == 0) - zero_samples++; - - dp+=2; - } - } - if (row_info->color_type > 3) - { - dp++; - if (row_info->bit_depth == 16) - dp++; - } - } - } -} -#endif /* WRITE_USER_TRANSFORM */ - -#ifndef PNG_STDIO_SUPPORTED -/* START of code to validate stdio-free compilation */ -/* These copies of the default read/write functions come from pngrio.c and - * pngwio.c. They allow "don't include stdio" testing of the library. - * This is the function that does the actual reading of data. If you are - * not reading from a standard C stream, you should create a replacement - * read_data function and use it at run time with png_set_read_fn(), rather - * than changing the library. - */ - -#ifdef PNG_IO_STATE_SUPPORTED -void -pngtest_check_io_state(png_structp png_ptr, size_t data_length, - png_uint_32 io_op); -void -pngtest_check_io_state(png_structp png_ptr, size_t data_length, - png_uint_32 io_op) -{ - png_uint_32 io_state = png_get_io_state(png_ptr); - int err = 0; - - /* Check if the current operation (reading / writing) is as expected. */ - if ((io_state & PNG_IO_MASK_OP) != io_op) - png_error(png_ptr, "Incorrect operation in I/O state"); - - /* Check if the buffer size specific to the current location - * (file signature / header / data / crc) is as expected. - */ - switch (io_state & PNG_IO_MASK_LOC) - { - case PNG_IO_SIGNATURE: - if (data_length > 8) - err = 1; - break; - case PNG_IO_CHUNK_HDR: - if (data_length != 8) - err = 1; - break; - case PNG_IO_CHUNK_DATA: - break; /* no restrictions here */ - case PNG_IO_CHUNK_CRC: - if (data_length != 4) - err = 1; - break; - default: - err = 1; /* uninitialized */ - } - if (err != 0) - png_error(png_ptr, "Bad I/O state or buffer size"); -} -#endif - -static void PNGCBAPI -pngtest_read_data(png_structp png_ptr, png_bytep data, size_t length) -{ - size_t check = 0; - png_voidp io_ptr; - - /* fread() returns 0 on error, so it is OK to store this in a size_t - * instead of an int, which is what fread() actually returns. - */ - io_ptr = png_get_io_ptr(png_ptr); - if (io_ptr != NULL) - { - check = fread(data, 1, length, (png_FILE_p)io_ptr); - } - - if (check != length) - { - png_error(png_ptr, "Read Error"); - } - -#ifdef PNG_IO_STATE_SUPPORTED - pngtest_check_io_state(png_ptr, length, PNG_IO_READING); -#endif -} - -#ifdef PNG_WRITE_FLUSH_SUPPORTED -static void PNGCBAPI -pngtest_flush(png_structp png_ptr) -{ - /* Do nothing; fflush() is said to be just a waste of energy. */ - PNG_UNUSED(png_ptr) /* Stifle compiler warning */ -} -#endif - -/* This is the function that does the actual writing of data. If you are - * not writing to a standard C stream, you should create a replacement - * write_data function and use it at run time with png_set_write_fn(), rather - * than changing the library. - */ -static void PNGCBAPI -pngtest_write_data(png_structp png_ptr, png_bytep data, size_t length) -{ - size_t check; - - check = fwrite(data, 1, length, (png_FILE_p)png_get_io_ptr(png_ptr)); - - if (check != length) - { - png_error(png_ptr, "Write Error"); - } - -#ifdef PNG_IO_STATE_SUPPORTED - pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING); -#endif -} -#endif /* !STDIO */ - -/* This function is called when there is a warning, but the library thinks - * it can continue anyway. Replacement functions don't have to do anything - * here if you don't want to. In the default configuration, png_ptr is - * not used, but it is passed in case it may be useful. - */ -typedef struct -{ - const char *file_name; -} pngtest_error_parameters; - -static void PNGCBAPI -pngtest_warning(png_structp png_ptr, png_const_charp message) -{ - const char *name = "UNKNOWN (ERROR!)"; - pngtest_error_parameters *test = - (pngtest_error_parameters*)png_get_error_ptr(png_ptr); - - ++warning_count; - - if (test != NULL && test->file_name != NULL) - name = test->file_name; - - fprintf(STDERR, "\n%s: libpng warning: %s\n", name, message); -} - -/* This is the default error handling function. Note that replacements for - * this function MUST NOT RETURN, or the program will likely crash. This - * function is used by default, or if the program supplies NULL for the - * error function pointer in png_set_error_fn(). - */ -static void PNGCBAPI -pngtest_error(png_structp png_ptr, png_const_charp message) -{ - ++error_count; - - pngtest_warning(png_ptr, message); - /* We can return because png_error calls the default handler, which is - * actually OK in this case. - */ -} - -/* END of code to validate stdio-free compilation */ - -/* START of code to validate memory allocation and deallocation */ -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - -/* Allocate memory. For reasonable files, size should never exceed - * 64K. However, zlib may allocate more than 64K if you don't tell - * it not to. See zconf.h and png.h for more information. zlib does - * need to allocate exactly 64K, so whatever you call here must - * have the ability to do that. - * - * This piece of code can be compiled to validate max 64K allocations - * by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. - */ -typedef struct memory_information -{ - png_alloc_size_t size; - png_voidp pointer; - struct memory_information *next; -} memory_information; -typedef memory_information *memory_infop; - -static memory_infop pinformation = NULL; -static int current_allocation = 0; -static int maximum_allocation = 0; -static int total_allocation = 0; -static int num_allocations = 0; - -png_voidp PNGCBAPI png_debug_malloc PNGARG((png_structp png_ptr, - png_alloc_size_t size)); -void PNGCBAPI png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr)); - -png_voidp -PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size) -{ - - /* png_malloc has already tested for NULL; png_create_struct calls - * png_debug_malloc directly, with png_ptr == NULL which is OK - */ - - if (size == 0) - return (NULL); - - /* This calls the library allocator twice, once to get the requested - buffer and once to get a new free list entry. */ - { - /* Disable malloc_fn and free_fn */ - memory_infop pinfo; - png_set_mem_fn(png_ptr, NULL, NULL, NULL); - pinfo = (memory_infop)png_malloc(png_ptr, - (sizeof *pinfo)); - pinfo->size = size; - current_allocation += size; - total_allocation += size; - num_allocations ++; - - if (current_allocation > maximum_allocation) - maximum_allocation = current_allocation; - - pinfo->pointer = png_malloc(png_ptr, size); - /* Restore malloc_fn and free_fn */ - - png_set_mem_fn(png_ptr, - NULL, png_debug_malloc, png_debug_free); - - if (size != 0 && pinfo->pointer == NULL) - { - current_allocation -= size; - total_allocation -= size; - png_error(png_ptr, - "out of memory in pngtest->png_debug_malloc"); - } - - pinfo->next = pinformation; - pinformation = pinfo; - /* Make sure the caller isn't assuming zeroed memory. */ - memset(pinfo->pointer, 0xdd, pinfo->size); - - if (verbose != 0) - printf("png_malloc %lu bytes at %p\n", (unsigned long)size, - pinfo->pointer); - - return (png_voidp)(pinfo->pointer); - } -} - -/* Free a pointer. It is removed from the list at the same time. */ -void PNGCBAPI -png_debug_free(png_structp png_ptr, png_voidp ptr) -{ - if (png_ptr == NULL) - fprintf(STDERR, "NULL pointer to png_debug_free.\n"); - - if (ptr == 0) - { -#if 0 /* This happens all the time. */ - fprintf(STDERR, "WARNING: freeing NULL pointer\n"); -#endif - return; - } - - /* Unlink the element from the list. */ - if (pinformation != NULL) - { - memory_infop *ppinfo = &pinformation; - - for (;;) - { - memory_infop pinfo = *ppinfo; - - if (pinfo->pointer == ptr) - { - *ppinfo = pinfo->next; - current_allocation -= pinfo->size; - if (current_allocation < 0) - fprintf(STDERR, "Duplicate free of memory\n"); - /* We must free the list element too, but first kill - the memory that is to be freed. */ - memset(ptr, 0x55, pinfo->size); - free(pinfo); - pinfo = NULL; - break; - } - - if (pinfo->next == NULL) - { - fprintf(STDERR, "Pointer %p not found\n", ptr); - break; - } - - ppinfo = &pinfo->next; - } - } - - /* Finally free the data. */ - if (verbose != 0) - printf("Freeing %p\n", ptr); - - if (ptr != NULL) - free(ptr); - ptr = NULL; -} -#endif /* USER_MEM && DEBUG */ -/* END of code to test memory allocation/deallocation */ - - -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED -/* Demonstration of user chunk support of the sTER and vpAg chunks */ - -/* (sTER is a public chunk not yet known by libpng. vpAg is a private -chunk used in ImageMagick to store "virtual page" size). */ - -static struct user_chunk_data -{ - png_const_infop info_ptr; - png_uint_32 vpAg_width, vpAg_height; - png_byte vpAg_units; - png_byte sTER_mode; - int location[2]; -} -user_chunk_data; - -/* Used for location and order; zero means nothing. */ -#define have_sTER 0x01 -#define have_vpAg 0x02 -#define before_PLTE 0x10 -#define before_IDAT 0x20 -#define after_IDAT 0x40 - -static void -init_callback_info(png_const_infop info_ptr) -{ - MEMZERO(user_chunk_data); - user_chunk_data.info_ptr = info_ptr; -} - -static int -set_location(png_structp png_ptr, struct user_chunk_data *data, int what) -{ - int location; - - if ((data->location[0] & what) != 0 || (data->location[1] & what) != 0) - return 0; /* already have one of these */ - - /* Find where we are (the code below zeroes info_ptr to indicate that the - * chunks before the first IDAT have been read.) - */ - if (data->info_ptr == NULL) /* after IDAT */ - location = what | after_IDAT; - - else if (png_get_valid(png_ptr, data->info_ptr, PNG_INFO_PLTE) != 0) - location = what | before_IDAT; - - else - location = what | before_PLTE; - - if (data->location[0] == 0) - data->location[0] = location; - - else - data->location[1] = location; - - return 1; /* handled */ -} - -static int PNGCBAPI -read_user_chunk_callback(png_struct *png_ptr, png_unknown_chunkp chunk) -{ - struct user_chunk_data *my_user_chunk_data = - (struct user_chunk_data*)png_get_user_chunk_ptr(png_ptr); - - if (my_user_chunk_data == NULL) - png_error(png_ptr, "lost user chunk pointer"); - - /* Return one of the following: - * return (-n); chunk had an error - * return (0); did not recognize - * return (n); success - * - * The unknown chunk structure contains the chunk data: - * png_byte name[5]; - * png_byte *data; - * size_t size; - * - * Note that libpng has already taken care of the CRC handling. - */ - - if (chunk->name[0] == 115 && chunk->name[1] == 84 && /* s T */ - chunk->name[2] == 69 && chunk->name[3] == 82) /* E R */ - { - /* Found sTER chunk */ - if (chunk->size != 1) - return (-1); /* Error return */ - - if (chunk->data[0] != 0 && chunk->data[0] != 1) - return (-1); /* Invalid mode */ - - if (set_location(png_ptr, my_user_chunk_data, have_sTER) != 0) - { - my_user_chunk_data->sTER_mode=chunk->data[0]; - return (1); - } - - else - return (0); /* duplicate sTER - give it to libpng */ - } - - if (chunk->name[0] != 118 || chunk->name[1] != 112 || /* v p */ - chunk->name[2] != 65 || chunk->name[3] != 103) /* A g */ - return (0); /* Did not recognize */ - - /* Found ImageMagick vpAg chunk */ - - if (chunk->size != 9) - return (-1); /* Error return */ - - if (set_location(png_ptr, my_user_chunk_data, have_vpAg) == 0) - return (0); /* duplicate vpAg */ - - my_user_chunk_data->vpAg_width = png_get_uint_31(png_ptr, chunk->data); - my_user_chunk_data->vpAg_height = png_get_uint_31(png_ptr, chunk->data + 4); - my_user_chunk_data->vpAg_units = chunk->data[8]; - - return (1); -} - -#ifdef PNG_WRITE_SUPPORTED -static void -write_sTER_chunk(png_structp write_ptr) -{ - png_byte sTER[5] = {115, 84, 69, 82, '\0'}; - - if (verbose != 0) - fprintf(STDERR, "\n stereo mode = %d\n", user_chunk_data.sTER_mode); - - png_write_chunk(write_ptr, sTER, &user_chunk_data.sTER_mode, 1); -} - -static void -write_vpAg_chunk(png_structp write_ptr) -{ - png_byte vpAg[5] = {118, 112, 65, 103, '\0'}; - - png_byte vpag_chunk_data[9]; - - if (verbose != 0) - fprintf(STDERR, " vpAg = %lu x %lu, units = %d\n", - (unsigned long)user_chunk_data.vpAg_width, - (unsigned long)user_chunk_data.vpAg_height, - user_chunk_data.vpAg_units); - - png_save_uint_32(vpag_chunk_data, user_chunk_data.vpAg_width); - png_save_uint_32(vpag_chunk_data + 4, user_chunk_data.vpAg_height); - vpag_chunk_data[8] = user_chunk_data.vpAg_units; - png_write_chunk(write_ptr, vpAg, vpag_chunk_data, 9); -} - -static void -write_chunks(png_structp write_ptr, int location) -{ - int i; - - /* Notice that this preserves the original chunk order, however chunks - * intercepted by the callback will be written *after* chunks passed to - * libpng. This will actually reverse a pair of sTER chunks or a pair of - * vpAg chunks, resulting in an error later. This is not worth worrying - * about - the chunks should not be duplicated! - */ - for (i=0; i<2; ++i) - { - if (user_chunk_data.location[i] == (location | have_sTER)) - write_sTER_chunk(write_ptr); - - else if (user_chunk_data.location[i] == (location | have_vpAg)) - write_vpAg_chunk(write_ptr); - } -} -#endif /* WRITE */ -#else /* !READ_USER_CHUNKS */ -# define write_chunks(pp,loc) ((void)0) -#endif -/* END of code to demonstrate user chunk support */ - -/* START of code to check that libpng has the required text support; this only - * checks for the write support because if read support is missing the chunk - * will simply not be reported back to pngtest. - */ -#ifdef PNG_TEXT_SUPPORTED -static void -pngtest_check_text_support(png_structp png_ptr, png_textp text_ptr, - int num_text) -{ - while (num_text > 0) - { - switch (text_ptr[--num_text].compression) - { - case PNG_TEXT_COMPRESSION_NONE: - break; - - case PNG_TEXT_COMPRESSION_zTXt: -# ifndef PNG_WRITE_zTXt_SUPPORTED - ++unsupported_chunks; - /* In libpng 1.7 this now does an app-error, so stop it: */ - text_ptr[num_text].compression = PNG_TEXT_COMPRESSION_NONE; -# endif - break; - - case PNG_ITXT_COMPRESSION_NONE: - case PNG_ITXT_COMPRESSION_zTXt: -# ifndef PNG_WRITE_iTXt_SUPPORTED - ++unsupported_chunks; - text_ptr[num_text].compression = PNG_TEXT_COMPRESSION_NONE; -# endif - break; - - default: - /* This is an error */ - png_error(png_ptr, "invalid text chunk compression field"); - break; - } - } -} -#endif -/* END of code to check that libpng has the required text support */ - -/* Test one file */ -static int -test_one_file(const char *inname, const char *outname) -{ - static png_FILE_p fpin; - static png_FILE_p fpout; /* "static" prevents setjmp corruption */ - pngtest_error_parameters error_parameters; - png_structp read_ptr; - png_infop read_info_ptr, end_info_ptr; -#ifdef PNG_WRITE_SUPPORTED - png_structp write_ptr; - png_infop write_info_ptr; - png_infop write_end_info_ptr; -#ifdef PNG_WRITE_FILTER_SUPPORTED - int interlace_preserved = 1; -#endif /* WRITE_FILTER */ -#else /* !WRITE */ - png_structp write_ptr = NULL; - png_infop write_info_ptr = NULL; - png_infop write_end_info_ptr = NULL; -#endif /* !WRITE */ - png_bytep row_buf; - png_uint_32 y; - png_uint_32 width, height; - volatile int num_passes; - int pass; - int bit_depth, color_type; - - row_buf = NULL; - error_parameters.file_name = inname; - - if ((fpin = fopen(inname, "rb")) == NULL) - { - fprintf(STDERR, "Could not find input file %s\n", inname); - return (1); - } - - if ((fpout = fopen(outname, "wb")) == NULL) - { - fprintf(STDERR, "Could not open output file %s\n", outname); - FCLOSE(fpin); - return (1); - } - - pngtest_debug("Allocating read and write structures"); -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - read_ptr = - png_create_read_struct_2(PNG_LIBPNG_VER_STRING, NULL, - NULL, NULL, NULL, png_debug_malloc, png_debug_free); -#else - read_ptr = - png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); -#endif - png_set_error_fn(read_ptr, &error_parameters, pngtest_error, - pngtest_warning); - -#ifdef PNG_WRITE_SUPPORTED -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - write_ptr = - png_create_write_struct_2(PNG_LIBPNG_VER_STRING, NULL, - NULL, NULL, NULL, png_debug_malloc, png_debug_free); -#else - write_ptr = - png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); -#endif - png_set_error_fn(write_ptr, &error_parameters, pngtest_error, - pngtest_warning); -#endif - pngtest_debug("Allocating read_info, write_info and end_info structures"); - read_info_ptr = png_create_info_struct(read_ptr); - end_info_ptr = png_create_info_struct(read_ptr); -#ifdef PNG_WRITE_SUPPORTED - write_info_ptr = png_create_info_struct(write_ptr); - write_end_info_ptr = png_create_info_struct(write_ptr); -#endif - -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED - init_callback_info(read_info_ptr); - png_set_read_user_chunk_fn(read_ptr, &user_chunk_data, - read_user_chunk_callback); -#endif - -#ifdef PNG_SETJMP_SUPPORTED - pngtest_debug("Setting jmpbuf for read struct"); - if (setjmp(png_jmpbuf(read_ptr))) - { - fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname); - png_free(read_ptr, row_buf); - row_buf = NULL; - if (verbose != 0) - fprintf(STDERR, " destroy read structs\n"); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - if (verbose != 0) - fprintf(STDERR, " destroy write structs\n"); - png_destroy_info_struct(write_ptr, &write_end_info_ptr); - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - FCLOSE(fpin); - FCLOSE(fpout); - return (1); - } - -#ifdef PNG_WRITE_SUPPORTED - pngtest_debug("Setting jmpbuf for write struct"); - - if (setjmp(png_jmpbuf(write_ptr))) - { - fprintf(STDERR, "%s -> %s: libpng write error\n", inname, outname); - png_free(read_ptr, row_buf); - row_buf = NULL; - if (verbose != 0) - fprintf(STDERR, " destroying read structs\n"); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); - if (verbose != 0) - fprintf(STDERR, " destroying write structs\n"); - png_destroy_info_struct(write_ptr, &write_end_info_ptr); - png_destroy_write_struct(&write_ptr, &write_info_ptr); - FCLOSE(fpin); - FCLOSE(fpout); - return (1); - } -#endif -#endif - -#ifdef PNG_BENIGN_ERRORS_SUPPORTED - if (strict != 0) - { - /* Treat png_benign_error() as errors on read */ - png_set_benign_errors(read_ptr, 0); - -# ifdef PNG_WRITE_SUPPORTED - /* Treat them as errors on write */ - png_set_benign_errors(write_ptr, 0); -# endif - - /* if strict is not set, then app warnings and errors are treated as - * warnings in release builds, but not in unstable builds; this can be - * changed with '--relaxed'. - */ - } - - else if (relaxed != 0) - { - /* Allow application (pngtest) errors and warnings to pass */ - png_set_benign_errors(read_ptr, 1); - - /* Turn off CRC checking while reading */ - png_set_crc_action(read_ptr, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE); - -#ifdef PNG_IGNORE_ADLER32 - /* Turn off ADLER32 checking while reading */ - png_set_option(read_ptr, PNG_IGNORE_ADLER32, PNG_OPTION_ON); -#endif - -# ifdef PNG_WRITE_SUPPORTED - png_set_benign_errors(write_ptr, 1); -# endif - - } -#endif /* BENIGN_ERRORS */ - - pngtest_debug("Initializing input and output streams"); -#ifdef PNG_STDIO_SUPPORTED - png_init_io(read_ptr, fpin); -# ifdef PNG_WRITE_SUPPORTED - png_init_io(write_ptr, fpout); -# endif -#else - png_set_read_fn(read_ptr, (png_voidp)fpin, pngtest_read_data); -# ifdef PNG_WRITE_SUPPORTED - png_set_write_fn(write_ptr, (png_voidp)fpout, pngtest_write_data, -# ifdef PNG_WRITE_FLUSH_SUPPORTED - pngtest_flush); -# else - NULL); -# endif -# endif -#endif - - if (status_dots_requested == 1) - { -#ifdef PNG_WRITE_SUPPORTED - png_set_write_status_fn(write_ptr, write_row_callback); -#endif - png_set_read_status_fn(read_ptr, read_row_callback); - } - - else - { -#ifdef PNG_WRITE_SUPPORTED - png_set_write_status_fn(write_ptr, NULL); -#endif - png_set_read_status_fn(read_ptr, NULL); - } - -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED - png_set_read_user_transform_fn(read_ptr, read_user_callback); -#endif -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED - zero_samples = 0; - png_set_write_user_transform_fn(write_ptr, count_zero_samples); -#endif - -#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED - /* Preserve all the unknown chunks, if possible. If this is disabled then, - * even if the png_{get,set}_unknown_chunks stuff is enabled, we can't use - * libpng to *save* the unknown chunks on read (because we can't switch the - * save option on!) - * - * Notice that if SET_UNKNOWN_CHUNKS is *not* supported read will discard all - * unknown chunks and write will write them all. - */ -#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED - png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS, - NULL, 0); -#endif -#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED - png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_ALWAYS, - NULL, 0); -#endif -#endif - - pngtest_debug("Reading info struct"); - png_read_info(read_ptr, read_info_ptr); - -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED - /* This is a bit of a hack; there is no obvious way in the callback function - * to determine that the chunks before the first IDAT have been read, so - * remove the info_ptr (which is only used to determine position relative to - * PLTE) here to indicate that we are after the IDAT. - */ - user_chunk_data.info_ptr = NULL; -#endif - - pngtest_debug("Transferring info struct"); - { - int interlace_type, compression_type, filter_type; - - if (png_get_IHDR(read_ptr, read_info_ptr, &width, &height, &bit_depth, - &color_type, &interlace_type, &compression_type, &filter_type) != 0) - { - png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth, - color_type, interlace_type, compression_type, filter_type); - /* num_passes may not be available below if interlace support is not - * provided by libpng for both read and write. - */ - switch (interlace_type) - { - case PNG_INTERLACE_NONE: - num_passes = 1; - break; - - case PNG_INTERLACE_ADAM7: - num_passes = 7; - break; - - default: - png_error(read_ptr, "invalid interlace type"); - /*NOT REACHED*/ - } - } - - else - png_error(read_ptr, "png_get_IHDR failed"); - } -#ifdef PNG_FIXED_POINT_SUPPORTED -#ifdef PNG_cHRM_SUPPORTED - { - png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x, - blue_y; - - if (png_get_cHRM_fixed(read_ptr, read_info_ptr, &white_x, &white_y, - &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0) - { - png_set_cHRM_fixed(write_ptr, write_info_ptr, white_x, white_y, red_x, - red_y, green_x, green_y, blue_x, blue_y); - } - } -#endif -#ifdef PNG_gAMA_SUPPORTED - { - png_fixed_point gamma; - - if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma) != 0) - png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma); - } -#endif -#else /* Use floating point versions */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -#ifdef PNG_cHRM_SUPPORTED - { - double white_x, white_y, red_x, red_y, green_x, green_y, blue_x, - blue_y; - - if (png_get_cHRM(read_ptr, read_info_ptr, &white_x, &white_y, &red_x, - &red_y, &green_x, &green_y, &blue_x, &blue_y) != 0) - { - png_set_cHRM(write_ptr, write_info_ptr, white_x, white_y, red_x, - red_y, green_x, green_y, blue_x, blue_y); - } - } -#endif -#ifdef PNG_gAMA_SUPPORTED - { - double gamma; - - if (png_get_gAMA(read_ptr, read_info_ptr, &gamma) != 0) - png_set_gAMA(write_ptr, write_info_ptr, gamma); - } -#endif -#endif /* Floating point */ -#endif /* Fixed point */ -#ifdef PNG_iCCP_SUPPORTED - { - png_charp name; - png_bytep profile; - png_uint_32 proflen; - int compression_type; - - if (png_get_iCCP(read_ptr, read_info_ptr, &name, &compression_type, - &profile, &proflen) != 0) - { - png_set_iCCP(write_ptr, write_info_ptr, name, compression_type, - profile, proflen); - } - } -#endif -#ifdef PNG_sRGB_SUPPORTED - { - int intent; - - if (png_get_sRGB(read_ptr, read_info_ptr, &intent) != 0) - png_set_sRGB(write_ptr, write_info_ptr, intent); - } -#endif - { - png_colorp palette; - int num_palette; - - if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette) != 0) - png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); - } -#ifdef PNG_bKGD_SUPPORTED - { - png_color_16p background; - - if (png_get_bKGD(read_ptr, read_info_ptr, &background) != 0) - { - png_set_bKGD(write_ptr, write_info_ptr, background); - } - } -#endif -#ifdef PNG_READ_eXIf_SUPPORTED - { - png_bytep exif=NULL; - png_uint_32 exif_length; - - if (png_get_eXIf_1(read_ptr, read_info_ptr, &exif_length, &exif) != 0) - { - if (exif_length > 1) - fprintf(STDERR," eXIf type %c%c, %lu bytes\n",exif[0],exif[1], - (unsigned long)exif_length); -# ifdef PNG_WRITE_eXIf_SUPPORTED - png_set_eXIf_1(write_ptr, write_info_ptr, exif_length, exif); -# endif - } - } -#endif -#ifdef PNG_hIST_SUPPORTED - { - png_uint_16p hist; - - if (png_get_hIST(read_ptr, read_info_ptr, &hist) != 0) - png_set_hIST(write_ptr, write_info_ptr, hist); - } -#endif -#ifdef PNG_oFFs_SUPPORTED - { - png_int_32 offset_x, offset_y; - int unit_type; - - if (png_get_oFFs(read_ptr, read_info_ptr, &offset_x, &offset_y, - &unit_type) != 0) - { - png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type); - } - } -#endif -#ifdef PNG_pCAL_SUPPORTED - { - png_charp purpose, units; - png_charpp params; - png_int_32 X0, X1; - int type, nparams; - - if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type, - &nparams, &units, ¶ms) != 0) - { - png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type, - nparams, units, params); - } - } -#endif -#ifdef PNG_pHYs_SUPPORTED - { - png_uint_32 res_x, res_y; - int unit_type; - - if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, - &unit_type) != 0) - png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type); - } -#endif -#ifdef PNG_sBIT_SUPPORTED - { - png_color_8p sig_bit; - - if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit) != 0) - png_set_sBIT(write_ptr, write_info_ptr, sig_bit); - } -#endif -#ifdef PNG_sCAL_SUPPORTED -#if defined(PNG_FLOATING_POINT_SUPPORTED) && \ - defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) - { - int unit; - double scal_width, scal_height; - - if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width, - &scal_height) != 0) - { - png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height); - } - } -#else -#ifdef PNG_FIXED_POINT_SUPPORTED - { - int unit; - png_charp scal_width, scal_height; - - if (png_get_sCAL_s(read_ptr, read_info_ptr, &unit, &scal_width, - &scal_height) != 0) - { - png_set_sCAL_s(write_ptr, write_info_ptr, unit, scal_width, - scal_height); - } - } -#endif -#endif -#endif - -#ifdef PNG_sPLT_SUPPORTED - { - png_sPLT_tp entries; - - int num_entries = (int) png_get_sPLT(read_ptr, read_info_ptr, &entries); - if (num_entries) - { - png_set_sPLT(write_ptr, write_info_ptr, entries, num_entries); - } - } -#endif - -#ifdef PNG_TEXT_SUPPORTED - { - png_textp text_ptr; - int num_text; - - if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0) - { - pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text); - - pngtest_check_text_support(read_ptr, text_ptr, num_text); - - if (verbose != 0) - { - int i; - - fprintf(STDERR,"\n"); - for (i=0; igray > sample_max) || - (color_type == PNG_COLOR_TYPE_RGB && - ((int)trans_color->red > sample_max || - (int)trans_color->green > sample_max || - (int)trans_color->blue > sample_max)))) - png_set_tRNS(write_ptr, write_info_ptr, trans_alpha, num_trans, - trans_color); - } - } -#endif -#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED - { - png_unknown_chunkp unknowns; - int num_unknowns = png_get_unknown_chunks(read_ptr, read_info_ptr, - &unknowns); - - if (num_unknowns != 0) - { - png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns, - num_unknowns); -#if PNG_LIBPNG_VER < 10600 - /* Copy the locations from the read_info_ptr. The automatically - * generated locations in write_end_info_ptr are wrong prior to 1.6.0 - * because they are reset from the write pointer (removed in 1.6.0). - */ - { - int i; - for (i = 0; i < num_unknowns; i++) - png_set_unknown_chunk_location(write_ptr, write_info_ptr, i, - unknowns[i].location); - } -#endif - } - } -#endif - -#ifdef PNG_WRITE_SUPPORTED - pngtest_debug("Writing info struct"); - - /* Write the info in two steps so that if we write the 'unknown' chunks here - * they go to the correct place. - */ - png_write_info_before_PLTE(write_ptr, write_info_ptr); - - write_chunks(write_ptr, before_PLTE); /* before PLTE */ - - png_write_info(write_ptr, write_info_ptr); - - write_chunks(write_ptr, before_IDAT); /* after PLTE */ - - png_write_info(write_ptr, write_end_info_ptr); - - write_chunks(write_ptr, after_IDAT); /* after IDAT */ - -#ifdef PNG_COMPRESSION_COMPAT - /* Test the 'compatibility' setting here, if it is available. */ - png_set_compression(write_ptr, PNG_COMPRESSION_COMPAT); -#endif -#endif - -#ifdef SINGLE_ROWBUF_ALLOC - pngtest_debug("Allocating row buffer..."); - row_buf = (png_bytep)png_malloc(read_ptr, - png_get_rowbytes(read_ptr, read_info_ptr)); - - pngtest_debug1("\t%p", row_buf); -#endif /* SINGLE_ROWBUF_ALLOC */ - pngtest_debug("Writing row data"); - -#if defined(PNG_READ_INTERLACING_SUPPORTED) &&\ - defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* Both must be defined for libpng to be able to handle the interlace, - * otherwise it gets handled below by simply reading and writing the passes - * directly. - */ - if (png_set_interlace_handling(read_ptr) != num_passes) - png_error(write_ptr, - "png_set_interlace_handling(read): wrong pass count "); - if (png_set_interlace_handling(write_ptr) != num_passes) - png_error(write_ptr, - "png_set_interlace_handling(write): wrong pass count "); -#else /* png_set_interlace_handling not called on either read or write */ -# define calc_pass_height -#endif /* not using libpng interlace handling */ - -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_misc += (t_stop - t_start); - t_start = t_stop; -#endif - for (pass = 0; pass < num_passes; pass++) - { -# ifdef calc_pass_height - png_uint_32 pass_height; - - if (num_passes == 7) /* interlaced */ - { - if (PNG_PASS_COLS(width, pass) > 0) - pass_height = PNG_PASS_ROWS(height, pass); - - else - pass_height = 0; - } - - else /* not interlaced */ - pass_height = height; -# else -# define pass_height height -# endif - - pngtest_debug1("Writing row data for pass %d", pass); - for (y = 0; y < pass_height; y++) - { -#ifndef SINGLE_ROWBUF_ALLOC - pngtest_debug2("Allocating row buffer (pass %d, y = %u)...", pass, y); - - row_buf = (png_bytep)png_malloc(read_ptr, - png_get_rowbytes(read_ptr, read_info_ptr)); - - pngtest_debug2("\t%p (%lu bytes)", row_buf, - (unsigned long)png_get_rowbytes(read_ptr, read_info_ptr)); - -#endif /* !SINGLE_ROWBUF_ALLOC */ - png_read_rows(read_ptr, (png_bytepp)&row_buf, NULL, 1); - -#ifdef PNG_WRITE_SUPPORTED -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_decode += (t_stop - t_start); - t_start = t_stop; -#endif - png_write_rows(write_ptr, (png_bytepp)&row_buf, 1); -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_encode += (t_stop - t_start); - t_start = t_stop; -#endif -#endif /* WRITE */ - -#ifndef SINGLE_ROWBUF_ALLOC - pngtest_debug2("Freeing row buffer (pass %d, y = %u)", pass, y); - png_free(read_ptr, row_buf); - row_buf = NULL; -#endif /* !SINGLE_ROWBUF_ALLOC */ - } - } - -#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED -# ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED - png_free_data(read_ptr, read_info_ptr, PNG_FREE_UNKN, -1); -# endif -# ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED - png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1); -# endif -#endif - - pngtest_debug("Reading and writing end_info data"); - - png_read_end(read_ptr, end_info_ptr); -#ifdef PNG_TEXT_SUPPORTED - { - png_textp text_ptr; - int num_text; - - if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0) - { - pngtest_debug1("Handling %d iTXt/tEXt/zTXt chunks", num_text); - - pngtest_check_text_support(read_ptr, text_ptr, num_text); - - if (verbose != 0) - { - int i; - - fprintf(STDERR,"\n"); - for (i=0; i 1) - fprintf(STDERR," eXIf type %c%c, %lu bytes\n",exif[0],exif[1], - (unsigned long)exif_length); -# ifdef PNG_WRITE_eXIf_SUPPORTED - png_set_eXIf_1(write_ptr, write_end_info_ptr, exif_length, exif); -# endif - } - } -#endif -#ifdef PNG_tIME_SUPPORTED - { - png_timep mod_time; - - if (png_get_tIME(read_ptr, end_info_ptr, &mod_time) != 0) - { - png_set_tIME(write_ptr, write_end_info_ptr, mod_time); -#ifdef PNG_TIME_RFC1123_SUPPORTED - if (png_convert_to_rfc1123_buffer(tIME_string, mod_time) != 0) - tIME_string[(sizeof tIME_string) - 1] = '\0'; - - else - { - strncpy(tIME_string, "*** invalid time ***", sizeof tIME_string); - tIME_string[(sizeof tIME_string)-1] = '\0'; - } - - tIME_chunk_present++; -#endif /* TIME_RFC1123 */ - } - } -#endif -#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED - { - png_unknown_chunkp unknowns; - int num_unknowns = png_get_unknown_chunks(read_ptr, end_info_ptr, - &unknowns); - - if (num_unknowns != 0) - { - png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns, - num_unknowns); -#if PNG_LIBPNG_VER < 10600 - /* Copy the locations from the read_info_ptr. The automatically - * generated locations in write_end_info_ptr are wrong prior to 1.6.0 - * because they are reset from the write pointer (removed in 1.6.0). - */ - { - int i; - for (i = 0; i < num_unknowns; i++) - png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i, - unknowns[i].location); - } -#endif - } - } -#endif - -#ifdef PNG_WRITE_SUPPORTED -#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED - /* Normally one would use Z_DEFAULT_STRATEGY for text compression. - * This is here just to make pngtest replicate the results from libpng - * versions prior to 1.5.4, and to test this new API. - */ - png_set_text_compression_strategy(write_ptr, Z_FILTERED); -#endif - - /* When the unknown vpAg/sTER chunks are written by pngtest the only way to - * do it is to write them *before* calling png_write_end. When unknown - * chunks are written by libpng, however, they are written just before IEND. - * There seems to be no way round this, however vpAg/sTER are not expected - * after IDAT. - */ - write_chunks(write_ptr, after_IDAT); - - png_write_end(write_ptr, write_end_info_ptr); -#endif - -#ifdef PNG_EASY_ACCESS_SUPPORTED - if (verbose != 0) - { - png_uint_32 iwidth, iheight; - iwidth = png_get_image_width(write_ptr, write_info_ptr); - iheight = png_get_image_height(write_ptr, write_info_ptr); - fprintf(STDERR, "\n Image width = %lu, height = %lu\n", - (unsigned long)iwidth, (unsigned long)iheight); - } -#endif - - pngtest_debug("Destroying data structs"); -#ifdef SINGLE_ROWBUF_ALLOC - pngtest_debug("destroying row_buf for read_ptr"); - png_free(read_ptr, row_buf); - row_buf = NULL; -#endif /* SINGLE_ROWBUF_ALLOC */ - pngtest_debug("destroying read_ptr, read_info_ptr, end_info_ptr"); - png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); -#ifdef PNG_WRITE_SUPPORTED - pngtest_debug("destroying write_end_info_ptr"); - png_destroy_info_struct(write_ptr, &write_end_info_ptr); - pngtest_debug("destroying write_ptr, write_info_ptr"); - png_destroy_write_struct(&write_ptr, &write_info_ptr); -#endif - pngtest_debug("Destruction complete."); - - FCLOSE(fpin); - FCLOSE(fpout); - - /* Summarize any warnings or errors and in 'strict' mode fail the test. - * Unsupported chunks can result in warnings, in that case ignore the strict - * setting, otherwise fail the test on warnings as well as errors. - */ - if (error_count > 0) - { - /* We don't really expect to get here because of the setjmp handling - * above, but this is safe. - */ - fprintf(STDERR, "\n %s: %d libpng errors found (%d warnings)", - inname, error_count, warning_count); - - if (strict != 0) - return (1); - } - -# ifdef PNG_WRITE_SUPPORTED - /* If there is no write support nothing was written! */ - else if (unsupported_chunks > 0) - { - fprintf(STDERR, "\n %s: unsupported chunks (%d)%s", - inname, unsupported_chunks, strict ? ": IGNORED --strict!" : ""); - } -# endif - - else if (warning_count > 0) - { - fprintf(STDERR, "\n %s: %d libpng warnings found", - inname, warning_count); - - if (strict != 0) - return (1); - } - - pngtest_debug("Opening files for comparison"); - if ((fpin = fopen(inname, "rb")) == NULL) - { - fprintf(STDERR, "Could not find file %s\n", inname); - return (1); - } - - if ((fpout = fopen(outname, "rb")) == NULL) - { - fprintf(STDERR, "Could not find file %s\n", outname); - FCLOSE(fpin); - return (1); - } - -#if defined (PNG_WRITE_SUPPORTED) /* else nothing was written */ &&\ - defined (PNG_WRITE_FILTER_SUPPORTED) - if (interlace_preserved != 0) /* else the files will be changed */ - { - for (;;) - { - static int wrote_question = 0; - size_t num_in, num_out; - char inbuf[256], outbuf[256]; - - num_in = fread(inbuf, 1, sizeof inbuf, fpin); - num_out = fread(outbuf, 1, sizeof outbuf, fpout); - - if (num_in != num_out) - { - fprintf(STDERR, "\nFiles %s and %s are of a different size\n", - inname, outname); - - if (wrote_question == 0 && unsupported_chunks == 0) - { - fprintf(STDERR, - " Was %s written with the same maximum IDAT" - " chunk size (%d bytes),", - inname, PNG_ZBUF_SIZE); - fprintf(STDERR, - "\n filtering heuristic (libpng default), compression"); - fprintf(STDERR, - " level (zlib default),\n and zlib version (%s)?\n\n", - ZLIB_VERSION); - wrote_question = 1; - } - - FCLOSE(fpin); - FCLOSE(fpout); - - if (strict != 0 && unsupported_chunks == 0) - return (1); - - else - return (0); - } - - if (num_in == 0) - break; - - if (memcmp(inbuf, outbuf, num_in)) - { - fprintf(STDERR, "\nFiles %s and %s are different\n", inname, - outname); - - if (wrote_question == 0 && unsupported_chunks == 0) - { - fprintf(STDERR, - " Was %s written with the same maximum" - " IDAT chunk size (%d bytes),", - inname, PNG_ZBUF_SIZE); - fprintf(STDERR, - "\n filtering heuristic (libpng default), compression"); - fprintf(STDERR, - " level (zlib default),\n and zlib version (%s)?\n\n", - ZLIB_VERSION); - wrote_question = 1; - } - - FCLOSE(fpin); - FCLOSE(fpout); - - /* NOTE: the unsupported_chunks escape is permitted here because - * unsupported text chunk compression will result in the compression - * mode being changed (to NONE) yet, in the test case, the result - * can be exactly the same size! - */ - if (strict != 0 && unsupported_chunks == 0) - return (1); - - else - return (0); - } - } - } -#endif /* WRITE && WRITE_FILTER */ - - FCLOSE(fpin); - FCLOSE(fpout); - - return (0); -} - -/* Input and output filenames */ -#ifdef RISCOS -static const char *inname = "pngtest/png"; -static const char *outname = "pngout/png"; -#else -static const char *inname = "pngtest.png"; -static const char *outname = "pngout.png"; -#endif - -int -main(int argc, char *argv[]) -{ - int multiple = 0; - int ierror = 0; - - png_structp dummy_ptr; - - fprintf(STDERR, "\n Testing libpng version %s\n", PNG_LIBPNG_VER_STRING); - fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION); - fprintf(STDERR, "%s", png_get_copyright(NULL)); - /* Show the version of libpng used in building the library */ - fprintf(STDERR, " library (%lu):%s", - (unsigned long)png_access_version_number(), - png_get_header_version(NULL)); - - /* Show the version of libpng used in building the application */ - fprintf(STDERR, " pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER, - PNG_HEADER_VERSION_STRING); - - /* Do some consistency checking on the memory allocation settings, I'm - * not sure this matters, but it is nice to know, the first of these - * tests should be impossible because of the way the macros are set - * in pngconf.h - */ -#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) - fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n"); -#endif - /* I think the following can happen. */ -#if !defined(MAXSEG_64K) && defined(PNG_MAX_MALLOC_64K) - fprintf(STDERR, " NOTE: libpng compiled for max 64k, zlib not\n"); -#endif - - if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING)) - { - fprintf(STDERR, - "Warning: versions are different between png.h and png.c\n"); - fprintf(STDERR, " png.h version: %s\n", PNG_LIBPNG_VER_STRING); - fprintf(STDERR, " png.c version: %s\n\n", png_libpng_ver); - ++ierror; - } - - if (argc > 1) - { - if (strcmp(argv[1], "-m") == 0) - { - multiple = 1; - status_dots_requested = 0; - } - - else if (strcmp(argv[1], "-mv") == 0 || - strcmp(argv[1], "-vm") == 0 ) - { - multiple = 1; - verbose = 1; - status_dots_requested = 1; - } - - else if (strcmp(argv[1], "-v") == 0) - { - verbose = 1; - status_dots_requested = 1; - inname = argv[2]; - } - - else if (strcmp(argv[1], "--strict") == 0) - { - status_dots_requested = 0; - verbose = 1; - inname = argv[2]; - strict++; - relaxed = 0; - multiple=1; - } - - else if (strcmp(argv[1], "--relaxed") == 0) - { - status_dots_requested = 0; - verbose = 1; - inname = argv[2]; - strict = 0; - relaxed++; - multiple=1; - } - else if (strcmp(argv[1], "--xfail") == 0) - { - status_dots_requested = 0; - verbose = 1; - inname = argv[2]; - strict = 0; - xfail++; - relaxed++; - multiple=1; - } - - else - { - inname = argv[1]; - status_dots_requested = 0; - } - } - - if (multiple == 0 && argc == 3 + verbose) - outname = argv[2 + verbose]; - - if ((multiple == 0 && argc > 3 + verbose) || - (multiple != 0 && argc < 2)) - { - fprintf(STDERR, - "usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n", - argv[0], argv[0]); - fprintf(STDERR, - " reads/writes one PNG file (without -m) or multiple files (-m)\n"); - fprintf(STDERR, - " with -m %s is used as a temporary file\n", outname); - exit(1); - } - - if (multiple != 0) - { - int i; -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - int allocation_now = current_allocation; -#endif - for (i=2; i 0 - fprintf(STDERR, "\n"); -#endif - kerror = test_one_file(argv[i], outname); - if (kerror == 0) - { -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED - fprintf(STDERR, "\n PASS (%lu zero samples)\n", - (unsigned long)zero_samples); -#else - fprintf(STDERR, " PASS\n"); -#endif -#ifdef PNG_TIME_RFC1123_SUPPORTED - if (tIME_chunk_present != 0) - fprintf(STDERR, " tIME = %s\n", tIME_string); - - tIME_chunk_present = 0; -#endif /* TIME_RFC1123 */ - } - - else - { - if (xfail) - fprintf(STDERR, " XFAIL\n"); - else - { - fprintf(STDERR, " FAIL\n"); - ierror += kerror; - } - } -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - if (allocation_now != current_allocation) - fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", - current_allocation - allocation_now); - - if (current_allocation != 0) - { - memory_infop pinfo = pinformation; - - fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n", - current_allocation); - - while (pinfo != NULL) - { - fprintf(STDERR, " %lu bytes at %p\n", - (unsigned long)pinfo->size, - pinfo->pointer); - pinfo = pinfo->next; - } - } -#endif - } -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - fprintf(STDERR, " Current memory allocation: %10d bytes\n", - current_allocation); - fprintf(STDERR, " Maximum memory allocation: %10d bytes\n", - maximum_allocation); - fprintf(STDERR, " Total memory allocation: %10d bytes\n", - total_allocation); - fprintf(STDERR, " Number of allocations: %10d\n", - num_allocations); -#endif - } - - else - { - int i; - for (i = 0; i<3; ++i) - { - int kerror; -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - int allocation_now = current_allocation; -#endif - if (i == 1) - status_dots_requested = 1; - - else if (verbose == 0) - status_dots_requested = 0; - - if (i == 0 || verbose == 1 || ierror != 0) - { - fprintf(STDERR, "\n Testing %s:", inname); -#if PNG_DEBUG > 0 - fprintf(STDERR, "\n"); -#endif - } - - kerror = test_one_file(inname, outname); - - if (kerror == 0) - { - if (verbose == 1 || i == 2) - { -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED - fprintf(STDERR, "\n PASS (%lu zero samples)\n", - (unsigned long)zero_samples); -#else - fprintf(STDERR, " PASS\n"); -#endif -#ifdef PNG_TIME_RFC1123_SUPPORTED - if (tIME_chunk_present != 0) - fprintf(STDERR, " tIME = %s\n", tIME_string); -#endif /* TIME_RFC1123 */ - } - } - - else - { - if (verbose == 0 && i != 2) - { - fprintf(STDERR, "\n Testing %s:", inname); -#if PNG_DEBUG > 0 - fprintf(STDERR, "\n"); -#endif - } - - if (xfail) - fprintf(STDERR, " XFAIL\n"); - else - { - fprintf(STDERR, " FAIL\n"); - ierror += kerror; - } - } -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - if (allocation_now != current_allocation) - fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", - current_allocation - allocation_now); - - if (current_allocation != 0) - { - memory_infop pinfo = pinformation; - - fprintf(STDERR, "MEMORY ERROR: %d bytes still allocated\n", - current_allocation); - - while (pinfo != NULL) - { - fprintf(STDERR, " %lu bytes at %p\n", - (unsigned long)pinfo->size, pinfo->pointer); - pinfo = pinfo->next; - } - } -#endif - } -#if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - fprintf(STDERR, " Current memory allocation: %10d bytes\n", - current_allocation); - fprintf(STDERR, " Maximum memory allocation: %10d bytes\n", - maximum_allocation); - fprintf(STDERR, " Total memory allocation: %10d bytes\n", - total_allocation); - fprintf(STDERR, " Number of allocations: %10d\n", - num_allocations); -#endif - } - -#ifdef PNGTEST_TIMING - t_stop = (float)clock(); - t_misc += (t_stop - t_start); - t_start = t_stop; - fprintf(STDERR, " CPU time used = %.3f seconds", - (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC); - fprintf(STDERR, " (decoding %.3f,\n", - t_decode/(float)CLOCKS_PER_SEC); - fprintf(STDERR, " encoding %.3f ,", - t_encode/(float)CLOCKS_PER_SEC); - fprintf(STDERR, " other %.3f seconds)\n\n", - t_misc/(float)CLOCKS_PER_SEC); -#endif - - if (ierror == 0) - fprintf(STDERR, " libpng passes test\n"); - - else - fprintf(STDERR, " libpng FAILS test\n"); - - dummy_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - fprintf(STDERR, " Default limits:\n"); - fprintf(STDERR, " width_max = %lu\n", - (unsigned long) png_get_user_width_max(dummy_ptr)); - fprintf(STDERR, " height_max = %lu\n", - (unsigned long) png_get_user_height_max(dummy_ptr)); - if (png_get_chunk_cache_max(dummy_ptr) == 0) - fprintf(STDERR, " cache_max = unlimited\n"); - else - fprintf(STDERR, " cache_max = %lu\n", - (unsigned long) png_get_chunk_cache_max(dummy_ptr)); - if (png_get_chunk_malloc_max(dummy_ptr) == 0) - fprintf(STDERR, " malloc_max = unlimited\n"); - else - fprintf(STDERR, " malloc_max = %lu\n", - (unsigned long) png_get_chunk_malloc_max(dummy_ptr)); - png_destroy_read_struct(&dummy_ptr, NULL, NULL); - - return (int)(ierror != 0); -} -#else -int -main(void) -{ - fprintf(STDERR, - " test ignored because libpng was not built with read support\n"); - /* And skip this test */ - return PNG_LIBPNG_VER < 10600 ? 0 : 77; -} -#endif - -/* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_37 Your_png_h_is_not_version_1_6_37; diff --git a/oversampling/WDL/libpng/pngtrans.c b/oversampling/WDL/libpng/pngtrans.c deleted file mode 100644 index 1100f46..0000000 --- a/oversampling/WDL/libpng/pngtrans.c +++ /dev/null @@ -1,864 +0,0 @@ - -/* pngtrans.c - transforms the data in a row (used by both readers and writers) - * - * Copyright (c) 2018 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - */ - -#include "pngpriv.h" - -#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* Turn on BGR-to-RGB mapping */ -void PNGAPI -png_set_bgr(png_structrp png_ptr) -{ - png_debug(1, "in png_set_bgr"); - - if (png_ptr == NULL) - return; - - png_ptr->transformations |= PNG_BGR; -} -#endif - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* Turn on 16-bit byte swapping */ -void PNGAPI -png_set_swap(png_structrp png_ptr) -{ - png_debug(1, "in png_set_swap"); - - if (png_ptr == NULL) - return; - - if (png_ptr->bit_depth == 16) - png_ptr->transformations |= PNG_SWAP_BYTES; -} -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* Turn on pixel packing */ -void PNGAPI -png_set_packing(png_structrp png_ptr) -{ - png_debug(1, "in png_set_packing"); - - if (png_ptr == NULL) - return; - - if (png_ptr->bit_depth < 8) - { - png_ptr->transformations |= PNG_PACK; -# ifdef PNG_WRITE_SUPPORTED - png_ptr->usr_bit_depth = 8; -# endif - } -} -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* Turn on packed pixel swapping */ -void PNGAPI -png_set_packswap(png_structrp png_ptr) -{ - png_debug(1, "in png_set_packswap"); - - if (png_ptr == NULL) - return; - - if (png_ptr->bit_depth < 8) - png_ptr->transformations |= PNG_PACKSWAP; -} -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) -void PNGAPI -png_set_shift(png_structrp png_ptr, png_const_color_8p true_bits) -{ - png_debug(1, "in png_set_shift"); - - if (png_ptr == NULL) - return; - - png_ptr->transformations |= PNG_SHIFT; - png_ptr->shift = *true_bits; -} -#endif - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) -int PNGAPI -png_set_interlace_handling(png_structrp png_ptr) -{ - png_debug(1, "in png_set_interlace handling"); - - if (png_ptr != 0 && png_ptr->interlaced != 0) - { - png_ptr->transformations |= PNG_INTERLACE; - return (7); - } - - return (1); -} -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -/* Add a filler byte on read, or remove a filler or alpha byte on write. - * The filler type has changed in v0.95 to allow future 2-byte fillers - * for 48-bit input data, as well as to avoid problems with some compilers - * that don't like bytes as parameters. - */ -void PNGAPI -png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc) -{ - png_debug(1, "in png_set_filler"); - - if (png_ptr == NULL) - return; - - /* In libpng 1.6 it is possible to determine whether this is a read or write - * operation and therefore to do more checking here for a valid call. - */ - if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) - { -# ifdef PNG_READ_FILLER_SUPPORTED - /* On read png_set_filler is always valid, regardless of the base PNG - * format, because other transformations can give a format where the - * filler code can execute (basically an 8 or 16-bit component RGB or G - * format.) - * - * NOTE: usr_channels is not used by the read code! (This has led to - * confusion in the past.) The filler is only used in the read code. - */ - png_ptr->filler = (png_uint_16)filler; -# else - png_app_error(png_ptr, "png_set_filler not supported on read"); - PNG_UNUSED(filler) /* not used in the write case */ - return; -# endif - } - - else /* write */ - { -# ifdef PNG_WRITE_FILLER_SUPPORTED - /* On write the usr_channels parameter must be set correctly at the - * start to record the number of channels in the app-supplied data. - */ - switch (png_ptr->color_type) - { - case PNG_COLOR_TYPE_RGB: - png_ptr->usr_channels = 4; - break; - - case PNG_COLOR_TYPE_GRAY: - if (png_ptr->bit_depth >= 8) - { - png_ptr->usr_channels = 2; - break; - } - - else - { - /* There simply isn't any code in libpng to strip out bits - * from bytes when the components are less than a byte in - * size! - */ - png_app_error(png_ptr, - "png_set_filler is invalid for" - " low bit depth gray output"); - return; - } - - default: - png_app_error(png_ptr, - "png_set_filler: inappropriate color type"); - return; - } -# else - png_app_error(png_ptr, "png_set_filler not supported on write"); - return; -# endif - } - - /* Here on success - libpng supports the operation, set the transformation - * and the flag to say where the filler channel is. - */ - png_ptr->transformations |= PNG_FILLER; - - if (filler_loc == PNG_FILLER_AFTER) - png_ptr->flags |= PNG_FLAG_FILLER_AFTER; - - else - png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER; -} - -/* Added to libpng-1.2.7 */ -void PNGAPI -png_set_add_alpha(png_structrp png_ptr, png_uint_32 filler, int filler_loc) -{ - png_debug(1, "in png_set_add_alpha"); - - if (png_ptr == NULL) - return; - - png_set_filler(png_ptr, filler, filler_loc); - /* The above may fail to do anything. */ - if ((png_ptr->transformations & PNG_FILLER) != 0) - png_ptr->transformations |= PNG_ADD_ALPHA; -} - -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -void PNGAPI -png_set_swap_alpha(png_structrp png_ptr) -{ - png_debug(1, "in png_set_swap_alpha"); - - if (png_ptr == NULL) - return; - - png_ptr->transformations |= PNG_SWAP_ALPHA; -} -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -void PNGAPI -png_set_invert_alpha(png_structrp png_ptr) -{ - png_debug(1, "in png_set_invert_alpha"); - - if (png_ptr == NULL) - return; - - png_ptr->transformations |= PNG_INVERT_ALPHA; -} -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -void PNGAPI -png_set_invert_mono(png_structrp png_ptr) -{ - png_debug(1, "in png_set_invert_mono"); - - if (png_ptr == NULL) - return; - - png_ptr->transformations |= PNG_INVERT_MONO; -} - -/* Invert monochrome grayscale data */ -void /* PRIVATE */ -png_do_invert(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_invert"); - - /* This test removed from libpng version 1.0.13 and 1.2.0: - * if (row_info->bit_depth == 1 && - */ - if (row_info->color_type == PNG_COLOR_TYPE_GRAY) - { - png_bytep rp = row; - size_t i; - size_t istop = row_info->rowbytes; - - for (i = 0; i < istop; i++) - { - *rp = (png_byte)(~(*rp)); - rp++; - } - } - - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && - row_info->bit_depth == 8) - { - png_bytep rp = row; - size_t i; - size_t istop = row_info->rowbytes; - - for (i = 0; i < istop; i += 2) - { - *rp = (png_byte)(~(*rp)); - rp += 2; - } - } - -#ifdef PNG_16BIT_SUPPORTED - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA && - row_info->bit_depth == 16) - { - png_bytep rp = row; - size_t i; - size_t istop = row_info->rowbytes; - - for (i = 0; i < istop; i += 4) - { - *rp = (png_byte)(~(*rp)); - *(rp + 1) = (png_byte)(~(*(rp + 1))); - rp += 4; - } - } -#endif -} -#endif - -#ifdef PNG_16BIT_SUPPORTED -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* Swaps byte order on 16-bit depth images */ -void /* PRIVATE */ -png_do_swap(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_swap"); - - if (row_info->bit_depth == 16) - { - png_bytep rp = row; - png_uint_32 i; - png_uint_32 istop= row_info->width * row_info->channels; - - for (i = 0; i < istop; i++, rp += 2) - { -#ifdef PNG_BUILTIN_BSWAP16_SUPPORTED - /* Feature added to libpng-1.6.11 for testing purposes, not - * enabled by default. - */ - *(png_uint_16*)rp = __builtin_bswap16(*(png_uint_16*)rp); -#else - png_byte t = *rp; - *rp = *(rp + 1); - *(rp + 1) = t; -#endif - } - } -} -#endif -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -static const png_byte onebppswaptable[256] = { - 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, - 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, - 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, - 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, - 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, - 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, - 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, - 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, - 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, - 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2, - 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, - 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA, - 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, - 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, - 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, - 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, - 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, - 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, - 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, - 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, - 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, - 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5, - 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, - 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD, - 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, - 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, - 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, - 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, - 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, - 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, - 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, - 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF -}; - -static const png_byte twobppswaptable[256] = { - 0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0, - 0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0, - 0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4, - 0x24, 0x64, 0xA4, 0xE4, 0x34, 0x74, 0xB4, 0xF4, - 0x08, 0x48, 0x88, 0xC8, 0x18, 0x58, 0x98, 0xD8, - 0x28, 0x68, 0xA8, 0xE8, 0x38, 0x78, 0xB8, 0xF8, - 0x0C, 0x4C, 0x8C, 0xCC, 0x1C, 0x5C, 0x9C, 0xDC, - 0x2C, 0x6C, 0xAC, 0xEC, 0x3C, 0x7C, 0xBC, 0xFC, - 0x01, 0x41, 0x81, 0xC1, 0x11, 0x51, 0x91, 0xD1, - 0x21, 0x61, 0xA1, 0xE1, 0x31, 0x71, 0xB1, 0xF1, - 0x05, 0x45, 0x85, 0xC5, 0x15, 0x55, 0x95, 0xD5, - 0x25, 0x65, 0xA5, 0xE5, 0x35, 0x75, 0xB5, 0xF5, - 0x09, 0x49, 0x89, 0xC9, 0x19, 0x59, 0x99, 0xD9, - 0x29, 0x69, 0xA9, 0xE9, 0x39, 0x79, 0xB9, 0xF9, - 0x0D, 0x4D, 0x8D, 0xCD, 0x1D, 0x5D, 0x9D, 0xDD, - 0x2D, 0x6D, 0xAD, 0xED, 0x3D, 0x7D, 0xBD, 0xFD, - 0x02, 0x42, 0x82, 0xC2, 0x12, 0x52, 0x92, 0xD2, - 0x22, 0x62, 0xA2, 0xE2, 0x32, 0x72, 0xB2, 0xF2, - 0x06, 0x46, 0x86, 0xC6, 0x16, 0x56, 0x96, 0xD6, - 0x26, 0x66, 0xA6, 0xE6, 0x36, 0x76, 0xB6, 0xF6, - 0x0A, 0x4A, 0x8A, 0xCA, 0x1A, 0x5A, 0x9A, 0xDA, - 0x2A, 0x6A, 0xAA, 0xEA, 0x3A, 0x7A, 0xBA, 0xFA, - 0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x5E, 0x9E, 0xDE, - 0x2E, 0x6E, 0xAE, 0xEE, 0x3E, 0x7E, 0xBE, 0xFE, - 0x03, 0x43, 0x83, 0xC3, 0x13, 0x53, 0x93, 0xD3, - 0x23, 0x63, 0xA3, 0xE3, 0x33, 0x73, 0xB3, 0xF3, - 0x07, 0x47, 0x87, 0xC7, 0x17, 0x57, 0x97, 0xD7, - 0x27, 0x67, 0xA7, 0xE7, 0x37, 0x77, 0xB7, 0xF7, - 0x0B, 0x4B, 0x8B, 0xCB, 0x1B, 0x5B, 0x9B, 0xDB, - 0x2B, 0x6B, 0xAB, 0xEB, 0x3B, 0x7B, 0xBB, 0xFB, - 0x0F, 0x4F, 0x8F, 0xCF, 0x1F, 0x5F, 0x9F, 0xDF, - 0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF -}; - -static const png_byte fourbppswaptable[256] = { - 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, - 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, - 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71, - 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1, - 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72, - 0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2, - 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73, - 0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3, - 0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74, - 0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4, - 0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75, - 0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5, - 0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76, - 0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6, - 0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77, - 0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7, - 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78, - 0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8, - 0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79, - 0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9, - 0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A, - 0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA, - 0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B, - 0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB, - 0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C, - 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC, - 0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D, - 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD, - 0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E, - 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE, - 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F, - 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF -}; - -/* Swaps pixel packing order within bytes */ -void /* PRIVATE */ -png_do_packswap(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_packswap"); - - if (row_info->bit_depth < 8) - { - png_bytep rp; - png_const_bytep end, table; - - end = row + row_info->rowbytes; - - if (row_info->bit_depth == 1) - table = onebppswaptable; - - else if (row_info->bit_depth == 2) - table = twobppswaptable; - - else if (row_info->bit_depth == 4) - table = fourbppswaptable; - - else - return; - - for (rp = row; rp < end; rp++) - *rp = table[*rp]; - } -} -#endif /* PACKSWAP || WRITE_PACKSWAP */ - -#if defined(PNG_WRITE_FILLER_SUPPORTED) || \ - defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -/* Remove a channel - this used to be 'png_do_strip_filler' but it used a - * somewhat weird combination of flags to determine what to do. All the calls - * to png_do_strip_filler are changed in 1.5.2 to call this instead with the - * correct arguments. - * - * The routine isn't general - the channel must be the channel at the start or - * end (not in the middle) of each pixel. - */ -void /* PRIVATE */ -png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) -{ - png_bytep sp = row; /* source pointer */ - png_bytep dp = row; /* destination pointer */ - png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */ - - /* At the start sp will point to the first byte to copy and dp to where - * it is copied to. ep always points just beyond the end of the row, so - * the loop simply copies (channels-1) channels until sp reaches ep. - * - * at_start: 0 -- convert AG, XG, ARGB, XRGB, AAGG, XXGG, etc. - * nonzero -- convert GA, GX, RGBA, RGBX, GGAA, RRGGBBXX, etc. - */ - - /* GA, GX, XG cases */ - if (row_info->channels == 2) - { - if (row_info->bit_depth == 8) - { - if (at_start != 0) /* Skip initial filler */ - ++sp; - else /* Skip initial channel and, for sp, the filler */ - { - sp += 2; ++dp; - } - - /* For a 1 pixel wide image there is nothing to do */ - while (sp < ep) - { - *dp++ = *sp; sp += 2; - } - - row_info->pixel_depth = 8; - } - - else if (row_info->bit_depth == 16) - { - if (at_start != 0) /* Skip initial filler */ - sp += 2; - else /* Skip initial channel and, for sp, the filler */ - { - sp += 4; dp += 2; - } - - while (sp < ep) - { - *dp++ = *sp++; *dp++ = *sp; sp += 3; - } - - row_info->pixel_depth = 16; - } - - else - return; /* bad bit depth */ - - row_info->channels = 1; - - /* Finally fix the color type if it records an alpha channel */ - if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - row_info->color_type = PNG_COLOR_TYPE_GRAY; - } - - /* RGBA, RGBX, XRGB cases */ - else if (row_info->channels == 4) - { - if (row_info->bit_depth == 8) - { - if (at_start != 0) /* Skip initial filler */ - ++sp; - else /* Skip initial channels and, for sp, the filler */ - { - sp += 4; dp += 3; - } - - /* Note that the loop adds 3 to dp and 4 to sp each time. */ - while (sp < ep) - { - *dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp; sp += 2; - } - - row_info->pixel_depth = 24; - } - - else if (row_info->bit_depth == 16) - { - if (at_start != 0) /* Skip initial filler */ - sp += 2; - else /* Skip initial channels and, for sp, the filler */ - { - sp += 8; dp += 6; - } - - while (sp < ep) - { - /* Copy 6 bytes, skip 2 */ - *dp++ = *sp++; *dp++ = *sp++; - *dp++ = *sp++; *dp++ = *sp++; - *dp++ = *sp++; *dp++ = *sp; sp += 3; - } - - row_info->pixel_depth = 48; - } - - else - return; /* bad bit depth */ - - row_info->channels = 3; - - /* Finally fix the color type if it records an alpha channel */ - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - row_info->color_type = PNG_COLOR_TYPE_RGB; - } - - else - return; /* The filler channel has gone already */ - - /* Fix the rowbytes value. */ - row_info->rowbytes = (size_t)(dp-row); -} -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* Swaps red and blue bytes within a pixel */ -void /* PRIVATE */ -png_do_bgr(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_bgr"); - - if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0) - { - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 3) - { - png_byte save = *rp; - *rp = *(rp + 2); - *(rp + 2) = save; - } - } - - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 4) - { - png_byte save = *rp; - *rp = *(rp + 2); - *(rp + 2) = save; - } - } - } - -#ifdef PNG_16BIT_SUPPORTED - else if (row_info->bit_depth == 16) - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 6) - { - png_byte save = *rp; - *rp = *(rp + 4); - *(rp + 4) = save; - save = *(rp + 1); - *(rp + 1) = *(rp + 5); - *(rp + 5) = save; - } - } - - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - png_bytep rp; - png_uint_32 i; - - for (i = 0, rp = row; i < row_width; i++, rp += 8) - { - png_byte save = *rp; - *rp = *(rp + 4); - *(rp + 4) = save; - save = *(rp + 1); - *(rp + 1) = *(rp + 5); - *(rp + 5) = save; - } - } - } -#endif - } -} -#endif /* READ_BGR || WRITE_BGR */ - -#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \ - defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED) -/* Added at libpng-1.5.10 */ -void /* PRIVATE */ -png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info) -{ - if (png_ptr->num_palette < (1 << row_info->bit_depth) && - png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */ - { - /* Calculations moved outside switch in an attempt to stop different - * compiler warnings. 'padding' is in *bits* within the last byte, it is - * an 'int' because pixel_depth becomes an 'int' in the expression below, - * and this calculation is used because it avoids warnings that other - * forms produced on either GCC or MSVC. - */ - int padding = PNG_PADBITS(row_info->pixel_depth, row_info->width); - png_bytep rp = png_ptr->row_buf + row_info->rowbytes - 1; - - switch (row_info->bit_depth) - { - case 1: - { - /* in this case, all bytes must be 0 so we don't need - * to unpack the pixels except for the rightmost one. - */ - for (; rp > png_ptr->row_buf; rp--) - { - if ((*rp >> padding) != 0) - png_ptr->num_palette_max = 1; - padding = 0; - } - - break; - } - - case 2: - { - for (; rp > png_ptr->row_buf; rp--) - { - int i = ((*rp >> padding) & 0x03); - - if (i > png_ptr->num_palette_max) - png_ptr->num_palette_max = i; - - i = (((*rp >> padding) >> 2) & 0x03); - - if (i > png_ptr->num_palette_max) - png_ptr->num_palette_max = i; - - i = (((*rp >> padding) >> 4) & 0x03); - - if (i > png_ptr->num_palette_max) - png_ptr->num_palette_max = i; - - i = (((*rp >> padding) >> 6) & 0x03); - - if (i > png_ptr->num_palette_max) - png_ptr->num_palette_max = i; - - padding = 0; - } - - break; - } - - case 4: - { - for (; rp > png_ptr->row_buf; rp--) - { - int i = ((*rp >> padding) & 0x0f); - - if (i > png_ptr->num_palette_max) - png_ptr->num_palette_max = i; - - i = (((*rp >> padding) >> 4) & 0x0f); - - if (i > png_ptr->num_palette_max) - png_ptr->num_palette_max = i; - - padding = 0; - } - - break; - } - - case 8: - { - for (; rp > png_ptr->row_buf; rp--) - { - if (*rp > png_ptr->num_palette_max) - png_ptr->num_palette_max = (int) *rp; - } - - break; - } - - default: - break; - } - } -} -#endif /* CHECK_FOR_INVALID_INDEX */ - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED -void PNGAPI -png_set_user_transform_info(png_structrp png_ptr, png_voidp - user_transform_ptr, int user_transform_depth, int user_transform_channels) -{ - png_debug(1, "in png_set_user_transform_info"); - - if (png_ptr == NULL) - return; - -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED - if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 && - (png_ptr->flags & PNG_FLAG_ROW_INIT) != 0) - { - png_app_error(png_ptr, - "info change after png_start_read_image or png_read_update_info"); - return; - } -#endif - - png_ptr->user_transform_ptr = user_transform_ptr; - png_ptr->user_transform_depth = (png_byte)user_transform_depth; - png_ptr->user_transform_channels = (png_byte)user_transform_channels; -} -#endif - -/* This function returns a pointer to the user_transform_ptr associated with - * the user transform functions. The application should free any memory - * associated with this pointer before png_write_destroy and png_read_destroy - * are called. - */ -#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED -png_voidp PNGAPI -png_get_user_transform_ptr(png_const_structrp png_ptr) -{ - if (png_ptr == NULL) - return (NULL); - - return png_ptr->user_transform_ptr; -} -#endif - -#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED -png_uint_32 PNGAPI -png_get_current_row_number(png_const_structrp png_ptr) -{ - /* See the comments in png.h - this is the sub-image row when reading an - * interlaced image. - */ - if (png_ptr != NULL) - return png_ptr->row_number; - - return PNG_UINT_32_MAX; /* help the app not to fail silently */ -} - -png_byte PNGAPI -png_get_current_pass_number(png_const_structrp png_ptr) -{ - if (png_ptr != NULL) - return png_ptr->pass; - return 8; /* invalid */ -} -#endif /* USER_TRANSFORM_INFO */ -#endif /* READ_USER_TRANSFORM || WRITE_USER_TRANSFORM */ -#endif /* READ || WRITE */ diff --git a/oversampling/WDL/libpng/pngwio.c b/oversampling/WDL/libpng/pngwio.c deleted file mode 100644 index 10e919d..0000000 --- a/oversampling/WDL/libpng/pngwio.c +++ /dev/null @@ -1,168 +0,0 @@ - -/* pngwio.c - functions for data output - * - * Copyright (c) 2018 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2014,2016,2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * - * This file provides a location for all output. Users who need - * special handling are expected to write functions that have the same - * arguments as these and perform similar functions, but that possibly - * use different output methods. Note that you shouldn't change these - * functions, but rather write replacement functions and then change - * them at run time with png_set_write_fn(...). - */ - -#include "pngpriv.h" - -#ifdef PNG_WRITE_SUPPORTED - -/* Write the data to whatever output you are using. The default routine - * writes to a file pointer. Note that this routine sometimes gets called - * with very small lengths, so you should implement some kind of simple - * buffering if you are using unbuffered writes. This should never be asked - * to write more than 64K on a 16-bit machine. - */ - -void /* PRIVATE */ -png_write_data(png_structrp png_ptr, png_const_bytep data, size_t length) -{ - /* NOTE: write_data_fn must not change the buffer! */ - if (png_ptr->write_data_fn != NULL ) - (*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data), - length); - - else - png_error(png_ptr, "Call to NULL write function"); -} - -#ifdef PNG_STDIO_SUPPORTED -/* This is the function that does the actual writing of data. If you are - * not writing to a standard C stream, you should create a replacement - * write_data function and use it at run time with png_set_write_fn(), rather - * than changing the library. - */ -void PNGCBAPI -png_default_write_data(png_structp png_ptr, png_bytep data, size_t length) -{ - size_t check; - - if (png_ptr == NULL) - return; - - check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); - - if (check != length) - png_error(png_ptr, "Write Error"); -} -#endif - -/* This function is called to output any data pending writing (normally - * to disk). After png_flush is called, there should be no data pending - * writing in any buffers. - */ -#ifdef PNG_WRITE_FLUSH_SUPPORTED -void /* PRIVATE */ -png_flush(png_structrp png_ptr) -{ - if (png_ptr->output_flush_fn != NULL) - (*(png_ptr->output_flush_fn))(png_ptr); -} - -# ifdef PNG_STDIO_SUPPORTED -void PNGCBAPI -png_default_flush(png_structp png_ptr) -{ - png_FILE_p io_ptr; - - if (png_ptr == NULL) - return; - - io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr)); - fflush(io_ptr); -} -# endif -#endif - -/* This function allows the application to supply new output functions for - * libpng if standard C streams aren't being used. - * - * This function takes as its arguments: - * png_ptr - pointer to a png output data structure - * io_ptr - pointer to user supplied structure containing info about - * the output functions. May be NULL. - * write_data_fn - pointer to a new output function that takes as its - * arguments a pointer to a png_struct, a pointer to - * data to be written, and a 32-bit unsigned int that is - * the number of bytes to be written. The new write - * function should call png_error(png_ptr, "Error msg") - * to exit and output any fatal error messages. May be - * NULL, in which case libpng's default function will - * be used. - * flush_data_fn - pointer to a new flush function that takes as its - * arguments a pointer to a png_struct. After a call to - * the flush function, there should be no data in any buffers - * or pending transmission. If the output method doesn't do - * any buffering of output, a function prototype must still be - * supplied although it doesn't have to do anything. If - * PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile - * time, output_flush_fn will be ignored, although it must be - * supplied for compatibility. May be NULL, in which case - * libpng's default function will be used, if - * PNG_WRITE_FLUSH_SUPPORTED is defined. This is not - * a good idea if io_ptr does not point to a standard - * *FILE structure. - */ -void PNGAPI -png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr, - png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) -{ - if (png_ptr == NULL) - return; - - png_ptr->io_ptr = io_ptr; - -#ifdef PNG_STDIO_SUPPORTED - if (write_data_fn != NULL) - png_ptr->write_data_fn = write_data_fn; - - else - png_ptr->write_data_fn = png_default_write_data; -#else - png_ptr->write_data_fn = write_data_fn; -#endif - -#ifdef PNG_WRITE_FLUSH_SUPPORTED -# ifdef PNG_STDIO_SUPPORTED - - if (output_flush_fn != NULL) - png_ptr->output_flush_fn = output_flush_fn; - - else - png_ptr->output_flush_fn = png_default_flush; - -# else - png_ptr->output_flush_fn = output_flush_fn; -# endif -#else - PNG_UNUSED(output_flush_fn) -#endif /* WRITE_FLUSH */ - -#ifdef PNG_READ_SUPPORTED - /* It is an error to read while writing a png file */ - if (png_ptr->read_data_fn != NULL) - { - png_ptr->read_data_fn = NULL; - - png_warning(png_ptr, - "Can't set both read_data_fn and write_data_fn in the" - " same structure"); - } -#endif -} -#endif /* WRITE */ diff --git a/oversampling/WDL/libpng/pngwrite.c b/oversampling/WDL/libpng/pngwrite.c deleted file mode 100644 index 59377a4..0000000 --- a/oversampling/WDL/libpng/pngwrite.c +++ /dev/null @@ -1,2395 +0,0 @@ - -/* pngwrite.c - general routines to write a PNG file - * - * Copyright (c) 2018-2019 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - */ - -#include "pngpriv.h" -#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED -# include -#endif /* SIMPLIFIED_WRITE_STDIO */ - -#ifdef PNG_WRITE_SUPPORTED - -#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED -/* Write out all the unknown chunks for the current given location */ -static void -write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr, - unsigned int where) -{ - if (info_ptr->unknown_chunks_num != 0) - { - png_const_unknown_chunkp up; - - png_debug(5, "writing extra chunks"); - - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - ++up) - if ((up->location & where) != 0) - { - /* If per-chunk unknown chunk handling is enabled use it, otherwise - * just write the chunks the application has set. - */ -#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED - int keep = png_handle_as_unknown(png_ptr, up->name); - - /* NOTE: this code is radically different from the read side in the - * matter of handling an ancillary unknown chunk. In the read side - * the default behavior is to discard it, in the code below the default - * behavior is to write it. Critical chunks are, however, only - * written if explicitly listed or if the default is set to write all - * unknown chunks. - * - * The default handling is also slightly weird - it is not possible to - * stop the writing of all unsafe-to-copy chunks! - * - * TODO: REVIEW: this would seem to be a bug. - */ - if (keep != PNG_HANDLE_CHUNK_NEVER && - ((up->name[3] & 0x20) /* safe-to-copy overrides everything */ || - keep == PNG_HANDLE_CHUNK_ALWAYS || - (keep == PNG_HANDLE_CHUNK_AS_DEFAULT && - png_ptr->unknown_default == PNG_HANDLE_CHUNK_ALWAYS))) -#endif - { - /* TODO: review, what is wrong with a zero length unknown chunk? */ - if (up->size == 0) - png_warning(png_ptr, "Writing zero-length unknown chunk"); - - png_write_chunk(png_ptr, up->name, up->data, up->size); - } - } - } -} -#endif /* WRITE_UNKNOWN_CHUNKS */ - -/* Writes all the PNG information. This is the suggested way to use the - * library. If you have a new chunk to add, make a function to write it, - * and put it in the correct location here. If you want the chunk written - * after the image data, put it in png_write_end(). I strongly encourage - * you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing - * the chunk, as that will keep the code from breaking if you want to just - * write a plain PNG file. If you have long comments, I suggest writing - * them in png_write_end(), and compressing them. - */ -void PNGAPI -png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr) -{ - png_debug(1, "in png_write_info_before_PLTE"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0) - { - /* Write PNG signature */ - png_write_sig(png_ptr); - -#ifdef PNG_MNG_FEATURES_SUPPORTED - if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && \ - png_ptr->mng_features_permitted != 0) - { - png_warning(png_ptr, - "MNG features are not allowed in a PNG datastream"); - png_ptr->mng_features_permitted = 0; - } -#endif - - /* Write IHDR information. */ - png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height, - info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, - info_ptr->filter_type, -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - info_ptr->interlace_type -#else - 0 -#endif - ); - - /* The rest of these check to see if the valid field has the appropriate - * flag set, and if it does, writes the chunk. - * - * 1.6.0: COLORSPACE support controls the writing of these chunks too, and - * the chunks will be written if the WRITE routine is there and - * information * is available in the COLORSPACE. (See - * png_colorspace_sync_info in png.c for where the valid flags get set.) - * - * Under certain circumstances the colorspace can be invalidated without - * syncing the info_struct 'valid' flags; this happens if libpng detects - * an error and calls png_error while the color space is being set, yet - * the application continues writing the PNG. So check the 'invalid' - * flag here too. - */ -#ifdef PNG_GAMMA_SUPPORTED -# ifdef PNG_WRITE_gAMA_SUPPORTED - if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 && - (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) != 0 && - (info_ptr->valid & PNG_INFO_gAMA) != 0) - png_write_gAMA_fixed(png_ptr, info_ptr->colorspace.gamma); -# endif -#endif - -#ifdef PNG_COLORSPACE_SUPPORTED - /* Write only one of sRGB or an ICC profile. If a profile was supplied - * and it matches one of the known sRGB ones issue a warning. - */ -# ifdef PNG_WRITE_iCCP_SUPPORTED - if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 && - (info_ptr->valid & PNG_INFO_iCCP) != 0) - { -# ifdef PNG_WRITE_sRGB_SUPPORTED - if ((info_ptr->valid & PNG_INFO_sRGB) != 0) - png_app_warning(png_ptr, - "profile matches sRGB but writing iCCP instead"); -# endif - - png_write_iCCP(png_ptr, info_ptr->iccp_name, - info_ptr->iccp_profile); - } -# ifdef PNG_WRITE_sRGB_SUPPORTED - else -# endif -# endif - -# ifdef PNG_WRITE_sRGB_SUPPORTED - if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 && - (info_ptr->valid & PNG_INFO_sRGB) != 0) - png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent); -# endif /* WRITE_sRGB */ -#endif /* COLORSPACE */ - -#ifdef PNG_WRITE_sBIT_SUPPORTED - if ((info_ptr->valid & PNG_INFO_sBIT) != 0) - png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type); -#endif - -#ifdef PNG_COLORSPACE_SUPPORTED -# ifdef PNG_WRITE_cHRM_SUPPORTED - if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 && - (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0 && - (info_ptr->valid & PNG_INFO_cHRM) != 0) - png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy); -# endif -#endif - -#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED - write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR); -#endif - - png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE; - } -} - -void PNGAPI -png_write_info(png_structrp png_ptr, png_const_inforp info_ptr) -{ -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) - int i; -#endif - - png_debug(1, "in png_write_info"); - - if (png_ptr == NULL || info_ptr == NULL) - return; - - png_write_info_before_PLTE(png_ptr, info_ptr); - - if ((info_ptr->valid & PNG_INFO_PLTE) != 0) - png_write_PLTE(png_ptr, info_ptr->palette, - (png_uint_32)info_ptr->num_palette); - - else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - png_error(png_ptr, "Valid palette required for paletted images"); - -#ifdef PNG_WRITE_tRNS_SUPPORTED - if ((info_ptr->valid & PNG_INFO_tRNS) !=0) - { -#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED - /* Invert the alpha channel (in tRNS) */ - if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0 && - info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - int j, jend; - - jend = info_ptr->num_trans; - if (jend > PNG_MAX_PALETTE_LENGTH) - jend = PNG_MAX_PALETTE_LENGTH; - - for (j = 0; jtrans_alpha[j] = - (png_byte)(255 - info_ptr->trans_alpha[j]); - } -#endif - png_write_tRNS(png_ptr, info_ptr->trans_alpha, &(info_ptr->trans_color), - info_ptr->num_trans, info_ptr->color_type); - } -#endif -#ifdef PNG_WRITE_bKGD_SUPPORTED - if ((info_ptr->valid & PNG_INFO_bKGD) != 0) - png_write_bKGD(png_ptr, &(info_ptr->background), info_ptr->color_type); -#endif - -#ifdef PNG_WRITE_eXIf_SUPPORTED - if ((info_ptr->valid & PNG_INFO_eXIf) != 0) - png_write_eXIf(png_ptr, info_ptr->exif, info_ptr->num_exif); -#endif - -#ifdef PNG_WRITE_hIST_SUPPORTED - if ((info_ptr->valid & PNG_INFO_hIST) != 0) - png_write_hIST(png_ptr, info_ptr->hist, info_ptr->num_palette); -#endif - -#ifdef PNG_WRITE_oFFs_SUPPORTED - if ((info_ptr->valid & PNG_INFO_oFFs) != 0) - png_write_oFFs(png_ptr, info_ptr->x_offset, info_ptr->y_offset, - info_ptr->offset_unit_type); -#endif - -#ifdef PNG_WRITE_pCAL_SUPPORTED - if ((info_ptr->valid & PNG_INFO_pCAL) != 0) - png_write_pCAL(png_ptr, info_ptr->pcal_purpose, info_ptr->pcal_X0, - info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams, - info_ptr->pcal_units, info_ptr->pcal_params); -#endif - -#ifdef PNG_WRITE_sCAL_SUPPORTED - if ((info_ptr->valid & PNG_INFO_sCAL) != 0) - png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit, - info_ptr->scal_s_width, info_ptr->scal_s_height); -#endif /* sCAL */ - -#ifdef PNG_WRITE_pHYs_SUPPORTED - if ((info_ptr->valid & PNG_INFO_pHYs) != 0) - png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit, - info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type); -#endif /* pHYs */ - -#ifdef PNG_WRITE_tIME_SUPPORTED - if ((info_ptr->valid & PNG_INFO_tIME) != 0) - { - png_write_tIME(png_ptr, &(info_ptr->mod_time)); - png_ptr->mode |= PNG_WROTE_tIME; - } -#endif /* tIME */ - -#ifdef PNG_WRITE_sPLT_SUPPORTED - if ((info_ptr->valid & PNG_INFO_sPLT) != 0) - for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) - png_write_sPLT(png_ptr, info_ptr->splt_palettes + i); -#endif /* sPLT */ - -#ifdef PNG_WRITE_TEXT_SUPPORTED - /* Check to see if we need to write text chunks */ - for (i = 0; i < info_ptr->num_text; i++) - { - png_debug2(2, "Writing header text chunk %d, type %d", i, - info_ptr->text[i].compression); - /* An internationalized chunk? */ - if (info_ptr->text[i].compression > 0) - { -#ifdef PNG_WRITE_iTXt_SUPPORTED - /* Write international chunk */ - png_write_iTXt(png_ptr, - info_ptr->text[i].compression, - info_ptr->text[i].key, - info_ptr->text[i].lang, - info_ptr->text[i].lang_key, - info_ptr->text[i].text); - /* Mark this chunk as written */ - if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - else - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; -#else - png_warning(png_ptr, "Unable to write international text"); -#endif - } - - /* If we want a compressed text chunk */ - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt) - { -#ifdef PNG_WRITE_zTXt_SUPPORTED - /* Write compressed chunk */ - png_write_zTXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, info_ptr->text[i].compression); - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; -#else - png_warning(png_ptr, "Unable to write compressed text"); -#endif - } - - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) - { -#ifdef PNG_WRITE_tEXt_SUPPORTED - /* Write uncompressed chunk */ - png_write_tEXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, - 0); - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; -#else - /* Can't get here */ - png_warning(png_ptr, "Unable to write uncompressed text"); -#endif - } - } -#endif /* tEXt */ - -#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED - write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_PLTE); -#endif -} - -/* Writes the end of the PNG file. If you don't want to write comments or - * time information, you can pass NULL for info. If you already wrote these - * in png_write_info(), do not write them again here. If you have long - * comments, I suggest writing them here, and compressing them. - */ -void PNGAPI -png_write_end(png_structrp png_ptr, png_inforp info_ptr) -{ - png_debug(1, "in png_write_end"); - - if (png_ptr == NULL) - return; - - if ((png_ptr->mode & PNG_HAVE_IDAT) == 0) - png_error(png_ptr, "No IDATs written into file"); - -#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED - if (png_ptr->num_palette_max > png_ptr->num_palette) - png_benign_error(png_ptr, "Wrote palette index exceeding num_palette"); -#endif - - /* See if user wants us to write information chunks */ - if (info_ptr != NULL) - { -#ifdef PNG_WRITE_TEXT_SUPPORTED - int i; /* local index variable */ -#endif -#ifdef PNG_WRITE_tIME_SUPPORTED - /* Check to see if user has supplied a time chunk */ - if ((info_ptr->valid & PNG_INFO_tIME) != 0 && - (png_ptr->mode & PNG_WROTE_tIME) == 0) - png_write_tIME(png_ptr, &(info_ptr->mod_time)); - -#endif -#ifdef PNG_WRITE_TEXT_SUPPORTED - /* Loop through comment chunks */ - for (i = 0; i < info_ptr->num_text; i++) - { - png_debug2(2, "Writing trailer text chunk %d, type %d", i, - info_ptr->text[i].compression); - /* An internationalized chunk? */ - if (info_ptr->text[i].compression > 0) - { -#ifdef PNG_WRITE_iTXt_SUPPORTED - /* Write international chunk */ - png_write_iTXt(png_ptr, - info_ptr->text[i].compression, - info_ptr->text[i].key, - info_ptr->text[i].lang, - info_ptr->text[i].lang_key, - info_ptr->text[i].text); - /* Mark this chunk as written */ - if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; - else - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; -#else - png_warning(png_ptr, "Unable to write international text"); -#endif - } - - else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt) - { -#ifdef PNG_WRITE_zTXt_SUPPORTED - /* Write compressed chunk */ - png_write_zTXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, info_ptr->text[i].compression); - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR; -#else - png_warning(png_ptr, "Unable to write compressed text"); -#endif - } - - else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) - { -#ifdef PNG_WRITE_tEXt_SUPPORTED - /* Write uncompressed chunk */ - png_write_tEXt(png_ptr, info_ptr->text[i].key, - info_ptr->text[i].text, 0); - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; -#else - png_warning(png_ptr, "Unable to write uncompressed text"); -#endif - } - } -#endif - -#ifdef PNG_WRITE_eXIf_SUPPORTED - if ((info_ptr->valid & PNG_INFO_eXIf) != 0) - png_write_eXIf(png_ptr, info_ptr->exif, info_ptr->num_exif); -#endif - -#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED - write_unknown_chunks(png_ptr, info_ptr, PNG_AFTER_IDAT); -#endif - } - - png_ptr->mode |= PNG_AFTER_IDAT; - - /* Write end of PNG file */ - png_write_IEND(png_ptr); - - /* This flush, added in libpng-1.0.8, removed from libpng-1.0.9beta03, - * and restored again in libpng-1.2.30, may cause some applications that - * do not set png_ptr->output_flush_fn to crash. If your application - * experiences a problem, please try building libpng with - * PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED defined, and report the event to - * png-mng-implement at lists.sf.net . - */ -#ifdef PNG_WRITE_FLUSH_SUPPORTED -# ifdef PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED - png_flush(png_ptr); -# endif -#endif -} - -#ifdef PNG_CONVERT_tIME_SUPPORTED -void PNGAPI -png_convert_from_struct_tm(png_timep ptime, const struct tm * ttime) -{ - png_debug(1, "in png_convert_from_struct_tm"); - - ptime->year = (png_uint_16)(1900 + ttime->tm_year); - ptime->month = (png_byte)(ttime->tm_mon + 1); - ptime->day = (png_byte)ttime->tm_mday; - ptime->hour = (png_byte)ttime->tm_hour; - ptime->minute = (png_byte)ttime->tm_min; - ptime->second = (png_byte)ttime->tm_sec; -} - -void PNGAPI -png_convert_from_time_t(png_timep ptime, time_t ttime) -{ - struct tm *tbuf; - - png_debug(1, "in png_convert_from_time_t"); - - tbuf = gmtime(&ttime); - png_convert_from_struct_tm(ptime, tbuf); -} -#endif - -/* Initialize png_ptr structure, and allocate any memory needed */ -PNG_FUNCTION(png_structp,PNGAPI -png_create_write_struct,(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED) -{ -#ifndef PNG_USER_MEM_SUPPORTED - png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr, - error_fn, warn_fn, NULL, NULL, NULL); -#else - return png_create_write_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, NULL, NULL, NULL); -} - -/* Alternate initialize png_ptr structure, and allocate any memory needed */ -PNG_FUNCTION(png_structp,PNGAPI -png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) -{ - png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr, - error_fn, warn_fn, mem_ptr, malloc_fn, free_fn); -#endif /* USER_MEM */ - if (png_ptr != NULL) - { - /* Set the zlib control values to defaults; they can be overridden by the - * application after the struct has been created. - */ - png_ptr->zbuffer_size = PNG_ZBUF_SIZE; - - /* The 'zlib_strategy' setting is irrelevant because png_default_claim in - * pngwutil.c defaults it according to whether or not filters will be - * used, and ignores this setting. - */ - png_ptr->zlib_strategy = PNG_Z_DEFAULT_STRATEGY; - png_ptr->zlib_level = PNG_Z_DEFAULT_COMPRESSION; - png_ptr->zlib_mem_level = 8; - png_ptr->zlib_window_bits = 15; - png_ptr->zlib_method = 8; - -#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED - png_ptr->zlib_text_strategy = PNG_TEXT_Z_DEFAULT_STRATEGY; - png_ptr->zlib_text_level = PNG_TEXT_Z_DEFAULT_COMPRESSION; - png_ptr->zlib_text_mem_level = 8; - png_ptr->zlib_text_window_bits = 15; - png_ptr->zlib_text_method = 8; -#endif /* WRITE_COMPRESSED_TEXT */ - - /* This is a highly dubious configuration option; by default it is off, - * but it may be appropriate for private builds that are testing - * extensions not conformant to the current specification, or of - * applications that must not fail to write at all costs! - */ -#ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED - /* In stable builds only warn if an application error can be completely - * handled. - */ - png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN; -#endif - - /* App warnings are warnings in release (or release candidate) builds but - * are errors during development. - */ -#if PNG_RELEASE_BUILD - png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN; -#endif - - /* TODO: delay this, it can be done in png_init_io() (if the app doesn't - * do it itself) avoiding setting the default function if it is not - * required. - */ - png_set_write_fn(png_ptr, NULL, NULL, NULL); - } - - return png_ptr; -} - - -/* Write a few rows of image data. If the image is interlaced, - * either you will have to write the 7 sub images, or, if you - * have called png_set_interlace_handling(), you will have to - * "write" the image seven times. - */ -void PNGAPI -png_write_rows(png_structrp png_ptr, png_bytepp row, - png_uint_32 num_rows) -{ - png_uint_32 i; /* row counter */ - png_bytepp rp; /* row pointer */ - - png_debug(1, "in png_write_rows"); - - if (png_ptr == NULL) - return; - - /* Loop through the rows */ - for (i = 0, rp = row; i < num_rows; i++, rp++) - { - png_write_row(png_ptr, *rp); - } -} - -/* Write the image. You only need to call this function once, even - * if you are writing an interlaced image. - */ -void PNGAPI -png_write_image(png_structrp png_ptr, png_bytepp image) -{ - png_uint_32 i; /* row index */ - int pass, num_pass; /* pass variables */ - png_bytepp rp; /* points to current row */ - - if (png_ptr == NULL) - return; - - png_debug(1, "in png_write_image"); - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* Initialize interlace handling. If image is not interlaced, - * this will set pass to 1 - */ - num_pass = png_set_interlace_handling(png_ptr); -#else - num_pass = 1; -#endif - /* Loop through passes */ - for (pass = 0; pass < num_pass; pass++) - { - /* Loop through image */ - for (i = 0, rp = image; i < png_ptr->height; i++, rp++) - { - png_write_row(png_ptr, *rp); - } - } -} - -#ifdef PNG_MNG_FEATURES_SUPPORTED -/* Performs intrapixel differencing */ -static void -png_do_write_intrapixel(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_intrapixel"); - - if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0) - { - int bytes_per_pixel; - png_uint_32 row_width = row_info->width; - if (row_info->bit_depth == 8) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 3; - - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 4; - - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - *(rp) = (png_byte)(*rp - *(rp + 1)); - *(rp + 2) = (png_byte)(*(rp + 2) - *(rp + 1)); - } - } - -#ifdef PNG_WRITE_16BIT_SUPPORTED - else if (row_info->bit_depth == 16) - { - png_bytep rp; - png_uint_32 i; - - if (row_info->color_type == PNG_COLOR_TYPE_RGB) - bytes_per_pixel = 6; - - else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - bytes_per_pixel = 8; - - else - return; - - for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) - { - png_uint_32 s0 = (png_uint_32)(*(rp ) << 8) | *(rp + 1); - png_uint_32 s1 = (png_uint_32)(*(rp + 2) << 8) | *(rp + 3); - png_uint_32 s2 = (png_uint_32)(*(rp + 4) << 8) | *(rp + 5); - png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL); - png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL); - *(rp ) = (png_byte)(red >> 8); - *(rp + 1) = (png_byte)red; - *(rp + 4) = (png_byte)(blue >> 8); - *(rp + 5) = (png_byte)blue; - } - } -#endif /* WRITE_16BIT */ - } -} -#endif /* MNG_FEATURES */ - -/* Called by user to write a row of image data */ -void PNGAPI -png_write_row(png_structrp png_ptr, png_const_bytep row) -{ - /* 1.5.6: moved from png_struct to be a local structure: */ - png_row_info row_info; - - if (png_ptr == NULL) - return; - - png_debug2(1, "in png_write_row (row %u, pass %d)", - png_ptr->row_number, png_ptr->pass); - - /* Initialize transformations and other stuff if first time */ - if (png_ptr->row_number == 0 && png_ptr->pass == 0) - { - /* Make sure we wrote the header info */ - if ((png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE) == 0) - png_error(png_ptr, - "png_write_info was never called before png_write_row"); - - /* Check for transforms that have been set but were defined out */ -#if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED) - if ((png_ptr->transformations & PNG_INVERT_MONO) != 0) - png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined"); -#endif - -#if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED) - if ((png_ptr->transformations & PNG_FILLER) != 0) - png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined"); -#endif -#if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \ - defined(PNG_READ_PACKSWAP_SUPPORTED) - if ((png_ptr->transformations & PNG_PACKSWAP) != 0) - png_warning(png_ptr, - "PNG_WRITE_PACKSWAP_SUPPORTED is not defined"); -#endif - -#if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED) - if ((png_ptr->transformations & PNG_PACK) != 0) - png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined"); -#endif - -#if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED) - if ((png_ptr->transformations & PNG_SHIFT) != 0) - png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined"); -#endif - -#if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED) - if ((png_ptr->transformations & PNG_BGR) != 0) - png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined"); -#endif - -#if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED) - if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0) - png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined"); -#endif - - png_write_start_row(png_ptr); - } - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* If interlaced and not interested in row, return */ - if (png_ptr->interlaced != 0 && - (png_ptr->transformations & PNG_INTERLACE) != 0) - { - switch (png_ptr->pass) - { - case 0: - if ((png_ptr->row_number & 0x07) != 0) - { - png_write_finish_row(png_ptr); - return; - } - break; - - case 1: - if ((png_ptr->row_number & 0x07) != 0 || png_ptr->width < 5) - { - png_write_finish_row(png_ptr); - return; - } - break; - - case 2: - if ((png_ptr->row_number & 0x07) != 4) - { - png_write_finish_row(png_ptr); - return; - } - break; - - case 3: - if ((png_ptr->row_number & 0x03) != 0 || png_ptr->width < 3) - { - png_write_finish_row(png_ptr); - return; - } - break; - - case 4: - if ((png_ptr->row_number & 0x03) != 2) - { - png_write_finish_row(png_ptr); - return; - } - break; - - case 5: - if ((png_ptr->row_number & 0x01) != 0 || png_ptr->width < 2) - { - png_write_finish_row(png_ptr); - return; - } - break; - - case 6: - if ((png_ptr->row_number & 0x01) == 0) - { - png_write_finish_row(png_ptr); - return; - } - break; - - default: /* error: ignore it */ - break; - } - } -#endif - - /* Set up row info for transformations */ - row_info.color_type = png_ptr->color_type; - row_info.width = png_ptr->usr_width; - row_info.channels = png_ptr->usr_channels; - row_info.bit_depth = png_ptr->usr_bit_depth; - row_info.pixel_depth = (png_byte)(row_info.bit_depth * row_info.channels); - row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width); - - png_debug1(3, "row_info->color_type = %d", row_info.color_type); - png_debug1(3, "row_info->width = %u", row_info.width); - png_debug1(3, "row_info->channels = %d", row_info.channels); - png_debug1(3, "row_info->bit_depth = %d", row_info.bit_depth); - png_debug1(3, "row_info->pixel_depth = %d", row_info.pixel_depth); - png_debug1(3, "row_info->rowbytes = %lu", (unsigned long)row_info.rowbytes); - - /* Copy user's row into buffer, leaving room for filter byte. */ - memcpy(png_ptr->row_buf + 1, row, row_info.rowbytes); - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* Handle interlacing */ - if (png_ptr->interlaced && png_ptr->pass < 6 && - (png_ptr->transformations & PNG_INTERLACE) != 0) - { - png_do_write_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass); - /* This should always get caught above, but still ... */ - if (row_info.width == 0) - { - png_write_finish_row(png_ptr); - return; - } - } -#endif - -#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED - /* Handle other transformations */ - if (png_ptr->transformations != 0) - png_do_write_transformations(png_ptr, &row_info); -#endif - - /* At this point the row_info pixel depth must match the 'transformed' depth, - * which is also the output depth. - */ - if (row_info.pixel_depth != png_ptr->pixel_depth || - row_info.pixel_depth != png_ptr->transformed_pixel_depth) - png_error(png_ptr, "internal write transform logic error"); - -#ifdef PNG_MNG_FEATURES_SUPPORTED - /* Write filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not write a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 && - (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) - { - /* Intrapixel differencing */ - png_do_write_intrapixel(&row_info, png_ptr->row_buf + 1); - } -#endif - -/* Added at libpng-1.5.10 */ -#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED - /* Check for out-of-range palette index */ - if (row_info.color_type == PNG_COLOR_TYPE_PALETTE && - png_ptr->num_palette_max >= 0) - png_do_check_palette_indexes(png_ptr, &row_info); -#endif - - /* Find a filter if necessary, filter the row and write it out. */ - png_write_find_filter(png_ptr, &row_info); - - if (png_ptr->write_row_fn != NULL) - (*(png_ptr->write_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass); -} - -#ifdef PNG_WRITE_FLUSH_SUPPORTED -/* Set the automatic flush interval or 0 to turn flushing off */ -void PNGAPI -png_set_flush(png_structrp png_ptr, int nrows) -{ - png_debug(1, "in png_set_flush"); - - if (png_ptr == NULL) - return; - - png_ptr->flush_dist = (nrows < 0 ? 0 : (png_uint_32)nrows); -} - -/* Flush the current output buffers now */ -void PNGAPI -png_write_flush(png_structrp png_ptr) -{ - png_debug(1, "in png_write_flush"); - - if (png_ptr == NULL) - return; - - /* We have already written out all of the data */ - if (png_ptr->row_number >= png_ptr->num_rows) - return; - - png_compress_IDAT(png_ptr, NULL, 0, Z_SYNC_FLUSH); - png_ptr->flush_rows = 0; - png_flush(png_ptr); -} -#endif /* WRITE_FLUSH */ - -/* Free any memory used in png_ptr struct without freeing the struct itself. */ -static void -png_write_destroy(png_structrp png_ptr) -{ - png_debug(1, "in png_write_destroy"); - - /* Free any memory zlib uses */ - if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0) - deflateEnd(&png_ptr->zstream); - - /* Free our memory. png_free checks NULL for us. */ - png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list); - png_free(png_ptr, png_ptr->row_buf); - png_ptr->row_buf = NULL; -#ifdef PNG_WRITE_FILTER_SUPPORTED - png_free(png_ptr, png_ptr->prev_row); - png_free(png_ptr, png_ptr->try_row); - png_free(png_ptr, png_ptr->tst_row); - png_ptr->prev_row = NULL; - png_ptr->try_row = NULL; - png_ptr->tst_row = NULL; -#endif - -#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list = NULL; -#endif - - /* The error handling and memory handling information is left intact at this - * point: the jmp_buf may still have to be freed. See png_destroy_png_struct - * for how this happens. - */ -} - -/* Free all memory used by the write. - * In libpng 1.6.0 this API changed quietly to no longer accept a NULL value for - * *png_ptr_ptr. Prior to 1.6.0 it would accept such a value and it would free - * the passed in info_structs but it would quietly fail to free any of the data - * inside them. In 1.6.0 it quietly does nothing (it has to be quiet because it - * has no png_ptr.) - */ -void PNGAPI -png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) -{ - png_debug(1, "in png_destroy_write_struct"); - - if (png_ptr_ptr != NULL) - { - png_structrp png_ptr = *png_ptr_ptr; - - if (png_ptr != NULL) /* added in libpng 1.6.0 */ - { - png_destroy_info_struct(png_ptr, info_ptr_ptr); - - *png_ptr_ptr = NULL; - png_write_destroy(png_ptr); - png_destroy_png_struct(png_ptr); - } - } -} - -/* Allow the application to select one or more row filters to use. */ -void PNGAPI -png_set_filter(png_structrp png_ptr, int method, int filters) -{ - png_debug(1, "in png_set_filter"); - - if (png_ptr == NULL) - return; - -#ifdef PNG_MNG_FEATURES_SUPPORTED - if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 && - (method == PNG_INTRAPIXEL_DIFFERENCING)) - method = PNG_FILTER_TYPE_BASE; - -#endif - if (method == PNG_FILTER_TYPE_BASE) - { - switch (filters & (PNG_ALL_FILTERS | 0x07)) - { -#ifdef PNG_WRITE_FILTER_SUPPORTED - case 5: - case 6: - case 7: png_app_error(png_ptr, "Unknown row filter for method 0"); -#endif /* WRITE_FILTER */ - /* FALLTHROUGH */ - case PNG_FILTER_VALUE_NONE: - png_ptr->do_filter = PNG_FILTER_NONE; break; - -#ifdef PNG_WRITE_FILTER_SUPPORTED - case PNG_FILTER_VALUE_SUB: - png_ptr->do_filter = PNG_FILTER_SUB; break; - - case PNG_FILTER_VALUE_UP: - png_ptr->do_filter = PNG_FILTER_UP; break; - - case PNG_FILTER_VALUE_AVG: - png_ptr->do_filter = PNG_FILTER_AVG; break; - - case PNG_FILTER_VALUE_PAETH: - png_ptr->do_filter = PNG_FILTER_PAETH; break; - - default: - png_ptr->do_filter = (png_byte)filters; break; -#else - default: - png_app_error(png_ptr, "Unknown row filter for method 0"); -#endif /* WRITE_FILTER */ - } - -#ifdef PNG_WRITE_FILTER_SUPPORTED - /* If we have allocated the row_buf, this means we have already started - * with the image and we should have allocated all of the filter buffers - * that have been selected. If prev_row isn't already allocated, then - * it is too late to start using the filters that need it, since we - * will be missing the data in the previous row. If an application - * wants to start and stop using particular filters during compression, - * it should start out with all of the filters, and then remove them - * or add them back after the start of compression. - * - * NOTE: this is a nasty constraint on the code, because it means that the - * prev_row buffer must be maintained even if there are currently no - * 'prev_row' requiring filters active. - */ - if (png_ptr->row_buf != NULL) - { - int num_filters; - png_alloc_size_t buf_size; - - /* Repeat the checks in png_write_start_row; 1 pixel high or wide - * images cannot benefit from certain filters. If this isn't done here - * the check below will fire on 1 pixel high images. - */ - if (png_ptr->height == 1) - filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH); - - if (png_ptr->width == 1) - filters &= ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH); - - if ((filters & (PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH)) != 0 - && png_ptr->prev_row == NULL) - { - /* This is the error case, however it is benign - the previous row - * is not available so the filter can't be used. Just warn here. - */ - png_app_warning(png_ptr, - "png_set_filter: UP/AVG/PAETH cannot be added after start"); - filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH); - } - - num_filters = 0; - - if (filters & PNG_FILTER_SUB) - num_filters++; - - if (filters & PNG_FILTER_UP) - num_filters++; - - if (filters & PNG_FILTER_AVG) - num_filters++; - - if (filters & PNG_FILTER_PAETH) - num_filters++; - - /* Allocate needed row buffers if they have not already been - * allocated. - */ - buf_size = PNG_ROWBYTES(png_ptr->usr_channels * png_ptr->usr_bit_depth, - png_ptr->width) + 1; - - if (png_ptr->try_row == NULL) - png_ptr->try_row = png_voidcast(png_bytep, - png_malloc(png_ptr, buf_size)); - - if (num_filters > 1) - { - if (png_ptr->tst_row == NULL) - png_ptr->tst_row = png_voidcast(png_bytep, - png_malloc(png_ptr, buf_size)); - } - } - png_ptr->do_filter = (png_byte)filters; -#endif - } - else - png_error(png_ptr, "Unknown custom filter method"); -} - -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */ -/* Provide floating and fixed point APIs */ -#ifdef PNG_FLOATING_POINT_SUPPORTED -void PNGAPI -png_set_filter_heuristics(png_structrp png_ptr, int heuristic_method, - int num_weights, png_const_doublep filter_weights, - png_const_doublep filter_costs) -{ - PNG_UNUSED(png_ptr) - PNG_UNUSED(heuristic_method) - PNG_UNUSED(num_weights) - PNG_UNUSED(filter_weights) - PNG_UNUSED(filter_costs) -} -#endif /* FLOATING_POINT */ - -#ifdef PNG_FIXED_POINT_SUPPORTED -void PNGAPI -png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method, - int num_weights, png_const_fixed_point_p filter_weights, - png_const_fixed_point_p filter_costs) -{ - PNG_UNUSED(png_ptr) - PNG_UNUSED(heuristic_method) - PNG_UNUSED(num_weights) - PNG_UNUSED(filter_weights) - PNG_UNUSED(filter_costs) -} -#endif /* FIXED_POINT */ -#endif /* WRITE_WEIGHTED_FILTER */ - -#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED -void PNGAPI -png_set_compression_level(png_structrp png_ptr, int level) -{ - png_debug(1, "in png_set_compression_level"); - - if (png_ptr == NULL) - return; - - png_ptr->zlib_level = level; -} - -void PNGAPI -png_set_compression_mem_level(png_structrp png_ptr, int mem_level) -{ - png_debug(1, "in png_set_compression_mem_level"); - - if (png_ptr == NULL) - return; - - png_ptr->zlib_mem_level = mem_level; -} - -void PNGAPI -png_set_compression_strategy(png_structrp png_ptr, int strategy) -{ - png_debug(1, "in png_set_compression_strategy"); - - if (png_ptr == NULL) - return; - - /* The flag setting here prevents the libpng dynamic selection of strategy. - */ - png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY; - png_ptr->zlib_strategy = strategy; -} - -/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a - * smaller value of window_bits if it can do so safely. - */ -void PNGAPI -png_set_compression_window_bits(png_structrp png_ptr, int window_bits) -{ - if (png_ptr == NULL) - return; - - /* Prior to 1.6.0 this would warn but then set the window_bits value. This - * meant that negative window bits values could be selected that would cause - * libpng to write a non-standard PNG file with raw deflate or gzip - * compressed IDAT or ancillary chunks. Such files can be read and there is - * no warning on read, so this seems like a very bad idea. - */ - if (window_bits > 15) - { - png_warning(png_ptr, "Only compression windows <= 32k supported by PNG"); - window_bits = 15; - } - - else if (window_bits < 8) - { - png_warning(png_ptr, "Only compression windows >= 256 supported by PNG"); - window_bits = 8; - } - - png_ptr->zlib_window_bits = window_bits; -} - -void PNGAPI -png_set_compression_method(png_structrp png_ptr, int method) -{ - png_debug(1, "in png_set_compression_method"); - - if (png_ptr == NULL) - return; - - /* This would produce an invalid PNG file if it worked, but it doesn't and - * deflate will fault it, so it is harmless to just warn here. - */ - if (method != 8) - png_warning(png_ptr, "Only compression method 8 is supported by PNG"); - - png_ptr->zlib_method = method; -} -#endif /* WRITE_CUSTOMIZE_COMPRESSION */ - -/* The following were added to libpng-1.5.4 */ -#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED -void PNGAPI -png_set_text_compression_level(png_structrp png_ptr, int level) -{ - png_debug(1, "in png_set_text_compression_level"); - - if (png_ptr == NULL) - return; - - png_ptr->zlib_text_level = level; -} - -void PNGAPI -png_set_text_compression_mem_level(png_structrp png_ptr, int mem_level) -{ - png_debug(1, "in png_set_text_compression_mem_level"); - - if (png_ptr == NULL) - return; - - png_ptr->zlib_text_mem_level = mem_level; -} - -void PNGAPI -png_set_text_compression_strategy(png_structrp png_ptr, int strategy) -{ - png_debug(1, "in png_set_text_compression_strategy"); - - if (png_ptr == NULL) - return; - - png_ptr->zlib_text_strategy = strategy; -} - -/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a - * smaller value of window_bits if it can do so safely. - */ -void PNGAPI -png_set_text_compression_window_bits(png_structrp png_ptr, int window_bits) -{ - if (png_ptr == NULL) - return; - - if (window_bits > 15) - { - png_warning(png_ptr, "Only compression windows <= 32k supported by PNG"); - window_bits = 15; - } - - else if (window_bits < 8) - { - png_warning(png_ptr, "Only compression windows >= 256 supported by PNG"); - window_bits = 8; - } - - png_ptr->zlib_text_window_bits = window_bits; -} - -void PNGAPI -png_set_text_compression_method(png_structrp png_ptr, int method) -{ - png_debug(1, "in png_set_text_compression_method"); - - if (png_ptr == NULL) - return; - - if (method != 8) - png_warning(png_ptr, "Only compression method 8 is supported by PNG"); - - png_ptr->zlib_text_method = method; -} -#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */ -/* end of API added to libpng-1.5.4 */ - -void PNGAPI -png_set_write_status_fn(png_structrp png_ptr, png_write_status_ptr write_row_fn) -{ - if (png_ptr == NULL) - return; - - png_ptr->write_row_fn = write_row_fn; -} - -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED -void PNGAPI -png_set_write_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr - write_user_transform_fn) -{ - png_debug(1, "in png_set_write_user_transform_fn"); - - if (png_ptr == NULL) - return; - - png_ptr->transformations |= PNG_USER_TRANSFORM; - png_ptr->write_user_transform_fn = write_user_transform_fn; -} -#endif - - -#ifdef PNG_INFO_IMAGE_SUPPORTED -void PNGAPI -png_write_png(png_structrp png_ptr, png_inforp info_ptr, - int transforms, voidp params) -{ - if (png_ptr == NULL || info_ptr == NULL) - return; - - if ((info_ptr->valid & PNG_INFO_IDAT) == 0) - { - png_app_error(png_ptr, "no rows for png_write_image to write"); - return; - } - - /* Write the file header information. */ - png_write_info(png_ptr, info_ptr); - - /* ------ these transformations don't touch the info structure ------- */ - - /* Invert monochrome pixels */ - if ((transforms & PNG_TRANSFORM_INVERT_MONO) != 0) -#ifdef PNG_WRITE_INVERT_SUPPORTED - png_set_invert_mono(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_MONO not supported"); -#endif - - /* Shift the pixels up to a legal bit depth and fill in - * as appropriate to correctly scale the image. - */ - if ((transforms & PNG_TRANSFORM_SHIFT) != 0) -#ifdef PNG_WRITE_SHIFT_SUPPORTED - if ((info_ptr->valid & PNG_INFO_sBIT) != 0) - png_set_shift(png_ptr, &info_ptr->sig_bit); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_SHIFT not supported"); -#endif - - /* Pack pixels into bytes */ - if ((transforms & PNG_TRANSFORM_PACKING) != 0) -#ifdef PNG_WRITE_PACK_SUPPORTED - png_set_packing(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_PACKING not supported"); -#endif - - /* Swap location of alpha bytes from ARGB to RGBA */ - if ((transforms & PNG_TRANSFORM_SWAP_ALPHA) != 0) -#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED - png_set_swap_alpha(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ALPHA not supported"); -#endif - - /* Remove a filler (X) from XRGB/RGBX/AG/GA into to convert it into - * RGB, note that the code expects the input color type to be G or RGB; no - * alpha channel. - */ - if ((transforms & (PNG_TRANSFORM_STRIP_FILLER_AFTER| - PNG_TRANSFORM_STRIP_FILLER_BEFORE)) != 0) - { -#ifdef PNG_WRITE_FILLER_SUPPORTED - if ((transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER) != 0) - { - if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0) - png_app_error(png_ptr, - "PNG_TRANSFORM_STRIP_FILLER: BEFORE+AFTER not supported"); - - /* Continue if ignored - this is the pre-1.6.10 behavior */ - png_set_filler(png_ptr, 0, PNG_FILLER_AFTER); - } - - else if ((transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) != 0) - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_STRIP_FILLER not supported"); -#endif - } - - /* Flip BGR pixels to RGB */ - if ((transforms & PNG_TRANSFORM_BGR) != 0) -#ifdef PNG_WRITE_BGR_SUPPORTED - png_set_bgr(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_BGR not supported"); -#endif - - /* Swap bytes of 16-bit files to most significant byte first */ - if ((transforms & PNG_TRANSFORM_SWAP_ENDIAN) != 0) -#ifdef PNG_WRITE_SWAP_SUPPORTED - png_set_swap(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_SWAP_ENDIAN not supported"); -#endif - - /* Swap bits of 1-bit, 2-bit, 4-bit packed pixel formats */ - if ((transforms & PNG_TRANSFORM_PACKSWAP) != 0) -#ifdef PNG_WRITE_PACKSWAP_SUPPORTED - png_set_packswap(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_PACKSWAP not supported"); -#endif - - /* Invert the alpha channel from opacity to transparency */ - if ((transforms & PNG_TRANSFORM_INVERT_ALPHA) != 0) -#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED - png_set_invert_alpha(png_ptr); -#else - png_app_error(png_ptr, "PNG_TRANSFORM_INVERT_ALPHA not supported"); -#endif - - /* ----------------------- end of transformations ------------------- */ - - /* Write the bits */ - png_write_image(png_ptr, info_ptr->row_pointers); - - /* It is REQUIRED to call this to finish writing the rest of the file */ - png_write_end(png_ptr, info_ptr); - - PNG_UNUSED(params) -} -#endif - - -#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED -/* Initialize the write structure - general purpose utility. */ -static int -png_image_write_init(png_imagep image) -{ - png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, image, - png_safe_error, png_safe_warning); - - if (png_ptr != NULL) - { - png_infop info_ptr = png_create_info_struct(png_ptr); - - if (info_ptr != NULL) - { - png_controlp control = png_voidcast(png_controlp, - png_malloc_warn(png_ptr, (sizeof *control))); - - if (control != NULL) - { - memset(control, 0, (sizeof *control)); - - control->png_ptr = png_ptr; - control->info_ptr = info_ptr; - control->for_write = 1; - - image->opaque = control; - return 1; - } - - /* Error clean up */ - png_destroy_info_struct(png_ptr, &info_ptr); - } - - png_destroy_write_struct(&png_ptr, NULL); - } - - return png_image_error(image, "png_image_write_: out of memory"); -} - -/* Arguments to png_image_write_main: */ -typedef struct -{ - /* Arguments: */ - png_imagep image; - png_const_voidp buffer; - png_int_32 row_stride; - png_const_voidp colormap; - int convert_to_8bit; - /* Local variables: */ - png_const_voidp first_row; - ptrdiff_t row_bytes; - png_voidp local_row; - /* Byte count for memory writing */ - png_bytep memory; - png_alloc_size_t memory_bytes; /* not used for STDIO */ - png_alloc_size_t output_bytes; /* running total */ -} png_image_write_control; - -/* Write png_uint_16 input to a 16-bit PNG; the png_ptr has already been set to - * do any necessary byte swapping. The component order is defined by the - * png_image format value. - */ -static int -png_write_image_16bit(png_voidp argument) -{ - png_image_write_control *display = png_voidcast(png_image_write_control*, - argument); - png_imagep image = display->image; - png_structrp png_ptr = image->opaque->png_ptr; - - png_const_uint_16p input_row = png_voidcast(png_const_uint_16p, - display->first_row); - png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row); - png_uint_16p row_end; - unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? - 3 : 1; - int aindex = 0; - png_uint_32 y = image->height; - - if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0) - { -# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED - if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0) - { - aindex = -1; - ++input_row; /* To point to the first component */ - ++output_row; - } - else - aindex = (int)channels; -# else - aindex = (int)channels; -# endif - } - - else - png_error(png_ptr, "png_write_image: internal call error"); - - /* Work out the output row end and count over this, note that the increment - * above to 'row' means that row_end can actually be beyond the end of the - * row; this is correct. - */ - row_end = output_row + image->width * (channels+1); - - for (; y > 0; --y) - { - png_const_uint_16p in_ptr = input_row; - png_uint_16p out_ptr = output_row; - - while (out_ptr < row_end) - { - png_uint_16 alpha = in_ptr[aindex]; - png_uint_32 reciprocal = 0; - int c; - - out_ptr[aindex] = alpha; - - /* Calculate a reciprocal. The correct calculation is simply - * component/alpha*65535 << 15. (I.e. 15 bits of precision); this - * allows correct rounding by adding .5 before the shift. 'reciprocal' - * is only initialized when required. - */ - if (alpha > 0 && alpha < 65535) - reciprocal = ((0xffff<<15)+(alpha>>1))/alpha; - - c = (int)channels; - do /* always at least one channel */ - { - png_uint_16 component = *in_ptr++; - - /* The following gives 65535 for an alpha of 0, which is fine, - * otherwise if 0/0 is represented as some other value there is more - * likely to be a discontinuity which will probably damage - * compression when moving from a fully transparent area to a - * nearly transparent one. (The assumption here is that opaque - * areas tend not to be 0 intensity.) - */ - if (component >= alpha) - component = 65535; - - /* component 0 && alpha < 65535) - { - png_uint_32 calc = component * reciprocal; - calc += 16384; /* round to nearest */ - component = (png_uint_16)(calc >> 15); - } - - *out_ptr++ = component; - } - while (--c > 0); - - /* Skip to next component (skip the intervening alpha channel) */ - ++in_ptr; - ++out_ptr; - } - - png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row)); - input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16)); - } - - return 1; -} - -/* Given 16-bit input (1 to 4 channels) write 8-bit output. If an alpha channel - * is present it must be removed from the components, the components are then - * written in sRGB encoding. No components are added or removed. - * - * Calculate an alpha reciprocal to reverse pre-multiplication. As above the - * calculation can be done to 15 bits of accuracy; however, the output needs to - * be scaled in the range 0..255*65535, so include that scaling here. - */ -# define UNP_RECIPROCAL(alpha) ((((0xffff*0xff)<<7)+((alpha)>>1))/(alpha)) - -static png_byte -png_unpremultiply(png_uint_32 component, png_uint_32 alpha, - png_uint_32 reciprocal/*from the above macro*/) -{ - /* The following gives 1.0 for an alpha of 0, which is fine, otherwise if 0/0 - * is represented as some other value there is more likely to be a - * discontinuity which will probably damage compression when moving from a - * fully transparent area to a nearly transparent one. (The assumption here - * is that opaque areas tend not to be 0 intensity.) - * - * There is a rounding problem here; if alpha is less than 128 it will end up - * as 0 when scaled to 8 bits. To avoid introducing spurious colors into the - * output change for this too. - */ - if (component >= alpha || alpha < 128) - return 255; - - /* component 0) - { - /* The test is that alpha/257 (rounded) is less than 255, the first value - * that becomes 255 is 65407. - * NOTE: this must agree with the PNG_DIV257 macro (which must, therefore, - * be exact!) [Could also test reciprocal != 0] - */ - if (alpha < 65407) - { - component *= reciprocal; - component += 64; /* round to nearest */ - component >>= 7; - } - - else - component *= 255; - - /* Convert the component to sRGB. */ - return (png_byte)PNG_sRGB_FROM_LINEAR(component); - } - - else - return 0; -} - -static int -png_write_image_8bit(png_voidp argument) -{ - png_image_write_control *display = png_voidcast(png_image_write_control*, - argument); - png_imagep image = display->image; - png_structrp png_ptr = image->opaque->png_ptr; - - png_const_uint_16p input_row = png_voidcast(png_const_uint_16p, - display->first_row); - png_bytep output_row = png_voidcast(png_bytep, display->local_row); - png_uint_32 y = image->height; - unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? - 3 : 1; - - if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0) - { - png_bytep row_end; - int aindex; - -# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED - if ((image->format & PNG_FORMAT_FLAG_AFIRST) != 0) - { - aindex = -1; - ++input_row; /* To point to the first component */ - ++output_row; - } - - else -# endif - aindex = (int)channels; - - /* Use row_end in place of a loop counter: */ - row_end = output_row + image->width * (channels+1); - - for (; y > 0; --y) - { - png_const_uint_16p in_ptr = input_row; - png_bytep out_ptr = output_row; - - while (out_ptr < row_end) - { - png_uint_16 alpha = in_ptr[aindex]; - png_byte alphabyte = (png_byte)PNG_DIV257(alpha); - png_uint_32 reciprocal = 0; - int c; - - /* Scale and write the alpha channel. */ - out_ptr[aindex] = alphabyte; - - if (alphabyte > 0 && alphabyte < 255) - reciprocal = UNP_RECIPROCAL(alpha); - - c = (int)channels; - do /* always at least one channel */ - *out_ptr++ = png_unpremultiply(*in_ptr++, alpha, reciprocal); - while (--c > 0); - - /* Skip to next component (skip the intervening alpha channel) */ - ++in_ptr; - ++out_ptr; - } /* while out_ptr < row_end */ - - png_write_row(png_ptr, png_voidcast(png_const_bytep, - display->local_row)); - input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16)); - } /* while y */ - } - - else - { - /* No alpha channel, so the row_end really is the end of the row and it - * is sufficient to loop over the components one by one. - */ - png_bytep row_end = output_row + image->width * channels; - - for (; y > 0; --y) - { - png_const_uint_16p in_ptr = input_row; - png_bytep out_ptr = output_row; - - while (out_ptr < row_end) - { - png_uint_32 component = *in_ptr++; - - component *= 255; - *out_ptr++ = (png_byte)PNG_sRGB_FROM_LINEAR(component); - } - - png_write_row(png_ptr, output_row); - input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16)); - } - } - - return 1; -} - -static void -png_image_set_PLTE(png_image_write_control *display) -{ - png_imagep image = display->image; - const void *cmap = display->colormap; - int entries = image->colormap_entries > 256 ? 256 : - (int)image->colormap_entries; - - /* NOTE: the caller must check for cmap != NULL and entries != 0 */ - png_uint_32 format = image->format; - unsigned int channels = PNG_IMAGE_SAMPLE_CHANNELS(format); - -# if defined(PNG_FORMAT_BGR_SUPPORTED) &&\ - defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED) - int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 && - (format & PNG_FORMAT_FLAG_ALPHA) != 0; -# else -# define afirst 0 -# endif - -# ifdef PNG_FORMAT_BGR_SUPPORTED - int bgr = (format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0; -# else -# define bgr 0 -# endif - - int i, num_trans; - png_color palette[256]; - png_byte tRNS[256]; - - memset(tRNS, 255, (sizeof tRNS)); - memset(palette, 0, (sizeof palette)); - - for (i=num_trans=0; i= 3) /* RGB */ - { - palette[i].blue = (png_byte)PNG_sRGB_FROM_LINEAR(255 * - entry[(2 ^ bgr)]); - palette[i].green = (png_byte)PNG_sRGB_FROM_LINEAR(255 * - entry[1]); - palette[i].red = (png_byte)PNG_sRGB_FROM_LINEAR(255 * - entry[bgr]); - } - - else /* Gray */ - palette[i].blue = palette[i].red = palette[i].green = - (png_byte)PNG_sRGB_FROM_LINEAR(255 * *entry); - } - - else /* alpha */ - { - png_uint_16 alpha = entry[afirst ? 0 : channels-1]; - png_byte alphabyte = (png_byte)PNG_DIV257(alpha); - png_uint_32 reciprocal = 0; - - /* Calculate a reciprocal, as in the png_write_image_8bit code above - * this is designed to produce a value scaled to 255*65535 when - * divided by 128 (i.e. asr 7). - */ - if (alphabyte > 0 && alphabyte < 255) - reciprocal = (((0xffff*0xff)<<7)+(alpha>>1))/alpha; - - tRNS[i] = alphabyte; - if (alphabyte < 255) - num_trans = i+1; - - if (channels >= 3) /* RGB */ - { - palette[i].blue = png_unpremultiply(entry[afirst + (2 ^ bgr)], - alpha, reciprocal); - palette[i].green = png_unpremultiply(entry[afirst + 1], alpha, - reciprocal); - palette[i].red = png_unpremultiply(entry[afirst + bgr], alpha, - reciprocal); - } - - else /* gray */ - palette[i].blue = palette[i].red = palette[i].green = - png_unpremultiply(entry[afirst], alpha, reciprocal); - } - } - - else /* Color-map has sRGB values */ - { - png_const_bytep entry = png_voidcast(png_const_bytep, cmap); - - entry += (unsigned int)i * channels; - - switch (channels) - { - case 4: - tRNS[i] = entry[afirst ? 0 : 3]; - if (tRNS[i] < 255) - num_trans = i+1; - /* FALLTHROUGH */ - case 3: - palette[i].blue = entry[afirst + (2 ^ bgr)]; - palette[i].green = entry[afirst + 1]; - palette[i].red = entry[afirst + bgr]; - break; - - case 2: - tRNS[i] = entry[1 ^ afirst]; - if (tRNS[i] < 255) - num_trans = i+1; - /* FALLTHROUGH */ - case 1: - palette[i].blue = palette[i].red = palette[i].green = - entry[afirst]; - break; - - default: - break; - } - } - } - -# ifdef afirst -# undef afirst -# endif -# ifdef bgr -# undef bgr -# endif - - png_set_PLTE(image->opaque->png_ptr, image->opaque->info_ptr, palette, - entries); - - if (num_trans > 0) - png_set_tRNS(image->opaque->png_ptr, image->opaque->info_ptr, tRNS, - num_trans, NULL); - - image->colormap_entries = (png_uint_32)entries; -} - -static int -png_image_write_main(png_voidp argument) -{ - png_image_write_control *display = png_voidcast(png_image_write_control*, - argument); - png_imagep image = display->image; - png_structrp png_ptr = image->opaque->png_ptr; - png_inforp info_ptr = image->opaque->info_ptr; - png_uint_32 format = image->format; - - /* The following four ints are actually booleans */ - int colormap = (format & PNG_FORMAT_FLAG_COLORMAP); - int linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR); /* input */ - int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA); - int write_16bit = linear && (display->convert_to_8bit == 0); - -# ifdef PNG_BENIGN_ERRORS_SUPPORTED - /* Make sure we error out on any bad situation */ - png_set_benign_errors(png_ptr, 0/*error*/); -# endif - - /* Default the 'row_stride' parameter if required, also check the row stride - * and total image size to ensure that they are within the system limits. - */ - { - unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format); - - if (image->width <= 0x7fffffffU/channels) /* no overflow */ - { - png_uint_32 check; - png_uint_32 png_row_stride = image->width * channels; - - if (display->row_stride == 0) - display->row_stride = (png_int_32)/*SAFE*/png_row_stride; - - if (display->row_stride < 0) - check = (png_uint_32)(-display->row_stride); - - else - check = (png_uint_32)display->row_stride; - - if (check >= png_row_stride) - { - /* Now check for overflow of the image buffer calculation; this - * limits the whole image size to 32 bits for API compatibility with - * the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro. - */ - if (image->height > 0xffffffffU/png_row_stride) - png_error(image->opaque->png_ptr, "memory image too large"); - } - - else - png_error(image->opaque->png_ptr, "supplied row stride too small"); - } - - else - png_error(image->opaque->png_ptr, "image row stride too large"); - } - - /* Set the required transforms then write the rows in the correct order. */ - if ((format & PNG_FORMAT_FLAG_COLORMAP) != 0) - { - if (display->colormap != NULL && image->colormap_entries > 0) - { - png_uint_32 entries = image->colormap_entries; - - png_set_IHDR(png_ptr, info_ptr, image->width, image->height, - entries > 16 ? 8 : (entries > 4 ? 4 : (entries > 2 ? 2 : 1)), - PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - png_image_set_PLTE(display); - } - - else - png_error(image->opaque->png_ptr, - "no color-map for color-mapped image"); - } - - else - png_set_IHDR(png_ptr, info_ptr, image->width, image->height, - write_16bit ? 16 : 8, - ((format & PNG_FORMAT_FLAG_COLOR) ? PNG_COLOR_MASK_COLOR : 0) + - ((format & PNG_FORMAT_FLAG_ALPHA) ? PNG_COLOR_MASK_ALPHA : 0), - PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - /* Counter-intuitively the data transformations must be called *after* - * png_write_info, not before as in the read code, but the 'set' functions - * must still be called before. Just set the color space information, never - * write an interlaced image. - */ - - if (write_16bit != 0) - { - /* The gamma here is 1.0 (linear) and the cHRM chunk matches sRGB. */ - png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_LINEAR); - - if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0) - png_set_cHRM_fixed(png_ptr, info_ptr, - /* color x y */ - /* white */ 31270, 32900, - /* red */ 64000, 33000, - /* green */ 30000, 60000, - /* blue */ 15000, 6000 - ); - } - - else if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0) - png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_PERCEPTUAL); - - /* Else writing an 8-bit file and the *colors* aren't sRGB, but the 8-bit - * space must still be gamma encoded. - */ - else - png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_sRGB_INVERSE); - - /* Write the file header. */ - png_write_info(png_ptr, info_ptr); - - /* Now set up the data transformations (*after* the header is written), - * remove the handled transformations from the 'format' flags for checking. - * - * First check for a little endian system if writing 16-bit files. - */ - if (write_16bit != 0) - { - png_uint_16 le = 0x0001; - - if ((*(png_const_bytep) & le) != 0) - png_set_swap(png_ptr); - } - -# ifdef PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED - if ((format & PNG_FORMAT_FLAG_BGR) != 0) - { - if (colormap == 0 && (format & PNG_FORMAT_FLAG_COLOR) != 0) - png_set_bgr(png_ptr); - format &= ~PNG_FORMAT_FLAG_BGR; - } -# endif - -# ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED - if ((format & PNG_FORMAT_FLAG_AFIRST) != 0) - { - if (colormap == 0 && (format & PNG_FORMAT_FLAG_ALPHA) != 0) - png_set_swap_alpha(png_ptr); - format &= ~PNG_FORMAT_FLAG_AFIRST; - } -# endif - - /* If there are 16 or fewer color-map entries we wrote a lower bit depth - * above, but the application data is still byte packed. - */ - if (colormap != 0 && image->colormap_entries <= 16) - png_set_packing(png_ptr); - - /* That should have handled all (both) the transforms. */ - if ((format & ~(png_uint_32)(PNG_FORMAT_FLAG_COLOR | PNG_FORMAT_FLAG_LINEAR | - PNG_FORMAT_FLAG_ALPHA | PNG_FORMAT_FLAG_COLORMAP)) != 0) - png_error(png_ptr, "png_write_image: unsupported transformation"); - - { - png_const_bytep row = png_voidcast(png_const_bytep, display->buffer); - ptrdiff_t row_bytes = display->row_stride; - - if (linear != 0) - row_bytes *= (sizeof (png_uint_16)); - - if (row_bytes < 0) - row += (image->height-1) * (-row_bytes); - - display->first_row = row; - display->row_bytes = row_bytes; - } - - /* Apply 'fast' options if the flag is set. */ - if ((image->flags & PNG_IMAGE_FLAG_FAST) != 0) - { - png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, PNG_NO_FILTERS); - /* NOTE: determined by experiment using pngstest, this reflects some - * balance between the time to write the image once and the time to read - * it about 50 times. The speed-up in pngstest was about 10-20% of the - * total (user) time on a heavily loaded system. - */ -# ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED - png_set_compression_level(png_ptr, 3); -# endif - } - - /* Check for the cases that currently require a pre-transform on the row - * before it is written. This only applies when the input is 16-bit and - * either there is an alpha channel or it is converted to 8-bit. - */ - if ((linear != 0 && alpha != 0 ) || - (colormap == 0 && display->convert_to_8bit != 0)) - { - png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr, - png_get_rowbytes(png_ptr, info_ptr))); - int result; - - display->local_row = row; - if (write_16bit != 0) - result = png_safe_execute(image, png_write_image_16bit, display); - else - result = png_safe_execute(image, png_write_image_8bit, display); - display->local_row = NULL; - - png_free(png_ptr, row); - - /* Skip the 'write_end' on error: */ - if (result == 0) - return 0; - } - - /* Otherwise this is the case where the input is in a format currently - * supported by the rest of the libpng write code; call it directly. - */ - else - { - png_const_bytep row = png_voidcast(png_const_bytep, display->first_row); - ptrdiff_t row_bytes = display->row_bytes; - png_uint_32 y = image->height; - - for (; y > 0; --y) - { - png_write_row(png_ptr, row); - row += row_bytes; - } - } - - png_write_end(png_ptr, info_ptr); - return 1; -} - - -static void (PNGCBAPI -image_memory_write)(png_structp png_ptr, png_bytep/*const*/ data, size_t size) -{ - png_image_write_control *display = png_voidcast(png_image_write_control*, - png_ptr->io_ptr/*backdoor: png_get_io_ptr(png_ptr)*/); - png_alloc_size_t ob = display->output_bytes; - - /* Check for overflow; this should never happen: */ - if (size <= ((png_alloc_size_t)-1) - ob) - { - /* I don't think libpng ever does this, but just in case: */ - if (size > 0) - { - if (display->memory_bytes >= ob+size) /* writing */ - memcpy(display->memory+ob, data, size); - - /* Always update the size: */ - display->output_bytes = ob+size; - } - } - - else - png_error(png_ptr, "png_image_write_to_memory: PNG too big"); -} - -static void (PNGCBAPI -image_memory_flush)(png_structp png_ptr) -{ - PNG_UNUSED(png_ptr) -} - -static int -png_image_write_memory(png_voidp argument) -{ - png_image_write_control *display = png_voidcast(png_image_write_control*, - argument); - - /* The rest of the memory-specific init and write_main in an error protected - * environment. This case needs to use callbacks for the write operations - * since libpng has no built in support for writing to memory. - */ - png_set_write_fn(display->image->opaque->png_ptr, display/*io_ptr*/, - image_memory_write, image_memory_flush); - - return png_image_write_main(display); -} - -int PNGAPI -png_image_write_to_memory(png_imagep image, void *memory, - png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8bit, - const void *buffer, png_int_32 row_stride, const void *colormap) -{ - /* Write the image to the given buffer, or count the bytes if it is NULL */ - if (image != NULL && image->version == PNG_IMAGE_VERSION) - { - if (memory_bytes != NULL && buffer != NULL) - { - /* This is to give the caller an easier error detection in the NULL - * case and guard against uninitialized variable problems: - */ - if (memory == NULL) - *memory_bytes = 0; - - if (png_image_write_init(image) != 0) - { - png_image_write_control display; - int result; - - memset(&display, 0, (sizeof display)); - display.image = image; - display.buffer = buffer; - display.row_stride = row_stride; - display.colormap = colormap; - display.convert_to_8bit = convert_to_8bit; - display.memory = png_voidcast(png_bytep, memory); - display.memory_bytes = *memory_bytes; - display.output_bytes = 0; - - result = png_safe_execute(image, png_image_write_memory, &display); - png_image_free(image); - - /* write_memory returns true even if we ran out of buffer. */ - if (result) - { - /* On out-of-buffer this function returns '0' but still updates - * memory_bytes: - */ - if (memory != NULL && display.output_bytes > *memory_bytes) - result = 0; - - *memory_bytes = display.output_bytes; - } - - return result; - } - - else - return 0; - } - - else - return png_image_error(image, - "png_image_write_to_memory: invalid argument"); - } - - else if (image != NULL) - return png_image_error(image, - "png_image_write_to_memory: incorrect PNG_IMAGE_VERSION"); - - else - return 0; -} - -#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED -int PNGAPI -png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit, - const void *buffer, png_int_32 row_stride, const void *colormap) -{ - /* Write the image to the given (FILE*). */ - if (image != NULL && image->version == PNG_IMAGE_VERSION) - { - if (file != NULL && buffer != NULL) - { - if (png_image_write_init(image) != 0) - { - png_image_write_control display; - int result; - - /* This is slightly evil, but png_init_io doesn't do anything other - * than this and we haven't changed the standard IO functions so - * this saves a 'safe' function. - */ - image->opaque->png_ptr->io_ptr = file; - - memset(&display, 0, (sizeof display)); - display.image = image; - display.buffer = buffer; - display.row_stride = row_stride; - display.colormap = colormap; - display.convert_to_8bit = convert_to_8bit; - - result = png_safe_execute(image, png_image_write_main, &display); - png_image_free(image); - return result; - } - - else - return 0; - } - - else - return png_image_error(image, - "png_image_write_to_stdio: invalid argument"); - } - - else if (image != NULL) - return png_image_error(image, - "png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION"); - - else - return 0; -} - -int PNGAPI -png_image_write_to_file(png_imagep image, const char *file_name, - int convert_to_8bit, const void *buffer, png_int_32 row_stride, - const void *colormap) -{ - /* Write the image to the named file. */ - if (image != NULL && image->version == PNG_IMAGE_VERSION) - { - if (file_name != NULL && buffer != NULL) - { - FILE *fp = fopen(file_name, "wb"); - - if (fp != NULL) - { - if (png_image_write_to_stdio(image, fp, convert_to_8bit, buffer, - row_stride, colormap) != 0) - { - int error; /* from fflush/fclose */ - - /* Make sure the file is flushed correctly. */ - if (fflush(fp) == 0 && ferror(fp) == 0) - { - if (fclose(fp) == 0) - return 1; - - error = errno; /* from fclose */ - } - - else - { - error = errno; /* from fflush or ferror */ - (void)fclose(fp); - } - - (void)remove(file_name); - /* The image has already been cleaned up; this is just used to - * set the error (because the original write succeeded). - */ - return png_image_error(image, strerror(error)); - } - - else - { - /* Clean up: just the opened file. */ - (void)fclose(fp); - (void)remove(file_name); - return 0; - } - } - - else - return png_image_error(image, strerror(errno)); - } - - else - return png_image_error(image, - "png_image_write_to_file: invalid argument"); - } - - else if (image != NULL) - return png_image_error(image, - "png_image_write_to_file: incorrect PNG_IMAGE_VERSION"); - - else - return 0; -} -#endif /* SIMPLIFIED_WRITE_STDIO */ -#endif /* SIMPLIFIED_WRITE */ -#endif /* WRITE */ diff --git a/oversampling/WDL/libpng/pngwtran.c b/oversampling/WDL/libpng/pngwtran.c deleted file mode 100644 index 49a13c1..0000000 --- a/oversampling/WDL/libpng/pngwtran.c +++ /dev/null @@ -1,575 +0,0 @@ - -/* pngwtran.c - transforms the data in a row for PNG writers - * - * Copyright (c) 2018 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - */ - -#include "pngpriv.h" - -#ifdef PNG_WRITE_SUPPORTED -#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED - -#ifdef PNG_WRITE_PACK_SUPPORTED -/* Pack pixels into bytes. Pass the true bit depth in bit_depth. The - * row_info bit depth should be 8 (one pixel per byte). The channels - * should be 1 (this only happens on grayscale and paletted images). - */ -static void -png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) -{ - png_debug(1, "in png_do_pack"); - - if (row_info->bit_depth == 8 && - row_info->channels == 1) - { - switch ((int)bit_depth) - { - case 1: - { - png_bytep sp, dp; - int mask, v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - mask = 0x80; - v = 0; - - for (i = 0; i < row_width; i++) - { - if (*sp != 0) - v |= mask; - - sp++; - - if (mask > 1) - mask >>= 1; - - else - { - mask = 0x80; - *dp = (png_byte)v; - dp++; - v = 0; - } - } - - if (mask != 0x80) - *dp = (png_byte)v; - - break; - } - - case 2: - { - png_bytep sp, dp; - unsigned int shift; - int v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - shift = 6; - v = 0; - - for (i = 0; i < row_width; i++) - { - png_byte value; - - value = (png_byte)(*sp & 0x03); - v |= (value << shift); - - if (shift == 0) - { - shift = 6; - *dp = (png_byte)v; - dp++; - v = 0; - } - - else - shift -= 2; - - sp++; - } - - if (shift != 6) - *dp = (png_byte)v; - - break; - } - - case 4: - { - png_bytep sp, dp; - unsigned int shift; - int v; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - sp = row; - dp = row; - shift = 4; - v = 0; - - for (i = 0; i < row_width; i++) - { - png_byte value; - - value = (png_byte)(*sp & 0x0f); - v |= (value << shift); - - if (shift == 0) - { - shift = 4; - *dp = (png_byte)v; - dp++; - v = 0; - } - - else - shift -= 4; - - sp++; - } - - if (shift != 4) - *dp = (png_byte)v; - - break; - } - - default: - break; - } - - row_info->bit_depth = (png_byte)bit_depth; - row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_info->width); - } -} -#endif - -#ifdef PNG_WRITE_SHIFT_SUPPORTED -/* Shift pixel values to take advantage of whole range. Pass the - * true number of bits in bit_depth. The row should be packed - * according to row_info->bit_depth. Thus, if you had a row of - * bit depth 4, but the pixels only had values from 0 to 7, you - * would pass 3 as bit_depth, and this routine would translate the - * data to 0 to 15. - */ -static void -png_do_shift(png_row_infop row_info, png_bytep row, - png_const_color_8p bit_depth) -{ - png_debug(1, "in png_do_shift"); - - if (row_info->color_type != PNG_COLOR_TYPE_PALETTE) - { - int shift_start[4], shift_dec[4]; - unsigned int channels = 0; - - if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0) - { - shift_start[channels] = row_info->bit_depth - bit_depth->red; - shift_dec[channels] = bit_depth->red; - channels++; - - shift_start[channels] = row_info->bit_depth - bit_depth->green; - shift_dec[channels] = bit_depth->green; - channels++; - - shift_start[channels] = row_info->bit_depth - bit_depth->blue; - shift_dec[channels] = bit_depth->blue; - channels++; - } - - else - { - shift_start[channels] = row_info->bit_depth - bit_depth->gray; - shift_dec[channels] = bit_depth->gray; - channels++; - } - - if ((row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0) - { - shift_start[channels] = row_info->bit_depth - bit_depth->alpha; - shift_dec[channels] = bit_depth->alpha; - channels++; - } - - /* With low row depths, could only be grayscale, so one channel */ - if (row_info->bit_depth < 8) - { - png_bytep bp = row; - size_t i; - unsigned int mask; - size_t row_bytes = row_info->rowbytes; - - if (bit_depth->gray == 1 && row_info->bit_depth == 2) - mask = 0x55; - - else if (row_info->bit_depth == 4 && bit_depth->gray == 3) - mask = 0x11; - - else - mask = 0xff; - - for (i = 0; i < row_bytes; i++, bp++) - { - int j; - unsigned int v, out; - - v = *bp; - out = 0; - - for (j = shift_start[0]; j > -shift_dec[0]; j -= shift_dec[0]) - { - if (j > 0) - out |= v << j; - - else - out |= (v >> (-j)) & mask; - } - - *bp = (png_byte)(out & 0xff); - } - } - - else if (row_info->bit_depth == 8) - { - png_bytep bp = row; - png_uint_32 i; - png_uint_32 istop = channels * row_info->width; - - for (i = 0; i < istop; i++, bp++) - { - unsigned int c = i%channels; - int j; - unsigned int v, out; - - v = *bp; - out = 0; - - for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) - { - if (j > 0) - out |= v << j; - - else - out |= v >> (-j); - } - - *bp = (png_byte)(out & 0xff); - } - } - - else - { - png_bytep bp; - png_uint_32 i; - png_uint_32 istop = channels * row_info->width; - - for (bp = row, i = 0; i < istop; i++) - { - unsigned int c = i%channels; - int j; - unsigned int value, v; - - v = png_get_uint_16(bp); - value = 0; - - for (j = shift_start[c]; j > -shift_dec[c]; j -= shift_dec[c]) - { - if (j > 0) - value |= v << j; - - else - value |= v >> (-j); - } - *bp++ = (png_byte)((value >> 8) & 0xff); - *bp++ = (png_byte)(value & 0xff); - } - } - } -} -#endif - -#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED -static void -png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_swap_alpha"); - - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - if (row_info->bit_depth == 8) - { - /* This converts from ARGB to RGBA */ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save; - } - } - -#ifdef PNG_WRITE_16BIT_SUPPORTED - else - { - /* This converts from AARRGGBB to RRGGBBAA */ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save[2]; - save[0] = *(sp++); - save[1] = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save[0]; - *(dp++) = save[1]; - } - } -#endif /* WRITE_16BIT */ - } - - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - if (row_info->bit_depth == 8) - { - /* This converts from AG to GA */ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save; - } - } - -#ifdef PNG_WRITE_16BIT_SUPPORTED - else - { - /* This converts from AAGG to GGAA */ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - png_byte save[2]; - save[0] = *(sp++); - save[1] = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = save[0]; - *(dp++) = save[1]; - } - } -#endif /* WRITE_16BIT */ - } - } -} -#endif - -#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED -static void -png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) -{ - png_debug(1, "in png_do_write_invert_alpha"); - - { - if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - { - if (row_info->bit_depth == 8) - { - /* This inverts the alpha channel in RGBA */ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - /* Does nothing - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - */ - sp+=3; dp = sp; - *dp = (png_byte)(255 - *(sp++)); - } - } - -#ifdef PNG_WRITE_16BIT_SUPPORTED - else - { - /* This inverts the alpha channel in RRGGBBAA */ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - /* Does nothing - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - *(dp++) = *(sp++); - */ - sp+=6; dp = sp; - *(dp++) = (png_byte)(255 - *(sp++)); - *dp = (png_byte)(255 - *(sp++)); - } - } -#endif /* WRITE_16BIT */ - } - - else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - { - if (row_info->bit_depth == 8) - { - /* This inverts the alpha channel in GA */ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - *(dp++) = *(sp++); - *(dp++) = (png_byte)(255 - *(sp++)); - } - } - -#ifdef PNG_WRITE_16BIT_SUPPORTED - else - { - /* This inverts the alpha channel in GGAA */ - png_bytep sp, dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - for (i = 0, sp = dp = row; i < row_width; i++) - { - /* Does nothing - *(dp++) = *(sp++); - *(dp++) = *(sp++); - */ - sp+=2; dp = sp; - *(dp++) = (png_byte)(255 - *(sp++)); - *dp = (png_byte)(255 - *(sp++)); - } - } -#endif /* WRITE_16BIT */ - } - } -} -#endif - -/* Transform the data according to the user's wishes. The order of - * transformations is significant. - */ -void /* PRIVATE */ -png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info) -{ - png_debug(1, "in png_do_write_transformations"); - - if (png_ptr == NULL) - return; - -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED - if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0) - if (png_ptr->write_user_transform_fn != NULL) - (*(png_ptr->write_user_transform_fn)) /* User write transform - function */ - (png_ptr, /* png_ptr */ - row_info, /* row_info: */ - /* png_uint_32 width; width of row */ - /* size_t rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ -#endif - -#ifdef PNG_WRITE_FILLER_SUPPORTED - if ((png_ptr->transformations & PNG_FILLER) != 0) - png_do_strip_channel(row_info, png_ptr->row_buf + 1, - !(png_ptr->flags & PNG_FLAG_FILLER_AFTER)); -#endif - -#ifdef PNG_WRITE_PACKSWAP_SUPPORTED - if ((png_ptr->transformations & PNG_PACKSWAP) != 0) - png_do_packswap(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_WRITE_PACK_SUPPORTED - if ((png_ptr->transformations & PNG_PACK) != 0) - png_do_pack(row_info, png_ptr->row_buf + 1, - (png_uint_32)png_ptr->bit_depth); -#endif - -#ifdef PNG_WRITE_SWAP_SUPPORTED -# ifdef PNG_16BIT_SUPPORTED - if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0) - png_do_swap(row_info, png_ptr->row_buf + 1); -# endif -#endif - -#ifdef PNG_WRITE_SHIFT_SUPPORTED - if ((png_ptr->transformations & PNG_SHIFT) != 0) - png_do_shift(row_info, png_ptr->row_buf + 1, - &(png_ptr->shift)); -#endif - -#ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED - if ((png_ptr->transformations & PNG_SWAP_ALPHA) != 0) - png_do_write_swap_alpha(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_WRITE_INVERT_ALPHA_SUPPORTED - if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0) - png_do_write_invert_alpha(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_WRITE_BGR_SUPPORTED - if ((png_ptr->transformations & PNG_BGR) != 0) - png_do_bgr(row_info, png_ptr->row_buf + 1); -#endif - -#ifdef PNG_WRITE_INVERT_SUPPORTED - if ((png_ptr->transformations & PNG_INVERT_MONO) != 0) - png_do_invert(row_info, png_ptr->row_buf + 1); -#endif -} -#endif /* WRITE_TRANSFORMS */ -#endif /* WRITE */ diff --git a/oversampling/WDL/libpng/pngwutil.c b/oversampling/WDL/libpng/pngwutil.c deleted file mode 100644 index 16345e4..0000000 --- a/oversampling/WDL/libpng/pngwutil.c +++ /dev/null @@ -1,2781 +0,0 @@ - -/* pngwutil.c - utilities to write a PNG file - * - * Copyright (c) 2018 Cosmin Truta - * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson - * Copyright (c) 1996-1997 Andreas Dilger - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - */ - -#include "pngpriv.h" - -#ifdef PNG_WRITE_SUPPORTED - -#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED -/* Place a 32-bit number into a buffer in PNG byte order. We work - * with unsigned numbers for convenience, although one supported - * ancillary chunk uses signed (two's complement) numbers. - */ -void PNGAPI -png_save_uint_32(png_bytep buf, png_uint_32 i) -{ - buf[0] = (png_byte)((i >> 24) & 0xffU); - buf[1] = (png_byte)((i >> 16) & 0xffU); - buf[2] = (png_byte)((i >> 8) & 0xffU); - buf[3] = (png_byte)( i & 0xffU); -} - -/* Place a 16-bit number into a buffer in PNG byte order. - * The parameter is declared unsigned int, not png_uint_16, - * just to avoid potential problems on pre-ANSI C compilers. - */ -void PNGAPI -png_save_uint_16(png_bytep buf, unsigned int i) -{ - buf[0] = (png_byte)((i >> 8) & 0xffU); - buf[1] = (png_byte)( i & 0xffU); -} -#endif - -/* Simple function to write the signature. If we have already written - * the magic bytes of the signature, or more likely, the PNG stream is - * being embedded into another stream and doesn't need its own signature, - * we should call png_set_sig_bytes() to tell libpng how many of the - * bytes have already been written. - */ -void PNGAPI -png_write_sig(png_structrp png_ptr) -{ - png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - -#ifdef PNG_IO_STATE_SUPPORTED - /* Inform the I/O callback that the signature is being written */ - png_ptr->io_state = PNG_IO_WRITING | PNG_IO_SIGNATURE; -#endif - - /* Write the rest of the 8 byte signature */ - png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], - (size_t)(8 - png_ptr->sig_bytes)); - - if (png_ptr->sig_bytes < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; -} - -/* Write the start of a PNG chunk. The type is the chunk type. - * The total_length is the sum of the lengths of all the data you will be - * passing in png_write_chunk_data(). - */ -static void -png_write_chunk_header(png_structrp png_ptr, png_uint_32 chunk_name, - png_uint_32 length) -{ - png_byte buf[8]; - -#if defined(PNG_DEBUG) && (PNG_DEBUG > 0) - PNG_CSTRING_FROM_CHUNK(buf, chunk_name); - png_debug2(0, "Writing %s chunk, length = %lu", buf, (unsigned long)length); -#endif - - if (png_ptr == NULL) - return; - -#ifdef PNG_IO_STATE_SUPPORTED - /* Inform the I/O callback that the chunk header is being written. - * PNG_IO_CHUNK_HDR requires a single I/O call. - */ - png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_HDR; -#endif - - /* Write the length and the chunk name */ - png_save_uint_32(buf, length); - png_save_uint_32(buf + 4, chunk_name); - png_write_data(png_ptr, buf, 8); - - /* Put the chunk name into png_ptr->chunk_name */ - png_ptr->chunk_name = chunk_name; - - /* Reset the crc and run it over the chunk name */ - png_reset_crc(png_ptr); - - png_calculate_crc(png_ptr, buf + 4, 4); - -#ifdef PNG_IO_STATE_SUPPORTED - /* Inform the I/O callback that chunk data will (possibly) be written. - * PNG_IO_CHUNK_DATA does NOT require a specific number of I/O calls. - */ - png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_DATA; -#endif -} - -void PNGAPI -png_write_chunk_start(png_structrp png_ptr, png_const_bytep chunk_string, - png_uint_32 length) -{ - png_write_chunk_header(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), length); -} - -/* Write the data of a PNG chunk started with png_write_chunk_header(). - * Note that multiple calls to this function are allowed, and that the - * sum of the lengths from these calls *must* add up to the total_length - * given to png_write_chunk_header(). - */ -void PNGAPI -png_write_chunk_data(png_structrp png_ptr, png_const_bytep data, size_t length) -{ - /* Write the data, and run the CRC over it */ - if (png_ptr == NULL) - return; - - if (data != NULL && length > 0) - { - png_write_data(png_ptr, data, length); - - /* Update the CRC after writing the data, - * in case the user I/O routine alters it. - */ - png_calculate_crc(png_ptr, data, length); - } -} - -/* Finish a chunk started with png_write_chunk_header(). */ -void PNGAPI -png_write_chunk_end(png_structrp png_ptr) -{ - png_byte buf[4]; - - if (png_ptr == NULL) return; - -#ifdef PNG_IO_STATE_SUPPORTED - /* Inform the I/O callback that the chunk CRC is being written. - * PNG_IO_CHUNK_CRC requires a single I/O function call. - */ - png_ptr->io_state = PNG_IO_WRITING | PNG_IO_CHUNK_CRC; -#endif - - /* Write the crc in a single operation */ - png_save_uint_32(buf, png_ptr->crc); - - png_write_data(png_ptr, buf, 4); -} - -/* Write a PNG chunk all at once. The type is an array of ASCII characters - * representing the chunk name. The array must be at least 4 bytes in - * length, and does not need to be null terminated. To be safe, pass the - * pre-defined chunk names here, and if you need a new one, define it - * where the others are defined. The length is the length of the data. - * All the data must be present. If that is not possible, use the - * png_write_chunk_start(), png_write_chunk_data(), and png_write_chunk_end() - * functions instead. - */ -static void -png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name, - png_const_bytep data, size_t length) -{ - if (png_ptr == NULL) - return; - - /* On 64-bit architectures 'length' may not fit in a png_uint_32. */ - if (length > PNG_UINT_31_MAX) - png_error(png_ptr, "length exceeds PNG maximum"); - - png_write_chunk_header(png_ptr, chunk_name, (png_uint_32)length); - png_write_chunk_data(png_ptr, data, length); - png_write_chunk_end(png_ptr); -} - -/* This is the API that calls the internal function above. */ -void PNGAPI -png_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string, - png_const_bytep data, size_t length) -{ - png_write_complete_chunk(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), data, - length); -} - -/* This is used below to find the size of an image to pass to png_deflate_claim, - * so it only needs to be accurate if the size is less than 16384 bytes (the - * point at which a lower LZ window size can be used.) - */ -static png_alloc_size_t -png_image_size(png_structrp png_ptr) -{ - /* Only return sizes up to the maximum of a png_uint_32; do this by limiting - * the width and height used to 15 bits. - */ - png_uint_32 h = png_ptr->height; - - if (png_ptr->rowbytes < 32768 && h < 32768) - { - if (png_ptr->interlaced != 0) - { - /* Interlacing makes the image larger because of the replication of - * both the filter byte and the padding to a byte boundary. - */ - png_uint_32 w = png_ptr->width; - unsigned int pd = png_ptr->pixel_depth; - png_alloc_size_t cb_base; - int pass; - - for (cb_base=0, pass=0; pass<=6; ++pass) - { - png_uint_32 pw = PNG_PASS_COLS(w, pass); - - if (pw > 0) - cb_base += (PNG_ROWBYTES(pd, pw)+1) * PNG_PASS_ROWS(h, pass); - } - - return cb_base; - } - - else - return (png_ptr->rowbytes+1) * h; - } - - else - return 0xffffffffU; -} - -#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED - /* This is the code to hack the first two bytes of the deflate stream (the - * deflate header) to correct the windowBits value to match the actual data - * size. Note that the second argument is the *uncompressed* size but the - * first argument is the *compressed* data (and it must be deflate - * compressed.) - */ -static void -optimize_cmf(png_bytep data, png_alloc_size_t data_size) -{ - /* Optimize the CMF field in the zlib stream. The resultant zlib stream is - * still compliant to the stream specification. - */ - if (data_size <= 16384) /* else windowBits must be 15 */ - { - unsigned int z_cmf = data[0]; /* zlib compression method and flags */ - - if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70) - { - unsigned int z_cinfo; - unsigned int half_z_window_size; - - z_cinfo = z_cmf >> 4; - half_z_window_size = 1U << (z_cinfo + 7); - - if (data_size <= half_z_window_size) /* else no change */ - { - unsigned int tmp; - - do - { - half_z_window_size >>= 1; - --z_cinfo; - } - while (z_cinfo > 0 && data_size <= half_z_window_size); - - z_cmf = (z_cmf & 0x0f) | (z_cinfo << 4); - - data[0] = (png_byte)z_cmf; - tmp = data[1] & 0xe0; - tmp += 0x1f - ((z_cmf << 8) + tmp) % 0x1f; - data[1] = (png_byte)tmp; - } - } - } -} -#endif /* WRITE_OPTIMIZE_CMF */ - -/* Initialize the compressor for the appropriate type of compression. */ -static int -png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, - png_alloc_size_t data_size) -{ - if (png_ptr->zowner != 0) - { -#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED) - char msg[64]; - - PNG_STRING_FROM_CHUNK(msg, owner); - msg[4] = ':'; - msg[5] = ' '; - PNG_STRING_FROM_CHUNK(msg+6, png_ptr->zowner); - /* So the message that results is " using zstream"; this is an - * internal error, but is very useful for debugging. i18n requirements - * are minimal. - */ - (void)png_safecat(msg, (sizeof msg), 10, " using zstream"); -#endif -#if PNG_RELEASE_BUILD - png_warning(png_ptr, msg); - - /* Attempt sane error recovery */ - if (png_ptr->zowner == png_IDAT) /* don't steal from IDAT */ - { - png_ptr->zstream.msg = PNGZ_MSG_CAST("in use by IDAT"); - return Z_STREAM_ERROR; - } - - png_ptr->zowner = 0; -#else - png_error(png_ptr, msg); -#endif - } - - { - int level = png_ptr->zlib_level; - int method = png_ptr->zlib_method; - int windowBits = png_ptr->zlib_window_bits; - int memLevel = png_ptr->zlib_mem_level; - int strategy; /* set below */ - int ret; /* zlib return code */ - - if (owner == png_IDAT) - { - if ((png_ptr->flags & PNG_FLAG_ZLIB_CUSTOM_STRATEGY) != 0) - strategy = png_ptr->zlib_strategy; - - else if (png_ptr->do_filter != PNG_FILTER_NONE) - strategy = PNG_Z_DEFAULT_STRATEGY; - - else - strategy = PNG_Z_DEFAULT_NOFILTER_STRATEGY; - } - - else - { -#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED - level = png_ptr->zlib_text_level; - method = png_ptr->zlib_text_method; - windowBits = png_ptr->zlib_text_window_bits; - memLevel = png_ptr->zlib_text_mem_level; - strategy = png_ptr->zlib_text_strategy; -#else - /* If customization is not supported the values all come from the - * IDAT values except for the strategy, which is fixed to the - * default. (This is the pre-1.6.0 behavior too, although it was - * implemented in a very different way.) - */ - strategy = Z_DEFAULT_STRATEGY; -#endif - } - - /* Adjust 'windowBits' down if larger than 'data_size'; to stop this - * happening just pass 32768 as the data_size parameter. Notice that zlib - * requires an extra 262 bytes in the window in addition to the data to be - * able to see the whole of the data, so if data_size+262 takes us to the - * next windowBits size we need to fix up the value later. (Because even - * though deflate needs the extra window, inflate does not!) - */ - if (data_size <= 16384) - { - /* IMPLEMENTATION NOTE: this 'half_window_size' stuff is only here to - * work round a Microsoft Visual C misbehavior which, contrary to C-90, - * widens the result of the following shift to 64-bits if (and, - * apparently, only if) it is used in a test. - */ - unsigned int half_window_size = 1U << (windowBits-1); - - while (data_size + 262 <= half_window_size) - { - half_window_size >>= 1; - --windowBits; - } - } - - /* Check against the previous initialized values, if any. */ - if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0 && - (png_ptr->zlib_set_level != level || - png_ptr->zlib_set_method != method || - png_ptr->zlib_set_window_bits != windowBits || - png_ptr->zlib_set_mem_level != memLevel || - png_ptr->zlib_set_strategy != strategy)) - { - if (deflateEnd(&png_ptr->zstream) != Z_OK) - png_warning(png_ptr, "deflateEnd failed (ignored)"); - - png_ptr->flags &= ~PNG_FLAG_ZSTREAM_INITIALIZED; - } - - /* For safety clear out the input and output pointers (currently zlib - * doesn't use them on Init, but it might in the future). - */ - png_ptr->zstream.next_in = NULL; - png_ptr->zstream.avail_in = 0; - png_ptr->zstream.next_out = NULL; - png_ptr->zstream.avail_out = 0; - - /* Now initialize if required, setting the new parameters, otherwise just - * do a simple reset to the previous parameters. - */ - if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0) - ret = deflateReset(&png_ptr->zstream); - - else - { - ret = deflateInit2(&png_ptr->zstream, level, method, windowBits, - memLevel, strategy); - - if (ret == Z_OK) - png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED; - } - - /* The return code is from either deflateReset or deflateInit2; they have - * pretty much the same set of error codes. - */ - if (ret == Z_OK) - png_ptr->zowner = owner; - - else - png_zstream_error(png_ptr, ret); - - return ret; - } -} - -/* Clean up (or trim) a linked list of compression buffers. */ -void /* PRIVATE */ -png_free_buffer_list(png_structrp png_ptr, png_compression_bufferp *listp) -{ - png_compression_bufferp list = *listp; - - if (list != NULL) - { - *listp = NULL; - - do - { - png_compression_bufferp next = list->next; - - png_free(png_ptr, list); - list = next; - } - while (list != NULL); - } -} - -#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED -/* This pair of functions encapsulates the operation of (a) compressing a - * text string, and (b) issuing it later as a series of chunk data writes. - * The compression_state structure is shared context for these functions - * set up by the caller to allow access to the relevant local variables. - * - * compression_buffer (new in 1.6.0) is just a linked list of zbuffer_size - * temporary buffers. From 1.6.0 it is retained in png_struct so that it will - * be correctly freed in the event of a write error (previous implementations - * just leaked memory.) - */ -typedef struct -{ - png_const_bytep input; /* The uncompressed input data */ - png_alloc_size_t input_len; /* Its length */ - png_uint_32 output_len; /* Final compressed length */ - png_byte output[1024]; /* First block of output */ -} compression_state; - -static void -png_text_compress_init(compression_state *comp, png_const_bytep input, - png_alloc_size_t input_len) -{ - comp->input = input; - comp->input_len = input_len; - comp->output_len = 0; -} - -/* Compress the data in the compression state input */ -static int -png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name, - compression_state *comp, png_uint_32 prefix_len) -{ - int ret; - - /* To find the length of the output it is necessary to first compress the - * input. The result is buffered rather than using the two-pass algorithm - * that is used on the inflate side; deflate is assumed to be slower and a - * PNG writer is assumed to have more memory available than a PNG reader. - * - * IMPLEMENTATION NOTE: the zlib API deflateBound() can be used to find an - * upper limit on the output size, but it is always bigger than the input - * size so it is likely to be more efficient to use this linked-list - * approach. - */ - ret = png_deflate_claim(png_ptr, chunk_name, comp->input_len); - - if (ret != Z_OK) - return ret; - - /* Set up the compression buffers, we need a loop here to avoid overflowing a - * uInt. Use ZLIB_IO_MAX to limit the input. The output is always limited - * by the output buffer size, so there is no need to check that. Since this - * is ANSI-C we know that an 'int', hence a uInt, is always at least 16 bits - * in size. - */ - { - png_compression_bufferp *end = &png_ptr->zbuffer_list; - png_alloc_size_t input_len = comp->input_len; /* may be zero! */ - png_uint_32 output_len; - - /* zlib updates these for us: */ - png_ptr->zstream.next_in = PNGZ_INPUT_CAST(comp->input); - png_ptr->zstream.avail_in = 0; /* Set below */ - png_ptr->zstream.next_out = comp->output; - png_ptr->zstream.avail_out = (sizeof comp->output); - - output_len = png_ptr->zstream.avail_out; - - do - { - uInt avail_in = ZLIB_IO_MAX; - - if (avail_in > input_len) - avail_in = (uInt)input_len; - - input_len -= avail_in; - - png_ptr->zstream.avail_in = avail_in; - - if (png_ptr->zstream.avail_out == 0) - { - png_compression_buffer *next; - - /* Chunk data is limited to 2^31 bytes in length, so the prefix - * length must be counted here. - */ - if (output_len + prefix_len > PNG_UINT_31_MAX) - { - ret = Z_MEM_ERROR; - break; - } - - /* Need a new (malloc'ed) buffer, but there may be one present - * already. - */ - next = *end; - if (next == NULL) - { - next = png_voidcast(png_compression_bufferp, png_malloc_base - (png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr))); - - if (next == NULL) - { - ret = Z_MEM_ERROR; - break; - } - - /* Link in this buffer (so that it will be freed later) */ - next->next = NULL; - *end = next; - } - - png_ptr->zstream.next_out = next->output; - png_ptr->zstream.avail_out = png_ptr->zbuffer_size; - output_len += png_ptr->zstream.avail_out; - - /* Move 'end' to the next buffer pointer. */ - end = &next->next; - } - - /* Compress the data */ - ret = deflate(&png_ptr->zstream, - input_len > 0 ? Z_NO_FLUSH : Z_FINISH); - - /* Claw back input data that was not consumed (because avail_in is - * reset above every time round the loop). - */ - input_len += png_ptr->zstream.avail_in; - png_ptr->zstream.avail_in = 0; /* safety */ - } - while (ret == Z_OK); - - /* There may be some space left in the last output buffer. This needs to - * be subtracted from output_len. - */ - output_len -= png_ptr->zstream.avail_out; - png_ptr->zstream.avail_out = 0; /* safety */ - comp->output_len = output_len; - - /* Now double check the output length, put in a custom message if it is - * too long. Otherwise ensure the z_stream::msg pointer is set to - * something. - */ - if (output_len + prefix_len >= PNG_UINT_31_MAX) - { - png_ptr->zstream.msg = PNGZ_MSG_CAST("compressed data too long"); - ret = Z_MEM_ERROR; - } - - else - png_zstream_error(png_ptr, ret); - - /* Reset zlib for another zTXt/iTXt or image data */ - png_ptr->zowner = 0; - - /* The only success case is Z_STREAM_END, input_len must be 0; if not this - * is an internal error. - */ - if (ret == Z_STREAM_END && input_len == 0) - { -#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED - /* Fix up the deflate header, if required */ - optimize_cmf(comp->output, comp->input_len); -#endif - /* But Z_OK is returned, not Z_STREAM_END; this allows the claim - * function above to return Z_STREAM_END on an error (though it never - * does in the current versions of zlib.) - */ - return Z_OK; - } - - else - return ret; - } -} - -/* Ship the compressed text out via chunk writes */ -static void -png_write_compressed_data_out(png_structrp png_ptr, compression_state *comp) -{ - png_uint_32 output_len = comp->output_len; - png_const_bytep output = comp->output; - png_uint_32 avail = (sizeof comp->output); - png_compression_buffer *next = png_ptr->zbuffer_list; - - for (;;) - { - if (avail > output_len) - avail = output_len; - - png_write_chunk_data(png_ptr, output, avail); - - output_len -= avail; - - if (output_len == 0 || next == NULL) - break; - - avail = png_ptr->zbuffer_size; - output = next->output; - next = next->next; - } - - /* This is an internal error; 'next' must have been NULL! */ - if (output_len > 0) - png_error(png_ptr, "error writing ancillary chunked compressed data"); -} -#endif /* WRITE_COMPRESSED_TEXT */ - -/* Write the IHDR chunk, and update the png_struct with the necessary - * information. Note that the rest of this code depends upon this - * information being correct. - */ -void /* PRIVATE */ -png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height, - int bit_depth, int color_type, int compression_type, int filter_type, - int interlace_type) -{ - png_byte buf[13]; /* Buffer to store the IHDR info */ - int is_invalid_depth; - - png_debug(1, "in png_write_IHDR"); - - /* Check that we have valid input data from the application info */ - switch (color_type) - { - case PNG_COLOR_TYPE_GRAY: - switch (bit_depth) - { - case 1: - case 2: - case 4: - case 8: -#ifdef PNG_WRITE_16BIT_SUPPORTED - case 16: -#endif - png_ptr->channels = 1; break; - - default: - png_error(png_ptr, - "Invalid bit depth for grayscale image"); - } - break; - - case PNG_COLOR_TYPE_RGB: - is_invalid_depth = (bit_depth != 8); -#ifdef PNG_WRITE_16BIT_SUPPORTED - is_invalid_depth = (is_invalid_depth && bit_depth != 16); -#endif - if (is_invalid_depth) - png_error(png_ptr, "Invalid bit depth for RGB image"); - - png_ptr->channels = 3; - break; - - case PNG_COLOR_TYPE_PALETTE: - switch (bit_depth) - { - case 1: - case 2: - case 4: - case 8: - png_ptr->channels = 1; - break; - - default: - png_error(png_ptr, "Invalid bit depth for paletted image"); - } - break; - - case PNG_COLOR_TYPE_GRAY_ALPHA: - is_invalid_depth = (bit_depth != 8); -#ifdef PNG_WRITE_16BIT_SUPPORTED - is_invalid_depth = (is_invalid_depth && bit_depth != 16); -#endif - if (is_invalid_depth) - png_error(png_ptr, "Invalid bit depth for grayscale+alpha image"); - - png_ptr->channels = 2; - break; - - case PNG_COLOR_TYPE_RGB_ALPHA: - is_invalid_depth = (bit_depth != 8); -#ifdef PNG_WRITE_16BIT_SUPPORTED - is_invalid_depth = (is_invalid_depth && bit_depth != 16); -#endif - if (is_invalid_depth) - png_error(png_ptr, "Invalid bit depth for RGBA image"); - - png_ptr->channels = 4; - break; - - default: - png_error(png_ptr, "Invalid image color type specified"); - } - - if (compression_type != PNG_COMPRESSION_TYPE_BASE) - { - png_warning(png_ptr, "Invalid compression type specified"); - compression_type = PNG_COMPRESSION_TYPE_BASE; - } - - /* Write filter_method 64 (intrapixel differencing) only if - * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and - * 2. Libpng did not write a PNG signature (this filter_method is only - * used in PNG datastreams that are embedded in MNG datastreams) and - * 3. The application called png_permit_mng_features with a mask that - * included PNG_FLAG_MNG_FILTER_64 and - * 4. The filter_method is 64 and - * 5. The color_type is RGB or RGBA - */ - if ( -#ifdef PNG_MNG_FEATURES_SUPPORTED - !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 && - ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) && -#endif - filter_type != PNG_FILTER_TYPE_BASE) - { - png_warning(png_ptr, "Invalid filter type specified"); - filter_type = PNG_FILTER_TYPE_BASE; - } - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - if (interlace_type != PNG_INTERLACE_NONE && - interlace_type != PNG_INTERLACE_ADAM7) - { - png_warning(png_ptr, "Invalid interlace type specified"); - interlace_type = PNG_INTERLACE_ADAM7; - } -#else - interlace_type=PNG_INTERLACE_NONE; -#endif - - /* Save the relevant information */ - png_ptr->bit_depth = (png_byte)bit_depth; - png_ptr->color_type = (png_byte)color_type; - png_ptr->interlaced = (png_byte)interlace_type; -#ifdef PNG_MNG_FEATURES_SUPPORTED - png_ptr->filter_type = (png_byte)filter_type; -#endif - png_ptr->compression_type = (png_byte)compression_type; - png_ptr->width = width; - png_ptr->height = height; - - png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels); - png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width); - /* Set the usr info, so any transformations can modify it */ - png_ptr->usr_width = png_ptr->width; - png_ptr->usr_bit_depth = png_ptr->bit_depth; - png_ptr->usr_channels = png_ptr->channels; - - /* Pack the header information into the buffer */ - png_save_uint_32(buf, width); - png_save_uint_32(buf + 4, height); - buf[8] = (png_byte)bit_depth; - buf[9] = (png_byte)color_type; - buf[10] = (png_byte)compression_type; - buf[11] = (png_byte)filter_type; - buf[12] = (png_byte)interlace_type; - - /* Write the chunk */ - png_write_complete_chunk(png_ptr, png_IHDR, buf, 13); - - if ((png_ptr->do_filter) == PNG_NO_FILTERS) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE || - png_ptr->bit_depth < 8) - png_ptr->do_filter = PNG_FILTER_NONE; - - else - png_ptr->do_filter = PNG_ALL_FILTERS; - } - - png_ptr->mode = PNG_HAVE_IHDR; /* not READY_FOR_ZTXT */ -} - -/* Write the palette. We are careful not to trust png_color to be in the - * correct order for PNG, so people can redefine it to any convenient - * structure. - */ -void /* PRIVATE */ -png_write_PLTE(png_structrp png_ptr, png_const_colorp palette, - png_uint_32 num_pal) -{ - png_uint_32 max_palette_length, i; - png_const_colorp pal_ptr; - png_byte buf[3]; - - png_debug(1, "in png_write_PLTE"); - - max_palette_length = (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ? - (1 << png_ptr->bit_depth) : PNG_MAX_PALETTE_LENGTH; - - if (( -#ifdef PNG_MNG_FEATURES_SUPPORTED - (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0 && -#endif - num_pal == 0) || num_pal > max_palette_length) - { - if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - png_error(png_ptr, "Invalid number of colors in palette"); - } - - else - { - png_warning(png_ptr, "Invalid number of colors in palette"); - return; - } - } - - if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) - { - png_warning(png_ptr, - "Ignoring request to write a PLTE chunk in grayscale PNG"); - - return; - } - - png_ptr->num_palette = (png_uint_16)num_pal; - png_debug1(3, "num_palette = %d", png_ptr->num_palette); - - png_write_chunk_header(png_ptr, png_PLTE, (png_uint_32)(num_pal * 3)); -#ifdef PNG_POINTER_INDEXING_SUPPORTED - - for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++) - { - buf[0] = pal_ptr->red; - buf[1] = pal_ptr->green; - buf[2] = pal_ptr->blue; - png_write_chunk_data(png_ptr, buf, 3); - } - -#else - /* This is a little slower but some buggy compilers need to do this - * instead - */ - pal_ptr=palette; - - for (i = 0; i < num_pal; i++) - { - buf[0] = pal_ptr[i].red; - buf[1] = pal_ptr[i].green; - buf[2] = pal_ptr[i].blue; - png_write_chunk_data(png_ptr, buf, 3); - } - -#endif - png_write_chunk_end(png_ptr); - png_ptr->mode |= PNG_HAVE_PLTE; -} - -/* This is similar to png_text_compress, above, except that it does not require - * all of the data at once and, instead of buffering the compressed result, - * writes it as IDAT chunks. Unlike png_text_compress it *can* png_error out - * because it calls the write interface. As a result it does its own error - * reporting and does not return an error code. In the event of error it will - * just call png_error. The input data length may exceed 32-bits. The 'flush' - * parameter is exactly the same as that to deflate, with the following - * meanings: - * - * Z_NO_FLUSH: normal incremental output of compressed data - * Z_SYNC_FLUSH: do a SYNC_FLUSH, used by png_write_flush - * Z_FINISH: this is the end of the input, do a Z_FINISH and clean up - * - * The routine manages the acquire and release of the png_ptr->zstream by - * checking and (at the end) clearing png_ptr->zowner; it does some sanity - * checks on the 'mode' flags while doing this. - */ -void /* PRIVATE */ -png_compress_IDAT(png_structrp png_ptr, png_const_bytep input, - png_alloc_size_t input_len, int flush) -{ - if (png_ptr->zowner != png_IDAT) - { - /* First time. Ensure we have a temporary buffer for compression and - * trim the buffer list if it has more than one entry to free memory. - * If 'WRITE_COMPRESSED_TEXT' is not set the list will never have been - * created at this point, but the check here is quick and safe. - */ - if (png_ptr->zbuffer_list == NULL) - { - png_ptr->zbuffer_list = png_voidcast(png_compression_bufferp, - png_malloc(png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr))); - png_ptr->zbuffer_list->next = NULL; - } - - else - png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list->next); - - /* It is a terminal error if we can't claim the zstream. */ - if (png_deflate_claim(png_ptr, png_IDAT, png_image_size(png_ptr)) != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg); - - /* The output state is maintained in png_ptr->zstream, so it must be - * initialized here after the claim. - */ - png_ptr->zstream.next_out = png_ptr->zbuffer_list->output; - png_ptr->zstream.avail_out = png_ptr->zbuffer_size; - } - - /* Now loop reading and writing until all the input is consumed or an error - * terminates the operation. The _out values are maintained across calls to - * this function, but the input must be reset each time. - */ - png_ptr->zstream.next_in = PNGZ_INPUT_CAST(input); - png_ptr->zstream.avail_in = 0; /* set below */ - for (;;) - { - int ret; - - /* INPUT: from the row data */ - uInt avail = ZLIB_IO_MAX; - - if (avail > input_len) - avail = (uInt)input_len; /* safe because of the check */ - - png_ptr->zstream.avail_in = avail; - input_len -= avail; - - ret = deflate(&png_ptr->zstream, input_len > 0 ? Z_NO_FLUSH : flush); - - /* Include as-yet unconsumed input */ - input_len += png_ptr->zstream.avail_in; - png_ptr->zstream.avail_in = 0; - - /* OUTPUT: write complete IDAT chunks when avail_out drops to zero. Note - * that these two zstream fields are preserved across the calls, therefore - * there is no need to set these up on entry to the loop. - */ - if (png_ptr->zstream.avail_out == 0) - { - png_bytep data = png_ptr->zbuffer_list->output; - uInt size = png_ptr->zbuffer_size; - - /* Write an IDAT containing the data then reset the buffer. The - * first IDAT may need deflate header optimization. - */ -#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED - if ((png_ptr->mode & PNG_HAVE_IDAT) == 0 && - png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE) - optimize_cmf(data, png_image_size(png_ptr)); -#endif - - if (size > 0) - png_write_complete_chunk(png_ptr, png_IDAT, data, size); - png_ptr->mode |= PNG_HAVE_IDAT; - - png_ptr->zstream.next_out = data; - png_ptr->zstream.avail_out = size; - - /* For SYNC_FLUSH or FINISH it is essential to keep calling zlib with - * the same flush parameter until it has finished output, for NO_FLUSH - * it doesn't matter. - */ - if (ret == Z_OK && flush != Z_NO_FLUSH) - continue; - } - - /* The order of these checks doesn't matter much; it just affects which - * possible error might be detected if multiple things go wrong at once. - */ - if (ret == Z_OK) /* most likely return code! */ - { - /* If all the input has been consumed then just return. If Z_FINISH - * was used as the flush parameter something has gone wrong if we get - * here. - */ - if (input_len == 0) - { - if (flush == Z_FINISH) - png_error(png_ptr, "Z_OK on Z_FINISH with output space"); - - return; - } - } - - else if (ret == Z_STREAM_END && flush == Z_FINISH) - { - /* This is the end of the IDAT data; any pending output must be - * flushed. For small PNG files we may still be at the beginning. - */ - png_bytep data = png_ptr->zbuffer_list->output; - uInt size = png_ptr->zbuffer_size - png_ptr->zstream.avail_out; - -#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED - if ((png_ptr->mode & PNG_HAVE_IDAT) == 0 && - png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE) - optimize_cmf(data, png_image_size(png_ptr)); -#endif - - if (size > 0) - png_write_complete_chunk(png_ptr, png_IDAT, data, size); - png_ptr->zstream.avail_out = 0; - png_ptr->zstream.next_out = NULL; - png_ptr->mode |= PNG_HAVE_IDAT | PNG_AFTER_IDAT; - - png_ptr->zowner = 0; /* Release the stream */ - return; - } - - else - { - /* This is an error condition. */ - png_zstream_error(png_ptr, ret); - png_error(png_ptr, png_ptr->zstream.msg); - } - } -} - -/* Write an IEND chunk */ -void /* PRIVATE */ -png_write_IEND(png_structrp png_ptr) -{ - png_debug(1, "in png_write_IEND"); - - png_write_complete_chunk(png_ptr, png_IEND, NULL, 0); - png_ptr->mode |= PNG_HAVE_IEND; -} - -#ifdef PNG_WRITE_gAMA_SUPPORTED -/* Write a gAMA chunk */ -void /* PRIVATE */ -png_write_gAMA_fixed(png_structrp png_ptr, png_fixed_point file_gamma) -{ - png_byte buf[4]; - - png_debug(1, "in png_write_gAMA"); - - /* file_gamma is saved in 1/100,000ths */ - png_save_uint_32(buf, (png_uint_32)file_gamma); - png_write_complete_chunk(png_ptr, png_gAMA, buf, 4); -} -#endif - -#ifdef PNG_WRITE_sRGB_SUPPORTED -/* Write a sRGB chunk */ -void /* PRIVATE */ -png_write_sRGB(png_structrp png_ptr, int srgb_intent) -{ - png_byte buf[1]; - - png_debug(1, "in png_write_sRGB"); - - if (srgb_intent >= PNG_sRGB_INTENT_LAST) - png_warning(png_ptr, - "Invalid sRGB rendering intent specified"); - - buf[0]=(png_byte)srgb_intent; - png_write_complete_chunk(png_ptr, png_sRGB, buf, 1); -} -#endif - -#ifdef PNG_WRITE_iCCP_SUPPORTED -/* Write an iCCP chunk */ -void /* PRIVATE */ -png_write_iCCP(png_structrp png_ptr, png_const_charp name, - png_const_bytep profile) -{ - png_uint_32 name_len; - png_uint_32 profile_len; - png_byte new_name[81]; /* 1 byte for the compression byte */ - compression_state comp; - png_uint_32 temp; - - png_debug(1, "in png_write_iCCP"); - - /* These are all internal problems: the profile should have been checked - * before when it was stored. - */ - if (profile == NULL) - png_error(png_ptr, "No profile for iCCP chunk"); /* internal error */ - - profile_len = png_get_uint_32(profile); - - if (profile_len < 132) - png_error(png_ptr, "ICC profile too short"); - - temp = (png_uint_32) (*(profile+8)); - if (temp > 3 && (profile_len & 0x03)) - png_error(png_ptr, "ICC profile length invalid (not a multiple of 4)"); - - { - png_uint_32 embedded_profile_len = png_get_uint_32(profile); - - if (profile_len != embedded_profile_len) - png_error(png_ptr, "Profile length does not match profile"); - } - - name_len = png_check_keyword(png_ptr, name, new_name); - - if (name_len == 0) - png_error(png_ptr, "iCCP: invalid keyword"); - - new_name[++name_len] = PNG_COMPRESSION_TYPE_BASE; - - /* Make sure we include the NULL after the name and the compression type */ - ++name_len; - - png_text_compress_init(&comp, profile, profile_len); - - /* Allow for keyword terminator and compression byte */ - if (png_text_compress(png_ptr, png_iCCP, &comp, name_len) != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg); - - png_write_chunk_header(png_ptr, png_iCCP, name_len + comp.output_len); - - png_write_chunk_data(png_ptr, new_name, name_len); - - png_write_compressed_data_out(png_ptr, &comp); - - png_write_chunk_end(png_ptr); -} -#endif - -#ifdef PNG_WRITE_sPLT_SUPPORTED -/* Write a sPLT chunk */ -void /* PRIVATE */ -png_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp spalette) -{ - png_uint_32 name_len; - png_byte new_name[80]; - png_byte entrybuf[10]; - size_t entry_size = (spalette->depth == 8 ? 6 : 10); - size_t palette_size = entry_size * (size_t)spalette->nentries; - png_sPLT_entryp ep; -#ifndef PNG_POINTER_INDEXING_SUPPORTED - int i; -#endif - - png_debug(1, "in png_write_sPLT"); - - name_len = png_check_keyword(png_ptr, spalette->name, new_name); - - if (name_len == 0) - png_error(png_ptr, "sPLT: invalid keyword"); - - /* Make sure we include the NULL after the name */ - png_write_chunk_header(png_ptr, png_sPLT, - (png_uint_32)(name_len + 2 + palette_size)); - - png_write_chunk_data(png_ptr, (png_bytep)new_name, (size_t)(name_len + 1)); - - png_write_chunk_data(png_ptr, &spalette->depth, 1); - - /* Loop through each palette entry, writing appropriately */ -#ifdef PNG_POINTER_INDEXING_SUPPORTED - for (ep = spalette->entries; epentries + spalette->nentries; ep++) - { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep->red; - entrybuf[1] = (png_byte)ep->green; - entrybuf[2] = (png_byte)ep->blue; - entrybuf[3] = (png_byte)ep->alpha; - png_save_uint_16(entrybuf + 4, ep->frequency); - } - - else - { - png_save_uint_16(entrybuf + 0, ep->red); - png_save_uint_16(entrybuf + 2, ep->green); - png_save_uint_16(entrybuf + 4, ep->blue); - png_save_uint_16(entrybuf + 6, ep->alpha); - png_save_uint_16(entrybuf + 8, ep->frequency); - } - - png_write_chunk_data(png_ptr, entrybuf, entry_size); - } -#else - ep=spalette->entries; - for (i = 0; i>spalette->nentries; i++) - { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep[i].red; - entrybuf[1] = (png_byte)ep[i].green; - entrybuf[2] = (png_byte)ep[i].blue; - entrybuf[3] = (png_byte)ep[i].alpha; - png_save_uint_16(entrybuf + 4, ep[i].frequency); - } - - else - { - png_save_uint_16(entrybuf + 0, ep[i].red); - png_save_uint_16(entrybuf + 2, ep[i].green); - png_save_uint_16(entrybuf + 4, ep[i].blue); - png_save_uint_16(entrybuf + 6, ep[i].alpha); - png_save_uint_16(entrybuf + 8, ep[i].frequency); - } - - png_write_chunk_data(png_ptr, entrybuf, entry_size); - } -#endif - - png_write_chunk_end(png_ptr); -} -#endif - -#ifdef PNG_WRITE_sBIT_SUPPORTED -/* Write the sBIT chunk */ -void /* PRIVATE */ -png_write_sBIT(png_structrp png_ptr, png_const_color_8p sbit, int color_type) -{ - png_byte buf[4]; - size_t size; - - png_debug(1, "in png_write_sBIT"); - - /* Make sure we don't depend upon the order of PNG_COLOR_8 */ - if ((color_type & PNG_COLOR_MASK_COLOR) != 0) - { - png_byte maxbits; - - maxbits = (png_byte)(color_type==PNG_COLOR_TYPE_PALETTE ? 8 : - png_ptr->usr_bit_depth); - - if (sbit->red == 0 || sbit->red > maxbits || - sbit->green == 0 || sbit->green > maxbits || - sbit->blue == 0 || sbit->blue > maxbits) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - - buf[0] = sbit->red; - buf[1] = sbit->green; - buf[2] = sbit->blue; - size = 3; - } - - else - { - if (sbit->gray == 0 || sbit->gray > png_ptr->usr_bit_depth) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - - buf[0] = sbit->gray; - size = 1; - } - - if ((color_type & PNG_COLOR_MASK_ALPHA) != 0) - { - if (sbit->alpha == 0 || sbit->alpha > png_ptr->usr_bit_depth) - { - png_warning(png_ptr, "Invalid sBIT depth specified"); - return; - } - - buf[size++] = sbit->alpha; - } - - png_write_complete_chunk(png_ptr, png_sBIT, buf, size); -} -#endif - -#ifdef PNG_WRITE_cHRM_SUPPORTED -/* Write the cHRM chunk */ -void /* PRIVATE */ -png_write_cHRM_fixed(png_structrp png_ptr, const png_xy *xy) -{ - png_byte buf[32]; - - png_debug(1, "in png_write_cHRM"); - - /* Each value is saved in 1/100,000ths */ - png_save_int_32(buf, xy->whitex); - png_save_int_32(buf + 4, xy->whitey); - - png_save_int_32(buf + 8, xy->redx); - png_save_int_32(buf + 12, xy->redy); - - png_save_int_32(buf + 16, xy->greenx); - png_save_int_32(buf + 20, xy->greeny); - - png_save_int_32(buf + 24, xy->bluex); - png_save_int_32(buf + 28, xy->bluey); - - png_write_complete_chunk(png_ptr, png_cHRM, buf, 32); -} -#endif - -#ifdef PNG_WRITE_tRNS_SUPPORTED -/* Write the tRNS chunk */ -void /* PRIVATE */ -png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha, - png_const_color_16p tran, int num_trans, int color_type) -{ - png_byte buf[6]; - - png_debug(1, "in png_write_tRNS"); - - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette) - { - png_app_warning(png_ptr, - "Invalid number of transparent colors specified"); - return; - } - - /* Write the chunk out as it is */ - png_write_complete_chunk(png_ptr, png_tRNS, trans_alpha, - (size_t)num_trans); - } - - else if (color_type == PNG_COLOR_TYPE_GRAY) - { - /* One 16-bit value */ - if (tran->gray >= (1 << png_ptr->bit_depth)) - { - png_app_warning(png_ptr, - "Ignoring attempt to write tRNS chunk out-of-range for bit_depth"); - - return; - } - - png_save_uint_16(buf, tran->gray); - png_write_complete_chunk(png_ptr, png_tRNS, buf, 2); - } - - else if (color_type == PNG_COLOR_TYPE_RGB) - { - /* Three 16-bit values */ - png_save_uint_16(buf, tran->red); - png_save_uint_16(buf + 2, tran->green); - png_save_uint_16(buf + 4, tran->blue); -#ifdef PNG_WRITE_16BIT_SUPPORTED - if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]) != 0) -#else - if ((buf[0] | buf[2] | buf[4]) != 0) -#endif - { - png_app_warning(png_ptr, - "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); - return; - } - - png_write_complete_chunk(png_ptr, png_tRNS, buf, 6); - } - - else - { - png_app_warning(png_ptr, "Can't write tRNS with an alpha channel"); - } -} -#endif - -#ifdef PNG_WRITE_bKGD_SUPPORTED -/* Write the background chunk */ -void /* PRIVATE */ -png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type) -{ - png_byte buf[6]; - - png_debug(1, "in png_write_bKGD"); - - if (color_type == PNG_COLOR_TYPE_PALETTE) - { - if ( -#ifdef PNG_MNG_FEATURES_SUPPORTED - (png_ptr->num_palette != 0 || - (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0) && -#endif - back->index >= png_ptr->num_palette) - { - png_warning(png_ptr, "Invalid background palette index"); - return; - } - - buf[0] = back->index; - png_write_complete_chunk(png_ptr, png_bKGD, buf, 1); - } - - else if ((color_type & PNG_COLOR_MASK_COLOR) != 0) - { - png_save_uint_16(buf, back->red); - png_save_uint_16(buf + 2, back->green); - png_save_uint_16(buf + 4, back->blue); -#ifdef PNG_WRITE_16BIT_SUPPORTED - if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4]) != 0) -#else - if ((buf[0] | buf[2] | buf[4]) != 0) -#endif - { - png_warning(png_ptr, - "Ignoring attempt to write 16-bit bKGD chunk " - "when bit_depth is 8"); - - return; - } - - png_write_complete_chunk(png_ptr, png_bKGD, buf, 6); - } - - else - { - if (back->gray >= (1 << png_ptr->bit_depth)) - { - png_warning(png_ptr, - "Ignoring attempt to write bKGD chunk out-of-range for bit_depth"); - - return; - } - - png_save_uint_16(buf, back->gray); - png_write_complete_chunk(png_ptr, png_bKGD, buf, 2); - } -} -#endif - -#ifdef PNG_WRITE_eXIf_SUPPORTED -/* Write the Exif data */ -void /* PRIVATE */ -png_write_eXIf(png_structrp png_ptr, png_bytep exif, int num_exif) -{ - int i; - png_byte buf[1]; - - png_debug(1, "in png_write_eXIf"); - - png_write_chunk_header(png_ptr, png_eXIf, (png_uint_32)(num_exif)); - - for (i = 0; i < num_exif; i++) - { - buf[0] = exif[i]; - png_write_chunk_data(png_ptr, buf, 1); - } - - png_write_chunk_end(png_ptr); -} -#endif - -#ifdef PNG_WRITE_hIST_SUPPORTED -/* Write the histogram */ -void /* PRIVATE */ -png_write_hIST(png_structrp png_ptr, png_const_uint_16p hist, int num_hist) -{ - int i; - png_byte buf[3]; - - png_debug(1, "in png_write_hIST"); - - if (num_hist > (int)png_ptr->num_palette) - { - png_debug2(3, "num_hist = %d, num_palette = %d", num_hist, - png_ptr->num_palette); - - png_warning(png_ptr, "Invalid number of histogram entries specified"); - return; - } - - png_write_chunk_header(png_ptr, png_hIST, (png_uint_32)(num_hist * 2)); - - for (i = 0; i < num_hist; i++) - { - png_save_uint_16(buf, hist[i]); - png_write_chunk_data(png_ptr, buf, 2); - } - - png_write_chunk_end(png_ptr); -} -#endif - -#ifdef PNG_WRITE_tEXt_SUPPORTED -/* Write a tEXt chunk */ -void /* PRIVATE */ -png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, - size_t text_len) -{ - png_uint_32 key_len; - png_byte new_key[80]; - - png_debug(1, "in png_write_tEXt"); - - key_len = png_check_keyword(png_ptr, key, new_key); - - if (key_len == 0) - png_error(png_ptr, "tEXt: invalid keyword"); - - if (text == NULL || *text == '\0') - text_len = 0; - - else - text_len = strlen(text); - - if (text_len > PNG_UINT_31_MAX - (key_len+1)) - png_error(png_ptr, "tEXt: text too long"); - - /* Make sure we include the 0 after the key */ - png_write_chunk_header(png_ptr, png_tEXt, - (png_uint_32)/*checked above*/(key_len + text_len + 1)); - /* - * We leave it to the application to meet PNG-1.0 requirements on the - * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of - * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. - * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. - */ - png_write_chunk_data(png_ptr, new_key, key_len + 1); - - if (text_len != 0) - png_write_chunk_data(png_ptr, (png_const_bytep)text, text_len); - - png_write_chunk_end(png_ptr); -} -#endif - -#ifdef PNG_WRITE_zTXt_SUPPORTED -/* Write a compressed text chunk */ -void /* PRIVATE */ -png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, - int compression) -{ - png_uint_32 key_len; - png_byte new_key[81]; - compression_state comp; - - png_debug(1, "in png_write_zTXt"); - - if (compression == PNG_TEXT_COMPRESSION_NONE) - { - png_write_tEXt(png_ptr, key, text, 0); - return; - } - - if (compression != PNG_TEXT_COMPRESSION_zTXt) - png_error(png_ptr, "zTXt: invalid compression type"); - - key_len = png_check_keyword(png_ptr, key, new_key); - - if (key_len == 0) - png_error(png_ptr, "zTXt: invalid keyword"); - - /* Add the compression method and 1 for the keyword separator. */ - new_key[++key_len] = PNG_COMPRESSION_TYPE_BASE; - ++key_len; - - /* Compute the compressed data; do it now for the length */ - png_text_compress_init(&comp, (png_const_bytep)text, - text == NULL ? 0 : strlen(text)); - - if (png_text_compress(png_ptr, png_zTXt, &comp, key_len) != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg); - - /* Write start of chunk */ - png_write_chunk_header(png_ptr, png_zTXt, key_len + comp.output_len); - - /* Write key */ - png_write_chunk_data(png_ptr, new_key, key_len); - - /* Write the compressed data */ - png_write_compressed_data_out(png_ptr, &comp); - - /* Close the chunk */ - png_write_chunk_end(png_ptr); -} -#endif - -#ifdef PNG_WRITE_iTXt_SUPPORTED -/* Write an iTXt chunk */ -void /* PRIVATE */ -png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key, - png_const_charp lang, png_const_charp lang_key, png_const_charp text) -{ - png_uint_32 key_len, prefix_len; - size_t lang_len, lang_key_len; - png_byte new_key[82]; - compression_state comp; - - png_debug(1, "in png_write_iTXt"); - - key_len = png_check_keyword(png_ptr, key, new_key); - - if (key_len == 0) - png_error(png_ptr, "iTXt: invalid keyword"); - - /* Set the compression flag */ - switch (compression) - { - case PNG_ITXT_COMPRESSION_NONE: - case PNG_TEXT_COMPRESSION_NONE: - compression = new_key[++key_len] = 0; /* no compression */ - break; - - case PNG_TEXT_COMPRESSION_zTXt: - case PNG_ITXT_COMPRESSION_zTXt: - compression = new_key[++key_len] = 1; /* compressed */ - break; - - default: - png_error(png_ptr, "iTXt: invalid compression"); - } - - new_key[++key_len] = PNG_COMPRESSION_TYPE_BASE; - ++key_len; /* for the keywod separator */ - - /* We leave it to the application to meet PNG-1.0 requirements on the - * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of - * any non-Latin-1 characters except for NEWLINE. ISO PNG, however, - * specifies that the text is UTF-8 and this really doesn't require any - * checking. - * - * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. - * - * TODO: validate the language tag correctly (see the spec.) - */ - if (lang == NULL) lang = ""; /* empty language is valid */ - lang_len = strlen(lang)+1; - if (lang_key == NULL) lang_key = ""; /* may be empty */ - lang_key_len = strlen(lang_key)+1; - if (text == NULL) text = ""; /* may be empty */ - - prefix_len = key_len; - if (lang_len > PNG_UINT_31_MAX-prefix_len) - prefix_len = PNG_UINT_31_MAX; - else - prefix_len = (png_uint_32)(prefix_len + lang_len); - - if (lang_key_len > PNG_UINT_31_MAX-prefix_len) - prefix_len = PNG_UINT_31_MAX; - else - prefix_len = (png_uint_32)(prefix_len + lang_key_len); - - png_text_compress_init(&comp, (png_const_bytep)text, strlen(text)); - - if (compression != 0) - { - if (png_text_compress(png_ptr, png_iTXt, &comp, prefix_len) != Z_OK) - png_error(png_ptr, png_ptr->zstream.msg); - } - - else - { - if (comp.input_len > PNG_UINT_31_MAX-prefix_len) - png_error(png_ptr, "iTXt: uncompressed text too long"); - - /* So the string will fit in a chunk: */ - comp.output_len = (png_uint_32)/*SAFE*/comp.input_len; - } - - png_write_chunk_header(png_ptr, png_iTXt, comp.output_len + prefix_len); - - png_write_chunk_data(png_ptr, new_key, key_len); - - png_write_chunk_data(png_ptr, (png_const_bytep)lang, lang_len); - - png_write_chunk_data(png_ptr, (png_const_bytep)lang_key, lang_key_len); - - if (compression != 0) - png_write_compressed_data_out(png_ptr, &comp); - - else - png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.output_len); - - png_write_chunk_end(png_ptr); -} -#endif - -#ifdef PNG_WRITE_oFFs_SUPPORTED -/* Write the oFFs chunk */ -void /* PRIVATE */ -png_write_oFFs(png_structrp png_ptr, png_int_32 x_offset, png_int_32 y_offset, - int unit_type) -{ - png_byte buf[9]; - - png_debug(1, "in png_write_oFFs"); - - if (unit_type >= PNG_OFFSET_LAST) - png_warning(png_ptr, "Unrecognized unit type for oFFs chunk"); - - png_save_int_32(buf, x_offset); - png_save_int_32(buf + 4, y_offset); - buf[8] = (png_byte)unit_type; - - png_write_complete_chunk(png_ptr, png_oFFs, buf, 9); -} -#endif -#ifdef PNG_WRITE_pCAL_SUPPORTED -/* Write the pCAL chunk (described in the PNG extensions document) */ -void /* PRIVATE */ -png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0, - png_int_32 X1, int type, int nparams, png_const_charp units, - png_charpp params) -{ - png_uint_32 purpose_len; - size_t units_len, total_len; - png_size_tp params_len; - png_byte buf[10]; - png_byte new_purpose[80]; - int i; - - png_debug1(1, "in png_write_pCAL (%d parameters)", nparams); - - if (type >= PNG_EQUATION_LAST) - png_error(png_ptr, "Unrecognized equation type for pCAL chunk"); - - purpose_len = png_check_keyword(png_ptr, purpose, new_purpose); - - if (purpose_len == 0) - png_error(png_ptr, "pCAL: invalid keyword"); - - ++purpose_len; /* terminator */ - - png_debug1(3, "pCAL purpose length = %d", (int)purpose_len); - units_len = strlen(units) + (nparams == 0 ? 0 : 1); - png_debug1(3, "pCAL units length = %d", (int)units_len); - total_len = purpose_len + units_len + 10; - - params_len = (png_size_tp)png_malloc(png_ptr, - (png_alloc_size_t)((png_alloc_size_t)nparams * (sizeof (size_t)))); - - /* Find the length of each parameter, making sure we don't count the - * null terminator for the last parameter. - */ - for (i = 0; i < nparams; i++) - { - params_len[i] = strlen(params[i]) + (i == nparams - 1 ? 0 : 1); - png_debug2(3, "pCAL parameter %d length = %lu", i, - (unsigned long)params_len[i]); - total_len += params_len[i]; - } - - png_debug1(3, "pCAL total length = %d", (int)total_len); - png_write_chunk_header(png_ptr, png_pCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, new_purpose, purpose_len); - png_save_int_32(buf, X0); - png_save_int_32(buf + 4, X1); - buf[8] = (png_byte)type; - buf[9] = (png_byte)nparams; - png_write_chunk_data(png_ptr, buf, 10); - png_write_chunk_data(png_ptr, (png_const_bytep)units, (size_t)units_len); - - for (i = 0; i < nparams; i++) - { - png_write_chunk_data(png_ptr, (png_const_bytep)params[i], params_len[i]); - } - - png_free(png_ptr, params_len); - png_write_chunk_end(png_ptr); -} -#endif - -#ifdef PNG_WRITE_sCAL_SUPPORTED -/* Write the sCAL chunk */ -void /* PRIVATE */ -png_write_sCAL_s(png_structrp png_ptr, int unit, png_const_charp width, - png_const_charp height) -{ - png_byte buf[64]; - size_t wlen, hlen, total_len; - - png_debug(1, "in png_write_sCAL_s"); - - wlen = strlen(width); - hlen = strlen(height); - total_len = wlen + hlen + 2; - - if (total_len > 64) - { - png_warning(png_ptr, "Can't write sCAL (buffer too small)"); - return; - } - - buf[0] = (png_byte)unit; - memcpy(buf + 1, width, wlen + 1); /* Append the '\0' here */ - memcpy(buf + wlen + 2, height, hlen); /* Do NOT append the '\0' here */ - - png_debug1(3, "sCAL total length = %u", (unsigned int)total_len); - png_write_complete_chunk(png_ptr, png_sCAL, buf, total_len); -} -#endif - -#ifdef PNG_WRITE_pHYs_SUPPORTED -/* Write the pHYs chunk */ -void /* PRIVATE */ -png_write_pHYs(png_structrp png_ptr, png_uint_32 x_pixels_per_unit, - png_uint_32 y_pixels_per_unit, - int unit_type) -{ - png_byte buf[9]; - - png_debug(1, "in png_write_pHYs"); - - if (unit_type >= PNG_RESOLUTION_LAST) - png_warning(png_ptr, "Unrecognized unit type for pHYs chunk"); - - png_save_uint_32(buf, x_pixels_per_unit); - png_save_uint_32(buf + 4, y_pixels_per_unit); - buf[8] = (png_byte)unit_type; - - png_write_complete_chunk(png_ptr, png_pHYs, buf, 9); -} -#endif - -#ifdef PNG_WRITE_tIME_SUPPORTED -/* Write the tIME chunk. Use either png_convert_from_struct_tm() - * or png_convert_from_time_t(), or fill in the structure yourself. - */ -void /* PRIVATE */ -png_write_tIME(png_structrp png_ptr, png_const_timep mod_time) -{ - png_byte buf[7]; - - png_debug(1, "in png_write_tIME"); - - if (mod_time->month > 12 || mod_time->month < 1 || - mod_time->day > 31 || mod_time->day < 1 || - mod_time->hour > 23 || mod_time->second > 60) - { - png_warning(png_ptr, "Invalid time specified for tIME chunk"); - return; - } - - png_save_uint_16(buf, mod_time->year); - buf[2] = mod_time->month; - buf[3] = mod_time->day; - buf[4] = mod_time->hour; - buf[5] = mod_time->minute; - buf[6] = mod_time->second; - - png_write_complete_chunk(png_ptr, png_tIME, buf, 7); -} -#endif - -/* Initializes the row writing capability of libpng */ -void /* PRIVATE */ -png_write_start_row(png_structrp png_ptr) -{ -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* Start of interlace block */ - static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* Offset to next interlace block */ - static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* Start of interlace block in the y direction */ - static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* Offset to next interlace block in the y direction */ - static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - png_alloc_size_t buf_size; - int usr_pixel_depth; - -#ifdef PNG_WRITE_FILTER_SUPPORTED - png_byte filters; -#endif - - png_debug(1, "in png_write_start_row"); - - usr_pixel_depth = png_ptr->usr_channels * png_ptr->usr_bit_depth; - buf_size = PNG_ROWBYTES(usr_pixel_depth, png_ptr->width) + 1; - - /* 1.5.6: added to allow checking in the row write code. */ - png_ptr->transformed_pixel_depth = png_ptr->pixel_depth; - png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth; - - /* Set up row buffer */ - png_ptr->row_buf = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size)); - - png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE; - -#ifdef PNG_WRITE_FILTER_SUPPORTED - filters = png_ptr->do_filter; - - if (png_ptr->height == 1) - filters &= 0xff & ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH); - - if (png_ptr->width == 1) - filters &= 0xff & ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH); - - if (filters == 0) - filters = PNG_FILTER_NONE; - - png_ptr->do_filter = filters; - - if (((filters & (PNG_FILTER_SUB | PNG_FILTER_UP | PNG_FILTER_AVG | - PNG_FILTER_PAETH)) != 0) && png_ptr->try_row == NULL) - { - int num_filters = 0; - - png_ptr->try_row = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size)); - - if (filters & PNG_FILTER_SUB) - num_filters++; - - if (filters & PNG_FILTER_UP) - num_filters++; - - if (filters & PNG_FILTER_AVG) - num_filters++; - - if (filters & PNG_FILTER_PAETH) - num_filters++; - - if (num_filters > 1) - png_ptr->tst_row = png_voidcast(png_bytep, png_malloc(png_ptr, - buf_size)); - } - - /* We only need to keep the previous row if we are using one of the following - * filters. - */ - if ((filters & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) != 0) - png_ptr->prev_row = png_voidcast(png_bytep, - png_calloc(png_ptr, buf_size)); -#endif /* WRITE_FILTER */ - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* If interlaced, we need to set up width and height of pass */ - if (png_ptr->interlaced != 0) - { - if ((png_ptr->transformations & PNG_INTERLACE) == 0) - { - png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 - - png_pass_ystart[0]) / png_pass_yinc[0]; - - png_ptr->usr_width = (png_ptr->width + png_pass_inc[0] - 1 - - png_pass_start[0]) / png_pass_inc[0]; - } - - else - { - png_ptr->num_rows = png_ptr->height; - png_ptr->usr_width = png_ptr->width; - } - } - - else -#endif - { - png_ptr->num_rows = png_ptr->height; - png_ptr->usr_width = png_ptr->width; - } -} - -/* Internal use only. Called when finished processing a row of data. */ -void /* PRIVATE */ -png_write_finish_row(png_structrp png_ptr) -{ -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* Start of interlace block */ - static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* Offset to next interlace block */ - static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - /* Start of interlace block in the y direction */ - static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - - /* Offset to next interlace block in the y direction */ - static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; -#endif - - png_debug(1, "in png_write_finish_row"); - - /* Next row */ - png_ptr->row_number++; - - /* See if we are done */ - if (png_ptr->row_number < png_ptr->num_rows) - return; - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* If interlaced, go to next pass */ - if (png_ptr->interlaced != 0) - { - png_ptr->row_number = 0; - if ((png_ptr->transformations & PNG_INTERLACE) != 0) - { - png_ptr->pass++; - } - - else - { - /* Loop until we find a non-zero width or height pass */ - do - { - png_ptr->pass++; - - if (png_ptr->pass >= 7) - break; - - png_ptr->usr_width = (png_ptr->width + - png_pass_inc[png_ptr->pass] - 1 - - png_pass_start[png_ptr->pass]) / - png_pass_inc[png_ptr->pass]; - - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[png_ptr->pass] - 1 - - png_pass_ystart[png_ptr->pass]) / - png_pass_yinc[png_ptr->pass]; - - if ((png_ptr->transformations & PNG_INTERLACE) != 0) - break; - - } while (png_ptr->usr_width == 0 || png_ptr->num_rows == 0); - - } - - /* Reset the row above the image for the next pass */ - if (png_ptr->pass < 7) - { - if (png_ptr->prev_row != NULL) - memset(png_ptr->prev_row, 0, - PNG_ROWBYTES(png_ptr->usr_channels * - png_ptr->usr_bit_depth, png_ptr->width) + 1); - - return; - } - } -#endif - - /* If we get here, we've just written the last row, so we need - to flush the compressor */ - png_compress_IDAT(png_ptr, NULL, 0, Z_FINISH); -} - -#ifdef PNG_WRITE_INTERLACING_SUPPORTED -/* Pick out the correct pixels for the interlace pass. - * The basic idea here is to go through the row with a source - * pointer and a destination pointer (sp and dp), and copy the - * correct pixels for the pass. As the row gets compacted, - * sp will always be >= dp, so we should never overwrite anything. - * See the default: case for the easiest code to understand. - */ -void /* PRIVATE */ -png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) -{ - /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - - /* Start of interlace block */ - static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - - /* Offset to next interlace block */ - static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - - png_debug(1, "in png_do_write_interlace"); - - /* We don't have to do anything on the last pass (6) */ - if (pass < 6) - { - /* Each pixel depth is handled separately */ - switch (row_info->pixel_depth) - { - case 1: - { - png_bytep sp; - png_bytep dp; - unsigned int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - d = 0; - shift = 7; - - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (size_t)(i >> 3); - value = (int)(*sp >> (7 - (int)(i & 0x07))) & 0x01; - d |= (value << shift); - - if (shift == 0) - { - shift = 7; - *dp++ = (png_byte)d; - d = 0; - } - - else - shift--; - - } - if (shift != 7) - *dp = (png_byte)d; - - break; - } - - case 2: - { - png_bytep sp; - png_bytep dp; - unsigned int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - shift = 6; - d = 0; - - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (size_t)(i >> 2); - value = (*sp >> ((3 - (int)(i & 0x03)) << 1)) & 0x03; - d |= (value << shift); - - if (shift == 0) - { - shift = 6; - *dp++ = (png_byte)d; - d = 0; - } - - else - shift -= 2; - } - if (shift != 6) - *dp = (png_byte)d; - - break; - } - - case 4: - { - png_bytep sp; - png_bytep dp; - unsigned int shift; - int d; - int value; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - - dp = row; - shift = 4; - d = 0; - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - sp = row + (size_t)(i >> 1); - value = (*sp >> ((1 - (int)(i & 0x01)) << 2)) & 0x0f; - d |= (value << shift); - - if (shift == 0) - { - shift = 4; - *dp++ = (png_byte)d; - d = 0; - } - - else - shift -= 4; - } - if (shift != 4) - *dp = (png_byte)d; - - break; - } - - default: - { - png_bytep sp; - png_bytep dp; - png_uint_32 i; - png_uint_32 row_width = row_info->width; - size_t pixel_bytes; - - /* Start at the beginning */ - dp = row; - - /* Find out how many bytes each pixel takes up */ - pixel_bytes = (row_info->pixel_depth >> 3); - - /* Loop through the row, only looking at the pixels that matter */ - for (i = png_pass_start[pass]; i < row_width; - i += png_pass_inc[pass]) - { - /* Find out where the original pixel is */ - sp = row + (size_t)i * pixel_bytes; - - /* Move the pixel */ - if (dp != sp) - memcpy(dp, sp, pixel_bytes); - - /* Next pixel */ - dp += pixel_bytes; - } - break; - } - } - /* Set new row width */ - row_info->width = (row_info->width + - png_pass_inc[pass] - 1 - - png_pass_start[pass]) / - png_pass_inc[pass]; - - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_info->width); - } -} -#endif - - -/* This filters the row, chooses which filter to use, if it has not already - * been specified by the application, and then writes the row out with the - * chosen filter. - */ -static void /* PRIVATE */ -png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, - size_t row_bytes); - -#ifdef PNG_WRITE_FILTER_SUPPORTED -static size_t /* PRIVATE */ -png_setup_sub_row(png_structrp png_ptr, png_uint_32 bpp, - size_t row_bytes, size_t lmins) -{ - png_bytep rp, dp, lp; - size_t i; - size_t sum = 0; - unsigned int v; - - png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB; - - for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1; i < bpp; - i++, rp++, dp++) - { - v = *dp = *rp; -#ifdef PNG_USE_ABS - sum += 128 - abs((int)v - 128); -#else - sum += (v < 128) ? v : 256 - v; -#endif - } - - for (lp = png_ptr->row_buf + 1; i < row_bytes; - i++, rp++, lp++, dp++) - { - v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); -#ifdef PNG_USE_ABS - sum += 128 - abs((int)v - 128); -#else - sum += (v < 128) ? v : 256 - v; -#endif - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - - return (sum); -} - -static void /* PRIVATE */ -png_setup_sub_row_only(png_structrp png_ptr, png_uint_32 bpp, - size_t row_bytes) -{ - png_bytep rp, dp, lp; - size_t i; - - png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB; - - for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1; i < bpp; - i++, rp++, dp++) - { - *dp = *rp; - } - - for (lp = png_ptr->row_buf + 1; i < row_bytes; - i++, rp++, lp++, dp++) - { - *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); - } -} - -static size_t /* PRIVATE */ -png_setup_up_row(png_structrp png_ptr, size_t row_bytes, size_t lmins) -{ - png_bytep rp, dp, pp; - size_t i; - size_t sum = 0; - unsigned int v; - - png_ptr->try_row[0] = PNG_FILTER_VALUE_UP; - - for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, - pp = png_ptr->prev_row + 1; i < row_bytes; - i++, rp++, pp++, dp++) - { - v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); -#ifdef PNG_USE_ABS - sum += 128 - abs((int)v - 128); -#else - sum += (v < 128) ? v : 256 - v; -#endif - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - - return (sum); -} -static void /* PRIVATE */ -png_setup_up_row_only(png_structrp png_ptr, size_t row_bytes) -{ - png_bytep rp, dp, pp; - size_t i; - - png_ptr->try_row[0] = PNG_FILTER_VALUE_UP; - - for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, - pp = png_ptr->prev_row + 1; i < row_bytes; - i++, rp++, pp++, dp++) - { - *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); - } -} - -static size_t /* PRIVATE */ -png_setup_avg_row(png_structrp png_ptr, png_uint_32 bpp, - size_t row_bytes, size_t lmins) -{ - png_bytep rp, dp, pp, lp; - png_uint_32 i; - size_t sum = 0; - unsigned int v; - - png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG; - - for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, - pp = png_ptr->prev_row + 1; i < bpp; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); - -#ifdef PNG_USE_ABS - sum += 128 - abs((int)v - 128); -#else - sum += (v < 128) ? v : 256 - v; -#endif - } - - for (lp = png_ptr->row_buf + 1; i < row_bytes; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) - & 0xff); - -#ifdef PNG_USE_ABS - sum += 128 - abs((int)v - 128); -#else - sum += (v < 128) ? v : 256 - v; -#endif - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - - return (sum); -} -static void /* PRIVATE */ -png_setup_avg_row_only(png_structrp png_ptr, png_uint_32 bpp, - size_t row_bytes) -{ - png_bytep rp, dp, pp, lp; - png_uint_32 i; - - png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG; - - for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, - pp = png_ptr->prev_row + 1; i < bpp; i++) - { - *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); - } - - for (lp = png_ptr->row_buf + 1; i < row_bytes; i++) - { - *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) - & 0xff); - } -} - -static size_t /* PRIVATE */ -png_setup_paeth_row(png_structrp png_ptr, png_uint_32 bpp, - size_t row_bytes, size_t lmins) -{ - png_bytep rp, dp, pp, cp, lp; - size_t i; - size_t sum = 0; - unsigned int v; - - png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH; - - for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, - pp = png_ptr->prev_row + 1; i < bpp; i++) - { - v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - -#ifdef PNG_USE_ABS - sum += 128 - abs((int)v - 128); -#else - sum += (v < 128) ? v : 256 - v; -#endif - } - - for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes; - i++) - { - int a, b, c, pa, pb, pc, p; - - b = *pp++; - c = *cp++; - a = *lp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); - -#ifdef PNG_USE_ABS - sum += 128 - abs((int)v - 128); -#else - sum += (v < 128) ? v : 256 - v; -#endif - - if (sum > lmins) /* We are already worse, don't continue. */ - break; - } - - return (sum); -} -static void /* PRIVATE */ -png_setup_paeth_row_only(png_structrp png_ptr, png_uint_32 bpp, - size_t row_bytes) -{ - png_bytep rp, dp, pp, cp, lp; - size_t i; - - png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH; - - for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, - pp = png_ptr->prev_row + 1; i < bpp; i++) - { - *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); - } - - for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes; - i++) - { - int a, b, c, pa, pb, pc, p; - - b = *pp++; - c = *cp++; - a = *lp++; - - p = b - c; - pc = a - c; - -#ifdef PNG_USE_ABS - pa = abs(p); - pb = abs(pc); - pc = abs(p + pc); -#else - pa = p < 0 ? -p : p; - pb = pc < 0 ? -pc : pc; - pc = (p + pc) < 0 ? -(p + pc) : p + pc; -#endif - - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; - - *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); - } -} -#endif /* WRITE_FILTER */ - -void /* PRIVATE */ -png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) -{ -#ifndef PNG_WRITE_FILTER_SUPPORTED - png_write_filtered_row(png_ptr, png_ptr->row_buf, row_info->rowbytes+1); -#else - unsigned int filter_to_do = png_ptr->do_filter; - png_bytep row_buf; - png_bytep best_row; - png_uint_32 bpp; - size_t mins; - size_t row_bytes = row_info->rowbytes; - - png_debug(1, "in png_write_find_filter"); - - /* Find out how many bytes offset each pixel is */ - bpp = (row_info->pixel_depth + 7) >> 3; - - row_buf = png_ptr->row_buf; - mins = PNG_SIZE_MAX - 256/* so we can detect potential overflow of the - running sum */; - - /* The prediction method we use is to find which method provides the - * smallest value when summing the absolute values of the distances - * from zero, using anything >= 128 as negative numbers. This is known - * as the "minimum sum of absolute differences" heuristic. Other - * heuristics are the "weighted minimum sum of absolute differences" - * (experimental and can in theory improve compression), and the "zlib - * predictive" method (not implemented yet), which does test compressions - * of lines using different filter methods, and then chooses the - * (series of) filter(s) that give minimum compressed data size (VERY - * computationally expensive). - * - * GRR 980525: consider also - * - * (1) minimum sum of absolute differences from running average (i.e., - * keep running sum of non-absolute differences & count of bytes) - * [track dispersion, too? restart average if dispersion too large?] - * - * (1b) minimum sum of absolute differences from sliding average, probably - * with window size <= deflate window (usually 32K) - * - * (2) minimum sum of squared differences from zero or running average - * (i.e., ~ root-mean-square approach) - */ - - - /* We don't need to test the 'no filter' case if this is the only filter - * that has been chosen, as it doesn't actually do anything to the data. - */ - best_row = png_ptr->row_buf; - - if (PNG_SIZE_MAX/128 <= row_bytes) - { - /* Overflow can occur in the calculation, just select the lowest set - * filter. - */ - filter_to_do &= 0U-filter_to_do; - } - else if ((filter_to_do & PNG_FILTER_NONE) != 0 && - filter_to_do != PNG_FILTER_NONE) - { - /* Overflow not possible and multiple filters in the list, including the - * 'none' filter. - */ - png_bytep rp; - size_t sum = 0; - size_t i; - unsigned int v; - - { - for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) - { - v = *rp; -#ifdef PNG_USE_ABS - sum += 128 - abs((int)v - 128); -#else - sum += (v < 128) ? v : 256 - v; -#endif - } - } - - mins = sum; - } - - /* Sub filter */ - if (filter_to_do == PNG_FILTER_SUB) - /* It's the only filter so no testing is needed */ - { - png_setup_sub_row_only(png_ptr, bpp, row_bytes); - best_row = png_ptr->try_row; - } - - else if ((filter_to_do & PNG_FILTER_SUB) != 0) - { - size_t sum; - size_t lmins = mins; - - sum = png_setup_sub_row(png_ptr, bpp, row_bytes, lmins); - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->try_row; - if (png_ptr->tst_row != NULL) - { - png_ptr->try_row = png_ptr->tst_row; - png_ptr->tst_row = best_row; - } - } - } - - /* Up filter */ - if (filter_to_do == PNG_FILTER_UP) - { - png_setup_up_row_only(png_ptr, row_bytes); - best_row = png_ptr->try_row; - } - - else if ((filter_to_do & PNG_FILTER_UP) != 0) - { - size_t sum; - size_t lmins = mins; - - sum = png_setup_up_row(png_ptr, row_bytes, lmins); - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->try_row; - if (png_ptr->tst_row != NULL) - { - png_ptr->try_row = png_ptr->tst_row; - png_ptr->tst_row = best_row; - } - } - } - - /* Avg filter */ - if (filter_to_do == PNG_FILTER_AVG) - { - png_setup_avg_row_only(png_ptr, bpp, row_bytes); - best_row = png_ptr->try_row; - } - - else if ((filter_to_do & PNG_FILTER_AVG) != 0) - { - size_t sum; - size_t lmins = mins; - - sum= png_setup_avg_row(png_ptr, bpp, row_bytes, lmins); - - if (sum < mins) - { - mins = sum; - best_row = png_ptr->try_row; - if (png_ptr->tst_row != NULL) - { - png_ptr->try_row = png_ptr->tst_row; - png_ptr->tst_row = best_row; - } - } - } - - /* Paeth filter */ - if (filter_to_do == PNG_FILTER_PAETH) - { - png_setup_paeth_row_only(png_ptr, bpp, row_bytes); - best_row = png_ptr->try_row; - } - - else if ((filter_to_do & PNG_FILTER_PAETH) != 0) - { - size_t sum; - size_t lmins = mins; - - sum = png_setup_paeth_row(png_ptr, bpp, row_bytes, lmins); - - if (sum < mins) - { - best_row = png_ptr->try_row; - if (png_ptr->tst_row != NULL) - { - png_ptr->try_row = png_ptr->tst_row; - png_ptr->tst_row = best_row; - } - } - } - - /* Do the actual writing of the filtered row data from the chosen filter. */ - png_write_filtered_row(png_ptr, best_row, row_info->rowbytes+1); - -#endif /* WRITE_FILTER */ -} - - -/* Do the actual writing of a previously filtered row. */ -static void -png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, - size_t full_row_length/*includes filter byte*/) -{ - png_debug(1, "in png_write_filtered_row"); - - png_debug1(2, "filter = %d", filtered_row[0]); - - png_compress_IDAT(png_ptr, filtered_row, full_row_length, Z_NO_FLUSH); - -#ifdef PNG_WRITE_FILTER_SUPPORTED - /* Swap the current and previous rows */ - if (png_ptr->prev_row != NULL) - { - png_bytep tptr; - - tptr = png_ptr->prev_row; - png_ptr->prev_row = png_ptr->row_buf; - png_ptr->row_buf = tptr; - } -#endif /* WRITE_FILTER */ - - /* Finish row - updates counters and flushes zlib if last row */ - png_write_finish_row(png_ptr); - -#ifdef PNG_WRITE_FLUSH_SUPPORTED - png_ptr->flush_rows++; - - if (png_ptr->flush_dist > 0 && - png_ptr->flush_rows >= png_ptr->flush_dist) - { - png_write_flush(png_ptr); - } -#endif /* WRITE_FLUSH */ -} -#endif /* WRITE */ diff --git a/oversampling/WDL/lice/curverasterbuffer.h b/oversampling/WDL/lice/curverasterbuffer.h deleted file mode 100644 index 24dc776..0000000 --- a/oversampling/WDL/lice/curverasterbuffer.h +++ /dev/null @@ -1,115 +0,0 @@ -#ifndef _LICE_CURVE_RASTER_BUFFER_H_ -#define _LICE_CURVE_RASTER_BUFFER_H_ - -class CurveRasterBuffer -{ - static void CopyPixelNoClip(LICE_IBitmap *bmp, int x, int y, LICE_pixel col, double alpha) - { - LICE_pixel *p=bmp->getBits()+y*bmp->getRowSpan()+x; - if (*p == col || alpha <= 0.0) return; - - if (alpha >= 1.0) - { - *p=col; - return; - } - - const int ia=256-(int)(alpha*256.0); - int r=LICE_GETR(col), g=LICE_GETG(col), b=LICE_GETB(col); - LICE_pixel_chan *c=(LICE_pixel_chan*)p; - c[LICE_PIXEL_R]=r+((c[LICE_PIXEL_R]-r)*ia)/256; - c[LICE_PIXEL_G]=g+((c[LICE_PIXEL_G]-g)*ia)/256; - c[LICE_PIXEL_B]=b+((c[LICE_PIXEL_B]-b)*ia)/256; - } - - static void DrawSlice(LICE_IBitmap* bmp, int x, double y1, double y2, int pxh, LICE_pixel color, float alpha) - { - const int iy1=(int)y1, iy2=(int)y2; - - if (iy1 == iy2) - { - if (iy1 >= 0 && iy1 < pxh) CopyPixelNoClip(bmp, x, iy1, color, (y2-y1)*alpha); - } - else - { - if (iy1 >= 0 && iy1 < pxh) CopyPixelNoClip(bmp, x, iy1, color, (1+iy1-y1)*alpha); - - if (iy2 > iy1+1) - { - int iy; - const int n=min(iy2, pxh); - for (iy=max(iy1+1, 0); iy < n; ++iy) - { - CopyPixelNoClip(bmp, x, iy, color, alpha); - } - } - - if (iy2 >= 0 && iy2 < pxh) CopyPixelNoClip(bmp, x, iy2, color, (y2-iy2)*alpha); - } - } - - public: - int xext[2],bmw; - float *sb; - - CurveRasterBuffer(int w, WDL_TypedBuf *sbuf) - { - xext[0]=bmw=w; - xext[1]=0; - sb = sbuf->ResizeOK(w*2,false); - } - - void addpt(int xpos, double ypos) - { - if (xpos >= 0 && xpos < bmw) - { - float *p = sb + xpos*2; - const int ext0=xext[0], ext1=xext[1]; - if (ext0 <= ext1) // existing range - { - if (xpos < ext0) - { - memset(p+2, 0, (ext0-xpos-1)*2*sizeof(*p)); - p[0]=p[1]=ypos; - xext[0]=xpos; - } - else if (xpos > ext1) - { - memset(sb + (ext1+1)*2, 0, (xpos-(ext1+1))*2*sizeof(*p)); - p[0]=p[1]=ypos; - xext[1]=xpos; - } - else if (p[0] == 0.0 && p[1] == 0.0) p[0] = p[1] = ypos; - else - { - if (ypos < p[0]) p[0] = ypos; - else if (ypos > p[1]) p[1] = ypos; - } - } - else // first point - { - xext[0]=xext[1] = xpos; - p[0]=p[1]=ypos; - } - } - } - - void Draw(LICE_IBitmap *bm, LICE_pixel color, float alpha) - { - int bmh = bm->getHeight(); - const int sc = (int) (INT_PTR)bm->Extended(LICE_EXT_GET_SCALING,NULL); - if (sc > 256) bmh = bmh * sc / 256; - const int xmax = xext[1]; - int x = xext[0]; - const float *sbuf = sb+x*2; - for (; x <= xmax; x ++) - { - const double v1 = sbuf[0], v2 = sbuf[1]; - if (v2>v1) DrawSlice(bm, x,v1,v2, bmh, color,alpha); - sbuf+= 2; - } - } -}; - - -#endif diff --git a/oversampling/WDL/lice/glew/include/GL/WGLEXT.H b/oversampling/WDL/lice/glew/include/GL/WGLEXT.H deleted file mode 100644 index 9dcee14..0000000 --- a/oversampling/WDL/lice/glew/include/GL/WGLEXT.H +++ /dev/null @@ -1,631 +0,0 @@ -#ifndef __wglext_h_ -#define __wglext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: This software was created using the -** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has -** not been independently verified as being compliant with the OpenGL(R) -** version 1.2.1 Specification. -*/ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -/* Header file version number */ -/* wglext.h last updated 2005/01/07 */ -/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ -#define WGL_WGLEXT_VERSION 6 - -#ifndef WGL_ARB_buffer_region -#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 -#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 -#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 -#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 -#endif - -#ifndef WGL_ARB_multisample -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 -#endif - -#ifndef WGL_ARB_extensions_string -#endif - -#ifndef WGL_ARB_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 -#define WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define WGL_DRAW_TO_BITMAP_ARB 0x2002 -#define WGL_ACCELERATION_ARB 0x2003 -#define WGL_NEED_PALETTE_ARB 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 -#define WGL_SWAP_METHOD_ARB 0x2007 -#define WGL_NUMBER_OVERLAYS_ARB 0x2008 -#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 -#define WGL_TRANSPARENT_ARB 0x200A -#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 -#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 -#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 -#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A -#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B -#define WGL_SHARE_DEPTH_ARB 0x200C -#define WGL_SHARE_STENCIL_ARB 0x200D -#define WGL_SHARE_ACCUM_ARB 0x200E -#define WGL_SUPPORT_GDI_ARB 0x200F -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_STEREO_ARB 0x2012 -#define WGL_PIXEL_TYPE_ARB 0x2013 -#define WGL_COLOR_BITS_ARB 0x2014 -#define WGL_RED_BITS_ARB 0x2015 -#define WGL_RED_SHIFT_ARB 0x2016 -#define WGL_GREEN_BITS_ARB 0x2017 -#define WGL_GREEN_SHIFT_ARB 0x2018 -#define WGL_BLUE_BITS_ARB 0x2019 -#define WGL_BLUE_SHIFT_ARB 0x201A -#define WGL_ALPHA_BITS_ARB 0x201B -#define WGL_ALPHA_SHIFT_ARB 0x201C -#define WGL_ACCUM_BITS_ARB 0x201D -#define WGL_ACCUM_RED_BITS_ARB 0x201E -#define WGL_ACCUM_GREEN_BITS_ARB 0x201F -#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 -#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 -#define WGL_AUX_BUFFERS_ARB 0x2024 -#define WGL_NO_ACCELERATION_ARB 0x2025 -#define WGL_GENERIC_ACCELERATION_ARB 0x2026 -#define WGL_FULL_ACCELERATION_ARB 0x2027 -#define WGL_SWAP_EXCHANGE_ARB 0x2028 -#define WGL_SWAP_COPY_ARB 0x2029 -#define WGL_SWAP_UNDEFINED_ARB 0x202A -#define WGL_TYPE_RGBA_ARB 0x202B -#define WGL_TYPE_COLORINDEX_ARB 0x202C -#endif - -#ifndef WGL_ARB_make_current_read -#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 -#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 -#endif - -#ifndef WGL_ARB_pbuffer -#define WGL_DRAW_TO_PBUFFER_ARB 0x202D -#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E -#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 -#define WGL_PBUFFER_LARGEST_ARB 0x2033 -#define WGL_PBUFFER_WIDTH_ARB 0x2034 -#define WGL_PBUFFER_HEIGHT_ARB 0x2035 -#define WGL_PBUFFER_LOST_ARB 0x2036 -#endif - -#ifndef WGL_ARB_render_texture -#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 -#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 -#define WGL_TEXTURE_FORMAT_ARB 0x2072 -#define WGL_TEXTURE_TARGET_ARB 0x2073 -#define WGL_MIPMAP_TEXTURE_ARB 0x2074 -#define WGL_TEXTURE_RGB_ARB 0x2075 -#define WGL_TEXTURE_RGBA_ARB 0x2076 -#define WGL_NO_TEXTURE_ARB 0x2077 -#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 -#define WGL_TEXTURE_1D_ARB 0x2079 -#define WGL_TEXTURE_2D_ARB 0x207A -#define WGL_MIPMAP_LEVEL_ARB 0x207B -#define WGL_CUBE_MAP_FACE_ARB 0x207C -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 -#define WGL_FRONT_LEFT_ARB 0x2083 -#define WGL_FRONT_RIGHT_ARB 0x2084 -#define WGL_BACK_LEFT_ARB 0x2085 -#define WGL_BACK_RIGHT_ARB 0x2086 -#define WGL_AUX0_ARB 0x2087 -#define WGL_AUX1_ARB 0x2088 -#define WGL_AUX2_ARB 0x2089 -#define WGL_AUX3_ARB 0x208A -#define WGL_AUX4_ARB 0x208B -#define WGL_AUX5_ARB 0x208C -#define WGL_AUX6_ARB 0x208D -#define WGL_AUX7_ARB 0x208E -#define WGL_AUX8_ARB 0x208F -#define WGL_AUX9_ARB 0x2090 -#endif - -#ifndef WGL_ARB_pixel_format_float -#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 -#endif - -#ifndef WGL_EXT_make_current_read -#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 -#endif - -#ifndef WGL_EXT_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 -#define WGL_DRAW_TO_WINDOW_EXT 0x2001 -#define WGL_DRAW_TO_BITMAP_EXT 0x2002 -#define WGL_ACCELERATION_EXT 0x2003 -#define WGL_NEED_PALETTE_EXT 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 -#define WGL_SWAP_METHOD_EXT 0x2007 -#define WGL_NUMBER_OVERLAYS_EXT 0x2008 -#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 -#define WGL_TRANSPARENT_EXT 0x200A -#define WGL_TRANSPARENT_VALUE_EXT 0x200B -#define WGL_SHARE_DEPTH_EXT 0x200C -#define WGL_SHARE_STENCIL_EXT 0x200D -#define WGL_SHARE_ACCUM_EXT 0x200E -#define WGL_SUPPORT_GDI_EXT 0x200F -#define WGL_SUPPORT_OPENGL_EXT 0x2010 -#define WGL_DOUBLE_BUFFER_EXT 0x2011 -#define WGL_STEREO_EXT 0x2012 -#define WGL_PIXEL_TYPE_EXT 0x2013 -#define WGL_COLOR_BITS_EXT 0x2014 -#define WGL_RED_BITS_EXT 0x2015 -#define WGL_RED_SHIFT_EXT 0x2016 -#define WGL_GREEN_BITS_EXT 0x2017 -#define WGL_GREEN_SHIFT_EXT 0x2018 -#define WGL_BLUE_BITS_EXT 0x2019 -#define WGL_BLUE_SHIFT_EXT 0x201A -#define WGL_ALPHA_BITS_EXT 0x201B -#define WGL_ALPHA_SHIFT_EXT 0x201C -#define WGL_ACCUM_BITS_EXT 0x201D -#define WGL_ACCUM_RED_BITS_EXT 0x201E -#define WGL_ACCUM_GREEN_BITS_EXT 0x201F -#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 -#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 -#define WGL_DEPTH_BITS_EXT 0x2022 -#define WGL_STENCIL_BITS_EXT 0x2023 -#define WGL_AUX_BUFFERS_EXT 0x2024 -#define WGL_NO_ACCELERATION_EXT 0x2025 -#define WGL_GENERIC_ACCELERATION_EXT 0x2026 -#define WGL_FULL_ACCELERATION_EXT 0x2027 -#define WGL_SWAP_EXCHANGE_EXT 0x2028 -#define WGL_SWAP_COPY_EXT 0x2029 -#define WGL_SWAP_UNDEFINED_EXT 0x202A -#define WGL_TYPE_RGBA_EXT 0x202B -#define WGL_TYPE_COLORINDEX_EXT 0x202C -#endif - -#ifndef WGL_EXT_pbuffer -#define WGL_DRAW_TO_PBUFFER_EXT 0x202D -#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E -#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 -#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 -#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 -#define WGL_PBUFFER_LARGEST_EXT 0x2033 -#define WGL_PBUFFER_WIDTH_EXT 0x2034 -#define WGL_PBUFFER_HEIGHT_EXT 0x2035 -#endif - -#ifndef WGL_EXT_depth_float -#define WGL_DEPTH_FLOAT_EXT 0x2040 -#endif - -#ifndef WGL_3DFX_multisample -#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 -#define WGL_SAMPLES_3DFX 0x2061 -#endif - -#ifndef WGL_EXT_multisample -#define WGL_SAMPLE_BUFFERS_EXT 0x2041 -#define WGL_SAMPLES_EXT 0x2042 -#endif - -#ifndef WGL_I3D_digital_video_control -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 -#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 -#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 -#endif - -#ifndef WGL_I3D_gamma -#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E -#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F -#endif - -#ifndef WGL_I3D_genlock -#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 -#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045 -#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046 -#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047 -#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 -#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 -#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A -#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B -#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C -#endif - -#ifndef WGL_I3D_image_buffer -#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 -#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 -#endif - -#ifndef WGL_I3D_swap_frame_lock -#endif - -#ifndef WGL_NV_render_depth_texture -#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 -#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 -#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 -#define WGL_DEPTH_COMPONENT_NV 0x20A7 -#endif - -#ifndef WGL_NV_render_texture_rectangle -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 -#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 -#endif - -#ifndef WGL_ATI_pixel_format_float -#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 -#endif - -#ifndef WGL_NV_float_buffer -#define WGL_FLOAT_COMPONENTS_NV 0x20B0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 -#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 -#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 -#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 -#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 -#endif - - -/*************************************************************/ - -#ifndef WGL_ARB_pbuffer -DECLARE_HANDLE(HPBUFFERARB); -#endif -#ifndef WGL_EXT_pbuffer -DECLARE_HANDLE(HPBUFFEREXT); -#endif - -#ifndef WGL_ARB_buffer_region -#define WGL_ARB_buffer_region 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HANDLE WINAPI wglCreateBufferRegionARB (HDC, int, UINT); -extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE); -extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE, int, int, int, int); -extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE, int, int, int, int, int, int); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); -typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); -typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); -typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); -#endif - -#ifndef WGL_ARB_multisample -#define WGL_ARB_multisample 1 -#endif - -#ifndef WGL_ARB_extensions_string -#define WGL_ARB_extensions_string 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern const char * WINAPI wglGetExtensionsStringARB (HDC); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); -#endif - -#ifndef WGL_ARB_pixel_format -#define WGL_ARB_pixel_format 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC, int, int, UINT, const int *, int *); -extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC, int, int, UINT, const int *, FLOAT *); -extern BOOL WINAPI wglChoosePixelFormatARB (HDC, const int *, const FLOAT *, UINT, int *, UINT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif - -#ifndef WGL_ARB_make_current_read -#define WGL_ARB_make_current_read 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglMakeContextCurrentARB (HDC, HDC, HGLRC); -extern HDC WINAPI wglGetCurrentReadDCARB (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); -#endif - -#ifndef WGL_ARB_pbuffer -#define WGL_ARB_pbuffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC, int, int, int, const int *); -extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB); -extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB, HDC); -extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB); -extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB, int, int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); -#endif - -#ifndef WGL_ARB_render_texture -#define WGL_ARB_render_texture 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB, int); -extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB, int); -extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB, const int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); -#endif - -#ifndef WGL_ARB_pixel_format_float -#define WGL_ARB_pixel_format_float 1 -#endif - -#ifndef WGL_EXT_display_color_table -#define WGL_EXT_display_color_table 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort); -extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *, GLuint); -extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort); -extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); -typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); -#endif - -#ifndef WGL_EXT_extensions_string -#define WGL_EXT_extensions_string 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern const char * WINAPI wglGetExtensionsStringEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); -#endif - -#ifndef WGL_EXT_make_current_read -#define WGL_EXT_make_current_read 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglMakeContextCurrentEXT (HDC, HDC, HGLRC); -extern HDC WINAPI wglGetCurrentReadDCEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); -typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); -#endif - -#ifndef WGL_EXT_pbuffer -#define WGL_EXT_pbuffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC, int, int, int, const int *); -extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT); -extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT, HDC); -extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT); -extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT, int, int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); -#endif - -#ifndef WGL_EXT_pixel_format -#define WGL_EXT_pixel_format 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC, int, int, UINT, int *, int *); -extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC, int, int, UINT, int *, FLOAT *); -extern BOOL WINAPI wglChoosePixelFormatEXT (HDC, const int *, const FLOAT *, UINT, int *, UINT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif - -#ifndef WGL_EXT_swap_control -#define WGL_EXT_swap_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglSwapIntervalEXT (int); -extern int WINAPI wglGetSwapIntervalEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); -typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); -#endif - -#ifndef WGL_EXT_depth_float -#define WGL_EXT_depth_float 1 -#endif - -#ifndef WGL_NV_vertex_array_range -#define WGL_NV_vertex_array_range 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern void* WINAPI wglAllocateMemoryNV (GLsizei, GLfloat, GLfloat, GLfloat); -extern void WINAPI wglFreeMemoryNV (void *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); -#endif - -#ifndef WGL_3DFX_multisample -#define WGL_3DFX_multisample 1 -#endif - -#ifndef WGL_EXT_multisample -#define WGL_EXT_multisample 1 -#endif - -#ifndef WGL_OML_sync_control -#define WGL_OML_sync_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetSyncValuesOML (HDC, INT64 *, INT64 *, INT64 *); -extern BOOL WINAPI wglGetMscRateOML (HDC, INT32 *, INT32 *); -extern INT64 WINAPI wglSwapBuffersMscOML (HDC, INT64, INT64, INT64); -extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC, int, INT64, INT64, INT64); -extern BOOL WINAPI wglWaitForMscOML (HDC, INT64, INT64, INT64, INT64 *, INT64 *, INT64 *); -extern BOOL WINAPI wglWaitForSbcOML (HDC, INT64, INT64 *, INT64 *, INT64 *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); -typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); -#endif - -#ifndef WGL_I3D_digital_video_control -#define WGL_I3D_digital_video_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC, int, int *); -extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC, int, const int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); -typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); -#endif - -#ifndef WGL_I3D_gamma -#define WGL_I3D_gamma 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC, int, int *); -extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC, int, const int *); -extern BOOL WINAPI wglGetGammaTableI3D (HDC, int, USHORT *, USHORT *, USHORT *); -extern BOOL WINAPI wglSetGammaTableI3D (HDC, int, const USHORT *, const USHORT *, const USHORT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); -typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); -typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); -typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); -#endif - -#ifndef WGL_I3D_genlock -#define WGL_I3D_genlock 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnableGenlockI3D (HDC); -extern BOOL WINAPI wglDisableGenlockI3D (HDC); -extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC, BOOL *); -extern BOOL WINAPI wglGenlockSourceI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSourceI3D (HDC, UINT *); -extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC, UINT *); -extern BOOL WINAPI wglGenlockSampleRateI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC, UINT *); -extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC, UINT *); -extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC, UINT *, UINT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); -typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); -typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge); -typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); -typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); -#endif - -#ifndef WGL_I3D_image_buffer -#define WGL_I3D_image_buffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern LPVOID WINAPI wglCreateImageBufferI3D (HDC, DWORD, UINT); -extern BOOL WINAPI wglDestroyImageBufferI3D (HDC, LPVOID); -extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC, const HANDLE *, const LPVOID *, const DWORD *, UINT); -extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC, const LPVOID *, UINT); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); -typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); -typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); -typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); -#endif - -#ifndef WGL_I3D_swap_frame_lock -#define WGL_I3D_swap_frame_lock 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnableFrameLockI3D (void); -extern BOOL WINAPI wglDisableFrameLockI3D (void); -extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *); -extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); -#endif - -#ifndef WGL_I3D_swap_frame_usage -#define WGL_I3D_swap_frame_usage 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetFrameUsageI3D (float *); -extern BOOL WINAPI wglBeginFrameTrackingI3D (void); -extern BOOL WINAPI wglEndFrameTrackingI3D (void); -extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *, DWORD *, float *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); -typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); -#endif - -#ifndef WGL_ATI_pixel_format_float -#define WGL_ATI_pixel_format_float 1 -#endif - -#ifndef WGL_NV_float_buffer -#define WGL_NV_float_buffer 1 -#endif - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/oversampling/WDL/lice/glew/include/GL/glew.h b/oversampling/WDL/lice/glew/include/GL/glew.h deleted file mode 100644 index 2014092..0000000 --- a/oversampling/WDL/lice/glew/include/GL/glew.h +++ /dev/null @@ -1,12262 +0,0 @@ -/* -** The OpenGL Extension Wrangler Library -** Copyright (C) 2002-2008, Milan Ikits -** Copyright (C) 2002-2008, Marcelo E. Magallon -** Copyright (C) 2002, Lev Povalahev -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** -** * Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** * The name of the author may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -** THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Mesa 3-D graphics library - * Version: 7.0 - * - * Copyright (C) 1999-2007 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 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are 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 Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#ifndef __glew_h__ -#define __glew_h__ -#define __GLEW_H__ - -#if defined(__gl_h_) || defined(__GL_H__) -#error gl.h included before glew.h -#endif -#if defined(__glext_h_) || defined(__GLEXT_H_) -#error glext.h included before glew.h -#endif -#if defined(__gl_ATI_h_) -#error glATI.h included before glew.h -#endif - -#define __gl_h_ -#define __GL_H__ -#define __glext_h_ -#define __GLEXT_H_ -#define __gl_ATI_h_ - -#if defined(_WIN32) - -/* - * GLEW does not include to avoid name space pollution. - * GL needs GLAPI and GLAPIENTRY, GLU needs APIENTRY, CALLBACK, and wchar_t - * defined properly. - */ -/* */ -#ifndef APIENTRY -#define GLEW_APIENTRY_DEFINED -# if defined(__MINGW32__) -# define APIENTRY __stdcall -# elif (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) -# define APIENTRY __stdcall -# else -# define APIENTRY -# endif -#endif -#ifndef GLAPI -# if defined(__MINGW32__) -# define GLAPI extern -# endif -#endif -/* */ -#ifndef CALLBACK -#define GLEW_CALLBACK_DEFINED -# if defined(__MINGW32__) -# define CALLBACK __attribute__ ((__stdcall__)) -# elif (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS) -# define CALLBACK __stdcall -# else -# define CALLBACK -# endif -#endif -/* and */ -#ifndef WINGDIAPI -#define GLEW_WINGDIAPI_DEFINED -#define WINGDIAPI __declspec(dllimport) -#endif -/* */ -#if (defined(_MSC_VER) || defined(__BORLANDC__)) && !defined(_WCHAR_T_DEFINED) -typedef unsigned short wchar_t; -# define _WCHAR_T_DEFINED -#endif -/* */ -#if !defined(_W64) -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && defined(_MSC_VER) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif -#endif -#if !defined(_PTRDIFF_T_DEFINED) && !defined(_PTRDIFF_T_) -# ifdef _WIN64 -typedef __int64 ptrdiff_t; -# else -typedef _W64 int ptrdiff_t; -# endif -# define _PTRDIFF_T_DEFINED -# define _PTRDIFF_T_ -#endif - -#ifndef GLAPI -# if defined(__MINGW32__) -# define GLAPI extern -# else -# define GLAPI WINGDIAPI -# endif -#endif - -#ifndef GLAPIENTRY -#define GLAPIENTRY APIENTRY -#endif - -/* - * GLEW_STATIC needs to be set when using the static version. - * GLEW_BUILD is set when building the DLL version. - */ -#ifdef GLEW_STATIC -# define GLEWAPI extern -#else -# ifdef GLEW_BUILD -# define GLEWAPI extern __declspec(dllexport) -# else -# define GLEWAPI extern __declspec(dllimport) -# endif -#endif - -#else /* _UNIX */ - -/* - * Needed for ptrdiff_t in turn needed by VBO. This is defined by ISO - * C. On my system, this amounts to _3 lines_ of included code, all of - * them pretty much harmless. If you know of a way of detecting 32 vs - * 64 _targets_ at compile time you are free to replace this with - * something that's portable. For now, _this_ is the portable solution. - * (mem, 2004-01-04) - */ - -#include -#include - -#define GLEW_APIENTRY_DEFINED -#define APIENTRY -#define GLEWAPI extern - -/* */ -#ifndef GLAPI -#define GLAPI extern -#endif -#ifndef GLAPIENTRY -#define GLAPIENTRY -#endif - -#endif /* _WIN32 */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* ----------------------------- GL_VERSION_1_1 ---------------------------- */ - -#ifndef GL_VERSION_1_1 -#define GL_VERSION_1_1 1 - -typedef unsigned int GLenum; -typedef unsigned int GLbitfield; -typedef unsigned int GLuint; -typedef int GLint; -typedef int GLsizei; -typedef unsigned char GLboolean; -typedef signed char GLbyte; -typedef short GLshort; -typedef unsigned char GLubyte; -typedef unsigned short GLushort; -typedef unsigned long GLulong; -typedef float GLfloat; -typedef float GLclampf; -typedef double GLdouble; -typedef double GLclampd; -typedef void GLvoid; -#if defined(_MSC_VER) -# if _MSC_VER < 1400 -typedef __int64 GLint64EXT; -typedef unsigned __int64 GLuint64EXT; -# else -typedef signed long long GLint64EXT; -typedef unsigned long long GLuint64EXT; -# endif -#else -# if defined(__MINGW32__) -#include -# endif -typedef int64_t GLint64EXT; -typedef uint64_t GLuint64EXT; -#endif - -#define GL_ACCUM 0x0100 -#define GL_LOAD 0x0101 -#define GL_RETURN 0x0102 -#define GL_MULT 0x0103 -#define GL_ADD 0x0104 -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 -#define GL_CURRENT_BIT 0x00000001 -#define GL_POINT_BIT 0x00000002 -#define GL_LINE_BIT 0x00000004 -#define GL_POLYGON_BIT 0x00000008 -#define GL_POLYGON_STIPPLE_BIT 0x00000010 -#define GL_PIXEL_MODE_BIT 0x00000020 -#define GL_LIGHTING_BIT 0x00000040 -#define GL_FOG_BIT 0x00000080 -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_ACCUM_BUFFER_BIT 0x00000200 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_VIEWPORT_BIT 0x00000800 -#define GL_TRANSFORM_BIT 0x00001000 -#define GL_ENABLE_BIT 0x00002000 -#define GL_COLOR_BUFFER_BIT 0x00004000 -#define GL_HINT_BIT 0x00008000 -#define GL_EVAL_BIT 0x00010000 -#define GL_LIST_BIT 0x00020000 -#define GL_TEXTURE_BIT 0x00040000 -#define GL_SCISSOR_BIT 0x00080000 -#define GL_ALL_ATTRIB_BITS 0x000fffff -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 -#define GL_QUADS 0x0007 -#define GL_QUAD_STRIP 0x0008 -#define GL_POLYGON 0x0009 -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -#define GL_TRUE 1 -#define GL_FALSE 0 -#define GL_CLIP_PLANE0 0x3000 -#define GL_CLIP_PLANE1 0x3001 -#define GL_CLIP_PLANE2 0x3002 -#define GL_CLIP_PLANE3 0x3003 -#define GL_CLIP_PLANE4 0x3004 -#define GL_CLIP_PLANE5 0x3005 -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_2_BYTES 0x1407 -#define GL_3_BYTES 0x1408 -#define GL_4_BYTES 0x1409 -#define GL_DOUBLE 0x140A -#define GL_NONE 0 -#define GL_FRONT_LEFT 0x0400 -#define GL_FRONT_RIGHT 0x0401 -#define GL_BACK_LEFT 0x0402 -#define GL_BACK_RIGHT 0x0403 -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_LEFT 0x0406 -#define GL_RIGHT 0x0407 -#define GL_FRONT_AND_BACK 0x0408 -#define GL_AUX0 0x0409 -#define GL_AUX1 0x040A -#define GL_AUX2 0x040B -#define GL_AUX3 0x040C -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_STACK_OVERFLOW 0x0503 -#define GL_STACK_UNDERFLOW 0x0504 -#define GL_OUT_OF_MEMORY 0x0505 -#define GL_2D 0x0600 -#define GL_3D 0x0601 -#define GL_3D_COLOR 0x0602 -#define GL_3D_COLOR_TEXTURE 0x0603 -#define GL_4D_COLOR_TEXTURE 0x0604 -#define GL_PASS_THROUGH_TOKEN 0x0700 -#define GL_POINT_TOKEN 0x0701 -#define GL_LINE_TOKEN 0x0702 -#define GL_POLYGON_TOKEN 0x0703 -#define GL_BITMAP_TOKEN 0x0704 -#define GL_DRAW_PIXEL_TOKEN 0x0705 -#define GL_COPY_PIXEL_TOKEN 0x0706 -#define GL_LINE_RESET_TOKEN 0x0707 -#define GL_EXP 0x0800 -#define GL_EXP2 0x0801 -#define GL_CW 0x0900 -#define GL_CCW 0x0901 -#define GL_COEFF 0x0A00 -#define GL_ORDER 0x0A01 -#define GL_DOMAIN 0x0A02 -#define GL_CURRENT_COLOR 0x0B00 -#define GL_CURRENT_INDEX 0x0B01 -#define GL_CURRENT_NORMAL 0x0B02 -#define GL_CURRENT_TEXTURE_COORDS 0x0B03 -#define GL_CURRENT_RASTER_COLOR 0x0B04 -#define GL_CURRENT_RASTER_INDEX 0x0B05 -#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06 -#define GL_CURRENT_RASTER_POSITION 0x0B07 -#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08 -#define GL_CURRENT_RASTER_DISTANCE 0x0B09 -#define GL_POINT_SMOOTH 0x0B10 -#define GL_POINT_SIZE 0x0B11 -#define GL_POINT_SIZE_RANGE 0x0B12 -#define GL_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_LINE_SMOOTH 0x0B20 -#define GL_LINE_WIDTH 0x0B21 -#define GL_LINE_WIDTH_RANGE 0x0B22 -#define GL_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_LINE_STIPPLE 0x0B24 -#define GL_LINE_STIPPLE_PATTERN 0x0B25 -#define GL_LINE_STIPPLE_REPEAT 0x0B26 -#define GL_LIST_MODE 0x0B30 -#define GL_MAX_LIST_NESTING 0x0B31 -#define GL_LIST_BASE 0x0B32 -#define GL_LIST_INDEX 0x0B33 -#define GL_POLYGON_MODE 0x0B40 -#define GL_POLYGON_SMOOTH 0x0B41 -#define GL_POLYGON_STIPPLE 0x0B42 -#define GL_EDGE_FLAG 0x0B43 -#define GL_CULL_FACE 0x0B44 -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_LIGHTING 0x0B50 -#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51 -#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 -#define GL_LIGHT_MODEL_AMBIENT 0x0B53 -#define GL_SHADE_MODEL 0x0B54 -#define GL_COLOR_MATERIAL_FACE 0x0B55 -#define GL_COLOR_MATERIAL_PARAMETER 0x0B56 -#define GL_COLOR_MATERIAL 0x0B57 -#define GL_FOG 0x0B60 -#define GL_FOG_INDEX 0x0B61 -#define GL_FOG_DENSITY 0x0B62 -#define GL_FOG_START 0x0B63 -#define GL_FOG_END 0x0B64 -#define GL_FOG_MODE 0x0B65 -#define GL_FOG_COLOR 0x0B66 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_TEST 0x0B71 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_ACCUM_CLEAR_VALUE 0x0B80 -#define GL_STENCIL_TEST 0x0B90 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_MATRIX_MODE 0x0BA0 -#define GL_NORMALIZE 0x0BA1 -#define GL_VIEWPORT 0x0BA2 -#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 -#define GL_PROJECTION_STACK_DEPTH 0x0BA4 -#define GL_TEXTURE_STACK_DEPTH 0x0BA5 -#define GL_MODELVIEW_MATRIX 0x0BA6 -#define GL_PROJECTION_MATRIX 0x0BA7 -#define GL_TEXTURE_MATRIX 0x0BA8 -#define GL_ATTRIB_STACK_DEPTH 0x0BB0 -#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1 -#define GL_ALPHA_TEST 0x0BC0 -#define GL_ALPHA_TEST_FUNC 0x0BC1 -#define GL_ALPHA_TEST_REF 0x0BC2 -#define GL_DITHER 0x0BD0 -#define GL_BLEND_DST 0x0BE0 -#define GL_BLEND_SRC 0x0BE1 -#define GL_BLEND 0x0BE2 -#define GL_LOGIC_OP_MODE 0x0BF0 -#define GL_INDEX_LOGIC_OP 0x0BF1 -#define GL_COLOR_LOGIC_OP 0x0BF2 -#define GL_AUX_BUFFERS 0x0C00 -#define GL_DRAW_BUFFER 0x0C01 -#define GL_READ_BUFFER 0x0C02 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_INDEX_CLEAR_VALUE 0x0C20 -#define GL_INDEX_WRITEMASK 0x0C21 -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_INDEX_MODE 0x0C30 -#define GL_RGBA_MODE 0x0C31 -#define GL_DOUBLEBUFFER 0x0C32 -#define GL_STEREO 0x0C33 -#define GL_RENDER_MODE 0x0C40 -#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 -#define GL_POINT_SMOOTH_HINT 0x0C51 -#define GL_LINE_SMOOTH_HINT 0x0C52 -#define GL_POLYGON_SMOOTH_HINT 0x0C53 -#define GL_FOG_HINT 0x0C54 -#define GL_TEXTURE_GEN_S 0x0C60 -#define GL_TEXTURE_GEN_T 0x0C61 -#define GL_TEXTURE_GEN_R 0x0C62 -#define GL_TEXTURE_GEN_Q 0x0C63 -#define GL_PIXEL_MAP_I_TO_I 0x0C70 -#define GL_PIXEL_MAP_S_TO_S 0x0C71 -#define GL_PIXEL_MAP_I_TO_R 0x0C72 -#define GL_PIXEL_MAP_I_TO_G 0x0C73 -#define GL_PIXEL_MAP_I_TO_B 0x0C74 -#define GL_PIXEL_MAP_I_TO_A 0x0C75 -#define GL_PIXEL_MAP_R_TO_R 0x0C76 -#define GL_PIXEL_MAP_G_TO_G 0x0C77 -#define GL_PIXEL_MAP_B_TO_B 0x0C78 -#define GL_PIXEL_MAP_A_TO_A 0x0C79 -#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0 -#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1 -#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2 -#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3 -#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4 -#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5 -#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6 -#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7 -#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8 -#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9 -#define GL_UNPACK_SWAP_BYTES 0x0CF0 -#define GL_UNPACK_LSB_FIRST 0x0CF1 -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#define GL_UNPACK_SKIP_ROWS 0x0CF3 -#define GL_UNPACK_SKIP_PIXELS 0x0CF4 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_SWAP_BYTES 0x0D00 -#define GL_PACK_LSB_FIRST 0x0D01 -#define GL_PACK_ROW_LENGTH 0x0D02 -#define GL_PACK_SKIP_ROWS 0x0D03 -#define GL_PACK_SKIP_PIXELS 0x0D04 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAP_COLOR 0x0D10 -#define GL_MAP_STENCIL 0x0D11 -#define GL_INDEX_SHIFT 0x0D12 -#define GL_INDEX_OFFSET 0x0D13 -#define GL_RED_SCALE 0x0D14 -#define GL_RED_BIAS 0x0D15 -#define GL_ZOOM_X 0x0D16 -#define GL_ZOOM_Y 0x0D17 -#define GL_GREEN_SCALE 0x0D18 -#define GL_GREEN_BIAS 0x0D19 -#define GL_BLUE_SCALE 0x0D1A -#define GL_BLUE_BIAS 0x0D1B -#define GL_ALPHA_SCALE 0x0D1C -#define GL_ALPHA_BIAS 0x0D1D -#define GL_DEPTH_SCALE 0x0D1E -#define GL_DEPTH_BIAS 0x0D1F -#define GL_MAX_EVAL_ORDER 0x0D30 -#define GL_MAX_LIGHTS 0x0D31 -#define GL_MAX_CLIP_PLANES 0x0D32 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_PIXEL_MAP_TABLE 0x0D34 -#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35 -#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 -#define GL_MAX_NAME_STACK_DEPTH 0x0D37 -#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 -#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_INDEX_BITS 0x0D51 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_ACCUM_RED_BITS 0x0D58 -#define GL_ACCUM_GREEN_BITS 0x0D59 -#define GL_ACCUM_BLUE_BITS 0x0D5A -#define GL_ACCUM_ALPHA_BITS 0x0D5B -#define GL_NAME_STACK_DEPTH 0x0D70 -#define GL_AUTO_NORMAL 0x0D80 -#define GL_MAP1_COLOR_4 0x0D90 -#define GL_MAP1_INDEX 0x0D91 -#define GL_MAP1_NORMAL 0x0D92 -#define GL_MAP1_TEXTURE_COORD_1 0x0D93 -#define GL_MAP1_TEXTURE_COORD_2 0x0D94 -#define GL_MAP1_TEXTURE_COORD_3 0x0D95 -#define GL_MAP1_TEXTURE_COORD_4 0x0D96 -#define GL_MAP1_VERTEX_3 0x0D97 -#define GL_MAP1_VERTEX_4 0x0D98 -#define GL_MAP2_COLOR_4 0x0DB0 -#define GL_MAP2_INDEX 0x0DB1 -#define GL_MAP2_NORMAL 0x0DB2 -#define GL_MAP2_TEXTURE_COORD_1 0x0DB3 -#define GL_MAP2_TEXTURE_COORD_2 0x0DB4 -#define GL_MAP2_TEXTURE_COORD_3 0x0DB5 -#define GL_MAP2_TEXTURE_COORD_4 0x0DB6 -#define GL_MAP2_VERTEX_3 0x0DB7 -#define GL_MAP2_VERTEX_4 0x0DB8 -#define GL_MAP1_GRID_DOMAIN 0x0DD0 -#define GL_MAP1_GRID_SEGMENTS 0x0DD1 -#define GL_MAP2_GRID_DOMAIN 0x0DD2 -#define GL_MAP2_GRID_SEGMENTS 0x0DD3 -#define GL_TEXTURE_1D 0x0DE0 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0 -#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1 -#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2 -#define GL_SELECTION_BUFFER_POINTER 0x0DF3 -#define GL_SELECTION_BUFFER_SIZE 0x0DF4 -#define GL_TEXTURE_WIDTH 0x1000 -#define GL_TEXTURE_HEIGHT 0x1001 -#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 -#define GL_TEXTURE_BORDER_COLOR 0x1004 -#define GL_TEXTURE_BORDER 0x1005 -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 -#define GL_LIGHT0 0x4000 -#define GL_LIGHT1 0x4001 -#define GL_LIGHT2 0x4002 -#define GL_LIGHT3 0x4003 -#define GL_LIGHT4 0x4004 -#define GL_LIGHT5 0x4005 -#define GL_LIGHT6 0x4006 -#define GL_LIGHT7 0x4007 -#define GL_AMBIENT 0x1200 -#define GL_DIFFUSE 0x1201 -#define GL_SPECULAR 0x1202 -#define GL_POSITION 0x1203 -#define GL_SPOT_DIRECTION 0x1204 -#define GL_SPOT_EXPONENT 0x1205 -#define GL_SPOT_CUTOFF 0x1206 -#define GL_CONSTANT_ATTENUATION 0x1207 -#define GL_LINEAR_ATTENUATION 0x1208 -#define GL_QUADRATIC_ATTENUATION 0x1209 -#define GL_COMPILE 0x1300 -#define GL_COMPILE_AND_EXECUTE 0x1301 -#define GL_CLEAR 0x1500 -#define GL_AND 0x1501 -#define GL_AND_REVERSE 0x1502 -#define GL_COPY 0x1503 -#define GL_AND_INVERTED 0x1504 -#define GL_NOOP 0x1505 -#define GL_XOR 0x1506 -#define GL_OR 0x1507 -#define GL_NOR 0x1508 -#define GL_EQUIV 0x1509 -#define GL_INVERT 0x150A -#define GL_OR_REVERSE 0x150B -#define GL_COPY_INVERTED 0x150C -#define GL_OR_INVERTED 0x150D -#define GL_NAND 0x150E -#define GL_SET 0x150F -#define GL_EMISSION 0x1600 -#define GL_SHININESS 0x1601 -#define GL_AMBIENT_AND_DIFFUSE 0x1602 -#define GL_COLOR_INDEXES 0x1603 -#define GL_MODELVIEW 0x1700 -#define GL_PROJECTION 0x1701 -#define GL_TEXTURE 0x1702 -#define GL_COLOR 0x1800 -#define GL_DEPTH 0x1801 -#define GL_STENCIL 0x1802 -#define GL_COLOR_INDEX 0x1900 -#define GL_STENCIL_INDEX 0x1901 -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_RED 0x1903 -#define GL_GREEN 0x1904 -#define GL_BLUE 0x1905 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A -#define GL_BITMAP 0x1A00 -#define GL_POINT 0x1B00 -#define GL_LINE 0x1B01 -#define GL_FILL 0x1B02 -#define GL_RENDER 0x1C00 -#define GL_FEEDBACK 0x1C01 -#define GL_SELECT 0x1C02 -#define GL_FLAT 0x1D00 -#define GL_SMOOTH 0x1D01 -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 -#define GL_S 0x2000 -#define GL_T 0x2001 -#define GL_R 0x2002 -#define GL_Q 0x2003 -#define GL_MODULATE 0x2100 -#define GL_DECAL 0x2101 -#define GL_TEXTURE_ENV_MODE 0x2200 -#define GL_TEXTURE_ENV_COLOR 0x2201 -#define GL_TEXTURE_ENV 0x2300 -#define GL_EYE_LINEAR 0x2400 -#define GL_OBJECT_LINEAR 0x2401 -#define GL_SPHERE_MAP 0x2402 -#define GL_TEXTURE_GEN_MODE 0x2500 -#define GL_OBJECT_PLANE 0x2501 -#define GL_EYE_PLANE 0x2502 -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -#define GL_CLAMP 0x2900 -#define GL_REPEAT 0x2901 -#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001 -#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002 -#define GL_CLIENT_ALL_ATTRIB_BITS 0xffffffff -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_POINT 0x2A01 -#define GL_POLYGON_OFFSET_LINE 0x2A02 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_ALPHA4 0x803B -#define GL_ALPHA8 0x803C -#define GL_ALPHA12 0x803D -#define GL_ALPHA16 0x803E -#define GL_LUMINANCE4 0x803F -#define GL_LUMINANCE8 0x8040 -#define GL_LUMINANCE12 0x8041 -#define GL_LUMINANCE16 0x8042 -#define GL_LUMINANCE4_ALPHA4 0x8043 -#define GL_LUMINANCE6_ALPHA2 0x8044 -#define GL_LUMINANCE8_ALPHA8 0x8045 -#define GL_LUMINANCE12_ALPHA4 0x8046 -#define GL_LUMINANCE12_ALPHA12 0x8047 -#define GL_LUMINANCE16_ALPHA16 0x8048 -#define GL_INTENSITY 0x8049 -#define GL_INTENSITY4 0x804A -#define GL_INTENSITY8 0x804B -#define GL_INTENSITY12 0x804C -#define GL_INTENSITY16 0x804D -#define GL_R3_G3_B2 0x2A10 -#define GL_RGB4 0x804F -#define GL_RGB5 0x8050 -#define GL_RGB8 0x8051 -#define GL_RGB10 0x8052 -#define GL_RGB12 0x8053 -#define GL_RGB16 0x8054 -#define GL_RGBA2 0x8055 -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGBA8 0x8058 -#define GL_RGB10_A2 0x8059 -#define GL_RGBA12 0x805A -#define GL_RGBA16 0x805B -#define GL_TEXTURE_RED_SIZE 0x805C -#define GL_TEXTURE_GREEN_SIZE 0x805D -#define GL_TEXTURE_BLUE_SIZE 0x805E -#define GL_TEXTURE_ALPHA_SIZE 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE 0x8061 -#define GL_PROXY_TEXTURE_1D 0x8063 -#define GL_PROXY_TEXTURE_2D 0x8064 -#define GL_TEXTURE_PRIORITY 0x8066 -#define GL_TEXTURE_RESIDENT 0x8067 -#define GL_TEXTURE_BINDING_1D 0x8068 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_VERTEX_ARRAY 0x8074 -#define GL_NORMAL_ARRAY 0x8075 -#define GL_COLOR_ARRAY 0x8076 -#define GL_INDEX_ARRAY 0x8077 -#define GL_TEXTURE_COORD_ARRAY 0x8078 -#define GL_EDGE_FLAG_ARRAY 0x8079 -#define GL_VERTEX_ARRAY_SIZE 0x807A -#define GL_VERTEX_ARRAY_TYPE 0x807B -#define GL_VERTEX_ARRAY_STRIDE 0x807C -#define GL_NORMAL_ARRAY_TYPE 0x807E -#define GL_NORMAL_ARRAY_STRIDE 0x807F -#define GL_COLOR_ARRAY_SIZE 0x8081 -#define GL_COLOR_ARRAY_TYPE 0x8082 -#define GL_COLOR_ARRAY_STRIDE 0x8083 -#define GL_INDEX_ARRAY_TYPE 0x8085 -#define GL_INDEX_ARRAY_STRIDE 0x8086 -#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A -#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C -#define GL_VERTEX_ARRAY_POINTER 0x808E -#define GL_NORMAL_ARRAY_POINTER 0x808F -#define GL_COLOR_ARRAY_POINTER 0x8090 -#define GL_INDEX_ARRAY_POINTER 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093 -#define GL_V2F 0x2A20 -#define GL_V3F 0x2A21 -#define GL_C4UB_V2F 0x2A22 -#define GL_C4UB_V3F 0x2A23 -#define GL_C3F_V3F 0x2A24 -#define GL_N3F_V3F 0x2A25 -#define GL_C4F_N3F_V3F 0x2A26 -#define GL_T2F_V3F 0x2A27 -#define GL_T4F_V4F 0x2A28 -#define GL_T2F_C4UB_V3F 0x2A29 -#define GL_T2F_C3F_V3F 0x2A2A -#define GL_T2F_N3F_V3F 0x2A2B -#define GL_T2F_C4F_N3F_V3F 0x2A2C -#define GL_T4F_C4F_N3F_V4F 0x2A2D -#define GL_LOGIC_OP GL_INDEX_LOGIC_OP -#define GL_TEXTURE_COMPONENTS GL_TEXTURE_INTERNAL_FORMAT -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 - -GLAPI void GLAPIENTRY glAccum (GLenum op, GLfloat value); -GLAPI void GLAPIENTRY glAlphaFunc (GLenum func, GLclampf ref); -GLAPI GLboolean GLAPIENTRY glAreTexturesResident (GLsizei n, const GLuint *textures, GLboolean *residences); -GLAPI void GLAPIENTRY glArrayElement (GLint i); -GLAPI void GLAPIENTRY glBegin (GLenum mode); -GLAPI void GLAPIENTRY glBindTexture (GLenum target, GLuint texture); -GLAPI void GLAPIENTRY glBitmap (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); -GLAPI void GLAPIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); -GLAPI void GLAPIENTRY glCallList (GLuint list); -GLAPI void GLAPIENTRY glCallLists (GLsizei n, GLenum type, const GLvoid *lists); -GLAPI void GLAPIENTRY glClear (GLbitfield mask); -GLAPI void GLAPIENTRY glClearAccum (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -GLAPI void GLAPIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GLAPI void GLAPIENTRY glClearDepth (GLclampd depth); -GLAPI void GLAPIENTRY glClearIndex (GLfloat c); -GLAPI void GLAPIENTRY glClearStencil (GLint s); -GLAPI void GLAPIENTRY glClipPlane (GLenum plane, const GLdouble *equation); -GLAPI void GLAPIENTRY glColor3b (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void GLAPIENTRY glColor3bv (const GLbyte *v); -GLAPI void GLAPIENTRY glColor3d (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void GLAPIENTRY glColor3dv (const GLdouble *v); -GLAPI void GLAPIENTRY glColor3f (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void GLAPIENTRY glColor3fv (const GLfloat *v); -GLAPI void GLAPIENTRY glColor3i (GLint red, GLint green, GLint blue); -GLAPI void GLAPIENTRY glColor3iv (const GLint *v); -GLAPI void GLAPIENTRY glColor3s (GLshort red, GLshort green, GLshort blue); -GLAPI void GLAPIENTRY glColor3sv (const GLshort *v); -GLAPI void GLAPIENTRY glColor3ub (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void GLAPIENTRY glColor3ubv (const GLubyte *v); -GLAPI void GLAPIENTRY glColor3ui (GLuint red, GLuint green, GLuint blue); -GLAPI void GLAPIENTRY glColor3uiv (const GLuint *v); -GLAPI void GLAPIENTRY glColor3us (GLushort red, GLushort green, GLushort blue); -GLAPI void GLAPIENTRY glColor3usv (const GLushort *v); -GLAPI void GLAPIENTRY glColor4b (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); -GLAPI void GLAPIENTRY glColor4bv (const GLbyte *v); -GLAPI void GLAPIENTRY glColor4d (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); -GLAPI void GLAPIENTRY glColor4dv (const GLdouble *v); -GLAPI void GLAPIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -GLAPI void GLAPIENTRY glColor4fv (const GLfloat *v); -GLAPI void GLAPIENTRY glColor4i (GLint red, GLint green, GLint blue, GLint alpha); -GLAPI void GLAPIENTRY glColor4iv (const GLint *v); -GLAPI void GLAPIENTRY glColor4s (GLshort red, GLshort green, GLshort blue, GLshort alpha); -GLAPI void GLAPIENTRY glColor4sv (const GLshort *v); -GLAPI void GLAPIENTRY glColor4ub (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); -GLAPI void GLAPIENTRY glColor4ubv (const GLubyte *v); -GLAPI void GLAPIENTRY glColor4ui (GLuint red, GLuint green, GLuint blue, GLuint alpha); -GLAPI void GLAPIENTRY glColor4uiv (const GLuint *v); -GLAPI void GLAPIENTRY glColor4us (GLushort red, GLushort green, GLushort blue, GLushort alpha); -GLAPI void GLAPIENTRY glColor4usv (const GLushort *v); -GLAPI void GLAPIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -GLAPI void GLAPIENTRY glColorMaterial (GLenum face, GLenum mode); -GLAPI void GLAPIENTRY glColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void GLAPIENTRY glCopyPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); -GLAPI void GLAPIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void GLAPIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void GLAPIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void GLAPIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void GLAPIENTRY glCullFace (GLenum mode); -GLAPI void GLAPIENTRY glDeleteLists (GLuint list, GLsizei range); -GLAPI void GLAPIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); -GLAPI void GLAPIENTRY glDepthFunc (GLenum func); -GLAPI void GLAPIENTRY glDepthMask (GLboolean flag); -GLAPI void GLAPIENTRY glDepthRange (GLclampd zNear, GLclampd zFar); -GLAPI void GLAPIENTRY glDisable (GLenum cap); -GLAPI void GLAPIENTRY glDisableClientState (GLenum array); -GLAPI void GLAPIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); -GLAPI void GLAPIENTRY glDrawBuffer (GLenum mode); -GLAPI void GLAPIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); -GLAPI void GLAPIENTRY glDrawPixels (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void GLAPIENTRY glEdgeFlag (GLboolean flag); -GLAPI void GLAPIENTRY glEdgeFlagPointer (GLsizei stride, const GLvoid *pointer); -GLAPI void GLAPIENTRY glEdgeFlagv (const GLboolean *flag); -GLAPI void GLAPIENTRY glEnable (GLenum cap); -GLAPI void GLAPIENTRY glEnableClientState (GLenum array); -GLAPI void GLAPIENTRY glEnd (void); -GLAPI void GLAPIENTRY glEndList (void); -GLAPI void GLAPIENTRY glEvalCoord1d (GLdouble u); -GLAPI void GLAPIENTRY glEvalCoord1dv (const GLdouble *u); -GLAPI void GLAPIENTRY glEvalCoord1f (GLfloat u); -GLAPI void GLAPIENTRY glEvalCoord1fv (const GLfloat *u); -GLAPI void GLAPIENTRY glEvalCoord2d (GLdouble u, GLdouble v); -GLAPI void GLAPIENTRY glEvalCoord2dv (const GLdouble *u); -GLAPI void GLAPIENTRY glEvalCoord2f (GLfloat u, GLfloat v); -GLAPI void GLAPIENTRY glEvalCoord2fv (const GLfloat *u); -GLAPI void GLAPIENTRY glEvalMesh1 (GLenum mode, GLint i1, GLint i2); -GLAPI void GLAPIENTRY glEvalMesh2 (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); -GLAPI void GLAPIENTRY glEvalPoint1 (GLint i); -GLAPI void GLAPIENTRY glEvalPoint2 (GLint i, GLint j); -GLAPI void GLAPIENTRY glFeedbackBuffer (GLsizei size, GLenum type, GLfloat *buffer); -GLAPI void GLAPIENTRY glFinish (void); -GLAPI void GLAPIENTRY glFlush (void); -GLAPI void GLAPIENTRY glFogf (GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glFogfv (GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glFogi (GLenum pname, GLint param); -GLAPI void GLAPIENTRY glFogiv (GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glFrontFace (GLenum mode); -GLAPI void GLAPIENTRY glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI GLuint GLAPIENTRY glGenLists (GLsizei range); -GLAPI void GLAPIENTRY glGenTextures (GLsizei n, GLuint *textures); -GLAPI void GLAPIENTRY glGetBooleanv (GLenum pname, GLboolean *params); -GLAPI void GLAPIENTRY glGetClipPlane (GLenum plane, GLdouble *equation); -GLAPI void GLAPIENTRY glGetDoublev (GLenum pname, GLdouble *params); -GLAPI GLenum GLAPIENTRY glGetError (void); -GLAPI void GLAPIENTRY glGetFloatv (GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetIntegerv (GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetLightiv (GLenum light, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetMapdv (GLenum target, GLenum query, GLdouble *v); -GLAPI void GLAPIENTRY glGetMapfv (GLenum target, GLenum query, GLfloat *v); -GLAPI void GLAPIENTRY glGetMapiv (GLenum target, GLenum query, GLint *v); -GLAPI void GLAPIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetMaterialiv (GLenum face, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetPixelMapfv (GLenum map, GLfloat *values); -GLAPI void GLAPIENTRY glGetPixelMapuiv (GLenum map, GLuint *values); -GLAPI void GLAPIENTRY glGetPixelMapusv (GLenum map, GLushort *values); -GLAPI void GLAPIENTRY glGetPointerv (GLenum pname, GLvoid* *params); -GLAPI void GLAPIENTRY glGetPolygonStipple (GLubyte *mask); -GLAPI const GLubyte * GLAPIENTRY glGetString (GLenum name); -GLAPI void GLAPIENTRY glGetTexEnvfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetTexEnviv (GLenum target, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetTexGendv (GLenum coord, GLenum pname, GLdouble *params); -GLAPI void GLAPIENTRY glGetTexGenfv (GLenum coord, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetTexGeniv (GLenum coord, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -GLAPI void GLAPIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void GLAPIENTRY glHint (GLenum target, GLenum mode); -GLAPI void GLAPIENTRY glIndexMask (GLuint mask); -GLAPI void GLAPIENTRY glIndexPointer (GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void GLAPIENTRY glIndexd (GLdouble c); -GLAPI void GLAPIENTRY glIndexdv (const GLdouble *c); -GLAPI void GLAPIENTRY glIndexf (GLfloat c); -GLAPI void GLAPIENTRY glIndexfv (const GLfloat *c); -GLAPI void GLAPIENTRY glIndexi (GLint c); -GLAPI void GLAPIENTRY glIndexiv (const GLint *c); -GLAPI void GLAPIENTRY glIndexs (GLshort c); -GLAPI void GLAPIENTRY glIndexsv (const GLshort *c); -GLAPI void GLAPIENTRY glIndexub (GLubyte c); -GLAPI void GLAPIENTRY glIndexubv (const GLubyte *c); -GLAPI void GLAPIENTRY glInitNames (void); -GLAPI void GLAPIENTRY glInterleavedArrays (GLenum format, GLsizei stride, const GLvoid *pointer); -GLAPI GLboolean GLAPIENTRY glIsEnabled (GLenum cap); -GLAPI GLboolean GLAPIENTRY glIsList (GLuint list); -GLAPI GLboolean GLAPIENTRY glIsTexture (GLuint texture); -GLAPI void GLAPIENTRY glLightModelf (GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glLightModelfv (GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glLightModeli (GLenum pname, GLint param); -GLAPI void GLAPIENTRY glLightModeliv (GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glLightf (GLenum light, GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glLightfv (GLenum light, GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glLighti (GLenum light, GLenum pname, GLint param); -GLAPI void GLAPIENTRY glLightiv (GLenum light, GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glLineStipple (GLint factor, GLushort pattern); -GLAPI void GLAPIENTRY glLineWidth (GLfloat width); -GLAPI void GLAPIENTRY glListBase (GLuint base); -GLAPI void GLAPIENTRY glLoadIdentity (void); -GLAPI void GLAPIENTRY glLoadMatrixd (const GLdouble *m); -GLAPI void GLAPIENTRY glLoadMatrixf (const GLfloat *m); -GLAPI void GLAPIENTRY glLoadName (GLuint name); -GLAPI void GLAPIENTRY glLogicOp (GLenum opcode); -GLAPI void GLAPIENTRY glMap1d (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -GLAPI void GLAPIENTRY glMap1f (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -GLAPI void GLAPIENTRY glMap2d (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -GLAPI void GLAPIENTRY glMap2f (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -GLAPI void GLAPIENTRY glMapGrid1d (GLint un, GLdouble u1, GLdouble u2); -GLAPI void GLAPIENTRY glMapGrid1f (GLint un, GLfloat u1, GLfloat u2); -GLAPI void GLAPIENTRY glMapGrid2d (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); -GLAPI void GLAPIENTRY glMapGrid2f (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); -GLAPI void GLAPIENTRY glMaterialf (GLenum face, GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glMaterialfv (GLenum face, GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glMateriali (GLenum face, GLenum pname, GLint param); -GLAPI void GLAPIENTRY glMaterialiv (GLenum face, GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glMatrixMode (GLenum mode); -GLAPI void GLAPIENTRY glMultMatrixd (const GLdouble *m); -GLAPI void GLAPIENTRY glMultMatrixf (const GLfloat *m); -GLAPI void GLAPIENTRY glNewList (GLuint list, GLenum mode); -GLAPI void GLAPIENTRY glNormal3b (GLbyte nx, GLbyte ny, GLbyte nz); -GLAPI void GLAPIENTRY glNormal3bv (const GLbyte *v); -GLAPI void GLAPIENTRY glNormal3d (GLdouble nx, GLdouble ny, GLdouble nz); -GLAPI void GLAPIENTRY glNormal3dv (const GLdouble *v); -GLAPI void GLAPIENTRY glNormal3f (GLfloat nx, GLfloat ny, GLfloat nz); -GLAPI void GLAPIENTRY glNormal3fv (const GLfloat *v); -GLAPI void GLAPIENTRY glNormal3i (GLint nx, GLint ny, GLint nz); -GLAPI void GLAPIENTRY glNormal3iv (const GLint *v); -GLAPI void GLAPIENTRY glNormal3s (GLshort nx, GLshort ny, GLshort nz); -GLAPI void GLAPIENTRY glNormal3sv (const GLshort *v); -GLAPI void GLAPIENTRY glNormalPointer (GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void GLAPIENTRY glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void GLAPIENTRY glPassThrough (GLfloat token); -GLAPI void GLAPIENTRY glPixelMapfv (GLenum map, GLsizei mapsize, const GLfloat *values); -GLAPI void GLAPIENTRY glPixelMapuiv (GLenum map, GLsizei mapsize, const GLuint *values); -GLAPI void GLAPIENTRY glPixelMapusv (GLenum map, GLsizei mapsize, const GLushort *values); -GLAPI void GLAPIENTRY glPixelStoref (GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glPixelStorei (GLenum pname, GLint param); -GLAPI void GLAPIENTRY glPixelTransferf (GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glPixelTransferi (GLenum pname, GLint param); -GLAPI void GLAPIENTRY glPixelZoom (GLfloat xfactor, GLfloat yfactor); -GLAPI void GLAPIENTRY glPointSize (GLfloat size); -GLAPI void GLAPIENTRY glPolygonMode (GLenum face, GLenum mode); -GLAPI void GLAPIENTRY glPolygonOffset (GLfloat factor, GLfloat units); -GLAPI void GLAPIENTRY glPolygonStipple (const GLubyte *mask); -GLAPI void GLAPIENTRY glPopAttrib (void); -GLAPI void GLAPIENTRY glPopClientAttrib (void); -GLAPI void GLAPIENTRY glPopMatrix (void); -GLAPI void GLAPIENTRY glPopName (void); -GLAPI void GLAPIENTRY glPrioritizeTextures (GLsizei n, const GLuint *textures, const GLclampf *priorities); -GLAPI void GLAPIENTRY glPushAttrib (GLbitfield mask); -GLAPI void GLAPIENTRY glPushClientAttrib (GLbitfield mask); -GLAPI void GLAPIENTRY glPushMatrix (void); -GLAPI void GLAPIENTRY glPushName (GLuint name); -GLAPI void GLAPIENTRY glRasterPos2d (GLdouble x, GLdouble y); -GLAPI void GLAPIENTRY glRasterPos2dv (const GLdouble *v); -GLAPI void GLAPIENTRY glRasterPos2f (GLfloat x, GLfloat y); -GLAPI void GLAPIENTRY glRasterPos2fv (const GLfloat *v); -GLAPI void GLAPIENTRY glRasterPos2i (GLint x, GLint y); -GLAPI void GLAPIENTRY glRasterPos2iv (const GLint *v); -GLAPI void GLAPIENTRY glRasterPos2s (GLshort x, GLshort y); -GLAPI void GLAPIENTRY glRasterPos2sv (const GLshort *v); -GLAPI void GLAPIENTRY glRasterPos3d (GLdouble x, GLdouble y, GLdouble z); -GLAPI void GLAPIENTRY glRasterPos3dv (const GLdouble *v); -GLAPI void GLAPIENTRY glRasterPos3f (GLfloat x, GLfloat y, GLfloat z); -GLAPI void GLAPIENTRY glRasterPos3fv (const GLfloat *v); -GLAPI void GLAPIENTRY glRasterPos3i (GLint x, GLint y, GLint z); -GLAPI void GLAPIENTRY glRasterPos3iv (const GLint *v); -GLAPI void GLAPIENTRY glRasterPos3s (GLshort x, GLshort y, GLshort z); -GLAPI void GLAPIENTRY glRasterPos3sv (const GLshort *v); -GLAPI void GLAPIENTRY glRasterPos4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void GLAPIENTRY glRasterPos4dv (const GLdouble *v); -GLAPI void GLAPIENTRY glRasterPos4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void GLAPIENTRY glRasterPos4fv (const GLfloat *v); -GLAPI void GLAPIENTRY glRasterPos4i (GLint x, GLint y, GLint z, GLint w); -GLAPI void GLAPIENTRY glRasterPos4iv (const GLint *v); -GLAPI void GLAPIENTRY glRasterPos4s (GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void GLAPIENTRY glRasterPos4sv (const GLshort *v); -GLAPI void GLAPIENTRY glReadBuffer (GLenum mode); -GLAPI void GLAPIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); -GLAPI void GLAPIENTRY glRectd (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); -GLAPI void GLAPIENTRY glRectdv (const GLdouble *v1, const GLdouble *v2); -GLAPI void GLAPIENTRY glRectf (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); -GLAPI void GLAPIENTRY glRectfv (const GLfloat *v1, const GLfloat *v2); -GLAPI void GLAPIENTRY glRecti (GLint x1, GLint y1, GLint x2, GLint y2); -GLAPI void GLAPIENTRY glRectiv (const GLint *v1, const GLint *v2); -GLAPI void GLAPIENTRY glRects (GLshort x1, GLshort y1, GLshort x2, GLshort y2); -GLAPI void GLAPIENTRY glRectsv (const GLshort *v1, const GLshort *v2); -GLAPI GLint GLAPIENTRY glRenderMode (GLenum mode); -GLAPI void GLAPIENTRY glRotated (GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -GLAPI void GLAPIENTRY glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -GLAPI void GLAPIENTRY glScaled (GLdouble x, GLdouble y, GLdouble z); -GLAPI void GLAPIENTRY glScalef (GLfloat x, GLfloat y, GLfloat z); -GLAPI void GLAPIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void GLAPIENTRY glSelectBuffer (GLsizei size, GLuint *buffer); -GLAPI void GLAPIENTRY glShadeModel (GLenum mode); -GLAPI void GLAPIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); -GLAPI void GLAPIENTRY glStencilMask (GLuint mask); -GLAPI void GLAPIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); -GLAPI void GLAPIENTRY glTexCoord1d (GLdouble s); -GLAPI void GLAPIENTRY glTexCoord1dv (const GLdouble *v); -GLAPI void GLAPIENTRY glTexCoord1f (GLfloat s); -GLAPI void GLAPIENTRY glTexCoord1fv (const GLfloat *v); -GLAPI void GLAPIENTRY glTexCoord1i (GLint s); -GLAPI void GLAPIENTRY glTexCoord1iv (const GLint *v); -GLAPI void GLAPIENTRY glTexCoord1s (GLshort s); -GLAPI void GLAPIENTRY glTexCoord1sv (const GLshort *v); -GLAPI void GLAPIENTRY glTexCoord2d (GLdouble s, GLdouble t); -GLAPI void GLAPIENTRY glTexCoord2dv (const GLdouble *v); -GLAPI void GLAPIENTRY glTexCoord2f (GLfloat s, GLfloat t); -GLAPI void GLAPIENTRY glTexCoord2fv (const GLfloat *v); -GLAPI void GLAPIENTRY glTexCoord2i (GLint s, GLint t); -GLAPI void GLAPIENTRY glTexCoord2iv (const GLint *v); -GLAPI void GLAPIENTRY glTexCoord2s (GLshort s, GLshort t); -GLAPI void GLAPIENTRY glTexCoord2sv (const GLshort *v); -GLAPI void GLAPIENTRY glTexCoord3d (GLdouble s, GLdouble t, GLdouble r); -GLAPI void GLAPIENTRY glTexCoord3dv (const GLdouble *v); -GLAPI void GLAPIENTRY glTexCoord3f (GLfloat s, GLfloat t, GLfloat r); -GLAPI void GLAPIENTRY glTexCoord3fv (const GLfloat *v); -GLAPI void GLAPIENTRY glTexCoord3i (GLint s, GLint t, GLint r); -GLAPI void GLAPIENTRY glTexCoord3iv (const GLint *v); -GLAPI void GLAPIENTRY glTexCoord3s (GLshort s, GLshort t, GLshort r); -GLAPI void GLAPIENTRY glTexCoord3sv (const GLshort *v); -GLAPI void GLAPIENTRY glTexCoord4d (GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void GLAPIENTRY glTexCoord4dv (const GLdouble *v); -GLAPI void GLAPIENTRY glTexCoord4f (GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void GLAPIENTRY glTexCoord4fv (const GLfloat *v); -GLAPI void GLAPIENTRY glTexCoord4i (GLint s, GLint t, GLint r, GLint q); -GLAPI void GLAPIENTRY glTexCoord4iv (const GLint *v); -GLAPI void GLAPIENTRY glTexCoord4s (GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void GLAPIENTRY glTexCoord4sv (const GLshort *v); -GLAPI void GLAPIENTRY glTexCoordPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void GLAPIENTRY glTexEnvf (GLenum target, GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glTexEnvfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glTexEnvi (GLenum target, GLenum pname, GLint param); -GLAPI void GLAPIENTRY glTexEnviv (GLenum target, GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glTexGend (GLenum coord, GLenum pname, GLdouble param); -GLAPI void GLAPIENTRY glTexGendv (GLenum coord, GLenum pname, const GLdouble *params); -GLAPI void GLAPIENTRY glTexGenf (GLenum coord, GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glTexGenfv (GLenum coord, GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glTexGeni (GLenum coord, GLenum pname, GLint param); -GLAPI void GLAPIENTRY glTexGeniv (GLenum coord, GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void GLAPIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void GLAPIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); -GLAPI void GLAPIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void GLAPIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); -GLAPI void GLAPIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void GLAPIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void GLAPIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void GLAPIENTRY glTranslated (GLdouble x, GLdouble y, GLdouble z); -GLAPI void GLAPIENTRY glTranslatef (GLfloat x, GLfloat y, GLfloat z); -GLAPI void GLAPIENTRY glVertex2d (GLdouble x, GLdouble y); -GLAPI void GLAPIENTRY glVertex2dv (const GLdouble *v); -GLAPI void GLAPIENTRY glVertex2f (GLfloat x, GLfloat y); -GLAPI void GLAPIENTRY glVertex2fv (const GLfloat *v); -GLAPI void GLAPIENTRY glVertex2i (GLint x, GLint y); -GLAPI void GLAPIENTRY glVertex2iv (const GLint *v); -GLAPI void GLAPIENTRY glVertex2s (GLshort x, GLshort y); -GLAPI void GLAPIENTRY glVertex2sv (const GLshort *v); -GLAPI void GLAPIENTRY glVertex3d (GLdouble x, GLdouble y, GLdouble z); -GLAPI void GLAPIENTRY glVertex3dv (const GLdouble *v); -GLAPI void GLAPIENTRY glVertex3f (GLfloat x, GLfloat y, GLfloat z); -GLAPI void GLAPIENTRY glVertex3fv (const GLfloat *v); -GLAPI void GLAPIENTRY glVertex3i (GLint x, GLint y, GLint z); -GLAPI void GLAPIENTRY glVertex3iv (const GLint *v); -GLAPI void GLAPIENTRY glVertex3s (GLshort x, GLshort y, GLshort z); -GLAPI void GLAPIENTRY glVertex3sv (const GLshort *v); -GLAPI void GLAPIENTRY glVertex4d (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void GLAPIENTRY glVertex4dv (const GLdouble *v); -GLAPI void GLAPIENTRY glVertex4f (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void GLAPIENTRY glVertex4fv (const GLfloat *v); -GLAPI void GLAPIENTRY glVertex4i (GLint x, GLint y, GLint z, GLint w); -GLAPI void GLAPIENTRY glVertex4iv (const GLint *v); -GLAPI void GLAPIENTRY glVertex4s (GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void GLAPIENTRY glVertex4sv (const GLshort *v); -GLAPI void GLAPIENTRY glVertexPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); - -#define GLEW_VERSION_1_1 GLEW_GET_VAR(__GLEW_VERSION_1_1) - -#endif /* GL_VERSION_1_1 */ - -/* ---------------------------------- GLU ---------------------------------- */ - -/* this is where we can safely include GLU */ -#if defined(__APPLE__) && defined(__MACH__) -#include -#else -#include -#endif - -/* ----------------------------- GL_VERSION_1_2 ---------------------------- */ - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 - -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_RESCALE_NORMAL 0x803A -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E - -typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); - -#define glCopyTexSubImage3D GLEW_GET_FUN(__glewCopyTexSubImage3D) -#define glDrawRangeElements GLEW_GET_FUN(__glewDrawRangeElements) -#define glTexImage3D GLEW_GET_FUN(__glewTexImage3D) -#define glTexSubImage3D GLEW_GET_FUN(__glewTexSubImage3D) - -#define GLEW_VERSION_1_2 GLEW_GET_VAR(__GLEW_VERSION_1_2) - -#endif /* GL_VERSION_1_2 */ - -/* ----------------------------- GL_VERSION_1_3 ---------------------------- */ - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 - -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_CLAMP_TO_BORDER 0x812D -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 -#define GL_SUBTRACT 0x84E7 -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_SOURCE0_RGB 0x8580 -#define GL_SOURCE1_RGB 0x8581 -#define GL_SOURCE2_RGB 0x8582 -#define GL_SOURCE0_ALPHA 0x8588 -#define GL_SOURCE1_ALPHA 0x8589 -#define GL_SOURCE2_ALPHA 0x858A -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF -#define GL_MULTISAMPLE_BIT 0x20000000 - -typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLvoid *img); -typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); -typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); -typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble m[16]); -typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat m[16]); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); - -#define glActiveTexture GLEW_GET_FUN(__glewActiveTexture) -#define glClientActiveTexture GLEW_GET_FUN(__glewClientActiveTexture) -#define glCompressedTexImage1D GLEW_GET_FUN(__glewCompressedTexImage1D) -#define glCompressedTexImage2D GLEW_GET_FUN(__glewCompressedTexImage2D) -#define glCompressedTexImage3D GLEW_GET_FUN(__glewCompressedTexImage3D) -#define glCompressedTexSubImage1D GLEW_GET_FUN(__glewCompressedTexSubImage1D) -#define glCompressedTexSubImage2D GLEW_GET_FUN(__glewCompressedTexSubImage2D) -#define glCompressedTexSubImage3D GLEW_GET_FUN(__glewCompressedTexSubImage3D) -#define glGetCompressedTexImage GLEW_GET_FUN(__glewGetCompressedTexImage) -#define glLoadTransposeMatrixd GLEW_GET_FUN(__glewLoadTransposeMatrixd) -#define glLoadTransposeMatrixf GLEW_GET_FUN(__glewLoadTransposeMatrixf) -#define glMultTransposeMatrixd GLEW_GET_FUN(__glewMultTransposeMatrixd) -#define glMultTransposeMatrixf GLEW_GET_FUN(__glewMultTransposeMatrixf) -#define glMultiTexCoord1d GLEW_GET_FUN(__glewMultiTexCoord1d) -#define glMultiTexCoord1dv GLEW_GET_FUN(__glewMultiTexCoord1dv) -#define glMultiTexCoord1f GLEW_GET_FUN(__glewMultiTexCoord1f) -#define glMultiTexCoord1fv GLEW_GET_FUN(__glewMultiTexCoord1fv) -#define glMultiTexCoord1i GLEW_GET_FUN(__glewMultiTexCoord1i) -#define glMultiTexCoord1iv GLEW_GET_FUN(__glewMultiTexCoord1iv) -#define glMultiTexCoord1s GLEW_GET_FUN(__glewMultiTexCoord1s) -#define glMultiTexCoord1sv GLEW_GET_FUN(__glewMultiTexCoord1sv) -#define glMultiTexCoord2d GLEW_GET_FUN(__glewMultiTexCoord2d) -#define glMultiTexCoord2dv GLEW_GET_FUN(__glewMultiTexCoord2dv) -#define glMultiTexCoord2f GLEW_GET_FUN(__glewMultiTexCoord2f) -#define glMultiTexCoord2fv GLEW_GET_FUN(__glewMultiTexCoord2fv) -#define glMultiTexCoord2i GLEW_GET_FUN(__glewMultiTexCoord2i) -#define glMultiTexCoord2iv GLEW_GET_FUN(__glewMultiTexCoord2iv) -#define glMultiTexCoord2s GLEW_GET_FUN(__glewMultiTexCoord2s) -#define glMultiTexCoord2sv GLEW_GET_FUN(__glewMultiTexCoord2sv) -#define glMultiTexCoord3d GLEW_GET_FUN(__glewMultiTexCoord3d) -#define glMultiTexCoord3dv GLEW_GET_FUN(__glewMultiTexCoord3dv) -#define glMultiTexCoord3f GLEW_GET_FUN(__glewMultiTexCoord3f) -#define glMultiTexCoord3fv GLEW_GET_FUN(__glewMultiTexCoord3fv) -#define glMultiTexCoord3i GLEW_GET_FUN(__glewMultiTexCoord3i) -#define glMultiTexCoord3iv GLEW_GET_FUN(__glewMultiTexCoord3iv) -#define glMultiTexCoord3s GLEW_GET_FUN(__glewMultiTexCoord3s) -#define glMultiTexCoord3sv GLEW_GET_FUN(__glewMultiTexCoord3sv) -#define glMultiTexCoord4d GLEW_GET_FUN(__glewMultiTexCoord4d) -#define glMultiTexCoord4dv GLEW_GET_FUN(__glewMultiTexCoord4dv) -#define glMultiTexCoord4f GLEW_GET_FUN(__glewMultiTexCoord4f) -#define glMultiTexCoord4fv GLEW_GET_FUN(__glewMultiTexCoord4fv) -#define glMultiTexCoord4i GLEW_GET_FUN(__glewMultiTexCoord4i) -#define glMultiTexCoord4iv GLEW_GET_FUN(__glewMultiTexCoord4iv) -#define glMultiTexCoord4s GLEW_GET_FUN(__glewMultiTexCoord4s) -#define glMultiTexCoord4sv GLEW_GET_FUN(__glewMultiTexCoord4sv) -#define glSampleCoverage GLEW_GET_FUN(__glewSampleCoverage) - -#define GLEW_VERSION_1_3 GLEW_GET_VAR(__GLEW_VERSION_1_3) - -#endif /* GL_VERSION_1_3 */ - -/* ----------------------------- GL_VERSION_1_4 ---------------------------- */ - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 - -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_FOG_COORDINATE_SOURCE 0x8450 -#define GL_FOG_COORDINATE 0x8451 -#define GL_FRAGMENT_DEPTH 0x8452 -#define GL_CURRENT_FOG_COORDINATE 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define GL_FOG_COORDINATE_ARRAY 0x8457 -#define GL_COLOR_SUM 0x8458 -#define GL_CURRENT_SECONDARY_COLOR 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_COMPARE_R_TO_TEXTURE 0x884E - -typedef void (GLAPIENTRY * PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (GLAPIENTRY * PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVPROC) (GLenum pname, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVPROC) (GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVPROC) (const GLdouble *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVPROC) (const GLfloat *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVPROC) (const GLint *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVPROC) (const GLshort *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVPROC) (const GLdouble *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVPROC) (const GLfloat *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVPROC) (const GLint *p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVPROC) (const GLshort *p); - -#define glBlendColor GLEW_GET_FUN(__glewBlendColor) -#define glBlendEquation GLEW_GET_FUN(__glewBlendEquation) -#define glBlendFuncSeparate GLEW_GET_FUN(__glewBlendFuncSeparate) -#define glFogCoordPointer GLEW_GET_FUN(__glewFogCoordPointer) -#define glFogCoordd GLEW_GET_FUN(__glewFogCoordd) -#define glFogCoorddv GLEW_GET_FUN(__glewFogCoorddv) -#define glFogCoordf GLEW_GET_FUN(__glewFogCoordf) -#define glFogCoordfv GLEW_GET_FUN(__glewFogCoordfv) -#define glMultiDrawArrays GLEW_GET_FUN(__glewMultiDrawArrays) -#define glMultiDrawElements GLEW_GET_FUN(__glewMultiDrawElements) -#define glPointParameterf GLEW_GET_FUN(__glewPointParameterf) -#define glPointParameterfv GLEW_GET_FUN(__glewPointParameterfv) -#define glPointParameteri GLEW_GET_FUN(__glewPointParameteri) -#define glPointParameteriv GLEW_GET_FUN(__glewPointParameteriv) -#define glSecondaryColor3b GLEW_GET_FUN(__glewSecondaryColor3b) -#define glSecondaryColor3bv GLEW_GET_FUN(__glewSecondaryColor3bv) -#define glSecondaryColor3d GLEW_GET_FUN(__glewSecondaryColor3d) -#define glSecondaryColor3dv GLEW_GET_FUN(__glewSecondaryColor3dv) -#define glSecondaryColor3f GLEW_GET_FUN(__glewSecondaryColor3f) -#define glSecondaryColor3fv GLEW_GET_FUN(__glewSecondaryColor3fv) -#define glSecondaryColor3i GLEW_GET_FUN(__glewSecondaryColor3i) -#define glSecondaryColor3iv GLEW_GET_FUN(__glewSecondaryColor3iv) -#define glSecondaryColor3s GLEW_GET_FUN(__glewSecondaryColor3s) -#define glSecondaryColor3sv GLEW_GET_FUN(__glewSecondaryColor3sv) -#define glSecondaryColor3ub GLEW_GET_FUN(__glewSecondaryColor3ub) -#define glSecondaryColor3ubv GLEW_GET_FUN(__glewSecondaryColor3ubv) -#define glSecondaryColor3ui GLEW_GET_FUN(__glewSecondaryColor3ui) -#define glSecondaryColor3uiv GLEW_GET_FUN(__glewSecondaryColor3uiv) -#define glSecondaryColor3us GLEW_GET_FUN(__glewSecondaryColor3us) -#define glSecondaryColor3usv GLEW_GET_FUN(__glewSecondaryColor3usv) -#define glSecondaryColorPointer GLEW_GET_FUN(__glewSecondaryColorPointer) -#define glWindowPos2d GLEW_GET_FUN(__glewWindowPos2d) -#define glWindowPos2dv GLEW_GET_FUN(__glewWindowPos2dv) -#define glWindowPos2f GLEW_GET_FUN(__glewWindowPos2f) -#define glWindowPos2fv GLEW_GET_FUN(__glewWindowPos2fv) -#define glWindowPos2i GLEW_GET_FUN(__glewWindowPos2i) -#define glWindowPos2iv GLEW_GET_FUN(__glewWindowPos2iv) -#define glWindowPos2s GLEW_GET_FUN(__glewWindowPos2s) -#define glWindowPos2sv GLEW_GET_FUN(__glewWindowPos2sv) -#define glWindowPos3d GLEW_GET_FUN(__glewWindowPos3d) -#define glWindowPos3dv GLEW_GET_FUN(__glewWindowPos3dv) -#define glWindowPos3f GLEW_GET_FUN(__glewWindowPos3f) -#define glWindowPos3fv GLEW_GET_FUN(__glewWindowPos3fv) -#define glWindowPos3i GLEW_GET_FUN(__glewWindowPos3i) -#define glWindowPos3iv GLEW_GET_FUN(__glewWindowPos3iv) -#define glWindowPos3s GLEW_GET_FUN(__glewWindowPos3s) -#define glWindowPos3sv GLEW_GET_FUN(__glewWindowPos3sv) - -#define GLEW_VERSION_1_4 GLEW_GET_VAR(__GLEW_VERSION_1_4) - -#endif /* GL_VERSION_1_4 */ - -/* ----------------------------- GL_VERSION_1_5 ---------------------------- */ - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 - -#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE -#define GL_FOG_COORD GL_FOG_COORDINATE -#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY -#define GL_SRC0_RGB GL_SOURCE0_RGB -#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER -#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE -#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA -#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE -#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE -#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA -#define GL_SRC1_RGB GL_SOURCE1_RGB -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING -#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA -#define GL_SRC2_RGB GL_SOURCE2_RGB -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 - -typedef ptrdiff_t GLsizeiptr; -typedef ptrdiff_t GLintptr; - -typedef void (GLAPIENTRY * PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); -typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); -typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint* buffers); -typedef void (GLAPIENTRY * PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint* ids); -typedef void (GLAPIENTRY * PFNGLENDQUERYPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLGENBUFFERSPROC) (GLsizei n, GLuint* buffers); -typedef void (GLAPIENTRY * PFNGLGENQUERIESPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid** params); -typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid* data); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERPROC) (GLuint buffer); -typedef GLboolean (GLAPIENTRY * PFNGLISQUERYPROC) (GLuint id); -typedef GLvoid* (GLAPIENTRY * PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERPROC) (GLenum target); - -#define glBeginQuery GLEW_GET_FUN(__glewBeginQuery) -#define glBindBuffer GLEW_GET_FUN(__glewBindBuffer) -#define glBufferData GLEW_GET_FUN(__glewBufferData) -#define glBufferSubData GLEW_GET_FUN(__glewBufferSubData) -#define glDeleteBuffers GLEW_GET_FUN(__glewDeleteBuffers) -#define glDeleteQueries GLEW_GET_FUN(__glewDeleteQueries) -#define glEndQuery GLEW_GET_FUN(__glewEndQuery) -#define glGenBuffers GLEW_GET_FUN(__glewGenBuffers) -#define glGenQueries GLEW_GET_FUN(__glewGenQueries) -#define glGetBufferParameteriv GLEW_GET_FUN(__glewGetBufferParameteriv) -#define glGetBufferPointerv GLEW_GET_FUN(__glewGetBufferPointerv) -#define glGetBufferSubData GLEW_GET_FUN(__glewGetBufferSubData) -#define glGetQueryObjectiv GLEW_GET_FUN(__glewGetQueryObjectiv) -#define glGetQueryObjectuiv GLEW_GET_FUN(__glewGetQueryObjectuiv) -#define glGetQueryiv GLEW_GET_FUN(__glewGetQueryiv) -#define glIsBuffer GLEW_GET_FUN(__glewIsBuffer) -#define glIsQuery GLEW_GET_FUN(__glewIsQuery) -#define glMapBuffer GLEW_GET_FUN(__glewMapBuffer) -#define glUnmapBuffer GLEW_GET_FUN(__glewUnmapBuffer) - -#define GLEW_VERSION_1_5 GLEW_GET_VAR(__GLEW_VERSION_1_5) - -#endif /* GL_VERSION_1_5 */ - -/* ----------------------------- GL_VERSION_2_0 ---------------------------- */ - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 - -#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_COORDS 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 - -typedef char GLchar; - -typedef void (GLAPIENTRY * PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar* name); -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum, GLenum); -typedef void (GLAPIENTRY * PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (GLAPIENTRY * PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (GLAPIENTRY * PFNGLCREATESHADERPROC) (GLenum type); -typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (GLAPIENTRY * PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (GLAPIENTRY * PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint); -typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum* bufs); -typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint); -typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); -typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei maxLength, GLsizei* length, GLint* size, GLenum* type, GLchar* name); -typedef void (GLAPIENTRY * PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei* count, GLuint* shaders); -typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar* name); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLchar* infoLog); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint* param); -typedef void (GLAPIENTRY * PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog); -typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEPROC) (GLint obj, GLsizei maxLength, GLsizei* length, GLchar* source); -typedef void (GLAPIENTRY * PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint* param); -typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar* name); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint, GLenum, GLvoid*); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVPROC) (GLuint, GLenum, GLdouble*); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVPROC) (GLuint, GLenum, GLfloat*); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVPROC) (GLuint, GLenum, GLint*); -typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (GLAPIENTRY * PFNGLISSHADERPROC) (GLuint shader); -typedef void (GLAPIENTRY * PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (GLAPIENTRY * PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar** strings, const GLint* lengths); -typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -typedef void (GLAPIENTRY * PFNGLSTENCILMASKSEPARATEPROC) (GLenum, GLuint); -typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (GLAPIENTRY * PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (GLAPIENTRY * PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (GLAPIENTRY * PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (GLAPIENTRY * PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (GLAPIENTRY * PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (GLAPIENTRY * PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (GLAPIENTRY * PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (GLAPIENTRY * PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (GLAPIENTRY * PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* pointer); - -#define glAttachShader GLEW_GET_FUN(__glewAttachShader) -#define glBindAttribLocation GLEW_GET_FUN(__glewBindAttribLocation) -#define glBlendEquationSeparate GLEW_GET_FUN(__glewBlendEquationSeparate) -#define glCompileShader GLEW_GET_FUN(__glewCompileShader) -#define glCreateProgram GLEW_GET_FUN(__glewCreateProgram) -#define glCreateShader GLEW_GET_FUN(__glewCreateShader) -#define glDeleteProgram GLEW_GET_FUN(__glewDeleteProgram) -#define glDeleteShader GLEW_GET_FUN(__glewDeleteShader) -#define glDetachShader GLEW_GET_FUN(__glewDetachShader) -#define glDisableVertexAttribArray GLEW_GET_FUN(__glewDisableVertexAttribArray) -#define glDrawBuffers GLEW_GET_FUN(__glewDrawBuffers) -#define glEnableVertexAttribArray GLEW_GET_FUN(__glewEnableVertexAttribArray) -#define glGetActiveAttrib GLEW_GET_FUN(__glewGetActiveAttrib) -#define glGetActiveUniform GLEW_GET_FUN(__glewGetActiveUniform) -#define glGetAttachedShaders GLEW_GET_FUN(__glewGetAttachedShaders) -#define glGetAttribLocation GLEW_GET_FUN(__glewGetAttribLocation) -#define glGetProgramInfoLog GLEW_GET_FUN(__glewGetProgramInfoLog) -#define glGetProgramiv GLEW_GET_FUN(__glewGetProgramiv) -#define glGetShaderInfoLog GLEW_GET_FUN(__glewGetShaderInfoLog) -#define glGetShaderSource GLEW_GET_FUN(__glewGetShaderSource) -#define glGetShaderiv GLEW_GET_FUN(__glewGetShaderiv) -#define glGetUniformLocation GLEW_GET_FUN(__glewGetUniformLocation) -#define glGetUniformfv GLEW_GET_FUN(__glewGetUniformfv) -#define glGetUniformiv GLEW_GET_FUN(__glewGetUniformiv) -#define glGetVertexAttribPointerv GLEW_GET_FUN(__glewGetVertexAttribPointerv) -#define glGetVertexAttribdv GLEW_GET_FUN(__glewGetVertexAttribdv) -#define glGetVertexAttribfv GLEW_GET_FUN(__glewGetVertexAttribfv) -#define glGetVertexAttribiv GLEW_GET_FUN(__glewGetVertexAttribiv) -#define glIsProgram GLEW_GET_FUN(__glewIsProgram) -#define glIsShader GLEW_GET_FUN(__glewIsShader) -#define glLinkProgram GLEW_GET_FUN(__glewLinkProgram) -#define glShaderSource GLEW_GET_FUN(__glewShaderSource) -#define glStencilFuncSeparate GLEW_GET_FUN(__glewStencilFuncSeparate) -#define glStencilMaskSeparate GLEW_GET_FUN(__glewStencilMaskSeparate) -#define glStencilOpSeparate GLEW_GET_FUN(__glewStencilOpSeparate) -#define glUniform1f GLEW_GET_FUN(__glewUniform1f) -#define glUniform1fv GLEW_GET_FUN(__glewUniform1fv) -#define glUniform1i GLEW_GET_FUN(__glewUniform1i) -#define glUniform1iv GLEW_GET_FUN(__glewUniform1iv) -#define glUniform2f GLEW_GET_FUN(__glewUniform2f) -#define glUniform2fv GLEW_GET_FUN(__glewUniform2fv) -#define glUniform2i GLEW_GET_FUN(__glewUniform2i) -#define glUniform2iv GLEW_GET_FUN(__glewUniform2iv) -#define glUniform3f GLEW_GET_FUN(__glewUniform3f) -#define glUniform3fv GLEW_GET_FUN(__glewUniform3fv) -#define glUniform3i GLEW_GET_FUN(__glewUniform3i) -#define glUniform3iv GLEW_GET_FUN(__glewUniform3iv) -#define glUniform4f GLEW_GET_FUN(__glewUniform4f) -#define glUniform4fv GLEW_GET_FUN(__glewUniform4fv) -#define glUniform4i GLEW_GET_FUN(__glewUniform4i) -#define glUniform4iv GLEW_GET_FUN(__glewUniform4iv) -#define glUniformMatrix2fv GLEW_GET_FUN(__glewUniformMatrix2fv) -#define glUniformMatrix3fv GLEW_GET_FUN(__glewUniformMatrix3fv) -#define glUniformMatrix4fv GLEW_GET_FUN(__glewUniformMatrix4fv) -#define glUseProgram GLEW_GET_FUN(__glewUseProgram) -#define glValidateProgram GLEW_GET_FUN(__glewValidateProgram) -#define glVertexAttrib1d GLEW_GET_FUN(__glewVertexAttrib1d) -#define glVertexAttrib1dv GLEW_GET_FUN(__glewVertexAttrib1dv) -#define glVertexAttrib1f GLEW_GET_FUN(__glewVertexAttrib1f) -#define glVertexAttrib1fv GLEW_GET_FUN(__glewVertexAttrib1fv) -#define glVertexAttrib1s GLEW_GET_FUN(__glewVertexAttrib1s) -#define glVertexAttrib1sv GLEW_GET_FUN(__glewVertexAttrib1sv) -#define glVertexAttrib2d GLEW_GET_FUN(__glewVertexAttrib2d) -#define glVertexAttrib2dv GLEW_GET_FUN(__glewVertexAttrib2dv) -#define glVertexAttrib2f GLEW_GET_FUN(__glewVertexAttrib2f) -#define glVertexAttrib2fv GLEW_GET_FUN(__glewVertexAttrib2fv) -#define glVertexAttrib2s GLEW_GET_FUN(__glewVertexAttrib2s) -#define glVertexAttrib2sv GLEW_GET_FUN(__glewVertexAttrib2sv) -#define glVertexAttrib3d GLEW_GET_FUN(__glewVertexAttrib3d) -#define glVertexAttrib3dv GLEW_GET_FUN(__glewVertexAttrib3dv) -#define glVertexAttrib3f GLEW_GET_FUN(__glewVertexAttrib3f) -#define glVertexAttrib3fv GLEW_GET_FUN(__glewVertexAttrib3fv) -#define glVertexAttrib3s GLEW_GET_FUN(__glewVertexAttrib3s) -#define glVertexAttrib3sv GLEW_GET_FUN(__glewVertexAttrib3sv) -#define glVertexAttrib4Nbv GLEW_GET_FUN(__glewVertexAttrib4Nbv) -#define glVertexAttrib4Niv GLEW_GET_FUN(__glewVertexAttrib4Niv) -#define glVertexAttrib4Nsv GLEW_GET_FUN(__glewVertexAttrib4Nsv) -#define glVertexAttrib4Nub GLEW_GET_FUN(__glewVertexAttrib4Nub) -#define glVertexAttrib4Nubv GLEW_GET_FUN(__glewVertexAttrib4Nubv) -#define glVertexAttrib4Nuiv GLEW_GET_FUN(__glewVertexAttrib4Nuiv) -#define glVertexAttrib4Nusv GLEW_GET_FUN(__glewVertexAttrib4Nusv) -#define glVertexAttrib4bv GLEW_GET_FUN(__glewVertexAttrib4bv) -#define glVertexAttrib4d GLEW_GET_FUN(__glewVertexAttrib4d) -#define glVertexAttrib4dv GLEW_GET_FUN(__glewVertexAttrib4dv) -#define glVertexAttrib4f GLEW_GET_FUN(__glewVertexAttrib4f) -#define glVertexAttrib4fv GLEW_GET_FUN(__glewVertexAttrib4fv) -#define glVertexAttrib4iv GLEW_GET_FUN(__glewVertexAttrib4iv) -#define glVertexAttrib4s GLEW_GET_FUN(__glewVertexAttrib4s) -#define glVertexAttrib4sv GLEW_GET_FUN(__glewVertexAttrib4sv) -#define glVertexAttrib4ubv GLEW_GET_FUN(__glewVertexAttrib4ubv) -#define glVertexAttrib4uiv GLEW_GET_FUN(__glewVertexAttrib4uiv) -#define glVertexAttrib4usv GLEW_GET_FUN(__glewVertexAttrib4usv) -#define glVertexAttribPointer GLEW_GET_FUN(__glewVertexAttribPointer) - -#define GLEW_VERSION_2_0 GLEW_GET_VAR(__GLEW_VERSION_2_0) - -#endif /* GL_VERSION_2_0 */ - -/* ----------------------------- GL_VERSION_2_1 ---------------------------- */ - -#ifndef GL_VERSION_2_1 -#define GL_VERSION_2_1 1 - -#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F -#define GL_PIXEL_PACK_BUFFER 0x88EB -#define GL_PIXEL_UNPACK_BUFFER 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF -#define GL_FLOAT_MAT2x3 0x8B65 -#define GL_FLOAT_MAT2x4 0x8B66 -#define GL_FLOAT_MAT3x2 0x8B67 -#define GL_FLOAT_MAT3x4 0x8B68 -#define GL_FLOAT_MAT4x2 0x8B69 -#define GL_FLOAT_MAT4x3 0x8B6A -#define GL_SRGB 0x8C40 -#define GL_SRGB8 0x8C41 -#define GL_SRGB_ALPHA 0x8C42 -#define GL_SRGB8_ALPHA8 0x8C43 -#define GL_SLUMINANCE_ALPHA 0x8C44 -#define GL_SLUMINANCE8_ALPHA8 0x8C45 -#define GL_SLUMINANCE 0x8C46 -#define GL_SLUMINANCE8 0x8C47 -#define GL_COMPRESSED_SRGB 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#define GL_COMPRESSED_SLUMINANCE 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B - -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); - -#define glUniformMatrix2x3fv GLEW_GET_FUN(__glewUniformMatrix2x3fv) -#define glUniformMatrix2x4fv GLEW_GET_FUN(__glewUniformMatrix2x4fv) -#define glUniformMatrix3x2fv GLEW_GET_FUN(__glewUniformMatrix3x2fv) -#define glUniformMatrix3x4fv GLEW_GET_FUN(__glewUniformMatrix3x4fv) -#define glUniformMatrix4x2fv GLEW_GET_FUN(__glewUniformMatrix4x2fv) -#define glUniformMatrix4x3fv GLEW_GET_FUN(__glewUniformMatrix4x3fv) - -#define GLEW_VERSION_2_1 GLEW_GET_VAR(__GLEW_VERSION_2_1) - -#endif /* GL_VERSION_2_1 */ - -/* ----------------------------- GL_VERSION_3_0 ---------------------------- */ - -#ifndef GL_VERSION_3_0 -#define GL_VERSION_3_0 1 - -#define GL_MAX_CLIP_DISTANCES GL_MAX_CLIP_PLANES -#define GL_CLIP_DISTANCE5 GL_CLIP_PLANE5 -#define GL_CLIP_DISTANCE1 GL_CLIP_PLANE1 -#define GL_CLIP_DISTANCE3 GL_CLIP_PLANE3 -#define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_R_TO_TEXTURE_ARB -#define GL_CLIP_DISTANCE0 GL_CLIP_PLANE0 -#define GL_CLIP_DISTANCE4 GL_CLIP_PLANE4 -#define GL_CLIP_DISTANCE2 GL_CLIP_PLANE2 -#define GL_MAX_VARYING_COMPONENTS GL_MAX_VARYING_FLOATS -#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 -#define GL_MAJOR_VERSION 0x821B -#define GL_MINOR_VERSION 0x821C -#define GL_NUM_EXTENSIONS 0x821D -#define GL_CONTEXT_FLAGS 0x821E -#define GL_DEPTH_BUFFER 0x8223 -#define GL_STENCIL_BUFFER 0x8224 -#define GL_COMPRESSED_RED 0x8225 -#define GL_COMPRESSED_RG 0x8226 -#define GL_RGBA32F 0x8814 -#define GL_RGB32F 0x8815 -#define GL_RGBA16F 0x881A -#define GL_RGB16F 0x881B -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD -#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF -#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 -#define GL_CLAMP_VERTEX_COLOR 0x891A -#define GL_CLAMP_FRAGMENT_COLOR 0x891B -#define GL_CLAMP_READ_COLOR 0x891C -#define GL_FIXED_ONLY 0x891D -#define GL_TEXTURE_RED_TYPE 0x8C10 -#define GL_TEXTURE_GREEN_TYPE 0x8C11 -#define GL_TEXTURE_BLUE_TYPE 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE 0x8C16 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_TEXTURE_1D_ARRAY 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 -#define GL_TEXTURE_2D_ARRAY 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D -#define GL_R11F_G11F_B10F 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B -#define GL_RGB9_E5 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E -#define GL_TEXTURE_SHARED_SIZE 0x8C3F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 -#define GL_PRIMITIVES_GENERATED 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 -#define GL_RASTERIZER_DISCARD 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B -#define GL_INTERLEAVED_ATTRIBS 0x8C8C -#define GL_SEPARATE_ATTRIBS 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F -#define GL_RGBA32UI 0x8D70 -#define GL_RGB32UI 0x8D71 -#define GL_RGBA16UI 0x8D76 -#define GL_RGB16UI 0x8D77 -#define GL_RGBA8UI 0x8D7C -#define GL_RGB8UI 0x8D7D -#define GL_RGBA32I 0x8D82 -#define GL_RGB32I 0x8D83 -#define GL_RGBA16I 0x8D88 -#define GL_RGB16I 0x8D89 -#define GL_RGBA8I 0x8D8E -#define GL_RGB8I 0x8D8F -#define GL_RED_INTEGER 0x8D94 -#define GL_GREEN_INTEGER 0x8D95 -#define GL_BLUE_INTEGER 0x8D96 -#define GL_ALPHA_INTEGER 0x8D97 -#define GL_RGB_INTEGER 0x8D98 -#define GL_RGBA_INTEGER 0x8D99 -#define GL_BGR_INTEGER 0x8D9A -#define GL_BGRA_INTEGER 0x8D9B -#define GL_SAMPLER_1D_ARRAY 0x8DC0 -#define GL_SAMPLER_2D_ARRAY 0x8DC1 -#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 -#define GL_UNSIGNED_INT_VEC2 0x8DC6 -#define GL_UNSIGNED_INT_VEC3 0x8DC7 -#define GL_UNSIGNED_INT_VEC4 0x8DC8 -#define GL_INT_SAMPLER_1D 0x8DC9 -#define GL_INT_SAMPLER_2D 0x8DCA -#define GL_INT_SAMPLER_3D 0x8DCB -#define GL_INT_SAMPLER_CUBE 0x8DCC -#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF -#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 -#define GL_QUERY_WAIT 0x8E13 -#define GL_QUERY_NO_WAIT 0x8E14 -#define GL_QUERY_BY_REGION_WAIT 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 - -typedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERPROC) (GLuint, GLenum); -typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEPROC) (GLenum, GLuint, GLuint); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEPROC) (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr); -typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONPROC) (GLuint, GLuint, const GLchar*); -typedef void (GLAPIENTRY * PFNGLCLAMPCOLORPROC) (GLenum, GLenum); -typedef void (GLAPIENTRY * PFNGLCLEARBUFFERFIPROC) (GLenum, GLint, GLfloat, GLint); -typedef void (GLAPIENTRY * PFNGLCLEARBUFFERFVPROC) (GLenum, GLint, const GLfloat*); -typedef void (GLAPIENTRY * PFNGLCLEARBUFFERIVPROC) (GLenum, GLint, const GLint*); -typedef void (GLAPIENTRY * PFNGLCLEARBUFFERUIVPROC) (GLenum, GLint, const GLuint*); -typedef void (GLAPIENTRY * PFNGLCOLORMASKIPROC) (GLuint, GLboolean, GLboolean, GLboolean, GLboolean); -typedef void (GLAPIENTRY * PFNGLDISABLEIPROC) (GLenum, GLuint); -typedef void (GLAPIENTRY * PFNGLENABLEIPROC) (GLenum, GLuint); -typedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERPROC) (void); -typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKPROC) (void); -typedef void (GLAPIENTRY * PFNGLGETBOOLEANI_VPROC) (GLenum, GLuint, GLboolean*); -typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONPROC) (GLuint, const GLchar*); -typedef void (GLAPIENTRY * PFNGLGETINTEGERI_VPROC) (GLenum, GLuint, GLint*); -typedef const GLubyte* (GLAPIENTRY * PFNGLGETSTRINGIPROC) (GLenum, GLuint); -typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVPROC) (GLenum, GLenum, GLint*); -typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVPROC) (GLenum, GLenum, GLuint*); -typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint, GLuint, GLint*); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVPROC) (GLuint, GLint, GLuint*); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVPROC) (GLuint, GLenum, GLint*); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint, GLenum, GLuint*); -typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDIPROC) (GLenum, GLuint); -typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVPROC) (GLenum, GLenum, const GLint*); -typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVPROC) (GLenum, GLenum, const GLuint*); -typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint, GLsizei, const GLint*, GLenum); -typedef void (GLAPIENTRY * PFNGLUNIFORM1UIPROC) (GLint, GLuint); -typedef void (GLAPIENTRY * PFNGLUNIFORM1UIVPROC) (GLint, GLsizei, const GLuint*); -typedef void (GLAPIENTRY * PFNGLUNIFORM2UIPROC) (GLint, GLuint, GLuint); -typedef void (GLAPIENTRY * PFNGLUNIFORM2UIVPROC) (GLint, GLsizei, const GLuint*); -typedef void (GLAPIENTRY * PFNGLUNIFORM3UIPROC) (GLint, GLuint, GLuint, GLuint); -typedef void (GLAPIENTRY * PFNGLUNIFORM3UIVPROC) (GLint, GLsizei, const GLuint*); -typedef void (GLAPIENTRY * PFNGLUNIFORM4UIPROC) (GLint, GLuint, GLuint, GLuint, GLuint); -typedef void (GLAPIENTRY * PFNGLUNIFORM4UIVPROC) (GLint, GLsizei, const GLuint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IPROC) (GLuint, GLint); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVPROC) (GLuint, const GLint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIPROC) (GLuint, GLuint); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVPROC) (GLuint, const GLuint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IPROC) (GLuint, GLint, GLint); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVPROC) (GLuint, const GLint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIPROC) (GLuint, GLuint, GLuint); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVPROC) (GLuint, const GLuint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IPROC) (GLuint, GLint, GLint, GLint); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVPROC) (GLuint, const GLint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIPROC) (GLuint, GLuint, GLuint, GLuint); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVPROC) (GLuint, const GLuint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVPROC) (GLuint, const GLbyte*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IPROC) (GLuint, GLint, GLint, GLint, GLint); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVPROC) (GLuint, const GLint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVPROC) (GLuint, const GLshort*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVPROC) (GLuint, const GLubyte*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIPROC) (GLuint, GLuint, GLuint, GLuint, GLuint); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVPROC) (GLuint, const GLuint*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVPROC) (GLuint, const GLushort*); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint, GLint, GLenum, GLsizei, const GLvoid*); - -#define glBeginConditionalRender GLEW_GET_FUN(__glewBeginConditionalRender) -#define glBeginTransformFeedback GLEW_GET_FUN(__glewBeginTransformFeedback) -#define glBindBufferBase GLEW_GET_FUN(__glewBindBufferBase) -#define glBindBufferRange GLEW_GET_FUN(__glewBindBufferRange) -#define glBindFragDataLocation GLEW_GET_FUN(__glewBindFragDataLocation) -#define glClampColor GLEW_GET_FUN(__glewClampColor) -#define glClearBufferfi GLEW_GET_FUN(__glewClearBufferfi) -#define glClearBufferfv GLEW_GET_FUN(__glewClearBufferfv) -#define glClearBufferiv GLEW_GET_FUN(__glewClearBufferiv) -#define glClearBufferuiv GLEW_GET_FUN(__glewClearBufferuiv) -#define glColorMaski GLEW_GET_FUN(__glewColorMaski) -#define glDisablei GLEW_GET_FUN(__glewDisablei) -#define glEnablei GLEW_GET_FUN(__glewEnablei) -#define glEndConditionalRender GLEW_GET_FUN(__glewEndConditionalRender) -#define glEndTransformFeedback GLEW_GET_FUN(__glewEndTransformFeedback) -#define glGetBooleani_v GLEW_GET_FUN(__glewGetBooleani_v) -#define glGetFragDataLocation GLEW_GET_FUN(__glewGetFragDataLocation) -#define glGetIntegeri_v GLEW_GET_FUN(__glewGetIntegeri_v) -#define glGetStringi GLEW_GET_FUN(__glewGetStringi) -#define glGetTexParameterIiv GLEW_GET_FUN(__glewGetTexParameterIiv) -#define glGetTexParameterIuiv GLEW_GET_FUN(__glewGetTexParameterIuiv) -#define glGetTransformFeedbackVarying GLEW_GET_FUN(__glewGetTransformFeedbackVarying) -#define glGetUniformuiv GLEW_GET_FUN(__glewGetUniformuiv) -#define glGetVertexAttribIiv GLEW_GET_FUN(__glewGetVertexAttribIiv) -#define glGetVertexAttribIuiv GLEW_GET_FUN(__glewGetVertexAttribIuiv) -#define glIsEnabledi GLEW_GET_FUN(__glewIsEnabledi) -#define glTexParameterIiv GLEW_GET_FUN(__glewTexParameterIiv) -#define glTexParameterIuiv GLEW_GET_FUN(__glewTexParameterIuiv) -#define glTransformFeedbackVaryings GLEW_GET_FUN(__glewTransformFeedbackVaryings) -#define glUniform1ui GLEW_GET_FUN(__glewUniform1ui) -#define glUniform1uiv GLEW_GET_FUN(__glewUniform1uiv) -#define glUniform2ui GLEW_GET_FUN(__glewUniform2ui) -#define glUniform2uiv GLEW_GET_FUN(__glewUniform2uiv) -#define glUniform3ui GLEW_GET_FUN(__glewUniform3ui) -#define glUniform3uiv GLEW_GET_FUN(__glewUniform3uiv) -#define glUniform4ui GLEW_GET_FUN(__glewUniform4ui) -#define glUniform4uiv GLEW_GET_FUN(__glewUniform4uiv) -#define glVertexAttribI1i GLEW_GET_FUN(__glewVertexAttribI1i) -#define glVertexAttribI1iv GLEW_GET_FUN(__glewVertexAttribI1iv) -#define glVertexAttribI1ui GLEW_GET_FUN(__glewVertexAttribI1ui) -#define glVertexAttribI1uiv GLEW_GET_FUN(__glewVertexAttribI1uiv) -#define glVertexAttribI2i GLEW_GET_FUN(__glewVertexAttribI2i) -#define glVertexAttribI2iv GLEW_GET_FUN(__glewVertexAttribI2iv) -#define glVertexAttribI2ui GLEW_GET_FUN(__glewVertexAttribI2ui) -#define glVertexAttribI2uiv GLEW_GET_FUN(__glewVertexAttribI2uiv) -#define glVertexAttribI3i GLEW_GET_FUN(__glewVertexAttribI3i) -#define glVertexAttribI3iv GLEW_GET_FUN(__glewVertexAttribI3iv) -#define glVertexAttribI3ui GLEW_GET_FUN(__glewVertexAttribI3ui) -#define glVertexAttribI3uiv GLEW_GET_FUN(__glewVertexAttribI3uiv) -#define glVertexAttribI4bv GLEW_GET_FUN(__glewVertexAttribI4bv) -#define glVertexAttribI4i GLEW_GET_FUN(__glewVertexAttribI4i) -#define glVertexAttribI4iv GLEW_GET_FUN(__glewVertexAttribI4iv) -#define glVertexAttribI4sv GLEW_GET_FUN(__glewVertexAttribI4sv) -#define glVertexAttribI4ubv GLEW_GET_FUN(__glewVertexAttribI4ubv) -#define glVertexAttribI4ui GLEW_GET_FUN(__glewVertexAttribI4ui) -#define glVertexAttribI4uiv GLEW_GET_FUN(__glewVertexAttribI4uiv) -#define glVertexAttribI4usv GLEW_GET_FUN(__glewVertexAttribI4usv) -#define glVertexAttribIPointer GLEW_GET_FUN(__glewVertexAttribIPointer) - -#define GLEW_VERSION_3_0 GLEW_GET_VAR(__GLEW_VERSION_3_0) - -#endif /* GL_VERSION_3_0 */ - -/* -------------------------- GL_3DFX_multisample -------------------------- */ - -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 - -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 - -#define GLEW_3DFX_multisample GLEW_GET_VAR(__GLEW_3DFX_multisample) - -#endif /* GL_3DFX_multisample */ - -/* ---------------------------- GL_3DFX_tbuffer ---------------------------- */ - -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 - -typedef void (GLAPIENTRY * PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); - -#define glTbufferMask3DFX GLEW_GET_FUN(__glewTbufferMask3DFX) - -#define GLEW_3DFX_tbuffer GLEW_GET_VAR(__GLEW_3DFX_tbuffer) - -#endif /* GL_3DFX_tbuffer */ - -/* -------------------- GL_3DFX_texture_compression_FXT1 ------------------- */ - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 - -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 - -#define GLEW_3DFX_texture_compression_FXT1 GLEW_GET_VAR(__GLEW_3DFX_texture_compression_FXT1) - -#endif /* GL_3DFX_texture_compression_FXT1 */ - -/* ------------------------ GL_APPLE_client_storage ------------------------ */ - -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 - -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 - -#define GLEW_APPLE_client_storage GLEW_GET_VAR(__GLEW_APPLE_client_storage) - -#endif /* GL_APPLE_client_storage */ - -/* ------------------------- GL_APPLE_element_array ------------------------ */ - -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 - -#define GL_ELEMENT_ARRAY_APPLE 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A - -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void* pointer); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint* first, const GLsizei *count, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint* first, const GLsizei *count, GLsizei primcount); - -#define glDrawElementArrayAPPLE GLEW_GET_FUN(__glewDrawElementArrayAPPLE) -#define glDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewDrawRangeElementArrayAPPLE) -#define glElementPointerAPPLE GLEW_GET_FUN(__glewElementPointerAPPLE) -#define glMultiDrawElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawElementArrayAPPLE) -#define glMultiDrawRangeElementArrayAPPLE GLEW_GET_FUN(__glewMultiDrawRangeElementArrayAPPLE) - -#define GLEW_APPLE_element_array GLEW_GET_VAR(__GLEW_APPLE_element_array) - -#endif /* GL_APPLE_element_array */ - -/* ----------------------------- GL_APPLE_fence ---------------------------- */ - -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 - -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B - -typedef void (GLAPIENTRY * PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint* fences); -typedef void (GLAPIENTRY * PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef void (GLAPIENTRY * PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); -typedef void (GLAPIENTRY * PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint* fences); -typedef GLboolean (GLAPIENTRY * PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef void (GLAPIENTRY * PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (GLAPIENTRY * PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); - -#define glDeleteFencesAPPLE GLEW_GET_FUN(__glewDeleteFencesAPPLE) -#define glFinishFenceAPPLE GLEW_GET_FUN(__glewFinishFenceAPPLE) -#define glFinishObjectAPPLE GLEW_GET_FUN(__glewFinishObjectAPPLE) -#define glGenFencesAPPLE GLEW_GET_FUN(__glewGenFencesAPPLE) -#define glIsFenceAPPLE GLEW_GET_FUN(__glewIsFenceAPPLE) -#define glSetFenceAPPLE GLEW_GET_FUN(__glewSetFenceAPPLE) -#define glTestFenceAPPLE GLEW_GET_FUN(__glewTestFenceAPPLE) -#define glTestObjectAPPLE GLEW_GET_FUN(__glewTestObjectAPPLE) - -#define GLEW_APPLE_fence GLEW_GET_VAR(__GLEW_APPLE_fence) - -#endif /* GL_APPLE_fence */ - -/* ------------------------- GL_APPLE_float_pixels ------------------------- */ - -#ifndef GL_APPLE_float_pixels -#define GL_APPLE_float_pixels 1 - -#define GL_HALF_APPLE 0x140B -#define GL_RGBA_FLOAT32_APPLE 0x8814 -#define GL_RGB_FLOAT32_APPLE 0x8815 -#define GL_ALPHA_FLOAT32_APPLE 0x8816 -#define GL_INTENSITY_FLOAT32_APPLE 0x8817 -#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 -#define GL_RGBA_FLOAT16_APPLE 0x881A -#define GL_RGB_FLOAT16_APPLE 0x881B -#define GL_ALPHA_FLOAT16_APPLE 0x881C -#define GL_INTENSITY_FLOAT16_APPLE 0x881D -#define GL_LUMINANCE_FLOAT16_APPLE 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F -#define GL_COLOR_FLOAT_APPLE 0x8A0F - -#define GLEW_APPLE_float_pixels GLEW_GET_VAR(__GLEW_APPLE_float_pixels) - -#endif /* GL_APPLE_float_pixels */ - -/* ---------------------- GL_APPLE_flush_buffer_range ---------------------- */ - -#ifndef GL_APPLE_flush_buffer_range -#define GL_APPLE_flush_buffer_range 1 - -#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 -#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 - -typedef void (GLAPIENTRY * PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); - -#define glBufferParameteriAPPLE GLEW_GET_FUN(__glewBufferParameteriAPPLE) -#define glFlushMappedBufferRangeAPPLE GLEW_GET_FUN(__glewFlushMappedBufferRangeAPPLE) - -#define GLEW_APPLE_flush_buffer_range GLEW_GET_VAR(__GLEW_APPLE_flush_buffer_range) - -#endif /* GL_APPLE_flush_buffer_range */ - -/* ------------------------- GL_APPLE_pixel_buffer ------------------------- */ - -#ifndef GL_APPLE_pixel_buffer -#define GL_APPLE_pixel_buffer 1 - -#define GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE 0x8A10 - -#define GLEW_APPLE_pixel_buffer GLEW_GET_VAR(__GLEW_APPLE_pixel_buffer) - -#endif /* GL_APPLE_pixel_buffer */ - -/* ------------------------ GL_APPLE_specular_vector ----------------------- */ - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 - -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 - -#define GLEW_APPLE_specular_vector GLEW_GET_VAR(__GLEW_APPLE_specular_vector) - -#endif /* GL_APPLE_specular_vector */ - -/* ------------------------- GL_APPLE_texture_range ------------------------ */ - -#ifndef GL_APPLE_texture_range -#define GL_APPLE_texture_range 1 - -#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 -#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 -#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC -#define GL_STORAGE_PRIVATE_APPLE 0x85BD -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF - -typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid **params); -typedef void (GLAPIENTRY * PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, GLvoid *pointer); - -#define glGetTexParameterPointervAPPLE GLEW_GET_FUN(__glewGetTexParameterPointervAPPLE) -#define glTextureRangeAPPLE GLEW_GET_FUN(__glewTextureRangeAPPLE) - -#define GLEW_APPLE_texture_range GLEW_GET_VAR(__GLEW_APPLE_texture_range) - -#endif /* GL_APPLE_texture_range */ - -/* ------------------------ GL_APPLE_transform_hint ------------------------ */ - -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 - -#define GL_TRANSFORM_HINT_APPLE 0x85B1 - -#define GLEW_APPLE_transform_hint GLEW_GET_VAR(__GLEW_APPLE_transform_hint) - -#endif /* GL_APPLE_transform_hint */ - -/* ---------------------- GL_APPLE_vertex_array_object --------------------- */ - -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 - -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 - -typedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); -typedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint* arrays); -typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); - -#define glBindVertexArrayAPPLE GLEW_GET_FUN(__glewBindVertexArrayAPPLE) -#define glDeleteVertexArraysAPPLE GLEW_GET_FUN(__glewDeleteVertexArraysAPPLE) -#define glGenVertexArraysAPPLE GLEW_GET_FUN(__glewGenVertexArraysAPPLE) -#define glIsVertexArrayAPPLE GLEW_GET_FUN(__glewIsVertexArrayAPPLE) - -#define GLEW_APPLE_vertex_array_object GLEW_GET_VAR(__GLEW_APPLE_vertex_array_object) - -#endif /* GL_APPLE_vertex_array_object */ - -/* ---------------------- GL_APPLE_vertex_array_range ---------------------- */ - -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 - -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_APPLE 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF - -typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void* pointer); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void* pointer); - -#define glFlushVertexArrayRangeAPPLE GLEW_GET_FUN(__glewFlushVertexArrayRangeAPPLE) -#define glVertexArrayParameteriAPPLE GLEW_GET_FUN(__glewVertexArrayParameteriAPPLE) -#define glVertexArrayRangeAPPLE GLEW_GET_FUN(__glewVertexArrayRangeAPPLE) - -#define GLEW_APPLE_vertex_array_range GLEW_GET_VAR(__GLEW_APPLE_vertex_array_range) - -#endif /* GL_APPLE_vertex_array_range */ - -/* --------------------------- GL_APPLE_ycbcr_422 -------------------------- */ - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 - -#define GL_YCBCR_422_APPLE 0x85B9 -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB - -#define GLEW_APPLE_ycbcr_422 GLEW_GET_VAR(__GLEW_APPLE_ycbcr_422) - -#endif /* GL_APPLE_ycbcr_422 */ - -/* ----------------------- GL_ARB_color_buffer_float ----------------------- */ - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 - -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D - -typedef void (GLAPIENTRY * PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); - -#define glClampColorARB GLEW_GET_FUN(__glewClampColorARB) - -#define GLEW_ARB_color_buffer_float GLEW_GET_VAR(__GLEW_ARB_color_buffer_float) - -#endif /* GL_ARB_color_buffer_float */ - -/* ----------------------- GL_ARB_depth_buffer_float ----------------------- */ - -#ifndef GL_ARB_depth_buffer_float -#define GL_ARB_depth_buffer_float 1 - -#define GL_DEPTH_COMPONENT32F 0x8CAC -#define GL_DEPTH32F_STENCIL8 0x8CAD -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD - -#define GLEW_ARB_depth_buffer_float GLEW_GET_VAR(__GLEW_ARB_depth_buffer_float) - -#endif /* GL_ARB_depth_buffer_float */ - -/* -------------------------- GL_ARB_depth_texture ------------------------- */ - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 - -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B - -#define GLEW_ARB_depth_texture GLEW_GET_VAR(__GLEW_ARB_depth_texture) - -#endif /* GL_ARB_depth_texture */ - -/* -------------------------- GL_ARB_draw_buffers -------------------------- */ - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 - -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 - -typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum* bufs); - -#define glDrawBuffersARB GLEW_GET_FUN(__glewDrawBuffersARB) - -#define GLEW_ARB_draw_buffers GLEW_GET_VAR(__GLEW_ARB_draw_buffers) - -#endif /* GL_ARB_draw_buffers */ - -/* ------------------------- GL_ARB_draw_instanced ------------------------- */ - -#ifndef GL_ARB_draw_instanced -#define GL_ARB_draw_instanced 1 - -typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount); - -#define glDrawArraysInstancedARB GLEW_GET_FUN(__glewDrawArraysInstancedARB) -#define glDrawElementsInstancedARB GLEW_GET_FUN(__glewDrawElementsInstancedARB) - -#define GLEW_ARB_draw_instanced GLEW_GET_VAR(__GLEW_ARB_draw_instanced) - -#endif /* GL_ARB_draw_instanced */ - -/* ------------------------ GL_ARB_fragment_program ------------------------ */ - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 - -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 - -#define GLEW_ARB_fragment_program GLEW_GET_VAR(__GLEW_ARB_fragment_program) - -#endif /* GL_ARB_fragment_program */ - -/* --------------------- GL_ARB_fragment_program_shadow -------------------- */ - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 - -#define GLEW_ARB_fragment_program_shadow GLEW_GET_VAR(__GLEW_ARB_fragment_program_shadow) - -#endif /* GL_ARB_fragment_program_shadow */ - -/* ------------------------- GL_ARB_fragment_shader ------------------------ */ - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 - -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B - -#define GLEW_ARB_fragment_shader GLEW_GET_VAR(__GLEW_ARB_fragment_shader) - -#endif /* GL_ARB_fragment_shader */ - -/* ----------------------- GL_ARB_framebuffer_object ----------------------- */ - -#ifndef GL_ARB_framebuffer_object -#define GL_ARB_framebuffer_object 1 - -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 -#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 -#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 -#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 -#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 -#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 -#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 -#define GL_FRAMEBUFFER_DEFAULT 0x8218 -#define GL_FRAMEBUFFER_UNDEFINED 0x8219 -#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define GL_INDEX 0x8222 -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_SRGB 0x8C40 -#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_READ_FRAMEBUFFER 0x8CA8 -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA -#define GL_RENDERBUFFER_SAMPLES 0x8CAB -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_COLOR_ATTACHMENT1 0x8CE1 -#define GL_COLOR_ATTACHMENT2 0x8CE2 -#define GL_COLOR_ATTACHMENT3 0x8CE3 -#define GL_COLOR_ATTACHMENT4 0x8CE4 -#define GL_COLOR_ATTACHMENT5 0x8CE5 -#define GL_COLOR_ATTACHMENT6 0x8CE6 -#define GL_COLOR_ATTACHMENT7 0x8CE7 -#define GL_COLOR_ATTACHMENT8 0x8CE8 -#define GL_COLOR_ATTACHMENT9 0x8CE9 -#define GL_COLOR_ATTACHMENT10 0x8CEA -#define GL_COLOR_ATTACHMENT11 0x8CEB -#define GL_COLOR_ATTACHMENT12 0x8CEC -#define GL_COLOR_ATTACHMENT13 0x8CED -#define GL_COLOR_ATTACHMENT14 0x8CEE -#define GL_COLOR_ATTACHMENT15 0x8CEF -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_STENCIL_INDEX1 0x8D46 -#define GL_STENCIL_INDEX4 0x8D47 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_STENCIL_INDEX16 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 - -typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); -typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint* framebuffers); -typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint* renderbuffers); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURLAYERPROC) (GLenum target,GLenum attachment, GLuint texture,GLint level,GLint layer); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint layer); -typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint* framebuffers); -typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint* renderbuffers); -typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); -typedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); - -#define glBindFramebuffer GLEW_GET_FUN(__glewBindFramebuffer) -#define glBindRenderbuffer GLEW_GET_FUN(__glewBindRenderbuffer) -#define glBlitFramebuffer GLEW_GET_FUN(__glewBlitFramebuffer) -#define glCheckFramebufferStatus GLEW_GET_FUN(__glewCheckFramebufferStatus) -#define glDeleteFramebuffers GLEW_GET_FUN(__glewDeleteFramebuffers) -#define glDeleteRenderbuffers GLEW_GET_FUN(__glewDeleteRenderbuffers) -#define glFramebufferRenderbuffer GLEW_GET_FUN(__glewFramebufferRenderbuffer) -#define glFramebufferTexturLayer GLEW_GET_FUN(__glewFramebufferTexturLayer) -#define glFramebufferTexture1D GLEW_GET_FUN(__glewFramebufferTexture1D) -#define glFramebufferTexture2D GLEW_GET_FUN(__glewFramebufferTexture2D) -#define glFramebufferTexture3D GLEW_GET_FUN(__glewFramebufferTexture3D) -#define glGenFramebuffers GLEW_GET_FUN(__glewGenFramebuffers) -#define glGenRenderbuffers GLEW_GET_FUN(__glewGenRenderbuffers) -#define glGenerateMipmap GLEW_GET_FUN(__glewGenerateMipmap) -#define glGetFramebufferAttachmentParameteriv GLEW_GET_FUN(__glewGetFramebufferAttachmentParameteriv) -#define glGetRenderbufferParameteriv GLEW_GET_FUN(__glewGetRenderbufferParameteriv) -#define glIsFramebuffer GLEW_GET_FUN(__glewIsFramebuffer) -#define glIsRenderbuffer GLEW_GET_FUN(__glewIsRenderbuffer) -#define glRenderbufferStorage GLEW_GET_FUN(__glewRenderbufferStorage) -#define glRenderbufferStorageMultisample GLEW_GET_FUN(__glewRenderbufferStorageMultisample) - -#define GLEW_ARB_framebuffer_object GLEW_GET_VAR(__GLEW_ARB_framebuffer_object) - -#endif /* GL_ARB_framebuffer_object */ - -/* ------------------------ GL_ARB_framebuffer_sRGB ------------------------ */ - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_ARB_framebuffer_sRGB 1 - -#define GL_FRAMEBUFFER_SRGB 0x8DB9 - -#define GLEW_ARB_framebuffer_sRGB GLEW_GET_VAR(__GLEW_ARB_framebuffer_sRGB) - -#endif /* GL_ARB_framebuffer_sRGB */ - -/* ------------------------ GL_ARB_geometry_shader4 ------------------------ */ - -#ifndef GL_ARB_geometry_shader4 -#define GL_ARB_geometry_shader4 1 - -#define GL_LINES_ADJACENCY_ARB 0xA -#define GL_LINE_STRIP_ADJACENCY_ARB 0xB -#define GL_TRIANGLES_ADJACENCY_ARB 0xC -#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0xD -#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 -#define GL_GEOMETRY_SHADER_ARB 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 - -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); - -#define glFramebufferTextureARB GLEW_GET_FUN(__glewFramebufferTextureARB) -#define glFramebufferTextureFaceARB GLEW_GET_FUN(__glewFramebufferTextureFaceARB) -#define glFramebufferTextureLayerARB GLEW_GET_FUN(__glewFramebufferTextureLayerARB) -#define glProgramParameteriARB GLEW_GET_FUN(__glewProgramParameteriARB) - -#define GLEW_ARB_geometry_shader4 GLEW_GET_VAR(__GLEW_ARB_geometry_shader4) - -#endif /* GL_ARB_geometry_shader4 */ - -/* ------------------------ GL_ARB_half_float_pixel ------------------------ */ - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 - -#define GL_HALF_FLOAT_ARB 0x140B - -#define GLEW_ARB_half_float_pixel GLEW_GET_VAR(__GLEW_ARB_half_float_pixel) - -#endif /* GL_ARB_half_float_pixel */ - -/* ------------------------ GL_ARB_half_float_vertex ----------------------- */ - -#ifndef GL_ARB_half_float_vertex -#define GL_ARB_half_float_vertex 1 - -#define GL_HALF_FLOAT 0x140B - -#define GLEW_ARB_half_float_vertex GLEW_GET_VAR(__GLEW_ARB_half_float_vertex) - -#endif /* GL_ARB_half_float_vertex */ - -/* ----------------------------- GL_ARB_imaging ---------------------------- */ - -#ifndef GL_ARB_imaging -#define GL_ARB_imaging 1 - -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_BLEND_EQUATION 0x8009 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_IGNORE_BORDER 0x8150 -#define GL_CONSTANT_BORDER 0x8151 -#define GL_WRAP_BORDER 0x8152 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 - -typedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (GLAPIENTRY * PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum types, GLvoid *values); -typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (GLAPIENTRY * PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (GLAPIENTRY * PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLRESETMINMAXPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); - -#define glColorSubTable GLEW_GET_FUN(__glewColorSubTable) -#define glColorTable GLEW_GET_FUN(__glewColorTable) -#define glColorTableParameterfv GLEW_GET_FUN(__glewColorTableParameterfv) -#define glColorTableParameteriv GLEW_GET_FUN(__glewColorTableParameteriv) -#define glConvolutionFilter1D GLEW_GET_FUN(__glewConvolutionFilter1D) -#define glConvolutionFilter2D GLEW_GET_FUN(__glewConvolutionFilter2D) -#define glConvolutionParameterf GLEW_GET_FUN(__glewConvolutionParameterf) -#define glConvolutionParameterfv GLEW_GET_FUN(__glewConvolutionParameterfv) -#define glConvolutionParameteri GLEW_GET_FUN(__glewConvolutionParameteri) -#define glConvolutionParameteriv GLEW_GET_FUN(__glewConvolutionParameteriv) -#define glCopyColorSubTable GLEW_GET_FUN(__glewCopyColorSubTable) -#define glCopyColorTable GLEW_GET_FUN(__glewCopyColorTable) -#define glCopyConvolutionFilter1D GLEW_GET_FUN(__glewCopyConvolutionFilter1D) -#define glCopyConvolutionFilter2D GLEW_GET_FUN(__glewCopyConvolutionFilter2D) -#define glGetColorTable GLEW_GET_FUN(__glewGetColorTable) -#define glGetColorTableParameterfv GLEW_GET_FUN(__glewGetColorTableParameterfv) -#define glGetColorTableParameteriv GLEW_GET_FUN(__glewGetColorTableParameteriv) -#define glGetConvolutionFilter GLEW_GET_FUN(__glewGetConvolutionFilter) -#define glGetConvolutionParameterfv GLEW_GET_FUN(__glewGetConvolutionParameterfv) -#define glGetConvolutionParameteriv GLEW_GET_FUN(__glewGetConvolutionParameteriv) -#define glGetHistogram GLEW_GET_FUN(__glewGetHistogram) -#define glGetHistogramParameterfv GLEW_GET_FUN(__glewGetHistogramParameterfv) -#define glGetHistogramParameteriv GLEW_GET_FUN(__glewGetHistogramParameteriv) -#define glGetMinmax GLEW_GET_FUN(__glewGetMinmax) -#define glGetMinmaxParameterfv GLEW_GET_FUN(__glewGetMinmaxParameterfv) -#define glGetMinmaxParameteriv GLEW_GET_FUN(__glewGetMinmaxParameteriv) -#define glGetSeparableFilter GLEW_GET_FUN(__glewGetSeparableFilter) -#define glHistogram GLEW_GET_FUN(__glewHistogram) -#define glMinmax GLEW_GET_FUN(__glewMinmax) -#define glResetHistogram GLEW_GET_FUN(__glewResetHistogram) -#define glResetMinmax GLEW_GET_FUN(__glewResetMinmax) -#define glSeparableFilter2D GLEW_GET_FUN(__glewSeparableFilter2D) - -#define GLEW_ARB_imaging GLEW_GET_VAR(__GLEW_ARB_imaging) - -#endif /* GL_ARB_imaging */ - -/* ------------------------ GL_ARB_instanced_arrays ------------------------ */ - -#ifndef GL_ARB_instanced_arrays -#define GL_ARB_instanced_arrays 1 - -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE - -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); - -#define glVertexAttribDivisorARB GLEW_GET_FUN(__glewVertexAttribDivisorARB) - -#define GLEW_ARB_instanced_arrays GLEW_GET_VAR(__GLEW_ARB_instanced_arrays) - -#endif /* GL_ARB_instanced_arrays */ - -/* ------------------------ GL_ARB_map_buffer_range ------------------------ */ - -#ifndef GL_ARB_map_buffer_range -#define GL_ARB_map_buffer_range 1 - -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 - -typedef void (GLAPIENTRY * PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); -typedef GLvoid * (GLAPIENTRY * PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); - -#define glFlushMappedBufferRange GLEW_GET_FUN(__glewFlushMappedBufferRange) -#define glMapBufferRange GLEW_GET_FUN(__glewMapBufferRange) - -#define GLEW_ARB_map_buffer_range GLEW_GET_VAR(__GLEW_ARB_map_buffer_range) - -#endif /* GL_ARB_map_buffer_range */ - -/* ------------------------- GL_ARB_matrix_palette ------------------------- */ - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 - -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 - -typedef void (GLAPIENTRY * PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (GLAPIENTRY * PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); -typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUBVARBPROC) (GLint size, GLubyte *indices); -typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUIVARBPROC) (GLint size, GLuint *indices); -typedef void (GLAPIENTRY * PFNGLMATRIXINDEXUSVARBPROC) (GLint size, GLushort *indices); - -#define glCurrentPaletteMatrixARB GLEW_GET_FUN(__glewCurrentPaletteMatrixARB) -#define glMatrixIndexPointerARB GLEW_GET_FUN(__glewMatrixIndexPointerARB) -#define glMatrixIndexubvARB GLEW_GET_FUN(__glewMatrixIndexubvARB) -#define glMatrixIndexuivARB GLEW_GET_FUN(__glewMatrixIndexuivARB) -#define glMatrixIndexusvARB GLEW_GET_FUN(__glewMatrixIndexusvARB) - -#define GLEW_ARB_matrix_palette GLEW_GET_VAR(__GLEW_ARB_matrix_palette) - -#endif /* GL_ARB_matrix_palette */ - -/* --------------------------- GL_ARB_multisample -------------------------- */ - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 - -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 - -typedef void (GLAPIENTRY * PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); - -#define glSampleCoverageARB GLEW_GET_FUN(__glewSampleCoverageARB) - -#define GLEW_ARB_multisample GLEW_GET_VAR(__GLEW_ARB_multisample) - -#endif /* GL_ARB_multisample */ - -/* -------------------------- GL_ARB_multitexture -------------------------- */ - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 - -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 - -typedef void (GLAPIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (GLAPIENTRY * PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); - -#define glActiveTextureARB GLEW_GET_FUN(__glewActiveTextureARB) -#define glClientActiveTextureARB GLEW_GET_FUN(__glewClientActiveTextureARB) -#define glMultiTexCoord1dARB GLEW_GET_FUN(__glewMultiTexCoord1dARB) -#define glMultiTexCoord1dvARB GLEW_GET_FUN(__glewMultiTexCoord1dvARB) -#define glMultiTexCoord1fARB GLEW_GET_FUN(__glewMultiTexCoord1fARB) -#define glMultiTexCoord1fvARB GLEW_GET_FUN(__glewMultiTexCoord1fvARB) -#define glMultiTexCoord1iARB GLEW_GET_FUN(__glewMultiTexCoord1iARB) -#define glMultiTexCoord1ivARB GLEW_GET_FUN(__glewMultiTexCoord1ivARB) -#define glMultiTexCoord1sARB GLEW_GET_FUN(__glewMultiTexCoord1sARB) -#define glMultiTexCoord1svARB GLEW_GET_FUN(__glewMultiTexCoord1svARB) -#define glMultiTexCoord2dARB GLEW_GET_FUN(__glewMultiTexCoord2dARB) -#define glMultiTexCoord2dvARB GLEW_GET_FUN(__glewMultiTexCoord2dvARB) -#define glMultiTexCoord2fARB GLEW_GET_FUN(__glewMultiTexCoord2fARB) -#define glMultiTexCoord2fvARB GLEW_GET_FUN(__glewMultiTexCoord2fvARB) -#define glMultiTexCoord2iARB GLEW_GET_FUN(__glewMultiTexCoord2iARB) -#define glMultiTexCoord2ivARB GLEW_GET_FUN(__glewMultiTexCoord2ivARB) -#define glMultiTexCoord2sARB GLEW_GET_FUN(__glewMultiTexCoord2sARB) -#define glMultiTexCoord2svARB GLEW_GET_FUN(__glewMultiTexCoord2svARB) -#define glMultiTexCoord3dARB GLEW_GET_FUN(__glewMultiTexCoord3dARB) -#define glMultiTexCoord3dvARB GLEW_GET_FUN(__glewMultiTexCoord3dvARB) -#define glMultiTexCoord3fARB GLEW_GET_FUN(__glewMultiTexCoord3fARB) -#define glMultiTexCoord3fvARB GLEW_GET_FUN(__glewMultiTexCoord3fvARB) -#define glMultiTexCoord3iARB GLEW_GET_FUN(__glewMultiTexCoord3iARB) -#define glMultiTexCoord3ivARB GLEW_GET_FUN(__glewMultiTexCoord3ivARB) -#define glMultiTexCoord3sARB GLEW_GET_FUN(__glewMultiTexCoord3sARB) -#define glMultiTexCoord3svARB GLEW_GET_FUN(__glewMultiTexCoord3svARB) -#define glMultiTexCoord4dARB GLEW_GET_FUN(__glewMultiTexCoord4dARB) -#define glMultiTexCoord4dvARB GLEW_GET_FUN(__glewMultiTexCoord4dvARB) -#define glMultiTexCoord4fARB GLEW_GET_FUN(__glewMultiTexCoord4fARB) -#define glMultiTexCoord4fvARB GLEW_GET_FUN(__glewMultiTexCoord4fvARB) -#define glMultiTexCoord4iARB GLEW_GET_FUN(__glewMultiTexCoord4iARB) -#define glMultiTexCoord4ivARB GLEW_GET_FUN(__glewMultiTexCoord4ivARB) -#define glMultiTexCoord4sARB GLEW_GET_FUN(__glewMultiTexCoord4sARB) -#define glMultiTexCoord4svARB GLEW_GET_FUN(__glewMultiTexCoord4svARB) - -#define GLEW_ARB_multitexture GLEW_GET_VAR(__GLEW_ARB_multitexture) - -#endif /* GL_ARB_multitexture */ - -/* ------------------------- GL_ARB_occlusion_query ------------------------ */ - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 - -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 - -typedef void (GLAPIENTRY * PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (GLAPIENTRY * PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint* ids); -typedef void (GLAPIENTRY * PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISQUERYARBPROC) (GLuint id); - -#define glBeginQueryARB GLEW_GET_FUN(__glewBeginQueryARB) -#define glDeleteQueriesARB GLEW_GET_FUN(__glewDeleteQueriesARB) -#define glEndQueryARB GLEW_GET_FUN(__glewEndQueryARB) -#define glGenQueriesARB GLEW_GET_FUN(__glewGenQueriesARB) -#define glGetQueryObjectivARB GLEW_GET_FUN(__glewGetQueryObjectivARB) -#define glGetQueryObjectuivARB GLEW_GET_FUN(__glewGetQueryObjectuivARB) -#define glGetQueryivARB GLEW_GET_FUN(__glewGetQueryivARB) -#define glIsQueryARB GLEW_GET_FUN(__glewIsQueryARB) - -#define GLEW_ARB_occlusion_query GLEW_GET_VAR(__GLEW_ARB_occlusion_query) - -#endif /* GL_ARB_occlusion_query */ - -/* ----------------------- GL_ARB_pixel_buffer_object ---------------------- */ - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 - -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF - -#define GLEW_ARB_pixel_buffer_object GLEW_GET_VAR(__GLEW_ARB_pixel_buffer_object) - -#endif /* GL_ARB_pixel_buffer_object */ - -/* ------------------------ GL_ARB_point_parameters ------------------------ */ - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 - -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 - -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, GLfloat* params); - -#define glPointParameterfARB GLEW_GET_FUN(__glewPointParameterfARB) -#define glPointParameterfvARB GLEW_GET_FUN(__glewPointParameterfvARB) - -#define GLEW_ARB_point_parameters GLEW_GET_VAR(__GLEW_ARB_point_parameters) - -#endif /* GL_ARB_point_parameters */ - -/* -------------------------- GL_ARB_point_sprite -------------------------- */ - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 - -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 - -#define GLEW_ARB_point_sprite GLEW_GET_VAR(__GLEW_ARB_point_sprite) - -#endif /* GL_ARB_point_sprite */ - -/* ------------------------- GL_ARB_shader_objects ------------------------- */ - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 - -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 - -typedef char GLcharARB; -typedef unsigned int GLhandleARB; - -typedef void (GLAPIENTRY * PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (GLAPIENTRY * PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (GLAPIENTRY * PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef GLhandleARB (GLAPIENTRY * PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (GLAPIENTRY * PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef void (GLAPIENTRY * PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef void (GLAPIENTRY * PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (GLAPIENTRY * PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei* count, GLhandleARB *obj); -typedef GLhandleARB (GLAPIENTRY * PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (GLAPIENTRY * PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *infoLog); -typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei* length, GLcharARB *source); -typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint* params); -typedef void (GLAPIENTRY * PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (GLAPIENTRY * PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB ** string, const GLint *length); -typedef void (GLAPIENTRY * PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (GLAPIENTRY * PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (GLAPIENTRY * PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (GLAPIENTRY * PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (GLAPIENTRY * PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (GLAPIENTRY * PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (GLAPIENTRY * PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (GLAPIENTRY * PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (GLAPIENTRY * PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (GLAPIENTRY * PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); - -#define glAttachObjectARB GLEW_GET_FUN(__glewAttachObjectARB) -#define glCompileShaderARB GLEW_GET_FUN(__glewCompileShaderARB) -#define glCreateProgramObjectARB GLEW_GET_FUN(__glewCreateProgramObjectARB) -#define glCreateShaderObjectARB GLEW_GET_FUN(__glewCreateShaderObjectARB) -#define glDeleteObjectARB GLEW_GET_FUN(__glewDeleteObjectARB) -#define glDetachObjectARB GLEW_GET_FUN(__glewDetachObjectARB) -#define glGetActiveUniformARB GLEW_GET_FUN(__glewGetActiveUniformARB) -#define glGetAttachedObjectsARB GLEW_GET_FUN(__glewGetAttachedObjectsARB) -#define glGetHandleARB GLEW_GET_FUN(__glewGetHandleARB) -#define glGetInfoLogARB GLEW_GET_FUN(__glewGetInfoLogARB) -#define glGetObjectParameterfvARB GLEW_GET_FUN(__glewGetObjectParameterfvARB) -#define glGetObjectParameterivARB GLEW_GET_FUN(__glewGetObjectParameterivARB) -#define glGetShaderSourceARB GLEW_GET_FUN(__glewGetShaderSourceARB) -#define glGetUniformLocationARB GLEW_GET_FUN(__glewGetUniformLocationARB) -#define glGetUniformfvARB GLEW_GET_FUN(__glewGetUniformfvARB) -#define glGetUniformivARB GLEW_GET_FUN(__glewGetUniformivARB) -#define glLinkProgramARB GLEW_GET_FUN(__glewLinkProgramARB) -#define glShaderSourceARB GLEW_GET_FUN(__glewShaderSourceARB) -#define glUniform1fARB GLEW_GET_FUN(__glewUniform1fARB) -#define glUniform1fvARB GLEW_GET_FUN(__glewUniform1fvARB) -#define glUniform1iARB GLEW_GET_FUN(__glewUniform1iARB) -#define glUniform1ivARB GLEW_GET_FUN(__glewUniform1ivARB) -#define glUniform2fARB GLEW_GET_FUN(__glewUniform2fARB) -#define glUniform2fvARB GLEW_GET_FUN(__glewUniform2fvARB) -#define glUniform2iARB GLEW_GET_FUN(__glewUniform2iARB) -#define glUniform2ivARB GLEW_GET_FUN(__glewUniform2ivARB) -#define glUniform3fARB GLEW_GET_FUN(__glewUniform3fARB) -#define glUniform3fvARB GLEW_GET_FUN(__glewUniform3fvARB) -#define glUniform3iARB GLEW_GET_FUN(__glewUniform3iARB) -#define glUniform3ivARB GLEW_GET_FUN(__glewUniform3ivARB) -#define glUniform4fARB GLEW_GET_FUN(__glewUniform4fARB) -#define glUniform4fvARB GLEW_GET_FUN(__glewUniform4fvARB) -#define glUniform4iARB GLEW_GET_FUN(__glewUniform4iARB) -#define glUniform4ivARB GLEW_GET_FUN(__glewUniform4ivARB) -#define glUniformMatrix2fvARB GLEW_GET_FUN(__glewUniformMatrix2fvARB) -#define glUniformMatrix3fvARB GLEW_GET_FUN(__glewUniformMatrix3fvARB) -#define glUniformMatrix4fvARB GLEW_GET_FUN(__glewUniformMatrix4fvARB) -#define glUseProgramObjectARB GLEW_GET_FUN(__glewUseProgramObjectARB) -#define glValidateProgramARB GLEW_GET_FUN(__glewValidateProgramARB) - -#define GLEW_ARB_shader_objects GLEW_GET_VAR(__GLEW_ARB_shader_objects) - -#endif /* GL_ARB_shader_objects */ - -/* ---------------------- GL_ARB_shading_language_100 ---------------------- */ - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 - -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C - -#define GLEW_ARB_shading_language_100 GLEW_GET_VAR(__GLEW_ARB_shading_language_100) - -#endif /* GL_ARB_shading_language_100 */ - -/* ----------------------------- GL_ARB_shadow ----------------------------- */ - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 - -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E - -#define GLEW_ARB_shadow GLEW_GET_VAR(__GLEW_ARB_shadow) - -#endif /* GL_ARB_shadow */ - -/* ------------------------- GL_ARB_shadow_ambient ------------------------- */ - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 - -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF - -#define GLEW_ARB_shadow_ambient GLEW_GET_VAR(__GLEW_ARB_shadow_ambient) - -#endif /* GL_ARB_shadow_ambient */ - -/* ---------------------- GL_ARB_texture_border_clamp ---------------------- */ - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 - -#define GL_CLAMP_TO_BORDER_ARB 0x812D - -#define GLEW_ARB_texture_border_clamp GLEW_GET_VAR(__GLEW_ARB_texture_border_clamp) - -#endif /* GL_ARB_texture_border_clamp */ - -/* ---------------------- GL_ARB_texture_buffer_object --------------------- */ - -#ifndef GL_ARB_texture_buffer_object -#define GL_ARB_texture_buffer_object 1 - -#define GL_TEXTURE_BUFFER_ARB 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E - -typedef void (GLAPIENTRY * PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); - -#define glTexBufferARB GLEW_GET_FUN(__glewTexBufferARB) - -#define GLEW_ARB_texture_buffer_object GLEW_GET_VAR(__GLEW_ARB_texture_buffer_object) - -#endif /* GL_ARB_texture_buffer_object */ - -/* ----------------------- GL_ARB_texture_compression ---------------------- */ - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 - -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 - -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, void* img); - -#define glCompressedTexImage1DARB GLEW_GET_FUN(__glewCompressedTexImage1DARB) -#define glCompressedTexImage2DARB GLEW_GET_FUN(__glewCompressedTexImage2DARB) -#define glCompressedTexImage3DARB GLEW_GET_FUN(__glewCompressedTexImage3DARB) -#define glCompressedTexSubImage1DARB GLEW_GET_FUN(__glewCompressedTexSubImage1DARB) -#define glCompressedTexSubImage2DARB GLEW_GET_FUN(__glewCompressedTexSubImage2DARB) -#define glCompressedTexSubImage3DARB GLEW_GET_FUN(__glewCompressedTexSubImage3DARB) -#define glGetCompressedTexImageARB GLEW_GET_FUN(__glewGetCompressedTexImageARB) - -#define GLEW_ARB_texture_compression GLEW_GET_VAR(__GLEW_ARB_texture_compression) - -#endif /* GL_ARB_texture_compression */ - -/* -------------------- GL_ARB_texture_compression_rgtc -------------------- */ - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_ARB_texture_compression_rgtc 1 - -#define GL_COMPRESSED_RED_RGTC1 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define GL_COMPRESSED_RG_RGTC2 0x8DBD -#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE - -#define GLEW_ARB_texture_compression_rgtc GLEW_GET_VAR(__GLEW_ARB_texture_compression_rgtc) - -#endif /* GL_ARB_texture_compression_rgtc */ - -/* ------------------------ GL_ARB_texture_cube_map ------------------------ */ - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 - -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C - -#define GLEW_ARB_texture_cube_map GLEW_GET_VAR(__GLEW_ARB_texture_cube_map) - -#endif /* GL_ARB_texture_cube_map */ - -/* ------------------------- GL_ARB_texture_env_add ------------------------ */ - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 - -#define GLEW_ARB_texture_env_add GLEW_GET_VAR(__GLEW_ARB_texture_env_add) - -#endif /* GL_ARB_texture_env_add */ - -/* ----------------------- GL_ARB_texture_env_combine ---------------------- */ - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 - -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A - -#define GLEW_ARB_texture_env_combine GLEW_GET_VAR(__GLEW_ARB_texture_env_combine) - -#endif /* GL_ARB_texture_env_combine */ - -/* ---------------------- GL_ARB_texture_env_crossbar ---------------------- */ - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 - -#define GLEW_ARB_texture_env_crossbar GLEW_GET_VAR(__GLEW_ARB_texture_env_crossbar) - -#endif /* GL_ARB_texture_env_crossbar */ - -/* ------------------------ GL_ARB_texture_env_dot3 ------------------------ */ - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 - -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF - -#define GLEW_ARB_texture_env_dot3 GLEW_GET_VAR(__GLEW_ARB_texture_env_dot3) - -#endif /* GL_ARB_texture_env_dot3 */ - -/* -------------------------- GL_ARB_texture_float ------------------------- */ - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 - -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 - -#define GLEW_ARB_texture_float GLEW_GET_VAR(__GLEW_ARB_texture_float) - -#endif /* GL_ARB_texture_float */ - -/* --------------------- GL_ARB_texture_mirrored_repeat -------------------- */ - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 - -#define GL_MIRRORED_REPEAT_ARB 0x8370 - -#define GLEW_ARB_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_ARB_texture_mirrored_repeat) - -#endif /* GL_ARB_texture_mirrored_repeat */ - -/* -------------------- GL_ARB_texture_non_power_of_two -------------------- */ - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 - -#define GLEW_ARB_texture_non_power_of_two GLEW_GET_VAR(__GLEW_ARB_texture_non_power_of_two) - -#endif /* GL_ARB_texture_non_power_of_two */ - -/* ------------------------ GL_ARB_texture_rectangle ----------------------- */ - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 - -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 - -#define GLEW_ARB_texture_rectangle GLEW_GET_VAR(__GLEW_ARB_texture_rectangle) - -#endif /* GL_ARB_texture_rectangle */ - -/* --------------------------- GL_ARB_texture_rg --------------------------- */ - -#ifndef GL_ARB_texture_rg -#define GL_ARB_texture_rg 1 - -#define GL_RED 0x1903 -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_R16 0x822A -#define GL_RG8 0x822B -#define GL_RG16 0x822C -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C - -#define GLEW_ARB_texture_rg GLEW_GET_VAR(__GLEW_ARB_texture_rg) - -#endif /* GL_ARB_texture_rg */ - -/* ------------------------ GL_ARB_transpose_matrix ------------------------ */ - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 - -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 - -typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]); -typedef void (GLAPIENTRY * PFNGLLOADTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]); -typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXDARBPROC) (GLdouble m[16]); -typedef void (GLAPIENTRY * PFNGLMULTTRANSPOSEMATRIXFARBPROC) (GLfloat m[16]); - -#define glLoadTransposeMatrixdARB GLEW_GET_FUN(__glewLoadTransposeMatrixdARB) -#define glLoadTransposeMatrixfARB GLEW_GET_FUN(__glewLoadTransposeMatrixfARB) -#define glMultTransposeMatrixdARB GLEW_GET_FUN(__glewMultTransposeMatrixdARB) -#define glMultTransposeMatrixfARB GLEW_GET_FUN(__glewMultTransposeMatrixfARB) - -#define GLEW_ARB_transpose_matrix GLEW_GET_VAR(__GLEW_ARB_transpose_matrix) - -#endif /* GL_ARB_transpose_matrix */ - -/* ----------------------- GL_ARB_vertex_array_object ---------------------- */ - -#ifndef GL_ARB_vertex_array_object -#define GL_ARB_vertex_array_object 1 - -#define GL_VERTEX_ARRAY_BINDING 0x85B5 - -typedef void (GLAPIENTRY * PFNGLBINDVERTEXARRAYPROC) (GLuint array); -typedef void (GLAPIENTRY * PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint* arrays); -typedef void (GLAPIENTRY * PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays); -typedef GLboolean (GLAPIENTRY * PFNGLISVERTEXARRAYPROC) (GLuint array); - -#define glBindVertexArray GLEW_GET_FUN(__glewBindVertexArray) -#define glDeleteVertexArrays GLEW_GET_FUN(__glewDeleteVertexArrays) -#define glGenVertexArrays GLEW_GET_FUN(__glewGenVertexArrays) -#define glIsVertexArray GLEW_GET_FUN(__glewIsVertexArray) - -#define GLEW_ARB_vertex_array_object GLEW_GET_VAR(__GLEW_ARB_vertex_array_object) - -#endif /* GL_ARB_vertex_array_object */ - -/* -------------------------- GL_ARB_vertex_blend -------------------------- */ - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 - -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F - -typedef void (GLAPIENTRY * PFNGLVERTEXBLENDARBPROC) (GLint count); -typedef void (GLAPIENTRY * PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); -typedef void (GLAPIENTRY * PFNGLWEIGHTBVARBPROC) (GLint size, GLbyte *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTDVARBPROC) (GLint size, GLdouble *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTFVARBPROC) (GLint size, GLfloat *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTIVARBPROC) (GLint size, GLint *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTSVARBPROC) (GLint size, GLshort *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTUBVARBPROC) (GLint size, GLubyte *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTUIVARBPROC) (GLint size, GLuint *weights); -typedef void (GLAPIENTRY * PFNGLWEIGHTUSVARBPROC) (GLint size, GLushort *weights); - -#define glVertexBlendARB GLEW_GET_FUN(__glewVertexBlendARB) -#define glWeightPointerARB GLEW_GET_FUN(__glewWeightPointerARB) -#define glWeightbvARB GLEW_GET_FUN(__glewWeightbvARB) -#define glWeightdvARB GLEW_GET_FUN(__glewWeightdvARB) -#define glWeightfvARB GLEW_GET_FUN(__glewWeightfvARB) -#define glWeightivARB GLEW_GET_FUN(__glewWeightivARB) -#define glWeightsvARB GLEW_GET_FUN(__glewWeightsvARB) -#define glWeightubvARB GLEW_GET_FUN(__glewWeightubvARB) -#define glWeightuivARB GLEW_GET_FUN(__glewWeightuivARB) -#define glWeightusvARB GLEW_GET_FUN(__glewWeightusvARB) - -#define GLEW_ARB_vertex_blend GLEW_GET_VAR(__GLEW_ARB_vertex_blend) - -#endif /* GL_ARB_vertex_blend */ - -/* ---------------------- GL_ARB_vertex_buffer_object ---------------------- */ - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 - -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA - -typedef ptrdiff_t GLsizeiptrARB; -typedef ptrdiff_t GLintptrARB; - -typedef void (GLAPIENTRY * PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid* data, GLenum usage); -typedef void (GLAPIENTRY * PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid* data); -typedef void (GLAPIENTRY * PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint* buffers); -typedef void (GLAPIENTRY * PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint* buffers); -typedef void (GLAPIENTRY * PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid** params); -typedef void (GLAPIENTRY * PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid* data); -typedef GLboolean (GLAPIENTRY * PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef GLvoid * (GLAPIENTRY * PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (GLAPIENTRY * PFNGLUNMAPBUFFERARBPROC) (GLenum target); - -#define glBindBufferARB GLEW_GET_FUN(__glewBindBufferARB) -#define glBufferDataARB GLEW_GET_FUN(__glewBufferDataARB) -#define glBufferSubDataARB GLEW_GET_FUN(__glewBufferSubDataARB) -#define glDeleteBuffersARB GLEW_GET_FUN(__glewDeleteBuffersARB) -#define glGenBuffersARB GLEW_GET_FUN(__glewGenBuffersARB) -#define glGetBufferParameterivARB GLEW_GET_FUN(__glewGetBufferParameterivARB) -#define glGetBufferPointervARB GLEW_GET_FUN(__glewGetBufferPointervARB) -#define glGetBufferSubDataARB GLEW_GET_FUN(__glewGetBufferSubDataARB) -#define glIsBufferARB GLEW_GET_FUN(__glewIsBufferARB) -#define glMapBufferARB GLEW_GET_FUN(__glewMapBufferARB) -#define glUnmapBufferARB GLEW_GET_FUN(__glewUnmapBufferARB) - -#define GLEW_ARB_vertex_buffer_object GLEW_GET_VAR(__GLEW_ARB_vertex_buffer_object) - -#endif /* GL_ARB_vertex_buffer_object */ - -/* ------------------------- GL_ARB_vertex_program ------------------------- */ - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 - -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF - -typedef void (GLAPIENTRY * PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint* programs); -typedef void (GLAPIENTRY * PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (GLAPIENTRY * PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (GLAPIENTRY * PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint* programs); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void* string); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid** pointer); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMARBPROC) (GLuint program); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void* string); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* pointer); - -#define glBindProgramARB GLEW_GET_FUN(__glewBindProgramARB) -#define glDeleteProgramsARB GLEW_GET_FUN(__glewDeleteProgramsARB) -#define glDisableVertexAttribArrayARB GLEW_GET_FUN(__glewDisableVertexAttribArrayARB) -#define glEnableVertexAttribArrayARB GLEW_GET_FUN(__glewEnableVertexAttribArrayARB) -#define glGenProgramsARB GLEW_GET_FUN(__glewGenProgramsARB) -#define glGetProgramEnvParameterdvARB GLEW_GET_FUN(__glewGetProgramEnvParameterdvARB) -#define glGetProgramEnvParameterfvARB GLEW_GET_FUN(__glewGetProgramEnvParameterfvARB) -#define glGetProgramLocalParameterdvARB GLEW_GET_FUN(__glewGetProgramLocalParameterdvARB) -#define glGetProgramLocalParameterfvARB GLEW_GET_FUN(__glewGetProgramLocalParameterfvARB) -#define glGetProgramStringARB GLEW_GET_FUN(__glewGetProgramStringARB) -#define glGetProgramivARB GLEW_GET_FUN(__glewGetProgramivARB) -#define glGetVertexAttribPointervARB GLEW_GET_FUN(__glewGetVertexAttribPointervARB) -#define glGetVertexAttribdvARB GLEW_GET_FUN(__glewGetVertexAttribdvARB) -#define glGetVertexAttribfvARB GLEW_GET_FUN(__glewGetVertexAttribfvARB) -#define glGetVertexAttribivARB GLEW_GET_FUN(__glewGetVertexAttribivARB) -#define glIsProgramARB GLEW_GET_FUN(__glewIsProgramARB) -#define glProgramEnvParameter4dARB GLEW_GET_FUN(__glewProgramEnvParameter4dARB) -#define glProgramEnvParameter4dvARB GLEW_GET_FUN(__glewProgramEnvParameter4dvARB) -#define glProgramEnvParameter4fARB GLEW_GET_FUN(__glewProgramEnvParameter4fARB) -#define glProgramEnvParameter4fvARB GLEW_GET_FUN(__glewProgramEnvParameter4fvARB) -#define glProgramLocalParameter4dARB GLEW_GET_FUN(__glewProgramLocalParameter4dARB) -#define glProgramLocalParameter4dvARB GLEW_GET_FUN(__glewProgramLocalParameter4dvARB) -#define glProgramLocalParameter4fARB GLEW_GET_FUN(__glewProgramLocalParameter4fARB) -#define glProgramLocalParameter4fvARB GLEW_GET_FUN(__glewProgramLocalParameter4fvARB) -#define glProgramStringARB GLEW_GET_FUN(__glewProgramStringARB) -#define glVertexAttrib1dARB GLEW_GET_FUN(__glewVertexAttrib1dARB) -#define glVertexAttrib1dvARB GLEW_GET_FUN(__glewVertexAttrib1dvARB) -#define glVertexAttrib1fARB GLEW_GET_FUN(__glewVertexAttrib1fARB) -#define glVertexAttrib1fvARB GLEW_GET_FUN(__glewVertexAttrib1fvARB) -#define glVertexAttrib1sARB GLEW_GET_FUN(__glewVertexAttrib1sARB) -#define glVertexAttrib1svARB GLEW_GET_FUN(__glewVertexAttrib1svARB) -#define glVertexAttrib2dARB GLEW_GET_FUN(__glewVertexAttrib2dARB) -#define glVertexAttrib2dvARB GLEW_GET_FUN(__glewVertexAttrib2dvARB) -#define glVertexAttrib2fARB GLEW_GET_FUN(__glewVertexAttrib2fARB) -#define glVertexAttrib2fvARB GLEW_GET_FUN(__glewVertexAttrib2fvARB) -#define glVertexAttrib2sARB GLEW_GET_FUN(__glewVertexAttrib2sARB) -#define glVertexAttrib2svARB GLEW_GET_FUN(__glewVertexAttrib2svARB) -#define glVertexAttrib3dARB GLEW_GET_FUN(__glewVertexAttrib3dARB) -#define glVertexAttrib3dvARB GLEW_GET_FUN(__glewVertexAttrib3dvARB) -#define glVertexAttrib3fARB GLEW_GET_FUN(__glewVertexAttrib3fARB) -#define glVertexAttrib3fvARB GLEW_GET_FUN(__glewVertexAttrib3fvARB) -#define glVertexAttrib3sARB GLEW_GET_FUN(__glewVertexAttrib3sARB) -#define glVertexAttrib3svARB GLEW_GET_FUN(__glewVertexAttrib3svARB) -#define glVertexAttrib4NbvARB GLEW_GET_FUN(__glewVertexAttrib4NbvARB) -#define glVertexAttrib4NivARB GLEW_GET_FUN(__glewVertexAttrib4NivARB) -#define glVertexAttrib4NsvARB GLEW_GET_FUN(__glewVertexAttrib4NsvARB) -#define glVertexAttrib4NubARB GLEW_GET_FUN(__glewVertexAttrib4NubARB) -#define glVertexAttrib4NubvARB GLEW_GET_FUN(__glewVertexAttrib4NubvARB) -#define glVertexAttrib4NuivARB GLEW_GET_FUN(__glewVertexAttrib4NuivARB) -#define glVertexAttrib4NusvARB GLEW_GET_FUN(__glewVertexAttrib4NusvARB) -#define glVertexAttrib4bvARB GLEW_GET_FUN(__glewVertexAttrib4bvARB) -#define glVertexAttrib4dARB GLEW_GET_FUN(__glewVertexAttrib4dARB) -#define glVertexAttrib4dvARB GLEW_GET_FUN(__glewVertexAttrib4dvARB) -#define glVertexAttrib4fARB GLEW_GET_FUN(__glewVertexAttrib4fARB) -#define glVertexAttrib4fvARB GLEW_GET_FUN(__glewVertexAttrib4fvARB) -#define glVertexAttrib4ivARB GLEW_GET_FUN(__glewVertexAttrib4ivARB) -#define glVertexAttrib4sARB GLEW_GET_FUN(__glewVertexAttrib4sARB) -#define glVertexAttrib4svARB GLEW_GET_FUN(__glewVertexAttrib4svARB) -#define glVertexAttrib4ubvARB GLEW_GET_FUN(__glewVertexAttrib4ubvARB) -#define glVertexAttrib4uivARB GLEW_GET_FUN(__glewVertexAttrib4uivARB) -#define glVertexAttrib4usvARB GLEW_GET_FUN(__glewVertexAttrib4usvARB) -#define glVertexAttribPointerARB GLEW_GET_FUN(__glewVertexAttribPointerARB) - -#define GLEW_ARB_vertex_program GLEW_GET_VAR(__GLEW_ARB_vertex_program) - -#endif /* GL_ARB_vertex_program */ - -/* -------------------------- GL_ARB_vertex_shader ------------------------- */ - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 - -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A - -typedef void (GLAPIENTRY * PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB* name); -typedef void (GLAPIENTRY * PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei* length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (GLAPIENTRY * PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB* name); - -#define glBindAttribLocationARB GLEW_GET_FUN(__glewBindAttribLocationARB) -#define glGetActiveAttribARB GLEW_GET_FUN(__glewGetActiveAttribARB) -#define glGetAttribLocationARB GLEW_GET_FUN(__glewGetAttribLocationARB) - -#define GLEW_ARB_vertex_shader GLEW_GET_VAR(__GLEW_ARB_vertex_shader) - -#endif /* GL_ARB_vertex_shader */ - -/* --------------------------- GL_ARB_window_pos --------------------------- */ - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 - -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVARBPROC) (const GLdouble* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVARBPROC) (const GLfloat* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVARBPROC) (const GLint* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVARBPROC) (const GLshort* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVARBPROC) (const GLdouble* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVARBPROC) (const GLfloat* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVARBPROC) (const GLint* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVARBPROC) (const GLshort* p); - -#define glWindowPos2dARB GLEW_GET_FUN(__glewWindowPos2dARB) -#define glWindowPos2dvARB GLEW_GET_FUN(__glewWindowPos2dvARB) -#define glWindowPos2fARB GLEW_GET_FUN(__glewWindowPos2fARB) -#define glWindowPos2fvARB GLEW_GET_FUN(__glewWindowPos2fvARB) -#define glWindowPos2iARB GLEW_GET_FUN(__glewWindowPos2iARB) -#define glWindowPos2ivARB GLEW_GET_FUN(__glewWindowPos2ivARB) -#define glWindowPos2sARB GLEW_GET_FUN(__glewWindowPos2sARB) -#define glWindowPos2svARB GLEW_GET_FUN(__glewWindowPos2svARB) -#define glWindowPos3dARB GLEW_GET_FUN(__glewWindowPos3dARB) -#define glWindowPos3dvARB GLEW_GET_FUN(__glewWindowPos3dvARB) -#define glWindowPos3fARB GLEW_GET_FUN(__glewWindowPos3fARB) -#define glWindowPos3fvARB GLEW_GET_FUN(__glewWindowPos3fvARB) -#define glWindowPos3iARB GLEW_GET_FUN(__glewWindowPos3iARB) -#define glWindowPos3ivARB GLEW_GET_FUN(__glewWindowPos3ivARB) -#define glWindowPos3sARB GLEW_GET_FUN(__glewWindowPos3sARB) -#define glWindowPos3svARB GLEW_GET_FUN(__glewWindowPos3svARB) - -#define GLEW_ARB_window_pos GLEW_GET_VAR(__GLEW_ARB_window_pos) - -#endif /* GL_ARB_window_pos */ - -/* ------------------------- GL_ATIX_point_sprites ------------------------- */ - -#ifndef GL_ATIX_point_sprites -#define GL_ATIX_point_sprites 1 - -#define GL_TEXTURE_POINT_MODE_ATIX 0x60B0 -#define GL_TEXTURE_POINT_ONE_COORD_ATIX 0x60B1 -#define GL_TEXTURE_POINT_SPRITE_ATIX 0x60B2 -#define GL_POINT_SPRITE_CULL_MODE_ATIX 0x60B3 -#define GL_POINT_SPRITE_CULL_CENTER_ATIX 0x60B4 -#define GL_POINT_SPRITE_CULL_CLIP_ATIX 0x60B5 - -#define GLEW_ATIX_point_sprites GLEW_GET_VAR(__GLEW_ATIX_point_sprites) - -#endif /* GL_ATIX_point_sprites */ - -/* ---------------------- GL_ATIX_texture_env_combine3 --------------------- */ - -#ifndef GL_ATIX_texture_env_combine3 -#define GL_ATIX_texture_env_combine3 1 - -#define GL_MODULATE_ADD_ATIX 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATIX 0x8745 -#define GL_MODULATE_SUBTRACT_ATIX 0x8746 - -#define GLEW_ATIX_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATIX_texture_env_combine3) - -#endif /* GL_ATIX_texture_env_combine3 */ - -/* ----------------------- GL_ATIX_texture_env_route ----------------------- */ - -#ifndef GL_ATIX_texture_env_route -#define GL_ATIX_texture_env_route 1 - -#define GL_SECONDARY_COLOR_ATIX 0x8747 -#define GL_TEXTURE_OUTPUT_RGB_ATIX 0x8748 -#define GL_TEXTURE_OUTPUT_ALPHA_ATIX 0x8749 - -#define GLEW_ATIX_texture_env_route GLEW_GET_VAR(__GLEW_ATIX_texture_env_route) - -#endif /* GL_ATIX_texture_env_route */ - -/* ---------------- GL_ATIX_vertex_shader_output_point_size ---------------- */ - -#ifndef GL_ATIX_vertex_shader_output_point_size -#define GL_ATIX_vertex_shader_output_point_size 1 - -#define GL_OUTPUT_POINT_SIZE_ATIX 0x610E - -#define GLEW_ATIX_vertex_shader_output_point_size GLEW_GET_VAR(__GLEW_ATIX_vertex_shader_output_point_size) - -#endif /* GL_ATIX_vertex_shader_output_point_size */ - -/* -------------------------- GL_ATI_draw_buffers -------------------------- */ - -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 - -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 - -typedef void (GLAPIENTRY * PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum* bufs); - -#define glDrawBuffersATI GLEW_GET_FUN(__glewDrawBuffersATI) - -#define GLEW_ATI_draw_buffers GLEW_GET_VAR(__GLEW_ATI_draw_buffers) - -#endif /* GL_ATI_draw_buffers */ - -/* -------------------------- GL_ATI_element_array ------------------------- */ - -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 - -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A - -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); -typedef void (GLAPIENTRY * PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void* pointer); - -#define glDrawElementArrayATI GLEW_GET_FUN(__glewDrawElementArrayATI) -#define glDrawRangeElementArrayATI GLEW_GET_FUN(__glewDrawRangeElementArrayATI) -#define glElementPointerATI GLEW_GET_FUN(__glewElementPointerATI) - -#define GLEW_ATI_element_array GLEW_GET_VAR(__GLEW_ATI_element_array) - -#endif /* GL_ATI_element_array */ - -/* ------------------------- GL_ATI_envmap_bumpmap ------------------------- */ - -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 - -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C - -typedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -typedef void (GLAPIENTRY * PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -typedef void (GLAPIENTRY * PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); - -#define glGetTexBumpParameterfvATI GLEW_GET_FUN(__glewGetTexBumpParameterfvATI) -#define glGetTexBumpParameterivATI GLEW_GET_FUN(__glewGetTexBumpParameterivATI) -#define glTexBumpParameterfvATI GLEW_GET_FUN(__glewTexBumpParameterfvATI) -#define glTexBumpParameterivATI GLEW_GET_FUN(__glewTexBumpParameterivATI) - -#define GLEW_ATI_envmap_bumpmap GLEW_GET_VAR(__GLEW_ATI_envmap_bumpmap) - -#endif /* GL_ATI_envmap_bumpmap */ - -/* ------------------------- GL_ATI_fragment_shader ------------------------ */ - -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 - -#define GL_RED_BIT_ATI 0x00000001 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B - -typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (GLAPIENTRY * PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (GLAPIENTRY * PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (GLAPIENTRY * PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (GLAPIENTRY * PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (GLAPIENTRY * PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef GLuint (GLAPIENTRY * PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (GLAPIENTRY * PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (GLAPIENTRY * PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (GLAPIENTRY * PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat* value); - -#define glAlphaFragmentOp1ATI GLEW_GET_FUN(__glewAlphaFragmentOp1ATI) -#define glAlphaFragmentOp2ATI GLEW_GET_FUN(__glewAlphaFragmentOp2ATI) -#define glAlphaFragmentOp3ATI GLEW_GET_FUN(__glewAlphaFragmentOp3ATI) -#define glBeginFragmentShaderATI GLEW_GET_FUN(__glewBeginFragmentShaderATI) -#define glBindFragmentShaderATI GLEW_GET_FUN(__glewBindFragmentShaderATI) -#define glColorFragmentOp1ATI GLEW_GET_FUN(__glewColorFragmentOp1ATI) -#define glColorFragmentOp2ATI GLEW_GET_FUN(__glewColorFragmentOp2ATI) -#define glColorFragmentOp3ATI GLEW_GET_FUN(__glewColorFragmentOp3ATI) -#define glDeleteFragmentShaderATI GLEW_GET_FUN(__glewDeleteFragmentShaderATI) -#define glEndFragmentShaderATI GLEW_GET_FUN(__glewEndFragmentShaderATI) -#define glGenFragmentShadersATI GLEW_GET_FUN(__glewGenFragmentShadersATI) -#define glPassTexCoordATI GLEW_GET_FUN(__glewPassTexCoordATI) -#define glSampleMapATI GLEW_GET_FUN(__glewSampleMapATI) -#define glSetFragmentShaderConstantATI GLEW_GET_FUN(__glewSetFragmentShaderConstantATI) - -#define GLEW_ATI_fragment_shader GLEW_GET_VAR(__GLEW_ATI_fragment_shader) - -#endif /* GL_ATI_fragment_shader */ - -/* ------------------------ GL_ATI_map_object_buffer ----------------------- */ - -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 - -typedef void* (GLAPIENTRY * PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (GLAPIENTRY * PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); - -#define glMapObjectBufferATI GLEW_GET_FUN(__glewMapObjectBufferATI) -#define glUnmapObjectBufferATI GLEW_GET_FUN(__glewUnmapObjectBufferATI) - -#define GLEW_ATI_map_object_buffer GLEW_GET_VAR(__GLEW_ATI_map_object_buffer) - -#endif /* GL_ATI_map_object_buffer */ - -/* -------------------------- GL_ATI_pn_triangles -------------------------- */ - -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 - -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 - -typedef void (GLAPIENTRY * PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); - -#define glPNTrianglesfATI GLEW_GET_FUN(__glPNTrianglewesfATI) -#define glPNTrianglesiATI GLEW_GET_FUN(__glPNTrianglewesiATI) - -#define GLEW_ATI_pn_triangles GLEW_GET_VAR(__GLEW_ATI_pn_triangles) - -#endif /* GL_ATI_pn_triangles */ - -/* ------------------------ GL_ATI_separate_stencil ------------------------ */ - -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 - -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 - -typedef void (GLAPIENTRY * PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -typedef void (GLAPIENTRY * PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); - -#define glStencilFuncSeparateATI GLEW_GET_FUN(__glewStencilFuncSeparateATI) -#define glStencilOpSeparateATI GLEW_GET_FUN(__glewStencilOpSeparateATI) - -#define GLEW_ATI_separate_stencil GLEW_GET_VAR(__GLEW_ATI_separate_stencil) - -#endif /* GL_ATI_separate_stencil */ - -/* ----------------------- GL_ATI_shader_texture_lod ----------------------- */ - -#ifndef GL_ATI_shader_texture_lod -#define GL_ATI_shader_texture_lod 1 - -#define GLEW_ATI_shader_texture_lod GLEW_GET_VAR(__GLEW_ATI_shader_texture_lod) - -#endif /* GL_ATI_shader_texture_lod */ - -/* ---------------------- GL_ATI_text_fragment_shader ---------------------- */ - -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 - -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 - -#define GLEW_ATI_text_fragment_shader GLEW_GET_VAR(__GLEW_ATI_text_fragment_shader) - -#endif /* GL_ATI_text_fragment_shader */ - -/* --------------------- GL_ATI_texture_compression_3dc -------------------- */ - -#ifndef GL_ATI_texture_compression_3dc -#define GL_ATI_texture_compression_3dc 1 - -#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837 - -#define GLEW_ATI_texture_compression_3dc GLEW_GET_VAR(__GLEW_ATI_texture_compression_3dc) - -#endif /* GL_ATI_texture_compression_3dc */ - -/* ---------------------- GL_ATI_texture_env_combine3 ---------------------- */ - -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 - -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 - -#define GLEW_ATI_texture_env_combine3 GLEW_GET_VAR(__GLEW_ATI_texture_env_combine3) - -#endif /* GL_ATI_texture_env_combine3 */ - -/* -------------------------- GL_ATI_texture_float ------------------------- */ - -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 - -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F - -#define GLEW_ATI_texture_float GLEW_GET_VAR(__GLEW_ATI_texture_float) - -#endif /* GL_ATI_texture_float */ - -/* ----------------------- GL_ATI_texture_mirror_once ---------------------- */ - -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 - -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 - -#define GLEW_ATI_texture_mirror_once GLEW_GET_VAR(__GLEW_ATI_texture_mirror_once) - -#endif /* GL_ATI_texture_mirror_once */ - -/* ----------------------- GL_ATI_vertex_array_object ---------------------- */ - -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 - -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 - -typedef void (GLAPIENTRY * PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (GLAPIENTRY * PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef GLuint (GLAPIENTRY * PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void* pointer, GLenum usage); -typedef void (GLAPIENTRY * PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void* pointer, GLenum preserve); -typedef void (GLAPIENTRY * PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); - -#define glArrayObjectATI GLEW_GET_FUN(__glewArrayObjectATI) -#define glFreeObjectBufferATI GLEW_GET_FUN(__glewFreeObjectBufferATI) -#define glGetArrayObjectfvATI GLEW_GET_FUN(__glewGetArrayObjectfvATI) -#define glGetArrayObjectivATI GLEW_GET_FUN(__glewGetArrayObjectivATI) -#define glGetObjectBufferfvATI GLEW_GET_FUN(__glewGetObjectBufferfvATI) -#define glGetObjectBufferivATI GLEW_GET_FUN(__glewGetObjectBufferivATI) -#define glGetVariantArrayObjectfvATI GLEW_GET_FUN(__glewGetVariantArrayObjectfvATI) -#define glGetVariantArrayObjectivATI GLEW_GET_FUN(__glewGetVariantArrayObjectivATI) -#define glIsObjectBufferATI GLEW_GET_FUN(__glewIsObjectBufferATI) -#define glNewObjectBufferATI GLEW_GET_FUN(__glewNewObjectBufferATI) -#define glUpdateObjectBufferATI GLEW_GET_FUN(__glewUpdateObjectBufferATI) -#define glVariantArrayObjectATI GLEW_GET_FUN(__glewVariantArrayObjectATI) - -#define GLEW_ATI_vertex_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_array_object) - -#endif /* GL_ATI_vertex_array_object */ - -/* ------------------- GL_ATI_vertex_attrib_array_object ------------------- */ - -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 - -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); - -#define glGetVertexAttribArrayObjectfvATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectfvATI) -#define glGetVertexAttribArrayObjectivATI GLEW_GET_FUN(__glewGetVertexAttribArrayObjectivATI) -#define glVertexAttribArrayObjectATI GLEW_GET_FUN(__glewVertexAttribArrayObjectATI) - -#define GLEW_ATI_vertex_attrib_array_object GLEW_GET_VAR(__GLEW_ATI_vertex_attrib_array_object) - -#endif /* GL_ATI_vertex_attrib_array_object */ - -/* ------------------------- GL_ATI_vertex_streams ------------------------- */ - -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 - -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_SOURCE_ATI 0x876C -#define GL_VERTEX_STREAM0_ATI 0x876D -#define GL_VERTEX_STREAM1_ATI 0x876E -#define GL_VERTEX_STREAM2_ATI 0x876F -#define GL_VERTEX_STREAM3_ATI 0x8770 -#define GL_VERTEX_STREAM4_ATI 0x8771 -#define GL_VERTEX_STREAM5_ATI 0x8772 -#define GL_VERTEX_STREAM6_ATI 0x8773 -#define GL_VERTEX_STREAM7_ATI 0x8774 - -typedef void (GLAPIENTRY * PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte x, GLbyte y, GLbyte z); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *v); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *v); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAPIENTRY * PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *v); - -#define glClientActiveVertexStreamATI GLEW_GET_FUN(__glewClientActiveVertexStreamATI) -#define glNormalStream3bATI GLEW_GET_FUN(__glewNormalStream3bATI) -#define glNormalStream3bvATI GLEW_GET_FUN(__glewNormalStream3bvATI) -#define glNormalStream3dATI GLEW_GET_FUN(__glewNormalStream3dATI) -#define glNormalStream3dvATI GLEW_GET_FUN(__glewNormalStream3dvATI) -#define glNormalStream3fATI GLEW_GET_FUN(__glewNormalStream3fATI) -#define glNormalStream3fvATI GLEW_GET_FUN(__glewNormalStream3fvATI) -#define glNormalStream3iATI GLEW_GET_FUN(__glewNormalStream3iATI) -#define glNormalStream3ivATI GLEW_GET_FUN(__glewNormalStream3ivATI) -#define glNormalStream3sATI GLEW_GET_FUN(__glewNormalStream3sATI) -#define glNormalStream3svATI GLEW_GET_FUN(__glewNormalStream3svATI) -#define glVertexBlendEnvfATI GLEW_GET_FUN(__glewVertexBlendEnvfATI) -#define glVertexBlendEnviATI GLEW_GET_FUN(__glewVertexBlendEnviATI) -#define glVertexStream2dATI GLEW_GET_FUN(__glewVertexStream2dATI) -#define glVertexStream2dvATI GLEW_GET_FUN(__glewVertexStream2dvATI) -#define glVertexStream2fATI GLEW_GET_FUN(__glewVertexStream2fATI) -#define glVertexStream2fvATI GLEW_GET_FUN(__glewVertexStream2fvATI) -#define glVertexStream2iATI GLEW_GET_FUN(__glewVertexStream2iATI) -#define glVertexStream2ivATI GLEW_GET_FUN(__glewVertexStream2ivATI) -#define glVertexStream2sATI GLEW_GET_FUN(__glewVertexStream2sATI) -#define glVertexStream2svATI GLEW_GET_FUN(__glewVertexStream2svATI) -#define glVertexStream3dATI GLEW_GET_FUN(__glewVertexStream3dATI) -#define glVertexStream3dvATI GLEW_GET_FUN(__glewVertexStream3dvATI) -#define glVertexStream3fATI GLEW_GET_FUN(__glewVertexStream3fATI) -#define glVertexStream3fvATI GLEW_GET_FUN(__glewVertexStream3fvATI) -#define glVertexStream3iATI GLEW_GET_FUN(__glewVertexStream3iATI) -#define glVertexStream3ivATI GLEW_GET_FUN(__glewVertexStream3ivATI) -#define glVertexStream3sATI GLEW_GET_FUN(__glewVertexStream3sATI) -#define glVertexStream3svATI GLEW_GET_FUN(__glewVertexStream3svATI) -#define glVertexStream4dATI GLEW_GET_FUN(__glewVertexStream4dATI) -#define glVertexStream4dvATI GLEW_GET_FUN(__glewVertexStream4dvATI) -#define glVertexStream4fATI GLEW_GET_FUN(__glewVertexStream4fATI) -#define glVertexStream4fvATI GLEW_GET_FUN(__glewVertexStream4fvATI) -#define glVertexStream4iATI GLEW_GET_FUN(__glewVertexStream4iATI) -#define glVertexStream4ivATI GLEW_GET_FUN(__glewVertexStream4ivATI) -#define glVertexStream4sATI GLEW_GET_FUN(__glewVertexStream4sATI) -#define glVertexStream4svATI GLEW_GET_FUN(__glewVertexStream4svATI) - -#define GLEW_ATI_vertex_streams GLEW_GET_VAR(__GLEW_ATI_vertex_streams) - -#endif /* GL_ATI_vertex_streams */ - -/* --------------------------- GL_EXT_422_pixels --------------------------- */ - -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 - -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF - -#define GLEW_EXT_422_pixels GLEW_GET_VAR(__GLEW_EXT_422_pixels) - -#endif /* GL_EXT_422_pixels */ - -/* ---------------------------- GL_EXT_Cg_shader --------------------------- */ - -#ifndef GL_EXT_Cg_shader -#define GL_EXT_Cg_shader 1 - -#define GL_CG_VERTEX_SHADER_EXT 0x890E -#define GL_CG_FRAGMENT_SHADER_EXT 0x890F - -#define GLEW_EXT_Cg_shader GLEW_GET_VAR(__GLEW_EXT_Cg_shader) - -#endif /* GL_EXT_Cg_shader */ - -/* ------------------------------ GL_EXT_abgr ------------------------------ */ - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 - -#define GL_ABGR_EXT 0x8000 - -#define GLEW_EXT_abgr GLEW_GET_VAR(__GLEW_EXT_abgr) - -#endif /* GL_EXT_abgr */ - -/* ------------------------------ GL_EXT_bgra ------------------------------ */ - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 - -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 - -#define GLEW_EXT_bgra GLEW_GET_VAR(__GLEW_EXT_bgra) - -#endif /* GL_EXT_bgra */ - -/* ------------------------ GL_EXT_bindable_uniform ------------------------ */ - -#ifndef GL_EXT_bindable_uniform -#define GL_EXT_bindable_uniform 1 - -#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 -#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 -#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 -#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED -#define GL_UNIFORM_BUFFER_EXT 0x8DEE -#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF - -typedef GLint (GLAPIENTRY * PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); -typedef GLintptr (GLAPIENTRY * PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); -typedef void (GLAPIENTRY * PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); - -#define glGetUniformBufferSizeEXT GLEW_GET_FUN(__glewGetUniformBufferSizeEXT) -#define glGetUniformOffsetEXT GLEW_GET_FUN(__glewGetUniformOffsetEXT) -#define glUniformBufferEXT GLEW_GET_FUN(__glewUniformBufferEXT) - -#define GLEW_EXT_bindable_uniform GLEW_GET_VAR(__GLEW_EXT_bindable_uniform) - -#endif /* GL_EXT_bindable_uniform */ - -/* --------------------------- GL_EXT_blend_color -------------------------- */ - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 - -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 - -typedef void (GLAPIENTRY * PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); - -#define glBlendColorEXT GLEW_GET_FUN(__glewBlendColorEXT) - -#define GLEW_EXT_blend_color GLEW_GET_VAR(__GLEW_EXT_blend_color) - -#endif /* GL_EXT_blend_color */ - -/* --------------------- GL_EXT_blend_equation_separate -------------------- */ - -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 - -#define GL_BLEND_EQUATION_RGB_EXT 0x8009 -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D - -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); - -#define glBlendEquationSeparateEXT GLEW_GET_FUN(__glewBlendEquationSeparateEXT) - -#define GLEW_EXT_blend_equation_separate GLEW_GET_VAR(__GLEW_EXT_blend_equation_separate) - -#endif /* GL_EXT_blend_equation_separate */ - -/* ----------------------- GL_EXT_blend_func_separate ---------------------- */ - -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 - -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB - -typedef void (GLAPIENTRY * PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); - -#define glBlendFuncSeparateEXT GLEW_GET_FUN(__glewBlendFuncSeparateEXT) - -#define GLEW_EXT_blend_func_separate GLEW_GET_VAR(__GLEW_EXT_blend_func_separate) - -#endif /* GL_EXT_blend_func_separate */ - -/* ------------------------- GL_EXT_blend_logic_op ------------------------- */ - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 - -#define GLEW_EXT_blend_logic_op GLEW_GET_VAR(__GLEW_EXT_blend_logic_op) - -#endif /* GL_EXT_blend_logic_op */ - -/* -------------------------- GL_EXT_blend_minmax -------------------------- */ - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 - -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_BLEND_EQUATION_EXT 0x8009 - -typedef void (GLAPIENTRY * PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); - -#define glBlendEquationEXT GLEW_GET_FUN(__glewBlendEquationEXT) - -#define GLEW_EXT_blend_minmax GLEW_GET_VAR(__GLEW_EXT_blend_minmax) - -#endif /* GL_EXT_blend_minmax */ - -/* ------------------------- GL_EXT_blend_subtract ------------------------- */ - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 - -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B - -#define GLEW_EXT_blend_subtract GLEW_GET_VAR(__GLEW_EXT_blend_subtract) - -#endif /* GL_EXT_blend_subtract */ - -/* ------------------------ GL_EXT_clip_volume_hint ------------------------ */ - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 - -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 - -#define GLEW_EXT_clip_volume_hint GLEW_GET_VAR(__GLEW_EXT_clip_volume_hint) - -#endif /* GL_EXT_clip_volume_hint */ - -/* ------------------------------ GL_EXT_cmyka ----------------------------- */ - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 - -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F - -#define GLEW_EXT_cmyka GLEW_GET_VAR(__GLEW_EXT_cmyka) - -#endif /* GL_EXT_cmyka */ - -/* ------------------------- GL_EXT_color_subtable ------------------------- */ - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 - -typedef void (GLAPIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void* data); -typedef void (GLAPIENTRY * PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); - -#define glColorSubTableEXT GLEW_GET_FUN(__glewColorSubTableEXT) -#define glCopyColorSubTableEXT GLEW_GET_FUN(__glewCopyColorSubTableEXT) - -#define GLEW_EXT_color_subtable GLEW_GET_VAR(__GLEW_EXT_color_subtable) - -#endif /* GL_EXT_color_subtable */ - -/* ---------------------- GL_EXT_compiled_vertex_array --------------------- */ - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 - -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 - -typedef void (GLAPIENTRY * PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (GLAPIENTRY * PFNGLUNLOCKARRAYSEXTPROC) (void); - -#define glLockArraysEXT GLEW_GET_FUN(__glewLockArraysEXT) -#define glUnlockArraysEXT GLEW_GET_FUN(__glewUnlockArraysEXT) - -#define GLEW_EXT_compiled_vertex_array GLEW_GET_VAR(__GLEW_EXT_compiled_vertex_array) - -#endif /* GL_EXT_compiled_vertex_array */ - -/* --------------------------- GL_EXT_convolution -------------------------- */ - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 - -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 - -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void* image); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* image); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void* image); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void* row, void* column, void* span); -typedef void (GLAPIENTRY * PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* row, const void* column); - -#define glConvolutionFilter1DEXT GLEW_GET_FUN(__glewConvolutionFilter1DEXT) -#define glConvolutionFilter2DEXT GLEW_GET_FUN(__glewConvolutionFilter2DEXT) -#define glConvolutionParameterfEXT GLEW_GET_FUN(__glewConvolutionParameterfEXT) -#define glConvolutionParameterfvEXT GLEW_GET_FUN(__glewConvolutionParameterfvEXT) -#define glConvolutionParameteriEXT GLEW_GET_FUN(__glewConvolutionParameteriEXT) -#define glConvolutionParameterivEXT GLEW_GET_FUN(__glewConvolutionParameterivEXT) -#define glCopyConvolutionFilter1DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter1DEXT) -#define glCopyConvolutionFilter2DEXT GLEW_GET_FUN(__glewCopyConvolutionFilter2DEXT) -#define glGetConvolutionFilterEXT GLEW_GET_FUN(__glewGetConvolutionFilterEXT) -#define glGetConvolutionParameterfvEXT GLEW_GET_FUN(__glewGetConvolutionParameterfvEXT) -#define glGetConvolutionParameterivEXT GLEW_GET_FUN(__glewGetConvolutionParameterivEXT) -#define glGetSeparableFilterEXT GLEW_GET_FUN(__glewGetSeparableFilterEXT) -#define glSeparableFilter2DEXT GLEW_GET_FUN(__glewSeparableFilter2DEXT) - -#define GLEW_EXT_convolution GLEW_GET_VAR(__GLEW_EXT_convolution) - -#endif /* GL_EXT_convolution */ - -/* ------------------------ GL_EXT_coordinate_frame ------------------------ */ - -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 - -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 - -typedef void (GLAPIENTRY * PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, void* pointer); -typedef void (GLAPIENTRY * PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, void* pointer); - -#define glBinormalPointerEXT GLEW_GET_FUN(__glewBinormalPointerEXT) -#define glTangentPointerEXT GLEW_GET_FUN(__glewTangentPointerEXT) - -#define GLEW_EXT_coordinate_frame GLEW_GET_VAR(__GLEW_EXT_coordinate_frame) - -#endif /* GL_EXT_coordinate_frame */ - -/* -------------------------- GL_EXT_copy_texture -------------------------- */ - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 - -typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); - -#define glCopyTexImage1DEXT GLEW_GET_FUN(__glewCopyTexImage1DEXT) -#define glCopyTexImage2DEXT GLEW_GET_FUN(__glewCopyTexImage2DEXT) -#define glCopyTexSubImage1DEXT GLEW_GET_FUN(__glewCopyTexSubImage1DEXT) -#define glCopyTexSubImage2DEXT GLEW_GET_FUN(__glewCopyTexSubImage2DEXT) -#define glCopyTexSubImage3DEXT GLEW_GET_FUN(__glewCopyTexSubImage3DEXT) - -#define GLEW_EXT_copy_texture GLEW_GET_VAR(__GLEW_EXT_copy_texture) - -#endif /* GL_EXT_copy_texture */ - -/* --------------------------- GL_EXT_cull_vertex -------------------------- */ - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 - -typedef void (GLAPIENTRY * PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat* params); - -#define glCullParameterdvEXT GLEW_GET_FUN(__glewCullParameterdvEXT) -#define glCullParameterfvEXT GLEW_GET_FUN(__glewCullParameterfvEXT) - -#define GLEW_EXT_cull_vertex GLEW_GET_VAR(__GLEW_EXT_cull_vertex) - -#endif /* GL_EXT_cull_vertex */ - -/* ------------------------ GL_EXT_depth_bounds_test ----------------------- */ - -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 - -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 - -typedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); - -#define glDepthBoundsEXT GLEW_GET_FUN(__glewDepthBoundsEXT) - -#define GLEW_EXT_depth_bounds_test GLEW_GET_VAR(__GLEW_EXT_depth_bounds_test) - -#endif /* GL_EXT_depth_bounds_test */ - -/* ----------------------- GL_EXT_direct_state_access ---------------------- */ - -#ifndef GL_EXT_direct_state_access -#define GL_EXT_direct_state_access 1 - -#define GL_PROGRAM_MATRIX_EXT 0x8E2D -#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E -#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F - -typedef void (GLAPIENTRY * PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); -typedef GLenum (GLAPIENTRY * PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); -typedef void (GLAPIENTRY * PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void* data); -typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (GLAPIENTRY * PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum* bufs); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); -typedef void (GLAPIENTRY * PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); -typedef void (GLAPIENTRY * PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); -typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, void* img); -typedef void (GLAPIENTRY * PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, void* img); -typedef void (GLAPIENTRY * PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum pname, GLuint index, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum pname, GLuint index, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint* param); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void* pixels); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void** params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void* data); -typedef void (GLAPIENTRY * PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void* string); -typedef void (GLAPIENTRY * PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum pname, GLuint index, GLvoid** params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void* pixels); -typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint* params); -typedef GLvoid * (GLAPIENTRY * PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); -typedef void (GLAPIENTRY * PFNGLMATRIXFRUSTUMEXTPROC) (GLenum matrixMode, GLdouble l, GLdouble r, GLdouble b, GLdouble t, GLdouble n, GLdouble f); -typedef void (GLAPIENTRY * PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum matrixMode); -typedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum matrixMode, const GLdouble* m); -typedef void (GLAPIENTRY * PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXLOADDEXTPROC) (GLenum matrixMode, const GLdouble* m); -typedef void (GLAPIENTRY * PFNGLMATRIXLOADFEXTPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum matrixMode, const GLdouble* m); -typedef void (GLAPIENTRY * PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXMULTDEXTPROC) (GLenum matrixMode, const GLdouble* m); -typedef void (GLAPIENTRY * PFNGLMATRIXMULTFEXTPROC) (GLenum matrixMode, const GLfloat* m); -typedef void (GLAPIENTRY * PFNGLMATRIXORTHOEXTPROC) (GLenum matrixMode, GLdouble l, GLdouble r, GLdouble b, GLdouble t, GLdouble n, GLdouble f); -typedef void (GLAPIENTRY * PFNGLMATRIXPOPEXTPROC) (GLenum matrixMode); -typedef void (GLAPIENTRY * PFNGLMATRIXPUSHEXTPROC) (GLenum matrixMode); -typedef void (GLAPIENTRY * PFNGLMATRIXROTATEDEXTPROC) (GLenum matrixMode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLMATRIXROTATEFEXTPROC) (GLenum matrixMode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLMATRIXSCALEDEXTPROC) (GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLMATRIXSCALEFEXTPROC) (GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum matrixMode, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum matrixMode, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void* pointer); -typedef void (GLAPIENTRY * PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint* params); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat* param); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint* param); -typedef void (GLAPIENTRY * PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void* data, GLenum usage); -typedef void (GLAPIENTRY * PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void* data); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); -typedef void (GLAPIENTRY * PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint* params); -typedef void (GLAPIENTRY * PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void* string); -typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -typedef void (GLAPIENTRY * PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (GLAPIENTRY * PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint* params); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat* param); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint* param); -typedef void (GLAPIENTRY * PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels); -typedef GLboolean (GLAPIENTRY * PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); - -#define glBindMultiTextureEXT GLEW_GET_FUN(__glewBindMultiTextureEXT) -#define glCheckNamedFramebufferStatusEXT GLEW_GET_FUN(__glewCheckNamedFramebufferStatusEXT) -#define glClientAttribDefaultEXT GLEW_GET_FUN(__glewClientAttribDefaultEXT) -#define glCompressedMultiTexImage1DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage1DEXT) -#define glCompressedMultiTexImage2DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage2DEXT) -#define glCompressedMultiTexImage3DEXT GLEW_GET_FUN(__glewCompressedMultiTexImage3DEXT) -#define glCompressedMultiTexSubImage1DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage1DEXT) -#define glCompressedMultiTexSubImage2DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage2DEXT) -#define glCompressedMultiTexSubImage3DEXT GLEW_GET_FUN(__glewCompressedMultiTexSubImage3DEXT) -#define glCompressedTextureImage1DEXT GLEW_GET_FUN(__glewCompressedTextureImage1DEXT) -#define glCompressedTextureImage2DEXT GLEW_GET_FUN(__glewCompressedTextureImage2DEXT) -#define glCompressedTextureImage3DEXT GLEW_GET_FUN(__glewCompressedTextureImage3DEXT) -#define glCompressedTextureSubImage1DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage1DEXT) -#define glCompressedTextureSubImage2DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage2DEXT) -#define glCompressedTextureSubImage3DEXT GLEW_GET_FUN(__glewCompressedTextureSubImage3DEXT) -#define glCopyMultiTexImage1DEXT GLEW_GET_FUN(__glewCopyMultiTexImage1DEXT) -#define glCopyMultiTexImage2DEXT GLEW_GET_FUN(__glewCopyMultiTexImage2DEXT) -#define glCopyMultiTexSubImage1DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage1DEXT) -#define glCopyMultiTexSubImage2DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage2DEXT) -#define glCopyMultiTexSubImage3DEXT GLEW_GET_FUN(__glewCopyMultiTexSubImage3DEXT) -#define glCopyTextureImage1DEXT GLEW_GET_FUN(__glewCopyTextureImage1DEXT) -#define glCopyTextureImage2DEXT GLEW_GET_FUN(__glewCopyTextureImage2DEXT) -#define glCopyTextureSubImage1DEXT GLEW_GET_FUN(__glewCopyTextureSubImage1DEXT) -#define glCopyTextureSubImage2DEXT GLEW_GET_FUN(__glewCopyTextureSubImage2DEXT) -#define glCopyTextureSubImage3DEXT GLEW_GET_FUN(__glewCopyTextureSubImage3DEXT) -#define glDisableClientStateIndexedEXT GLEW_GET_FUN(__glewDisableClientStateIndexedEXT) -#define glEnableClientStateIndexedEXT GLEW_GET_FUN(__glewEnableClientStateIndexedEXT) -#define glFramebufferDrawBufferEXT GLEW_GET_FUN(__glewFramebufferDrawBufferEXT) -#define glFramebufferDrawBuffersEXT GLEW_GET_FUN(__glewFramebufferDrawBuffersEXT) -#define glFramebufferReadBufferEXT GLEW_GET_FUN(__glewFramebufferReadBufferEXT) -#define glGenerateMultiTexMipmapEXT GLEW_GET_FUN(__glewGenerateMultiTexMipmapEXT) -#define glGenerateTextureMipmapEXT GLEW_GET_FUN(__glewGenerateTextureMipmapEXT) -#define glGetCompressedMultiTexImageEXT GLEW_GET_FUN(__glewGetCompressedMultiTexImageEXT) -#define glGetCompressedTextureImageEXT GLEW_GET_FUN(__glewGetCompressedTextureImageEXT) -#define glGetDoubleIndexedvEXT GLEW_GET_FUN(__glewGetDoubleIndexedvEXT) -#define glGetFloatIndexedvEXT GLEW_GET_FUN(__glewGetFloatIndexedvEXT) -#define glGetFramebufferParameterivEXT GLEW_GET_FUN(__glewGetFramebufferParameterivEXT) -#define glGetMultiTexEnvfvEXT GLEW_GET_FUN(__glewGetMultiTexEnvfvEXT) -#define glGetMultiTexEnvivEXT GLEW_GET_FUN(__glewGetMultiTexEnvivEXT) -#define glGetMultiTexGendvEXT GLEW_GET_FUN(__glewGetMultiTexGendvEXT) -#define glGetMultiTexGenfvEXT GLEW_GET_FUN(__glewGetMultiTexGenfvEXT) -#define glGetMultiTexGenivEXT GLEW_GET_FUN(__glewGetMultiTexGenivEXT) -#define glGetMultiTexImageEXT GLEW_GET_FUN(__glewGetMultiTexImageEXT) -#define glGetMultiTexLevelParameterfvEXT GLEW_GET_FUN(__glewGetMultiTexLevelParameterfvEXT) -#define glGetMultiTexLevelParameterivEXT GLEW_GET_FUN(__glewGetMultiTexLevelParameterivEXT) -#define glGetMultiTexParameterIivEXT GLEW_GET_FUN(__glewGetMultiTexParameterIivEXT) -#define glGetMultiTexParameterIuivEXT GLEW_GET_FUN(__glewGetMultiTexParameterIuivEXT) -#define glGetMultiTexParameterfvEXT GLEW_GET_FUN(__glewGetMultiTexParameterfvEXT) -#define glGetMultiTexParameterivEXT GLEW_GET_FUN(__glewGetMultiTexParameterivEXT) -#define glGetNamedBufferParameterivEXT GLEW_GET_FUN(__glewGetNamedBufferParameterivEXT) -#define glGetNamedBufferPointervEXT GLEW_GET_FUN(__glewGetNamedBufferPointervEXT) -#define glGetNamedBufferSubDataEXT GLEW_GET_FUN(__glewGetNamedBufferSubDataEXT) -#define glGetNamedFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetNamedFramebufferAttachmentParameterivEXT) -#define glGetNamedProgramLocalParameterIivEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterIivEXT) -#define glGetNamedProgramLocalParameterIuivEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterIuivEXT) -#define glGetNamedProgramLocalParameterdvEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterdvEXT) -#define glGetNamedProgramLocalParameterfvEXT GLEW_GET_FUN(__glewGetNamedProgramLocalParameterfvEXT) -#define glGetNamedProgramStringEXT GLEW_GET_FUN(__glewGetNamedProgramStringEXT) -#define glGetNamedProgramivEXT GLEW_GET_FUN(__glewGetNamedProgramivEXT) -#define glGetNamedRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetNamedRenderbufferParameterivEXT) -#define glGetPointerIndexedvEXT GLEW_GET_FUN(__glewGetPointerIndexedvEXT) -#define glGetTextureImageEXT GLEW_GET_FUN(__glewGetTextureImageEXT) -#define glGetTextureLevelParameterfvEXT GLEW_GET_FUN(__glewGetTextureLevelParameterfvEXT) -#define glGetTextureLevelParameterivEXT GLEW_GET_FUN(__glewGetTextureLevelParameterivEXT) -#define glGetTextureParameterIivEXT GLEW_GET_FUN(__glewGetTextureParameterIivEXT) -#define glGetTextureParameterIuivEXT GLEW_GET_FUN(__glewGetTextureParameterIuivEXT) -#define glGetTextureParameterfvEXT GLEW_GET_FUN(__glewGetTextureParameterfvEXT) -#define glGetTextureParameterivEXT GLEW_GET_FUN(__glewGetTextureParameterivEXT) -#define glMapNamedBufferEXT GLEW_GET_FUN(__glewMapNamedBufferEXT) -#define glMatrixFrustumEXT GLEW_GET_FUN(__glewMatrixFrustumEXT) -#define glMatrixLoadIdentityEXT GLEW_GET_FUN(__glewMatrixLoadIdentityEXT) -#define glMatrixLoadTransposedEXT GLEW_GET_FUN(__glewMatrixLoadTransposedEXT) -#define glMatrixLoadTransposefEXT GLEW_GET_FUN(__glewMatrixLoadTransposefEXT) -#define glMatrixLoaddEXT GLEW_GET_FUN(__glewMatrixLoaddEXT) -#define glMatrixLoadfEXT GLEW_GET_FUN(__glewMatrixLoadfEXT) -#define glMatrixMultTransposedEXT GLEW_GET_FUN(__glewMatrixMultTransposedEXT) -#define glMatrixMultTransposefEXT GLEW_GET_FUN(__glewMatrixMultTransposefEXT) -#define glMatrixMultdEXT GLEW_GET_FUN(__glewMatrixMultdEXT) -#define glMatrixMultfEXT GLEW_GET_FUN(__glewMatrixMultfEXT) -#define glMatrixOrthoEXT GLEW_GET_FUN(__glewMatrixOrthoEXT) -#define glMatrixPopEXT GLEW_GET_FUN(__glewMatrixPopEXT) -#define glMatrixPushEXT GLEW_GET_FUN(__glewMatrixPushEXT) -#define glMatrixRotatedEXT GLEW_GET_FUN(__glewMatrixRotatedEXT) -#define glMatrixRotatefEXT GLEW_GET_FUN(__glewMatrixRotatefEXT) -#define glMatrixScaledEXT GLEW_GET_FUN(__glewMatrixScaledEXT) -#define glMatrixScalefEXT GLEW_GET_FUN(__glewMatrixScalefEXT) -#define glMatrixTranslatedEXT GLEW_GET_FUN(__glewMatrixTranslatedEXT) -#define glMatrixTranslatefEXT GLEW_GET_FUN(__glewMatrixTranslatefEXT) -#define glMultiTexBufferEXT GLEW_GET_FUN(__glewMultiTexBufferEXT) -#define glMultiTexCoordPointerEXT GLEW_GET_FUN(__glewMultiTexCoordPointerEXT) -#define glMultiTexEnvfEXT GLEW_GET_FUN(__glewMultiTexEnvfEXT) -#define glMultiTexEnvfvEXT GLEW_GET_FUN(__glewMultiTexEnvfvEXT) -#define glMultiTexEnviEXT GLEW_GET_FUN(__glewMultiTexEnviEXT) -#define glMultiTexEnvivEXT GLEW_GET_FUN(__glewMultiTexEnvivEXT) -#define glMultiTexGendEXT GLEW_GET_FUN(__glewMultiTexGendEXT) -#define glMultiTexGendvEXT GLEW_GET_FUN(__glewMultiTexGendvEXT) -#define glMultiTexGenfEXT GLEW_GET_FUN(__glewMultiTexGenfEXT) -#define glMultiTexGenfvEXT GLEW_GET_FUN(__glewMultiTexGenfvEXT) -#define glMultiTexGeniEXT GLEW_GET_FUN(__glewMultiTexGeniEXT) -#define glMultiTexGenivEXT GLEW_GET_FUN(__glewMultiTexGenivEXT) -#define glMultiTexImage1DEXT GLEW_GET_FUN(__glewMultiTexImage1DEXT) -#define glMultiTexImage2DEXT GLEW_GET_FUN(__glewMultiTexImage2DEXT) -#define glMultiTexImage3DEXT GLEW_GET_FUN(__glewMultiTexImage3DEXT) -#define glMultiTexParameterIivEXT GLEW_GET_FUN(__glewMultiTexParameterIivEXT) -#define glMultiTexParameterIuivEXT GLEW_GET_FUN(__glewMultiTexParameterIuivEXT) -#define glMultiTexParameterfEXT GLEW_GET_FUN(__glewMultiTexParameterfEXT) -#define glMultiTexParameterfvEXT GLEW_GET_FUN(__glewMultiTexParameterfvEXT) -#define glMultiTexParameteriEXT GLEW_GET_FUN(__glewMultiTexParameteriEXT) -#define glMultiTexParameterivEXT GLEW_GET_FUN(__glewMultiTexParameterivEXT) -#define glMultiTexRenderbufferEXT GLEW_GET_FUN(__glewMultiTexRenderbufferEXT) -#define glMultiTexSubImage1DEXT GLEW_GET_FUN(__glewMultiTexSubImage1DEXT) -#define glMultiTexSubImage2DEXT GLEW_GET_FUN(__glewMultiTexSubImage2DEXT) -#define glMultiTexSubImage3DEXT GLEW_GET_FUN(__glewMultiTexSubImage3DEXT) -#define glNamedBufferDataEXT GLEW_GET_FUN(__glewNamedBufferDataEXT) -#define glNamedBufferSubDataEXT GLEW_GET_FUN(__glewNamedBufferSubDataEXT) -#define glNamedFramebufferRenderbufferEXT GLEW_GET_FUN(__glewNamedFramebufferRenderbufferEXT) -#define glNamedFramebufferTexture1DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture1DEXT) -#define glNamedFramebufferTexture2DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture2DEXT) -#define glNamedFramebufferTexture3DEXT GLEW_GET_FUN(__glewNamedFramebufferTexture3DEXT) -#define glNamedFramebufferTextureEXT GLEW_GET_FUN(__glewNamedFramebufferTextureEXT) -#define glNamedFramebufferTextureFaceEXT GLEW_GET_FUN(__glewNamedFramebufferTextureFaceEXT) -#define glNamedFramebufferTextureLayerEXT GLEW_GET_FUN(__glewNamedFramebufferTextureLayerEXT) -#define glNamedProgramLocalParameter4dEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4dEXT) -#define glNamedProgramLocalParameter4dvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4dvEXT) -#define glNamedProgramLocalParameter4fEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4fEXT) -#define glNamedProgramLocalParameter4fvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameter4fvEXT) -#define glNamedProgramLocalParameterI4iEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4iEXT) -#define glNamedProgramLocalParameterI4ivEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4ivEXT) -#define glNamedProgramLocalParameterI4uiEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4uiEXT) -#define glNamedProgramLocalParameterI4uivEXT GLEW_GET_FUN(__glewNamedProgramLocalParameterI4uivEXT) -#define glNamedProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewNamedProgramLocalParameters4fvEXT) -#define glNamedProgramLocalParametersI4ivEXT GLEW_GET_FUN(__glewNamedProgramLocalParametersI4ivEXT) -#define glNamedProgramLocalParametersI4uivEXT GLEW_GET_FUN(__glewNamedProgramLocalParametersI4uivEXT) -#define glNamedProgramStringEXT GLEW_GET_FUN(__glewNamedProgramStringEXT) -#define glNamedRenderbufferStorageEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageEXT) -#define glNamedRenderbufferStorageMultisampleCoverageEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisampleCoverageEXT) -#define glNamedRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewNamedRenderbufferStorageMultisampleEXT) -#define glProgramUniform1fEXT GLEW_GET_FUN(__glewProgramUniform1fEXT) -#define glProgramUniform1fvEXT GLEW_GET_FUN(__glewProgramUniform1fvEXT) -#define glProgramUniform1iEXT GLEW_GET_FUN(__glewProgramUniform1iEXT) -#define glProgramUniform1ivEXT GLEW_GET_FUN(__glewProgramUniform1ivEXT) -#define glProgramUniform1uiEXT GLEW_GET_FUN(__glewProgramUniform1uiEXT) -#define glProgramUniform1uivEXT GLEW_GET_FUN(__glewProgramUniform1uivEXT) -#define glProgramUniform2fEXT GLEW_GET_FUN(__glewProgramUniform2fEXT) -#define glProgramUniform2fvEXT GLEW_GET_FUN(__glewProgramUniform2fvEXT) -#define glProgramUniform2iEXT GLEW_GET_FUN(__glewProgramUniform2iEXT) -#define glProgramUniform2ivEXT GLEW_GET_FUN(__glewProgramUniform2ivEXT) -#define glProgramUniform2uiEXT GLEW_GET_FUN(__glewProgramUniform2uiEXT) -#define glProgramUniform2uivEXT GLEW_GET_FUN(__glewProgramUniform2uivEXT) -#define glProgramUniform3fEXT GLEW_GET_FUN(__glewProgramUniform3fEXT) -#define glProgramUniform3fvEXT GLEW_GET_FUN(__glewProgramUniform3fvEXT) -#define glProgramUniform3iEXT GLEW_GET_FUN(__glewProgramUniform3iEXT) -#define glProgramUniform3ivEXT GLEW_GET_FUN(__glewProgramUniform3ivEXT) -#define glProgramUniform3uiEXT GLEW_GET_FUN(__glewProgramUniform3uiEXT) -#define glProgramUniform3uivEXT GLEW_GET_FUN(__glewProgramUniform3uivEXT) -#define glProgramUniform4fEXT GLEW_GET_FUN(__glewProgramUniform4fEXT) -#define glProgramUniform4fvEXT GLEW_GET_FUN(__glewProgramUniform4fvEXT) -#define glProgramUniform4iEXT GLEW_GET_FUN(__glewProgramUniform4iEXT) -#define glProgramUniform4ivEXT GLEW_GET_FUN(__glewProgramUniform4ivEXT) -#define glProgramUniform4uiEXT GLEW_GET_FUN(__glewProgramUniform4uiEXT) -#define glProgramUniform4uivEXT GLEW_GET_FUN(__glewProgramUniform4uivEXT) -#define glProgramUniformMatrix2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2fvEXT) -#define glProgramUniformMatrix2x3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x3fvEXT) -#define glProgramUniformMatrix2x4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix2x4fvEXT) -#define glProgramUniformMatrix3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3fvEXT) -#define glProgramUniformMatrix3x2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x2fvEXT) -#define glProgramUniformMatrix3x4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix3x4fvEXT) -#define glProgramUniformMatrix4fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4fvEXT) -#define glProgramUniformMatrix4x2fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x2fvEXT) -#define glProgramUniformMatrix4x3fvEXT GLEW_GET_FUN(__glewProgramUniformMatrix4x3fvEXT) -#define glPushClientAttribDefaultEXT GLEW_GET_FUN(__glewPushClientAttribDefaultEXT) -#define glTextureBufferEXT GLEW_GET_FUN(__glewTextureBufferEXT) -#define glTextureImage1DEXT GLEW_GET_FUN(__glewTextureImage1DEXT) -#define glTextureImage2DEXT GLEW_GET_FUN(__glewTextureImage2DEXT) -#define glTextureImage3DEXT GLEW_GET_FUN(__glewTextureImage3DEXT) -#define glTextureParameterIivEXT GLEW_GET_FUN(__glewTextureParameterIivEXT) -#define glTextureParameterIuivEXT GLEW_GET_FUN(__glewTextureParameterIuivEXT) -#define glTextureParameterfEXT GLEW_GET_FUN(__glewTextureParameterfEXT) -#define glTextureParameterfvEXT GLEW_GET_FUN(__glewTextureParameterfvEXT) -#define glTextureParameteriEXT GLEW_GET_FUN(__glewTextureParameteriEXT) -#define glTextureParameterivEXT GLEW_GET_FUN(__glewTextureParameterivEXT) -#define glTextureRenderbufferEXT GLEW_GET_FUN(__glewTextureRenderbufferEXT) -#define glTextureSubImage1DEXT GLEW_GET_FUN(__glewTextureSubImage1DEXT) -#define glTextureSubImage2DEXT GLEW_GET_FUN(__glewTextureSubImage2DEXT) -#define glTextureSubImage3DEXT GLEW_GET_FUN(__glewTextureSubImage3DEXT) -#define glUnmapNamedBufferEXT GLEW_GET_FUN(__glewUnmapNamedBufferEXT) - -#define GLEW_EXT_direct_state_access GLEW_GET_VAR(__GLEW_EXT_direct_state_access) - -#endif /* GL_EXT_direct_state_access */ - -/* -------------------------- GL_EXT_draw_buffers2 ------------------------- */ - -#ifndef GL_EXT_draw_buffers2 -#define GL_EXT_draw_buffers2 1 - -typedef void (GLAPIENTRY * PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint buf, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (GLAPIENTRY * PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (GLAPIENTRY * PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (GLAPIENTRY * PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum value, GLuint index, GLboolean* data); -typedef void (GLAPIENTRY * PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum value, GLuint index, GLint* data); -typedef GLboolean (GLAPIENTRY * PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); - -#define glColorMaskIndexedEXT GLEW_GET_FUN(__glewColorMaskIndexedEXT) -#define glDisableIndexedEXT GLEW_GET_FUN(__glewDisableIndexedEXT) -#define glEnableIndexedEXT GLEW_GET_FUN(__glewEnableIndexedEXT) -#define glGetBooleanIndexedvEXT GLEW_GET_FUN(__glewGetBooleanIndexedvEXT) -#define glGetIntegerIndexedvEXT GLEW_GET_FUN(__glewGetIntegerIndexedvEXT) -#define glIsEnabledIndexedEXT GLEW_GET_FUN(__glewIsEnabledIndexedEXT) - -#define GLEW_EXT_draw_buffers2 GLEW_GET_VAR(__GLEW_EXT_draw_buffers2) - -#endif /* GL_EXT_draw_buffers2 */ - -/* ------------------------- GL_EXT_draw_instanced ------------------------- */ - -#ifndef GL_EXT_draw_instanced -#define GL_EXT_draw_instanced 1 - -typedef void (GLAPIENTRY * PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); - -#define glDrawArraysInstancedEXT GLEW_GET_FUN(__glewDrawArraysInstancedEXT) -#define glDrawElementsInstancedEXT GLEW_GET_FUN(__glewDrawElementsInstancedEXT) - -#define GLEW_EXT_draw_instanced GLEW_GET_VAR(__GLEW_EXT_draw_instanced) - -#endif /* GL_EXT_draw_instanced */ - -/* ----------------------- GL_EXT_draw_range_elements ---------------------- */ - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 - -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 - -typedef void (GLAPIENTRY * PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); - -#define glDrawRangeElementsEXT GLEW_GET_FUN(__glewDrawRangeElementsEXT) - -#define GLEW_EXT_draw_range_elements GLEW_GET_VAR(__GLEW_EXT_draw_range_elements) - -#endif /* GL_EXT_draw_range_elements */ - -/* ---------------------------- GL_EXT_fog_coord --------------------------- */ - -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 - -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 - -typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (GLAPIENTRY * PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (GLAPIENTRY * PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); - -#define glFogCoordPointerEXT GLEW_GET_FUN(__glewFogCoordPointerEXT) -#define glFogCoorddEXT GLEW_GET_FUN(__glewFogCoorddEXT) -#define glFogCoorddvEXT GLEW_GET_FUN(__glewFogCoorddvEXT) -#define glFogCoordfEXT GLEW_GET_FUN(__glewFogCoordfEXT) -#define glFogCoordfvEXT GLEW_GET_FUN(__glewFogCoordfvEXT) - -#define GLEW_EXT_fog_coord GLEW_GET_VAR(__GLEW_EXT_fog_coord) - -#endif /* GL_EXT_fog_coord */ - -/* ------------------------ GL_EXT_fragment_lighting ----------------------- */ - -#ifndef GL_EXT_fragment_lighting -#define GL_EXT_fragment_lighting 1 - -#define GL_FRAGMENT_LIGHTING_EXT 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_EXT 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_EXT 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_EXT 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_EXT 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_EXT 0x8405 -#define GL_CURRENT_RASTER_NORMAL_EXT 0x8406 -#define GL_LIGHT_ENV_MODE_EXT 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_EXT 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_EXT 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_EXT 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_EXT 0x840B -#define GL_FRAGMENT_LIGHT0_EXT 0x840C -#define GL_FRAGMENT_LIGHT7_EXT 0x8413 - -typedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALEXTPROC) (GLenum face, GLenum mode); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFEXTPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVEXTPROC) (GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIEXTPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVEXTPROC) (GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFEXTPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIEXTPROC) (GLenum light, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFEXTPROC) (GLenum face, GLenum pname, const GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIEXTPROC) (GLenum face, GLenum pname, const GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVEXTPROC) (GLenum light, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVEXTPROC) (GLenum light, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVEXTPROC) (GLenum face, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVEXTPROC) (GLenum face, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLLIGHTENVIEXTPROC) (GLenum pname, GLint param); - -#define glFragmentColorMaterialEXT GLEW_GET_FUN(__glewFragmentColorMaterialEXT) -#define glFragmentLightModelfEXT GLEW_GET_FUN(__glewFragmentLightModelfEXT) -#define glFragmentLightModelfvEXT GLEW_GET_FUN(__glewFragmentLightModelfvEXT) -#define glFragmentLightModeliEXT GLEW_GET_FUN(__glewFragmentLightModeliEXT) -#define glFragmentLightModelivEXT GLEW_GET_FUN(__glewFragmentLightModelivEXT) -#define glFragmentLightfEXT GLEW_GET_FUN(__glewFragmentLightfEXT) -#define glFragmentLightfvEXT GLEW_GET_FUN(__glewFragmentLightfvEXT) -#define glFragmentLightiEXT GLEW_GET_FUN(__glewFragmentLightiEXT) -#define glFragmentLightivEXT GLEW_GET_FUN(__glewFragmentLightivEXT) -#define glFragmentMaterialfEXT GLEW_GET_FUN(__glewFragmentMaterialfEXT) -#define glFragmentMaterialfvEXT GLEW_GET_FUN(__glewFragmentMaterialfvEXT) -#define glFragmentMaterialiEXT GLEW_GET_FUN(__glewFragmentMaterialiEXT) -#define glFragmentMaterialivEXT GLEW_GET_FUN(__glewFragmentMaterialivEXT) -#define glGetFragmentLightfvEXT GLEW_GET_FUN(__glewGetFragmentLightfvEXT) -#define glGetFragmentLightivEXT GLEW_GET_FUN(__glewGetFragmentLightivEXT) -#define glGetFragmentMaterialfvEXT GLEW_GET_FUN(__glewGetFragmentMaterialfvEXT) -#define glGetFragmentMaterialivEXT GLEW_GET_FUN(__glewGetFragmentMaterialivEXT) -#define glLightEnviEXT GLEW_GET_FUN(__glewLightEnviEXT) - -#define GLEW_EXT_fragment_lighting GLEW_GET_VAR(__GLEW_EXT_fragment_lighting) - -#endif /* GL_EXT_fragment_lighting */ - -/* ------------------------ GL_EXT_framebuffer_blit ------------------------ */ - -#ifndef GL_EXT_framebuffer_blit -#define GL_EXT_framebuffer_blit 1 - -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA - -typedef void (GLAPIENTRY * PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); - -#define glBlitFramebufferEXT GLEW_GET_FUN(__glewBlitFramebufferEXT) - -#define GLEW_EXT_framebuffer_blit GLEW_GET_VAR(__GLEW_EXT_framebuffer_blit) - -#endif /* GL_EXT_framebuffer_blit */ - -/* --------------------- GL_EXT_framebuffer_multisample -------------------- */ - -#ifndef GL_EXT_framebuffer_multisample -#define GL_EXT_framebuffer_multisample 1 - -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 - -typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); - -#define glRenderbufferStorageMultisampleEXT GLEW_GET_FUN(__glewRenderbufferStorageMultisampleEXT) - -#define GLEW_EXT_framebuffer_multisample GLEW_GET_VAR(__GLEW_EXT_framebuffer_multisample) - -#endif /* GL_EXT_framebuffer_multisample */ - -/* ----------------------- GL_EXT_framebuffer_object ----------------------- */ - -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 - -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 - -typedef void (GLAPIENTRY * PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (GLAPIENTRY * PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef GLenum (GLAPIENTRY * PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint* framebuffers); -typedef void (GLAPIENTRY * PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint* renderbuffers); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (GLAPIENTRY * PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint* framebuffers); -typedef void (GLAPIENTRY * PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint* renderbuffers); -typedef void (GLAPIENTRY * PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef GLboolean (GLAPIENTRY * PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); - -#define glBindFramebufferEXT GLEW_GET_FUN(__glewBindFramebufferEXT) -#define glBindRenderbufferEXT GLEW_GET_FUN(__glewBindRenderbufferEXT) -#define glCheckFramebufferStatusEXT GLEW_GET_FUN(__glewCheckFramebufferStatusEXT) -#define glDeleteFramebuffersEXT GLEW_GET_FUN(__glewDeleteFramebuffersEXT) -#define glDeleteRenderbuffersEXT GLEW_GET_FUN(__glewDeleteRenderbuffersEXT) -#define glFramebufferRenderbufferEXT GLEW_GET_FUN(__glewFramebufferRenderbufferEXT) -#define glFramebufferTexture1DEXT GLEW_GET_FUN(__glewFramebufferTexture1DEXT) -#define glFramebufferTexture2DEXT GLEW_GET_FUN(__glewFramebufferTexture2DEXT) -#define glFramebufferTexture3DEXT GLEW_GET_FUN(__glewFramebufferTexture3DEXT) -#define glGenFramebuffersEXT GLEW_GET_FUN(__glewGenFramebuffersEXT) -#define glGenRenderbuffersEXT GLEW_GET_FUN(__glewGenRenderbuffersEXT) -#define glGenerateMipmapEXT GLEW_GET_FUN(__glewGenerateMipmapEXT) -#define glGetFramebufferAttachmentParameterivEXT GLEW_GET_FUN(__glewGetFramebufferAttachmentParameterivEXT) -#define glGetRenderbufferParameterivEXT GLEW_GET_FUN(__glewGetRenderbufferParameterivEXT) -#define glIsFramebufferEXT GLEW_GET_FUN(__glewIsFramebufferEXT) -#define glIsRenderbufferEXT GLEW_GET_FUN(__glewIsRenderbufferEXT) -#define glRenderbufferStorageEXT GLEW_GET_FUN(__glewRenderbufferStorageEXT) - -#define GLEW_EXT_framebuffer_object GLEW_GET_VAR(__GLEW_EXT_framebuffer_object) - -#endif /* GL_EXT_framebuffer_object */ - -/* ------------------------ GL_EXT_framebuffer_sRGB ------------------------ */ - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_EXT_framebuffer_sRGB 1 - -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA - -#define GLEW_EXT_framebuffer_sRGB GLEW_GET_VAR(__GLEW_EXT_framebuffer_sRGB) - -#endif /* GL_EXT_framebuffer_sRGB */ - -/* ------------------------ GL_EXT_geometry_shader4 ------------------------ */ - -#ifndef GL_EXT_geometry_shader4 -#define GL_EXT_geometry_shader4 1 - -#define GL_LINES_ADJACENCY_EXT 0xA -#define GL_LINE_STRIP_ADJACENCY_EXT 0xB -#define GL_TRIANGLES_ADJACENCY_EXT 0xC -#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0xD -#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 -#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 -#define GL_GEOMETRY_SHADER_EXT 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 - -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -typedef void (GLAPIENTRY * PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); - -#define glFramebufferTextureEXT GLEW_GET_FUN(__glewFramebufferTextureEXT) -#define glFramebufferTextureFaceEXT GLEW_GET_FUN(__glewFramebufferTextureFaceEXT) -#define glFramebufferTextureLayerEXT GLEW_GET_FUN(__glewFramebufferTextureLayerEXT) -#define glProgramParameteriEXT GLEW_GET_FUN(__glewProgramParameteriEXT) - -#define GLEW_EXT_geometry_shader4 GLEW_GET_VAR(__GLEW_EXT_geometry_shader4) - -#endif /* GL_EXT_geometry_shader4 */ - -/* --------------------- GL_EXT_gpu_program_parameters --------------------- */ - -#ifndef GL_EXT_gpu_program_parameters -#define GL_EXT_gpu_program_parameters 1 - -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat* params); - -#define glProgramEnvParameters4fvEXT GLEW_GET_FUN(__glewProgramEnvParameters4fvEXT) -#define glProgramLocalParameters4fvEXT GLEW_GET_FUN(__glewProgramLocalParameters4fvEXT) - -#define GLEW_EXT_gpu_program_parameters GLEW_GET_VAR(__GLEW_EXT_gpu_program_parameters) - -#endif /* GL_EXT_gpu_program_parameters */ - -/* --------------------------- GL_EXT_gpu_shader4 -------------------------- */ - -#ifndef GL_EXT_gpu_shader4 -#define GL_EXT_gpu_shader4 1 - -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD -#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 -#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 -#define GL_SAMPLER_BUFFER_EXT 0x8DC2 -#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 -#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 -#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 -#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 -#define GL_INT_SAMPLER_1D_EXT 0x8DC9 -#define GL_INT_SAMPLER_2D_EXT 0x8DCA -#define GL_INT_SAMPLER_3D_EXT 0x8DCB -#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC -#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD -#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF -#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 - -typedef void (GLAPIENTRY * PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (GLAPIENTRY * PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); -typedef void (GLAPIENTRY * PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); -typedef void (GLAPIENTRY * PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); -typedef void (GLAPIENTRY * PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (GLAPIENTRY * PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (GLAPIENTRY * PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (GLAPIENTRY * PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (GLAPIENTRY * PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (GLAPIENTRY * PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (GLAPIENTRY * PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); - -#define glBindFragDataLocationEXT GLEW_GET_FUN(__glewBindFragDataLocationEXT) -#define glGetFragDataLocationEXT GLEW_GET_FUN(__glewGetFragDataLocationEXT) -#define glGetUniformuivEXT GLEW_GET_FUN(__glewGetUniformuivEXT) -#define glGetVertexAttribIivEXT GLEW_GET_FUN(__glewGetVertexAttribIivEXT) -#define glGetVertexAttribIuivEXT GLEW_GET_FUN(__glewGetVertexAttribIuivEXT) -#define glUniform1uiEXT GLEW_GET_FUN(__glewUniform1uiEXT) -#define glUniform1uivEXT GLEW_GET_FUN(__glewUniform1uivEXT) -#define glUniform2uiEXT GLEW_GET_FUN(__glewUniform2uiEXT) -#define glUniform2uivEXT GLEW_GET_FUN(__glewUniform2uivEXT) -#define glUniform3uiEXT GLEW_GET_FUN(__glewUniform3uiEXT) -#define glUniform3uivEXT GLEW_GET_FUN(__glewUniform3uivEXT) -#define glUniform4uiEXT GLEW_GET_FUN(__glewUniform4uiEXT) -#define glUniform4uivEXT GLEW_GET_FUN(__glewUniform4uivEXT) -#define glVertexAttribI1iEXT GLEW_GET_FUN(__glewVertexAttribI1iEXT) -#define glVertexAttribI1ivEXT GLEW_GET_FUN(__glewVertexAttribI1ivEXT) -#define glVertexAttribI1uiEXT GLEW_GET_FUN(__glewVertexAttribI1uiEXT) -#define glVertexAttribI1uivEXT GLEW_GET_FUN(__glewVertexAttribI1uivEXT) -#define glVertexAttribI2iEXT GLEW_GET_FUN(__glewVertexAttribI2iEXT) -#define glVertexAttribI2ivEXT GLEW_GET_FUN(__glewVertexAttribI2ivEXT) -#define glVertexAttribI2uiEXT GLEW_GET_FUN(__glewVertexAttribI2uiEXT) -#define glVertexAttribI2uivEXT GLEW_GET_FUN(__glewVertexAttribI2uivEXT) -#define glVertexAttribI3iEXT GLEW_GET_FUN(__glewVertexAttribI3iEXT) -#define glVertexAttribI3ivEXT GLEW_GET_FUN(__glewVertexAttribI3ivEXT) -#define glVertexAttribI3uiEXT GLEW_GET_FUN(__glewVertexAttribI3uiEXT) -#define glVertexAttribI3uivEXT GLEW_GET_FUN(__glewVertexAttribI3uivEXT) -#define glVertexAttribI4bvEXT GLEW_GET_FUN(__glewVertexAttribI4bvEXT) -#define glVertexAttribI4iEXT GLEW_GET_FUN(__glewVertexAttribI4iEXT) -#define glVertexAttribI4ivEXT GLEW_GET_FUN(__glewVertexAttribI4ivEXT) -#define glVertexAttribI4svEXT GLEW_GET_FUN(__glewVertexAttribI4svEXT) -#define glVertexAttribI4ubvEXT GLEW_GET_FUN(__glewVertexAttribI4ubvEXT) -#define glVertexAttribI4uiEXT GLEW_GET_FUN(__glewVertexAttribI4uiEXT) -#define glVertexAttribI4uivEXT GLEW_GET_FUN(__glewVertexAttribI4uivEXT) -#define glVertexAttribI4usvEXT GLEW_GET_FUN(__glewVertexAttribI4usvEXT) -#define glVertexAttribIPointerEXT GLEW_GET_FUN(__glewVertexAttribIPointerEXT) - -#define GLEW_EXT_gpu_shader4 GLEW_GET_VAR(__GLEW_EXT_gpu_shader4) - -#endif /* GL_EXT_gpu_shader4 */ - -/* ---------------------------- GL_EXT_histogram --------------------------- */ - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 - -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 - -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void* values); -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void* values); -typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (GLAPIENTRY * PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (GLAPIENTRY * PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLRESETMINMAXEXTPROC) (GLenum target); - -#define glGetHistogramEXT GLEW_GET_FUN(__glewGetHistogramEXT) -#define glGetHistogramParameterfvEXT GLEW_GET_FUN(__glewGetHistogramParameterfvEXT) -#define glGetHistogramParameterivEXT GLEW_GET_FUN(__glewGetHistogramParameterivEXT) -#define glGetMinmaxEXT GLEW_GET_FUN(__glewGetMinmaxEXT) -#define glGetMinmaxParameterfvEXT GLEW_GET_FUN(__glewGetMinmaxParameterfvEXT) -#define glGetMinmaxParameterivEXT GLEW_GET_FUN(__glewGetMinmaxParameterivEXT) -#define glHistogramEXT GLEW_GET_FUN(__glewHistogramEXT) -#define glMinmaxEXT GLEW_GET_FUN(__glewMinmaxEXT) -#define glResetHistogramEXT GLEW_GET_FUN(__glewResetHistogramEXT) -#define glResetMinmaxEXT GLEW_GET_FUN(__glewResetMinmaxEXT) - -#define GLEW_EXT_histogram GLEW_GET_VAR(__GLEW_EXT_histogram) - -#endif /* GL_EXT_histogram */ - -/* ----------------------- GL_EXT_index_array_formats ---------------------- */ - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 - -#define GLEW_EXT_index_array_formats GLEW_GET_VAR(__GLEW_EXT_index_array_formats) - -#endif /* GL_EXT_index_array_formats */ - -/* --------------------------- GL_EXT_index_func --------------------------- */ - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 - -typedef void (GLAPIENTRY * PFNGLINDEXFUNCEXTPROC) (GLenum func, GLfloat ref); - -#define glIndexFuncEXT GLEW_GET_FUN(__glewIndexFuncEXT) - -#define GLEW_EXT_index_func GLEW_GET_VAR(__GLEW_EXT_index_func) - -#endif /* GL_EXT_index_func */ - -/* ------------------------- GL_EXT_index_material ------------------------- */ - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 - -typedef void (GLAPIENTRY * PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); - -#define glIndexMaterialEXT GLEW_GET_FUN(__glewIndexMaterialEXT) - -#define GLEW_EXT_index_material GLEW_GET_VAR(__GLEW_EXT_index_material) - -#endif /* GL_EXT_index_material */ - -/* -------------------------- GL_EXT_index_texture ------------------------- */ - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 - -#define GLEW_EXT_index_texture GLEW_GET_VAR(__GLEW_EXT_index_texture) - -#endif /* GL_EXT_index_texture */ - -/* -------------------------- GL_EXT_light_texture ------------------------- */ - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 - -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 - -typedef void (GLAPIENTRY * PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (GLAPIENTRY * PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (GLAPIENTRY * PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); - -#define glApplyTextureEXT GLEW_GET_FUN(__glewApplyTextureEXT) -#define glTextureLightEXT GLEW_GET_FUN(__glewTextureLightEXT) -#define glTextureMaterialEXT GLEW_GET_FUN(__glewTextureMaterialEXT) - -#define GLEW_EXT_light_texture GLEW_GET_VAR(__GLEW_EXT_light_texture) - -#endif /* GL_EXT_light_texture */ - -/* ------------------------- GL_EXT_misc_attribute ------------------------- */ - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 - -#define GLEW_EXT_misc_attribute GLEW_GET_VAR(__GLEW_EXT_misc_attribute) - -#endif /* GL_EXT_misc_attribute */ - -/* ------------------------ GL_EXT_multi_draw_arrays ----------------------- */ - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 - -typedef void (GLAPIENTRY * PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint* first, GLsizei *count, GLsizei primcount); -typedef void (GLAPIENTRY * PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, GLsizei* count, GLenum type, const GLvoid **indices, GLsizei primcount); - -#define glMultiDrawArraysEXT GLEW_GET_FUN(__glewMultiDrawArraysEXT) -#define glMultiDrawElementsEXT GLEW_GET_FUN(__glewMultiDrawElementsEXT) - -#define GLEW_EXT_multi_draw_arrays GLEW_GET_VAR(__GLEW_EXT_multi_draw_arrays) - -#endif /* GL_EXT_multi_draw_arrays */ - -/* --------------------------- GL_EXT_multisample -------------------------- */ - -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 - -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 - -typedef void (GLAPIENTRY * PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); - -#define glSampleMaskEXT GLEW_GET_FUN(__glewSampleMaskEXT) -#define glSamplePatternEXT GLEW_GET_FUN(__glewSamplePatternEXT) - -#define GLEW_EXT_multisample GLEW_GET_VAR(__GLEW_EXT_multisample) - -#endif /* GL_EXT_multisample */ - -/* ---------------------- GL_EXT_packed_depth_stencil ---------------------- */ - -#ifndef GL_EXT_packed_depth_stencil -#define GL_EXT_packed_depth_stencil 1 - -#define GL_DEPTH_STENCIL_EXT 0x84F9 -#define GL_UNSIGNED_INT_24_8_EXT 0x84FA -#define GL_DEPTH24_STENCIL8_EXT 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 - -#define GLEW_EXT_packed_depth_stencil GLEW_GET_VAR(__GLEW_EXT_packed_depth_stencil) - -#endif /* GL_EXT_packed_depth_stencil */ - -/* -------------------------- GL_EXT_packed_float -------------------------- */ - -#ifndef GL_EXT_packed_float -#define GL_EXT_packed_float 1 - -#define GL_R11F_G11F_B10F_EXT 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B -#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C - -#define GLEW_EXT_packed_float GLEW_GET_VAR(__GLEW_EXT_packed_float) - -#endif /* GL_EXT_packed_float */ - -/* -------------------------- GL_EXT_packed_pixels ------------------------- */ - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 - -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 - -#define GLEW_EXT_packed_pixels GLEW_GET_VAR(__GLEW_EXT_packed_pixels) - -#endif /* GL_EXT_packed_pixels */ - -/* ------------------------ GL_EXT_paletted_texture ------------------------ */ - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 - -#define GL_TEXTURE_1D 0x0DE0 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_PROXY_TEXTURE_1D 0x8063 -#define GL_PROXY_TEXTURE_2D 0x8064 -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_COLOR_TABLE_FORMAT_EXT 0x80D8 -#define GL_COLOR_TABLE_WIDTH_EXT 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_EXT 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_EXT 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_EXT 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_EXT 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_EXT 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_EXT 0x80DF -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B - -typedef void (GLAPIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void* data); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void* data); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint* params); - -#define glColorTableEXT GLEW_GET_FUN(__glewColorTableEXT) -#define glGetColorTableEXT GLEW_GET_FUN(__glewGetColorTableEXT) -#define glGetColorTableParameterfvEXT GLEW_GET_FUN(__glewGetColorTableParameterfvEXT) -#define glGetColorTableParameterivEXT GLEW_GET_FUN(__glewGetColorTableParameterivEXT) - -#define GLEW_EXT_paletted_texture GLEW_GET_VAR(__GLEW_EXT_paletted_texture) - -#endif /* GL_EXT_paletted_texture */ - -/* ----------------------- GL_EXT_pixel_buffer_object ---------------------- */ - -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 - -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF - -#define GLEW_EXT_pixel_buffer_object GLEW_GET_VAR(__GLEW_EXT_pixel_buffer_object) - -#endif /* GL_EXT_pixel_buffer_object */ - -/* ------------------------- GL_EXT_pixel_transform ------------------------ */ - -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 - -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 - -typedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, const GLfloat param); -typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, const GLint param); -typedef void (GLAPIENTRY * PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint* params); - -#define glGetPixelTransformParameterfvEXT GLEW_GET_FUN(__glewGetPixelTransformParameterfvEXT) -#define glGetPixelTransformParameterivEXT GLEW_GET_FUN(__glewGetPixelTransformParameterivEXT) -#define glPixelTransformParameterfEXT GLEW_GET_FUN(__glewPixelTransformParameterfEXT) -#define glPixelTransformParameterfvEXT GLEW_GET_FUN(__glewPixelTransformParameterfvEXT) -#define glPixelTransformParameteriEXT GLEW_GET_FUN(__glewPixelTransformParameteriEXT) -#define glPixelTransformParameterivEXT GLEW_GET_FUN(__glewPixelTransformParameterivEXT) - -#define GLEW_EXT_pixel_transform GLEW_GET_VAR(__GLEW_EXT_pixel_transform) - -#endif /* GL_EXT_pixel_transform */ - -/* ------------------- GL_EXT_pixel_transform_color_table ------------------ */ - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 - -#define GLEW_EXT_pixel_transform_color_table GLEW_GET_VAR(__GLEW_EXT_pixel_transform_color_table) - -#endif /* GL_EXT_pixel_transform_color_table */ - -/* ------------------------ GL_EXT_point_parameters ------------------------ */ - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 - -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 - -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, GLfloat* params); - -#define glPointParameterfEXT GLEW_GET_FUN(__glewPointParameterfEXT) -#define glPointParameterfvEXT GLEW_GET_FUN(__glewPointParameterfvEXT) - -#define GLEW_EXT_point_parameters GLEW_GET_VAR(__GLEW_EXT_point_parameters) - -#endif /* GL_EXT_point_parameters */ - -/* ------------------------- GL_EXT_polygon_offset ------------------------- */ - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 - -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 - -typedef void (GLAPIENTRY * PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); - -#define glPolygonOffsetEXT GLEW_GET_FUN(__glewPolygonOffsetEXT) - -#define GLEW_EXT_polygon_offset GLEW_GET_VAR(__GLEW_EXT_polygon_offset) - -#endif /* GL_EXT_polygon_offset */ - -/* ------------------------- GL_EXT_rescale_normal ------------------------- */ - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 - -#define GL_RESCALE_NORMAL_EXT 0x803A - -#define GLEW_EXT_rescale_normal GLEW_GET_VAR(__GLEW_EXT_rescale_normal) - -#endif /* GL_EXT_rescale_normal */ - -/* -------------------------- GL_EXT_scene_marker -------------------------- */ - -#ifndef GL_EXT_scene_marker -#define GL_EXT_scene_marker 1 - -typedef void (GLAPIENTRY * PFNGLBEGINSCENEEXTPROC) (void); -typedef void (GLAPIENTRY * PFNGLENDSCENEEXTPROC) (void); - -#define glBeginSceneEXT GLEW_GET_FUN(__glewBeginSceneEXT) -#define glEndSceneEXT GLEW_GET_FUN(__glewEndSceneEXT) - -#define GLEW_EXT_scene_marker GLEW_GET_VAR(__GLEW_EXT_scene_marker) - -#endif /* GL_EXT_scene_marker */ - -/* ------------------------- GL_EXT_secondary_color ------------------------ */ - -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 - -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E - -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLvoid *pointer); - -#define glSecondaryColor3bEXT GLEW_GET_FUN(__glewSecondaryColor3bEXT) -#define glSecondaryColor3bvEXT GLEW_GET_FUN(__glewSecondaryColor3bvEXT) -#define glSecondaryColor3dEXT GLEW_GET_FUN(__glewSecondaryColor3dEXT) -#define glSecondaryColor3dvEXT GLEW_GET_FUN(__glewSecondaryColor3dvEXT) -#define glSecondaryColor3fEXT GLEW_GET_FUN(__glewSecondaryColor3fEXT) -#define glSecondaryColor3fvEXT GLEW_GET_FUN(__glewSecondaryColor3fvEXT) -#define glSecondaryColor3iEXT GLEW_GET_FUN(__glewSecondaryColor3iEXT) -#define glSecondaryColor3ivEXT GLEW_GET_FUN(__glewSecondaryColor3ivEXT) -#define glSecondaryColor3sEXT GLEW_GET_FUN(__glewSecondaryColor3sEXT) -#define glSecondaryColor3svEXT GLEW_GET_FUN(__glewSecondaryColor3svEXT) -#define glSecondaryColor3ubEXT GLEW_GET_FUN(__glewSecondaryColor3ubEXT) -#define glSecondaryColor3ubvEXT GLEW_GET_FUN(__glewSecondaryColor3ubvEXT) -#define glSecondaryColor3uiEXT GLEW_GET_FUN(__glewSecondaryColor3uiEXT) -#define glSecondaryColor3uivEXT GLEW_GET_FUN(__glewSecondaryColor3uivEXT) -#define glSecondaryColor3usEXT GLEW_GET_FUN(__glewSecondaryColor3usEXT) -#define glSecondaryColor3usvEXT GLEW_GET_FUN(__glewSecondaryColor3usvEXT) -#define glSecondaryColorPointerEXT GLEW_GET_FUN(__glewSecondaryColorPointerEXT) - -#define GLEW_EXT_secondary_color GLEW_GET_VAR(__GLEW_EXT_secondary_color) - -#endif /* GL_EXT_secondary_color */ - -/* --------------------- GL_EXT_separate_specular_color -------------------- */ - -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 - -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA - -#define GLEW_EXT_separate_specular_color GLEW_GET_VAR(__GLEW_EXT_separate_specular_color) - -#endif /* GL_EXT_separate_specular_color */ - -/* -------------------------- GL_EXT_shadow_funcs -------------------------- */ - -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 - -#define GLEW_EXT_shadow_funcs GLEW_GET_VAR(__GLEW_EXT_shadow_funcs) - -#endif /* GL_EXT_shadow_funcs */ - -/* --------------------- GL_EXT_shared_texture_palette --------------------- */ - -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 - -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB - -#define GLEW_EXT_shared_texture_palette GLEW_GET_VAR(__GLEW_EXT_shared_texture_palette) - -#endif /* GL_EXT_shared_texture_palette */ - -/* ------------------------ GL_EXT_stencil_clear_tag ----------------------- */ - -#ifndef GL_EXT_stencil_clear_tag -#define GL_EXT_stencil_clear_tag 1 - -#define GL_STENCIL_TAG_BITS_EXT 0x88F2 -#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 - -#define GLEW_EXT_stencil_clear_tag GLEW_GET_VAR(__GLEW_EXT_stencil_clear_tag) - -#endif /* GL_EXT_stencil_clear_tag */ - -/* ------------------------ GL_EXT_stencil_two_side ------------------------ */ - -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 - -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 - -typedef void (GLAPIENTRY * PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); - -#define glActiveStencilFaceEXT GLEW_GET_FUN(__glewActiveStencilFaceEXT) - -#define GLEW_EXT_stencil_two_side GLEW_GET_VAR(__GLEW_EXT_stencil_two_side) - -#endif /* GL_EXT_stencil_two_side */ - -/* -------------------------- GL_EXT_stencil_wrap -------------------------- */ - -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 - -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 - -#define GLEW_EXT_stencil_wrap GLEW_GET_VAR(__GLEW_EXT_stencil_wrap) - -#endif /* GL_EXT_stencil_wrap */ - -/* --------------------------- GL_EXT_subtexture --------------------------- */ - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 - -typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void* pixels); - -#define glTexSubImage1DEXT GLEW_GET_FUN(__glewTexSubImage1DEXT) -#define glTexSubImage2DEXT GLEW_GET_FUN(__glewTexSubImage2DEXT) -#define glTexSubImage3DEXT GLEW_GET_FUN(__glewTexSubImage3DEXT) - -#define GLEW_EXT_subtexture GLEW_GET_VAR(__GLEW_EXT_subtexture) - -#endif /* GL_EXT_subtexture */ - -/* ----------------------------- GL_EXT_texture ---------------------------- */ - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 - -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 - -#define GLEW_EXT_texture GLEW_GET_VAR(__GLEW_EXT_texture) - -#endif /* GL_EXT_texture */ - -/* ---------------------------- GL_EXT_texture3D --------------------------- */ - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 - -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 - -typedef void (GLAPIENTRY * PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void* pixels); - -#define glTexImage3DEXT GLEW_GET_FUN(__glewTexImage3DEXT) - -#define GLEW_EXT_texture3D GLEW_GET_VAR(__GLEW_EXT_texture3D) - -#endif /* GL_EXT_texture3D */ - -/* -------------------------- GL_EXT_texture_array ------------------------- */ - -#ifndef GL_EXT_texture_array -#define GL_EXT_texture_array 1 - -#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E -#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF -#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 -#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D - -#define GLEW_EXT_texture_array GLEW_GET_VAR(__GLEW_EXT_texture_array) - -#endif /* GL_EXT_texture_array */ - -/* ---------------------- GL_EXT_texture_buffer_object --------------------- */ - -#ifndef GL_EXT_texture_buffer_object -#define GL_EXT_texture_buffer_object 1 - -#define GL_TEXTURE_BUFFER_EXT 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E - -typedef void (GLAPIENTRY * PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); - -#define glTexBufferEXT GLEW_GET_FUN(__glewTexBufferEXT) - -#define GLEW_EXT_texture_buffer_object GLEW_GET_VAR(__GLEW_EXT_texture_buffer_object) - -#endif /* GL_EXT_texture_buffer_object */ - -/* -------------------- GL_EXT_texture_compression_dxt1 -------------------- */ - -#ifndef GL_EXT_texture_compression_dxt1 -#define GL_EXT_texture_compression_dxt1 1 - -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 - -#define GLEW_EXT_texture_compression_dxt1 GLEW_GET_VAR(__GLEW_EXT_texture_compression_dxt1) - -#endif /* GL_EXT_texture_compression_dxt1 */ - -/* -------------------- GL_EXT_texture_compression_latc -------------------- */ - -#ifndef GL_EXT_texture_compression_latc -#define GL_EXT_texture_compression_latc 1 - -#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 -#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 -#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 -#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 - -#define GLEW_EXT_texture_compression_latc GLEW_GET_VAR(__GLEW_EXT_texture_compression_latc) - -#endif /* GL_EXT_texture_compression_latc */ - -/* -------------------- GL_EXT_texture_compression_rgtc -------------------- */ - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_EXT_texture_compression_rgtc 1 - -#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE - -#define GLEW_EXT_texture_compression_rgtc GLEW_GET_VAR(__GLEW_EXT_texture_compression_rgtc) - -#endif /* GL_EXT_texture_compression_rgtc */ - -/* -------------------- GL_EXT_texture_compression_s3tc -------------------- */ - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_EXT_texture_compression_s3tc 1 - -#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 - -#define GLEW_EXT_texture_compression_s3tc GLEW_GET_VAR(__GLEW_EXT_texture_compression_s3tc) - -#endif /* GL_EXT_texture_compression_s3tc */ - -/* ------------------------ GL_EXT_texture_cube_map ------------------------ */ - -#ifndef GL_EXT_texture_cube_map -#define GL_EXT_texture_cube_map 1 - -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C - -#define GLEW_EXT_texture_cube_map GLEW_GET_VAR(__GLEW_EXT_texture_cube_map) - -#endif /* GL_EXT_texture_cube_map */ - -/* ----------------------- GL_EXT_texture_edge_clamp ----------------------- */ - -#ifndef GL_EXT_texture_edge_clamp -#define GL_EXT_texture_edge_clamp 1 - -#define GL_CLAMP_TO_EDGE_EXT 0x812F - -#define GLEW_EXT_texture_edge_clamp GLEW_GET_VAR(__GLEW_EXT_texture_edge_clamp) - -#endif /* GL_EXT_texture_edge_clamp */ - -/* --------------------------- GL_EXT_texture_env -------------------------- */ - -#ifndef GL_EXT_texture_env -#define GL_EXT_texture_env 1 - -#define GL_TEXTURE_ENV0_EXT 0 -#define GL_ENV_BLEND_EXT 0 -#define GL_TEXTURE_ENV_SHIFT_EXT 0 -#define GL_ENV_REPLACE_EXT 0 -#define GL_ENV_ADD_EXT 0 -#define GL_ENV_SUBTRACT_EXT 0 -#define GL_TEXTURE_ENV_MODE_ALPHA_EXT 0 -#define GL_ENV_REVERSE_SUBTRACT_EXT 0 -#define GL_ENV_REVERSE_BLEND_EXT 0 -#define GL_ENV_COPY_EXT 0 -#define GL_ENV_MODULATE_EXT 0 - -#define GLEW_EXT_texture_env GLEW_GET_VAR(__GLEW_EXT_texture_env) - -#endif /* GL_EXT_texture_env */ - -/* ------------------------- GL_EXT_texture_env_add ------------------------ */ - -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 - -#define GLEW_EXT_texture_env_add GLEW_GET_VAR(__GLEW_EXT_texture_env_add) - -#endif /* GL_EXT_texture_env_add */ - -/* ----------------------- GL_EXT_texture_env_combine ---------------------- */ - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 - -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A - -#define GLEW_EXT_texture_env_combine GLEW_GET_VAR(__GLEW_EXT_texture_env_combine) - -#endif /* GL_EXT_texture_env_combine */ - -/* ------------------------ GL_EXT_texture_env_dot3 ------------------------ */ - -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 - -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 - -#define GLEW_EXT_texture_env_dot3 GLEW_GET_VAR(__GLEW_EXT_texture_env_dot3) - -#endif /* GL_EXT_texture_env_dot3 */ - -/* ------------------- GL_EXT_texture_filter_anisotropic ------------------- */ - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 - -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF - -#define GLEW_EXT_texture_filter_anisotropic GLEW_GET_VAR(__GLEW_EXT_texture_filter_anisotropic) - -#endif /* GL_EXT_texture_filter_anisotropic */ - -/* ------------------------- GL_EXT_texture_integer ------------------------ */ - -#ifndef GL_EXT_texture_integer -#define GL_EXT_texture_integer 1 - -#define GL_RGBA32UI_EXT 0x8D70 -#define GL_RGB32UI_EXT 0x8D71 -#define GL_ALPHA32UI_EXT 0x8D72 -#define GL_INTENSITY32UI_EXT 0x8D73 -#define GL_LUMINANCE32UI_EXT 0x8D74 -#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 -#define GL_RGBA16UI_EXT 0x8D76 -#define GL_RGB16UI_EXT 0x8D77 -#define GL_ALPHA16UI_EXT 0x8D78 -#define GL_INTENSITY16UI_EXT 0x8D79 -#define GL_LUMINANCE16UI_EXT 0x8D7A -#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B -#define GL_RGBA8UI_EXT 0x8D7C -#define GL_RGB8UI_EXT 0x8D7D -#define GL_ALPHA8UI_EXT 0x8D7E -#define GL_INTENSITY8UI_EXT 0x8D7F -#define GL_LUMINANCE8UI_EXT 0x8D80 -#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 -#define GL_RGBA32I_EXT 0x8D82 -#define GL_RGB32I_EXT 0x8D83 -#define GL_ALPHA32I_EXT 0x8D84 -#define GL_INTENSITY32I_EXT 0x8D85 -#define GL_LUMINANCE32I_EXT 0x8D86 -#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 -#define GL_RGBA16I_EXT 0x8D88 -#define GL_RGB16I_EXT 0x8D89 -#define GL_ALPHA16I_EXT 0x8D8A -#define GL_INTENSITY16I_EXT 0x8D8B -#define GL_LUMINANCE16I_EXT 0x8D8C -#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D -#define GL_RGBA8I_EXT 0x8D8E -#define GL_RGB8I_EXT 0x8D8F -#define GL_ALPHA8I_EXT 0x8D90 -#define GL_INTENSITY8I_EXT 0x8D91 -#define GL_LUMINANCE8I_EXT 0x8D92 -#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 -#define GL_RED_INTEGER_EXT 0x8D94 -#define GL_GREEN_INTEGER_EXT 0x8D95 -#define GL_BLUE_INTEGER_EXT 0x8D96 -#define GL_ALPHA_INTEGER_EXT 0x8D97 -#define GL_RGB_INTEGER_EXT 0x8D98 -#define GL_RGBA_INTEGER_EXT 0x8D99 -#define GL_BGR_INTEGER_EXT 0x8D9A -#define GL_BGRA_INTEGER_EXT 0x8D9B -#define GL_LUMINANCE_INTEGER_EXT 0x8D9C -#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D -#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E - -typedef void (GLAPIENTRY * PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); -typedef void (GLAPIENTRY * PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); -typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (GLAPIENTRY * PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); - -#define glClearColorIiEXT GLEW_GET_FUN(__glewClearColorIiEXT) -#define glClearColorIuiEXT GLEW_GET_FUN(__glewClearColorIuiEXT) -#define glGetTexParameterIivEXT GLEW_GET_FUN(__glewGetTexParameterIivEXT) -#define glGetTexParameterIuivEXT GLEW_GET_FUN(__glewGetTexParameterIuivEXT) -#define glTexParameterIivEXT GLEW_GET_FUN(__glewTexParameterIivEXT) -#define glTexParameterIuivEXT GLEW_GET_FUN(__glewTexParameterIuivEXT) - -#define GLEW_EXT_texture_integer GLEW_GET_VAR(__GLEW_EXT_texture_integer) - -#endif /* GL_EXT_texture_integer */ - -/* ------------------------ GL_EXT_texture_lod_bias ------------------------ */ - -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 - -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 - -#define GLEW_EXT_texture_lod_bias GLEW_GET_VAR(__GLEW_EXT_texture_lod_bias) - -#endif /* GL_EXT_texture_lod_bias */ - -/* ---------------------- GL_EXT_texture_mirror_clamp ---------------------- */ - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 - -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 - -#define GLEW_EXT_texture_mirror_clamp GLEW_GET_VAR(__GLEW_EXT_texture_mirror_clamp) - -#endif /* GL_EXT_texture_mirror_clamp */ - -/* ------------------------- GL_EXT_texture_object ------------------------- */ - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 - -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A - -typedef GLboolean (GLAPIENTRY * PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint* textures, GLboolean* residences); -typedef void (GLAPIENTRY * PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (GLAPIENTRY * PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint* textures); -typedef void (GLAPIENTRY * PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint* textures); -typedef GLboolean (GLAPIENTRY * PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (GLAPIENTRY * PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint* textures, const GLclampf* priorities); - -#define glAreTexturesResidentEXT GLEW_GET_FUN(__glewAreTexturesResidentEXT) -#define glBindTextureEXT GLEW_GET_FUN(__glewBindTextureEXT) -#define glDeleteTexturesEXT GLEW_GET_FUN(__glewDeleteTexturesEXT) -#define glGenTexturesEXT GLEW_GET_FUN(__glewGenTexturesEXT) -#define glIsTextureEXT GLEW_GET_FUN(__glewIsTextureEXT) -#define glPrioritizeTexturesEXT GLEW_GET_FUN(__glewPrioritizeTexturesEXT) - -#define GLEW_EXT_texture_object GLEW_GET_VAR(__GLEW_EXT_texture_object) - -#endif /* GL_EXT_texture_object */ - -/* --------------------- GL_EXT_texture_perturb_normal --------------------- */ - -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 - -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF - -typedef void (GLAPIENTRY * PFNGLTEXTURENORMALEXTPROC) (GLenum mode); - -#define glTextureNormalEXT GLEW_GET_FUN(__glewTextureNormalEXT) - -#define GLEW_EXT_texture_perturb_normal GLEW_GET_VAR(__GLEW_EXT_texture_perturb_normal) - -#endif /* GL_EXT_texture_perturb_normal */ - -/* ------------------------ GL_EXT_texture_rectangle ----------------------- */ - -#ifndef GL_EXT_texture_rectangle -#define GL_EXT_texture_rectangle 1 - -#define GL_TEXTURE_RECTANGLE_EXT 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_EXT 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_EXT 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT 0x84F8 - -#define GLEW_EXT_texture_rectangle GLEW_GET_VAR(__GLEW_EXT_texture_rectangle) - -#endif /* GL_EXT_texture_rectangle */ - -/* -------------------------- GL_EXT_texture_sRGB -------------------------- */ - -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB 1 - -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F - -#define GLEW_EXT_texture_sRGB GLEW_GET_VAR(__GLEW_EXT_texture_sRGB) - -#endif /* GL_EXT_texture_sRGB */ - -/* --------------------- GL_EXT_texture_shared_exponent -------------------- */ - -#ifndef GL_EXT_texture_shared_exponent -#define GL_EXT_texture_shared_exponent 1 - -#define GL_RGB9_E5_EXT 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E -#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F - -#define GLEW_EXT_texture_shared_exponent GLEW_GET_VAR(__GLEW_EXT_texture_shared_exponent) - -#endif /* GL_EXT_texture_shared_exponent */ - -/* ------------------------- GL_EXT_texture_swizzle ------------------------ */ - -#ifndef GL_EXT_texture_swizzle -#define GL_EXT_texture_swizzle 1 - -#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 -#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 -#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 -#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 - -#define GLEW_EXT_texture_swizzle GLEW_GET_VAR(__GLEW_EXT_texture_swizzle) - -#endif /* GL_EXT_texture_swizzle */ - -/* --------------------------- GL_EXT_timer_query -------------------------- */ - -#ifndef GL_EXT_timer_query -#define GL_EXT_timer_query 1 - -#define GL_TIME_ELAPSED_EXT 0x88BF - -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); -typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); - -#define glGetQueryObjecti64vEXT GLEW_GET_FUN(__glewGetQueryObjecti64vEXT) -#define glGetQueryObjectui64vEXT GLEW_GET_FUN(__glewGetQueryObjectui64vEXT) - -#define GLEW_EXT_timer_query GLEW_GET_VAR(__GLEW_EXT_timer_query) - -#endif /* GL_EXT_timer_query */ - -/* ----------------------- GL_EXT_transform_feedback ----------------------- */ - -#ifndef GL_EXT_transform_feedback -#define GL_EXT_transform_feedback 1 - -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 -#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 -#define GL_RASTERIZER_DISCARD_EXT 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B -#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C -#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F - -typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); -typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei *size, GLenum *type, char *name); -typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const char ** varyings, GLenum bufferMode); - -#define glBeginTransformFeedbackEXT GLEW_GET_FUN(__glewBeginTransformFeedbackEXT) -#define glBindBufferBaseEXT GLEW_GET_FUN(__glewBindBufferBaseEXT) -#define glBindBufferOffsetEXT GLEW_GET_FUN(__glewBindBufferOffsetEXT) -#define glBindBufferRangeEXT GLEW_GET_FUN(__glewBindBufferRangeEXT) -#define glEndTransformFeedbackEXT GLEW_GET_FUN(__glewEndTransformFeedbackEXT) -#define glGetTransformFeedbackVaryingEXT GLEW_GET_FUN(__glewGetTransformFeedbackVaryingEXT) -#define glTransformFeedbackVaryingsEXT GLEW_GET_FUN(__glewTransformFeedbackVaryingsEXT) - -#define GLEW_EXT_transform_feedback GLEW_GET_VAR(__GLEW_EXT_transform_feedback) - -#endif /* GL_EXT_transform_feedback */ - -/* -------------------------- GL_EXT_vertex_array -------------------------- */ - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 - -#define GL_DOUBLE_EXT 0x140A -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 - -typedef void (GLAPIENTRY * PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (GLAPIENTRY * PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); -typedef void (GLAPIENTRY * PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean* pointer); -typedef void (GLAPIENTRY * PFNGLGETPOINTERVEXTPROC) (GLenum pname, void** params); -typedef void (GLAPIENTRY * PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void* pointer); -typedef void (GLAPIENTRY * PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void* pointer); -typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); -typedef void (GLAPIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void* pointer); - -#define glArrayElementEXT GLEW_GET_FUN(__glewArrayElementEXT) -#define glColorPointerEXT GLEW_GET_FUN(__glewColorPointerEXT) -#define glDrawArraysEXT GLEW_GET_FUN(__glewDrawArraysEXT) -#define glEdgeFlagPointerEXT GLEW_GET_FUN(__glewEdgeFlagPointerEXT) -#define glGetPointervEXT GLEW_GET_FUN(__glewGetPointervEXT) -#define glIndexPointerEXT GLEW_GET_FUN(__glewIndexPointerEXT) -#define glNormalPointerEXT GLEW_GET_FUN(__glewNormalPointerEXT) -#define glTexCoordPointerEXT GLEW_GET_FUN(__glewTexCoordPointerEXT) -#define glVertexPointerEXT GLEW_GET_FUN(__glewVertexPointerEXT) - -#define GLEW_EXT_vertex_array GLEW_GET_VAR(__GLEW_EXT_vertex_array) - -#endif /* GL_EXT_vertex_array */ - -/* ------------------------ GL_EXT_vertex_array_bgra ----------------------- */ - -#ifndef GL_EXT_vertex_array_bgra -#define GL_EXT_vertex_array_bgra 1 - -#define GL_BGRA 0x80E1 - -#define GLEW_EXT_vertex_array_bgra GLEW_GET_VAR(__GLEW_EXT_vertex_array_bgra) - -#endif /* GL_EXT_vertex_array_bgra */ - -/* -------------------------- GL_EXT_vertex_shader ------------------------- */ - -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 - -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED - -typedef void (GLAPIENTRY * PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef GLuint (GLAPIENTRY * PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (GLAPIENTRY * PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (GLAPIENTRY * PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLuint (GLAPIENTRY * PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (GLAPIENTRY * PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef void (GLAPIENTRY * PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (GLAPIENTRY * PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (GLAPIENTRY * PFNGLGENSYMBOLSEXTPROC) (GLenum dataType, GLenum storageType, GLenum range, GLuint components); -typedef GLuint (GLAPIENTRY * PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (GLAPIENTRY * PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (GLAPIENTRY * PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (GLAPIENTRY * PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (GLAPIENTRY * PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (GLAPIENTRY * PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (GLAPIENTRY * PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (GLAPIENTRY * PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (GLAPIENTRY * PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid **data); -typedef void (GLAPIENTRY * PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLboolean (GLAPIENTRY * PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (GLAPIENTRY * PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, GLvoid *addr); -typedef void (GLAPIENTRY * PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, GLvoid *addr); -typedef void (GLAPIENTRY * PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (GLAPIENTRY * PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (GLAPIENTRY * PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (GLAPIENTRY * PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (GLAPIENTRY * PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, GLvoid *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTBVEXTPROC) (GLuint id, GLbyte *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTDVEXTPROC) (GLuint id, GLdouble *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTFVEXTPROC) (GLuint id, GLfloat *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTIVEXTPROC) (GLuint id, GLint *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTSVEXTPROC) (GLuint id, GLshort *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTUBVEXTPROC) (GLuint id, GLubyte *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTUIVEXTPROC) (GLuint id, GLuint *addr); -typedef void (GLAPIENTRY * PFNGLVARIANTUSVEXTPROC) (GLuint id, GLushort *addr); -typedef void (GLAPIENTRY * PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); - -#define glBeginVertexShaderEXT GLEW_GET_FUN(__glewBeginVertexShaderEXT) -#define glBindLightParameterEXT GLEW_GET_FUN(__glewBindLightParameterEXT) -#define glBindMaterialParameterEXT GLEW_GET_FUN(__glewBindMaterialParameterEXT) -#define glBindParameterEXT GLEW_GET_FUN(__glewBindParameterEXT) -#define glBindTexGenParameterEXT GLEW_GET_FUN(__glewBindTexGenParameterEXT) -#define glBindTextureUnitParameterEXT GLEW_GET_FUN(__glewBindTextureUnitParameterEXT) -#define glBindVertexShaderEXT GLEW_GET_FUN(__glewBindVertexShaderEXT) -#define glDeleteVertexShaderEXT GLEW_GET_FUN(__glewDeleteVertexShaderEXT) -#define glDisableVariantClientStateEXT GLEW_GET_FUN(__glewDisableVariantClientStateEXT) -#define glEnableVariantClientStateEXT GLEW_GET_FUN(__glewEnableVariantClientStateEXT) -#define glEndVertexShaderEXT GLEW_GET_FUN(__glewEndVertexShaderEXT) -#define glExtractComponentEXT GLEW_GET_FUN(__glewExtractComponentEXT) -#define glGenSymbolsEXT GLEW_GET_FUN(__glewGenSymbolsEXT) -#define glGenVertexShadersEXT GLEW_GET_FUN(__glewGenVertexShadersEXT) -#define glGetInvariantBooleanvEXT GLEW_GET_FUN(__glewGetInvariantBooleanvEXT) -#define glGetInvariantFloatvEXT GLEW_GET_FUN(__glewGetInvariantFloatvEXT) -#define glGetInvariantIntegervEXT GLEW_GET_FUN(__glewGetInvariantIntegervEXT) -#define glGetLocalConstantBooleanvEXT GLEW_GET_FUN(__glewGetLocalConstantBooleanvEXT) -#define glGetLocalConstantFloatvEXT GLEW_GET_FUN(__glewGetLocalConstantFloatvEXT) -#define glGetLocalConstantIntegervEXT GLEW_GET_FUN(__glewGetLocalConstantIntegervEXT) -#define glGetVariantBooleanvEXT GLEW_GET_FUN(__glewGetVariantBooleanvEXT) -#define glGetVariantFloatvEXT GLEW_GET_FUN(__glewGetVariantFloatvEXT) -#define glGetVariantIntegervEXT GLEW_GET_FUN(__glewGetVariantIntegervEXT) -#define glGetVariantPointervEXT GLEW_GET_FUN(__glewGetVariantPointervEXT) -#define glInsertComponentEXT GLEW_GET_FUN(__glewInsertComponentEXT) -#define glIsVariantEnabledEXT GLEW_GET_FUN(__glewIsVariantEnabledEXT) -#define glSetInvariantEXT GLEW_GET_FUN(__glewSetInvariantEXT) -#define glSetLocalConstantEXT GLEW_GET_FUN(__glewSetLocalConstantEXT) -#define glShaderOp1EXT GLEW_GET_FUN(__glewShaderOp1EXT) -#define glShaderOp2EXT GLEW_GET_FUN(__glewShaderOp2EXT) -#define glShaderOp3EXT GLEW_GET_FUN(__glewShaderOp3EXT) -#define glSwizzleEXT GLEW_GET_FUN(__glewSwizzleEXT) -#define glVariantPointerEXT GLEW_GET_FUN(__glewVariantPointerEXT) -#define glVariantbvEXT GLEW_GET_FUN(__glewVariantbvEXT) -#define glVariantdvEXT GLEW_GET_FUN(__glewVariantdvEXT) -#define glVariantfvEXT GLEW_GET_FUN(__glewVariantfvEXT) -#define glVariantivEXT GLEW_GET_FUN(__glewVariantivEXT) -#define glVariantsvEXT GLEW_GET_FUN(__glewVariantsvEXT) -#define glVariantubvEXT GLEW_GET_FUN(__glewVariantubvEXT) -#define glVariantuivEXT GLEW_GET_FUN(__glewVariantuivEXT) -#define glVariantusvEXT GLEW_GET_FUN(__glewVariantusvEXT) -#define glWriteMaskEXT GLEW_GET_FUN(__glewWriteMaskEXT) - -#define GLEW_EXT_vertex_shader GLEW_GET_VAR(__GLEW_EXT_vertex_shader) - -#endif /* GL_EXT_vertex_shader */ - -/* ------------------------ GL_EXT_vertex_weighting ------------------------ */ - -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 - -#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 -#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 -#define GL_MODELVIEW0_EXT 0x1700 -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 - -typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, void* pointer); -typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTFVEXTPROC) (GLfloat* weight); - -#define glVertexWeightPointerEXT GLEW_GET_FUN(__glewVertexWeightPointerEXT) -#define glVertexWeightfEXT GLEW_GET_FUN(__glewVertexWeightfEXT) -#define glVertexWeightfvEXT GLEW_GET_FUN(__glewVertexWeightfvEXT) - -#define GLEW_EXT_vertex_weighting GLEW_GET_VAR(__GLEW_EXT_vertex_weighting) - -#endif /* GL_EXT_vertex_weighting */ - -/* ---------------------- GL_GREMEDY_frame_terminator ---------------------- */ - -#ifndef GL_GREMEDY_frame_terminator -#define GL_GREMEDY_frame_terminator 1 - -typedef void (GLAPIENTRY * PFNGLFRAMETERMINATORGREMEDYPROC) (void); - -#define glFrameTerminatorGREMEDY GLEW_GET_FUN(__glewFrameTerminatorGREMEDY) - -#define GLEW_GREMEDY_frame_terminator GLEW_GET_VAR(__GLEW_GREMEDY_frame_terminator) - -#endif /* GL_GREMEDY_frame_terminator */ - -/* ------------------------ GL_GREMEDY_string_marker ----------------------- */ - -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 - -typedef void (GLAPIENTRY * PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void* string); - -#define glStringMarkerGREMEDY GLEW_GET_FUN(__glewStringMarkerGREMEDY) - -#define GLEW_GREMEDY_string_marker GLEW_GET_VAR(__GLEW_GREMEDY_string_marker) - -#endif /* GL_GREMEDY_string_marker */ - -/* --------------------- GL_HP_convolution_border_modes -------------------- */ - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 - -#define GLEW_HP_convolution_border_modes GLEW_GET_VAR(__GLEW_HP_convolution_border_modes) - -#endif /* GL_HP_convolution_border_modes */ - -/* ------------------------- GL_HP_image_transform ------------------------- */ - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 - -typedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, const GLfloat param); -typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, const GLint param); -typedef void (GLAPIENTRY * PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint* params); - -#define glGetImageTransformParameterfvHP GLEW_GET_FUN(__glewGetImageTransformParameterfvHP) -#define glGetImageTransformParameterivHP GLEW_GET_FUN(__glewGetImageTransformParameterivHP) -#define glImageTransformParameterfHP GLEW_GET_FUN(__glewImageTransformParameterfHP) -#define glImageTransformParameterfvHP GLEW_GET_FUN(__glewImageTransformParameterfvHP) -#define glImageTransformParameteriHP GLEW_GET_FUN(__glewImageTransformParameteriHP) -#define glImageTransformParameterivHP GLEW_GET_FUN(__glewImageTransformParameterivHP) - -#define GLEW_HP_image_transform GLEW_GET_VAR(__GLEW_HP_image_transform) - -#endif /* GL_HP_image_transform */ - -/* -------------------------- GL_HP_occlusion_test ------------------------- */ - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 - -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 - -#define GLEW_HP_occlusion_test GLEW_GET_VAR(__GLEW_HP_occlusion_test) - -#endif /* GL_HP_occlusion_test */ - -/* ------------------------- GL_HP_texture_lighting ------------------------ */ - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 - -#define GLEW_HP_texture_lighting GLEW_GET_VAR(__GLEW_HP_texture_lighting) - -#endif /* GL_HP_texture_lighting */ - -/* --------------------------- GL_IBM_cull_vertex -------------------------- */ - -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 - -#define GL_CULL_VERTEX_IBM 103050 - -#define GLEW_IBM_cull_vertex GLEW_GET_VAR(__GLEW_IBM_cull_vertex) - -#endif /* GL_IBM_cull_vertex */ - -/* ---------------------- GL_IBM_multimode_draw_arrays --------------------- */ - -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 - -typedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum* mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (GLAPIENTRY * PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum* mode, const GLsizei *count, GLenum type, const GLvoid * const *indices, GLsizei primcount, GLint modestride); - -#define glMultiModeDrawArraysIBM GLEW_GET_FUN(__glewMultiModeDrawArraysIBM) -#define glMultiModeDrawElementsIBM GLEW_GET_FUN(__glewMultiModeDrawElementsIBM) - -#define GLEW_IBM_multimode_draw_arrays GLEW_GET_VAR(__GLEW_IBM_multimode_draw_arrays) - -#endif /* GL_IBM_multimode_draw_arrays */ - -/* ------------------------- GL_IBM_rasterpos_clip ------------------------- */ - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 - -#define GL_RASTER_POSITION_UNCLIPPED_IBM 103010 - -#define GLEW_IBM_rasterpos_clip GLEW_GET_VAR(__GLEW_IBM_rasterpos_clip) - -#endif /* GL_IBM_rasterpos_clip */ - -/* --------------------------- GL_IBM_static_data -------------------------- */ - -#ifndef GL_IBM_static_data -#define GL_IBM_static_data 1 - -#define GL_ALL_STATIC_DATA_IBM 103060 -#define GL_STATIC_VERTEX_ARRAY_IBM 103061 - -#define GLEW_IBM_static_data GLEW_GET_VAR(__GLEW_IBM_static_data) - -#endif /* GL_IBM_static_data */ - -/* --------------------- GL_IBM_texture_mirrored_repeat -------------------- */ - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_IBM_texture_mirrored_repeat 1 - -#define GL_MIRRORED_REPEAT_IBM 0x8370 - -#define GLEW_IBM_texture_mirrored_repeat GLEW_GET_VAR(__GLEW_IBM_texture_mirrored_repeat) - -#endif /* GL_IBM_texture_mirrored_repeat */ - -/* ----------------------- GL_IBM_vertex_array_lists ----------------------- */ - -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 - -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 - -typedef void (GLAPIENTRY * PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean ** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); -typedef void (GLAPIENTRY * PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid ** pointer, GLint ptrstride); - -#define glColorPointerListIBM GLEW_GET_FUN(__glewColorPointerListIBM) -#define glEdgeFlagPointerListIBM GLEW_GET_FUN(__glewEdgeFlagPointerListIBM) -#define glFogCoordPointerListIBM GLEW_GET_FUN(__glewFogCoordPointerListIBM) -#define glIndexPointerListIBM GLEW_GET_FUN(__glewIndexPointerListIBM) -#define glNormalPointerListIBM GLEW_GET_FUN(__glewNormalPointerListIBM) -#define glSecondaryColorPointerListIBM GLEW_GET_FUN(__glewSecondaryColorPointerListIBM) -#define glTexCoordPointerListIBM GLEW_GET_FUN(__glewTexCoordPointerListIBM) -#define glVertexPointerListIBM GLEW_GET_FUN(__glewVertexPointerListIBM) - -#define GLEW_IBM_vertex_array_lists GLEW_GET_VAR(__GLEW_IBM_vertex_array_lists) - -#endif /* GL_IBM_vertex_array_lists */ - -/* -------------------------- GL_INGR_color_clamp -------------------------- */ - -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 - -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 - -#define GLEW_INGR_color_clamp GLEW_GET_VAR(__GLEW_INGR_color_clamp) - -#endif /* GL_INGR_color_clamp */ - -/* ------------------------- GL_INGR_interlace_read ------------------------ */ - -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 - -#define GL_INTERLACE_READ_INGR 0x8568 - -#define GLEW_INGR_interlace_read GLEW_GET_VAR(__GLEW_INGR_interlace_read) - -#endif /* GL_INGR_interlace_read */ - -/* ------------------------ GL_INTEL_parallel_arrays ----------------------- */ - -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 - -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 - -typedef void (GLAPIENTRY * PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); -typedef void (GLAPIENTRY * PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void** pointer); -typedef void (GLAPIENTRY * PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); -typedef void (GLAPIENTRY * PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); - -#define glColorPointervINTEL GLEW_GET_FUN(__glewColorPointervINTEL) -#define glNormalPointervINTEL GLEW_GET_FUN(__glewNormalPointervINTEL) -#define glTexCoordPointervINTEL GLEW_GET_FUN(__glewTexCoordPointervINTEL) -#define glVertexPointervINTEL GLEW_GET_FUN(__glewVertexPointervINTEL) - -#define GLEW_INTEL_parallel_arrays GLEW_GET_VAR(__GLEW_INTEL_parallel_arrays) - -#endif /* GL_INTEL_parallel_arrays */ - -/* ------------------------ GL_INTEL_texture_scissor ----------------------- */ - -#ifndef GL_INTEL_texture_scissor -#define GL_INTEL_texture_scissor 1 - -typedef void (GLAPIENTRY * PFNGLTEXSCISSORFUNCINTELPROC) (GLenum target, GLenum lfunc, GLenum hfunc); -typedef void (GLAPIENTRY * PFNGLTEXSCISSORINTELPROC) (GLenum target, GLclampf tlow, GLclampf thigh); - -#define glTexScissorFuncINTEL GLEW_GET_FUN(__glewTexScissorFuncINTEL) -#define glTexScissorINTEL GLEW_GET_FUN(__glewTexScissorINTEL) - -#define GLEW_INTEL_texture_scissor GLEW_GET_VAR(__GLEW_INTEL_texture_scissor) - -#endif /* GL_INTEL_texture_scissor */ - -/* -------------------------- GL_KTX_buffer_region ------------------------- */ - -#ifndef GL_KTX_buffer_region -#define GL_KTX_buffer_region 1 - -#define GL_KTX_FRONT_REGION 0x0 -#define GL_KTX_BACK_REGION 0x1 -#define GL_KTX_Z_REGION 0x2 -#define GL_KTX_STENCIL_REGION 0x3 - -typedef GLuint (GLAPIENTRY * PFNGLBUFFERREGIONENABLEDEXTPROC) (void); -typedef void (GLAPIENTRY * PFNGLDELETEBUFFERREGIONEXTPROC) (GLenum region); -typedef void (GLAPIENTRY * PFNGLDRAWBUFFERREGIONEXTPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height, GLint xDest, GLint yDest); -typedef GLuint (GLAPIENTRY * PFNGLNEWBUFFERREGIONEXTPROC) (GLenum region); -typedef void (GLAPIENTRY * PFNGLREADBUFFERREGIONEXTPROC) (GLuint region, GLint x, GLint y, GLsizei width, GLsizei height); - -#define glBufferRegionEnabledEXT GLEW_GET_FUN(__glewBufferRegionEnabledEXT) -#define glDeleteBufferRegionEXT GLEW_GET_FUN(__glewDeleteBufferRegionEXT) -#define glDrawBufferRegionEXT GLEW_GET_FUN(__glewDrawBufferRegionEXT) -#define glNewBufferRegionEXT GLEW_GET_FUN(__glewNewBufferRegionEXT) -#define glReadBufferRegionEXT GLEW_GET_FUN(__glewReadBufferRegionEXT) - -#define GLEW_KTX_buffer_region GLEW_GET_VAR(__GLEW_KTX_buffer_region) - -#endif /* GL_KTX_buffer_region */ - -/* ------------------------- GL_MESAX_texture_stack ------------------------ */ - -#ifndef GL_MESAX_texture_stack -#define GL_MESAX_texture_stack 1 - -#define GL_TEXTURE_1D_STACK_MESAX 0x8759 -#define GL_TEXTURE_2D_STACK_MESAX 0x875A -#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B -#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C -#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D -#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E - -#define GLEW_MESAX_texture_stack GLEW_GET_VAR(__GLEW_MESAX_texture_stack) - -#endif /* GL_MESAX_texture_stack */ - -/* -------------------------- GL_MESA_pack_invert -------------------------- */ - -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 - -#define GL_PACK_INVERT_MESA 0x8758 - -#define GLEW_MESA_pack_invert GLEW_GET_VAR(__GLEW_MESA_pack_invert) - -#endif /* GL_MESA_pack_invert */ - -/* ------------------------- GL_MESA_resize_buffers ------------------------ */ - -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 - -typedef void (GLAPIENTRY * PFNGLRESIZEBUFFERSMESAPROC) (void); - -#define glResizeBuffersMESA GLEW_GET_FUN(__glewResizeBuffersMESA) - -#define GLEW_MESA_resize_buffers GLEW_GET_VAR(__GLEW_MESA_resize_buffers) - -#endif /* GL_MESA_resize_buffers */ - -/* --------------------------- GL_MESA_window_pos -------------------------- */ - -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 - -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2IVMESAPROC) (const GLint* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS2SVMESAPROC) (const GLshort* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3IVMESAPROC) (const GLint* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS3SVMESAPROC) (const GLshort* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4IVMESAPROC) (const GLint* p); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAPIENTRY * PFNGLWINDOWPOS4SVMESAPROC) (const GLshort* p); - -#define glWindowPos2dMESA GLEW_GET_FUN(__glewWindowPos2dMESA) -#define glWindowPos2dvMESA GLEW_GET_FUN(__glewWindowPos2dvMESA) -#define glWindowPos2fMESA GLEW_GET_FUN(__glewWindowPos2fMESA) -#define glWindowPos2fvMESA GLEW_GET_FUN(__glewWindowPos2fvMESA) -#define glWindowPos2iMESA GLEW_GET_FUN(__glewWindowPos2iMESA) -#define glWindowPos2ivMESA GLEW_GET_FUN(__glewWindowPos2ivMESA) -#define glWindowPos2sMESA GLEW_GET_FUN(__glewWindowPos2sMESA) -#define glWindowPos2svMESA GLEW_GET_FUN(__glewWindowPos2svMESA) -#define glWindowPos3dMESA GLEW_GET_FUN(__glewWindowPos3dMESA) -#define glWindowPos3dvMESA GLEW_GET_FUN(__glewWindowPos3dvMESA) -#define glWindowPos3fMESA GLEW_GET_FUN(__glewWindowPos3fMESA) -#define glWindowPos3fvMESA GLEW_GET_FUN(__glewWindowPos3fvMESA) -#define glWindowPos3iMESA GLEW_GET_FUN(__glewWindowPos3iMESA) -#define glWindowPos3ivMESA GLEW_GET_FUN(__glewWindowPos3ivMESA) -#define glWindowPos3sMESA GLEW_GET_FUN(__glewWindowPos3sMESA) -#define glWindowPos3svMESA GLEW_GET_FUN(__glewWindowPos3svMESA) -#define glWindowPos4dMESA GLEW_GET_FUN(__glewWindowPos4dMESA) -#define glWindowPos4dvMESA GLEW_GET_FUN(__glewWindowPos4dvMESA) -#define glWindowPos4fMESA GLEW_GET_FUN(__glewWindowPos4fMESA) -#define glWindowPos4fvMESA GLEW_GET_FUN(__glewWindowPos4fvMESA) -#define glWindowPos4iMESA GLEW_GET_FUN(__glewWindowPos4iMESA) -#define glWindowPos4ivMESA GLEW_GET_FUN(__glewWindowPos4ivMESA) -#define glWindowPos4sMESA GLEW_GET_FUN(__glewWindowPos4sMESA) -#define glWindowPos4svMESA GLEW_GET_FUN(__glewWindowPos4svMESA) - -#define GLEW_MESA_window_pos GLEW_GET_VAR(__GLEW_MESA_window_pos) - -#endif /* GL_MESA_window_pos */ - -/* ------------------------- GL_MESA_ycbcr_texture ------------------------- */ - -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 - -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 - -#define GLEW_MESA_ycbcr_texture GLEW_GET_VAR(__GLEW_MESA_ycbcr_texture) - -#endif /* GL_MESA_ycbcr_texture */ - -/* --------------------------- GL_NV_blend_square -------------------------- */ - -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 - -#define GLEW_NV_blend_square GLEW_GET_VAR(__GLEW_NV_blend_square) - -#endif /* GL_NV_blend_square */ - -/* ------------------------ GL_NV_conditional_render ----------------------- */ - -#ifndef GL_NV_conditional_render -#define GL_NV_conditional_render 1 - -#define GL_QUERY_WAIT_NV 0x8E13 -#define GL_QUERY_NO_WAIT_NV 0x8E14 -#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 - -typedef void (GLAPIENTRY * PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); -typedef void (GLAPIENTRY * PFNGLENDCONDITIONALRENDERNVPROC) (void); - -#define glBeginConditionalRenderNV GLEW_GET_FUN(__glewBeginConditionalRenderNV) -#define glEndConditionalRenderNV GLEW_GET_FUN(__glewEndConditionalRenderNV) - -#define GLEW_NV_conditional_render GLEW_GET_VAR(__GLEW_NV_conditional_render) - -#endif /* GL_NV_conditional_render */ - -/* ----------------------- GL_NV_copy_depth_to_color ----------------------- */ - -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 - -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F - -#define GLEW_NV_copy_depth_to_color GLEW_GET_VAR(__GLEW_NV_copy_depth_to_color) - -#endif /* GL_NV_copy_depth_to_color */ - -/* ------------------------ GL_NV_depth_buffer_float ----------------------- */ - -#ifndef GL_NV_depth_buffer_float -#define GL_NV_depth_buffer_float 1 - -#define GL_DEPTH_COMPONENT32F_NV 0x8DAB -#define GL_DEPTH32F_STENCIL8_NV 0x8DAC -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD -#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF - -typedef void (GLAPIENTRY * PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); -typedef void (GLAPIENTRY * PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); -typedef void (GLAPIENTRY * PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); - -#define glClearDepthdNV GLEW_GET_FUN(__glewClearDepthdNV) -#define glDepthBoundsdNV GLEW_GET_FUN(__glewDepthBoundsdNV) -#define glDepthRangedNV GLEW_GET_FUN(__glewDepthRangedNV) - -#define GLEW_NV_depth_buffer_float GLEW_GET_VAR(__GLEW_NV_depth_buffer_float) - -#endif /* GL_NV_depth_buffer_float */ - -/* --------------------------- GL_NV_depth_clamp --------------------------- */ - -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 - -#define GL_DEPTH_CLAMP_NV 0x864F - -#define GLEW_NV_depth_clamp GLEW_GET_VAR(__GLEW_NV_depth_clamp) - -#endif /* GL_NV_depth_clamp */ - -/* ---------------------- GL_NV_depth_range_unclamped ---------------------- */ - -#ifndef GL_NV_depth_range_unclamped -#define GL_NV_depth_range_unclamped 1 - -#define GL_SAMPLE_COUNT_BITS_NV 0x8864 -#define GL_CURRENT_SAMPLE_COUNT_QUERY_NV 0x8865 -#define GL_QUERY_RESULT_NV 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_NV 0x8867 -#define GL_SAMPLE_COUNT_NV 0x8914 - -#define GLEW_NV_depth_range_unclamped GLEW_GET_VAR(__GLEW_NV_depth_range_unclamped) - -#endif /* GL_NV_depth_range_unclamped */ - -/* ---------------------------- GL_NV_evaluators --------------------------- */ - -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 - -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 - -typedef void (GLAPIENTRY * PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -typedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void* points); -typedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void* points); -typedef void (GLAPIENTRY * PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint* params); - -#define glEvalMapsNV GLEW_GET_FUN(__glewEvalMapsNV) -#define glGetMapAttribParameterfvNV GLEW_GET_FUN(__glewGetMapAttribParameterfvNV) -#define glGetMapAttribParameterivNV GLEW_GET_FUN(__glewGetMapAttribParameterivNV) -#define glGetMapControlPointsNV GLEW_GET_FUN(__glewGetMapControlPointsNV) -#define glGetMapParameterfvNV GLEW_GET_FUN(__glewGetMapParameterfvNV) -#define glGetMapParameterivNV GLEW_GET_FUN(__glewGetMapParameterivNV) -#define glMapControlPointsNV GLEW_GET_FUN(__glewMapControlPointsNV) -#define glMapParameterfvNV GLEW_GET_FUN(__glewMapParameterfvNV) -#define glMapParameterivNV GLEW_GET_FUN(__glewMapParameterivNV) - -#define GLEW_NV_evaluators GLEW_GET_VAR(__GLEW_NV_evaluators) - -#endif /* GL_NV_evaluators */ - -/* ----------------------- GL_NV_explicit_multisample ---------------------- */ - -#ifndef GL_NV_explicit_multisample -#define GL_NV_explicit_multisample 1 - -#define GL_SAMPLE_POSITION_NV 0x8E50 -#define GL_SAMPLE_MASK_NV 0x8E51 -#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 -#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 -#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 -#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 -#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 -#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 -#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 -#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 - -typedef void (GLAPIENTRY * PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat* val); -typedef void (GLAPIENTRY * PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); -typedef void (GLAPIENTRY * PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); - -#define glGetMultisamplefvNV GLEW_GET_FUN(__glewGetMultisamplefvNV) -#define glSampleMaskIndexedNV GLEW_GET_FUN(__glewSampleMaskIndexedNV) -#define glTexRenderbufferNV GLEW_GET_FUN(__glewTexRenderbufferNV) - -#define GLEW_NV_explicit_multisample GLEW_GET_VAR(__GLEW_NV_explicit_multisample) - -#endif /* GL_NV_explicit_multisample */ - -/* ------------------------------ GL_NV_fence ------------------------------ */ - -#ifndef GL_NV_fence -#define GL_NV_fence 1 - -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 - -typedef void (GLAPIENTRY * PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint* fences); -typedef void (GLAPIENTRY * PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (GLAPIENTRY * PFNGLGENFENCESNVPROC) (GLsizei n, GLuint* fences); -typedef void (GLAPIENTRY * PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISFENCENVPROC) (GLuint fence); -typedef void (GLAPIENTRY * PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -typedef GLboolean (GLAPIENTRY * PFNGLTESTFENCENVPROC) (GLuint fence); - -#define glDeleteFencesNV GLEW_GET_FUN(__glewDeleteFencesNV) -#define glFinishFenceNV GLEW_GET_FUN(__glewFinishFenceNV) -#define glGenFencesNV GLEW_GET_FUN(__glewGenFencesNV) -#define glGetFenceivNV GLEW_GET_FUN(__glewGetFenceivNV) -#define glIsFenceNV GLEW_GET_FUN(__glewIsFenceNV) -#define glSetFenceNV GLEW_GET_FUN(__glewSetFenceNV) -#define glTestFenceNV GLEW_GET_FUN(__glewTestFenceNV) - -#define GLEW_NV_fence GLEW_GET_VAR(__GLEW_NV_fence) - -#endif /* GL_NV_fence */ - -/* --------------------------- GL_NV_float_buffer -------------------------- */ - -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 - -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E - -#define GLEW_NV_float_buffer GLEW_GET_VAR(__GLEW_NV_float_buffer) - -#endif /* GL_NV_float_buffer */ - -/* --------------------------- GL_NV_fog_distance -------------------------- */ - -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 - -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C - -#define GLEW_NV_fog_distance GLEW_GET_VAR(__GLEW_NV_fog_distance) - -#endif /* GL_NV_fog_distance */ - -/* ------------------------- GL_NV_fragment_program ------------------------ */ - -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 - -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 - -typedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble *params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLdouble v[]); -typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte* name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte* name, const GLfloat v[]); - -#define glGetProgramNamedParameterdvNV GLEW_GET_FUN(__glewGetProgramNamedParameterdvNV) -#define glGetProgramNamedParameterfvNV GLEW_GET_FUN(__glewGetProgramNamedParameterfvNV) -#define glProgramNamedParameter4dNV GLEW_GET_FUN(__glewProgramNamedParameter4dNV) -#define glProgramNamedParameter4dvNV GLEW_GET_FUN(__glewProgramNamedParameter4dvNV) -#define glProgramNamedParameter4fNV GLEW_GET_FUN(__glewProgramNamedParameter4fNV) -#define glProgramNamedParameter4fvNV GLEW_GET_FUN(__glewProgramNamedParameter4fvNV) - -#define GLEW_NV_fragment_program GLEW_GET_VAR(__GLEW_NV_fragment_program) - -#endif /* GL_NV_fragment_program */ - -/* ------------------------ GL_NV_fragment_program2 ------------------------ */ - -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 - -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 - -#define GLEW_NV_fragment_program2 GLEW_GET_VAR(__GLEW_NV_fragment_program2) - -#endif /* GL_NV_fragment_program2 */ - -/* ------------------------ GL_NV_fragment_program4 ------------------------ */ - -#ifndef GL_NV_fragment_program4 -#define GL_NV_fragment_program4 1 - -#define GLEW_NV_fragment_program4 GLEW_GET_VAR(__GLEW_NV_fragment_program4) - -#endif /* GL_NV_fragment_program4 */ - -/* --------------------- GL_NV_fragment_program_option --------------------- */ - -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 - -#define GLEW_NV_fragment_program_option GLEW_GET_VAR(__GLEW_NV_fragment_program_option) - -#endif /* GL_NV_fragment_program_option */ - -/* ----------------- GL_NV_framebuffer_multisample_coverage ---------------- */ - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_NV_framebuffer_multisample_coverage 1 - -#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB -#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 -#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 -#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 - -typedef void (GLAPIENTRY * PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); - -#define glRenderbufferStorageMultisampleCoverageNV GLEW_GET_FUN(__glewRenderbufferStorageMultisampleCoverageNV) - -#define GLEW_NV_framebuffer_multisample_coverage GLEW_GET_VAR(__GLEW_NV_framebuffer_multisample_coverage) - -#endif /* GL_NV_framebuffer_multisample_coverage */ - -/* ------------------------ GL_NV_geometry_program4 ------------------------ */ - -#ifndef GL_NV_geometry_program4 -#define GL_NV_geometry_program4 1 - -#define GL_GEOMETRY_PROGRAM_NV 0x8C26 -#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 -#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 - -typedef void (GLAPIENTRY * PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); - -#define glProgramVertexLimitNV GLEW_GET_FUN(__glewProgramVertexLimitNV) - -#define GLEW_NV_geometry_program4 GLEW_GET_VAR(__GLEW_NV_geometry_program4) - -#endif /* GL_NV_geometry_program4 */ - -/* ------------------------- GL_NV_geometry_shader4 ------------------------ */ - -#ifndef GL_NV_geometry_shader4 -#define GL_NV_geometry_shader4 1 - -#define GLEW_NV_geometry_shader4 GLEW_GET_VAR(__GLEW_NV_geometry_shader4) - -#endif /* GL_NV_geometry_shader4 */ - -/* --------------------------- GL_NV_gpu_program4 -------------------------- */ - -#ifndef GL_NV_gpu_program4 -#define GL_NV_gpu_program4 1 - -#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 -#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 -#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 -#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 -#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 -#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 -#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 - -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); - -#define glProgramEnvParameterI4iNV GLEW_GET_FUN(__glewProgramEnvParameterI4iNV) -#define glProgramEnvParameterI4ivNV GLEW_GET_FUN(__glewProgramEnvParameterI4ivNV) -#define glProgramEnvParameterI4uiNV GLEW_GET_FUN(__glewProgramEnvParameterI4uiNV) -#define glProgramEnvParameterI4uivNV GLEW_GET_FUN(__glewProgramEnvParameterI4uivNV) -#define glProgramEnvParametersI4ivNV GLEW_GET_FUN(__glewProgramEnvParametersI4ivNV) -#define glProgramEnvParametersI4uivNV GLEW_GET_FUN(__glewProgramEnvParametersI4uivNV) -#define glProgramLocalParameterI4iNV GLEW_GET_FUN(__glewProgramLocalParameterI4iNV) -#define glProgramLocalParameterI4ivNV GLEW_GET_FUN(__glewProgramLocalParameterI4ivNV) -#define glProgramLocalParameterI4uiNV GLEW_GET_FUN(__glewProgramLocalParameterI4uiNV) -#define glProgramLocalParameterI4uivNV GLEW_GET_FUN(__glewProgramLocalParameterI4uivNV) -#define glProgramLocalParametersI4ivNV GLEW_GET_FUN(__glewProgramLocalParametersI4ivNV) -#define glProgramLocalParametersI4uivNV GLEW_GET_FUN(__glewProgramLocalParametersI4uivNV) - -#define GLEW_NV_gpu_program4 GLEW_GET_VAR(__GLEW_NV_gpu_program4) - -#endif /* GL_NV_gpu_program4 */ - -/* ---------------------------- GL_NV_half_float --------------------------- */ - -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 - -#define GL_HALF_FLOAT_NV 0x140B - -typedef unsigned short GLhalf; - -typedef void (GLAPIENTRY * PFNGLCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue); -typedef void (GLAPIENTRY * PFNGLCOLOR3HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLCOLOR4HNVPROC) (GLhalf red, GLhalf green, GLhalf blue, GLhalf alpha); -typedef void (GLAPIENTRY * PFNGLCOLOR4HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLFOGCOORDHNVPROC) (GLhalf fog); -typedef void (GLAPIENTRY * PFNGLFOGCOORDHVNVPROC) (const GLhalf* fog); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalf s); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalf s, GLhalf t); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalf s, GLhalf t, GLhalf r, GLhalf q); -typedef void (GLAPIENTRY * PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLNORMAL3HNVPROC) (GLhalf nx, GLhalf ny, GLhalf nz); -typedef void (GLAPIENTRY * PFNGLNORMAL3HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HNVPROC) (GLhalf red, GLhalf green, GLhalf blue); -typedef void (GLAPIENTRY * PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD1HNVPROC) (GLhalf s); -typedef void (GLAPIENTRY * PFNGLTEXCOORD1HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2HNVPROC) (GLhalf s, GLhalf t); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD3HNVPROC) (GLhalf s, GLhalf t, GLhalf r); -typedef void (GLAPIENTRY * PFNGLTEXCOORD3HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD4HNVPROC) (GLhalf s, GLhalf t, GLhalf r, GLhalf q); -typedef void (GLAPIENTRY * PFNGLTEXCOORD4HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEX2HNVPROC) (GLhalf x, GLhalf y); -typedef void (GLAPIENTRY * PFNGLVERTEX2HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEX3HNVPROC) (GLhalf x, GLhalf y, GLhalf z); -typedef void (GLAPIENTRY * PFNGLVERTEX3HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEX4HNVPROC) (GLhalf x, GLhalf y, GLhalf z, GLhalf w); -typedef void (GLAPIENTRY * PFNGLVERTEX4HVNVPROC) (const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalf x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalf x, GLhalf y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalf x, GLhalf y, GLhalf z, GLhalf w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalf* v); -typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHNVPROC) (GLhalf weight); -typedef void (GLAPIENTRY * PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalf* weight); - -#define glColor3hNV GLEW_GET_FUN(__glewColor3hNV) -#define glColor3hvNV GLEW_GET_FUN(__glewColor3hvNV) -#define glColor4hNV GLEW_GET_FUN(__glewColor4hNV) -#define glColor4hvNV GLEW_GET_FUN(__glewColor4hvNV) -#define glFogCoordhNV GLEW_GET_FUN(__glewFogCoordhNV) -#define glFogCoordhvNV GLEW_GET_FUN(__glewFogCoordhvNV) -#define glMultiTexCoord1hNV GLEW_GET_FUN(__glewMultiTexCoord1hNV) -#define glMultiTexCoord1hvNV GLEW_GET_FUN(__glewMultiTexCoord1hvNV) -#define glMultiTexCoord2hNV GLEW_GET_FUN(__glewMultiTexCoord2hNV) -#define glMultiTexCoord2hvNV GLEW_GET_FUN(__glewMultiTexCoord2hvNV) -#define glMultiTexCoord3hNV GLEW_GET_FUN(__glewMultiTexCoord3hNV) -#define glMultiTexCoord3hvNV GLEW_GET_FUN(__glewMultiTexCoord3hvNV) -#define glMultiTexCoord4hNV GLEW_GET_FUN(__glewMultiTexCoord4hNV) -#define glMultiTexCoord4hvNV GLEW_GET_FUN(__glewMultiTexCoord4hvNV) -#define glNormal3hNV GLEW_GET_FUN(__glewNormal3hNV) -#define glNormal3hvNV GLEW_GET_FUN(__glewNormal3hvNV) -#define glSecondaryColor3hNV GLEW_GET_FUN(__glewSecondaryColor3hNV) -#define glSecondaryColor3hvNV GLEW_GET_FUN(__glewSecondaryColor3hvNV) -#define glTexCoord1hNV GLEW_GET_FUN(__glewTexCoord1hNV) -#define glTexCoord1hvNV GLEW_GET_FUN(__glewTexCoord1hvNV) -#define glTexCoord2hNV GLEW_GET_FUN(__glewTexCoord2hNV) -#define glTexCoord2hvNV GLEW_GET_FUN(__glewTexCoord2hvNV) -#define glTexCoord3hNV GLEW_GET_FUN(__glewTexCoord3hNV) -#define glTexCoord3hvNV GLEW_GET_FUN(__glewTexCoord3hvNV) -#define glTexCoord4hNV GLEW_GET_FUN(__glewTexCoord4hNV) -#define glTexCoord4hvNV GLEW_GET_FUN(__glewTexCoord4hvNV) -#define glVertex2hNV GLEW_GET_FUN(__glewVertex2hNV) -#define glVertex2hvNV GLEW_GET_FUN(__glewVertex2hvNV) -#define glVertex3hNV GLEW_GET_FUN(__glewVertex3hNV) -#define glVertex3hvNV GLEW_GET_FUN(__glewVertex3hvNV) -#define glVertex4hNV GLEW_GET_FUN(__glewVertex4hNV) -#define glVertex4hvNV GLEW_GET_FUN(__glewVertex4hvNV) -#define glVertexAttrib1hNV GLEW_GET_FUN(__glewVertexAttrib1hNV) -#define glVertexAttrib1hvNV GLEW_GET_FUN(__glewVertexAttrib1hvNV) -#define glVertexAttrib2hNV GLEW_GET_FUN(__glewVertexAttrib2hNV) -#define glVertexAttrib2hvNV GLEW_GET_FUN(__glewVertexAttrib2hvNV) -#define glVertexAttrib3hNV GLEW_GET_FUN(__glewVertexAttrib3hNV) -#define glVertexAttrib3hvNV GLEW_GET_FUN(__glewVertexAttrib3hvNV) -#define glVertexAttrib4hNV GLEW_GET_FUN(__glewVertexAttrib4hNV) -#define glVertexAttrib4hvNV GLEW_GET_FUN(__glewVertexAttrib4hvNV) -#define glVertexAttribs1hvNV GLEW_GET_FUN(__glewVertexAttribs1hvNV) -#define glVertexAttribs2hvNV GLEW_GET_FUN(__glewVertexAttribs2hvNV) -#define glVertexAttribs3hvNV GLEW_GET_FUN(__glewVertexAttribs3hvNV) -#define glVertexAttribs4hvNV GLEW_GET_FUN(__glewVertexAttribs4hvNV) -#define glVertexWeighthNV GLEW_GET_FUN(__glewVertexWeighthNV) -#define glVertexWeighthvNV GLEW_GET_FUN(__glewVertexWeighthvNV) - -#define GLEW_NV_half_float GLEW_GET_VAR(__GLEW_NV_half_float) - -#endif /* GL_NV_half_float */ - -/* ------------------------ GL_NV_light_max_exponent ----------------------- */ - -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 - -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 - -#define GLEW_NV_light_max_exponent GLEW_GET_VAR(__GLEW_NV_light_max_exponent) - -#endif /* GL_NV_light_max_exponent */ - -/* --------------------- GL_NV_multisample_filter_hint --------------------- */ - -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 - -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 - -#define GLEW_NV_multisample_filter_hint GLEW_GET_VAR(__GLEW_NV_multisample_filter_hint) - -#endif /* GL_NV_multisample_filter_hint */ - -/* ------------------------- GL_NV_occlusion_query ------------------------- */ - -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 - -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 - -typedef void (GLAPIENTRY * PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint* ids); -typedef void (GLAPIENTRY * PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (GLAPIENTRY * PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); - -#define glBeginOcclusionQueryNV GLEW_GET_FUN(__glewBeginOcclusionQueryNV) -#define glDeleteOcclusionQueriesNV GLEW_GET_FUN(__glewDeleteOcclusionQueriesNV) -#define glEndOcclusionQueryNV GLEW_GET_FUN(__glewEndOcclusionQueryNV) -#define glGenOcclusionQueriesNV GLEW_GET_FUN(__glewGenOcclusionQueriesNV) -#define glGetOcclusionQueryivNV GLEW_GET_FUN(__glewGetOcclusionQueryivNV) -#define glGetOcclusionQueryuivNV GLEW_GET_FUN(__glewGetOcclusionQueryuivNV) -#define glIsOcclusionQueryNV GLEW_GET_FUN(__glewIsOcclusionQueryNV) - -#define GLEW_NV_occlusion_query GLEW_GET_VAR(__GLEW_NV_occlusion_query) - -#endif /* GL_NV_occlusion_query */ - -/* ----------------------- GL_NV_packed_depth_stencil ---------------------- */ - -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 - -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA - -#define GLEW_NV_packed_depth_stencil GLEW_GET_VAR(__GLEW_NV_packed_depth_stencil) - -#endif /* GL_NV_packed_depth_stencil */ - -/* --------------------- GL_NV_parameter_buffer_object --------------------- */ - -#ifndef GL_NV_parameter_buffer_object -#define GL_NV_parameter_buffer_object 1 - -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 -#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 -#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 -#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 - -typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); -typedef void (GLAPIENTRY * PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); - -#define glProgramBufferParametersIivNV GLEW_GET_FUN(__glewProgramBufferParametersIivNV) -#define glProgramBufferParametersIuivNV GLEW_GET_FUN(__glewProgramBufferParametersIuivNV) -#define glProgramBufferParametersfvNV GLEW_GET_FUN(__glewProgramBufferParametersfvNV) - -#define GLEW_NV_parameter_buffer_object GLEW_GET_VAR(__GLEW_NV_parameter_buffer_object) - -#endif /* GL_NV_parameter_buffer_object */ - -/* ------------------------- GL_NV_pixel_data_range ------------------------ */ - -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 - -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D - -typedef void (GLAPIENTRY * PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); -typedef void (GLAPIENTRY * PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, void* pointer); - -#define glFlushPixelDataRangeNV GLEW_GET_FUN(__glewFlushPixelDataRangeNV) -#define glPixelDataRangeNV GLEW_GET_FUN(__glewPixelDataRangeNV) - -#define GLEW_NV_pixel_data_range GLEW_GET_VAR(__GLEW_NV_pixel_data_range) - -#endif /* GL_NV_pixel_data_range */ - -/* --------------------------- GL_NV_point_sprite -------------------------- */ - -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 - -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 - -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint* params); - -#define glPointParameteriNV GLEW_GET_FUN(__glewPointParameteriNV) -#define glPointParameterivNV GLEW_GET_FUN(__glewPointParameterivNV) - -#define GLEW_NV_point_sprite GLEW_GET_VAR(__GLEW_NV_point_sprite) - -#endif /* GL_NV_point_sprite */ - -/* -------------------------- GL_NV_present_video -------------------------- */ - -#ifndef GL_NV_present_video -#define GL_NV_present_video 1 - -#define GL_FRAME_NV 0x8E26 -#define GL_FIELDS_NV 0x8E27 -#define GL_CURRENT_TIME_NV 0x8E28 -#define GL_NUM_FILL_STREAMS_NV 0x8E29 -#define GL_PRESENT_TIME_NV 0x8E2A -#define GL_PRESENT_DURATION_NV 0x8E2B - -typedef void (GLAPIENTRY * PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT* params); -typedef void (GLAPIENTRY * PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT* params); -typedef void (GLAPIENTRY * PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint* params); -typedef void (GLAPIENTRY * PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -typedef void (GLAPIENTRY * PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); -typedef void (GLAPIENTRY * PFNGLVIDEOPARAMETERIVNVPROC) (GLuint video_slot, GLenum pname, const GLint* params); - -#define glGetVideoi64vNV GLEW_GET_FUN(__glewGetVideoi64vNV) -#define glGetVideoivNV GLEW_GET_FUN(__glewGetVideoivNV) -#define glGetVideoui64vNV GLEW_GET_FUN(__glewGetVideoui64vNV) -#define glGetVideouivNV GLEW_GET_FUN(__glewGetVideouivNV) -#define glPresentFrameDualFillNV GLEW_GET_FUN(__glewPresentFrameDualFillNV) -#define glPresentFrameKeyedNV GLEW_GET_FUN(__glewPresentFrameKeyedNV) -#define glVideoParameterivNV GLEW_GET_FUN(__glewVideoParameterivNV) - -#define GLEW_NV_present_video GLEW_GET_VAR(__GLEW_NV_present_video) - -#endif /* GL_NV_present_video */ - -/* ------------------------ GL_NV_primitive_restart ------------------------ */ - -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 - -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 - -typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); -typedef void (GLAPIENTRY * PFNGLPRIMITIVERESTARTNVPROC) (void); - -#define glPrimitiveRestartIndexNV GLEW_GET_FUN(__glewPrimitiveRestartIndexNV) -#define glPrimitiveRestartNV GLEW_GET_FUN(__glewPrimitiveRestartNV) - -#define GLEW_NV_primitive_restart GLEW_GET_VAR(__GLEW_NV_primitive_restart) - -#endif /* GL_NV_primitive_restart */ - -/* ------------------------ GL_NV_register_combiners ----------------------- */ - -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 - -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 - -typedef void (GLAPIENTRY * PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (GLAPIENTRY * PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint* params); - -#define glCombinerInputNV GLEW_GET_FUN(__glewCombinerInputNV) -#define glCombinerOutputNV GLEW_GET_FUN(__glewCombinerOutputNV) -#define glCombinerParameterfNV GLEW_GET_FUN(__glewCombinerParameterfNV) -#define glCombinerParameterfvNV GLEW_GET_FUN(__glewCombinerParameterfvNV) -#define glCombinerParameteriNV GLEW_GET_FUN(__glewCombinerParameteriNV) -#define glCombinerParameterivNV GLEW_GET_FUN(__glewCombinerParameterivNV) -#define glFinalCombinerInputNV GLEW_GET_FUN(__glewFinalCombinerInputNV) -#define glGetCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetCombinerInputParameterfvNV) -#define glGetCombinerInputParameterivNV GLEW_GET_FUN(__glewGetCombinerInputParameterivNV) -#define glGetCombinerOutputParameterfvNV GLEW_GET_FUN(__glewGetCombinerOutputParameterfvNV) -#define glGetCombinerOutputParameterivNV GLEW_GET_FUN(__glewGetCombinerOutputParameterivNV) -#define glGetFinalCombinerInputParameterfvNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterfvNV) -#define glGetFinalCombinerInputParameterivNV GLEW_GET_FUN(__glewGetFinalCombinerInputParameterivNV) - -#define GLEW_NV_register_combiners GLEW_GET_VAR(__GLEW_NV_register_combiners) - -#endif /* GL_NV_register_combiners */ - -/* ----------------------- GL_NV_register_combiners2 ----------------------- */ - -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 - -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 - -typedef void (GLAPIENTRY * PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat* params); - -#define glCombinerStageParameterfvNV GLEW_GET_FUN(__glewCombinerStageParameterfvNV) -#define glGetCombinerStageParameterfvNV GLEW_GET_FUN(__glewGetCombinerStageParameterfvNV) - -#define GLEW_NV_register_combiners2 GLEW_GET_VAR(__GLEW_NV_register_combiners2) - -#endif /* GL_NV_register_combiners2 */ - -/* -------------------------- GL_NV_texgen_emboss -------------------------- */ - -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 - -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F - -#define GLEW_NV_texgen_emboss GLEW_GET_VAR(__GLEW_NV_texgen_emboss) - -#endif /* GL_NV_texgen_emboss */ - -/* ------------------------ GL_NV_texgen_reflection ------------------------ */ - -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 - -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 - -#define GLEW_NV_texgen_reflection GLEW_GET_VAR(__GLEW_NV_texgen_reflection) - -#endif /* GL_NV_texgen_reflection */ - -/* --------------------- GL_NV_texture_compression_vtc --------------------- */ - -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 - -#define GLEW_NV_texture_compression_vtc GLEW_GET_VAR(__GLEW_NV_texture_compression_vtc) - -#endif /* GL_NV_texture_compression_vtc */ - -/* ----------------------- GL_NV_texture_env_combine4 ---------------------- */ - -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 - -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B - -#define GLEW_NV_texture_env_combine4 GLEW_GET_VAR(__GLEW_NV_texture_env_combine4) - -#endif /* GL_NV_texture_env_combine4 */ - -/* ---------------------- GL_NV_texture_expand_normal ---------------------- */ - -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 - -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F - -#define GLEW_NV_texture_expand_normal GLEW_GET_VAR(__GLEW_NV_texture_expand_normal) - -#endif /* GL_NV_texture_expand_normal */ - -/* ------------------------ GL_NV_texture_rectangle ------------------------ */ - -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 - -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 - -#define GLEW_NV_texture_rectangle GLEW_GET_VAR(__GLEW_NV_texture_rectangle) - -#endif /* GL_NV_texture_rectangle */ - -/* -------------------------- GL_NV_texture_shader ------------------------- */ - -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 - -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F - -#define GLEW_NV_texture_shader GLEW_GET_VAR(__GLEW_NV_texture_shader) - -#endif /* GL_NV_texture_shader */ - -/* ------------------------- GL_NV_texture_shader2 ------------------------- */ - -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 - -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D - -#define GLEW_NV_texture_shader2 GLEW_GET_VAR(__GLEW_NV_texture_shader2) - -#endif /* GL_NV_texture_shader2 */ - -/* ------------------------- GL_NV_texture_shader3 ------------------------- */ - -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 - -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 - -#define GLEW_NV_texture_shader3 GLEW_GET_VAR(__GLEW_NV_texture_shader3) - -#endif /* GL_NV_texture_shader3 */ - -/* ------------------------ GL_NV_transform_feedback ----------------------- */ - -#ifndef GL_NV_transform_feedback -#define GL_NV_transform_feedback 1 - -#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 -#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 -#define GL_TEXTURE_COORD_NV 0x8C79 -#define GL_CLIP_DISTANCE_NV 0x8C7A -#define GL_VERTEX_ID_NV 0x8C7B -#define GL_PRIMITIVE_ID_NV 0x8C7C -#define GL_GENERIC_ATTRIB_NV 0x8C7D -#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 -#define GL_ACTIVE_VARYINGS_NV 0x8C81 -#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 -#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 -#define GL_PRIMITIVES_GENERATED_NV 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 -#define GL_RASTERIZER_DISCARD_NV 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B -#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C -#define GL_SEPARATE_ATTRIBS_NV 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F - -typedef void (GLAPIENTRY * PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); -typedef void (GLAPIENTRY * PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (GLAPIENTRY * PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (GLAPIENTRY * PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (GLAPIENTRY * PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); -typedef void (GLAPIENTRY * PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (GLAPIENTRY * PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); -typedef GLint (GLAPIENTRY * PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); -typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); -typedef void (GLAPIENTRY * PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); - -#define glActiveVaryingNV GLEW_GET_FUN(__glewActiveVaryingNV) -#define glBeginTransformFeedbackNV GLEW_GET_FUN(__glewBeginTransformFeedbackNV) -#define glBindBufferBaseNV GLEW_GET_FUN(__glewBindBufferBaseNV) -#define glBindBufferOffsetNV GLEW_GET_FUN(__glewBindBufferOffsetNV) -#define glBindBufferRangeNV GLEW_GET_FUN(__glewBindBufferRangeNV) -#define glEndTransformFeedbackNV GLEW_GET_FUN(__glewEndTransformFeedbackNV) -#define glGetActiveVaryingNV GLEW_GET_FUN(__glewGetActiveVaryingNV) -#define glGetTransformFeedbackVaryingNV GLEW_GET_FUN(__glewGetTransformFeedbackVaryingNV) -#define glGetVaryingLocationNV GLEW_GET_FUN(__glewGetVaryingLocationNV) -#define glTransformFeedbackAttribsNV GLEW_GET_FUN(__glewTransformFeedbackAttribsNV) -#define glTransformFeedbackVaryingsNV GLEW_GET_FUN(__glewTransformFeedbackVaryingsNV) - -#define GLEW_NV_transform_feedback GLEW_GET_VAR(__GLEW_NV_transform_feedback) - -#endif /* GL_NV_transform_feedback */ - -/* ------------------------ GL_NV_vertex_array_range ----------------------- */ - -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 - -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 - -typedef void (GLAPIENTRY * PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (GLAPIENTRY * PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, void* pointer); - -#define glFlushVertexArrayRangeNV GLEW_GET_FUN(__glewFlushVertexArrayRangeNV) -#define glVertexArrayRangeNV GLEW_GET_FUN(__glewVertexArrayRangeNV) - -#define GLEW_NV_vertex_array_range GLEW_GET_VAR(__GLEW_NV_vertex_array_range) - -#endif /* GL_NV_vertex_array_range */ - -/* ----------------------- GL_NV_vertex_array_range2 ----------------------- */ - -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 - -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 - -#define GLEW_NV_vertex_array_range2 GLEW_GET_VAR(__GLEW_NV_vertex_array_range2) - -#endif /* GL_NV_vertex_array_range2 */ - -/* -------------------------- GL_NV_vertex_program ------------------------- */ - -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 - -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F - -typedef GLboolean (GLAPIENTRY * PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint* ids, GLboolean *residences); -typedef void (GLAPIENTRY * PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (GLAPIENTRY * PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint* ids); -typedef void (GLAPIENTRY * PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte* program); -typedef void (GLAPIENTRY * PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid** pointer); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint* params); -typedef GLboolean (GLAPIENTRY * PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (GLAPIENTRY * PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte* program); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint num, const GLdouble* params); -typedef void (GLAPIENTRY * PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint num, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, GLuint* ids); -typedef void (GLAPIENTRY * PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void* pointer); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei n, const GLdouble* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei n, const GLfloat* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei n, const GLshort* v); -typedef void (GLAPIENTRY * PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei n, const GLubyte* v); - -#define glAreProgramsResidentNV GLEW_GET_FUN(__glewAreProgramsResidentNV) -#define glBindProgramNV GLEW_GET_FUN(__glewBindProgramNV) -#define glDeleteProgramsNV GLEW_GET_FUN(__glewDeleteProgramsNV) -#define glExecuteProgramNV GLEW_GET_FUN(__glewExecuteProgramNV) -#define glGenProgramsNV GLEW_GET_FUN(__glewGenProgramsNV) -#define glGetProgramParameterdvNV GLEW_GET_FUN(__glewGetProgramParameterdvNV) -#define glGetProgramParameterfvNV GLEW_GET_FUN(__glewGetProgramParameterfvNV) -#define glGetProgramStringNV GLEW_GET_FUN(__glewGetProgramStringNV) -#define glGetProgramivNV GLEW_GET_FUN(__glewGetProgramivNV) -#define glGetTrackMatrixivNV GLEW_GET_FUN(__glewGetTrackMatrixivNV) -#define glGetVertexAttribPointervNV GLEW_GET_FUN(__glewGetVertexAttribPointervNV) -#define glGetVertexAttribdvNV GLEW_GET_FUN(__glewGetVertexAttribdvNV) -#define glGetVertexAttribfvNV GLEW_GET_FUN(__glewGetVertexAttribfvNV) -#define glGetVertexAttribivNV GLEW_GET_FUN(__glewGetVertexAttribivNV) -#define glIsProgramNV GLEW_GET_FUN(__glewIsProgramNV) -#define glLoadProgramNV GLEW_GET_FUN(__glewLoadProgramNV) -#define glProgramParameter4dNV GLEW_GET_FUN(__glewProgramParameter4dNV) -#define glProgramParameter4dvNV GLEW_GET_FUN(__glewProgramParameter4dvNV) -#define glProgramParameter4fNV GLEW_GET_FUN(__glewProgramParameter4fNV) -#define glProgramParameter4fvNV GLEW_GET_FUN(__glewProgramParameter4fvNV) -#define glProgramParameters4dvNV GLEW_GET_FUN(__glewProgramParameters4dvNV) -#define glProgramParameters4fvNV GLEW_GET_FUN(__glewProgramParameters4fvNV) -#define glRequestResidentProgramsNV GLEW_GET_FUN(__glewRequestResidentProgramsNV) -#define glTrackMatrixNV GLEW_GET_FUN(__glewTrackMatrixNV) -#define glVertexAttrib1dNV GLEW_GET_FUN(__glewVertexAttrib1dNV) -#define glVertexAttrib1dvNV GLEW_GET_FUN(__glewVertexAttrib1dvNV) -#define glVertexAttrib1fNV GLEW_GET_FUN(__glewVertexAttrib1fNV) -#define glVertexAttrib1fvNV GLEW_GET_FUN(__glewVertexAttrib1fvNV) -#define glVertexAttrib1sNV GLEW_GET_FUN(__glewVertexAttrib1sNV) -#define glVertexAttrib1svNV GLEW_GET_FUN(__glewVertexAttrib1svNV) -#define glVertexAttrib2dNV GLEW_GET_FUN(__glewVertexAttrib2dNV) -#define glVertexAttrib2dvNV GLEW_GET_FUN(__glewVertexAttrib2dvNV) -#define glVertexAttrib2fNV GLEW_GET_FUN(__glewVertexAttrib2fNV) -#define glVertexAttrib2fvNV GLEW_GET_FUN(__glewVertexAttrib2fvNV) -#define glVertexAttrib2sNV GLEW_GET_FUN(__glewVertexAttrib2sNV) -#define glVertexAttrib2svNV GLEW_GET_FUN(__glewVertexAttrib2svNV) -#define glVertexAttrib3dNV GLEW_GET_FUN(__glewVertexAttrib3dNV) -#define glVertexAttrib3dvNV GLEW_GET_FUN(__glewVertexAttrib3dvNV) -#define glVertexAttrib3fNV GLEW_GET_FUN(__glewVertexAttrib3fNV) -#define glVertexAttrib3fvNV GLEW_GET_FUN(__glewVertexAttrib3fvNV) -#define glVertexAttrib3sNV GLEW_GET_FUN(__glewVertexAttrib3sNV) -#define glVertexAttrib3svNV GLEW_GET_FUN(__glewVertexAttrib3svNV) -#define glVertexAttrib4dNV GLEW_GET_FUN(__glewVertexAttrib4dNV) -#define glVertexAttrib4dvNV GLEW_GET_FUN(__glewVertexAttrib4dvNV) -#define glVertexAttrib4fNV GLEW_GET_FUN(__glewVertexAttrib4fNV) -#define glVertexAttrib4fvNV GLEW_GET_FUN(__glewVertexAttrib4fvNV) -#define glVertexAttrib4sNV GLEW_GET_FUN(__glewVertexAttrib4sNV) -#define glVertexAttrib4svNV GLEW_GET_FUN(__glewVertexAttrib4svNV) -#define glVertexAttrib4ubNV GLEW_GET_FUN(__glewVertexAttrib4ubNV) -#define glVertexAttrib4ubvNV GLEW_GET_FUN(__glewVertexAttrib4ubvNV) -#define glVertexAttribPointerNV GLEW_GET_FUN(__glewVertexAttribPointerNV) -#define glVertexAttribs1dvNV GLEW_GET_FUN(__glewVertexAttribs1dvNV) -#define glVertexAttribs1fvNV GLEW_GET_FUN(__glewVertexAttribs1fvNV) -#define glVertexAttribs1svNV GLEW_GET_FUN(__glewVertexAttribs1svNV) -#define glVertexAttribs2dvNV GLEW_GET_FUN(__glewVertexAttribs2dvNV) -#define glVertexAttribs2fvNV GLEW_GET_FUN(__glewVertexAttribs2fvNV) -#define glVertexAttribs2svNV GLEW_GET_FUN(__glewVertexAttribs2svNV) -#define glVertexAttribs3dvNV GLEW_GET_FUN(__glewVertexAttribs3dvNV) -#define glVertexAttribs3fvNV GLEW_GET_FUN(__glewVertexAttribs3fvNV) -#define glVertexAttribs3svNV GLEW_GET_FUN(__glewVertexAttribs3svNV) -#define glVertexAttribs4dvNV GLEW_GET_FUN(__glewVertexAttribs4dvNV) -#define glVertexAttribs4fvNV GLEW_GET_FUN(__glewVertexAttribs4fvNV) -#define glVertexAttribs4svNV GLEW_GET_FUN(__glewVertexAttribs4svNV) -#define glVertexAttribs4ubvNV GLEW_GET_FUN(__glewVertexAttribs4ubvNV) - -#define GLEW_NV_vertex_program GLEW_GET_VAR(__GLEW_NV_vertex_program) - -#endif /* GL_NV_vertex_program */ - -/* ------------------------ GL_NV_vertex_program1_1 ------------------------ */ - -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 - -#define GLEW_NV_vertex_program1_1 GLEW_GET_VAR(__GLEW_NV_vertex_program1_1) - -#endif /* GL_NV_vertex_program1_1 */ - -/* ------------------------- GL_NV_vertex_program2 ------------------------- */ - -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 - -#define GLEW_NV_vertex_program2 GLEW_GET_VAR(__GLEW_NV_vertex_program2) - -#endif /* GL_NV_vertex_program2 */ - -/* ---------------------- GL_NV_vertex_program2_option --------------------- */ - -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 - -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 - -#define GLEW_NV_vertex_program2_option GLEW_GET_VAR(__GLEW_NV_vertex_program2_option) - -#endif /* GL_NV_vertex_program2_option */ - -/* ------------------------- GL_NV_vertex_program3 ------------------------- */ - -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 - -#define MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C - -#define GLEW_NV_vertex_program3 GLEW_GET_VAR(__GLEW_NV_vertex_program3) - -#endif /* GL_NV_vertex_program3 */ - -/* ------------------------- GL_NV_vertex_program4 ------------------------- */ - -#ifndef GL_NV_vertex_program4 -#define GL_NV_vertex_program4 1 - -#define GLEW_NV_vertex_program4 GLEW_GET_VAR(__GLEW_NV_vertex_program4) - -#endif /* GL_NV_vertex_program4 */ - -/* ------------------------ GL_OES_byte_coordinates ------------------------ */ - -#ifndef GL_OES_byte_coordinates -#define GL_OES_byte_coordinates 1 - -#define GL_BYTE 0x1400 - -#define GLEW_OES_byte_coordinates GLEW_GET_VAR(__GLEW_OES_byte_coordinates) - -#endif /* GL_OES_byte_coordinates */ - -/* ------------------- GL_OES_compressed_paletted_texture ------------------ */ - -#ifndef GL_OES_compressed_paletted_texture -#define GL_OES_compressed_paletted_texture 1 - -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 - -#define GLEW_OES_compressed_paletted_texture GLEW_GET_VAR(__GLEW_OES_compressed_paletted_texture) - -#endif /* GL_OES_compressed_paletted_texture */ - -/* --------------------------- GL_OES_read_format -------------------------- */ - -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 - -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B - -#define GLEW_OES_read_format GLEW_GET_VAR(__GLEW_OES_read_format) - -#endif /* GL_OES_read_format */ - -/* ------------------------ GL_OES_single_precision ------------------------ */ - -#ifndef GL_OES_single_precision -#define GL_OES_single_precision 1 - -typedef void (GLAPIENTRY * PFNGLCLEARDEPTHFOESPROC) (GLclampd depth); -typedef void (GLAPIENTRY * PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat* equation); -typedef void (GLAPIENTRY * PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); -typedef void (GLAPIENTRY * PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -typedef void (GLAPIENTRY * PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat* equation); -typedef void (GLAPIENTRY * PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); - -#define glClearDepthfOES GLEW_GET_FUN(__glewClearDepthfOES) -#define glClipPlanefOES GLEW_GET_FUN(__glewClipPlanefOES) -#define glDepthRangefOES GLEW_GET_FUN(__glewDepthRangefOES) -#define glFrustumfOES GLEW_GET_FUN(__glewFrustumfOES) -#define glGetClipPlanefOES GLEW_GET_FUN(__glewGetClipPlanefOES) -#define glOrthofOES GLEW_GET_FUN(__glewOrthofOES) - -#define GLEW_OES_single_precision GLEW_GET_VAR(__GLEW_OES_single_precision) - -#endif /* GL_OES_single_precision */ - -/* ---------------------------- GL_OML_interlace --------------------------- */ - -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 - -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 - -#define GLEW_OML_interlace GLEW_GET_VAR(__GLEW_OML_interlace) - -#endif /* GL_OML_interlace */ - -/* ---------------------------- GL_OML_resample ---------------------------- */ - -#ifndef GL_OML_resample -#define GL_OML_resample 1 - -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 - -#define GLEW_OML_resample GLEW_GET_VAR(__GLEW_OML_resample) - -#endif /* GL_OML_resample */ - -/* ---------------------------- GL_OML_subsample --------------------------- */ - -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 - -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 - -#define GLEW_OML_subsample GLEW_GET_VAR(__GLEW_OML_subsample) - -#endif /* GL_OML_subsample */ - -/* --------------------------- GL_PGI_misc_hints --------------------------- */ - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 - -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 107000 -#define GL_CONSERVE_MEMORY_HINT_PGI 107005 -#define GL_RECLAIM_MEMORY_HINT_PGI 107006 -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 107010 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 107011 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 107012 -#define GL_ALWAYS_FAST_HINT_PGI 107020 -#define GL_ALWAYS_SOFT_HINT_PGI 107021 -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 107022 -#define GL_ALLOW_DRAW_WIN_HINT_PGI 107023 -#define GL_ALLOW_DRAW_FRG_HINT_PGI 107024 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 107025 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 107030 -#define GL_STRICT_LIGHTING_HINT_PGI 107031 -#define GL_STRICT_SCISSOR_HINT_PGI 107032 -#define GL_FULL_STIPPLE_HINT_PGI 107033 -#define GL_CLIP_NEAR_HINT_PGI 107040 -#define GL_CLIP_FAR_HINT_PGI 107041 -#define GL_WIDE_LINE_HINT_PGI 107042 -#define GL_BACK_NORMALS_HINT_PGI 107043 - -#define GLEW_PGI_misc_hints GLEW_GET_VAR(__GLEW_PGI_misc_hints) - -#endif /* GL_PGI_misc_hints */ - -/* -------------------------- GL_PGI_vertex_hints -------------------------- */ - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 - -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_VERTEX_DATA_HINT_PGI 107050 -#define GL_VERTEX_CONSISTENT_HINT_PGI 107051 -#define GL_MATERIAL_SIDE_HINT_PGI 107052 -#define GL_MAX_VERTEX_HINT_PGI 107053 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 - -#define GLEW_PGI_vertex_hints GLEW_GET_VAR(__GLEW_PGI_vertex_hints) - -#endif /* GL_PGI_vertex_hints */ - -/* ----------------------- GL_REND_screen_coordinates ---------------------- */ - -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 - -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 - -#define GLEW_REND_screen_coordinates GLEW_GET_VAR(__GLEW_REND_screen_coordinates) - -#endif /* GL_REND_screen_coordinates */ - -/* ------------------------------- GL_S3_s3tc ------------------------------ */ - -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 - -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#define GL_RGBA_DXT5_S3TC 0x83A4 -#define GL_RGBA4_DXT5_S3TC 0x83A5 - -#define GLEW_S3_s3tc GLEW_GET_VAR(__GLEW_S3_s3tc) - -#endif /* GL_S3_s3tc */ - -/* -------------------------- GL_SGIS_color_range -------------------------- */ - -#ifndef GL_SGIS_color_range -#define GL_SGIS_color_range 1 - -#define GL_EXTENDED_RANGE_SGIS 0x85A5 -#define GL_MIN_RED_SGIS 0x85A6 -#define GL_MAX_RED_SGIS 0x85A7 -#define GL_MIN_GREEN_SGIS 0x85A8 -#define GL_MAX_GREEN_SGIS 0x85A9 -#define GL_MIN_BLUE_SGIS 0x85AA -#define GL_MAX_BLUE_SGIS 0x85AB -#define GL_MIN_ALPHA_SGIS 0x85AC -#define GL_MAX_ALPHA_SGIS 0x85AD - -#define GLEW_SGIS_color_range GLEW_GET_VAR(__GLEW_SGIS_color_range) - -#endif /* GL_SGIS_color_range */ - -/* ------------------------- GL_SGIS_detail_texture ------------------------ */ - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 - -typedef void (GLAPIENTRY * PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points); -typedef void (GLAPIENTRY * PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat* points); - -#define glDetailTexFuncSGIS GLEW_GET_FUN(__glewDetailTexFuncSGIS) -#define glGetDetailTexFuncSGIS GLEW_GET_FUN(__glewGetDetailTexFuncSGIS) - -#define GLEW_SGIS_detail_texture GLEW_GET_VAR(__GLEW_SGIS_detail_texture) - -#endif /* GL_SGIS_detail_texture */ - -/* -------------------------- GL_SGIS_fog_function ------------------------- */ - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 - -typedef void (GLAPIENTRY * PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat* points); -typedef void (GLAPIENTRY * PFNGLGETFOGFUNCSGISPROC) (GLfloat* points); - -#define glFogFuncSGIS GLEW_GET_FUN(__glewFogFuncSGIS) -#define glGetFogFuncSGIS GLEW_GET_FUN(__glewGetFogFuncSGIS) - -#define GLEW_SGIS_fog_function GLEW_GET_VAR(__GLEW_SGIS_fog_function) - -#endif /* GL_SGIS_fog_function */ - -/* ------------------------ GL_SGIS_generate_mipmap ------------------------ */ - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 - -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 - -#define GLEW_SGIS_generate_mipmap GLEW_GET_VAR(__GLEW_SGIS_generate_mipmap) - -#endif /* GL_SGIS_generate_mipmap */ - -/* -------------------------- GL_SGIS_multisample -------------------------- */ - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 - -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 - -typedef void (GLAPIENTRY * PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (GLAPIENTRY * PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); - -#define glSampleMaskSGIS GLEW_GET_FUN(__glewSampleMaskSGIS) -#define glSamplePatternSGIS GLEW_GET_FUN(__glewSamplePatternSGIS) - -#define GLEW_SGIS_multisample GLEW_GET_VAR(__GLEW_SGIS_multisample) - -#endif /* GL_SGIS_multisample */ - -/* ------------------------- GL_SGIS_pixel_texture ------------------------- */ - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 - -#define GLEW_SGIS_pixel_texture GLEW_GET_VAR(__GLEW_SGIS_pixel_texture) - -#endif /* GL_SGIS_pixel_texture */ - -/* ----------------------- GL_SGIS_point_line_texgen ----------------------- */ - -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 - -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 - -#define GLEW_SGIS_point_line_texgen GLEW_GET_VAR(__GLEW_SGIS_point_line_texgen) - -#endif /* GL_SGIS_point_line_texgen */ - -/* ------------------------ GL_SGIS_sharpen_texture ------------------------ */ - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 - -typedef void (GLAPIENTRY * PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat* points); -typedef void (GLAPIENTRY * PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat* points); - -#define glGetSharpenTexFuncSGIS GLEW_GET_FUN(__glewGetSharpenTexFuncSGIS) -#define glSharpenTexFuncSGIS GLEW_GET_FUN(__glewSharpenTexFuncSGIS) - -#define GLEW_SGIS_sharpen_texture GLEW_GET_VAR(__GLEW_SGIS_sharpen_texture) - -#endif /* GL_SGIS_sharpen_texture */ - -/* --------------------------- GL_SGIS_texture4D --------------------------- */ - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 - -typedef void (GLAPIENTRY * PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const void* pixels); -typedef void (GLAPIENTRY * PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLenum format, GLenum type, const void* pixels); - -#define glTexImage4DSGIS GLEW_GET_FUN(__glewTexImage4DSGIS) -#define glTexSubImage4DSGIS GLEW_GET_FUN(__glewTexSubImage4DSGIS) - -#define GLEW_SGIS_texture4D GLEW_GET_VAR(__GLEW_SGIS_texture4D) - -#endif /* GL_SGIS_texture4D */ - -/* ---------------------- GL_SGIS_texture_border_clamp --------------------- */ - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 - -#define GL_CLAMP_TO_BORDER_SGIS 0x812D - -#define GLEW_SGIS_texture_border_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_border_clamp) - -#endif /* GL_SGIS_texture_border_clamp */ - -/* ----------------------- GL_SGIS_texture_edge_clamp ---------------------- */ - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 - -#define GL_CLAMP_TO_EDGE_SGIS 0x812F - -#define GLEW_SGIS_texture_edge_clamp GLEW_GET_VAR(__GLEW_SGIS_texture_edge_clamp) - -#endif /* GL_SGIS_texture_edge_clamp */ - -/* ------------------------ GL_SGIS_texture_filter4 ------------------------ */ - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 - -typedef void (GLAPIENTRY * PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat* weights); -typedef void (GLAPIENTRY * PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat* weights); - -#define glGetTexFilterFuncSGIS GLEW_GET_FUN(__glewGetTexFilterFuncSGIS) -#define glTexFilterFuncSGIS GLEW_GET_FUN(__glewTexFilterFuncSGIS) - -#define GLEW_SGIS_texture_filter4 GLEW_GET_VAR(__GLEW_SGIS_texture_filter4) - -#endif /* GL_SGIS_texture_filter4 */ - -/* -------------------------- GL_SGIS_texture_lod -------------------------- */ - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 - -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D - -#define GLEW_SGIS_texture_lod GLEW_GET_VAR(__GLEW_SGIS_texture_lod) - -#endif /* GL_SGIS_texture_lod */ - -/* ------------------------- GL_SGIS_texture_select ------------------------ */ - -#ifndef GL_SGIS_texture_select -#define GL_SGIS_texture_select 1 - -#define GLEW_SGIS_texture_select GLEW_GET_VAR(__GLEW_SGIS_texture_select) - -#endif /* GL_SGIS_texture_select */ - -/* ----------------------------- GL_SGIX_async ----------------------------- */ - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 - -#define GL_ASYNC_MARKER_SGIX 0x8329 - -typedef void (GLAPIENTRY * PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef void (GLAPIENTRY * PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLint (GLAPIENTRY * PFNGLFINISHASYNCSGIXPROC) (GLuint* markerp); -typedef GLuint (GLAPIENTRY * PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef GLboolean (GLAPIENTRY * PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (GLAPIENTRY * PFNGLPOLLASYNCSGIXPROC) (GLuint* markerp); - -#define glAsyncMarkerSGIX GLEW_GET_FUN(__glewAsyncMarkerSGIX) -#define glDeleteAsyncMarkersSGIX GLEW_GET_FUN(__glewDeleteAsyncMarkersSGIX) -#define glFinishAsyncSGIX GLEW_GET_FUN(__glewFinishAsyncSGIX) -#define glGenAsyncMarkersSGIX GLEW_GET_FUN(__glewGenAsyncMarkersSGIX) -#define glIsAsyncMarkerSGIX GLEW_GET_FUN(__glewIsAsyncMarkerSGIX) -#define glPollAsyncSGIX GLEW_GET_FUN(__glewPollAsyncSGIX) - -#define GLEW_SGIX_async GLEW_GET_VAR(__GLEW_SGIX_async) - -#endif /* GL_SGIX_async */ - -/* ------------------------ GL_SGIX_async_histogram ------------------------ */ - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 - -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D - -#define GLEW_SGIX_async_histogram GLEW_GET_VAR(__GLEW_SGIX_async_histogram) - -#endif /* GL_SGIX_async_histogram */ - -/* -------------------------- GL_SGIX_async_pixel -------------------------- */ - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 - -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 - -#define GLEW_SGIX_async_pixel GLEW_GET_VAR(__GLEW_SGIX_async_pixel) - -#endif /* GL_SGIX_async_pixel */ - -/* ----------------------- GL_SGIX_blend_alpha_minmax ---------------------- */ - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 - -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 - -#define GLEW_SGIX_blend_alpha_minmax GLEW_GET_VAR(__GLEW_SGIX_blend_alpha_minmax) - -#endif /* GL_SGIX_blend_alpha_minmax */ - -/* ---------------------------- GL_SGIX_clipmap ---------------------------- */ - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 - -#define GLEW_SGIX_clipmap GLEW_GET_VAR(__GLEW_SGIX_clipmap) - -#endif /* GL_SGIX_clipmap */ - -/* ---------------------- GL_SGIX_convolution_accuracy --------------------- */ - -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 - -#define GL_CONVOLUTION_HINT_SGIX 0x8316 - -#define GLEW_SGIX_convolution_accuracy GLEW_GET_VAR(__GLEW_SGIX_convolution_accuracy) - -#endif /* GL_SGIX_convolution_accuracy */ - -/* ------------------------- GL_SGIX_depth_texture ------------------------- */ - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 - -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 - -#define GLEW_SGIX_depth_texture GLEW_GET_VAR(__GLEW_SGIX_depth_texture) - -#endif /* GL_SGIX_depth_texture */ - -/* -------------------------- GL_SGIX_flush_raster ------------------------- */ - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 - -typedef void (GLAPIENTRY * PFNGLFLUSHRASTERSGIXPROC) (void); - -#define glFlushRasterSGIX GLEW_GET_FUN(__glewFlushRasterSGIX) - -#define GLEW_SGIX_flush_raster GLEW_GET_VAR(__GLEW_SGIX_flush_raster) - -#endif /* GL_SGIX_flush_raster */ - -/* --------------------------- GL_SGIX_fog_offset -------------------------- */ - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 - -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 - -#define GLEW_SGIX_fog_offset GLEW_GET_VAR(__GLEW_SGIX_fog_offset) - -#endif /* GL_SGIX_fog_offset */ - -/* -------------------------- GL_SGIX_fog_texture -------------------------- */ - -#ifndef GL_SGIX_fog_texture -#define GL_SGIX_fog_texture 1 - -#define GL_TEXTURE_FOG_SGIX 0 -#define GL_FOG_PATCHY_FACTOR_SGIX 0 -#define GL_FRAGMENT_FOG_SGIX 0 - -typedef void (GLAPIENTRY * PFNGLTEXTUREFOGSGIXPROC) (GLenum pname); - -#define glTextureFogSGIX GLEW_GET_FUN(__glewTextureFogSGIX) - -#define GLEW_SGIX_fog_texture GLEW_GET_VAR(__GLEW_SGIX_fog_texture) - -#endif /* GL_SGIX_fog_texture */ - -/* ------------------- GL_SGIX_fragment_specular_lighting ------------------ */ - -#ifndef GL_SGIX_fragment_specular_lighting -#define GL_SGIX_fragment_specular_lighting 1 - -typedef void (GLAPIENTRY * PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, const GLfloat param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, const GLint param); -typedef void (GLAPIENTRY * PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum value, GLfloat* data); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum value, GLint* data); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat* data); -typedef void (GLAPIENTRY * PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint* data); - -#define glFragmentColorMaterialSGIX GLEW_GET_FUN(__glewFragmentColorMaterialSGIX) -#define glFragmentLightModelfSGIX GLEW_GET_FUN(__glewFragmentLightModelfSGIX) -#define glFragmentLightModelfvSGIX GLEW_GET_FUN(__glewFragmentLightModelfvSGIX) -#define glFragmentLightModeliSGIX GLEW_GET_FUN(__glewFragmentLightModeliSGIX) -#define glFragmentLightModelivSGIX GLEW_GET_FUN(__glewFragmentLightModelivSGIX) -#define glFragmentLightfSGIX GLEW_GET_FUN(__glewFragmentLightfSGIX) -#define glFragmentLightfvSGIX GLEW_GET_FUN(__glewFragmentLightfvSGIX) -#define glFragmentLightiSGIX GLEW_GET_FUN(__glewFragmentLightiSGIX) -#define glFragmentLightivSGIX GLEW_GET_FUN(__glewFragmentLightivSGIX) -#define glFragmentMaterialfSGIX GLEW_GET_FUN(__glewFragmentMaterialfSGIX) -#define glFragmentMaterialfvSGIX GLEW_GET_FUN(__glewFragmentMaterialfvSGIX) -#define glFragmentMaterialiSGIX GLEW_GET_FUN(__glewFragmentMaterialiSGIX) -#define glFragmentMaterialivSGIX GLEW_GET_FUN(__glewFragmentMaterialivSGIX) -#define glGetFragmentLightfvSGIX GLEW_GET_FUN(__glewGetFragmentLightfvSGIX) -#define glGetFragmentLightivSGIX GLEW_GET_FUN(__glewGetFragmentLightivSGIX) -#define glGetFragmentMaterialfvSGIX GLEW_GET_FUN(__glewGetFragmentMaterialfvSGIX) -#define glGetFragmentMaterialivSGIX GLEW_GET_FUN(__glewGetFragmentMaterialivSGIX) - -#define GLEW_SGIX_fragment_specular_lighting GLEW_GET_VAR(__GLEW_SGIX_fragment_specular_lighting) - -#endif /* GL_SGIX_fragment_specular_lighting */ - -/* --------------------------- GL_SGIX_framezoom --------------------------- */ - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 - -typedef void (GLAPIENTRY * PFNGLFRAMEZOOMSGIXPROC) (GLint factor); - -#define glFrameZoomSGIX GLEW_GET_FUN(__glewFrameZoomSGIX) - -#define GLEW_SGIX_framezoom GLEW_GET_VAR(__GLEW_SGIX_framezoom) - -#endif /* GL_SGIX_framezoom */ - -/* --------------------------- GL_SGIX_interlace --------------------------- */ - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 - -#define GL_INTERLACE_SGIX 0x8094 - -#define GLEW_SGIX_interlace GLEW_GET_VAR(__GLEW_SGIX_interlace) - -#endif /* GL_SGIX_interlace */ - -/* ------------------------- GL_SGIX_ir_instrument1 ------------------------ */ - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 - -#define GLEW_SGIX_ir_instrument1 GLEW_GET_VAR(__GLEW_SGIX_ir_instrument1) - -#endif /* GL_SGIX_ir_instrument1 */ - -/* ------------------------- GL_SGIX_list_priority ------------------------- */ - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 - -#define GLEW_SGIX_list_priority GLEW_GET_VAR(__GLEW_SGIX_list_priority) - -#endif /* GL_SGIX_list_priority */ - -/* ------------------------- GL_SGIX_pixel_texture ------------------------- */ - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 - -typedef void (GLAPIENTRY * PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); - -#define glPixelTexGenSGIX GLEW_GET_FUN(__glewPixelTexGenSGIX) - -#define GLEW_SGIX_pixel_texture GLEW_GET_VAR(__GLEW_SGIX_pixel_texture) - -#endif /* GL_SGIX_pixel_texture */ - -/* ----------------------- GL_SGIX_pixel_texture_bits ---------------------- */ - -#ifndef GL_SGIX_pixel_texture_bits -#define GL_SGIX_pixel_texture_bits 1 - -#define GLEW_SGIX_pixel_texture_bits GLEW_GET_VAR(__GLEW_SGIX_pixel_texture_bits) - -#endif /* GL_SGIX_pixel_texture_bits */ - -/* ------------------------ GL_SGIX_reference_plane ------------------------ */ - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 - -typedef void (GLAPIENTRY * PFNGLREFERENCEPLANESGIXPROC) (const GLdouble* equation); - -#define glReferencePlaneSGIX GLEW_GET_FUN(__glewReferencePlaneSGIX) - -#define GLEW_SGIX_reference_plane GLEW_GET_VAR(__GLEW_SGIX_reference_plane) - -#endif /* GL_SGIX_reference_plane */ - -/* ---------------------------- GL_SGIX_resample --------------------------- */ - -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 - -#define GL_PACK_RESAMPLE_SGIX 0x842E -#define GL_UNPACK_RESAMPLE_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#define GL_RESAMPLE_REPLICATE_SGIX 0x8433 -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 - -#define GLEW_SGIX_resample GLEW_GET_VAR(__GLEW_SGIX_resample) - -#endif /* GL_SGIX_resample */ - -/* ----------------------------- GL_SGIX_shadow ---------------------------- */ - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 - -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D - -#define GLEW_SGIX_shadow GLEW_GET_VAR(__GLEW_SGIX_shadow) - -#endif /* GL_SGIX_shadow */ - -/* ------------------------- GL_SGIX_shadow_ambient ------------------------ */ - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 - -#define GL_SHADOW_AMBIENT_SGIX 0x80BF - -#define GLEW_SGIX_shadow_ambient GLEW_GET_VAR(__GLEW_SGIX_shadow_ambient) - -#endif /* GL_SGIX_shadow_ambient */ - -/* ----------------------------- GL_SGIX_sprite ---------------------------- */ - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 - -typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (GLAPIENTRY * PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, GLint* params); - -#define glSpriteParameterfSGIX GLEW_GET_FUN(__glewSpriteParameterfSGIX) -#define glSpriteParameterfvSGIX GLEW_GET_FUN(__glewSpriteParameterfvSGIX) -#define glSpriteParameteriSGIX GLEW_GET_FUN(__glewSpriteParameteriSGIX) -#define glSpriteParameterivSGIX GLEW_GET_FUN(__glewSpriteParameterivSGIX) - -#define GLEW_SGIX_sprite GLEW_GET_VAR(__GLEW_SGIX_sprite) - -#endif /* GL_SGIX_sprite */ - -/* ----------------------- GL_SGIX_tag_sample_buffer ----------------------- */ - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 - -typedef void (GLAPIENTRY * PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); - -#define glTagSampleBufferSGIX GLEW_GET_FUN(__glewTagSampleBufferSGIX) - -#define GLEW_SGIX_tag_sample_buffer GLEW_GET_VAR(__GLEW_SGIX_tag_sample_buffer) - -#endif /* GL_SGIX_tag_sample_buffer */ - -/* ------------------------ GL_SGIX_texture_add_env ------------------------ */ - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 - -#define GLEW_SGIX_texture_add_env GLEW_GET_VAR(__GLEW_SGIX_texture_add_env) - -#endif /* GL_SGIX_texture_add_env */ - -/* -------------------- GL_SGIX_texture_coordinate_clamp ------------------- */ - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 - -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B - -#define GLEW_SGIX_texture_coordinate_clamp GLEW_GET_VAR(__GLEW_SGIX_texture_coordinate_clamp) - -#endif /* GL_SGIX_texture_coordinate_clamp */ - -/* ------------------------ GL_SGIX_texture_lod_bias ----------------------- */ - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 - -#define GLEW_SGIX_texture_lod_bias GLEW_GET_VAR(__GLEW_SGIX_texture_lod_bias) - -#endif /* GL_SGIX_texture_lod_bias */ - -/* ---------------------- GL_SGIX_texture_multi_buffer --------------------- */ - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 - -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E - -#define GLEW_SGIX_texture_multi_buffer GLEW_GET_VAR(__GLEW_SGIX_texture_multi_buffer) - -#endif /* GL_SGIX_texture_multi_buffer */ - -/* ------------------------- GL_SGIX_texture_range ------------------------- */ - -#ifndef GL_SGIX_texture_range -#define GL_SGIX_texture_range 1 - -#define GL_RGB_SIGNED_SGIX 0x85E0 -#define GL_RGBA_SIGNED_SGIX 0x85E1 -#define GL_ALPHA_SIGNED_SGIX 0x85E2 -#define GL_LUMINANCE_SIGNED_SGIX 0x85E3 -#define GL_INTENSITY_SIGNED_SGIX 0x85E4 -#define GL_LUMINANCE_ALPHA_SIGNED_SGIX 0x85E5 -#define GL_RGB16_SIGNED_SGIX 0x85E6 -#define GL_RGBA16_SIGNED_SGIX 0x85E7 -#define GL_ALPHA16_SIGNED_SGIX 0x85E8 -#define GL_LUMINANCE16_SIGNED_SGIX 0x85E9 -#define GL_INTENSITY16_SIGNED_SGIX 0x85EA -#define GL_LUMINANCE16_ALPHA16_SIGNED_SGIX 0x85EB -#define GL_RGB_EXTENDED_RANGE_SGIX 0x85EC -#define GL_RGBA_EXTENDED_RANGE_SGIX 0x85ED -#define GL_ALPHA_EXTENDED_RANGE_SGIX 0x85EE -#define GL_LUMINANCE_EXTENDED_RANGE_SGIX 0x85EF -#define GL_INTENSITY_EXTENDED_RANGE_SGIX 0x85F0 -#define GL_LUMINANCE_ALPHA_EXTENDED_RANGE_SGIX 0x85F1 -#define GL_RGB16_EXTENDED_RANGE_SGIX 0x85F2 -#define GL_RGBA16_EXTENDED_RANGE_SGIX 0x85F3 -#define GL_ALPHA16_EXTENDED_RANGE_SGIX 0x85F4 -#define GL_LUMINANCE16_EXTENDED_RANGE_SGIX 0x85F5 -#define GL_INTENSITY16_EXTENDED_RANGE_SGIX 0x85F6 -#define GL_LUMINANCE16_ALPHA16_EXTENDED_RANGE_SGIX 0x85F7 -#define GL_MIN_LUMINANCE_SGIS 0x85F8 -#define GL_MAX_LUMINANCE_SGIS 0x85F9 -#define GL_MIN_INTENSITY_SGIS 0x85FA -#define GL_MAX_INTENSITY_SGIS 0x85FB - -#define GLEW_SGIX_texture_range GLEW_GET_VAR(__GLEW_SGIX_texture_range) - -#endif /* GL_SGIX_texture_range */ - -/* ----------------------- GL_SGIX_texture_scale_bias ---------------------- */ - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 - -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C - -#define GLEW_SGIX_texture_scale_bias GLEW_GET_VAR(__GLEW_SGIX_texture_scale_bias) - -#endif /* GL_SGIX_texture_scale_bias */ - -/* ------------------------- GL_SGIX_vertex_preclip ------------------------ */ - -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 - -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF - -#define GLEW_SGIX_vertex_preclip GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip) - -#endif /* GL_SGIX_vertex_preclip */ - -/* ---------------------- GL_SGIX_vertex_preclip_hint ---------------------- */ - -#ifndef GL_SGIX_vertex_preclip_hint -#define GL_SGIX_vertex_preclip_hint 1 - -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF - -#define GLEW_SGIX_vertex_preclip_hint GLEW_GET_VAR(__GLEW_SGIX_vertex_preclip_hint) - -#endif /* GL_SGIX_vertex_preclip_hint */ - -/* ----------------------------- GL_SGIX_ycrcb ----------------------------- */ - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 - -#define GLEW_SGIX_ycrcb GLEW_GET_VAR(__GLEW_SGIX_ycrcb) - -#endif /* GL_SGIX_ycrcb */ - -/* -------------------------- GL_SGI_color_matrix -------------------------- */ - -#ifndef GL_SGI_color_matrix -#define GL_SGI_color_matrix 1 - -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB - -#define GLEW_SGI_color_matrix GLEW_GET_VAR(__GLEW_SGI_color_matrix) - -#endif /* GL_SGI_color_matrix */ - -/* --------------------------- GL_SGI_color_table -------------------------- */ - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 - -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF - -typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat* params); -typedef void (GLAPIENTRY * PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint* params); -typedef void (GLAPIENTRY * PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void* table); -typedef void (GLAPIENTRY * PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat* params); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint* params); -typedef void (GLAPIENTRY * PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void* table); - -#define glColorTableParameterfvSGI GLEW_GET_FUN(__glewColorTableParameterfvSGI) -#define glColorTableParameterivSGI GLEW_GET_FUN(__glewColorTableParameterivSGI) -#define glColorTableSGI GLEW_GET_FUN(__glewColorTableSGI) -#define glCopyColorTableSGI GLEW_GET_FUN(__glewCopyColorTableSGI) -#define glGetColorTableParameterfvSGI GLEW_GET_FUN(__glewGetColorTableParameterfvSGI) -#define glGetColorTableParameterivSGI GLEW_GET_FUN(__glewGetColorTableParameterivSGI) -#define glGetColorTableSGI GLEW_GET_FUN(__glewGetColorTableSGI) - -#define GLEW_SGI_color_table GLEW_GET_VAR(__GLEW_SGI_color_table) - -#endif /* GL_SGI_color_table */ - -/* ----------------------- GL_SGI_texture_color_table ---------------------- */ - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 - -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD - -#define GLEW_SGI_texture_color_table GLEW_GET_VAR(__GLEW_SGI_texture_color_table) - -#endif /* GL_SGI_texture_color_table */ - -/* ------------------------- GL_SUNX_constant_data ------------------------- */ - -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 - -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 - -typedef void (GLAPIENTRY * PFNGLFINISHTEXTURESUNXPROC) (void); - -#define glFinishTextureSUNX GLEW_GET_FUN(__glewFinishTextureSUNX) - -#define GLEW_SUNX_constant_data GLEW_GET_VAR(__GLEW_SUNX_constant_data) - -#endif /* GL_SUNX_constant_data */ - -/* -------------------- GL_SUN_convolution_border_modes -------------------- */ - -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 - -#define GL_WRAP_BORDER_SUN 0x81D4 - -#define GLEW_SUN_convolution_border_modes GLEW_GET_VAR(__GLEW_SUN_convolution_border_modes) - -#endif /* GL_SUN_convolution_border_modes */ - -/* -------------------------- GL_SUN_global_alpha -------------------------- */ - -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 - -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA - -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); -typedef void (GLAPIENTRY * PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); - -#define glGlobalAlphaFactorbSUN GLEW_GET_FUN(__glewGlobalAlphaFactorbSUN) -#define glGlobalAlphaFactordSUN GLEW_GET_FUN(__glewGlobalAlphaFactordSUN) -#define glGlobalAlphaFactorfSUN GLEW_GET_FUN(__glewGlobalAlphaFactorfSUN) -#define glGlobalAlphaFactoriSUN GLEW_GET_FUN(__glewGlobalAlphaFactoriSUN) -#define glGlobalAlphaFactorsSUN GLEW_GET_FUN(__glewGlobalAlphaFactorsSUN) -#define glGlobalAlphaFactorubSUN GLEW_GET_FUN(__glewGlobalAlphaFactorubSUN) -#define glGlobalAlphaFactoruiSUN GLEW_GET_FUN(__glewGlobalAlphaFactoruiSUN) -#define glGlobalAlphaFactorusSUN GLEW_GET_FUN(__glewGlobalAlphaFactorusSUN) - -#define GLEW_SUN_global_alpha GLEW_GET_VAR(__GLEW_SUN_global_alpha) - -#endif /* GL_SUN_global_alpha */ - -/* --------------------------- GL_SUN_mesh_array --------------------------- */ - -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 - -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 - -#define GLEW_SUN_mesh_array GLEW_GET_VAR(__GLEW_SUN_mesh_array) - -#endif /* GL_SUN_mesh_array */ - -/* ------------------------ GL_SUN_read_video_pixels ----------------------- */ - -#ifndef GL_SUN_read_video_pixels -#define GL_SUN_read_video_pixels 1 - -typedef void (GLAPIENTRY * PFNGLREADVIDEOPIXELSSUNPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); - -#define glReadVideoPixelsSUN GLEW_GET_FUN(__glewReadVideoPixelsSUN) - -#define GLEW_SUN_read_video_pixels GLEW_GET_VAR(__GLEW_SUN_read_video_pixels) - -#endif /* GL_SUN_read_video_pixels */ - -/* --------------------------- GL_SUN_slice_accum -------------------------- */ - -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 - -#define GL_SLICE_ACCUM_SUN 0x85CC - -#define GLEW_SUN_slice_accum GLEW_GET_VAR(__GLEW_SUN_slice_accum) - -#endif /* GL_SUN_slice_accum */ - -/* -------------------------- GL_SUN_triangle_list ------------------------- */ - -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 - -#define GL_RESTART_SUN 0x01 -#define GL_REPLACE_MIDDLE_SUN 0x02 -#define GL_REPLACE_OLDEST_SUN 0x03 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB - -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void* pointer); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte* code); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint* code); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort* code); - -#define glReplacementCodePointerSUN GLEW_GET_FUN(__glewReplacementCodePointerSUN) -#define glReplacementCodeubSUN GLEW_GET_FUN(__glewReplacementCodeubSUN) -#define glReplacementCodeubvSUN GLEW_GET_FUN(__glewReplacementCodeubvSUN) -#define glReplacementCodeuiSUN GLEW_GET_FUN(__glewReplacementCodeuiSUN) -#define glReplacementCodeuivSUN GLEW_GET_FUN(__glewReplacementCodeuivSUN) -#define glReplacementCodeusSUN GLEW_GET_FUN(__glewReplacementCodeusSUN) -#define glReplacementCodeusvSUN GLEW_GET_FUN(__glewReplacementCodeusvSUN) - -#define GLEW_SUN_triangle_list GLEW_GET_VAR(__GLEW_SUN_triangle_list) - -#endif /* GL_SUN_triangle_list */ - -/* ----------------------------- GL_SUN_vertex ----------------------------- */ - -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 - -typedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* c, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte* c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte* c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint* rc, const GLubyte *c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *tc, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint* rc, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat* tc, const GLubyte *c, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (GLAPIENTRY * PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat* tc, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (GLAPIENTRY * PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat* tc, const GLfloat *v); - -#define glColor3fVertex3fSUN GLEW_GET_FUN(__glewColor3fVertex3fSUN) -#define glColor3fVertex3fvSUN GLEW_GET_FUN(__glewColor3fVertex3fvSUN) -#define glColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fSUN) -#define glColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewColor4fNormal3fVertex3fvSUN) -#define glColor4ubVertex2fSUN GLEW_GET_FUN(__glewColor4ubVertex2fSUN) -#define glColor4ubVertex2fvSUN GLEW_GET_FUN(__glewColor4ubVertex2fvSUN) -#define glColor4ubVertex3fSUN GLEW_GET_FUN(__glewColor4ubVertex3fSUN) -#define glColor4ubVertex3fvSUN GLEW_GET_FUN(__glewColor4ubVertex3fvSUN) -#define glNormal3fVertex3fSUN GLEW_GET_FUN(__glewNormal3fVertex3fSUN) -#define glNormal3fVertex3fvSUN GLEW_GET_FUN(__glewNormal3fVertex3fvSUN) -#define glReplacementCodeuiColor3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fSUN) -#define glReplacementCodeuiColor3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor3fVertex3fvSUN) -#define glReplacementCodeuiColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fSUN) -#define glReplacementCodeuiColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4fNormal3fVertex3fvSUN) -#define glReplacementCodeuiColor4ubVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fSUN) -#define glReplacementCodeuiColor4ubVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiColor4ubVertex3fvSUN) -#define glReplacementCodeuiNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fSUN) -#define glReplacementCodeuiNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiNormal3fVertex3fvSUN) -#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN) -#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN) -#define glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN) -#define glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN) -#define glReplacementCodeuiTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fSUN) -#define glReplacementCodeuiTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiTexCoord2fVertex3fvSUN) -#define glReplacementCodeuiVertex3fSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fSUN) -#define glReplacementCodeuiVertex3fvSUN GLEW_GET_FUN(__glewReplacementCodeuiVertex3fvSUN) -#define glTexCoord2fColor3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fSUN) -#define glTexCoord2fColor3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor3fVertex3fvSUN) -#define glTexCoord2fColor4fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fSUN) -#define glTexCoord2fColor4fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4fNormal3fVertex3fvSUN) -#define glTexCoord2fColor4ubVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fSUN) -#define glTexCoord2fColor4ubVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fColor4ubVertex3fvSUN) -#define glTexCoord2fNormal3fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fSUN) -#define glTexCoord2fNormal3fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fNormal3fVertex3fvSUN) -#define glTexCoord2fVertex3fSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fSUN) -#define glTexCoord2fVertex3fvSUN GLEW_GET_FUN(__glewTexCoord2fVertex3fvSUN) -#define glTexCoord4fColor4fNormal3fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fSUN) -#define glTexCoord4fColor4fNormal3fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fColor4fNormal3fVertex4fvSUN) -#define glTexCoord4fVertex4fSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fSUN) -#define glTexCoord4fVertex4fvSUN GLEW_GET_FUN(__glewTexCoord4fVertex4fvSUN) - -#define GLEW_SUN_vertex GLEW_GET_VAR(__GLEW_SUN_vertex) - -#endif /* GL_SUN_vertex */ - -/* -------------------------- GL_WIN_phong_shading ------------------------- */ - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 - -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB - -#define GLEW_WIN_phong_shading GLEW_GET_VAR(__GLEW_WIN_phong_shading) - -#endif /* GL_WIN_phong_shading */ - -/* -------------------------- GL_WIN_specular_fog -------------------------- */ - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 - -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC - -#define GLEW_WIN_specular_fog GLEW_GET_VAR(__GLEW_WIN_specular_fog) - -#endif /* GL_WIN_specular_fog */ - -/* ---------------------------- GL_WIN_swap_hint --------------------------- */ - -#ifndef GL_WIN_swap_hint -#define GL_WIN_swap_hint 1 - -typedef void (GLAPIENTRY * PFNGLADDSWAPHINTRECTWINPROC) (GLint x, GLint y, GLsizei width, GLsizei height); - -#define glAddSwapHintRectWIN GLEW_GET_FUN(__glewAddSwapHintRectWIN) - -#define GLEW_WIN_swap_hint GLEW_GET_VAR(__GLEW_WIN_swap_hint) - -#endif /* GL_WIN_swap_hint */ - -/* ------------------------------------------------------------------------- */ - -#if defined(GLEW_MX) && defined(_WIN32) -#define GLEW_FUN_EXPORT -#else -#define GLEW_FUN_EXPORT GLEWAPI -#endif /* GLEW_MX */ - -#if defined(GLEW_MX) -#define GLEW_VAR_EXPORT -#else -#define GLEW_VAR_EXPORT GLEWAPI -#endif /* GLEW_MX */ - -#if defined(GLEW_MX) && defined(_WIN32) -struct GLEWContextStruct -{ -#endif /* GLEW_MX */ - -GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DPROC __glewCopyTexSubImage3D; -GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSPROC __glewDrawRangeElements; -GLEW_FUN_EXPORT PFNGLTEXIMAGE3DPROC __glewTexImage3D; -GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DPROC __glewTexSubImage3D; - -GLEW_FUN_EXPORT PFNGLACTIVETEXTUREPROC __glewActiveTexture; -GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DPROC __glewCompressedTexImage1D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DPROC __glewCompressedTexImage2D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DPROC __glewCompressedTexImage3D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC __glewCompressedTexSubImage1D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC __glewCompressedTexSubImage2D; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC __glewCompressedTexSubImage3D; -GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEPROC __glewGetCompressedTexImage; -GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDPROC __glewLoadTransposeMatrixd; -GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFPROC __glewLoadTransposeMatrixf; -GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDPROC __glewMultTransposeMatrixd; -GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFPROC __glewMultTransposeMatrixf; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DPROC __glewMultiTexCoord1d; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVPROC __glewMultiTexCoord1dv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FPROC __glewMultiTexCoord1f; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVPROC __glewMultiTexCoord1fv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IPROC __glewMultiTexCoord1i; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVPROC __glewMultiTexCoord1iv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SPROC __glewMultiTexCoord1s; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVPROC __glewMultiTexCoord1sv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DPROC __glewMultiTexCoord2d; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVPROC __glewMultiTexCoord2dv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FPROC __glewMultiTexCoord2f; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVPROC __glewMultiTexCoord2fv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IPROC __glewMultiTexCoord2i; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVPROC __glewMultiTexCoord2iv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SPROC __glewMultiTexCoord2s; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVPROC __glewMultiTexCoord2sv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DPROC __glewMultiTexCoord3d; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVPROC __glewMultiTexCoord3dv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FPROC __glewMultiTexCoord3f; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVPROC __glewMultiTexCoord3fv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IPROC __glewMultiTexCoord3i; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVPROC __glewMultiTexCoord3iv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SPROC __glewMultiTexCoord3s; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVPROC __glewMultiTexCoord3sv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DPROC __glewMultiTexCoord4d; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVPROC __glewMultiTexCoord4dv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FPROC __glewMultiTexCoord4f; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVPROC __glewMultiTexCoord4fv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IPROC __glewMultiTexCoord4i; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVPROC __glewMultiTexCoord4iv; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SPROC __glewMultiTexCoord4s; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVPROC __glewMultiTexCoord4sv; -GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEPROC __glewSampleCoverage; - -GLEW_FUN_EXPORT PFNGLBLENDCOLORPROC __glewBlendColor; -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONPROC __glewBlendEquation; -GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEPROC __glewBlendFuncSeparate; -GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERPROC __glewFogCoordPointer; -GLEW_FUN_EXPORT PFNGLFOGCOORDDPROC __glewFogCoordd; -GLEW_FUN_EXPORT PFNGLFOGCOORDDVPROC __glewFogCoorddv; -GLEW_FUN_EXPORT PFNGLFOGCOORDFPROC __glewFogCoordf; -GLEW_FUN_EXPORT PFNGLFOGCOORDFVPROC __glewFogCoordfv; -GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSPROC __glewMultiDrawArrays; -GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSPROC __glewMultiDrawElements; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFPROC __glewPointParameterf; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVPROC __glewPointParameterfv; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIPROC __glewPointParameteri; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVPROC __glewPointParameteriv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BPROC __glewSecondaryColor3b; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVPROC __glewSecondaryColor3bv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DPROC __glewSecondaryColor3d; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVPROC __glewSecondaryColor3dv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FPROC __glewSecondaryColor3f; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVPROC __glewSecondaryColor3fv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IPROC __glewSecondaryColor3i; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVPROC __glewSecondaryColor3iv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SPROC __glewSecondaryColor3s; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVPROC __glewSecondaryColor3sv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBPROC __glewSecondaryColor3ub; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVPROC __glewSecondaryColor3ubv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIPROC __glewSecondaryColor3ui; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVPROC __glewSecondaryColor3uiv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USPROC __glewSecondaryColor3us; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVPROC __glewSecondaryColor3usv; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERPROC __glewSecondaryColorPointer; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DPROC __glewWindowPos2d; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVPROC __glewWindowPos2dv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FPROC __glewWindowPos2f; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVPROC __glewWindowPos2fv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IPROC __glewWindowPos2i; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVPROC __glewWindowPos2iv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SPROC __glewWindowPos2s; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVPROC __glewWindowPos2sv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DPROC __glewWindowPos3d; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVPROC __glewWindowPos3dv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FPROC __glewWindowPos3f; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVPROC __glewWindowPos3fv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IPROC __glewWindowPos3i; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVPROC __glewWindowPos3iv; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SPROC __glewWindowPos3s; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVPROC __glewWindowPos3sv; - -GLEW_FUN_EXPORT PFNGLBEGINQUERYPROC __glewBeginQuery; -GLEW_FUN_EXPORT PFNGLBINDBUFFERPROC __glewBindBuffer; -GLEW_FUN_EXPORT PFNGLBUFFERDATAPROC __glewBufferData; -GLEW_FUN_EXPORT PFNGLBUFFERSUBDATAPROC __glewBufferSubData; -GLEW_FUN_EXPORT PFNGLDELETEBUFFERSPROC __glewDeleteBuffers; -GLEW_FUN_EXPORT PFNGLDELETEQUERIESPROC __glewDeleteQueries; -GLEW_FUN_EXPORT PFNGLENDQUERYPROC __glewEndQuery; -GLEW_FUN_EXPORT PFNGLGENBUFFERSPROC __glewGenBuffers; -GLEW_FUN_EXPORT PFNGLGENQUERIESPROC __glewGenQueries; -GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVPROC __glewGetBufferParameteriv; -GLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVPROC __glewGetBufferPointerv; -GLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAPROC __glewGetBufferSubData; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVPROC __glewGetQueryObjectiv; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVPROC __glewGetQueryObjectuiv; -GLEW_FUN_EXPORT PFNGLGETQUERYIVPROC __glewGetQueryiv; -GLEW_FUN_EXPORT PFNGLISBUFFERPROC __glewIsBuffer; -GLEW_FUN_EXPORT PFNGLISQUERYPROC __glewIsQuery; -GLEW_FUN_EXPORT PFNGLMAPBUFFERPROC __glewMapBuffer; -GLEW_FUN_EXPORT PFNGLUNMAPBUFFERPROC __glewUnmapBuffer; - -GLEW_FUN_EXPORT PFNGLATTACHSHADERPROC __glewAttachShader; -GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONPROC __glewBindAttribLocation; -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEPROC __glewBlendEquationSeparate; -GLEW_FUN_EXPORT PFNGLCOMPILESHADERPROC __glewCompileShader; -GLEW_FUN_EXPORT PFNGLCREATEPROGRAMPROC __glewCreateProgram; -GLEW_FUN_EXPORT PFNGLCREATESHADERPROC __glewCreateShader; -GLEW_FUN_EXPORT PFNGLDELETEPROGRAMPROC __glewDeleteProgram; -GLEW_FUN_EXPORT PFNGLDELETESHADERPROC __glewDeleteShader; -GLEW_FUN_EXPORT PFNGLDETACHSHADERPROC __glewDetachShader; -GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYPROC __glewDisableVertexAttribArray; -GLEW_FUN_EXPORT PFNGLDRAWBUFFERSPROC __glewDrawBuffers; -GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYPROC __glewEnableVertexAttribArray; -GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBPROC __glewGetActiveAttrib; -GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMPROC __glewGetActiveUniform; -GLEW_FUN_EXPORT PFNGLGETATTACHEDSHADERSPROC __glewGetAttachedShaders; -GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONPROC __glewGetAttribLocation; -GLEW_FUN_EXPORT PFNGLGETPROGRAMINFOLOGPROC __glewGetProgramInfoLog; -GLEW_FUN_EXPORT PFNGLGETPROGRAMIVPROC __glewGetProgramiv; -GLEW_FUN_EXPORT PFNGLGETSHADERINFOLOGPROC __glewGetShaderInfoLog; -GLEW_FUN_EXPORT PFNGLGETSHADERSOURCEPROC __glewGetShaderSource; -GLEW_FUN_EXPORT PFNGLGETSHADERIVPROC __glewGetShaderiv; -GLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONPROC __glewGetUniformLocation; -GLEW_FUN_EXPORT PFNGLGETUNIFORMFVPROC __glewGetUniformfv; -GLEW_FUN_EXPORT PFNGLGETUNIFORMIVPROC __glewGetUniformiv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVPROC __glewGetVertexAttribPointerv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVPROC __glewGetVertexAttribdv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVPROC __glewGetVertexAttribfv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVPROC __glewGetVertexAttribiv; -GLEW_FUN_EXPORT PFNGLISPROGRAMPROC __glewIsProgram; -GLEW_FUN_EXPORT PFNGLISSHADERPROC __glewIsShader; -GLEW_FUN_EXPORT PFNGLLINKPROGRAMPROC __glewLinkProgram; -GLEW_FUN_EXPORT PFNGLSHADERSOURCEPROC __glewShaderSource; -GLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEPROC __glewStencilFuncSeparate; -GLEW_FUN_EXPORT PFNGLSTENCILMASKSEPARATEPROC __glewStencilMaskSeparate; -GLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEPROC __glewStencilOpSeparate; -GLEW_FUN_EXPORT PFNGLUNIFORM1FPROC __glewUniform1f; -GLEW_FUN_EXPORT PFNGLUNIFORM1FVPROC __glewUniform1fv; -GLEW_FUN_EXPORT PFNGLUNIFORM1IPROC __glewUniform1i; -GLEW_FUN_EXPORT PFNGLUNIFORM1IVPROC __glewUniform1iv; -GLEW_FUN_EXPORT PFNGLUNIFORM2FPROC __glewUniform2f; -GLEW_FUN_EXPORT PFNGLUNIFORM2FVPROC __glewUniform2fv; -GLEW_FUN_EXPORT PFNGLUNIFORM2IPROC __glewUniform2i; -GLEW_FUN_EXPORT PFNGLUNIFORM2IVPROC __glewUniform2iv; -GLEW_FUN_EXPORT PFNGLUNIFORM3FPROC __glewUniform3f; -GLEW_FUN_EXPORT PFNGLUNIFORM3FVPROC __glewUniform3fv; -GLEW_FUN_EXPORT PFNGLUNIFORM3IPROC __glewUniform3i; -GLEW_FUN_EXPORT PFNGLUNIFORM3IVPROC __glewUniform3iv; -GLEW_FUN_EXPORT PFNGLUNIFORM4FPROC __glewUniform4f; -GLEW_FUN_EXPORT PFNGLUNIFORM4FVPROC __glewUniform4fv; -GLEW_FUN_EXPORT PFNGLUNIFORM4IPROC __glewUniform4i; -GLEW_FUN_EXPORT PFNGLUNIFORM4IVPROC __glewUniform4iv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVPROC __glewUniformMatrix2fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVPROC __glewUniformMatrix3fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVPROC __glewUniformMatrix4fv; -GLEW_FUN_EXPORT PFNGLUSEPROGRAMPROC __glewUseProgram; -GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMPROC __glewValidateProgram; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DPROC __glewVertexAttrib1d; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVPROC __glewVertexAttrib1dv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FPROC __glewVertexAttrib1f; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVPROC __glewVertexAttrib1fv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SPROC __glewVertexAttrib1s; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVPROC __glewVertexAttrib1sv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DPROC __glewVertexAttrib2d; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVPROC __glewVertexAttrib2dv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FPROC __glewVertexAttrib2f; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVPROC __glewVertexAttrib2fv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SPROC __glewVertexAttrib2s; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVPROC __glewVertexAttrib2sv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DPROC __glewVertexAttrib3d; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVPROC __glewVertexAttrib3dv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FPROC __glewVertexAttrib3f; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVPROC __glewVertexAttrib3fv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SPROC __glewVertexAttrib3s; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVPROC __glewVertexAttrib3sv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVPROC __glewVertexAttrib4Nbv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVPROC __glewVertexAttrib4Niv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVPROC __glewVertexAttrib4Nsv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBPROC __glewVertexAttrib4Nub; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVPROC __glewVertexAttrib4Nubv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVPROC __glewVertexAttrib4Nuiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVPROC __glewVertexAttrib4Nusv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVPROC __glewVertexAttrib4bv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DPROC __glewVertexAttrib4d; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVPROC __glewVertexAttrib4dv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FPROC __glewVertexAttrib4f; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVPROC __glewVertexAttrib4fv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVPROC __glewVertexAttrib4iv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SPROC __glewVertexAttrib4s; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVPROC __glewVertexAttrib4sv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVPROC __glewVertexAttrib4ubv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVPROC __glewVertexAttrib4uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVPROC __glewVertexAttrib4usv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERPROC __glewVertexAttribPointer; - -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X3FVPROC __glewUniformMatrix2x3fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2X4FVPROC __glewUniformMatrix2x4fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X2FVPROC __glewUniformMatrix3x2fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3X4FVPROC __glewUniformMatrix3x4fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X2FVPROC __glewUniformMatrix4x2fv; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4X3FVPROC __glewUniformMatrix4x3fv; - -GLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERPROC __glewBeginConditionalRender; -GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKPROC __glewBeginTransformFeedback; -GLEW_FUN_EXPORT PFNGLBINDBUFFERBASEPROC __glewBindBufferBase; -GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGEPROC __glewBindBufferRange; -GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONPROC __glewBindFragDataLocation; -GLEW_FUN_EXPORT PFNGLCLAMPCOLORPROC __glewClampColor; -GLEW_FUN_EXPORT PFNGLCLEARBUFFERFIPROC __glewClearBufferfi; -GLEW_FUN_EXPORT PFNGLCLEARBUFFERFVPROC __glewClearBufferfv; -GLEW_FUN_EXPORT PFNGLCLEARBUFFERIVPROC __glewClearBufferiv; -GLEW_FUN_EXPORT PFNGLCLEARBUFFERUIVPROC __glewClearBufferuiv; -GLEW_FUN_EXPORT PFNGLCOLORMASKIPROC __glewColorMaski; -GLEW_FUN_EXPORT PFNGLDISABLEIPROC __glewDisablei; -GLEW_FUN_EXPORT PFNGLENABLEIPROC __glewEnablei; -GLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERPROC __glewEndConditionalRender; -GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKPROC __glewEndTransformFeedback; -GLEW_FUN_EXPORT PFNGLGETBOOLEANI_VPROC __glewGetBooleani_v; -GLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONPROC __glewGetFragDataLocation; -GLEW_FUN_EXPORT PFNGLGETINTEGERI_VPROC __glewGetIntegeri_v; -GLEW_FUN_EXPORT PFNGLGETSTRINGIPROC __glewGetStringi; -GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVPROC __glewGetTexParameterIiv; -GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVPROC __glewGetTexParameterIuiv; -GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGPROC __glewGetTransformFeedbackVarying; -GLEW_FUN_EXPORT PFNGLGETUNIFORMUIVPROC __glewGetUniformuiv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVPROC __glewGetVertexAttribIiv; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVPROC __glewGetVertexAttribIuiv; -GLEW_FUN_EXPORT PFNGLISENABLEDIPROC __glewIsEnabledi; -GLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVPROC __glewTexParameterIiv; -GLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVPROC __glewTexParameterIuiv; -GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSPROC __glewTransformFeedbackVaryings; -GLEW_FUN_EXPORT PFNGLUNIFORM1UIPROC __glewUniform1ui; -GLEW_FUN_EXPORT PFNGLUNIFORM1UIVPROC __glewUniform1uiv; -GLEW_FUN_EXPORT PFNGLUNIFORM2UIPROC __glewUniform2ui; -GLEW_FUN_EXPORT PFNGLUNIFORM2UIVPROC __glewUniform2uiv; -GLEW_FUN_EXPORT PFNGLUNIFORM3UIPROC __glewUniform3ui; -GLEW_FUN_EXPORT PFNGLUNIFORM3UIVPROC __glewUniform3uiv; -GLEW_FUN_EXPORT PFNGLUNIFORM4UIPROC __glewUniform4ui; -GLEW_FUN_EXPORT PFNGLUNIFORM4UIVPROC __glewUniform4uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IPROC __glewVertexAttribI1i; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVPROC __glewVertexAttribI1iv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIPROC __glewVertexAttribI1ui; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVPROC __glewVertexAttribI1uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IPROC __glewVertexAttribI2i; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVPROC __glewVertexAttribI2iv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIPROC __glewVertexAttribI2ui; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVPROC __glewVertexAttribI2uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IPROC __glewVertexAttribI3i; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVPROC __glewVertexAttribI3iv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIPROC __glewVertexAttribI3ui; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVPROC __glewVertexAttribI3uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVPROC __glewVertexAttribI4bv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IPROC __glewVertexAttribI4i; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVPROC __glewVertexAttribI4iv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVPROC __glewVertexAttribI4sv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVPROC __glewVertexAttribI4ubv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIPROC __glewVertexAttribI4ui; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVPROC __glewVertexAttribI4uiv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVPROC __glewVertexAttribI4usv; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTERPROC __glewVertexAttribIPointer; - -GLEW_FUN_EXPORT PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX; - -GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYAPPLEPROC __glewDrawElementArrayAPPLE; -GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC __glewDrawRangeElementArrayAPPLE; -GLEW_FUN_EXPORT PFNGLELEMENTPOINTERAPPLEPROC __glewElementPointerAPPLE; -GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC __glewMultiDrawElementArrayAPPLE; -GLEW_FUN_EXPORT PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC __glewMultiDrawRangeElementArrayAPPLE; - -GLEW_FUN_EXPORT PFNGLDELETEFENCESAPPLEPROC __glewDeleteFencesAPPLE; -GLEW_FUN_EXPORT PFNGLFINISHFENCEAPPLEPROC __glewFinishFenceAPPLE; -GLEW_FUN_EXPORT PFNGLFINISHOBJECTAPPLEPROC __glewFinishObjectAPPLE; -GLEW_FUN_EXPORT PFNGLGENFENCESAPPLEPROC __glewGenFencesAPPLE; -GLEW_FUN_EXPORT PFNGLISFENCEAPPLEPROC __glewIsFenceAPPLE; -GLEW_FUN_EXPORT PFNGLSETFENCEAPPLEPROC __glewSetFenceAPPLE; -GLEW_FUN_EXPORT PFNGLTESTFENCEAPPLEPROC __glewTestFenceAPPLE; -GLEW_FUN_EXPORT PFNGLTESTOBJECTAPPLEPROC __glewTestObjectAPPLE; - -GLEW_FUN_EXPORT PFNGLBUFFERPARAMETERIAPPLEPROC __glewBufferParameteriAPPLE; -GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC __glewFlushMappedBufferRangeAPPLE; - -GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC __glewGetTexParameterPointervAPPLE; -GLEW_FUN_EXPORT PFNGLTEXTURERANGEAPPLEPROC __glewTextureRangeAPPLE; - -GLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYAPPLEPROC __glewBindVertexArrayAPPLE; -GLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSAPPLEPROC __glewDeleteVertexArraysAPPLE; -GLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSAPPLEPROC __glewGenVertexArraysAPPLE; -GLEW_FUN_EXPORT PFNGLISVERTEXARRAYAPPLEPROC __glewIsVertexArrayAPPLE; - -GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC __glewFlushVertexArrayRangeAPPLE; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYPARAMETERIAPPLEPROC __glewVertexArrayParameteriAPPLE; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGEAPPLEPROC __glewVertexArrayRangeAPPLE; - -GLEW_FUN_EXPORT PFNGLCLAMPCOLORARBPROC __glewClampColorARB; - -GLEW_FUN_EXPORT PFNGLDRAWBUFFERSARBPROC __glewDrawBuffersARB; - -GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDARBPROC __glewDrawArraysInstancedARB; -GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDARBPROC __glewDrawElementsInstancedARB; - -GLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFERPROC __glewBindFramebuffer; -GLEW_FUN_EXPORT PFNGLBINDRENDERBUFFERPROC __glewBindRenderbuffer; -GLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFERPROC __glewBlitFramebuffer; -GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus; -GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers; -GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURLAYERPROC __glewFramebufferTexturLayer; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D; -GLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSPROC __glewGenFramebuffers; -GLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSPROC __glewGenRenderbuffers; -GLEW_FUN_EXPORT PFNGLGENERATEMIPMAPPROC __glewGenerateMipmap; -GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC __glewGetFramebufferAttachmentParameteriv; -GLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVPROC __glewGetRenderbufferParameteriv; -GLEW_FUN_EXPORT PFNGLISFRAMEBUFFERPROC __glewIsFramebuffer; -GLEW_FUN_EXPORT PFNGLISRENDERBUFFERPROC __glewIsRenderbuffer; -GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEPROC __glewRenderbufferStorage; -GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC __glewRenderbufferStorageMultisample; - -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREARBPROC __glewFramebufferTextureARB; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEARBPROC __glewFramebufferTextureFaceARB; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYERARBPROC __glewFramebufferTextureLayerARB; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIARBPROC __glewProgramParameteriARB; - -GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEPROC __glewColorSubTable; -GLEW_FUN_EXPORT PFNGLCOLORTABLEPROC __glewColorTable; -GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVPROC __glewColorTableParameterfv; -GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVPROC __glewColorTableParameteriv; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DPROC __glewConvolutionFilter1D; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DPROC __glewConvolutionFilter2D; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFPROC __glewConvolutionParameterf; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVPROC __glewConvolutionParameterfv; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIPROC __glewConvolutionParameteri; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVPROC __glewConvolutionParameteriv; -GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEPROC __glewCopyColorSubTable; -GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLEPROC __glewCopyColorTable; -GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DPROC __glewCopyConvolutionFilter1D; -GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DPROC __glewCopyConvolutionFilter2D; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPROC __glewGetColorTable; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVPROC __glewGetColorTableParameterfv; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVPROC __glewGetColorTableParameteriv; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTERPROC __glewGetConvolutionFilter; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVPROC __glewGetConvolutionParameterfv; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVPROC __glewGetConvolutionParameteriv; -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPROC __glewGetHistogram; -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVPROC __glewGetHistogramParameterfv; -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVPROC __glewGetHistogramParameteriv; -GLEW_FUN_EXPORT PFNGLGETMINMAXPROC __glewGetMinmax; -GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVPROC __glewGetMinmaxParameterfv; -GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVPROC __glewGetMinmaxParameteriv; -GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTERPROC __glewGetSeparableFilter; -GLEW_FUN_EXPORT PFNGLHISTOGRAMPROC __glewHistogram; -GLEW_FUN_EXPORT PFNGLMINMAXPROC __glewMinmax; -GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMPROC __glewResetHistogram; -GLEW_FUN_EXPORT PFNGLRESETMINMAXPROC __glewResetMinmax; -GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DPROC __glewSeparableFilter2D; - -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBDIVISORARBPROC __glewVertexAttribDivisorARB; - -GLEW_FUN_EXPORT PFNGLFLUSHMAPPEDBUFFERRANGEPROC __glewFlushMappedBufferRange; -GLEW_FUN_EXPORT PFNGLMAPBUFFERRANGEPROC __glewMapBufferRange; - -GLEW_FUN_EXPORT PFNGLCURRENTPALETTEMATRIXARBPROC __glewCurrentPaletteMatrixARB; -GLEW_FUN_EXPORT PFNGLMATRIXINDEXPOINTERARBPROC __glewMatrixIndexPointerARB; -GLEW_FUN_EXPORT PFNGLMATRIXINDEXUBVARBPROC __glewMatrixIndexubvARB; -GLEW_FUN_EXPORT PFNGLMATRIXINDEXUIVARBPROC __glewMatrixIndexuivARB; -GLEW_FUN_EXPORT PFNGLMATRIXINDEXUSVARBPROC __glewMatrixIndexusvARB; - -GLEW_FUN_EXPORT PFNGLSAMPLECOVERAGEARBPROC __glewSampleCoverageARB; - -GLEW_FUN_EXPORT PFNGLACTIVETEXTUREARBPROC __glewActiveTextureARB; -GLEW_FUN_EXPORT PFNGLCLIENTACTIVETEXTUREARBPROC __glewClientActiveTextureARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DARBPROC __glewMultiTexCoord1dARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1DVARBPROC __glewMultiTexCoord1dvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FARBPROC __glewMultiTexCoord1fARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1FVARBPROC __glewMultiTexCoord1fvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IARBPROC __glewMultiTexCoord1iARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1IVARBPROC __glewMultiTexCoord1ivARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SARBPROC __glewMultiTexCoord1sARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1SVARBPROC __glewMultiTexCoord1svARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DARBPROC __glewMultiTexCoord2dARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2DVARBPROC __glewMultiTexCoord2dvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FARBPROC __glewMultiTexCoord2fARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2FVARBPROC __glewMultiTexCoord2fvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IARBPROC __glewMultiTexCoord2iARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2IVARBPROC __glewMultiTexCoord2ivARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SARBPROC __glewMultiTexCoord2sARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2SVARBPROC __glewMultiTexCoord2svARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DARBPROC __glewMultiTexCoord3dARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3DVARBPROC __glewMultiTexCoord3dvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FARBPROC __glewMultiTexCoord3fARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3FVARBPROC __glewMultiTexCoord3fvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IARBPROC __glewMultiTexCoord3iARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3IVARBPROC __glewMultiTexCoord3ivARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SARBPROC __glewMultiTexCoord3sARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3SVARBPROC __glewMultiTexCoord3svARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DARBPROC __glewMultiTexCoord4dARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4DVARBPROC __glewMultiTexCoord4dvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FARBPROC __glewMultiTexCoord4fARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4FVARBPROC __glewMultiTexCoord4fvARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IARBPROC __glewMultiTexCoord4iARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4IVARBPROC __glewMultiTexCoord4ivARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SARBPROC __glewMultiTexCoord4sARB; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4SVARBPROC __glewMultiTexCoord4svARB; - -GLEW_FUN_EXPORT PFNGLBEGINQUERYARBPROC __glewBeginQueryARB; -GLEW_FUN_EXPORT PFNGLDELETEQUERIESARBPROC __glewDeleteQueriesARB; -GLEW_FUN_EXPORT PFNGLENDQUERYARBPROC __glewEndQueryARB; -GLEW_FUN_EXPORT PFNGLGENQUERIESARBPROC __glewGenQueriesARB; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTIVARBPROC __glewGetQueryObjectivARB; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUIVARBPROC __glewGetQueryObjectuivARB; -GLEW_FUN_EXPORT PFNGLGETQUERYIVARBPROC __glewGetQueryivARB; -GLEW_FUN_EXPORT PFNGLISQUERYARBPROC __glewIsQueryARB; - -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFARBPROC __glewPointParameterfARB; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVARBPROC __glewPointParameterfvARB; - -GLEW_FUN_EXPORT PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB; -GLEW_FUN_EXPORT PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB; -GLEW_FUN_EXPORT PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB; -GLEW_FUN_EXPORT PFNGLCREATESHADEROBJECTARBPROC __glewCreateShaderObjectARB; -GLEW_FUN_EXPORT PFNGLDELETEOBJECTARBPROC __glewDeleteObjectARB; -GLEW_FUN_EXPORT PFNGLDETACHOBJECTARBPROC __glewDetachObjectARB; -GLEW_FUN_EXPORT PFNGLGETACTIVEUNIFORMARBPROC __glewGetActiveUniformARB; -GLEW_FUN_EXPORT PFNGLGETATTACHEDOBJECTSARBPROC __glewGetAttachedObjectsARB; -GLEW_FUN_EXPORT PFNGLGETHANDLEARBPROC __glewGetHandleARB; -GLEW_FUN_EXPORT PFNGLGETINFOLOGARBPROC __glewGetInfoLogARB; -GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERFVARBPROC __glewGetObjectParameterfvARB; -GLEW_FUN_EXPORT PFNGLGETOBJECTPARAMETERIVARBPROC __glewGetObjectParameterivARB; -GLEW_FUN_EXPORT PFNGLGETSHADERSOURCEARBPROC __glewGetShaderSourceARB; -GLEW_FUN_EXPORT PFNGLGETUNIFORMLOCATIONARBPROC __glewGetUniformLocationARB; -GLEW_FUN_EXPORT PFNGLGETUNIFORMFVARBPROC __glewGetUniformfvARB; -GLEW_FUN_EXPORT PFNGLGETUNIFORMIVARBPROC __glewGetUniformivARB; -GLEW_FUN_EXPORT PFNGLLINKPROGRAMARBPROC __glewLinkProgramARB; -GLEW_FUN_EXPORT PFNGLSHADERSOURCEARBPROC __glewShaderSourceARB; -GLEW_FUN_EXPORT PFNGLUNIFORM1FARBPROC __glewUniform1fARB; -GLEW_FUN_EXPORT PFNGLUNIFORM1FVARBPROC __glewUniform1fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORM1IARBPROC __glewUniform1iARB; -GLEW_FUN_EXPORT PFNGLUNIFORM1IVARBPROC __glewUniform1ivARB; -GLEW_FUN_EXPORT PFNGLUNIFORM2FARBPROC __glewUniform2fARB; -GLEW_FUN_EXPORT PFNGLUNIFORM2FVARBPROC __glewUniform2fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORM2IARBPROC __glewUniform2iARB; -GLEW_FUN_EXPORT PFNGLUNIFORM2IVARBPROC __glewUniform2ivARB; -GLEW_FUN_EXPORT PFNGLUNIFORM3FARBPROC __glewUniform3fARB; -GLEW_FUN_EXPORT PFNGLUNIFORM3FVARBPROC __glewUniform3fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORM3IARBPROC __glewUniform3iARB; -GLEW_FUN_EXPORT PFNGLUNIFORM3IVARBPROC __glewUniform3ivARB; -GLEW_FUN_EXPORT PFNGLUNIFORM4FARBPROC __glewUniform4fARB; -GLEW_FUN_EXPORT PFNGLUNIFORM4FVARBPROC __glewUniform4fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORM4IARBPROC __glewUniform4iARB; -GLEW_FUN_EXPORT PFNGLUNIFORM4IVARBPROC __glewUniform4ivARB; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX2FVARBPROC __glewUniformMatrix2fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX3FVARBPROC __glewUniformMatrix3fvARB; -GLEW_FUN_EXPORT PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB; -GLEW_FUN_EXPORT PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB; -GLEW_FUN_EXPORT PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB; - -GLEW_FUN_EXPORT PFNGLTEXBUFFERARBPROC __glewTexBufferARB; - -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE2DARBPROC __glewCompressedTexImage2DARB; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXIMAGE3DARBPROC __glewCompressedTexImage3DARB; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC __glewCompressedTexSubImage1DARB; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC __glewCompressedTexSubImage2DARB; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC __glewCompressedTexSubImage3DARB; -GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXIMAGEARBPROC __glewGetCompressedTexImageARB; - -GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB; -GLEW_FUN_EXPORT PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB; -GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB; -GLEW_FUN_EXPORT PFNGLMULTTRANSPOSEMATRIXFARBPROC __glewMultTransposeMatrixfARB; - -GLEW_FUN_EXPORT PFNGLBINDVERTEXARRAYPROC __glewBindVertexArray; -GLEW_FUN_EXPORT PFNGLDELETEVERTEXARRAYSPROC __glewDeleteVertexArrays; -GLEW_FUN_EXPORT PFNGLGENVERTEXARRAYSPROC __glewGenVertexArrays; -GLEW_FUN_EXPORT PFNGLISVERTEXARRAYPROC __glewIsVertexArray; - -GLEW_FUN_EXPORT PFNGLVERTEXBLENDARBPROC __glewVertexBlendARB; -GLEW_FUN_EXPORT PFNGLWEIGHTPOINTERARBPROC __glewWeightPointerARB; -GLEW_FUN_EXPORT PFNGLWEIGHTBVARBPROC __glewWeightbvARB; -GLEW_FUN_EXPORT PFNGLWEIGHTDVARBPROC __glewWeightdvARB; -GLEW_FUN_EXPORT PFNGLWEIGHTFVARBPROC __glewWeightfvARB; -GLEW_FUN_EXPORT PFNGLWEIGHTIVARBPROC __glewWeightivARB; -GLEW_FUN_EXPORT PFNGLWEIGHTSVARBPROC __glewWeightsvARB; -GLEW_FUN_EXPORT PFNGLWEIGHTUBVARBPROC __glewWeightubvARB; -GLEW_FUN_EXPORT PFNGLWEIGHTUIVARBPROC __glewWeightuivARB; -GLEW_FUN_EXPORT PFNGLWEIGHTUSVARBPROC __glewWeightusvARB; - -GLEW_FUN_EXPORT PFNGLBINDBUFFERARBPROC __glewBindBufferARB; -GLEW_FUN_EXPORT PFNGLBUFFERDATAARBPROC __glewBufferDataARB; -GLEW_FUN_EXPORT PFNGLBUFFERSUBDATAARBPROC __glewBufferSubDataARB; -GLEW_FUN_EXPORT PFNGLDELETEBUFFERSARBPROC __glewDeleteBuffersARB; -GLEW_FUN_EXPORT PFNGLGENBUFFERSARBPROC __glewGenBuffersARB; -GLEW_FUN_EXPORT PFNGLGETBUFFERPARAMETERIVARBPROC __glewGetBufferParameterivARB; -GLEW_FUN_EXPORT PFNGLGETBUFFERPOINTERVARBPROC __glewGetBufferPointervARB; -GLEW_FUN_EXPORT PFNGLGETBUFFERSUBDATAARBPROC __glewGetBufferSubDataARB; -GLEW_FUN_EXPORT PFNGLISBUFFERARBPROC __glewIsBufferARB; -GLEW_FUN_EXPORT PFNGLMAPBUFFERARBPROC __glewMapBufferARB; -GLEW_FUN_EXPORT PFNGLUNMAPBUFFERARBPROC __glewUnmapBufferARB; - -GLEW_FUN_EXPORT PFNGLBINDPROGRAMARBPROC __glewBindProgramARB; -GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSARBPROC __glewDeleteProgramsARB; -GLEW_FUN_EXPORT PFNGLDISABLEVERTEXATTRIBARRAYARBPROC __glewDisableVertexAttribArrayARB; -GLEW_FUN_EXPORT PFNGLENABLEVERTEXATTRIBARRAYARBPROC __glewEnableVertexAttribArrayARB; -GLEW_FUN_EXPORT PFNGLGENPROGRAMSARBPROC __glewGenProgramsARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERDVARBPROC __glewGetProgramEnvParameterdvARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMENVPARAMETERFVARBPROC __glewGetProgramEnvParameterfvARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC __glewGetProgramLocalParameterdvARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC __glewGetProgramLocalParameterfvARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGARBPROC __glewGetProgramStringARB; -GLEW_FUN_EXPORT PFNGLGETPROGRAMIVARBPROC __glewGetProgramivARB; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVARBPROC __glewGetVertexAttribPointervARB; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVARBPROC __glewGetVertexAttribdvARB; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVARBPROC __glewGetVertexAttribfvARB; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVARBPROC __glewGetVertexAttribivARB; -GLEW_FUN_EXPORT PFNGLISPROGRAMARBPROC __glewIsProgramARB; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DARBPROC __glewProgramEnvParameter4dARB; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4DVARBPROC __glewProgramEnvParameter4dvARB; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FARBPROC __glewProgramEnvParameter4fARB; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETER4FVARBPROC __glewProgramEnvParameter4fvARB; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DARBPROC __glewProgramLocalParameter4dARB; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4DVARBPROC __glewProgramLocalParameter4dvARB; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FARBPROC __glewProgramLocalParameter4fARB; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETER4FVARBPROC __glewProgramLocalParameter4fvARB; -GLEW_FUN_EXPORT PFNGLPROGRAMSTRINGARBPROC __glewProgramStringARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DARBPROC __glewVertexAttrib1dARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVARBPROC __glewVertexAttrib1dvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FARBPROC __glewVertexAttrib1fARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVARBPROC __glewVertexAttrib1fvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SARBPROC __glewVertexAttrib1sARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVARBPROC __glewVertexAttrib1svARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DARBPROC __glewVertexAttrib2dARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVARBPROC __glewVertexAttrib2dvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FARBPROC __glewVertexAttrib2fARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVARBPROC __glewVertexAttrib2fvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SARBPROC __glewVertexAttrib2sARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVARBPROC __glewVertexAttrib2svARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DARBPROC __glewVertexAttrib3dARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVARBPROC __glewVertexAttrib3dvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FARBPROC __glewVertexAttrib3fARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVARBPROC __glewVertexAttrib3fvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SARBPROC __glewVertexAttrib3sARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVARBPROC __glewVertexAttrib3svARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NBVARBPROC __glewVertexAttrib4NbvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NIVARBPROC __glewVertexAttrib4NivARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NSVARBPROC __glewVertexAttrib4NsvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBARBPROC __glewVertexAttrib4NubARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUBVARBPROC __glewVertexAttrib4NubvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUIVARBPROC __glewVertexAttrib4NuivARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4NUSVARBPROC __glewVertexAttrib4NusvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4BVARBPROC __glewVertexAttrib4bvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DARBPROC __glewVertexAttrib4dARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVARBPROC __glewVertexAttrib4dvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FARBPROC __glewVertexAttrib4fARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVARBPROC __glewVertexAttrib4fvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4IVARBPROC __glewVertexAttrib4ivARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SARBPROC __glewVertexAttrib4sARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVARBPROC __glewVertexAttrib4svARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVARBPROC __glewVertexAttrib4ubvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UIVARBPROC __glewVertexAttrib4uivARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4USVARBPROC __glewVertexAttrib4usvARB; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERARBPROC __glewVertexAttribPointerARB; - -GLEW_FUN_EXPORT PFNGLBINDATTRIBLOCATIONARBPROC __glewBindAttribLocationARB; -GLEW_FUN_EXPORT PFNGLGETACTIVEATTRIBARBPROC __glewGetActiveAttribARB; -GLEW_FUN_EXPORT PFNGLGETATTRIBLOCATIONARBPROC __glewGetAttribLocationARB; - -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DARBPROC __glewWindowPos2dARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVARBPROC __glewWindowPos2dvARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FARBPROC __glewWindowPos2fARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVARBPROC __glewWindowPos2fvARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IARBPROC __glewWindowPos2iARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVARBPROC __glewWindowPos2ivARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SARBPROC __glewWindowPos2sARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVARBPROC __glewWindowPos2svARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DARBPROC __glewWindowPos3dARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVARBPROC __glewWindowPos3dvARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FARBPROC __glewWindowPos3fARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVARBPROC __glewWindowPos3fvARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IARBPROC __glewWindowPos3iARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVARBPROC __glewWindowPos3ivARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SARBPROC __glewWindowPos3sARB; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVARBPROC __glewWindowPos3svARB; - -GLEW_FUN_EXPORT PFNGLDRAWBUFFERSATIPROC __glewDrawBuffersATI; - -GLEW_FUN_EXPORT PFNGLDRAWELEMENTARRAYATIPROC __glewDrawElementArrayATI; -GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTARRAYATIPROC __glewDrawRangeElementArrayATI; -GLEW_FUN_EXPORT PFNGLELEMENTPOINTERATIPROC __glewElementPointerATI; - -GLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERFVATIPROC __glewGetTexBumpParameterfvATI; -GLEW_FUN_EXPORT PFNGLGETTEXBUMPPARAMETERIVATIPROC __glewGetTexBumpParameterivATI; -GLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERFVATIPROC __glewTexBumpParameterfvATI; -GLEW_FUN_EXPORT PFNGLTEXBUMPPARAMETERIVATIPROC __glewTexBumpParameterivATI; - -GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP1ATIPROC __glewAlphaFragmentOp1ATI; -GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP2ATIPROC __glewAlphaFragmentOp2ATI; -GLEW_FUN_EXPORT PFNGLALPHAFRAGMENTOP3ATIPROC __glewAlphaFragmentOp3ATI; -GLEW_FUN_EXPORT PFNGLBEGINFRAGMENTSHADERATIPROC __glewBeginFragmentShaderATI; -GLEW_FUN_EXPORT PFNGLBINDFRAGMENTSHADERATIPROC __glewBindFragmentShaderATI; -GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP1ATIPROC __glewColorFragmentOp1ATI; -GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP2ATIPROC __glewColorFragmentOp2ATI; -GLEW_FUN_EXPORT PFNGLCOLORFRAGMENTOP3ATIPROC __glewColorFragmentOp3ATI; -GLEW_FUN_EXPORT PFNGLDELETEFRAGMENTSHADERATIPROC __glewDeleteFragmentShaderATI; -GLEW_FUN_EXPORT PFNGLENDFRAGMENTSHADERATIPROC __glewEndFragmentShaderATI; -GLEW_FUN_EXPORT PFNGLGENFRAGMENTSHADERSATIPROC __glewGenFragmentShadersATI; -GLEW_FUN_EXPORT PFNGLPASSTEXCOORDATIPROC __glewPassTexCoordATI; -GLEW_FUN_EXPORT PFNGLSAMPLEMAPATIPROC __glewSampleMapATI; -GLEW_FUN_EXPORT PFNGLSETFRAGMENTSHADERCONSTANTATIPROC __glewSetFragmentShaderConstantATI; - -GLEW_FUN_EXPORT PFNGLMAPOBJECTBUFFERATIPROC __glewMapObjectBufferATI; -GLEW_FUN_EXPORT PFNGLUNMAPOBJECTBUFFERATIPROC __glewUnmapObjectBufferATI; - -GLEW_FUN_EXPORT PFNGLPNTRIANGLESFATIPROC __glPNTrianglewesfATI; -GLEW_FUN_EXPORT PFNGLPNTRIANGLESIATIPROC __glPNTrianglewesiATI; - -GLEW_FUN_EXPORT PFNGLSTENCILFUNCSEPARATEATIPROC __glewStencilFuncSeparateATI; -GLEW_FUN_EXPORT PFNGLSTENCILOPSEPARATEATIPROC __glewStencilOpSeparateATI; - -GLEW_FUN_EXPORT PFNGLARRAYOBJECTATIPROC __glewArrayObjectATI; -GLEW_FUN_EXPORT PFNGLFREEOBJECTBUFFERATIPROC __glewFreeObjectBufferATI; -GLEW_FUN_EXPORT PFNGLGETARRAYOBJECTFVATIPROC __glewGetArrayObjectfvATI; -GLEW_FUN_EXPORT PFNGLGETARRAYOBJECTIVATIPROC __glewGetArrayObjectivATI; -GLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERFVATIPROC __glewGetObjectBufferfvATI; -GLEW_FUN_EXPORT PFNGLGETOBJECTBUFFERIVATIPROC __glewGetObjectBufferivATI; -GLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTFVATIPROC __glewGetVariantArrayObjectfvATI; -GLEW_FUN_EXPORT PFNGLGETVARIANTARRAYOBJECTIVATIPROC __glewGetVariantArrayObjectivATI; -GLEW_FUN_EXPORT PFNGLISOBJECTBUFFERATIPROC __glewIsObjectBufferATI; -GLEW_FUN_EXPORT PFNGLNEWOBJECTBUFFERATIPROC __glewNewObjectBufferATI; -GLEW_FUN_EXPORT PFNGLUPDATEOBJECTBUFFERATIPROC __glewUpdateObjectBufferATI; -GLEW_FUN_EXPORT PFNGLVARIANTARRAYOBJECTATIPROC __glewVariantArrayObjectATI; - -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC __glewGetVertexAttribArrayObjectfvATI; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC __glewGetVertexAttribArrayObjectivATI; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBARRAYOBJECTATIPROC __glewVertexAttribArrayObjectATI; - -GLEW_FUN_EXPORT PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC __glewClientActiveVertexStreamATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3BATIPROC __glewNormalStream3bATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3BVATIPROC __glewNormalStream3bvATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3DATIPROC __glewNormalStream3dATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3DVATIPROC __glewNormalStream3dvATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3FATIPROC __glewNormalStream3fATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3FVATIPROC __glewNormalStream3fvATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3IATIPROC __glewNormalStream3iATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3IVATIPROC __glewNormalStream3ivATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3SATIPROC __glewNormalStream3sATI; -GLEW_FUN_EXPORT PFNGLNORMALSTREAM3SVATIPROC __glewNormalStream3svATI; -GLEW_FUN_EXPORT PFNGLVERTEXBLENDENVFATIPROC __glewVertexBlendEnvfATI; -GLEW_FUN_EXPORT PFNGLVERTEXBLENDENVIATIPROC __glewVertexBlendEnviATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DATIPROC __glewVertexStream2dATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2DVATIPROC __glewVertexStream2dvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FATIPROC __glewVertexStream2fATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2FVATIPROC __glewVertexStream2fvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IATIPROC __glewVertexStream2iATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2IVATIPROC __glewVertexStream2ivATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SATIPROC __glewVertexStream2sATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM2SVATIPROC __glewVertexStream2svATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DATIPROC __glewVertexStream3dATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3DVATIPROC __glewVertexStream3dvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FATIPROC __glewVertexStream3fATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3FVATIPROC __glewVertexStream3fvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IATIPROC __glewVertexStream3iATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3IVATIPROC __glewVertexStream3ivATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SATIPROC __glewVertexStream3sATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM3SVATIPROC __glewVertexStream3svATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DATIPROC __glewVertexStream4dATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4DVATIPROC __glewVertexStream4dvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FATIPROC __glewVertexStream4fATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4FVATIPROC __glewVertexStream4fvATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IATIPROC __glewVertexStream4iATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4IVATIPROC __glewVertexStream4ivATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SATIPROC __glewVertexStream4sATI; -GLEW_FUN_EXPORT PFNGLVERTEXSTREAM4SVATIPROC __glewVertexStream4svATI; - -GLEW_FUN_EXPORT PFNGLGETUNIFORMBUFFERSIZEEXTPROC __glewGetUniformBufferSizeEXT; -GLEW_FUN_EXPORT PFNGLGETUNIFORMOFFSETEXTPROC __glewGetUniformOffsetEXT; -GLEW_FUN_EXPORT PFNGLUNIFORMBUFFEREXTPROC __glewUniformBufferEXT; - -GLEW_FUN_EXPORT PFNGLBLENDCOLOREXTPROC __glewBlendColorEXT; - -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONSEPARATEEXTPROC __glewBlendEquationSeparateEXT; - -GLEW_FUN_EXPORT PFNGLBLENDFUNCSEPARATEEXTPROC __glewBlendFuncSeparateEXT; - -GLEW_FUN_EXPORT PFNGLBLENDEQUATIONEXTPROC __glewBlendEquationEXT; - -GLEW_FUN_EXPORT PFNGLCOLORSUBTABLEEXTPROC __glewColorSubTableEXT; -GLEW_FUN_EXPORT PFNGLCOPYCOLORSUBTABLEEXTPROC __glewCopyColorSubTableEXT; - -GLEW_FUN_EXPORT PFNGLLOCKARRAYSEXTPROC __glewLockArraysEXT; -GLEW_FUN_EXPORT PFNGLUNLOCKARRAYSEXTPROC __glewUnlockArraysEXT; - -GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER1DEXTPROC __glewConvolutionFilter1DEXT; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONFILTER2DEXTPROC __glewConvolutionFilter2DEXT; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFEXTPROC __glewConvolutionParameterfEXT; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERFVEXTPROC __glewConvolutionParameterfvEXT; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIEXTPROC __glewConvolutionParameteriEXT; -GLEW_FUN_EXPORT PFNGLCONVOLUTIONPARAMETERIVEXTPROC __glewConvolutionParameterivEXT; -GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC __glewCopyConvolutionFilter1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC __glewCopyConvolutionFilter2DEXT; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONFILTEREXTPROC __glewGetConvolutionFilterEXT; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC __glewGetConvolutionParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC __glewGetConvolutionParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETSEPARABLEFILTEREXTPROC __glewGetSeparableFilterEXT; -GLEW_FUN_EXPORT PFNGLSEPARABLEFILTER2DEXTPROC __glewSeparableFilter2DEXT; - -GLEW_FUN_EXPORT PFNGLBINORMALPOINTEREXTPROC __glewBinormalPointerEXT; -GLEW_FUN_EXPORT PFNGLTANGENTPOINTEREXTPROC __glewTangentPointerEXT; - -GLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE1DEXTPROC __glewCopyTexImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXIMAGE2DEXTPROC __glewCopyTexImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE1DEXTPROC __glewCopyTexSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE2DEXTPROC __glewCopyTexSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXSUBIMAGE3DEXTPROC __glewCopyTexSubImage3DEXT; - -GLEW_FUN_EXPORT PFNGLCULLPARAMETERDVEXTPROC __glewCullParameterdvEXT; -GLEW_FUN_EXPORT PFNGLCULLPARAMETERFVEXTPROC __glewCullParameterfvEXT; - -GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSEXTPROC __glewDepthBoundsEXT; - -GLEW_FUN_EXPORT PFNGLBINDMULTITEXTUREEXTPROC __glewBindMultiTextureEXT; -GLEW_FUN_EXPORT PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC __glewCheckNamedFramebufferStatusEXT; -GLEW_FUN_EXPORT PFNGLCLIENTATTRIBDEFAULTEXTPROC __glewClientAttribDefaultEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC __glewCompressedMultiTexImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC __glewCompressedMultiTexImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC __glewCompressedMultiTexImage3DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC __glewCompressedMultiTexSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC __glewCompressedMultiTexSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC __glewCompressedMultiTexSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC __glewCompressedTextureImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC __glewCompressedTextureImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC __glewCompressedTextureImage3DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC __glewCompressedTextureSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC __glewCompressedTextureSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC __glewCompressedTextureSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLCOPYMULTITEXIMAGE1DEXTPROC __glewCopyMultiTexImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYMULTITEXIMAGE2DEXTPROC __glewCopyMultiTexImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC __glewCopyMultiTexSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC __glewCopyMultiTexSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC __glewCopyMultiTexSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXTUREIMAGE1DEXTPROC __glewCopyTextureImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXTUREIMAGE2DEXTPROC __glewCopyTextureImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC __glewCopyTextureSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC __glewCopyTextureSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC __glewCopyTextureSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC __glewDisableClientStateIndexedEXT; -GLEW_FUN_EXPORT PFNGLENABLECLIENTSTATEINDEXEDEXTPROC __glewEnableClientStateIndexedEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC __glewFramebufferDrawBufferEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC __glewFramebufferDrawBuffersEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERREADBUFFEREXTPROC __glewFramebufferReadBufferEXT; -GLEW_FUN_EXPORT PFNGLGENERATEMULTITEXMIPMAPEXTPROC __glewGenerateMultiTexMipmapEXT; -GLEW_FUN_EXPORT PFNGLGENERATETEXTUREMIPMAPEXTPROC __glewGenerateTextureMipmapEXT; -GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC __glewGetCompressedMultiTexImageEXT; -GLEW_FUN_EXPORT PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC __glewGetCompressedTextureImageEXT; -GLEW_FUN_EXPORT PFNGLGETDOUBLEINDEXEDVEXTPROC __glewGetDoubleIndexedvEXT; -GLEW_FUN_EXPORT PFNGLGETFLOATINDEXEDVEXTPROC __glewGetFloatIndexedvEXT; -GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC __glewGetFramebufferParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXENVFVEXTPROC __glewGetMultiTexEnvfvEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXENVIVEXTPROC __glewGetMultiTexEnvivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXGENDVEXTPROC __glewGetMultiTexGendvEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXGENFVEXTPROC __glewGetMultiTexGenfvEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXGENIVEXTPROC __glewGetMultiTexGenivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXIMAGEEXTPROC __glewGetMultiTexImageEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC __glewGetMultiTexLevelParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC __glewGetMultiTexLevelParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIIVEXTPROC __glewGetMultiTexParameterIivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIUIVEXTPROC __glewGetMultiTexParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERFVEXTPROC __glewGetMultiTexParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETMULTITEXPARAMETERIVEXTPROC __glewGetMultiTexParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC __glewGetNamedBufferParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERPOINTERVEXTPROC __glewGetNamedBufferPointervEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDBUFFERSUBDATAEXTPROC __glewGetNamedBufferSubDataEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetNamedFramebufferAttachmentParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC __glewGetNamedProgramLocalParameterIivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC __glewGetNamedProgramLocalParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC __glewGetNamedProgramLocalParameterdvEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC __glewGetNamedProgramLocalParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMSTRINGEXTPROC __glewGetNamedProgramStringEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDPROGRAMIVEXTPROC __glewGetNamedProgramivEXT; -GLEW_FUN_EXPORT PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC __glewGetNamedRenderbufferParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETPOINTERINDEXEDVEXTPROC __glewGetPointerIndexedvEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTUREIMAGEEXTPROC __glewGetTextureImageEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC __glewGetTextureLevelParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC __glewGetTextureLevelParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIIVEXTPROC __glewGetTextureParameterIivEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIUIVEXTPROC __glewGetTextureParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERFVEXTPROC __glewGetTextureParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETTEXTUREPARAMETERIVEXTPROC __glewGetTextureParameterivEXT; -GLEW_FUN_EXPORT PFNGLMAPNAMEDBUFFEREXTPROC __glewMapNamedBufferEXT; -GLEW_FUN_EXPORT PFNGLMATRIXFRUSTUMEXTPROC __glewMatrixFrustumEXT; -GLEW_FUN_EXPORT PFNGLMATRIXLOADIDENTITYEXTPROC __glewMatrixLoadIdentityEXT; -GLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSEDEXTPROC __glewMatrixLoadTransposedEXT; -GLEW_FUN_EXPORT PFNGLMATRIXLOADTRANSPOSEFEXTPROC __glewMatrixLoadTransposefEXT; -GLEW_FUN_EXPORT PFNGLMATRIXLOADDEXTPROC __glewMatrixLoaddEXT; -GLEW_FUN_EXPORT PFNGLMATRIXLOADFEXTPROC __glewMatrixLoadfEXT; -GLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSEDEXTPROC __glewMatrixMultTransposedEXT; -GLEW_FUN_EXPORT PFNGLMATRIXMULTTRANSPOSEFEXTPROC __glewMatrixMultTransposefEXT; -GLEW_FUN_EXPORT PFNGLMATRIXMULTDEXTPROC __glewMatrixMultdEXT; -GLEW_FUN_EXPORT PFNGLMATRIXMULTFEXTPROC __glewMatrixMultfEXT; -GLEW_FUN_EXPORT PFNGLMATRIXORTHOEXTPROC __glewMatrixOrthoEXT; -GLEW_FUN_EXPORT PFNGLMATRIXPOPEXTPROC __glewMatrixPopEXT; -GLEW_FUN_EXPORT PFNGLMATRIXPUSHEXTPROC __glewMatrixPushEXT; -GLEW_FUN_EXPORT PFNGLMATRIXROTATEDEXTPROC __glewMatrixRotatedEXT; -GLEW_FUN_EXPORT PFNGLMATRIXROTATEFEXTPROC __glewMatrixRotatefEXT; -GLEW_FUN_EXPORT PFNGLMATRIXSCALEDEXTPROC __glewMatrixScaledEXT; -GLEW_FUN_EXPORT PFNGLMATRIXSCALEFEXTPROC __glewMatrixScalefEXT; -GLEW_FUN_EXPORT PFNGLMATRIXTRANSLATEDEXTPROC __glewMatrixTranslatedEXT; -GLEW_FUN_EXPORT PFNGLMATRIXTRANSLATEFEXTPROC __glewMatrixTranslatefEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXBUFFEREXTPROC __glewMultiTexBufferEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORDPOINTEREXTPROC __glewMultiTexCoordPointerEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXENVFEXTPROC __glewMultiTexEnvfEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXENVFVEXTPROC __glewMultiTexEnvfvEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXENVIEXTPROC __glewMultiTexEnviEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXENVIVEXTPROC __glewMultiTexEnvivEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENDEXTPROC __glewMultiTexGendEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENDVEXTPROC __glewMultiTexGendvEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENFEXTPROC __glewMultiTexGenfEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENFVEXTPROC __glewMultiTexGenfvEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENIEXTPROC __glewMultiTexGeniEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXGENIVEXTPROC __glewMultiTexGenivEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXIMAGE1DEXTPROC __glewMultiTexImage1DEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXIMAGE2DEXTPROC __glewMultiTexImage2DEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXIMAGE3DEXTPROC __glewMultiTexImage3DEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIIVEXTPROC __glewMultiTexParameterIivEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIUIVEXTPROC __glewMultiTexParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERFEXTPROC __glewMultiTexParameterfEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERFVEXTPROC __glewMultiTexParameterfvEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIEXTPROC __glewMultiTexParameteriEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXPARAMETERIVEXTPROC __glewMultiTexParameterivEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXRENDERBUFFEREXTPROC __glewMultiTexRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE1DEXTPROC __glewMultiTexSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE2DEXTPROC __glewMultiTexSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLMULTITEXSUBIMAGE3DEXTPROC __glewMultiTexSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLNAMEDBUFFERDATAEXTPROC __glewNamedBufferDataEXT; -GLEW_FUN_EXPORT PFNGLNAMEDBUFFERSUBDATAEXTPROC __glewNamedBufferSubDataEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC __glewNamedFramebufferRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC __glewNamedFramebufferTexture1DEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC __glewNamedFramebufferTexture2DEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC __glewNamedFramebufferTexture3DEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC __glewNamedFramebufferTextureEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC __glewNamedFramebufferTextureFaceEXT; -GLEW_FUN_EXPORT PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC __glewNamedFramebufferTextureLayerEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC __glewNamedProgramLocalParameter4dEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC __glewNamedProgramLocalParameter4dvEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC __glewNamedProgramLocalParameter4fEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC __glewNamedProgramLocalParameter4fvEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC __glewNamedProgramLocalParameterI4iEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC __glewNamedProgramLocalParameterI4ivEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC __glewNamedProgramLocalParameterI4uiEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC __glewNamedProgramLocalParameterI4uivEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC __glewNamedProgramLocalParameters4fvEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC __glewNamedProgramLocalParametersI4ivEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC __glewNamedProgramLocalParametersI4uivEXT; -GLEW_FUN_EXPORT PFNGLNAMEDPROGRAMSTRINGEXTPROC __glewNamedProgramStringEXT; -GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC __glewNamedRenderbufferStorageEXT; -GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC __glewNamedRenderbufferStorageMultisampleCoverageEXT; -GLEW_FUN_EXPORT PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewNamedRenderbufferStorageMultisampleEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FEXTPROC __glewProgramUniform1fEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1FVEXTPROC __glewProgramUniform1fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IEXTPROC __glewProgramUniform1iEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1IVEXTPROC __glewProgramUniform1ivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIEXTPROC __glewProgramUniform1uiEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM1UIVEXTPROC __glewProgramUniform1uivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FEXTPROC __glewProgramUniform2fEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2FVEXTPROC __glewProgramUniform2fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IEXTPROC __glewProgramUniform2iEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2IVEXTPROC __glewProgramUniform2ivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIEXTPROC __glewProgramUniform2uiEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM2UIVEXTPROC __glewProgramUniform2uivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FEXTPROC __glewProgramUniform3fEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3FVEXTPROC __glewProgramUniform3fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IEXTPROC __glewProgramUniform3iEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3IVEXTPROC __glewProgramUniform3ivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIEXTPROC __glewProgramUniform3uiEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM3UIVEXTPROC __glewProgramUniform3uivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FEXTPROC __glewProgramUniform4fEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4FVEXTPROC __glewProgramUniform4fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IEXTPROC __glewProgramUniform4iEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4IVEXTPROC __glewProgramUniform4ivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIEXTPROC __glewProgramUniform4uiEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORM4UIVEXTPROC __glewProgramUniform4uivEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC __glewProgramUniformMatrix2fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC __glewProgramUniformMatrix2x3fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC __glewProgramUniformMatrix2x4fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC __glewProgramUniformMatrix3fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC __glewProgramUniformMatrix3x2fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC __glewProgramUniformMatrix3x4fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC __glewProgramUniformMatrix4fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC __glewProgramUniformMatrix4x2fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC __glewProgramUniformMatrix4x3fvEXT; -GLEW_FUN_EXPORT PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC __glewPushClientAttribDefaultEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREBUFFEREXTPROC __glewTextureBufferEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE1DEXTPROC __glewTextureImage1DEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE2DEXTPROC __glewTextureImage2DEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREIMAGE3DEXTPROC __glewTextureImage3DEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIIVEXTPROC __glewTextureParameterIivEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIUIVEXTPROC __glewTextureParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFEXTPROC __glewTextureParameterfEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERFVEXTPROC __glewTextureParameterfvEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIEXTPROC __glewTextureParameteriEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREPARAMETERIVEXTPROC __glewTextureParameterivEXT; -GLEW_FUN_EXPORT PFNGLTEXTURERENDERBUFFEREXTPROC __glewTextureRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE1DEXTPROC __glewTextureSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE2DEXTPROC __glewTextureSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLTEXTURESUBIMAGE3DEXTPROC __glewTextureSubImage3DEXT; -GLEW_FUN_EXPORT PFNGLUNMAPNAMEDBUFFEREXTPROC __glewUnmapNamedBufferEXT; - -GLEW_FUN_EXPORT PFNGLCOLORMASKINDEXEDEXTPROC __glewColorMaskIndexedEXT; -GLEW_FUN_EXPORT PFNGLDISABLEINDEXEDEXTPROC __glewDisableIndexedEXT; -GLEW_FUN_EXPORT PFNGLENABLEINDEXEDEXTPROC __glewEnableIndexedEXT; -GLEW_FUN_EXPORT PFNGLGETBOOLEANINDEXEDVEXTPROC __glewGetBooleanIndexedvEXT; -GLEW_FUN_EXPORT PFNGLGETINTEGERINDEXEDVEXTPROC __glewGetIntegerIndexedvEXT; -GLEW_FUN_EXPORT PFNGLISENABLEDINDEXEDEXTPROC __glewIsEnabledIndexedEXT; - -GLEW_FUN_EXPORT PFNGLDRAWARRAYSINSTANCEDEXTPROC __glewDrawArraysInstancedEXT; -GLEW_FUN_EXPORT PFNGLDRAWELEMENTSINSTANCEDEXTPROC __glewDrawElementsInstancedEXT; - -GLEW_FUN_EXPORT PFNGLDRAWRANGEELEMENTSEXTPROC __glewDrawRangeElementsEXT; - -GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTEREXTPROC __glewFogCoordPointerEXT; -GLEW_FUN_EXPORT PFNGLFOGCOORDDEXTPROC __glewFogCoorddEXT; -GLEW_FUN_EXPORT PFNGLFOGCOORDDVEXTPROC __glewFogCoorddvEXT; -GLEW_FUN_EXPORT PFNGLFOGCOORDFEXTPROC __glewFogCoordfEXT; -GLEW_FUN_EXPORT PFNGLFOGCOORDFVEXTPROC __glewFogCoordfvEXT; - -GLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALEXTPROC __glewFragmentColorMaterialEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFEXTPROC __glewFragmentLightModelfEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVEXTPROC __glewFragmentLightModelfvEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIEXTPROC __glewFragmentLightModeliEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVEXTPROC __glewFragmentLightModelivEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFEXTPROC __glewFragmentLightfEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVEXTPROC __glewFragmentLightfvEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIEXTPROC __glewFragmentLightiEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVEXTPROC __glewFragmentLightivEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFEXTPROC __glewFragmentMaterialfEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVEXTPROC __glewFragmentMaterialfvEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIEXTPROC __glewFragmentMaterialiEXT; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVEXTPROC __glewFragmentMaterialivEXT; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVEXTPROC __glewGetFragmentLightfvEXT; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVEXTPROC __glewGetFragmentLightivEXT; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVEXTPROC __glewGetFragmentMaterialfvEXT; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVEXTPROC __glewGetFragmentMaterialivEXT; -GLEW_FUN_EXPORT PFNGLLIGHTENVIEXTPROC __glewLightEnviEXT; - -GLEW_FUN_EXPORT PFNGLBLITFRAMEBUFFEREXTPROC __glewBlitFramebufferEXT; - -GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewRenderbufferStorageMultisampleEXT; - -GLEW_FUN_EXPORT PFNGLBINDFRAMEBUFFEREXTPROC __glewBindFramebufferEXT; -GLEW_FUN_EXPORT PFNGLBINDRENDERBUFFEREXTPROC __glewBindRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC __glewCheckFramebufferStatusEXT; -GLEW_FUN_EXPORT PFNGLDELETEFRAMEBUFFERSEXTPROC __glewDeleteFramebuffersEXT; -GLEW_FUN_EXPORT PFNGLDELETERENDERBUFFERSEXTPROC __glewDeleteRenderbuffersEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC __glewFramebufferRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE1DEXTPROC __glewFramebufferTexture1DEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE2DEXTPROC __glewFramebufferTexture2DEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURE3DEXTPROC __glewFramebufferTexture3DEXT; -GLEW_FUN_EXPORT PFNGLGENFRAMEBUFFERSEXTPROC __glewGenFramebuffersEXT; -GLEW_FUN_EXPORT PFNGLGENRENDERBUFFERSEXTPROC __glewGenRenderbuffersEXT; -GLEW_FUN_EXPORT PFNGLGENERATEMIPMAPEXTPROC __glewGenerateMipmapEXT; -GLEW_FUN_EXPORT PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetFramebufferAttachmentParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC __glewGetRenderbufferParameterivEXT; -GLEW_FUN_EXPORT PFNGLISFRAMEBUFFEREXTPROC __glewIsFramebufferEXT; -GLEW_FUN_EXPORT PFNGLISRENDERBUFFEREXTPROC __glewIsRenderbufferEXT; -GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEEXTPROC __glewRenderbufferStorageEXT; - -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREEXTPROC __glewFramebufferTextureEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC __glewFramebufferTextureFaceEXT; -GLEW_FUN_EXPORT PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC __glewFramebufferTextureLayerEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERIEXTPROC __glewProgramParameteriEXT; - -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERS4FVEXTPROC __glewProgramEnvParameters4fvEXT; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC __glewProgramLocalParameters4fvEXT; - -GLEW_FUN_EXPORT PFNGLBINDFRAGDATALOCATIONEXTPROC __glewBindFragDataLocationEXT; -GLEW_FUN_EXPORT PFNGLGETFRAGDATALOCATIONEXTPROC __glewGetFragDataLocationEXT; -GLEW_FUN_EXPORT PFNGLGETUNIFORMUIVEXTPROC __glewGetUniformuivEXT; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIIVEXTPROC __glewGetVertexAttribIivEXT; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIUIVEXTPROC __glewGetVertexAttribIuivEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM1UIEXTPROC __glewUniform1uiEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM1UIVEXTPROC __glewUniform1uivEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM2UIEXTPROC __glewUniform2uiEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM2UIVEXTPROC __glewUniform2uivEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM3UIEXTPROC __glewUniform3uiEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM3UIVEXTPROC __glewUniform3uivEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM4UIEXTPROC __glewUniform4uiEXT; -GLEW_FUN_EXPORT PFNGLUNIFORM4UIVEXTPROC __glewUniform4uivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IEXTPROC __glewVertexAttribI1iEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1IVEXTPROC __glewVertexAttribI1ivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIEXTPROC __glewVertexAttribI1uiEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI1UIVEXTPROC __glewVertexAttribI1uivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IEXTPROC __glewVertexAttribI2iEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2IVEXTPROC __glewVertexAttribI2ivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIEXTPROC __glewVertexAttribI2uiEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI2UIVEXTPROC __glewVertexAttribI2uivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IEXTPROC __glewVertexAttribI3iEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3IVEXTPROC __glewVertexAttribI3ivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIEXTPROC __glewVertexAttribI3uiEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI3UIVEXTPROC __glewVertexAttribI3uivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4BVEXTPROC __glewVertexAttribI4bvEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IEXTPROC __glewVertexAttribI4iEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4IVEXTPROC __glewVertexAttribI4ivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4SVEXTPROC __glewVertexAttribI4svEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UBVEXTPROC __glewVertexAttribI4ubvEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIEXTPROC __glewVertexAttribI4uiEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4UIVEXTPROC __glewVertexAttribI4uivEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBI4USVEXTPROC __glewVertexAttribI4usvEXT; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBIPOINTEREXTPROC __glewVertexAttribIPointerEXT; - -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMEXTPROC __glewGetHistogramEXT; -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERFVEXTPROC __glewGetHistogramParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETHISTOGRAMPARAMETERIVEXTPROC __glewGetHistogramParameterivEXT; -GLEW_FUN_EXPORT PFNGLGETMINMAXEXTPROC __glewGetMinmaxEXT; -GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERFVEXTPROC __glewGetMinmaxParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETMINMAXPARAMETERIVEXTPROC __glewGetMinmaxParameterivEXT; -GLEW_FUN_EXPORT PFNGLHISTOGRAMEXTPROC __glewHistogramEXT; -GLEW_FUN_EXPORT PFNGLMINMAXEXTPROC __glewMinmaxEXT; -GLEW_FUN_EXPORT PFNGLRESETHISTOGRAMEXTPROC __glewResetHistogramEXT; -GLEW_FUN_EXPORT PFNGLRESETMINMAXEXTPROC __glewResetMinmaxEXT; - -GLEW_FUN_EXPORT PFNGLINDEXFUNCEXTPROC __glewIndexFuncEXT; - -GLEW_FUN_EXPORT PFNGLINDEXMATERIALEXTPROC __glewIndexMaterialEXT; - -GLEW_FUN_EXPORT PFNGLAPPLYTEXTUREEXTPROC __glewApplyTextureEXT; -GLEW_FUN_EXPORT PFNGLTEXTURELIGHTEXTPROC __glewTextureLightEXT; -GLEW_FUN_EXPORT PFNGLTEXTUREMATERIALEXTPROC __glewTextureMaterialEXT; - -GLEW_FUN_EXPORT PFNGLMULTIDRAWARRAYSEXTPROC __glewMultiDrawArraysEXT; -GLEW_FUN_EXPORT PFNGLMULTIDRAWELEMENTSEXTPROC __glewMultiDrawElementsEXT; - -GLEW_FUN_EXPORT PFNGLSAMPLEMASKEXTPROC __glewSampleMaskEXT; -GLEW_FUN_EXPORT PFNGLSAMPLEPATTERNEXTPROC __glewSamplePatternEXT; - -GLEW_FUN_EXPORT PFNGLCOLORTABLEEXTPROC __glewColorTableEXT; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEEXTPROC __glewGetColorTableEXT; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVEXTPROC __glewGetColorTableParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVEXTPROC __glewGetColorTableParameterivEXT; - -GLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC __glewGetPixelTransformParameterfvEXT; -GLEW_FUN_EXPORT PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC __glewGetPixelTransformParameterivEXT; -GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFEXTPROC __glewPixelTransformParameterfEXT; -GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC __glewPixelTransformParameterfvEXT; -GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIEXTPROC __glewPixelTransformParameteriEXT; -GLEW_FUN_EXPORT PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC __glewPixelTransformParameterivEXT; - -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFEXTPROC __glewPointParameterfEXT; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERFVEXTPROC __glewPointParameterfvEXT; - -GLEW_FUN_EXPORT PFNGLPOLYGONOFFSETEXTPROC __glewPolygonOffsetEXT; - -GLEW_FUN_EXPORT PFNGLBEGINSCENEEXTPROC __glewBeginSceneEXT; -GLEW_FUN_EXPORT PFNGLENDSCENEEXTPROC __glewEndSceneEXT; - -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BEXTPROC __glewSecondaryColor3bEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3BVEXTPROC __glewSecondaryColor3bvEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DEXTPROC __glewSecondaryColor3dEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3DVEXTPROC __glewSecondaryColor3dvEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FEXTPROC __glewSecondaryColor3fEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3FVEXTPROC __glewSecondaryColor3fvEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IEXTPROC __glewSecondaryColor3iEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3IVEXTPROC __glewSecondaryColor3ivEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SEXTPROC __glewSecondaryColor3sEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3SVEXTPROC __glewSecondaryColor3svEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBEXTPROC __glewSecondaryColor3ubEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UBVEXTPROC __glewSecondaryColor3ubvEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIEXTPROC __glewSecondaryColor3uiEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3UIVEXTPROC __glewSecondaryColor3uivEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USEXTPROC __glewSecondaryColor3usEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3USVEXTPROC __glewSecondaryColor3usvEXT; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTEREXTPROC __glewSecondaryColorPointerEXT; - -GLEW_FUN_EXPORT PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT; - -GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT; -GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE2DEXTPROC __glewTexSubImage2DEXT; -GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE3DEXTPROC __glewTexSubImage3DEXT; - -GLEW_FUN_EXPORT PFNGLTEXIMAGE3DEXTPROC __glewTexImage3DEXT; - -GLEW_FUN_EXPORT PFNGLTEXBUFFEREXTPROC __glewTexBufferEXT; - -GLEW_FUN_EXPORT PFNGLCLEARCOLORIIEXTPROC __glewClearColorIiEXT; -GLEW_FUN_EXPORT PFNGLCLEARCOLORIUIEXTPROC __glewClearColorIuiEXT; -GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIIVEXTPROC __glewGetTexParameterIivEXT; -GLEW_FUN_EXPORT PFNGLGETTEXPARAMETERIUIVEXTPROC __glewGetTexParameterIuivEXT; -GLEW_FUN_EXPORT PFNGLTEXPARAMETERIIVEXTPROC __glewTexParameterIivEXT; -GLEW_FUN_EXPORT PFNGLTEXPARAMETERIUIVEXTPROC __glewTexParameterIuivEXT; - -GLEW_FUN_EXPORT PFNGLARETEXTURESRESIDENTEXTPROC __glewAreTexturesResidentEXT; -GLEW_FUN_EXPORT PFNGLBINDTEXTUREEXTPROC __glewBindTextureEXT; -GLEW_FUN_EXPORT PFNGLDELETETEXTURESEXTPROC __glewDeleteTexturesEXT; -GLEW_FUN_EXPORT PFNGLGENTEXTURESEXTPROC __glewGenTexturesEXT; -GLEW_FUN_EXPORT PFNGLISTEXTUREEXTPROC __glewIsTextureEXT; -GLEW_FUN_EXPORT PFNGLPRIORITIZETEXTURESEXTPROC __glewPrioritizeTexturesEXT; - -GLEW_FUN_EXPORT PFNGLTEXTURENORMALEXTPROC __glewTextureNormalEXT; - -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTI64VEXTPROC __glewGetQueryObjecti64vEXT; -GLEW_FUN_EXPORT PFNGLGETQUERYOBJECTUI64VEXTPROC __glewGetQueryObjectui64vEXT; - -GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKEXTPROC __glewBeginTransformFeedbackEXT; -GLEW_FUN_EXPORT PFNGLBINDBUFFERBASEEXTPROC __glewBindBufferBaseEXT; -GLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETEXTPROC __glewBindBufferOffsetEXT; -GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGEEXTPROC __glewBindBufferRangeEXT; -GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKEXTPROC __glewEndTransformFeedbackEXT; -GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC __glewGetTransformFeedbackVaryingEXT; -GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC __glewTransformFeedbackVaryingsEXT; - -GLEW_FUN_EXPORT PFNGLARRAYELEMENTEXTPROC __glewArrayElementEXT; -GLEW_FUN_EXPORT PFNGLCOLORPOINTEREXTPROC __glewColorPointerEXT; -GLEW_FUN_EXPORT PFNGLDRAWARRAYSEXTPROC __glewDrawArraysEXT; -GLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTEREXTPROC __glewEdgeFlagPointerEXT; -GLEW_FUN_EXPORT PFNGLGETPOINTERVEXTPROC __glewGetPointervEXT; -GLEW_FUN_EXPORT PFNGLINDEXPOINTEREXTPROC __glewIndexPointerEXT; -GLEW_FUN_EXPORT PFNGLNORMALPOINTEREXTPROC __glewNormalPointerEXT; -GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTEREXTPROC __glewTexCoordPointerEXT; -GLEW_FUN_EXPORT PFNGLVERTEXPOINTEREXTPROC __glewVertexPointerEXT; - -GLEW_FUN_EXPORT PFNGLBEGINVERTEXSHADEREXTPROC __glewBeginVertexShaderEXT; -GLEW_FUN_EXPORT PFNGLBINDLIGHTPARAMETEREXTPROC __glewBindLightParameterEXT; -GLEW_FUN_EXPORT PFNGLBINDMATERIALPARAMETEREXTPROC __glewBindMaterialParameterEXT; -GLEW_FUN_EXPORT PFNGLBINDPARAMETEREXTPROC __glewBindParameterEXT; -GLEW_FUN_EXPORT PFNGLBINDTEXGENPARAMETEREXTPROC __glewBindTexGenParameterEXT; -GLEW_FUN_EXPORT PFNGLBINDTEXTUREUNITPARAMETEREXTPROC __glewBindTextureUnitParameterEXT; -GLEW_FUN_EXPORT PFNGLBINDVERTEXSHADEREXTPROC __glewBindVertexShaderEXT; -GLEW_FUN_EXPORT PFNGLDELETEVERTEXSHADEREXTPROC __glewDeleteVertexShaderEXT; -GLEW_FUN_EXPORT PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC __glewDisableVariantClientStateEXT; -GLEW_FUN_EXPORT PFNGLENABLEVARIANTCLIENTSTATEEXTPROC __glewEnableVariantClientStateEXT; -GLEW_FUN_EXPORT PFNGLENDVERTEXSHADEREXTPROC __glewEndVertexShaderEXT; -GLEW_FUN_EXPORT PFNGLEXTRACTCOMPONENTEXTPROC __glewExtractComponentEXT; -GLEW_FUN_EXPORT PFNGLGENSYMBOLSEXTPROC __glewGenSymbolsEXT; -GLEW_FUN_EXPORT PFNGLGENVERTEXSHADERSEXTPROC __glewGenVertexShadersEXT; -GLEW_FUN_EXPORT PFNGLGETINVARIANTBOOLEANVEXTPROC __glewGetInvariantBooleanvEXT; -GLEW_FUN_EXPORT PFNGLGETINVARIANTFLOATVEXTPROC __glewGetInvariantFloatvEXT; -GLEW_FUN_EXPORT PFNGLGETINVARIANTINTEGERVEXTPROC __glewGetInvariantIntegervEXT; -GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC __glewGetLocalConstantBooleanvEXT; -GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTFLOATVEXTPROC __glewGetLocalConstantFloatvEXT; -GLEW_FUN_EXPORT PFNGLGETLOCALCONSTANTINTEGERVEXTPROC __glewGetLocalConstantIntegervEXT; -GLEW_FUN_EXPORT PFNGLGETVARIANTBOOLEANVEXTPROC __glewGetVariantBooleanvEXT; -GLEW_FUN_EXPORT PFNGLGETVARIANTFLOATVEXTPROC __glewGetVariantFloatvEXT; -GLEW_FUN_EXPORT PFNGLGETVARIANTINTEGERVEXTPROC __glewGetVariantIntegervEXT; -GLEW_FUN_EXPORT PFNGLGETVARIANTPOINTERVEXTPROC __glewGetVariantPointervEXT; -GLEW_FUN_EXPORT PFNGLINSERTCOMPONENTEXTPROC __glewInsertComponentEXT; -GLEW_FUN_EXPORT PFNGLISVARIANTENABLEDEXTPROC __glewIsVariantEnabledEXT; -GLEW_FUN_EXPORT PFNGLSETINVARIANTEXTPROC __glewSetInvariantEXT; -GLEW_FUN_EXPORT PFNGLSETLOCALCONSTANTEXTPROC __glewSetLocalConstantEXT; -GLEW_FUN_EXPORT PFNGLSHADEROP1EXTPROC __glewShaderOp1EXT; -GLEW_FUN_EXPORT PFNGLSHADEROP2EXTPROC __glewShaderOp2EXT; -GLEW_FUN_EXPORT PFNGLSHADEROP3EXTPROC __glewShaderOp3EXT; -GLEW_FUN_EXPORT PFNGLSWIZZLEEXTPROC __glewSwizzleEXT; -GLEW_FUN_EXPORT PFNGLVARIANTPOINTEREXTPROC __glewVariantPointerEXT; -GLEW_FUN_EXPORT PFNGLVARIANTBVEXTPROC __glewVariantbvEXT; -GLEW_FUN_EXPORT PFNGLVARIANTDVEXTPROC __glewVariantdvEXT; -GLEW_FUN_EXPORT PFNGLVARIANTFVEXTPROC __glewVariantfvEXT; -GLEW_FUN_EXPORT PFNGLVARIANTIVEXTPROC __glewVariantivEXT; -GLEW_FUN_EXPORT PFNGLVARIANTSVEXTPROC __glewVariantsvEXT; -GLEW_FUN_EXPORT PFNGLVARIANTUBVEXTPROC __glewVariantubvEXT; -GLEW_FUN_EXPORT PFNGLVARIANTUIVEXTPROC __glewVariantuivEXT; -GLEW_FUN_EXPORT PFNGLVARIANTUSVEXTPROC __glewVariantusvEXT; -GLEW_FUN_EXPORT PFNGLWRITEMASKEXTPROC __glewWriteMaskEXT; - -GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTPOINTEREXTPROC __glewVertexWeightPointerEXT; -GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFEXTPROC __glewVertexWeightfEXT; -GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTFVEXTPROC __glewVertexWeightfvEXT; - -GLEW_FUN_EXPORT PFNGLFRAMETERMINATORGREMEDYPROC __glewFrameTerminatorGREMEDY; - -GLEW_FUN_EXPORT PFNGLSTRINGMARKERGREMEDYPROC __glewStringMarkerGREMEDY; - -GLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC __glewGetImageTransformParameterfvHP; -GLEW_FUN_EXPORT PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC __glewGetImageTransformParameterivHP; -GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFHPPROC __glewImageTransformParameterfHP; -GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERFVHPPROC __glewImageTransformParameterfvHP; -GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIHPPROC __glewImageTransformParameteriHP; -GLEW_FUN_EXPORT PFNGLIMAGETRANSFORMPARAMETERIVHPPROC __glewImageTransformParameterivHP; - -GLEW_FUN_EXPORT PFNGLMULTIMODEDRAWARRAYSIBMPROC __glewMultiModeDrawArraysIBM; -GLEW_FUN_EXPORT PFNGLMULTIMODEDRAWELEMENTSIBMPROC __glewMultiModeDrawElementsIBM; - -GLEW_FUN_EXPORT PFNGLCOLORPOINTERLISTIBMPROC __glewColorPointerListIBM; -GLEW_FUN_EXPORT PFNGLEDGEFLAGPOINTERLISTIBMPROC __glewEdgeFlagPointerListIBM; -GLEW_FUN_EXPORT PFNGLFOGCOORDPOINTERLISTIBMPROC __glewFogCoordPointerListIBM; -GLEW_FUN_EXPORT PFNGLINDEXPOINTERLISTIBMPROC __glewIndexPointerListIBM; -GLEW_FUN_EXPORT PFNGLNORMALPOINTERLISTIBMPROC __glewNormalPointerListIBM; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLORPOINTERLISTIBMPROC __glewSecondaryColorPointerListIBM; -GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERLISTIBMPROC __glewTexCoordPointerListIBM; -GLEW_FUN_EXPORT PFNGLVERTEXPOINTERLISTIBMPROC __glewVertexPointerListIBM; - -GLEW_FUN_EXPORT PFNGLCOLORPOINTERVINTELPROC __glewColorPointervINTEL; -GLEW_FUN_EXPORT PFNGLNORMALPOINTERVINTELPROC __glewNormalPointervINTEL; -GLEW_FUN_EXPORT PFNGLTEXCOORDPOINTERVINTELPROC __glewTexCoordPointervINTEL; -GLEW_FUN_EXPORT PFNGLVERTEXPOINTERVINTELPROC __glewVertexPointervINTEL; - -GLEW_FUN_EXPORT PFNGLTEXSCISSORFUNCINTELPROC __glewTexScissorFuncINTEL; -GLEW_FUN_EXPORT PFNGLTEXSCISSORINTELPROC __glewTexScissorINTEL; - -GLEW_FUN_EXPORT PFNGLBUFFERREGIONENABLEDEXTPROC __glewBufferRegionEnabledEXT; -GLEW_FUN_EXPORT PFNGLDELETEBUFFERREGIONEXTPROC __glewDeleteBufferRegionEXT; -GLEW_FUN_EXPORT PFNGLDRAWBUFFERREGIONEXTPROC __glewDrawBufferRegionEXT; -GLEW_FUN_EXPORT PFNGLNEWBUFFERREGIONEXTPROC __glewNewBufferRegionEXT; -GLEW_FUN_EXPORT PFNGLREADBUFFERREGIONEXTPROC __glewReadBufferRegionEXT; - -GLEW_FUN_EXPORT PFNGLRESIZEBUFFERSMESAPROC __glewResizeBuffersMESA; - -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DMESAPROC __glewWindowPos2dMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2DVMESAPROC __glewWindowPos2dvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FMESAPROC __glewWindowPos2fMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2FVMESAPROC __glewWindowPos2fvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IMESAPROC __glewWindowPos2iMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2IVMESAPROC __glewWindowPos2ivMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SMESAPROC __glewWindowPos2sMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS2SVMESAPROC __glewWindowPos2svMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DMESAPROC __glewWindowPos3dMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3DVMESAPROC __glewWindowPos3dvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FMESAPROC __glewWindowPos3fMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3FVMESAPROC __glewWindowPos3fvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IMESAPROC __glewWindowPos3iMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3IVMESAPROC __glewWindowPos3ivMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SMESAPROC __glewWindowPos3sMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS3SVMESAPROC __glewWindowPos3svMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4DMESAPROC __glewWindowPos4dMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4DVMESAPROC __glewWindowPos4dvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4FMESAPROC __glewWindowPos4fMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4FVMESAPROC __glewWindowPos4fvMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4IMESAPROC __glewWindowPos4iMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4IVMESAPROC __glewWindowPos4ivMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4SMESAPROC __glewWindowPos4sMESA; -GLEW_FUN_EXPORT PFNGLWINDOWPOS4SVMESAPROC __glewWindowPos4svMESA; - -GLEW_FUN_EXPORT PFNGLBEGINCONDITIONALRENDERNVPROC __glewBeginConditionalRenderNV; -GLEW_FUN_EXPORT PFNGLENDCONDITIONALRENDERNVPROC __glewEndConditionalRenderNV; - -GLEW_FUN_EXPORT PFNGLCLEARDEPTHDNVPROC __glewClearDepthdNV; -GLEW_FUN_EXPORT PFNGLDEPTHBOUNDSDNVPROC __glewDepthBoundsdNV; -GLEW_FUN_EXPORT PFNGLDEPTHRANGEDNVPROC __glewDepthRangedNV; - -GLEW_FUN_EXPORT PFNGLEVALMAPSNVPROC __glewEvalMapsNV; -GLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERFVNVPROC __glewGetMapAttribParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETMAPATTRIBPARAMETERIVNVPROC __glewGetMapAttribParameterivNV; -GLEW_FUN_EXPORT PFNGLGETMAPCONTROLPOINTSNVPROC __glewGetMapControlPointsNV; -GLEW_FUN_EXPORT PFNGLGETMAPPARAMETERFVNVPROC __glewGetMapParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETMAPPARAMETERIVNVPROC __glewGetMapParameterivNV; -GLEW_FUN_EXPORT PFNGLMAPCONTROLPOINTSNVPROC __glewMapControlPointsNV; -GLEW_FUN_EXPORT PFNGLMAPPARAMETERFVNVPROC __glewMapParameterfvNV; -GLEW_FUN_EXPORT PFNGLMAPPARAMETERIVNVPROC __glewMapParameterivNV; - -GLEW_FUN_EXPORT PFNGLGETMULTISAMPLEFVNVPROC __glewGetMultisamplefvNV; -GLEW_FUN_EXPORT PFNGLSAMPLEMASKINDEXEDNVPROC __glewSampleMaskIndexedNV; -GLEW_FUN_EXPORT PFNGLTEXRENDERBUFFERNVPROC __glewTexRenderbufferNV; - -GLEW_FUN_EXPORT PFNGLDELETEFENCESNVPROC __glewDeleteFencesNV; -GLEW_FUN_EXPORT PFNGLFINISHFENCENVPROC __glewFinishFenceNV; -GLEW_FUN_EXPORT PFNGLGENFENCESNVPROC __glewGenFencesNV; -GLEW_FUN_EXPORT PFNGLGETFENCEIVNVPROC __glewGetFenceivNV; -GLEW_FUN_EXPORT PFNGLISFENCENVPROC __glewIsFenceNV; -GLEW_FUN_EXPORT PFNGLSETFENCENVPROC __glewSetFenceNV; -GLEW_FUN_EXPORT PFNGLTESTFENCENVPROC __glewTestFenceNV; - -GLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC __glewGetProgramNamedParameterdvNV; -GLEW_FUN_EXPORT PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC __glewGetProgramNamedParameterfvNV; -GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DNVPROC __glewProgramNamedParameter4dNV; -GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC __glewProgramNamedParameter4dvNV; -GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FNVPROC __glewProgramNamedParameter4fNV; -GLEW_FUN_EXPORT PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC __glewProgramNamedParameter4fvNV; - -GLEW_FUN_EXPORT PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC __glewRenderbufferStorageMultisampleCoverageNV; - -GLEW_FUN_EXPORT PFNGLPROGRAMVERTEXLIMITNVPROC __glewProgramVertexLimitNV; - -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4INVPROC __glewProgramEnvParameterI4iNV; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4IVNVPROC __glewProgramEnvParameterI4ivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UINVPROC __glewProgramEnvParameterI4uiNV; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERI4UIVNVPROC __glewProgramEnvParameterI4uivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4IVNVPROC __glewProgramEnvParametersI4ivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC __glewProgramEnvParametersI4uivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4INVPROC __glewProgramLocalParameterI4iNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC __glewProgramLocalParameterI4ivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UINVPROC __glewProgramLocalParameterI4uiNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC __glewProgramLocalParameterI4uivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC __glewProgramLocalParametersI4ivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC __glewProgramLocalParametersI4uivNV; - -GLEW_FUN_EXPORT PFNGLCOLOR3HNVPROC __glewColor3hNV; -GLEW_FUN_EXPORT PFNGLCOLOR3HVNVPROC __glewColor3hvNV; -GLEW_FUN_EXPORT PFNGLCOLOR4HNVPROC __glewColor4hNV; -GLEW_FUN_EXPORT PFNGLCOLOR4HVNVPROC __glewColor4hvNV; -GLEW_FUN_EXPORT PFNGLFOGCOORDHNVPROC __glewFogCoordhNV; -GLEW_FUN_EXPORT PFNGLFOGCOORDHVNVPROC __glewFogCoordhvNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HNVPROC __glewMultiTexCoord1hNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD1HVNVPROC __glewMultiTexCoord1hvNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HNVPROC __glewMultiTexCoord2hNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD2HVNVPROC __glewMultiTexCoord2hvNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HNVPROC __glewMultiTexCoord3hNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD3HVNVPROC __glewMultiTexCoord3hvNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HNVPROC __glewMultiTexCoord4hNV; -GLEW_FUN_EXPORT PFNGLMULTITEXCOORD4HVNVPROC __glewMultiTexCoord4hvNV; -GLEW_FUN_EXPORT PFNGLNORMAL3HNVPROC __glewNormal3hNV; -GLEW_FUN_EXPORT PFNGLNORMAL3HVNVPROC __glewNormal3hvNV; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HNVPROC __glewSecondaryColor3hNV; -GLEW_FUN_EXPORT PFNGLSECONDARYCOLOR3HVNVPROC __glewSecondaryColor3hvNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD1HNVPROC __glewTexCoord1hNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD1HVNVPROC __glewTexCoord1hvNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD2HNVPROC __glewTexCoord2hNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD2HVNVPROC __glewTexCoord2hvNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD3HNVPROC __glewTexCoord3hNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD3HVNVPROC __glewTexCoord3hvNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD4HNVPROC __glewTexCoord4hNV; -GLEW_FUN_EXPORT PFNGLTEXCOORD4HVNVPROC __glewTexCoord4hvNV; -GLEW_FUN_EXPORT PFNGLVERTEX2HNVPROC __glewVertex2hNV; -GLEW_FUN_EXPORT PFNGLVERTEX2HVNVPROC __glewVertex2hvNV; -GLEW_FUN_EXPORT PFNGLVERTEX3HNVPROC __glewVertex3hNV; -GLEW_FUN_EXPORT PFNGLVERTEX3HVNVPROC __glewVertex3hvNV; -GLEW_FUN_EXPORT PFNGLVERTEX4HNVPROC __glewVertex4hNV; -GLEW_FUN_EXPORT PFNGLVERTEX4HVNVPROC __glewVertex4hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HNVPROC __glewVertexAttrib1hNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1HVNVPROC __glewVertexAttrib1hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HNVPROC __glewVertexAttrib2hNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2HVNVPROC __glewVertexAttrib2hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HNVPROC __glewVertexAttrib3hNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3HVNVPROC __glewVertexAttrib3hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HNVPROC __glewVertexAttrib4hNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4HVNVPROC __glewVertexAttrib4hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1HVNVPROC __glewVertexAttribs1hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2HVNVPROC __glewVertexAttribs2hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3HVNVPROC __glewVertexAttribs3hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4HVNVPROC __glewVertexAttribs4hvNV; -GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHNVPROC __glewVertexWeighthNV; -GLEW_FUN_EXPORT PFNGLVERTEXWEIGHTHVNVPROC __glewVertexWeighthvNV; - -GLEW_FUN_EXPORT PFNGLBEGINOCCLUSIONQUERYNVPROC __glewBeginOcclusionQueryNV; -GLEW_FUN_EXPORT PFNGLDELETEOCCLUSIONQUERIESNVPROC __glewDeleteOcclusionQueriesNV; -GLEW_FUN_EXPORT PFNGLENDOCCLUSIONQUERYNVPROC __glewEndOcclusionQueryNV; -GLEW_FUN_EXPORT PFNGLGENOCCLUSIONQUERIESNVPROC __glewGenOcclusionQueriesNV; -GLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYIVNVPROC __glewGetOcclusionQueryivNV; -GLEW_FUN_EXPORT PFNGLGETOCCLUSIONQUERYUIVNVPROC __glewGetOcclusionQueryuivNV; -GLEW_FUN_EXPORT PFNGLISOCCLUSIONQUERYNVPROC __glewIsOcclusionQueryNV; - -GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC __glewProgramBufferParametersIivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC __glewProgramBufferParametersIuivNV; -GLEW_FUN_EXPORT PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC __glewProgramBufferParametersfvNV; - -GLEW_FUN_EXPORT PFNGLFLUSHPIXELDATARANGENVPROC __glewFlushPixelDataRangeNV; -GLEW_FUN_EXPORT PFNGLPIXELDATARANGENVPROC __glewPixelDataRangeNV; - -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERINVPROC __glewPointParameteriNV; -GLEW_FUN_EXPORT PFNGLPOINTPARAMETERIVNVPROC __glewPointParameterivNV; - -GLEW_FUN_EXPORT PFNGLGETVIDEOI64VNVPROC __glewGetVideoi64vNV; -GLEW_FUN_EXPORT PFNGLGETVIDEOIVNVPROC __glewGetVideoivNV; -GLEW_FUN_EXPORT PFNGLGETVIDEOUI64VNVPROC __glewGetVideoui64vNV; -GLEW_FUN_EXPORT PFNGLGETVIDEOUIVNVPROC __glewGetVideouivNV; -GLEW_FUN_EXPORT PFNGLPRESENTFRAMEDUALFILLNVPROC __glewPresentFrameDualFillNV; -GLEW_FUN_EXPORT PFNGLPRESENTFRAMEKEYEDNVPROC __glewPresentFrameKeyedNV; -GLEW_FUN_EXPORT PFNGLVIDEOPARAMETERIVNVPROC __glewVideoParameterivNV; - -GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTINDEXNVPROC __glewPrimitiveRestartIndexNV; -GLEW_FUN_EXPORT PFNGLPRIMITIVERESTARTNVPROC __glewPrimitiveRestartNV; - -GLEW_FUN_EXPORT PFNGLCOMBINERINPUTNVPROC __glewCombinerInputNV; -GLEW_FUN_EXPORT PFNGLCOMBINEROUTPUTNVPROC __glewCombinerOutputNV; -GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFNVPROC __glewCombinerParameterfNV; -GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERFVNVPROC __glewCombinerParameterfvNV; -GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERINVPROC __glewCombinerParameteriNV; -GLEW_FUN_EXPORT PFNGLCOMBINERPARAMETERIVNVPROC __glewCombinerParameterivNV; -GLEW_FUN_EXPORT PFNGLFINALCOMBINERINPUTNVPROC __glewFinalCombinerInputNV; -GLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC __glewGetCombinerInputParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC __glewGetCombinerInputParameterivNV; -GLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC __glewGetCombinerOutputParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC __glewGetCombinerOutputParameterivNV; -GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC __glewGetFinalCombinerInputParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC __glewGetFinalCombinerInputParameterivNV; - -GLEW_FUN_EXPORT PFNGLCOMBINERSTAGEPARAMETERFVNVPROC __glewCombinerStageParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV; - -GLEW_FUN_EXPORT PFNGLACTIVEVARYINGNVPROC __glewActiveVaryingNV; -GLEW_FUN_EXPORT PFNGLBEGINTRANSFORMFEEDBACKNVPROC __glewBeginTransformFeedbackNV; -GLEW_FUN_EXPORT PFNGLBINDBUFFERBASENVPROC __glewBindBufferBaseNV; -GLEW_FUN_EXPORT PFNGLBINDBUFFEROFFSETNVPROC __glewBindBufferOffsetNV; -GLEW_FUN_EXPORT PFNGLBINDBUFFERRANGENVPROC __glewBindBufferRangeNV; -GLEW_FUN_EXPORT PFNGLENDTRANSFORMFEEDBACKNVPROC __glewEndTransformFeedbackNV; -GLEW_FUN_EXPORT PFNGLGETACTIVEVARYINGNVPROC __glewGetActiveVaryingNV; -GLEW_FUN_EXPORT PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC __glewGetTransformFeedbackVaryingNV; -GLEW_FUN_EXPORT PFNGLGETVARYINGLOCATIONNVPROC __glewGetVaryingLocationNV; -GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC __glewTransformFeedbackAttribsNV; -GLEW_FUN_EXPORT PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC __glewTransformFeedbackVaryingsNV; - -GLEW_FUN_EXPORT PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV; -GLEW_FUN_EXPORT PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV; - -GLEW_FUN_EXPORT PFNGLAREPROGRAMSRESIDENTNVPROC __glewAreProgramsResidentNV; -GLEW_FUN_EXPORT PFNGLBINDPROGRAMNVPROC __glewBindProgramNV; -GLEW_FUN_EXPORT PFNGLDELETEPROGRAMSNVPROC __glewDeleteProgramsNV; -GLEW_FUN_EXPORT PFNGLEXECUTEPROGRAMNVPROC __glewExecuteProgramNV; -GLEW_FUN_EXPORT PFNGLGENPROGRAMSNVPROC __glewGenProgramsNV; -GLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERDVNVPROC __glewGetProgramParameterdvNV; -GLEW_FUN_EXPORT PFNGLGETPROGRAMPARAMETERFVNVPROC __glewGetProgramParameterfvNV; -GLEW_FUN_EXPORT PFNGLGETPROGRAMSTRINGNVPROC __glewGetProgramStringNV; -GLEW_FUN_EXPORT PFNGLGETPROGRAMIVNVPROC __glewGetProgramivNV; -GLEW_FUN_EXPORT PFNGLGETTRACKMATRIXIVNVPROC __glewGetTrackMatrixivNV; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBPOINTERVNVPROC __glewGetVertexAttribPointervNV; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBDVNVPROC __glewGetVertexAttribdvNV; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBFVNVPROC __glewGetVertexAttribfvNV; -GLEW_FUN_EXPORT PFNGLGETVERTEXATTRIBIVNVPROC __glewGetVertexAttribivNV; -GLEW_FUN_EXPORT PFNGLISPROGRAMNVPROC __glewIsProgramNV; -GLEW_FUN_EXPORT PFNGLLOADPROGRAMNVPROC __glewLoadProgramNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DNVPROC __glewProgramParameter4dNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4DVNVPROC __glewProgramParameter4dvNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FNVPROC __glewProgramParameter4fNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETER4FVNVPROC __glewProgramParameter4fvNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4DVNVPROC __glewProgramParameters4dvNV; -GLEW_FUN_EXPORT PFNGLPROGRAMPARAMETERS4FVNVPROC __glewProgramParameters4fvNV; -GLEW_FUN_EXPORT PFNGLREQUESTRESIDENTPROGRAMSNVPROC __glewRequestResidentProgramsNV; -GLEW_FUN_EXPORT PFNGLTRACKMATRIXNVPROC __glewTrackMatrixNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DNVPROC __glewVertexAttrib1dNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1DVNVPROC __glewVertexAttrib1dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FNVPROC __glewVertexAttrib1fNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1FVNVPROC __glewVertexAttrib1fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SNVPROC __glewVertexAttrib1sNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB1SVNVPROC __glewVertexAttrib1svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DNVPROC __glewVertexAttrib2dNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2DVNVPROC __glewVertexAttrib2dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FNVPROC __glewVertexAttrib2fNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2FVNVPROC __glewVertexAttrib2fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SNVPROC __glewVertexAttrib2sNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB2SVNVPROC __glewVertexAttrib2svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DNVPROC __glewVertexAttrib3dNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3DVNVPROC __glewVertexAttrib3dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FNVPROC __glewVertexAttrib3fNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3FVNVPROC __glewVertexAttrib3fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SNVPROC __glewVertexAttrib3sNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB3SVNVPROC __glewVertexAttrib3svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DNVPROC __glewVertexAttrib4dNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4DVNVPROC __glewVertexAttrib4dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FNVPROC __glewVertexAttrib4fNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4FVNVPROC __glewVertexAttrib4fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SNVPROC __glewVertexAttrib4sNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4SVNVPROC __glewVertexAttrib4svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBNVPROC __glewVertexAttrib4ubNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIB4UBVNVPROC __glewVertexAttrib4ubvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBPOINTERNVPROC __glewVertexAttribPointerNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1DVNVPROC __glewVertexAttribs1dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1FVNVPROC __glewVertexAttribs1fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS1SVNVPROC __glewVertexAttribs1svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2DVNVPROC __glewVertexAttribs2dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2FVNVPROC __glewVertexAttribs2fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS2SVNVPROC __glewVertexAttribs2svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3DVNVPROC __glewVertexAttribs3dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3FVNVPROC __glewVertexAttribs3fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS3SVNVPROC __glewVertexAttribs3svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4DVNVPROC __glewVertexAttribs4dvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4FVNVPROC __glewVertexAttribs4fvNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4SVNVPROC __glewVertexAttribs4svNV; -GLEW_FUN_EXPORT PFNGLVERTEXATTRIBS4UBVNVPROC __glewVertexAttribs4ubvNV; - -GLEW_FUN_EXPORT PFNGLCLEARDEPTHFOESPROC __glewClearDepthfOES; -GLEW_FUN_EXPORT PFNGLCLIPPLANEFOESPROC __glewClipPlanefOES; -GLEW_FUN_EXPORT PFNGLDEPTHRANGEFOESPROC __glewDepthRangefOES; -GLEW_FUN_EXPORT PFNGLFRUSTUMFOESPROC __glewFrustumfOES; -GLEW_FUN_EXPORT PFNGLGETCLIPPLANEFOESPROC __glewGetClipPlanefOES; -GLEW_FUN_EXPORT PFNGLORTHOFOESPROC __glewOrthofOES; - -GLEW_FUN_EXPORT PFNGLDETAILTEXFUNCSGISPROC __glewDetailTexFuncSGIS; -GLEW_FUN_EXPORT PFNGLGETDETAILTEXFUNCSGISPROC __glewGetDetailTexFuncSGIS; - -GLEW_FUN_EXPORT PFNGLFOGFUNCSGISPROC __glewFogFuncSGIS; -GLEW_FUN_EXPORT PFNGLGETFOGFUNCSGISPROC __glewGetFogFuncSGIS; - -GLEW_FUN_EXPORT PFNGLSAMPLEMASKSGISPROC __glewSampleMaskSGIS; -GLEW_FUN_EXPORT PFNGLSAMPLEPATTERNSGISPROC __glewSamplePatternSGIS; - -GLEW_FUN_EXPORT PFNGLGETSHARPENTEXFUNCSGISPROC __glewGetSharpenTexFuncSGIS; -GLEW_FUN_EXPORT PFNGLSHARPENTEXFUNCSGISPROC __glewSharpenTexFuncSGIS; - -GLEW_FUN_EXPORT PFNGLTEXIMAGE4DSGISPROC __glewTexImage4DSGIS; -GLEW_FUN_EXPORT PFNGLTEXSUBIMAGE4DSGISPROC __glewTexSubImage4DSGIS; - -GLEW_FUN_EXPORT PFNGLGETTEXFILTERFUNCSGISPROC __glewGetTexFilterFuncSGIS; -GLEW_FUN_EXPORT PFNGLTEXFILTERFUNCSGISPROC __glewTexFilterFuncSGIS; - -GLEW_FUN_EXPORT PFNGLASYNCMARKERSGIXPROC __glewAsyncMarkerSGIX; -GLEW_FUN_EXPORT PFNGLDELETEASYNCMARKERSSGIXPROC __glewDeleteAsyncMarkersSGIX; -GLEW_FUN_EXPORT PFNGLFINISHASYNCSGIXPROC __glewFinishAsyncSGIX; -GLEW_FUN_EXPORT PFNGLGENASYNCMARKERSSGIXPROC __glewGenAsyncMarkersSGIX; -GLEW_FUN_EXPORT PFNGLISASYNCMARKERSGIXPROC __glewIsAsyncMarkerSGIX; -GLEW_FUN_EXPORT PFNGLPOLLASYNCSGIXPROC __glewPollAsyncSGIX; - -GLEW_FUN_EXPORT PFNGLFLUSHRASTERSGIXPROC __glewFlushRasterSGIX; - -GLEW_FUN_EXPORT PFNGLTEXTUREFOGSGIXPROC __glewTextureFogSGIX; - -GLEW_FUN_EXPORT PFNGLFRAGMENTCOLORMATERIALSGIXPROC __glewFragmentColorMaterialSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFSGIXPROC __glewFragmentLightModelfSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELFVSGIXPROC __glewFragmentLightModelfvSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELISGIXPROC __glewFragmentLightModeliSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTMODELIVSGIXPROC __glewFragmentLightModelivSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFSGIXPROC __glewFragmentLightfSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTFVSGIXPROC __glewFragmentLightfvSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTISGIXPROC __glewFragmentLightiSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTLIGHTIVSGIXPROC __glewFragmentLightivSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFSGIXPROC __glewFragmentMaterialfSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALFVSGIXPROC __glewFragmentMaterialfvSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALISGIXPROC __glewFragmentMaterialiSGIX; -GLEW_FUN_EXPORT PFNGLFRAGMENTMATERIALIVSGIXPROC __glewFragmentMaterialivSGIX; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTFVSGIXPROC __glewGetFragmentLightfvSGIX; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTLIGHTIVSGIXPROC __glewGetFragmentLightivSGIX; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALFVSGIXPROC __glewGetFragmentMaterialfvSGIX; -GLEW_FUN_EXPORT PFNGLGETFRAGMENTMATERIALIVSGIXPROC __glewGetFragmentMaterialivSGIX; - -GLEW_FUN_EXPORT PFNGLFRAMEZOOMSGIXPROC __glewFrameZoomSGIX; - -GLEW_FUN_EXPORT PFNGLPIXELTEXGENSGIXPROC __glewPixelTexGenSGIX; - -GLEW_FUN_EXPORT PFNGLREFERENCEPLANESGIXPROC __glewReferencePlaneSGIX; - -GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFSGIXPROC __glewSpriteParameterfSGIX; -GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERFVSGIXPROC __glewSpriteParameterfvSGIX; -GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERISGIXPROC __glewSpriteParameteriSGIX; -GLEW_FUN_EXPORT PFNGLSPRITEPARAMETERIVSGIXPROC __glewSpriteParameterivSGIX; - -GLEW_FUN_EXPORT PFNGLTAGSAMPLEBUFFERSGIXPROC __glewTagSampleBufferSGIX; - -GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERFVSGIPROC __glewColorTableParameterfvSGI; -GLEW_FUN_EXPORT PFNGLCOLORTABLEPARAMETERIVSGIPROC __glewColorTableParameterivSGI; -GLEW_FUN_EXPORT PFNGLCOLORTABLESGIPROC __glewColorTableSGI; -GLEW_FUN_EXPORT PFNGLCOPYCOLORTABLESGIPROC __glewCopyColorTableSGI; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERFVSGIPROC __glewGetColorTableParameterfvSGI; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLEPARAMETERIVSGIPROC __glewGetColorTableParameterivSGI; -GLEW_FUN_EXPORT PFNGLGETCOLORTABLESGIPROC __glewGetColorTableSGI; - -GLEW_FUN_EXPORT PFNGLFINISHTEXTURESUNXPROC __glewFinishTextureSUNX; - -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORBSUNPROC __glewGlobalAlphaFactorbSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORDSUNPROC __glewGlobalAlphaFactordSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORFSUNPROC __glewGlobalAlphaFactorfSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORISUNPROC __glewGlobalAlphaFactoriSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORSSUNPROC __glewGlobalAlphaFactorsSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUBSUNPROC __glewGlobalAlphaFactorubSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUISUNPROC __glewGlobalAlphaFactoruiSUN; -GLEW_FUN_EXPORT PFNGLGLOBALALPHAFACTORUSSUNPROC __glewGlobalAlphaFactorusSUN; - -GLEW_FUN_EXPORT PFNGLREADVIDEOPIXELSSUNPROC __glewReadVideoPixelsSUN; - -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEPOINTERSUNPROC __glewReplacementCodePointerSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBSUNPROC __glewReplacementCodeubSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUBVSUNPROC __glewReplacementCodeubvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUISUNPROC __glewReplacementCodeuiSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVSUNPROC __glewReplacementCodeuivSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSSUNPROC __glewReplacementCodeusSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUSVSUNPROC __glewReplacementCodeusvSUN; - -GLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FSUNPROC __glewColor3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLCOLOR3FVERTEX3FVSUNPROC __glewColor3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewColor4fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewColor4fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FSUNPROC __glewColor4ubVertex2fSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX2FVSUNPROC __glewColor4ubVertex2fvSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FSUNPROC __glewColor4ubVertex3fSUN; -GLEW_FUN_EXPORT PFNGLCOLOR4UBVERTEX3FVSUNPROC __glewColor4ubVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FSUNPROC __glewNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLNORMAL3FVERTEX3FVSUNPROC __glewNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC __glewReplacementCodeuiColor3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC __glewReplacementCodeuiColor4ubVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC __glewReplacementCodeuiColor4ubVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC __glewReplacementCodeuiVertex3fSUN; -GLEW_FUN_EXPORT PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC __glewReplacementCodeuiVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC __glewTexCoord2fColor3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC __glewTexCoord2fColor3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC __glewTexCoord2fColor4ubVertex3fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC __glewTexCoord2fColor4ubVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fNormal3fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fNormal3fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FSUNPROC __glewTexCoord2fVertex3fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD2FVERTEX3FVSUNPROC __glewTexCoord2fVertex3fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fvSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FSUNPROC __glewTexCoord4fVertex4fSUN; -GLEW_FUN_EXPORT PFNGLTEXCOORD4FVERTEX4FVSUNPROC __glewTexCoord4fVertex4fvSUN; - -GLEW_FUN_EXPORT PFNGLADDSWAPHINTRECTWINPROC __glewAddSwapHintRectWIN; - -#if defined(GLEW_MX) && !defined(_WIN32) -struct GLEWContextStruct -{ -#endif /* GLEW_MX */ - -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_1; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_2; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_3; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_4; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_1_5; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_0; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_2_1; -GLEW_VAR_EXPORT GLboolean __GLEW_VERSION_3_0; -GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_tbuffer; -GLEW_VAR_EXPORT GLboolean __GLEW_3DFX_texture_compression_FXT1; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_client_storage; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_element_array; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_fence; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_float_pixels; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_flush_buffer_range; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_pixel_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_specular_vector; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_texture_range; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_transform_hint; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_object; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_vertex_array_range; -GLEW_VAR_EXPORT GLboolean __GLEW_APPLE_ycbcr_422; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_color_buffer_float; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_buffer_float; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_depth_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_buffers; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_draw_instanced; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_program_shadow; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_fragment_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_framebuffer_sRGB; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_geometry_shader4; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_pixel; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_half_float_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_imaging; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_instanced_arrays; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_map_buffer_range; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_matrix_palette; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_multitexture; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_occlusion_query; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_pixel_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_parameters; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_point_sprite; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shader_objects; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shading_language_100; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_shadow_ambient; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_border_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_compression_rgtc; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_cube_map; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_add; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_combine; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_crossbar; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_env_dot3; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_float; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_mirrored_repeat; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_non_power_of_two; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rectangle; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_texture_rg; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_transpose_matrix; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_array_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_blend; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_program; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_vertex_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_ARB_window_pos; -GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_point_sprites; -GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_combine3; -GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_texture_env_route; -GLEW_VAR_EXPORT GLboolean __GLEW_ATIX_vertex_shader_output_point_size; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_draw_buffers; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_element_array; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_envmap_bumpmap; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_fragment_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_map_object_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_pn_triangles; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_separate_stencil; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_shader_texture_lod; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_text_fragment_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_compression_3dc; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_env_combine3; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_float; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_texture_mirror_once; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_array_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_attrib_array_object; -GLEW_VAR_EXPORT GLboolean __GLEW_ATI_vertex_streams; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_422_pixels; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_Cg_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_abgr; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_bgra; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_bindable_uniform; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_color; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_equation_separate; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_func_separate; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_logic_op; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_minmax; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_blend_subtract; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_clip_volume_hint; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_cmyka; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_color_subtable; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_compiled_vertex_array; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_convolution; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_coordinate_frame; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_copy_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_cull_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_depth_bounds_test; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_direct_state_access; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_buffers2; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_instanced; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_draw_range_elements; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_fog_coord; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_fragment_lighting; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_blit; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_framebuffer_sRGB; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_geometry_shader4; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_program_parameters; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_gpu_shader4; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_histogram; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_array_formats; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_func; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_material; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_index_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_light_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_misc_attribute; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_multi_draw_arrays; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_depth_stencil; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_float; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_packed_pixels; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_paletted_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_pixel_transform_color_table; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_point_parameters; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_polygon_offset; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_rescale_normal; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_scene_marker; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_secondary_color; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_separate_specular_color; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shadow_funcs; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_shared_texture_palette; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_clear_tag; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_two_side; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_stencil_wrap; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_subtexture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture3D; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_array; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_dxt1; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_latc; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_rgtc; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_compression_s3tc; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_cube_map; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_edge_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_add; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_combine; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_env_dot3; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_filter_anisotropic; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_integer; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_lod_bias; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_mirror_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_object; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_perturb_normal; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_rectangle; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_sRGB; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_shared_exponent; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_texture_swizzle; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_timer_query; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_transform_feedback; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_array_bgra; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_EXT_vertex_weighting; -GLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_frame_terminator; -GLEW_VAR_EXPORT GLboolean __GLEW_GREMEDY_string_marker; -GLEW_VAR_EXPORT GLboolean __GLEW_HP_convolution_border_modes; -GLEW_VAR_EXPORT GLboolean __GLEW_HP_image_transform; -GLEW_VAR_EXPORT GLboolean __GLEW_HP_occlusion_test; -GLEW_VAR_EXPORT GLboolean __GLEW_HP_texture_lighting; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_cull_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_multimode_draw_arrays; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_rasterpos_clip; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_static_data; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_texture_mirrored_repeat; -GLEW_VAR_EXPORT GLboolean __GLEW_IBM_vertex_array_lists; -GLEW_VAR_EXPORT GLboolean __GLEW_INGR_color_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_INGR_interlace_read; -GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_parallel_arrays; -GLEW_VAR_EXPORT GLboolean __GLEW_INTEL_texture_scissor; -GLEW_VAR_EXPORT GLboolean __GLEW_KTX_buffer_region; -GLEW_VAR_EXPORT GLboolean __GLEW_MESAX_texture_stack; -GLEW_VAR_EXPORT GLboolean __GLEW_MESA_pack_invert; -GLEW_VAR_EXPORT GLboolean __GLEW_MESA_resize_buffers; -GLEW_VAR_EXPORT GLboolean __GLEW_MESA_window_pos; -GLEW_VAR_EXPORT GLboolean __GLEW_MESA_ycbcr_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_blend_square; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_conditional_render; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_copy_depth_to_color; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_buffer_float; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_depth_range_unclamped; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_evaluators; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_explicit_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fence; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_float_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fog_distance; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program4; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_fragment_program_option; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_framebuffer_multisample_coverage; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_program4; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_geometry_shader4; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_gpu_program4; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_half_float; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_light_max_exponent; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_multisample_filter_hint; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_occlusion_query; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_packed_depth_stencil; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_parameter_buffer_object; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_pixel_data_range; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_point_sprite; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_present_video; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_primitive_restart; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_register_combiners2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_emboss; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texgen_reflection; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_compression_vtc; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_env_combine4; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_expand_normal; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_rectangle; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_texture_shader3; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_transform_feedback; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_array_range2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program1_1; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program2_option; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program3; -GLEW_VAR_EXPORT GLboolean __GLEW_NV_vertex_program4; -GLEW_VAR_EXPORT GLboolean __GLEW_OES_byte_coordinates; -GLEW_VAR_EXPORT GLboolean __GLEW_OES_compressed_paletted_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_OES_read_format; -GLEW_VAR_EXPORT GLboolean __GLEW_OES_single_precision; -GLEW_VAR_EXPORT GLboolean __GLEW_OML_interlace; -GLEW_VAR_EXPORT GLboolean __GLEW_OML_resample; -GLEW_VAR_EXPORT GLboolean __GLEW_OML_subsample; -GLEW_VAR_EXPORT GLboolean __GLEW_PGI_misc_hints; -GLEW_VAR_EXPORT GLboolean __GLEW_PGI_vertex_hints; -GLEW_VAR_EXPORT GLboolean __GLEW_REND_screen_coordinates; -GLEW_VAR_EXPORT GLboolean __GLEW_S3_s3tc; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_color_range; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_detail_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_fog_function; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_generate_mipmap; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_multisample; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_pixel_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_point_line_texgen; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_sharpen_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture4D; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_border_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_edge_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_filter4; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_lod; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIS_texture_select; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_histogram; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_async_pixel; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_blend_alpha_minmax; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_clipmap; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_convolution_accuracy; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_depth_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_flush_raster; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_offset; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fog_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_fragment_specular_lighting; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_framezoom; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_interlace; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ir_instrument1; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_list_priority; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_pixel_texture_bits; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_reference_plane; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_resample; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_shadow_ambient; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_sprite; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_tag_sample_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_add_env; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_coordinate_clamp; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_lod_bias; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_multi_buffer; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_range; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_texture_scale_bias; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_vertex_preclip_hint; -GLEW_VAR_EXPORT GLboolean __GLEW_SGIX_ycrcb; -GLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_matrix; -GLEW_VAR_EXPORT GLboolean __GLEW_SGI_color_table; -GLEW_VAR_EXPORT GLboolean __GLEW_SGI_texture_color_table; -GLEW_VAR_EXPORT GLboolean __GLEW_SUNX_constant_data; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_convolution_border_modes; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_global_alpha; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_mesh_array; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_read_video_pixels; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_slice_accum; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_triangle_list; -GLEW_VAR_EXPORT GLboolean __GLEW_SUN_vertex; -GLEW_VAR_EXPORT GLboolean __GLEW_WIN_phong_shading; -GLEW_VAR_EXPORT GLboolean __GLEW_WIN_specular_fog; -GLEW_VAR_EXPORT GLboolean __GLEW_WIN_swap_hint; - -#ifdef GLEW_MX -}; /* GLEWContextStruct */ -#endif /* GLEW_MX */ - -/* ------------------------------------------------------------------------- */ - -/* error codes */ -#define GLEW_OK 0 -#define GLEW_NO_ERROR 0 -#define GLEW_ERROR_NO_GL_VERSION 1 /* missing GL version */ -#define GLEW_ERROR_GL_VERSION_10_ONLY 2 /* GL 1.1 and up are not supported */ -#define GLEW_ERROR_GLX_VERSION_11_ONLY 3 /* GLX 1.2 and up are not supported */ - -/* string codes */ -#define GLEW_VERSION 1 -#define GLEW_VERSION_MAJOR 2 -#define GLEW_VERSION_MINOR 3 -#define GLEW_VERSION_MICRO 4 - -/* API */ -#ifdef GLEW_MX - -typedef struct GLEWContextStruct GLEWContext; -GLEWAPI GLenum glewContextInit (GLEWContext* ctx); -GLEWAPI GLboolean glewContextIsSupported (GLEWContext* ctx, const char* name); - -#define glewInit() glewContextInit(glewGetContext()) -#define glewIsSupported(x) glewContextIsSupported(glewGetContext(), x) -#define glewIsExtensionSupported(x) glewIsSupported(x) - -#define GLEW_GET_VAR(x) (*(const GLboolean*)&(glewGetContext()->x)) -#ifdef _WIN32 -# define GLEW_GET_FUN(x) glewGetContext()->x -#else -# define GLEW_GET_FUN(x) x -#endif - -#else /* GLEW_MX */ - -GLEWAPI GLenum glewInit (); -GLEWAPI GLboolean glewIsSupported (const char* name); -#define glewIsExtensionSupported(x) glewIsSupported(x) - -#define GLEW_GET_VAR(x) (*(const GLboolean*)&x) -#define GLEW_GET_FUN(x) x - -#endif /* GLEW_MX */ - -GLEWAPI GLboolean glewExperimental; -GLEWAPI GLboolean glewGetExtension (const char* name); -GLEWAPI const GLubyte* glewGetErrorString (GLenum error); -GLEWAPI const GLubyte* glewGetString (GLenum name); - -#ifdef __cplusplus -} -#endif - -#ifdef GLEW_APIENTRY_DEFINED -#undef GLEW_APIENTRY_DEFINED -#undef APIENTRY -#undef GLAPIENTRY -#endif - -#ifdef GLEW_CALLBACK_DEFINED -#undef GLEW_CALLBACK_DEFINED -#undef CALLBACK -#endif - -#ifdef GLEW_WINGDIAPI_DEFINED -#undef GLEW_WINGDIAPI_DEFINED -#undef WINGDIAPI -#endif - -#undef GLAPI -/* #undef GLEWAPI */ - -#endif /* __glew_h__ */ diff --git a/oversampling/WDL/lice/glew/include/GL/glxew.h b/oversampling/WDL/lice/glew/include/GL/glxew.h deleted file mode 100644 index a29030d..0000000 --- a/oversampling/WDL/lice/glew/include/GL/glxew.h +++ /dev/null @@ -1,1397 +0,0 @@ -/* -** The OpenGL Extension Wrangler Library -** Copyright (C) 2002-2008, Milan Ikits -** Copyright (C) 2002-2008, Marcelo E. Magallon -** Copyright (C) 2002, Lev Povalahev -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** -** * Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** * The name of the author may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -** THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - * Mesa 3-D graphics library - * Version: 7.0 - * - * Copyright (C) 1999-2007 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 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are 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 Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#ifndef __glxew_h__ -#define __glxew_h__ -#define __GLXEW_H__ - -#ifdef __glxext_h_ -#error glxext.h included before glxew.h -#endif -#ifdef GLX_H -#error glx.h included before glxew.h -#endif - -#define __glxext_h_ -#define __GLX_glx_h__ -#define GLX_H - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* ---------------------------- GLX_VERSION_1_0 --------------------------- */ - -#ifndef GLX_VERSION_1_0 -#define GLX_VERSION_1_0 1 - -#define GLX_USE_GL 1 -#define GLX_BUFFER_SIZE 2 -#define GLX_LEVEL 3 -#define GLX_RGBA 4 -#define GLX_DOUBLEBUFFER 5 -#define GLX_STEREO 6 -#define GLX_AUX_BUFFERS 7 -#define GLX_RED_SIZE 8 -#define GLX_GREEN_SIZE 9 -#define GLX_BLUE_SIZE 10 -#define GLX_ALPHA_SIZE 11 -#define GLX_DEPTH_SIZE 12 -#define GLX_STENCIL_SIZE 13 -#define GLX_ACCUM_RED_SIZE 14 -#define GLX_ACCUM_GREEN_SIZE 15 -#define GLX_ACCUM_BLUE_SIZE 16 -#define GLX_ACCUM_ALPHA_SIZE 17 -#define GLX_BAD_SCREEN 1 -#define GLX_BAD_ATTRIBUTE 2 -#define GLX_NO_EXTENSION 3 -#define GLX_BAD_VISUAL 4 -#define GLX_BAD_CONTEXT 5 -#define GLX_BAD_VALUE 6 -#define GLX_BAD_ENUM 7 - -typedef XID GLXDrawable; -typedef XID GLXPixmap; -#ifdef __sun -typedef struct __glXContextRec *GLXContext; -#else -typedef struct __GLXcontextRec *GLXContext; -#endif - -typedef unsigned int GLXVideoDeviceNV; - -extern Bool glXQueryExtension (Display *dpy, int *errorBase, int *eventBase); -extern Bool glXQueryVersion (Display *dpy, int *major, int *minor); -extern int glXGetConfig (Display *dpy, XVisualInfo *vis, int attrib, int *value); -extern XVisualInfo* glXChooseVisual (Display *dpy, int screen, int *attribList); -extern GLXPixmap glXCreateGLXPixmap (Display *dpy, XVisualInfo *vis, Pixmap pixmap); -extern void glXDestroyGLXPixmap (Display *dpy, GLXPixmap pix); -extern GLXContext glXCreateContext (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct); -extern void glXDestroyContext (Display *dpy, GLXContext ctx); -extern Bool glXIsDirect (Display *dpy, GLXContext ctx); -extern void glXCopyContext (Display *dpy, GLXContext src, GLXContext dst, GLulong mask); -extern Bool glXMakeCurrent (Display *dpy, GLXDrawable drawable, GLXContext ctx); -extern GLXContext glXGetCurrentContext (void); -extern GLXDrawable glXGetCurrentDrawable (void); -extern void glXWaitGL (void); -extern void glXWaitX (void); -extern void glXSwapBuffers (Display *dpy, GLXDrawable drawable); -extern void glXUseXFont (Font font, int first, int count, int listBase); - -#define GLXEW_VERSION_1_0 GLXEW_GET_VAR(__GLXEW_VERSION_1_0) - -#endif /* GLX_VERSION_1_0 */ - -/* ---------------------------- GLX_VERSION_1_1 --------------------------- */ - -#ifndef GLX_VERSION_1_1 -#define GLX_VERSION_1_1 - -#define GLX_VENDOR 0x1 -#define GLX_VERSION 0x2 -#define GLX_EXTENSIONS 0x3 - -extern const char* glXQueryExtensionsString (Display *dpy, int screen); -extern const char* glXGetClientString (Display *dpy, int name); -extern const char* glXQueryServerString (Display *dpy, int screen, int name); - -#define GLXEW_VERSION_1_1 GLXEW_GET_VAR(__GLXEW_VERSION_1_1) - -#endif /* GLX_VERSION_1_1 */ - -/* ---------------------------- GLX_VERSION_1_2 ---------------------------- */ - -#ifndef GLX_VERSION_1_2 -#define GLX_VERSION_1_2 1 - -typedef Display* ( * PFNGLXGETCURRENTDISPLAYPROC) (void); - -#define glXGetCurrentDisplay GLXEW_GET_FUN(__glewXGetCurrentDisplay) - -#define GLXEW_VERSION_1_2 GLXEW_GET_VAR(__GLXEW_VERSION_1_2) - -#endif /* GLX_VERSION_1_2 */ - -/* ---------------------------- GLX_VERSION_1_3 ---------------------------- */ - -#ifndef GLX_VERSION_1_3 -#define GLX_VERSION_1_3 1 - -#define GLX_RGBA_BIT 0x00000001 -#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 -#define GLX_WINDOW_BIT 0x00000001 -#define GLX_COLOR_INDEX_BIT 0x00000002 -#define GLX_PIXMAP_BIT 0x00000002 -#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 -#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 -#define GLX_PBUFFER_BIT 0x00000004 -#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 -#define GLX_AUX_BUFFERS_BIT 0x00000010 -#define GLX_CONFIG_CAVEAT 0x20 -#define GLX_DEPTH_BUFFER_BIT 0x00000020 -#define GLX_X_VISUAL_TYPE 0x22 -#define GLX_TRANSPARENT_TYPE 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE 0x24 -#define GLX_TRANSPARENT_RED_VALUE 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE 0x28 -#define GLX_STENCIL_BUFFER_BIT 0x00000040 -#define GLX_ACCUM_BUFFER_BIT 0x00000080 -#define GLX_NONE 0x8000 -#define GLX_SLOW_CONFIG 0x8001 -#define GLX_TRUE_COLOR 0x8002 -#define GLX_DIRECT_COLOR 0x8003 -#define GLX_PSEUDO_COLOR 0x8004 -#define GLX_STATIC_COLOR 0x8005 -#define GLX_GRAY_SCALE 0x8006 -#define GLX_STATIC_GRAY 0x8007 -#define GLX_TRANSPARENT_RGB 0x8008 -#define GLX_TRANSPARENT_INDEX 0x8009 -#define GLX_VISUAL_ID 0x800B -#define GLX_SCREEN 0x800C -#define GLX_NON_CONFORMANT_CONFIG 0x800D -#define GLX_DRAWABLE_TYPE 0x8010 -#define GLX_RENDER_TYPE 0x8011 -#define GLX_X_RENDERABLE 0x8012 -#define GLX_FBCONFIG_ID 0x8013 -#define GLX_RGBA_TYPE 0x8014 -#define GLX_COLOR_INDEX_TYPE 0x8015 -#define GLX_MAX_PBUFFER_WIDTH 0x8016 -#define GLX_MAX_PBUFFER_HEIGHT 0x8017 -#define GLX_MAX_PBUFFER_PIXELS 0x8018 -#define GLX_PRESERVED_CONTENTS 0x801B -#define GLX_LARGEST_PBUFFER 0x801C -#define GLX_WIDTH 0x801D -#define GLX_HEIGHT 0x801E -#define GLX_EVENT_MASK 0x801F -#define GLX_DAMAGED 0x8020 -#define GLX_SAVED 0x8021 -#define GLX_WINDOW 0x8022 -#define GLX_PBUFFER 0x8023 -#define GLX_PBUFFER_HEIGHT 0x8040 -#define GLX_PBUFFER_WIDTH 0x8041 -#define GLX_PBUFFER_CLOBBER_MASK 0x08000000 -#define GLX_DONT_CARE 0xFFFFFFFF - -typedef XID GLXFBConfigID; -typedef XID GLXWindow; -typedef XID GLXPbuffer; -typedef struct __GLXFBConfigRec *GLXFBConfig; - -typedef struct { - int event_type; - int draw_type; - unsigned long serial; - Bool send_event; - Display *display; - GLXDrawable drawable; - unsigned int buffer_mask; - unsigned int aux_buffer; - int x, y; - int width, height; - int count; -} GLXPbufferClobberEvent; -typedef union __GLXEvent { - GLXPbufferClobberEvent glxpbufferclobber; - long pad[24]; -} GLXEvent; - -typedef GLXFBConfig* ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); -typedef GLXContext ( * PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); -typedef GLXPbuffer ( * PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list); -typedef GLXPixmap ( * PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); -typedef GLXWindow ( * PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); -typedef void ( * PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf); -typedef void ( * PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap); -typedef void ( * PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win); -typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLEPROC) (void); -typedef int ( * PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value); -typedef GLXFBConfig* ( * PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements); -typedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask); -typedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config); -typedef Bool ( * PFNGLXMAKECONTEXTCURRENTPROC) (Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx); -typedef int ( * PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value); -typedef void ( * PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); -typedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask); - -#define glXChooseFBConfig GLXEW_GET_FUN(__glewXChooseFBConfig) -#define glXCreateNewContext GLXEW_GET_FUN(__glewXCreateNewContext) -#define glXCreatePbuffer GLXEW_GET_FUN(__glewXCreatePbuffer) -#define glXCreatePixmap GLXEW_GET_FUN(__glewXCreatePixmap) -#define glXCreateWindow GLXEW_GET_FUN(__glewXCreateWindow) -#define glXDestroyPbuffer GLXEW_GET_FUN(__glewXDestroyPbuffer) -#define glXDestroyPixmap GLXEW_GET_FUN(__glewXDestroyPixmap) -#define glXDestroyWindow GLXEW_GET_FUN(__glewXDestroyWindow) -#define glXGetCurrentReadDrawable GLXEW_GET_FUN(__glewXGetCurrentReadDrawable) -#define glXGetFBConfigAttrib GLXEW_GET_FUN(__glewXGetFBConfigAttrib) -#define glXGetFBConfigs GLXEW_GET_FUN(__glewXGetFBConfigs) -#define glXGetSelectedEvent GLXEW_GET_FUN(__glewXGetSelectedEvent) -#define glXGetVisualFromFBConfig GLXEW_GET_FUN(__glewXGetVisualFromFBConfig) -#define glXMakeContextCurrent GLXEW_GET_FUN(__glewXMakeContextCurrent) -#define glXQueryContext GLXEW_GET_FUN(__glewXQueryContext) -#define glXQueryDrawable GLXEW_GET_FUN(__glewXQueryDrawable) -#define glXSelectEvent GLXEW_GET_FUN(__glewXSelectEvent) - -#define GLXEW_VERSION_1_3 GLXEW_GET_VAR(__GLXEW_VERSION_1_3) - -#endif /* GLX_VERSION_1_3 */ - -/* ---------------------------- GLX_VERSION_1_4 ---------------------------- */ - -#ifndef GLX_VERSION_1_4 -#define GLX_VERSION_1_4 1 - -#define GLX_SAMPLE_BUFFERS 100000 -#define GLX_SAMPLES 100001 - -extern void ( * glXGetProcAddress (const GLubyte *procName)) (void); - -#define GLXEW_VERSION_1_4 GLXEW_GET_VAR(__GLXEW_VERSION_1_4) - -#endif /* GLX_VERSION_1_4 */ - -/* -------------------------- GLX_3DFX_multisample ------------------------- */ - -#ifndef GLX_3DFX_multisample -#define GLX_3DFX_multisample 1 - -#define GLX_SAMPLE_BUFFERS_3DFX 0x8050 -#define GLX_SAMPLES_3DFX 0x8051 - -#define GLXEW_3DFX_multisample GLXEW_GET_VAR(__GLXEW_3DFX_multisample) - -#endif /* GLX_3DFX_multisample */ - -/* ------------------------- GLX_ARB_create_context ------------------------ */ - -#ifndef GLX_ARB_create_context -#define GLX_ARB_create_context 1 - -#define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001 -#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 -#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define GLX_CONTEXT_FLAGS_ARB 0x2094 - -typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); - -#define glXCreateContextAttribsARB GLXEW_GET_FUN(__glewXCreateContextAttribsARB) - -#define GLXEW_ARB_create_context GLXEW_GET_VAR(__GLXEW_ARB_create_context) - -#endif /* GLX_ARB_create_context */ - -/* ------------------------- GLX_ARB_fbconfig_float ------------------------ */ - -#ifndef GLX_ARB_fbconfig_float -#define GLX_ARB_fbconfig_float 1 - -#define GLX_RGBA_FLOAT_BIT 0x00000004 -#define GLX_RGBA_FLOAT_TYPE 0x20B9 - -#define GLXEW_ARB_fbconfig_float GLXEW_GET_VAR(__GLXEW_ARB_fbconfig_float) - -#endif /* GLX_ARB_fbconfig_float */ - -/* ------------------------ GLX_ARB_framebuffer_sRGB ----------------------- */ - -#ifndef GLX_ARB_framebuffer_sRGB -#define GLX_ARB_framebuffer_sRGB 1 - -#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 - -#define GLXEW_ARB_framebuffer_sRGB GLXEW_GET_VAR(__GLXEW_ARB_framebuffer_sRGB) - -#endif /* GLX_ARB_framebuffer_sRGB */ - -/* ------------------------ GLX_ARB_get_proc_address ----------------------- */ - -#ifndef GLX_ARB_get_proc_address -#define GLX_ARB_get_proc_address 1 - -extern void ( * glXGetProcAddressARB (const GLubyte *procName)) (void); - -#define GLXEW_ARB_get_proc_address GLXEW_GET_VAR(__GLXEW_ARB_get_proc_address) - -#endif /* GLX_ARB_get_proc_address */ - -/* -------------------------- GLX_ARB_multisample -------------------------- */ - -#ifndef GLX_ARB_multisample -#define GLX_ARB_multisample 1 - -#define GLX_SAMPLE_BUFFERS_ARB 100000 -#define GLX_SAMPLES_ARB 100001 - -#define GLXEW_ARB_multisample GLXEW_GET_VAR(__GLXEW_ARB_multisample) - -#endif /* GLX_ARB_multisample */ - -/* ----------------------- GLX_ATI_pixel_format_float ---------------------- */ - -#ifndef GLX_ATI_pixel_format_float -#define GLX_ATI_pixel_format_float 1 - -#define GLX_RGBA_FLOAT_ATI_BIT 0x00000100 - -#define GLXEW_ATI_pixel_format_float GLXEW_GET_VAR(__GLXEW_ATI_pixel_format_float) - -#endif /* GLX_ATI_pixel_format_float */ - -/* ------------------------- GLX_ATI_render_texture ------------------------ */ - -#ifndef GLX_ATI_render_texture -#define GLX_ATI_render_texture 1 - -#define GLX_BIND_TO_TEXTURE_RGB_ATI 0x9800 -#define GLX_BIND_TO_TEXTURE_RGBA_ATI 0x9801 -#define GLX_TEXTURE_FORMAT_ATI 0x9802 -#define GLX_TEXTURE_TARGET_ATI 0x9803 -#define GLX_MIPMAP_TEXTURE_ATI 0x9804 -#define GLX_TEXTURE_RGB_ATI 0x9805 -#define GLX_TEXTURE_RGBA_ATI 0x9806 -#define GLX_NO_TEXTURE_ATI 0x9807 -#define GLX_TEXTURE_CUBE_MAP_ATI 0x9808 -#define GLX_TEXTURE_1D_ATI 0x9809 -#define GLX_TEXTURE_2D_ATI 0x980A -#define GLX_MIPMAP_LEVEL_ATI 0x980B -#define GLX_CUBE_MAP_FACE_ATI 0x980C -#define GLX_TEXTURE_CUBE_MAP_POSITIVE_X_ATI 0x980D -#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_X_ATI 0x980E -#define GLX_TEXTURE_CUBE_MAP_POSITIVE_Y_ATI 0x980F -#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Y_ATI 0x9810 -#define GLX_TEXTURE_CUBE_MAP_POSITIVE_Z_ATI 0x9811 -#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Z_ATI 0x9812 -#define GLX_FRONT_LEFT_ATI 0x9813 -#define GLX_FRONT_RIGHT_ATI 0x9814 -#define GLX_BACK_LEFT_ATI 0x9815 -#define GLX_BACK_RIGHT_ATI 0x9816 -#define GLX_AUX0_ATI 0x9817 -#define GLX_AUX1_ATI 0x9818 -#define GLX_AUX2_ATI 0x9819 -#define GLX_AUX3_ATI 0x981A -#define GLX_AUX4_ATI 0x981B -#define GLX_AUX5_ATI 0x981C -#define GLX_AUX6_ATI 0x981D -#define GLX_AUX7_ATI 0x981E -#define GLX_AUX8_ATI 0x981F -#define GLX_AUX9_ATI 0x9820 -#define GLX_BIND_TO_TEXTURE_LUMINANCE_ATI 0x9821 -#define GLX_BIND_TO_TEXTURE_INTENSITY_ATI 0x9822 - -typedef void ( * PFNGLXBINDTEXIMAGEATIPROC) (Display *dpy, GLXPbuffer pbuf, int buffer); -typedef void ( * PFNGLXDRAWABLEATTRIBATIPROC) (Display *dpy, GLXDrawable draw, const int *attrib_list); -typedef void ( * PFNGLXRELEASETEXIMAGEATIPROC) (Display *dpy, GLXPbuffer pbuf, int buffer); - -#define glXBindTexImageATI GLXEW_GET_FUN(__glewXBindTexImageATI) -#define glXDrawableAttribATI GLXEW_GET_FUN(__glewXDrawableAttribATI) -#define glXReleaseTexImageATI GLXEW_GET_FUN(__glewXReleaseTexImageATI) - -#define GLXEW_ATI_render_texture GLXEW_GET_VAR(__GLXEW_ATI_render_texture) - -#endif /* GLX_ATI_render_texture */ - -/* --------------------- GLX_EXT_fbconfig_packed_float --------------------- */ - -#ifndef GLX_EXT_fbconfig_packed_float -#define GLX_EXT_fbconfig_packed_float 1 - -#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008 -#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1 - -#define GLXEW_EXT_fbconfig_packed_float GLXEW_GET_VAR(__GLXEW_EXT_fbconfig_packed_float) - -#endif /* GLX_EXT_fbconfig_packed_float */ - -/* ------------------------ GLX_EXT_framebuffer_sRGB ----------------------- */ - -#ifndef GLX_EXT_framebuffer_sRGB -#define GLX_EXT_framebuffer_sRGB 1 - -#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2 - -#define GLXEW_EXT_framebuffer_sRGB GLXEW_GET_VAR(__GLXEW_EXT_framebuffer_sRGB) - -#endif /* GLX_EXT_framebuffer_sRGB */ - -/* ------------------------- GLX_EXT_import_context ------------------------ */ - -#ifndef GLX_EXT_import_context -#define GLX_EXT_import_context 1 - -#define GLX_SHARE_CONTEXT_EXT 0x800A -#define GLX_VISUAL_ID_EXT 0x800B -#define GLX_SCREEN_EXT 0x800C - -typedef XID GLXContextID; - -typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display* dpy, GLXContext context); -typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context); -typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display* dpy, GLXContextID contextID); -typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display* dpy, GLXContext context, int attribute,int *value); - -#define glXFreeContextEXT GLXEW_GET_FUN(__glewXFreeContextEXT) -#define glXGetContextIDEXT GLXEW_GET_FUN(__glewXGetContextIDEXT) -#define glXImportContextEXT GLXEW_GET_FUN(__glewXImportContextEXT) -#define glXQueryContextInfoEXT GLXEW_GET_FUN(__glewXQueryContextInfoEXT) - -#define GLXEW_EXT_import_context GLXEW_GET_VAR(__GLXEW_EXT_import_context) - -#endif /* GLX_EXT_import_context */ - -/* -------------------------- GLX_EXT_scene_marker ------------------------- */ - -#ifndef GLX_EXT_scene_marker -#define GLX_EXT_scene_marker 1 - -#define GLXEW_EXT_scene_marker GLXEW_GET_VAR(__GLXEW_EXT_scene_marker) - -#endif /* GLX_EXT_scene_marker */ - -/* ---------------------- GLX_EXT_texture_from_pixmap ---------------------- */ - -#ifndef GLX_EXT_texture_from_pixmap -#define GLX_EXT_texture_from_pixmap 1 - -#define GLX_TEXTURE_1D_BIT_EXT 0x00000001 -#define GLX_TEXTURE_2D_BIT_EXT 0x00000002 -#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 -#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 -#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 -#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 -#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 -#define GLX_Y_INVERTED_EXT 0x20D4 -#define GLX_TEXTURE_FORMAT_EXT 0x20D5 -#define GLX_TEXTURE_TARGET_EXT 0x20D6 -#define GLX_MIPMAP_TEXTURE_EXT 0x20D7 -#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 -#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 -#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA -#define GLX_TEXTURE_1D_EXT 0x20DB -#define GLX_TEXTURE_2D_EXT 0x20DC -#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD -#define GLX_FRONT_LEFT_EXT 0x20DE -#define GLX_FRONT_RIGHT_EXT 0x20DF -#define GLX_BACK_LEFT_EXT 0x20E0 -#define GLX_BACK_RIGHT_EXT 0x20E1 -#define GLX_AUX0_EXT 0x20E2 -#define GLX_AUX1_EXT 0x20E3 -#define GLX_AUX2_EXT 0x20E4 -#define GLX_AUX3_EXT 0x20E5 -#define GLX_AUX4_EXT 0x20E6 -#define GLX_AUX5_EXT 0x20E7 -#define GLX_AUX6_EXT 0x20E8 -#define GLX_AUX7_EXT 0x20E9 -#define GLX_AUX8_EXT 0x20EA -#define GLX_AUX9_EXT 0x20EB - -typedef void ( * PFNGLXBINDTEXIMAGEEXTPROC) (Display* display, GLXDrawable drawable, int buffer, const int *attrib_list); -typedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display* display, GLXDrawable drawable, int buffer); - -#define glXBindTexImageEXT GLXEW_GET_FUN(__glewXBindTexImageEXT) -#define glXReleaseTexImageEXT GLXEW_GET_FUN(__glewXReleaseTexImageEXT) - -#define GLXEW_EXT_texture_from_pixmap GLXEW_GET_VAR(__GLXEW_EXT_texture_from_pixmap) - -#endif /* GLX_EXT_texture_from_pixmap */ - -/* -------------------------- GLX_EXT_visual_info -------------------------- */ - -#ifndef GLX_EXT_visual_info -#define GLX_EXT_visual_info 1 - -#define GLX_X_VISUAL_TYPE_EXT 0x22 -#define GLX_TRANSPARENT_TYPE_EXT 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 -#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 -#define GLX_NONE_EXT 0x8000 -#define GLX_TRUE_COLOR_EXT 0x8002 -#define GLX_DIRECT_COLOR_EXT 0x8003 -#define GLX_PSEUDO_COLOR_EXT 0x8004 -#define GLX_STATIC_COLOR_EXT 0x8005 -#define GLX_GRAY_SCALE_EXT 0x8006 -#define GLX_STATIC_GRAY_EXT 0x8007 -#define GLX_TRANSPARENT_RGB_EXT 0x8008 -#define GLX_TRANSPARENT_INDEX_EXT 0x8009 - -#define GLXEW_EXT_visual_info GLXEW_GET_VAR(__GLXEW_EXT_visual_info) - -#endif /* GLX_EXT_visual_info */ - -/* ------------------------- GLX_EXT_visual_rating ------------------------- */ - -#ifndef GLX_EXT_visual_rating -#define GLX_EXT_visual_rating 1 - -#define GLX_VISUAL_CAVEAT_EXT 0x20 -#define GLX_SLOW_VISUAL_EXT 0x8001 -#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D - -#define GLXEW_EXT_visual_rating GLXEW_GET_VAR(__GLXEW_EXT_visual_rating) - -#endif /* GLX_EXT_visual_rating */ - -/* -------------------------- GLX_MESA_agp_offset -------------------------- */ - -#ifndef GLX_MESA_agp_offset -#define GLX_MESA_agp_offset 1 - -typedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void* pointer); - -#define glXGetAGPOffsetMESA GLXEW_GET_FUN(__glewXGetAGPOffsetMESA) - -#define GLXEW_MESA_agp_offset GLXEW_GET_VAR(__GLXEW_MESA_agp_offset) - -#endif /* GLX_MESA_agp_offset */ - -/* ------------------------ GLX_MESA_copy_sub_buffer ----------------------- */ - -#ifndef GLX_MESA_copy_sub_buffer -#define GLX_MESA_copy_sub_buffer 1 - -typedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display* dpy, GLXDrawable drawable, int x, int y, int width, int height); - -#define glXCopySubBufferMESA GLXEW_GET_FUN(__glewXCopySubBufferMESA) - -#define GLXEW_MESA_copy_sub_buffer GLXEW_GET_VAR(__GLXEW_MESA_copy_sub_buffer) - -#endif /* GLX_MESA_copy_sub_buffer */ - -/* ------------------------ GLX_MESA_pixmap_colormap ----------------------- */ - -#ifndef GLX_MESA_pixmap_colormap -#define GLX_MESA_pixmap_colormap 1 - -typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display* dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); - -#define glXCreateGLXPixmapMESA GLXEW_GET_FUN(__glewXCreateGLXPixmapMESA) - -#define GLXEW_MESA_pixmap_colormap GLXEW_GET_VAR(__GLXEW_MESA_pixmap_colormap) - -#endif /* GLX_MESA_pixmap_colormap */ - -/* ------------------------ GLX_MESA_release_buffers ----------------------- */ - -#ifndef GLX_MESA_release_buffers -#define GLX_MESA_release_buffers 1 - -typedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display* dpy, GLXDrawable d); - -#define glXReleaseBuffersMESA GLXEW_GET_FUN(__glewXReleaseBuffersMESA) - -#define GLXEW_MESA_release_buffers GLXEW_GET_VAR(__GLXEW_MESA_release_buffers) - -#endif /* GLX_MESA_release_buffers */ - -/* ------------------------- GLX_MESA_set_3dfx_mode ------------------------ */ - -#ifndef GLX_MESA_set_3dfx_mode -#define GLX_MESA_set_3dfx_mode 1 - -#define GLX_3DFX_WINDOW_MODE_MESA 0x1 -#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 - -typedef GLboolean ( * PFNGLXSET3DFXMODEMESAPROC) (GLint mode); - -#define glXSet3DfxModeMESA GLXEW_GET_FUN(__glewXSet3DfxModeMESA) - -#define GLXEW_MESA_set_3dfx_mode GLXEW_GET_VAR(__GLXEW_MESA_set_3dfx_mode) - -#endif /* GLX_MESA_set_3dfx_mode */ - -/* -------------------------- GLX_NV_float_buffer -------------------------- */ - -#ifndef GLX_NV_float_buffer -#define GLX_NV_float_buffer 1 - -#define GLX_FLOAT_COMPONENTS_NV 0x20B0 - -#define GLXEW_NV_float_buffer GLXEW_GET_VAR(__GLXEW_NV_float_buffer) - -#endif /* GLX_NV_float_buffer */ - -/* -------------------------- GLX_NV_present_video ------------------------- */ - -#ifndef GLX_NV_present_video -#define GLX_NV_present_video 1 - -#define GLX_NUM_VIDEO_SLOTS_NV 0x20F0 - -typedef int ( * PFNGLXBINDVIDEODEVICENVPROC) (Display* dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list); -typedef unsigned int* ( * PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements); - -#define glXBindVideoDeviceNV GLXEW_GET_FUN(__glewXBindVideoDeviceNV) -#define glXEnumerateVideoDevicesNV GLXEW_GET_FUN(__glewXEnumerateVideoDevicesNV) - -#define GLXEW_NV_present_video GLXEW_GET_VAR(__GLXEW_NV_present_video) - -#endif /* GLX_NV_present_video */ - -/* --------------------------- GLX_NV_swap_group --------------------------- */ - -#ifndef GLX_NV_swap_group -#define GLX_NV_swap_group 1 - -typedef Bool ( * PFNGLXBINDSWAPBARRIERNVPROC) (Display* dpy, GLuint group, GLuint barrier); -typedef Bool ( * PFNGLXJOINSWAPGROUPNVPROC) (Display* dpy, GLXDrawable drawable, GLuint group); -typedef Bool ( * PFNGLXQUERYFRAMECOUNTNVPROC) (Display* dpy, int screen, GLuint *count); -typedef Bool ( * PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display* dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers); -typedef Bool ( * PFNGLXQUERYSWAPGROUPNVPROC) (Display* dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier); -typedef Bool ( * PFNGLXRESETFRAMECOUNTNVPROC) (Display* dpy, int screen); - -#define glXBindSwapBarrierNV GLXEW_GET_FUN(__glewXBindSwapBarrierNV) -#define glXJoinSwapGroupNV GLXEW_GET_FUN(__glewXJoinSwapGroupNV) -#define glXQueryFrameCountNV GLXEW_GET_FUN(__glewXQueryFrameCountNV) -#define glXQueryMaxSwapGroupsNV GLXEW_GET_FUN(__glewXQueryMaxSwapGroupsNV) -#define glXQuerySwapGroupNV GLXEW_GET_FUN(__glewXQuerySwapGroupNV) -#define glXResetFrameCountNV GLXEW_GET_FUN(__glewXResetFrameCountNV) - -#define GLXEW_NV_swap_group GLXEW_GET_VAR(__GLXEW_NV_swap_group) - -#endif /* GLX_NV_swap_group */ - -/* ----------------------- GLX_NV_vertex_array_range ----------------------- */ - -#ifndef GLX_NV_vertex_array_range -#define GLX_NV_vertex_array_range 1 - -typedef void * ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority); -typedef void ( * PFNGLXFREEMEMORYNVPROC) (void *pointer); - -#define glXAllocateMemoryNV GLXEW_GET_FUN(__glewXAllocateMemoryNV) -#define glXFreeMemoryNV GLXEW_GET_FUN(__glewXFreeMemoryNV) - -#define GLXEW_NV_vertex_array_range GLXEW_GET_VAR(__GLXEW_NV_vertex_array_range) - -#endif /* GLX_NV_vertex_array_range */ - -/* -------------------------- GLX_NV_video_output -------------------------- */ - -#ifndef GLX_NV_video_output -#define GLX_NV_video_output 1 - -#define GLX_VIDEO_OUT_COLOR_NV 0x20C3 -#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4 -#define GLX_VIDEO_OUT_DEPTH_NV 0x20C5 -#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 -#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 -#define GLX_VIDEO_OUT_FRAME_NV 0x20C8 -#define GLX_VIDEO_OUT_FIELD_1_NV 0x20C9 -#define GLX_VIDEO_OUT_FIELD_2_NV 0x20CA -#define GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB -#define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC - -typedef int ( * PFNGLXBINDVIDEOIMAGENVPROC) (Display* dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer); -typedef int ( * PFNGLXGETVIDEODEVICENVPROC) (Display* dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice); -typedef int ( * PFNGLXGETVIDEOINFONVPROC) (Display* dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); -typedef int ( * PFNGLXRELEASEVIDEODEVICENVPROC) (Display* dpy, int screen, GLXVideoDeviceNV VideoDevice); -typedef int ( * PFNGLXRELEASEVIDEOIMAGENVPROC) (Display* dpy, GLXPbuffer pbuf); -typedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display* dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock); - -#define glXBindVideoImageNV GLXEW_GET_FUN(__glewXBindVideoImageNV) -#define glXGetVideoDeviceNV GLXEW_GET_FUN(__glewXGetVideoDeviceNV) -#define glXGetVideoInfoNV GLXEW_GET_FUN(__glewXGetVideoInfoNV) -#define glXReleaseVideoDeviceNV GLXEW_GET_FUN(__glewXReleaseVideoDeviceNV) -#define glXReleaseVideoImageNV GLXEW_GET_FUN(__glewXReleaseVideoImageNV) -#define glXSendPbufferToVideoNV GLXEW_GET_FUN(__glewXSendPbufferToVideoNV) - -#define GLXEW_NV_video_output GLXEW_GET_VAR(__GLXEW_NV_video_output) - -#endif /* GLX_NV_video_output */ - -/* -------------------------- GLX_OML_swap_method -------------------------- */ - -#ifndef GLX_OML_swap_method -#define GLX_OML_swap_method 1 - -#define GLX_SWAP_METHOD_OML 0x8060 -#define GLX_SWAP_EXCHANGE_OML 0x8061 -#define GLX_SWAP_COPY_OML 0x8062 -#define GLX_SWAP_UNDEFINED_OML 0x8063 - -#define GLXEW_OML_swap_method GLXEW_GET_VAR(__GLXEW_OML_swap_method) - -#endif /* GLX_OML_swap_method */ - -/* -------------------------- GLX_OML_sync_control ------------------------- */ - -#if !defined(GLX_OML_sync_control) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -#include -#define GLX_OML_sync_control 1 - -typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display* dpy, GLXDrawable drawable, int32_t* numerator, int32_t* denominator); -typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t* ust, int64_t* msc, int64_t* sbc); -typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); -typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t* ust, int64_t* msc, int64_t* sbc); -typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_sbc, int64_t* ust, int64_t* msc, int64_t* sbc); - -#define glXGetMscRateOML GLXEW_GET_FUN(__glewXGetMscRateOML) -#define glXGetSyncValuesOML GLXEW_GET_FUN(__glewXGetSyncValuesOML) -#define glXSwapBuffersMscOML GLXEW_GET_FUN(__glewXSwapBuffersMscOML) -#define glXWaitForMscOML GLXEW_GET_FUN(__glewXWaitForMscOML) -#define glXWaitForSbcOML GLXEW_GET_FUN(__glewXWaitForSbcOML) - -#define GLXEW_OML_sync_control GLXEW_GET_VAR(__GLXEW_OML_sync_control) - -#endif /* GLX_OML_sync_control */ - -/* ------------------------ GLX_SGIS_blended_overlay ----------------------- */ - -#ifndef GLX_SGIS_blended_overlay -#define GLX_SGIS_blended_overlay 1 - -#define GLX_BLENDED_RGBA_SGIS 0x8025 - -#define GLXEW_SGIS_blended_overlay GLXEW_GET_VAR(__GLXEW_SGIS_blended_overlay) - -#endif /* GLX_SGIS_blended_overlay */ - -/* -------------------------- GLX_SGIS_color_range ------------------------- */ - -#ifndef GLX_SGIS_color_range -#define GLX_SGIS_color_range 1 - -#define GLX_MIN_RED_SGIS 0 -#define GLX_MAX_GREEN_SGIS 0 -#define GLX_MIN_BLUE_SGIS 0 -#define GLX_MAX_ALPHA_SGIS 0 -#define GLX_MIN_GREEN_SGIS 0 -#define GLX_MIN_ALPHA_SGIS 0 -#define GLX_MAX_RED_SGIS 0 -#define GLX_EXTENDED_RANGE_SGIS 0 -#define GLX_MAX_BLUE_SGIS 0 - -#define GLXEW_SGIS_color_range GLXEW_GET_VAR(__GLXEW_SGIS_color_range) - -#endif /* GLX_SGIS_color_range */ - -/* -------------------------- GLX_SGIS_multisample ------------------------- */ - -#ifndef GLX_SGIS_multisample -#define GLX_SGIS_multisample 1 - -#define GLX_SAMPLE_BUFFERS_SGIS 100000 -#define GLX_SAMPLES_SGIS 100001 - -#define GLXEW_SGIS_multisample GLXEW_GET_VAR(__GLXEW_SGIS_multisample) - -#endif /* GLX_SGIS_multisample */ - -/* ---------------------- GLX_SGIS_shared_multisample ---------------------- */ - -#ifndef GLX_SGIS_shared_multisample -#define GLX_SGIS_shared_multisample 1 - -#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026 -#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027 - -#define GLXEW_SGIS_shared_multisample GLXEW_GET_VAR(__GLXEW_SGIS_shared_multisample) - -#endif /* GLX_SGIS_shared_multisample */ - -/* --------------------------- GLX_SGIX_fbconfig --------------------------- */ - -#ifndef GLX_SGIX_fbconfig -#define GLX_SGIX_fbconfig 1 - -#define GLX_WINDOW_BIT_SGIX 0x00000001 -#define GLX_RGBA_BIT_SGIX 0x00000001 -#define GLX_PIXMAP_BIT_SGIX 0x00000002 -#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002 -#define GLX_SCREEN_EXT 0x800C -#define GLX_DRAWABLE_TYPE_SGIX 0x8010 -#define GLX_RENDER_TYPE_SGIX 0x8011 -#define GLX_X_RENDERABLE_SGIX 0x8012 -#define GLX_FBCONFIG_ID_SGIX 0x8013 -#define GLX_RGBA_TYPE_SGIX 0x8014 -#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015 - -typedef XID GLXFBConfigIDSGIX; -typedef struct __GLXFBConfigRec *GLXFBConfigSGIX; - -typedef GLXFBConfigSGIX* ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); -typedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display* dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); -typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display* dpy, GLXFBConfig config, Pixmap pixmap); -typedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display* dpy, GLXFBConfigSGIX config, int attribute, int *value); -typedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display* dpy, XVisualInfo *vis); -typedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfig config); - -#define glXChooseFBConfigSGIX GLXEW_GET_FUN(__glewXChooseFBConfigSGIX) -#define glXCreateContextWithConfigSGIX GLXEW_GET_FUN(__glewXCreateContextWithConfigSGIX) -#define glXCreateGLXPixmapWithConfigSGIX GLXEW_GET_FUN(__glewXCreateGLXPixmapWithConfigSGIX) -#define glXGetFBConfigAttribSGIX GLXEW_GET_FUN(__glewXGetFBConfigAttribSGIX) -#define glXGetFBConfigFromVisualSGIX GLXEW_GET_FUN(__glewXGetFBConfigFromVisualSGIX) -#define glXGetVisualFromFBConfigSGIX GLXEW_GET_FUN(__glewXGetVisualFromFBConfigSGIX) - -#define GLXEW_SGIX_fbconfig GLXEW_GET_VAR(__GLXEW_SGIX_fbconfig) - -#endif /* GLX_SGIX_fbconfig */ - -/* --------------------------- GLX_SGIX_hyperpipe -------------------------- */ - -#ifndef GLX_SGIX_hyperpipe -#define GLX_SGIX_hyperpipe 1 - -#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001 -#define GLX_PIPE_RECT_SGIX 0x00000001 -#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002 -#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002 -#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003 -#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004 -#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80 -#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91 -#define GLX_BAD_HYPERPIPE_SGIX 92 -#define GLX_HYPERPIPE_ID_SGIX 0x8030 - -typedef struct { - char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; - int networkId; -} GLXHyperpipeNetworkSGIX; -typedef struct { - char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; - int XOrigin; - int YOrigin; - int maxHeight; - int maxWidth; -} GLXPipeRectLimits; -typedef struct { - char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; - int channel; - unsigned int participationType; - int timeSlice; -} GLXHyperpipeConfigSGIX; -typedef struct { - char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; - int srcXOrigin; - int srcYOrigin; - int srcWidth; - int srcHeight; - int destXOrigin; - int destYOrigin; - int destWidth; - int destHeight; -} GLXPipeRect; - -typedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId); -typedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId); -typedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList); -typedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId); -typedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList); -typedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList); -typedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes); -typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes); - -#define glXBindHyperpipeSGIX GLXEW_GET_FUN(__glewXBindHyperpipeSGIX) -#define glXDestroyHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXDestroyHyperpipeConfigSGIX) -#define glXHyperpipeAttribSGIX GLXEW_GET_FUN(__glewXHyperpipeAttribSGIX) -#define glXHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXHyperpipeConfigSGIX) -#define glXQueryHyperpipeAttribSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeAttribSGIX) -#define glXQueryHyperpipeBestAttribSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeBestAttribSGIX) -#define glXQueryHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeConfigSGIX) -#define glXQueryHyperpipeNetworkSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeNetworkSGIX) - -#define GLXEW_SGIX_hyperpipe GLXEW_GET_VAR(__GLXEW_SGIX_hyperpipe) - -#endif /* GLX_SGIX_hyperpipe */ - -/* ---------------------------- GLX_SGIX_pbuffer --------------------------- */ - -#ifndef GLX_SGIX_pbuffer -#define GLX_SGIX_pbuffer 1 - -#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001 -#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002 -#define GLX_PBUFFER_BIT_SGIX 0x00000004 -#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004 -#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008 -#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010 -#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020 -#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040 -#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080 -#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100 -#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016 -#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017 -#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018 -#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 -#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A -#define GLX_PRESERVED_CONTENTS_SGIX 0x801B -#define GLX_LARGEST_PBUFFER_SGIX 0x801C -#define GLX_WIDTH_SGIX 0x801D -#define GLX_HEIGHT_SGIX 0x801E -#define GLX_EVENT_MASK_SGIX 0x801F -#define GLX_DAMAGED_SGIX 0x8020 -#define GLX_SAVED_SGIX 0x8021 -#define GLX_WINDOW_SGIX 0x8022 -#define GLX_PBUFFER_SGIX 0x8023 -#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000 - -typedef XID GLXPbufferSGIX; -typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX; - -typedef GLXPbuffer ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display* dpy, GLXFBConfig config, unsigned int width, unsigned int height, int *attrib_list); -typedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display* dpy, GLXPbuffer pbuf); -typedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display* dpy, GLXDrawable drawable, unsigned long *mask); -typedef void ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display* dpy, GLXPbuffer pbuf, int attribute, unsigned int *value); -typedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display* dpy, GLXDrawable drawable, unsigned long mask); - -#define glXCreateGLXPbufferSGIX GLXEW_GET_FUN(__glewXCreateGLXPbufferSGIX) -#define glXDestroyGLXPbufferSGIX GLXEW_GET_FUN(__glewXDestroyGLXPbufferSGIX) -#define glXGetSelectedEventSGIX GLXEW_GET_FUN(__glewXGetSelectedEventSGIX) -#define glXQueryGLXPbufferSGIX GLXEW_GET_FUN(__glewXQueryGLXPbufferSGIX) -#define glXSelectEventSGIX GLXEW_GET_FUN(__glewXSelectEventSGIX) - -#define GLXEW_SGIX_pbuffer GLXEW_GET_VAR(__GLXEW_SGIX_pbuffer) - -#endif /* GLX_SGIX_pbuffer */ - -/* ------------------------- GLX_SGIX_swap_barrier ------------------------- */ - -#ifndef GLX_SGIX_swap_barrier -#define GLX_SGIX_swap_barrier 1 - -typedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier); -typedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max); - -#define glXBindSwapBarrierSGIX GLXEW_GET_FUN(__glewXBindSwapBarrierSGIX) -#define glXQueryMaxSwapBarriersSGIX GLXEW_GET_FUN(__glewXQueryMaxSwapBarriersSGIX) - -#define GLXEW_SGIX_swap_barrier GLXEW_GET_VAR(__GLXEW_SGIX_swap_barrier) - -#endif /* GLX_SGIX_swap_barrier */ - -/* -------------------------- GLX_SGIX_swap_group -------------------------- */ - -#ifndef GLX_SGIX_swap_group -#define GLX_SGIX_swap_group 1 - -typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member); - -#define glXJoinSwapGroupSGIX GLXEW_GET_FUN(__glewXJoinSwapGroupSGIX) - -#define GLXEW_SGIX_swap_group GLXEW_GET_VAR(__GLXEW_SGIX_swap_group) - -#endif /* GLX_SGIX_swap_group */ - -/* ------------------------- GLX_SGIX_video_resize ------------------------- */ - -#ifndef GLX_SGIX_video_resize -#define GLX_SGIX_video_resize 1 - -#define GLX_SYNC_FRAME_SGIX 0x00000000 -#define GLX_SYNC_SWAP_SGIX 0x00000001 - -typedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display* display, int screen, int channel, Window window); -typedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display* display, int screen, int channel, int x, int y, int w, int h); -typedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display* display, int screen, int channel, GLenum synctype); -typedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display* display, int screen, int channel, int *x, int *y, int *w, int *h); -typedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display* display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); - -#define glXBindChannelToWindowSGIX GLXEW_GET_FUN(__glewXBindChannelToWindowSGIX) -#define glXChannelRectSGIX GLXEW_GET_FUN(__glewXChannelRectSGIX) -#define glXChannelRectSyncSGIX GLXEW_GET_FUN(__glewXChannelRectSyncSGIX) -#define glXQueryChannelDeltasSGIX GLXEW_GET_FUN(__glewXQueryChannelDeltasSGIX) -#define glXQueryChannelRectSGIX GLXEW_GET_FUN(__glewXQueryChannelRectSGIX) - -#define GLXEW_SGIX_video_resize GLXEW_GET_VAR(__GLXEW_SGIX_video_resize) - -#endif /* GLX_SGIX_video_resize */ - -/* ---------------------- GLX_SGIX_visual_select_group --------------------- */ - -#ifndef GLX_SGIX_visual_select_group -#define GLX_SGIX_visual_select_group 1 - -#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028 - -#define GLXEW_SGIX_visual_select_group GLXEW_GET_VAR(__GLXEW_SGIX_visual_select_group) - -#endif /* GLX_SGIX_visual_select_group */ - -/* ---------------------------- GLX_SGI_cushion ---------------------------- */ - -#ifndef GLX_SGI_cushion -#define GLX_SGI_cushion 1 - -typedef void ( * PFNGLXCUSHIONSGIPROC) (Display* dpy, Window window, float cushion); - -#define glXCushionSGI GLXEW_GET_FUN(__glewXCushionSGI) - -#define GLXEW_SGI_cushion GLXEW_GET_VAR(__GLXEW_SGI_cushion) - -#endif /* GLX_SGI_cushion */ - -/* ----------------------- GLX_SGI_make_current_read ----------------------- */ - -#ifndef GLX_SGI_make_current_read -#define GLX_SGI_make_current_read 1 - -typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void); -typedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); - -#define glXGetCurrentReadDrawableSGI GLXEW_GET_FUN(__glewXGetCurrentReadDrawableSGI) -#define glXMakeCurrentReadSGI GLXEW_GET_FUN(__glewXMakeCurrentReadSGI) - -#define GLXEW_SGI_make_current_read GLXEW_GET_VAR(__GLXEW_SGI_make_current_read) - -#endif /* GLX_SGI_make_current_read */ - -/* -------------------------- GLX_SGI_swap_control ------------------------- */ - -#ifndef GLX_SGI_swap_control -#define GLX_SGI_swap_control 1 - -typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval); - -#define glXSwapIntervalSGI GLXEW_GET_FUN(__glewXSwapIntervalSGI) - -#define GLXEW_SGI_swap_control GLXEW_GET_VAR(__GLXEW_SGI_swap_control) - -#endif /* GLX_SGI_swap_control */ - -/* --------------------------- GLX_SGI_video_sync -------------------------- */ - -#ifndef GLX_SGI_video_sync -#define GLX_SGI_video_sync 1 - -typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (uint* count); -typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int* count); - -#define glXGetVideoSyncSGI GLXEW_GET_FUN(__glewXGetVideoSyncSGI) -#define glXWaitVideoSyncSGI GLXEW_GET_FUN(__glewXWaitVideoSyncSGI) - -#define GLXEW_SGI_video_sync GLXEW_GET_VAR(__GLXEW_SGI_video_sync) - -#endif /* GLX_SGI_video_sync */ - -/* --------------------- GLX_SUN_get_transparent_index --------------------- */ - -#ifndef GLX_SUN_get_transparent_index -#define GLX_SUN_get_transparent_index 1 - -typedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display* dpy, Window overlay, Window underlay, unsigned long *pTransparentIndex); - -#define glXGetTransparentIndexSUN GLXEW_GET_FUN(__glewXGetTransparentIndexSUN) - -#define GLXEW_SUN_get_transparent_index GLXEW_GET_VAR(__GLXEW_SUN_get_transparent_index) - -#endif /* GLX_SUN_get_transparent_index */ - -/* -------------------------- GLX_SUN_video_resize ------------------------- */ - -#ifndef GLX_SUN_video_resize -#define GLX_SUN_video_resize 1 - -#define GLX_VIDEO_RESIZE_SUN 0x8171 -#define GL_VIDEO_RESIZE_COMPENSATION_SUN 0x85CD - -typedef int ( * PFNGLXGETVIDEORESIZESUNPROC) (Display* display, GLXDrawable window, float* factor); -typedef int ( * PFNGLXVIDEORESIZESUNPROC) (Display* display, GLXDrawable window, float factor); - -#define glXGetVideoResizeSUN GLXEW_GET_FUN(__glewXGetVideoResizeSUN) -#define glXVideoResizeSUN GLXEW_GET_FUN(__glewXVideoResizeSUN) - -#define GLXEW_SUN_video_resize GLXEW_GET_VAR(__GLXEW_SUN_video_resize) - -#endif /* GLX_SUN_video_resize */ - -/* ------------------------------------------------------------------------- */ - -#ifdef GLEW_MX -#define GLXEW_EXPORT -#else -#define GLXEW_EXPORT extern -#endif /* GLEW_MX */ - -extern PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay; - -extern PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig; -extern PFNGLXCREATENEWCONTEXTPROC __glewXCreateNewContext; -extern PFNGLXCREATEPBUFFERPROC __glewXCreatePbuffer; -extern PFNGLXCREATEPIXMAPPROC __glewXCreatePixmap; -extern PFNGLXCREATEWINDOWPROC __glewXCreateWindow; -extern PFNGLXDESTROYPBUFFERPROC __glewXDestroyPbuffer; -extern PFNGLXDESTROYPIXMAPPROC __glewXDestroyPixmap; -extern PFNGLXDESTROYWINDOWPROC __glewXDestroyWindow; -extern PFNGLXGETCURRENTREADDRAWABLEPROC __glewXGetCurrentReadDrawable; -extern PFNGLXGETFBCONFIGATTRIBPROC __glewXGetFBConfigAttrib; -extern PFNGLXGETFBCONFIGSPROC __glewXGetFBConfigs; -extern PFNGLXGETSELECTEDEVENTPROC __glewXGetSelectedEvent; -extern PFNGLXGETVISUALFROMFBCONFIGPROC __glewXGetVisualFromFBConfig; -extern PFNGLXMAKECONTEXTCURRENTPROC __glewXMakeContextCurrent; -extern PFNGLXQUERYCONTEXTPROC __glewXQueryContext; -extern PFNGLXQUERYDRAWABLEPROC __glewXQueryDrawable; -extern PFNGLXSELECTEVENTPROC __glewXSelectEvent; - -extern PFNGLXCREATECONTEXTATTRIBSARBPROC __glewXCreateContextAttribsARB; - -extern PFNGLXBINDTEXIMAGEATIPROC __glewXBindTexImageATI; -extern PFNGLXDRAWABLEATTRIBATIPROC __glewXDrawableAttribATI; -extern PFNGLXRELEASETEXIMAGEATIPROC __glewXReleaseTexImageATI; - -extern PFNGLXFREECONTEXTEXTPROC __glewXFreeContextEXT; -extern PFNGLXGETCONTEXTIDEXTPROC __glewXGetContextIDEXT; -extern PFNGLXIMPORTCONTEXTEXTPROC __glewXImportContextEXT; -extern PFNGLXQUERYCONTEXTINFOEXTPROC __glewXQueryContextInfoEXT; - -extern PFNGLXBINDTEXIMAGEEXTPROC __glewXBindTexImageEXT; -extern PFNGLXRELEASETEXIMAGEEXTPROC __glewXReleaseTexImageEXT; - -extern PFNGLXGETAGPOFFSETMESAPROC __glewXGetAGPOffsetMESA; - -extern PFNGLXCOPYSUBBUFFERMESAPROC __glewXCopySubBufferMESA; - -extern PFNGLXCREATEGLXPIXMAPMESAPROC __glewXCreateGLXPixmapMESA; - -extern PFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA; - -extern PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA; - -extern PFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV; -extern PFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV; - -extern PFNGLXBINDSWAPBARRIERNVPROC __glewXBindSwapBarrierNV; -extern PFNGLXJOINSWAPGROUPNVPROC __glewXJoinSwapGroupNV; -extern PFNGLXQUERYFRAMECOUNTNVPROC __glewXQueryFrameCountNV; -extern PFNGLXQUERYMAXSWAPGROUPSNVPROC __glewXQueryMaxSwapGroupsNV; -extern PFNGLXQUERYSWAPGROUPNVPROC __glewXQuerySwapGroupNV; -extern PFNGLXRESETFRAMECOUNTNVPROC __glewXResetFrameCountNV; - -extern PFNGLXALLOCATEMEMORYNVPROC __glewXAllocateMemoryNV; -extern PFNGLXFREEMEMORYNVPROC __glewXFreeMemoryNV; - -extern PFNGLXBINDVIDEOIMAGENVPROC __glewXBindVideoImageNV; -extern PFNGLXGETVIDEODEVICENVPROC __glewXGetVideoDeviceNV; -extern PFNGLXGETVIDEOINFONVPROC __glewXGetVideoInfoNV; -extern PFNGLXRELEASEVIDEODEVICENVPROC __glewXReleaseVideoDeviceNV; -extern PFNGLXRELEASEVIDEOIMAGENVPROC __glewXReleaseVideoImageNV; -extern PFNGLXSENDPBUFFERTOVIDEONVPROC __glewXSendPbufferToVideoNV; - -#ifdef GLX_OML_sync_control -extern PFNGLXGETMSCRATEOMLPROC __glewXGetMscRateOML; -extern PFNGLXGETSYNCVALUESOMLPROC __glewXGetSyncValuesOML; -extern PFNGLXSWAPBUFFERSMSCOMLPROC __glewXSwapBuffersMscOML; -extern PFNGLXWAITFORMSCOMLPROC __glewXWaitForMscOML; -extern PFNGLXWAITFORSBCOMLPROC __glewXWaitForSbcOML; -#endif - -extern PFNGLXCHOOSEFBCONFIGSGIXPROC __glewXChooseFBConfigSGIX; -extern PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC __glewXCreateContextWithConfigSGIX; -extern PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC __glewXCreateGLXPixmapWithConfigSGIX; -extern PFNGLXGETFBCONFIGATTRIBSGIXPROC __glewXGetFBConfigAttribSGIX; -extern PFNGLXGETFBCONFIGFROMVISUALSGIXPROC __glewXGetFBConfigFromVisualSGIX; -extern PFNGLXGETVISUALFROMFBCONFIGSGIXPROC __glewXGetVisualFromFBConfigSGIX; - -extern PFNGLXBINDHYPERPIPESGIXPROC __glewXBindHyperpipeSGIX; -extern PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC __glewXDestroyHyperpipeConfigSGIX; -extern PFNGLXHYPERPIPEATTRIBSGIXPROC __glewXHyperpipeAttribSGIX; -extern PFNGLXHYPERPIPECONFIGSGIXPROC __glewXHyperpipeConfigSGIX; -extern PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC __glewXQueryHyperpipeAttribSGIX; -extern PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC __glewXQueryHyperpipeBestAttribSGIX; -extern PFNGLXQUERYHYPERPIPECONFIGSGIXPROC __glewXQueryHyperpipeConfigSGIX; -extern PFNGLXQUERYHYPERPIPENETWORKSGIXPROC __glewXQueryHyperpipeNetworkSGIX; - -extern PFNGLXCREATEGLXPBUFFERSGIXPROC __glewXCreateGLXPbufferSGIX; -extern PFNGLXDESTROYGLXPBUFFERSGIXPROC __glewXDestroyGLXPbufferSGIX; -extern PFNGLXGETSELECTEDEVENTSGIXPROC __glewXGetSelectedEventSGIX; -extern PFNGLXQUERYGLXPBUFFERSGIXPROC __glewXQueryGLXPbufferSGIX; -extern PFNGLXSELECTEVENTSGIXPROC __glewXSelectEventSGIX; - -extern PFNGLXBINDSWAPBARRIERSGIXPROC __glewXBindSwapBarrierSGIX; -extern PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC __glewXQueryMaxSwapBarriersSGIX; - -extern PFNGLXJOINSWAPGROUPSGIXPROC __glewXJoinSwapGroupSGIX; - -extern PFNGLXBINDCHANNELTOWINDOWSGIXPROC __glewXBindChannelToWindowSGIX; -extern PFNGLXCHANNELRECTSGIXPROC __glewXChannelRectSGIX; -extern PFNGLXCHANNELRECTSYNCSGIXPROC __glewXChannelRectSyncSGIX; -extern PFNGLXQUERYCHANNELDELTASSGIXPROC __glewXQueryChannelDeltasSGIX; -extern PFNGLXQUERYCHANNELRECTSGIXPROC __glewXQueryChannelRectSGIX; - -extern PFNGLXCUSHIONSGIPROC __glewXCushionSGI; - -extern PFNGLXGETCURRENTREADDRAWABLESGIPROC __glewXGetCurrentReadDrawableSGI; -extern PFNGLXMAKECURRENTREADSGIPROC __glewXMakeCurrentReadSGI; - -extern PFNGLXSWAPINTERVALSGIPROC __glewXSwapIntervalSGI; - -extern PFNGLXGETVIDEOSYNCSGIPROC __glewXGetVideoSyncSGI; -extern PFNGLXWAITVIDEOSYNCSGIPROC __glewXWaitVideoSyncSGI; - -extern PFNGLXGETTRANSPARENTINDEXSUNPROC __glewXGetTransparentIndexSUN; - -extern PFNGLXGETVIDEORESIZESUNPROC __glewXGetVideoResizeSUN; -extern PFNGLXVIDEORESIZESUNPROC __glewXVideoResizeSUN; - -#if defined(GLEW_MX) -struct GLXEWContextStruct -{ -#endif /* GLEW_MX */ - -GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_0; -GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_1; -GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_2; -GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_3; -GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_4; -GLXEW_EXPORT GLboolean __GLXEW_3DFX_multisample; -GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context; -GLXEW_EXPORT GLboolean __GLXEW_ARB_fbconfig_float; -GLXEW_EXPORT GLboolean __GLXEW_ARB_framebuffer_sRGB; -GLXEW_EXPORT GLboolean __GLXEW_ARB_get_proc_address; -GLXEW_EXPORT GLboolean __GLXEW_ARB_multisample; -GLXEW_EXPORT GLboolean __GLXEW_ATI_pixel_format_float; -GLXEW_EXPORT GLboolean __GLXEW_ATI_render_texture; -GLXEW_EXPORT GLboolean __GLXEW_EXT_fbconfig_packed_float; -GLXEW_EXPORT GLboolean __GLXEW_EXT_framebuffer_sRGB; -GLXEW_EXPORT GLboolean __GLXEW_EXT_import_context; -GLXEW_EXPORT GLboolean __GLXEW_EXT_scene_marker; -GLXEW_EXPORT GLboolean __GLXEW_EXT_texture_from_pixmap; -GLXEW_EXPORT GLboolean __GLXEW_EXT_visual_info; -GLXEW_EXPORT GLboolean __GLXEW_EXT_visual_rating; -GLXEW_EXPORT GLboolean __GLXEW_MESA_agp_offset; -GLXEW_EXPORT GLboolean __GLXEW_MESA_copy_sub_buffer; -GLXEW_EXPORT GLboolean __GLXEW_MESA_pixmap_colormap; -GLXEW_EXPORT GLboolean __GLXEW_MESA_release_buffers; -GLXEW_EXPORT GLboolean __GLXEW_MESA_set_3dfx_mode; -GLXEW_EXPORT GLboolean __GLXEW_NV_float_buffer; -GLXEW_EXPORT GLboolean __GLXEW_NV_present_video; -GLXEW_EXPORT GLboolean __GLXEW_NV_swap_group; -GLXEW_EXPORT GLboolean __GLXEW_NV_vertex_array_range; -GLXEW_EXPORT GLboolean __GLXEW_NV_video_output; -GLXEW_EXPORT GLboolean __GLXEW_OML_swap_method; -GLXEW_EXPORT GLboolean __GLXEW_OML_sync_control; -GLXEW_EXPORT GLboolean __GLXEW_SGIS_blended_overlay; -GLXEW_EXPORT GLboolean __GLXEW_SGIS_color_range; -GLXEW_EXPORT GLboolean __GLXEW_SGIS_multisample; -GLXEW_EXPORT GLboolean __GLXEW_SGIS_shared_multisample; -GLXEW_EXPORT GLboolean __GLXEW_SGIX_fbconfig; -GLXEW_EXPORT GLboolean __GLXEW_SGIX_hyperpipe; -GLXEW_EXPORT GLboolean __GLXEW_SGIX_pbuffer; -GLXEW_EXPORT GLboolean __GLXEW_SGIX_swap_barrier; -GLXEW_EXPORT GLboolean __GLXEW_SGIX_swap_group; -GLXEW_EXPORT GLboolean __GLXEW_SGIX_video_resize; -GLXEW_EXPORT GLboolean __GLXEW_SGIX_visual_select_group; -GLXEW_EXPORT GLboolean __GLXEW_SGI_cushion; -GLXEW_EXPORT GLboolean __GLXEW_SGI_make_current_read; -GLXEW_EXPORT GLboolean __GLXEW_SGI_swap_control; -GLXEW_EXPORT GLboolean __GLXEW_SGI_video_sync; -GLXEW_EXPORT GLboolean __GLXEW_SUN_get_transparent_index; -GLXEW_EXPORT GLboolean __GLXEW_SUN_video_resize; - -#ifdef GLEW_MX -}; /* GLXEWContextStruct */ -#endif /* GLEW_MX */ - -/* ------------------------------------------------------------------------ */ - -#ifdef GLEW_MX - -typedef struct GLXEWContextStruct GLXEWContext; -extern GLenum glxewContextInit (GLXEWContext* ctx); -extern GLboolean glxewContextIsSupported (GLXEWContext* ctx, const char* name); - -#define glxewInit() glxewContextInit(glxewGetContext()) -#define glxewIsSupported(x) glxewContextIsSupported(glxewGetContext(), x) - -#define GLXEW_GET_VAR(x) (*(const GLboolean*)&(glxewGetContext()->x)) -#define GLXEW_GET_FUN(x) x - -#else /* GLEW_MX */ - -#define GLXEW_GET_VAR(x) (*(const GLboolean*)&x) -#define GLXEW_GET_FUN(x) x - -extern GLboolean glxewIsSupported (const char* name); - -#endif /* GLEW_MX */ - -extern GLboolean glxewGetExtension (const char* name); - -#ifdef __cplusplus -} -#endif - -#endif /* __glxew_h__ */ diff --git a/oversampling/WDL/lice/glew/include/GL/wglew.h b/oversampling/WDL/lice/glew/include/GL/wglew.h deleted file mode 100644 index 2eaad36..0000000 --- a/oversampling/WDL/lice/glew/include/GL/wglew.h +++ /dev/null @@ -1,1165 +0,0 @@ -/* -** The OpenGL Extension Wrangler Library -** Copyright (C) 2002-2008, Milan Ikits -** Copyright (C) 2002-2008, Marcelo E. Magallon -** Copyright (C) 2002, Lev Povalahev -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** -** * Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** * The name of the author may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -** THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* -** Copyright (c) 2007 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are 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 Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#ifndef __wglew_h__ -#define __wglew_h__ -#define __WGLEW_H__ - -#ifdef __wglext_h_ -#error wglext.h included before wglew.h -#endif - -#define __wglext_h_ - -#if !defined(APIENTRY) && !defined(__CYGWIN__) -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN 1 -# endif -#include -#endif - -/* - * GLEW_STATIC needs to be set when using the static version. - * GLEW_BUILD is set when building the DLL version. - */ -#ifdef GLEW_STATIC -# define GLEWAPI extern -#else -# ifdef GLEW_BUILD -# define GLEWAPI extern __declspec(dllexport) -# else -# define GLEWAPI extern __declspec(dllimport) -# endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* -------------------------- WGL_3DFX_multisample ------------------------- */ - -#ifndef WGL_3DFX_multisample -#define WGL_3DFX_multisample 1 - -#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 -#define WGL_SAMPLES_3DFX 0x2061 - -#define WGLEW_3DFX_multisample WGLEW_GET_VAR(__WGLEW_3DFX_multisample) - -#endif /* WGL_3DFX_multisample */ - -/* ------------------------- WGL_3DL_stereo_control ------------------------ */ - -#ifndef WGL_3DL_stereo_control -#define WGL_3DL_stereo_control 1 - -#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 -#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 -#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 -#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 - -typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); - -#define wglSetStereoEmitterState3DL WGLEW_GET_FUN(__wglewSetStereoEmitterState3DL) - -#define WGLEW_3DL_stereo_control WGLEW_GET_VAR(__WGLEW_3DL_stereo_control) - -#endif /* WGL_3DL_stereo_control */ - -/* ------------------------- WGL_ARB_buffer_region ------------------------- */ - -#ifndef WGL_ARB_buffer_region -#define WGL_ARB_buffer_region 1 - -#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 -#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 -#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 -#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 - -typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); -typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); -typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); -typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); - -#define wglCreateBufferRegionARB WGLEW_GET_FUN(__wglewCreateBufferRegionARB) -#define wglDeleteBufferRegionARB WGLEW_GET_FUN(__wglewDeleteBufferRegionARB) -#define wglRestoreBufferRegionARB WGLEW_GET_FUN(__wglewRestoreBufferRegionARB) -#define wglSaveBufferRegionARB WGLEW_GET_FUN(__wglewSaveBufferRegionARB) - -#define WGLEW_ARB_buffer_region WGLEW_GET_VAR(__WGLEW_ARB_buffer_region) - -#endif /* WGL_ARB_buffer_region */ - -/* ------------------------- WGL_ARB_create_context ------------------------ */ - -#ifndef WGL_ARB_create_context -#define WGL_ARB_create_context 1 - -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 -#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 - -typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int* attribList); - -#define wglCreateContextAttribsARB WGLEW_GET_FUN(__wglewCreateContextAttribsARB) - -#define WGLEW_ARB_create_context WGLEW_GET_VAR(__WGLEW_ARB_create_context) - -#endif /* WGL_ARB_create_context */ - -/* ----------------------- WGL_ARB_extensions_string ----------------------- */ - -#ifndef WGL_ARB_extensions_string -#define WGL_ARB_extensions_string 1 - -typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); - -#define wglGetExtensionsStringARB WGLEW_GET_FUN(__wglewGetExtensionsStringARB) - -#define WGLEW_ARB_extensions_string WGLEW_GET_VAR(__WGLEW_ARB_extensions_string) - -#endif /* WGL_ARB_extensions_string */ - -/* ------------------------ WGL_ARB_framebuffer_sRGB ----------------------- */ - -#ifndef WGL_ARB_framebuffer_sRGB -#define WGL_ARB_framebuffer_sRGB 1 - -#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 - -#define WGLEW_ARB_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_ARB_framebuffer_sRGB) - -#endif /* WGL_ARB_framebuffer_sRGB */ - -/* ----------------------- WGL_ARB_make_current_read ----------------------- */ - -#ifndef WGL_ARB_make_current_read -#define WGL_ARB_make_current_read 1 - -#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 -#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 - -typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (VOID); -typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); - -#define wglGetCurrentReadDCARB WGLEW_GET_FUN(__wglewGetCurrentReadDCARB) -#define wglMakeContextCurrentARB WGLEW_GET_FUN(__wglewMakeContextCurrentARB) - -#define WGLEW_ARB_make_current_read WGLEW_GET_VAR(__WGLEW_ARB_make_current_read) - -#endif /* WGL_ARB_make_current_read */ - -/* -------------------------- WGL_ARB_multisample -------------------------- */ - -#ifndef WGL_ARB_multisample -#define WGL_ARB_multisample 1 - -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 - -#define WGLEW_ARB_multisample WGLEW_GET_VAR(__WGLEW_ARB_multisample) - -#endif /* WGL_ARB_multisample */ - -/* ---------------------------- WGL_ARB_pbuffer ---------------------------- */ - -#ifndef WGL_ARB_pbuffer -#define WGL_ARB_pbuffer 1 - -#define WGL_DRAW_TO_PBUFFER_ARB 0x202D -#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E -#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 -#define WGL_PBUFFER_LARGEST_ARB 0x2033 -#define WGL_PBUFFER_WIDTH_ARB 0x2034 -#define WGL_PBUFFER_HEIGHT_ARB 0x2035 -#define WGL_PBUFFER_LOST_ARB 0x2036 - -DECLARE_HANDLE(HPBUFFERARB); - -typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int* piValue); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); - -#define wglCreatePbufferARB WGLEW_GET_FUN(__wglewCreatePbufferARB) -#define wglDestroyPbufferARB WGLEW_GET_FUN(__wglewDestroyPbufferARB) -#define wglGetPbufferDCARB WGLEW_GET_FUN(__wglewGetPbufferDCARB) -#define wglQueryPbufferARB WGLEW_GET_FUN(__wglewQueryPbufferARB) -#define wglReleasePbufferDCARB WGLEW_GET_FUN(__wglewReleasePbufferDCARB) - -#define WGLEW_ARB_pbuffer WGLEW_GET_VAR(__WGLEW_ARB_pbuffer) - -#endif /* WGL_ARB_pbuffer */ - -/* -------------------------- WGL_ARB_pixel_format ------------------------- */ - -#ifndef WGL_ARB_pixel_format -#define WGL_ARB_pixel_format 1 - -#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 -#define WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define WGL_DRAW_TO_BITMAP_ARB 0x2002 -#define WGL_ACCELERATION_ARB 0x2003 -#define WGL_NEED_PALETTE_ARB 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 -#define WGL_SWAP_METHOD_ARB 0x2007 -#define WGL_NUMBER_OVERLAYS_ARB 0x2008 -#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 -#define WGL_TRANSPARENT_ARB 0x200A -#define WGL_SHARE_DEPTH_ARB 0x200C -#define WGL_SHARE_STENCIL_ARB 0x200D -#define WGL_SHARE_ACCUM_ARB 0x200E -#define WGL_SUPPORT_GDI_ARB 0x200F -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_STEREO_ARB 0x2012 -#define WGL_PIXEL_TYPE_ARB 0x2013 -#define WGL_COLOR_BITS_ARB 0x2014 -#define WGL_RED_BITS_ARB 0x2015 -#define WGL_RED_SHIFT_ARB 0x2016 -#define WGL_GREEN_BITS_ARB 0x2017 -#define WGL_GREEN_SHIFT_ARB 0x2018 -#define WGL_BLUE_BITS_ARB 0x2019 -#define WGL_BLUE_SHIFT_ARB 0x201A -#define WGL_ALPHA_BITS_ARB 0x201B -#define WGL_ALPHA_SHIFT_ARB 0x201C -#define WGL_ACCUM_BITS_ARB 0x201D -#define WGL_ACCUM_RED_BITS_ARB 0x201E -#define WGL_ACCUM_GREEN_BITS_ARB 0x201F -#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 -#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 -#define WGL_AUX_BUFFERS_ARB 0x2024 -#define WGL_NO_ACCELERATION_ARB 0x2025 -#define WGL_GENERIC_ACCELERATION_ARB 0x2026 -#define WGL_FULL_ACCELERATION_ARB 0x2027 -#define WGL_SWAP_EXCHANGE_ARB 0x2028 -#define WGL_SWAP_COPY_ARB 0x2029 -#define WGL_SWAP_UNDEFINED_ARB 0x202A -#define WGL_TYPE_RGBA_ARB 0x202B -#define WGL_TYPE_COLORINDEX_ARB 0x202C -#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 -#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 -#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 -#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A -#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B - -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, int *piValues); - -#define wglChoosePixelFormatARB WGLEW_GET_FUN(__wglewChoosePixelFormatARB) -#define wglGetPixelFormatAttribfvARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvARB) -#define wglGetPixelFormatAttribivARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribivARB) - -#define WGLEW_ARB_pixel_format WGLEW_GET_VAR(__WGLEW_ARB_pixel_format) - -#endif /* WGL_ARB_pixel_format */ - -/* ----------------------- WGL_ARB_pixel_format_float ---------------------- */ - -#ifndef WGL_ARB_pixel_format_float -#define WGL_ARB_pixel_format_float 1 - -#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 - -#define WGLEW_ARB_pixel_format_float WGLEW_GET_VAR(__WGLEW_ARB_pixel_format_float) - -#endif /* WGL_ARB_pixel_format_float */ - -/* ------------------------- WGL_ARB_render_texture ------------------------ */ - -#ifndef WGL_ARB_render_texture -#define WGL_ARB_render_texture 1 - -#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 -#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 -#define WGL_TEXTURE_FORMAT_ARB 0x2072 -#define WGL_TEXTURE_TARGET_ARB 0x2073 -#define WGL_MIPMAP_TEXTURE_ARB 0x2074 -#define WGL_TEXTURE_RGB_ARB 0x2075 -#define WGL_TEXTURE_RGBA_ARB 0x2076 -#define WGL_NO_TEXTURE_ARB 0x2077 -#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 -#define WGL_TEXTURE_1D_ARB 0x2079 -#define WGL_TEXTURE_2D_ARB 0x207A -#define WGL_MIPMAP_LEVEL_ARB 0x207B -#define WGL_CUBE_MAP_FACE_ARB 0x207C -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 -#define WGL_FRONT_LEFT_ARB 0x2083 -#define WGL_FRONT_RIGHT_ARB 0x2084 -#define WGL_BACK_LEFT_ARB 0x2085 -#define WGL_BACK_RIGHT_ARB 0x2086 -#define WGL_AUX0_ARB 0x2087 -#define WGL_AUX1_ARB 0x2088 -#define WGL_AUX2_ARB 0x2089 -#define WGL_AUX3_ARB 0x208A -#define WGL_AUX4_ARB 0x208B -#define WGL_AUX5_ARB 0x208C -#define WGL_AUX6_ARB 0x208D -#define WGL_AUX7_ARB 0x208E -#define WGL_AUX8_ARB 0x208F -#define WGL_AUX9_ARB 0x2090 - -typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int* piAttribList); - -#define wglBindTexImageARB WGLEW_GET_FUN(__wglewBindTexImageARB) -#define wglReleaseTexImageARB WGLEW_GET_FUN(__wglewReleaseTexImageARB) -#define wglSetPbufferAttribARB WGLEW_GET_FUN(__wglewSetPbufferAttribARB) - -#define WGLEW_ARB_render_texture WGLEW_GET_VAR(__WGLEW_ARB_render_texture) - -#endif /* WGL_ARB_render_texture */ - -/* ----------------------- WGL_ATI_pixel_format_float ---------------------- */ - -#ifndef WGL_ATI_pixel_format_float -#define WGL_ATI_pixel_format_float 1 - -#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 -#define GL_RGBA_FLOAT_MODE_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 - -#define WGLEW_ATI_pixel_format_float WGLEW_GET_VAR(__WGLEW_ATI_pixel_format_float) - -#endif /* WGL_ATI_pixel_format_float */ - -/* -------------------- WGL_ATI_render_texture_rectangle ------------------- */ - -#ifndef WGL_ATI_render_texture_rectangle -#define WGL_ATI_render_texture_rectangle 1 - -#define WGL_TEXTURE_RECTANGLE_ATI 0x21A5 - -#define WGLEW_ATI_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_ATI_render_texture_rectangle) - -#endif /* WGL_ATI_render_texture_rectangle */ - -/* -------------------------- WGL_EXT_depth_float -------------------------- */ - -#ifndef WGL_EXT_depth_float -#define WGL_EXT_depth_float 1 - -#define WGL_DEPTH_FLOAT_EXT 0x2040 - -#define WGLEW_EXT_depth_float WGLEW_GET_VAR(__WGLEW_EXT_depth_float) - -#endif /* WGL_EXT_depth_float */ - -/* ---------------------- WGL_EXT_display_color_table ---------------------- */ - -#ifndef WGL_EXT_display_color_table -#define WGL_EXT_display_color_table 1 - -typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef void (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); -typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (GLushort* table, GLuint length); - -#define wglBindDisplayColorTableEXT WGLEW_GET_FUN(__wglewBindDisplayColorTableEXT) -#define wglCreateDisplayColorTableEXT WGLEW_GET_FUN(__wglewCreateDisplayColorTableEXT) -#define wglDestroyDisplayColorTableEXT WGLEW_GET_FUN(__wglewDestroyDisplayColorTableEXT) -#define wglLoadDisplayColorTableEXT WGLEW_GET_FUN(__wglewLoadDisplayColorTableEXT) - -#define WGLEW_EXT_display_color_table WGLEW_GET_VAR(__WGLEW_EXT_display_color_table) - -#endif /* WGL_EXT_display_color_table */ - -/* ----------------------- WGL_EXT_extensions_string ----------------------- */ - -#ifndef WGL_EXT_extensions_string -#define WGL_EXT_extensions_string 1 - -typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); - -#define wglGetExtensionsStringEXT WGLEW_GET_FUN(__wglewGetExtensionsStringEXT) - -#define WGLEW_EXT_extensions_string WGLEW_GET_VAR(__WGLEW_EXT_extensions_string) - -#endif /* WGL_EXT_extensions_string */ - -/* ------------------------ WGL_EXT_framebuffer_sRGB ----------------------- */ - -#ifndef WGL_EXT_framebuffer_sRGB -#define WGL_EXT_framebuffer_sRGB 1 - -#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 - -#define WGLEW_EXT_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_EXT_framebuffer_sRGB) - -#endif /* WGL_EXT_framebuffer_sRGB */ - -/* ----------------------- WGL_EXT_make_current_read ----------------------- */ - -#ifndef WGL_EXT_make_current_read -#define WGL_EXT_make_current_read 1 - -#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 - -typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (VOID); -typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); - -#define wglGetCurrentReadDCEXT WGLEW_GET_FUN(__wglewGetCurrentReadDCEXT) -#define wglMakeContextCurrentEXT WGLEW_GET_FUN(__wglewMakeContextCurrentEXT) - -#define WGLEW_EXT_make_current_read WGLEW_GET_VAR(__WGLEW_EXT_make_current_read) - -#endif /* WGL_EXT_make_current_read */ - -/* -------------------------- WGL_EXT_multisample -------------------------- */ - -#ifndef WGL_EXT_multisample -#define WGL_EXT_multisample 1 - -#define WGL_SAMPLE_BUFFERS_EXT 0x2041 -#define WGL_SAMPLES_EXT 0x2042 - -#define WGLEW_EXT_multisample WGLEW_GET_VAR(__WGLEW_EXT_multisample) - -#endif /* WGL_EXT_multisample */ - -/* ---------------------------- WGL_EXT_pbuffer ---------------------------- */ - -#ifndef WGL_EXT_pbuffer -#define WGL_EXT_pbuffer 1 - -#define WGL_DRAW_TO_PBUFFER_EXT 0x202D -#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E -#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 -#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 -#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 -#define WGL_PBUFFER_LARGEST_EXT 0x2033 -#define WGL_PBUFFER_WIDTH_EXT 0x2034 -#define WGL_PBUFFER_HEIGHT_EXT 0x2035 - -DECLARE_HANDLE(HPBUFFEREXT); - -typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int* piValue); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); - -#define wglCreatePbufferEXT WGLEW_GET_FUN(__wglewCreatePbufferEXT) -#define wglDestroyPbufferEXT WGLEW_GET_FUN(__wglewDestroyPbufferEXT) -#define wglGetPbufferDCEXT WGLEW_GET_FUN(__wglewGetPbufferDCEXT) -#define wglQueryPbufferEXT WGLEW_GET_FUN(__wglewQueryPbufferEXT) -#define wglReleasePbufferDCEXT WGLEW_GET_FUN(__wglewReleasePbufferDCEXT) - -#define WGLEW_EXT_pbuffer WGLEW_GET_VAR(__WGLEW_EXT_pbuffer) - -#endif /* WGL_EXT_pbuffer */ - -/* -------------------------- WGL_EXT_pixel_format ------------------------- */ - -#ifndef WGL_EXT_pixel_format -#define WGL_EXT_pixel_format 1 - -#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 -#define WGL_DRAW_TO_WINDOW_EXT 0x2001 -#define WGL_DRAW_TO_BITMAP_EXT 0x2002 -#define WGL_ACCELERATION_EXT 0x2003 -#define WGL_NEED_PALETTE_EXT 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 -#define WGL_SWAP_METHOD_EXT 0x2007 -#define WGL_NUMBER_OVERLAYS_EXT 0x2008 -#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 -#define WGL_TRANSPARENT_EXT 0x200A -#define WGL_TRANSPARENT_VALUE_EXT 0x200B -#define WGL_SHARE_DEPTH_EXT 0x200C -#define WGL_SHARE_STENCIL_EXT 0x200D -#define WGL_SHARE_ACCUM_EXT 0x200E -#define WGL_SUPPORT_GDI_EXT 0x200F -#define WGL_SUPPORT_OPENGL_EXT 0x2010 -#define WGL_DOUBLE_BUFFER_EXT 0x2011 -#define WGL_STEREO_EXT 0x2012 -#define WGL_PIXEL_TYPE_EXT 0x2013 -#define WGL_COLOR_BITS_EXT 0x2014 -#define WGL_RED_BITS_EXT 0x2015 -#define WGL_RED_SHIFT_EXT 0x2016 -#define WGL_GREEN_BITS_EXT 0x2017 -#define WGL_GREEN_SHIFT_EXT 0x2018 -#define WGL_BLUE_BITS_EXT 0x2019 -#define WGL_BLUE_SHIFT_EXT 0x201A -#define WGL_ALPHA_BITS_EXT 0x201B -#define WGL_ALPHA_SHIFT_EXT 0x201C -#define WGL_ACCUM_BITS_EXT 0x201D -#define WGL_ACCUM_RED_BITS_EXT 0x201E -#define WGL_ACCUM_GREEN_BITS_EXT 0x201F -#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 -#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 -#define WGL_DEPTH_BITS_EXT 0x2022 -#define WGL_STENCIL_BITS_EXT 0x2023 -#define WGL_AUX_BUFFERS_EXT 0x2024 -#define WGL_NO_ACCELERATION_EXT 0x2025 -#define WGL_GENERIC_ACCELERATION_EXT 0x2026 -#define WGL_FULL_ACCELERATION_EXT 0x2027 -#define WGL_SWAP_EXCHANGE_EXT 0x2028 -#define WGL_SWAP_COPY_EXT 0x2029 -#define WGL_SWAP_UNDEFINED_EXT 0x202A -#define WGL_TYPE_RGBA_EXT 0x202B -#define WGL_TYPE_COLORINDEX_EXT 0x202C - -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues); - -#define wglChoosePixelFormatEXT WGLEW_GET_FUN(__wglewChoosePixelFormatEXT) -#define wglGetPixelFormatAttribfvEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvEXT) -#define wglGetPixelFormatAttribivEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribivEXT) - -#define WGLEW_EXT_pixel_format WGLEW_GET_VAR(__WGLEW_EXT_pixel_format) - -#endif /* WGL_EXT_pixel_format */ - -/* ------------------- WGL_EXT_pixel_format_packed_float ------------------- */ - -#ifndef WGL_EXT_pixel_format_packed_float -#define WGL_EXT_pixel_format_packed_float 1 - -#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 - -#define WGLEW_EXT_pixel_format_packed_float WGLEW_GET_VAR(__WGLEW_EXT_pixel_format_packed_float) - -#endif /* WGL_EXT_pixel_format_packed_float */ - -/* -------------------------- WGL_EXT_swap_control ------------------------- */ - -#ifndef WGL_EXT_swap_control -#define WGL_EXT_swap_control 1 - -typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); -typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); - -#define wglGetSwapIntervalEXT WGLEW_GET_FUN(__wglewGetSwapIntervalEXT) -#define wglSwapIntervalEXT WGLEW_GET_FUN(__wglewSwapIntervalEXT) - -#define WGLEW_EXT_swap_control WGLEW_GET_VAR(__WGLEW_EXT_swap_control) - -#endif /* WGL_EXT_swap_control */ - -/* --------------------- WGL_I3D_digital_video_control --------------------- */ - -#ifndef WGL_I3D_digital_video_control -#define WGL_I3D_digital_video_control 1 - -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 -#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 -#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 - -typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue); -typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue); - -#define wglGetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewGetDigitalVideoParametersI3D) -#define wglSetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewSetDigitalVideoParametersI3D) - -#define WGLEW_I3D_digital_video_control WGLEW_GET_VAR(__WGLEW_I3D_digital_video_control) - -#endif /* WGL_I3D_digital_video_control */ - -/* ----------------------------- WGL_I3D_gamma ----------------------------- */ - -#ifndef WGL_I3D_gamma -#define WGL_I3D_gamma 1 - -#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E -#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F - -typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT* puRed, USHORT *puGreen, USHORT *puBlue); -typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue); -typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT* puRed, const USHORT *puGreen, const USHORT *puBlue); -typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue); - -#define wglGetGammaTableI3D WGLEW_GET_FUN(__wglewGetGammaTableI3D) -#define wglGetGammaTableParametersI3D WGLEW_GET_FUN(__wglewGetGammaTableParametersI3D) -#define wglSetGammaTableI3D WGLEW_GET_FUN(__wglewSetGammaTableI3D) -#define wglSetGammaTableParametersI3D WGLEW_GET_FUN(__wglewSetGammaTableParametersI3D) - -#define WGLEW_I3D_gamma WGLEW_GET_VAR(__WGLEW_I3D_gamma) - -#endif /* WGL_I3D_gamma */ - -/* ---------------------------- WGL_I3D_genlock ---------------------------- */ - -#ifndef WGL_I3D_genlock -#define WGL_I3D_genlock 1 - -#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 -#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 -#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 -#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 -#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 -#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 -#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A -#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B -#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C - -typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); -typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); -typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); -typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT* uRate); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT* uDelay); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT* uEdge); -typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT* uSource); -typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL* pFlag); -typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT* uMaxLineDelay, UINT *uMaxPixelDelay); - -#define wglDisableGenlockI3D WGLEW_GET_FUN(__wglewDisableGenlockI3D) -#define wglEnableGenlockI3D WGLEW_GET_FUN(__wglewEnableGenlockI3D) -#define wglGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGenlockSampleRateI3D) -#define wglGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGenlockSourceDelayI3D) -#define wglGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGenlockSourceEdgeI3D) -#define wglGenlockSourceI3D WGLEW_GET_FUN(__wglewGenlockSourceI3D) -#define wglGetGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGetGenlockSampleRateI3D) -#define wglGetGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGetGenlockSourceDelayI3D) -#define wglGetGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGetGenlockSourceEdgeI3D) -#define wglGetGenlockSourceI3D WGLEW_GET_FUN(__wglewGetGenlockSourceI3D) -#define wglIsEnabledGenlockI3D WGLEW_GET_FUN(__wglewIsEnabledGenlockI3D) -#define wglQueryGenlockMaxSourceDelayI3D WGLEW_GET_FUN(__wglewQueryGenlockMaxSourceDelayI3D) - -#define WGLEW_I3D_genlock WGLEW_GET_VAR(__WGLEW_I3D_genlock) - -#endif /* WGL_I3D_genlock */ - -/* -------------------------- WGL_I3D_image_buffer ------------------------- */ - -#ifndef WGL_I3D_image_buffer -#define WGL_I3D_image_buffer 1 - -#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 -#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 - -typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, HANDLE* pEvent, LPVOID *pAddress, DWORD *pSize, UINT count); -typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); -typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); -typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, LPVOID* pAddress, UINT count); - -#define wglAssociateImageBufferEventsI3D WGLEW_GET_FUN(__wglewAssociateImageBufferEventsI3D) -#define wglCreateImageBufferI3D WGLEW_GET_FUN(__wglewCreateImageBufferI3D) -#define wglDestroyImageBufferI3D WGLEW_GET_FUN(__wglewDestroyImageBufferI3D) -#define wglReleaseImageBufferEventsI3D WGLEW_GET_FUN(__wglewReleaseImageBufferEventsI3D) - -#define WGLEW_I3D_image_buffer WGLEW_GET_VAR(__WGLEW_I3D_image_buffer) - -#endif /* WGL_I3D_image_buffer */ - -/* ------------------------ WGL_I3D_swap_frame_lock ------------------------ */ - -#ifndef WGL_I3D_swap_frame_lock -#define WGL_I3D_swap_frame_lock 1 - -typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (VOID); -typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (VOID); -typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL* pFlag); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL* pFlag); - -#define wglDisableFrameLockI3D WGLEW_GET_FUN(__wglewDisableFrameLockI3D) -#define wglEnableFrameLockI3D WGLEW_GET_FUN(__wglewEnableFrameLockI3D) -#define wglIsEnabledFrameLockI3D WGLEW_GET_FUN(__wglewIsEnabledFrameLockI3D) -#define wglQueryFrameLockMasterI3D WGLEW_GET_FUN(__wglewQueryFrameLockMasterI3D) - -#define WGLEW_I3D_swap_frame_lock WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_lock) - -#endif /* WGL_I3D_swap_frame_lock */ - -/* ------------------------ WGL_I3D_swap_frame_usage ----------------------- */ - -#ifndef WGL_I3D_swap_frame_usage -#define WGL_I3D_swap_frame_usage 1 - -typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); -typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float* pUsage); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD* pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); - -#define wglBeginFrameTrackingI3D WGLEW_GET_FUN(__wglewBeginFrameTrackingI3D) -#define wglEndFrameTrackingI3D WGLEW_GET_FUN(__wglewEndFrameTrackingI3D) -#define wglGetFrameUsageI3D WGLEW_GET_FUN(__wglewGetFrameUsageI3D) -#define wglQueryFrameTrackingI3D WGLEW_GET_FUN(__wglewQueryFrameTrackingI3D) - -#define WGLEW_I3D_swap_frame_usage WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_usage) - -#endif /* WGL_I3D_swap_frame_usage */ - -/* -------------------------- WGL_NV_float_buffer -------------------------- */ - -#ifndef WGL_NV_float_buffer -#define WGL_NV_float_buffer 1 - -#define WGL_FLOAT_COMPONENTS_NV 0x20B0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 -#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 -#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 -#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 -#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 - -#define WGLEW_NV_float_buffer WGLEW_GET_VAR(__WGLEW_NV_float_buffer) - -#endif /* WGL_NV_float_buffer */ - -/* -------------------------- WGL_NV_gpu_affinity -------------------------- */ - -#ifndef WGL_NV_gpu_affinity -#define WGL_NV_gpu_affinity 1 - -#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 -#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 - -DECLARE_HANDLE(HGPUNV); -typedef struct _GPU_DEVICE { - DWORD cb; - CHAR DeviceName[32]; - CHAR DeviceString[128]; - DWORD Flags; - RECT rcVirtualScreen; -} GPU_DEVICE, *PGPU_DEVICE; - -typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); -typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); -typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); -typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); -typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); - -#define wglCreateAffinityDCNV WGLEW_GET_FUN(__wglewCreateAffinityDCNV) -#define wglDeleteDCNV WGLEW_GET_FUN(__wglewDeleteDCNV) -#define wglEnumGpuDevicesNV WGLEW_GET_FUN(__wglewEnumGpuDevicesNV) -#define wglEnumGpusFromAffinityDCNV WGLEW_GET_FUN(__wglewEnumGpusFromAffinityDCNV) -#define wglEnumGpusNV WGLEW_GET_FUN(__wglewEnumGpusNV) - -#define WGLEW_NV_gpu_affinity WGLEW_GET_VAR(__WGLEW_NV_gpu_affinity) - -#endif /* WGL_NV_gpu_affinity */ - -/* -------------------------- WGL_NV_present_video ------------------------- */ - -#ifndef WGL_NV_present_video -#define WGL_NV_present_video 1 - -#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 - -DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); - -typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int* piAttribList); -typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV* phDeviceList); -typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int* piValue); - -#define wglBindVideoDeviceNV WGLEW_GET_FUN(__wglewBindVideoDeviceNV) -#define wglEnumerateVideoDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoDevicesNV) -#define wglQueryCurrentContextNV WGLEW_GET_FUN(__wglewQueryCurrentContextNV) - -#define WGLEW_NV_present_video WGLEW_GET_VAR(__WGLEW_NV_present_video) - -#endif /* WGL_NV_present_video */ - -/* ---------------------- WGL_NV_render_depth_texture ---------------------- */ - -#ifndef WGL_NV_render_depth_texture -#define WGL_NV_render_depth_texture 1 - -#define WGL_NO_TEXTURE_ARB 0x2077 -#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 -#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 -#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 -#define WGL_DEPTH_COMPONENT_NV 0x20A7 - -#define WGLEW_NV_render_depth_texture WGLEW_GET_VAR(__WGLEW_NV_render_depth_texture) - -#endif /* WGL_NV_render_depth_texture */ - -/* -------------------- WGL_NV_render_texture_rectangle -------------------- */ - -#ifndef WGL_NV_render_texture_rectangle -#define WGL_NV_render_texture_rectangle 1 - -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 -#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 - -#define WGLEW_NV_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_NV_render_texture_rectangle) - -#endif /* WGL_NV_render_texture_rectangle */ - -/* --------------------------- WGL_NV_swap_group --------------------------- */ - -#ifndef WGL_NV_swap_group -#define WGL_NV_swap_group 1 - -typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); -typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); -typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint* count); -typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint* maxGroups, GLuint *maxBarriers); -typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint* group); -typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); - -#define wglBindSwapBarrierNV WGLEW_GET_FUN(__wglewBindSwapBarrierNV) -#define wglJoinSwapGroupNV WGLEW_GET_FUN(__wglewJoinSwapGroupNV) -#define wglQueryFrameCountNV WGLEW_GET_FUN(__wglewQueryFrameCountNV) -#define wglQueryMaxSwapGroupsNV WGLEW_GET_FUN(__wglewQueryMaxSwapGroupsNV) -#define wglQuerySwapGroupNV WGLEW_GET_FUN(__wglewQuerySwapGroupNV) -#define wglResetFrameCountNV WGLEW_GET_FUN(__wglewResetFrameCountNV) - -#define WGLEW_NV_swap_group WGLEW_GET_VAR(__WGLEW_NV_swap_group) - -#endif /* WGL_NV_swap_group */ - -/* ----------------------- WGL_NV_vertex_array_range ----------------------- */ - -#ifndef WGL_NV_vertex_array_range -#define WGL_NV_vertex_array_range 1 - -typedef void * (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority); -typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); - -#define wglAllocateMemoryNV WGLEW_GET_FUN(__wglewAllocateMemoryNV) -#define wglFreeMemoryNV WGLEW_GET_FUN(__wglewFreeMemoryNV) - -#define WGLEW_NV_vertex_array_range WGLEW_GET_VAR(__WGLEW_NV_vertex_array_range) - -#endif /* WGL_NV_vertex_array_range */ - -/* -------------------------- WGL_NV_video_output -------------------------- */ - -#ifndef WGL_NV_video_output -#define WGL_NV_video_output 1 - -#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 -#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 -#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 -#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 -#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 -#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 -#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 -#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 -#define WGL_VIDEO_OUT_FRAME 0x20C8 -#define WGL_VIDEO_OUT_FIELD_1 0x20C9 -#define WGL_VIDEO_OUT_FIELD_2 0x20CA -#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB -#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC - -DECLARE_HANDLE(HPVIDEODEV); - -typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); -typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV* hVideoDevice); -typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long* pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); -typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); -typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long* pulCounterPbuffer, BOOL bBlock); - -#define wglBindVideoImageNV WGLEW_GET_FUN(__wglewBindVideoImageNV) -#define wglGetVideoDeviceNV WGLEW_GET_FUN(__wglewGetVideoDeviceNV) -#define wglGetVideoInfoNV WGLEW_GET_FUN(__wglewGetVideoInfoNV) -#define wglReleaseVideoDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoDeviceNV) -#define wglReleaseVideoImageNV WGLEW_GET_FUN(__wglewReleaseVideoImageNV) -#define wglSendPbufferToVideoNV WGLEW_GET_FUN(__wglewSendPbufferToVideoNV) - -#define WGLEW_NV_video_output WGLEW_GET_VAR(__WGLEW_NV_video_output) - -#endif /* WGL_NV_video_output */ - -/* -------------------------- WGL_OML_sync_control ------------------------- */ - -#ifndef WGL_OML_sync_control -#define WGL_OML_sync_control 1 - -typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32* numerator, INT32 *denominator); -typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64* ust, INT64 *msc, INT64 *sbc); -typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64* ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64* ust, INT64 *msc, INT64 *sbc); - -#define wglGetMscRateOML WGLEW_GET_FUN(__wglewGetMscRateOML) -#define wglGetSyncValuesOML WGLEW_GET_FUN(__wglewGetSyncValuesOML) -#define wglSwapBuffersMscOML WGLEW_GET_FUN(__wglewSwapBuffersMscOML) -#define wglSwapLayerBuffersMscOML WGLEW_GET_FUN(__wglewSwapLayerBuffersMscOML) -#define wglWaitForMscOML WGLEW_GET_FUN(__wglewWaitForMscOML) -#define wglWaitForSbcOML WGLEW_GET_FUN(__wglewWaitForSbcOML) - -#define WGLEW_OML_sync_control WGLEW_GET_VAR(__WGLEW_OML_sync_control) - -#endif /* WGL_OML_sync_control */ - -/* ------------------------------------------------------------------------- */ - -#ifdef GLEW_MX -#define WGLEW_EXPORT -#else -#define WGLEW_EXPORT GLEWAPI -#endif /* GLEW_MX */ - -#ifdef GLEW_MX -struct WGLEWContextStruct -{ -#endif /* GLEW_MX */ - -WGLEW_EXPORT PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL; - -WGLEW_EXPORT PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB; -WGLEW_EXPORT PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB; -WGLEW_EXPORT PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB; -WGLEW_EXPORT PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB; - -WGLEW_EXPORT PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB; - -WGLEW_EXPORT PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB; - -WGLEW_EXPORT PFNWGLGETCURRENTREADDCARBPROC __wglewGetCurrentReadDCARB; -WGLEW_EXPORT PFNWGLMAKECONTEXTCURRENTARBPROC __wglewMakeContextCurrentARB; - -WGLEW_EXPORT PFNWGLCREATEPBUFFERARBPROC __wglewCreatePbufferARB; -WGLEW_EXPORT PFNWGLDESTROYPBUFFERARBPROC __wglewDestroyPbufferARB; -WGLEW_EXPORT PFNWGLGETPBUFFERDCARBPROC __wglewGetPbufferDCARB; -WGLEW_EXPORT PFNWGLQUERYPBUFFERARBPROC __wglewQueryPbufferARB; -WGLEW_EXPORT PFNWGLRELEASEPBUFFERDCARBPROC __wglewReleasePbufferDCARB; - -WGLEW_EXPORT PFNWGLCHOOSEPIXELFORMATARBPROC __wglewChoosePixelFormatARB; -WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBFVARBPROC __wglewGetPixelFormatAttribfvARB; -WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBIVARBPROC __wglewGetPixelFormatAttribivARB; - -WGLEW_EXPORT PFNWGLBINDTEXIMAGEARBPROC __wglewBindTexImageARB; -WGLEW_EXPORT PFNWGLRELEASETEXIMAGEARBPROC __wglewReleaseTexImageARB; -WGLEW_EXPORT PFNWGLSETPBUFFERATTRIBARBPROC __wglewSetPbufferAttribARB; - -WGLEW_EXPORT PFNWGLBINDDISPLAYCOLORTABLEEXTPROC __wglewBindDisplayColorTableEXT; -WGLEW_EXPORT PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC __wglewCreateDisplayColorTableEXT; -WGLEW_EXPORT PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC __wglewDestroyDisplayColorTableEXT; -WGLEW_EXPORT PFNWGLLOADDISPLAYCOLORTABLEEXTPROC __wglewLoadDisplayColorTableEXT; - -WGLEW_EXPORT PFNWGLGETEXTENSIONSSTRINGEXTPROC __wglewGetExtensionsStringEXT; - -WGLEW_EXPORT PFNWGLGETCURRENTREADDCEXTPROC __wglewGetCurrentReadDCEXT; -WGLEW_EXPORT PFNWGLMAKECONTEXTCURRENTEXTPROC __wglewMakeContextCurrentEXT; - -WGLEW_EXPORT PFNWGLCREATEPBUFFEREXTPROC __wglewCreatePbufferEXT; -WGLEW_EXPORT PFNWGLDESTROYPBUFFEREXTPROC __wglewDestroyPbufferEXT; -WGLEW_EXPORT PFNWGLGETPBUFFERDCEXTPROC __wglewGetPbufferDCEXT; -WGLEW_EXPORT PFNWGLQUERYPBUFFEREXTPROC __wglewQueryPbufferEXT; -WGLEW_EXPORT PFNWGLRELEASEPBUFFERDCEXTPROC __wglewReleasePbufferDCEXT; - -WGLEW_EXPORT PFNWGLCHOOSEPIXELFORMATEXTPROC __wglewChoosePixelFormatEXT; -WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBFVEXTPROC __wglewGetPixelFormatAttribfvEXT; -WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBIVEXTPROC __wglewGetPixelFormatAttribivEXT; - -WGLEW_EXPORT PFNWGLGETSWAPINTERVALEXTPROC __wglewGetSwapIntervalEXT; -WGLEW_EXPORT PFNWGLSWAPINTERVALEXTPROC __wglewSwapIntervalEXT; - -WGLEW_EXPORT PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC __wglewGetDigitalVideoParametersI3D; -WGLEW_EXPORT PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC __wglewSetDigitalVideoParametersI3D; - -WGLEW_EXPORT PFNWGLGETGAMMATABLEI3DPROC __wglewGetGammaTableI3D; -WGLEW_EXPORT PFNWGLGETGAMMATABLEPARAMETERSI3DPROC __wglewGetGammaTableParametersI3D; -WGLEW_EXPORT PFNWGLSETGAMMATABLEI3DPROC __wglewSetGammaTableI3D; -WGLEW_EXPORT PFNWGLSETGAMMATABLEPARAMETERSI3DPROC __wglewSetGammaTableParametersI3D; - -WGLEW_EXPORT PFNWGLDISABLEGENLOCKI3DPROC __wglewDisableGenlockI3D; -WGLEW_EXPORT PFNWGLENABLEGENLOCKI3DPROC __wglewEnableGenlockI3D; -WGLEW_EXPORT PFNWGLGENLOCKSAMPLERATEI3DPROC __wglewGenlockSampleRateI3D; -WGLEW_EXPORT PFNWGLGENLOCKSOURCEDELAYI3DPROC __wglewGenlockSourceDelayI3D; -WGLEW_EXPORT PFNWGLGENLOCKSOURCEEDGEI3DPROC __wglewGenlockSourceEdgeI3D; -WGLEW_EXPORT PFNWGLGENLOCKSOURCEI3DPROC __wglewGenlockSourceI3D; -WGLEW_EXPORT PFNWGLGETGENLOCKSAMPLERATEI3DPROC __wglewGetGenlockSampleRateI3D; -WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEDELAYI3DPROC __wglewGetGenlockSourceDelayI3D; -WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEEDGEI3DPROC __wglewGetGenlockSourceEdgeI3D; -WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEI3DPROC __wglewGetGenlockSourceI3D; -WGLEW_EXPORT PFNWGLISENABLEDGENLOCKI3DPROC __wglewIsEnabledGenlockI3D; -WGLEW_EXPORT PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC __wglewQueryGenlockMaxSourceDelayI3D; - -WGLEW_EXPORT PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC __wglewAssociateImageBufferEventsI3D; -WGLEW_EXPORT PFNWGLCREATEIMAGEBUFFERI3DPROC __wglewCreateImageBufferI3D; -WGLEW_EXPORT PFNWGLDESTROYIMAGEBUFFERI3DPROC __wglewDestroyImageBufferI3D; -WGLEW_EXPORT PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC __wglewReleaseImageBufferEventsI3D; - -WGLEW_EXPORT PFNWGLDISABLEFRAMELOCKI3DPROC __wglewDisableFrameLockI3D; -WGLEW_EXPORT PFNWGLENABLEFRAMELOCKI3DPROC __wglewEnableFrameLockI3D; -WGLEW_EXPORT PFNWGLISENABLEDFRAMELOCKI3DPROC __wglewIsEnabledFrameLockI3D; -WGLEW_EXPORT PFNWGLQUERYFRAMELOCKMASTERI3DPROC __wglewQueryFrameLockMasterI3D; - -WGLEW_EXPORT PFNWGLBEGINFRAMETRACKINGI3DPROC __wglewBeginFrameTrackingI3D; -WGLEW_EXPORT PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D; -WGLEW_EXPORT PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D; -WGLEW_EXPORT PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D; - -WGLEW_EXPORT PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV; -WGLEW_EXPORT PFNWGLDELETEDCNVPROC __wglewDeleteDCNV; -WGLEW_EXPORT PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV; -WGLEW_EXPORT PFNWGLENUMGPUSFROMAFFINITYDCNVPROC __wglewEnumGpusFromAffinityDCNV; -WGLEW_EXPORT PFNWGLENUMGPUSNVPROC __wglewEnumGpusNV; - -WGLEW_EXPORT PFNWGLBINDVIDEODEVICENVPROC __wglewBindVideoDeviceNV; -WGLEW_EXPORT PFNWGLENUMERATEVIDEODEVICESNVPROC __wglewEnumerateVideoDevicesNV; -WGLEW_EXPORT PFNWGLQUERYCURRENTCONTEXTNVPROC __wglewQueryCurrentContextNV; - -WGLEW_EXPORT PFNWGLBINDSWAPBARRIERNVPROC __wglewBindSwapBarrierNV; -WGLEW_EXPORT PFNWGLJOINSWAPGROUPNVPROC __wglewJoinSwapGroupNV; -WGLEW_EXPORT PFNWGLQUERYFRAMECOUNTNVPROC __wglewQueryFrameCountNV; -WGLEW_EXPORT PFNWGLQUERYMAXSWAPGROUPSNVPROC __wglewQueryMaxSwapGroupsNV; -WGLEW_EXPORT PFNWGLQUERYSWAPGROUPNVPROC __wglewQuerySwapGroupNV; -WGLEW_EXPORT PFNWGLRESETFRAMECOUNTNVPROC __wglewResetFrameCountNV; - -WGLEW_EXPORT PFNWGLALLOCATEMEMORYNVPROC __wglewAllocateMemoryNV; -WGLEW_EXPORT PFNWGLFREEMEMORYNVPROC __wglewFreeMemoryNV; - -WGLEW_EXPORT PFNWGLBINDVIDEOIMAGENVPROC __wglewBindVideoImageNV; -WGLEW_EXPORT PFNWGLGETVIDEODEVICENVPROC __wglewGetVideoDeviceNV; -WGLEW_EXPORT PFNWGLGETVIDEOINFONVPROC __wglewGetVideoInfoNV; -WGLEW_EXPORT PFNWGLRELEASEVIDEODEVICENVPROC __wglewReleaseVideoDeviceNV; -WGLEW_EXPORT PFNWGLRELEASEVIDEOIMAGENVPROC __wglewReleaseVideoImageNV; -WGLEW_EXPORT PFNWGLSENDPBUFFERTOVIDEONVPROC __wglewSendPbufferToVideoNV; - -WGLEW_EXPORT PFNWGLGETMSCRATEOMLPROC __wglewGetMscRateOML; -WGLEW_EXPORT PFNWGLGETSYNCVALUESOMLPROC __wglewGetSyncValuesOML; -WGLEW_EXPORT PFNWGLSWAPBUFFERSMSCOMLPROC __wglewSwapBuffersMscOML; -WGLEW_EXPORT PFNWGLSWAPLAYERBUFFERSMSCOMLPROC __wglewSwapLayerBuffersMscOML; -WGLEW_EXPORT PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML; -WGLEW_EXPORT PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML; -WGLEW_EXPORT GLboolean __WGLEW_3DFX_multisample; -WGLEW_EXPORT GLboolean __WGLEW_3DL_stereo_control; -WGLEW_EXPORT GLboolean __WGLEW_ARB_buffer_region; -WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context; -WGLEW_EXPORT GLboolean __WGLEW_ARB_extensions_string; -WGLEW_EXPORT GLboolean __WGLEW_ARB_framebuffer_sRGB; -WGLEW_EXPORT GLboolean __WGLEW_ARB_make_current_read; -WGLEW_EXPORT GLboolean __WGLEW_ARB_multisample; -WGLEW_EXPORT GLboolean __WGLEW_ARB_pbuffer; -WGLEW_EXPORT GLboolean __WGLEW_ARB_pixel_format; -WGLEW_EXPORT GLboolean __WGLEW_ARB_pixel_format_float; -WGLEW_EXPORT GLboolean __WGLEW_ARB_render_texture; -WGLEW_EXPORT GLboolean __WGLEW_ATI_pixel_format_float; -WGLEW_EXPORT GLboolean __WGLEW_ATI_render_texture_rectangle; -WGLEW_EXPORT GLboolean __WGLEW_EXT_depth_float; -WGLEW_EXPORT GLboolean __WGLEW_EXT_display_color_table; -WGLEW_EXPORT GLboolean __WGLEW_EXT_extensions_string; -WGLEW_EXPORT GLboolean __WGLEW_EXT_framebuffer_sRGB; -WGLEW_EXPORT GLboolean __WGLEW_EXT_make_current_read; -WGLEW_EXPORT GLboolean __WGLEW_EXT_multisample; -WGLEW_EXPORT GLboolean __WGLEW_EXT_pbuffer; -WGLEW_EXPORT GLboolean __WGLEW_EXT_pixel_format; -WGLEW_EXPORT GLboolean __WGLEW_EXT_pixel_format_packed_float; -WGLEW_EXPORT GLboolean __WGLEW_EXT_swap_control; -WGLEW_EXPORT GLboolean __WGLEW_I3D_digital_video_control; -WGLEW_EXPORT GLboolean __WGLEW_I3D_gamma; -WGLEW_EXPORT GLboolean __WGLEW_I3D_genlock; -WGLEW_EXPORT GLboolean __WGLEW_I3D_image_buffer; -WGLEW_EXPORT GLboolean __WGLEW_I3D_swap_frame_lock; -WGLEW_EXPORT GLboolean __WGLEW_I3D_swap_frame_usage; -WGLEW_EXPORT GLboolean __WGLEW_NV_float_buffer; -WGLEW_EXPORT GLboolean __WGLEW_NV_gpu_affinity; -WGLEW_EXPORT GLboolean __WGLEW_NV_present_video; -WGLEW_EXPORT GLboolean __WGLEW_NV_render_depth_texture; -WGLEW_EXPORT GLboolean __WGLEW_NV_render_texture_rectangle; -WGLEW_EXPORT GLboolean __WGLEW_NV_swap_group; -WGLEW_EXPORT GLboolean __WGLEW_NV_vertex_array_range; -WGLEW_EXPORT GLboolean __WGLEW_NV_video_output; -WGLEW_EXPORT GLboolean __WGLEW_OML_sync_control; - -#ifdef GLEW_MX -}; /* WGLEWContextStruct */ -#endif /* GLEW_MX */ - -/* ------------------------------------------------------------------------- */ - -#ifdef GLEW_MX - -typedef struct WGLEWContextStruct WGLEWContext; -GLEWAPI GLenum wglewContextInit (WGLEWContext* ctx); -GLEWAPI GLboolean wglewContextIsSupported (WGLEWContext* ctx, const char* name); - -#define wglewInit() wglewContextInit(wglewGetContext()) -#define wglewIsSupported(x) wglewContextIsSupported(wglewGetContext(), x) - -#define WGLEW_GET_VAR(x) (*(const GLboolean*)&(wglewGetContext()->x)) -#define WGLEW_GET_FUN(x) wglewGetContext()->x - -#else /* GLEW_MX */ - -#define WGLEW_GET_VAR(x) (*(const GLboolean*)&x) -#define WGLEW_GET_FUN(x) x - -GLEWAPI GLboolean wglewIsSupported (const char* name); - -#endif /* GLEW_MX */ - -GLEWAPI GLboolean wglewGetExtension (const char* name); - -#ifdef __cplusplus -} -#endif - -#undef GLEWAPI - -#endif /* __wglew_h__ */ diff --git a/oversampling/WDL/lice/glew/src/glew.c b/oversampling/WDL/lice/glew/src/glew.c deleted file mode 100644 index 7d4b8f8..0000000 --- a/oversampling/WDL/lice/glew/src/glew.c +++ /dev/null @@ -1,12180 +0,0 @@ -/* -** The OpenGL Extension Wrangler Library -** Copyright (C) 2002-2008, Milan Ikits -** Copyright (C) 2002-2008, Marcelo E. Magallon -** Copyright (C) 2002, Lev Povalahev -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** -** * Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** * The name of the author may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -** THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include "../include/GL/glew.h" -#if defined(_WIN32) -# include "../include/GL/wglew.h" -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) -# include "../include/GL/glxew.h" -#endif - -/* - * Define glewGetContext and related helper macros. - */ -#ifdef GLEW_MX -# define glewGetContext() ctx -# ifdef _WIN32 -# define GLEW_CONTEXT_ARG_DEF_INIT GLEWContext* ctx -# define GLEW_CONTEXT_ARG_VAR_INIT ctx -# define wglewGetContext() ctx -# define WGLEW_CONTEXT_ARG_DEF_INIT WGLEWContext* ctx -# define WGLEW_CONTEXT_ARG_DEF_LIST WGLEWContext* ctx -# else /* _WIN32 */ -# define GLEW_CONTEXT_ARG_DEF_INIT void -# define GLEW_CONTEXT_ARG_VAR_INIT -# define glxewGetContext() ctx -# define GLXEW_CONTEXT_ARG_DEF_INIT void -# define GLXEW_CONTEXT_ARG_DEF_LIST GLXEWContext* ctx -# endif /* _WIN32 */ -# define GLEW_CONTEXT_ARG_DEF_LIST GLEWContext* ctx -#else /* GLEW_MX */ -# define GLEW_CONTEXT_ARG_DEF_INIT void -# define GLEW_CONTEXT_ARG_VAR_INIT -# define GLEW_CONTEXT_ARG_DEF_LIST void -# define WGLEW_CONTEXT_ARG_DEF_INIT void -# define WGLEW_CONTEXT_ARG_DEF_LIST void -# define GLXEW_CONTEXT_ARG_DEF_INIT void -# define GLXEW_CONTEXT_ARG_DEF_LIST void -#endif /* GLEW_MX */ - -#if defined(__APPLE__) -#include -#include -#include - -void* NSGLGetProcAddress (const GLubyte *name) -{ - static const struct mach_header* image = NULL; - NSSymbol symbol; - char* symbolName; - if (NULL == image) - { - image = NSAddImage("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", NSADDIMAGE_OPTION_RETURN_ON_ERROR); - } - /* prepend a '_' for the Unix C symbol mangling convention */ - symbolName = malloc(strlen((const char*)name) + 2); - strcpy(symbolName+1, (const char*)name); - symbolName[0] = '_'; - symbol = NULL; - /* if (NSIsSymbolNameDefined(symbolName)) - symbol = NSLookupAndBindSymbol(symbolName); */ - symbol = image ? NSLookupSymbolInImage(image, symbolName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : NULL; - free(symbolName); - return symbol ? NSAddressOfSymbol(symbol) : NULL; -} -#endif /* __APPLE__ */ - -#if defined(__sgi) || defined (__sun) -#include -#include -#include - -void* dlGetProcAddress (const GLubyte* name) -{ - static void* h = NULL; - static void* gpa; - - if (h == NULL) - { - if ((h = dlopen(NULL, RTLD_LAZY | RTLD_LOCAL)) == NULL) return NULL; - gpa = dlsym(h, "glXGetProcAddress"); - } - - if (gpa != NULL) - return ((void*(*)(const GLubyte*))gpa)(name); - else - return dlsym(h, (const char*)name); -} -#endif /* __sgi || __sun */ - -/* - * Define glewGetProcAddress. - */ -#if defined(_WIN32) -# define glewGetProcAddress(name) wglGetProcAddress((LPCSTR)name) -#else -# if defined(__APPLE__) -# define glewGetProcAddress(name) NSGLGetProcAddress(name) -# else -# if defined(__sgi) || defined(__sun) -# define glewGetProcAddress(name) dlGetProcAddress(name) -# else /* __linux */ -# define glewGetProcAddress(name) (*glXGetProcAddressARB)(name) -# endif -# endif -#endif - -/* - * Define GLboolean const cast. - */ -#define CONST_CAST(x) (*(GLboolean*)&x) - -/* - * GLEW, just like OpenGL or GLU, does not rely on the standard C library. - * These functions implement the functionality required in this file. - */ -static GLuint _glewStrLen (const GLubyte* s) -{ - GLuint i=0; - if (s == NULL) return 0; - while (s[i] != '\0') i++; - return i; -} - -static GLuint _glewStrCLen (const GLubyte* s, GLubyte c) -{ - GLuint i=0; - if (s == NULL) return 0; - while (s[i] != '\0' && s[i] != c) i++; - return (s[i] == '\0' || s[i] == c) ? i : 0; -} - -static GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n) -{ - GLuint i=0; - if(a == NULL || b == NULL) - return (a == NULL && b == NULL && n == 0) ? GL_TRUE : GL_FALSE; - while (i < n && a[i] != '\0' && b[i] != '\0' && a[i] == b[i]) i++; - return i == n ? GL_TRUE : GL_FALSE; -} - -static GLboolean _glewStrSame1 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) -{ - while (*na > 0 && (**a == ' ' || **a == '\n' || **a == '\r' || **a == '\t')) - { - (*a)++; - (*na)--; - } - if(*na >= nb) - { - GLuint i=0; - while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++; - if(i == nb) - { - *a = *a + nb; - *na = *na - nb; - return GL_TRUE; - } - } - return GL_FALSE; -} - -static GLboolean _glewStrSame2 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) -{ - if(*na >= nb) - { - GLuint i=0; - while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++; - if(i == nb) - { - *a = *a + nb; - *na = *na - nb; - return GL_TRUE; - } - } - return GL_FALSE; -} - -static GLboolean _glewStrSame3 (GLubyte** a, GLuint* na, const GLubyte* b, GLuint nb) -{ - if(*na >= nb) - { - GLuint i=0; - while (i < nb && (*a)+i != NULL && b+i != NULL && (*a)[i] == b[i]) i++; - if (i == nb && (*na == nb || (*a)[i] == ' ' || (*a)[i] == '\n' || (*a)[i] == '\r' || (*a)[i] == '\t')) - { - *a = *a + nb; - *na = *na - nb; - return GL_TRUE; - } - } - return GL_FALSE; -} - -#if !defined(_WIN32) || !defined(GLEW_MX) - -PFNGLCOPYTEXSUBIMAGE3DPROC __glewCopyTexSubImage3D = NULL; -PFNGLDRAWRANGEELEMENTSPROC __glewDrawRangeElements = NULL; -PFNGLTEXIMAGE3DPROC __glewTexImage3D = NULL; -PFNGLTEXSUBIMAGE3DPROC __glewTexSubImage3D = NULL; - -PFNGLACTIVETEXTUREPROC __glewActiveTexture = NULL; -PFNGLCLIENTACTIVETEXTUREPROC __glewClientActiveTexture = NULL; -PFNGLCOMPRESSEDTEXIMAGE1DPROC __glewCompressedTexImage1D = NULL; -PFNGLCOMPRESSEDTEXIMAGE2DPROC __glewCompressedTexImage2D = NULL; -PFNGLCOMPRESSEDTEXIMAGE3DPROC __glewCompressedTexImage3D = NULL; -PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC __glewCompressedTexSubImage1D = NULL; -PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC __glewCompressedTexSubImage2D = NULL; -PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC __glewCompressedTexSubImage3D = NULL; -PFNGLGETCOMPRESSEDTEXIMAGEPROC __glewGetCompressedTexImage = NULL; -PFNGLLOADTRANSPOSEMATRIXDPROC __glewLoadTransposeMatrixd = NULL; -PFNGLLOADTRANSPOSEMATRIXFPROC __glewLoadTransposeMatrixf = NULL; -PFNGLMULTTRANSPOSEMATRIXDPROC __glewMultTransposeMatrixd = NULL; -PFNGLMULTTRANSPOSEMATRIXFPROC __glewMultTransposeMatrixf = NULL; -PFNGLMULTITEXCOORD1DPROC __glewMultiTexCoord1d = NULL; -PFNGLMULTITEXCOORD1DVPROC __glewMultiTexCoord1dv = NULL; -PFNGLMULTITEXCOORD1FPROC __glewMultiTexCoord1f = NULL; -PFNGLMULTITEXCOORD1FVPROC __glewMultiTexCoord1fv = NULL; -PFNGLMULTITEXCOORD1IPROC __glewMultiTexCoord1i = NULL; -PFNGLMULTITEXCOORD1IVPROC __glewMultiTexCoord1iv = NULL; -PFNGLMULTITEXCOORD1SPROC __glewMultiTexCoord1s = NULL; -PFNGLMULTITEXCOORD1SVPROC __glewMultiTexCoord1sv = NULL; -PFNGLMULTITEXCOORD2DPROC __glewMultiTexCoord2d = NULL; -PFNGLMULTITEXCOORD2DVPROC __glewMultiTexCoord2dv = NULL; -PFNGLMULTITEXCOORD2FPROC __glewMultiTexCoord2f = NULL; -PFNGLMULTITEXCOORD2FVPROC __glewMultiTexCoord2fv = NULL; -PFNGLMULTITEXCOORD2IPROC __glewMultiTexCoord2i = NULL; -PFNGLMULTITEXCOORD2IVPROC __glewMultiTexCoord2iv = NULL; -PFNGLMULTITEXCOORD2SPROC __glewMultiTexCoord2s = NULL; -PFNGLMULTITEXCOORD2SVPROC __glewMultiTexCoord2sv = NULL; -PFNGLMULTITEXCOORD3DPROC __glewMultiTexCoord3d = NULL; -PFNGLMULTITEXCOORD3DVPROC __glewMultiTexCoord3dv = NULL; -PFNGLMULTITEXCOORD3FPROC __glewMultiTexCoord3f = NULL; -PFNGLMULTITEXCOORD3FVPROC __glewMultiTexCoord3fv = NULL; -PFNGLMULTITEXCOORD3IPROC __glewMultiTexCoord3i = NULL; -PFNGLMULTITEXCOORD3IVPROC __glewMultiTexCoord3iv = NULL; -PFNGLMULTITEXCOORD3SPROC __glewMultiTexCoord3s = NULL; -PFNGLMULTITEXCOORD3SVPROC __glewMultiTexCoord3sv = NULL; -PFNGLMULTITEXCOORD4DPROC __glewMultiTexCoord4d = NULL; -PFNGLMULTITEXCOORD4DVPROC __glewMultiTexCoord4dv = NULL; -PFNGLMULTITEXCOORD4FPROC __glewMultiTexCoord4f = NULL; -PFNGLMULTITEXCOORD4FVPROC __glewMultiTexCoord4fv = NULL; -PFNGLMULTITEXCOORD4IPROC __glewMultiTexCoord4i = NULL; -PFNGLMULTITEXCOORD4IVPROC __glewMultiTexCoord4iv = NULL; -PFNGLMULTITEXCOORD4SPROC __glewMultiTexCoord4s = NULL; -PFNGLMULTITEXCOORD4SVPROC __glewMultiTexCoord4sv = NULL; -PFNGLSAMPLECOVERAGEPROC __glewSampleCoverage = NULL; - -PFNGLBLENDCOLORPROC __glewBlendColor = NULL; -PFNGLBLENDEQUATIONPROC __glewBlendEquation = NULL; -PFNGLBLENDFUNCSEPARATEPROC __glewBlendFuncSeparate = NULL; -PFNGLFOGCOORDPOINTERPROC __glewFogCoordPointer = NULL; -PFNGLFOGCOORDDPROC __glewFogCoordd = NULL; -PFNGLFOGCOORDDVPROC __glewFogCoorddv = NULL; -PFNGLFOGCOORDFPROC __glewFogCoordf = NULL; -PFNGLFOGCOORDFVPROC __glewFogCoordfv = NULL; -PFNGLMULTIDRAWARRAYSPROC __glewMultiDrawArrays = NULL; -PFNGLMULTIDRAWELEMENTSPROC __glewMultiDrawElements = NULL; -PFNGLPOINTPARAMETERFPROC __glewPointParameterf = NULL; -PFNGLPOINTPARAMETERFVPROC __glewPointParameterfv = NULL; -PFNGLPOINTPARAMETERIPROC __glewPointParameteri = NULL; -PFNGLPOINTPARAMETERIVPROC __glewPointParameteriv = NULL; -PFNGLSECONDARYCOLOR3BPROC __glewSecondaryColor3b = NULL; -PFNGLSECONDARYCOLOR3BVPROC __glewSecondaryColor3bv = NULL; -PFNGLSECONDARYCOLOR3DPROC __glewSecondaryColor3d = NULL; -PFNGLSECONDARYCOLOR3DVPROC __glewSecondaryColor3dv = NULL; -PFNGLSECONDARYCOLOR3FPROC __glewSecondaryColor3f = NULL; -PFNGLSECONDARYCOLOR3FVPROC __glewSecondaryColor3fv = NULL; -PFNGLSECONDARYCOLOR3IPROC __glewSecondaryColor3i = NULL; -PFNGLSECONDARYCOLOR3IVPROC __glewSecondaryColor3iv = NULL; -PFNGLSECONDARYCOLOR3SPROC __glewSecondaryColor3s = NULL; -PFNGLSECONDARYCOLOR3SVPROC __glewSecondaryColor3sv = NULL; -PFNGLSECONDARYCOLOR3UBPROC __glewSecondaryColor3ub = NULL; -PFNGLSECONDARYCOLOR3UBVPROC __glewSecondaryColor3ubv = NULL; -PFNGLSECONDARYCOLOR3UIPROC __glewSecondaryColor3ui = NULL; -PFNGLSECONDARYCOLOR3UIVPROC __glewSecondaryColor3uiv = NULL; -PFNGLSECONDARYCOLOR3USPROC __glewSecondaryColor3us = NULL; -PFNGLSECONDARYCOLOR3USVPROC __glewSecondaryColor3usv = NULL; -PFNGLSECONDARYCOLORPOINTERPROC __glewSecondaryColorPointer = NULL; -PFNGLWINDOWPOS2DPROC __glewWindowPos2d = NULL; -PFNGLWINDOWPOS2DVPROC __glewWindowPos2dv = NULL; -PFNGLWINDOWPOS2FPROC __glewWindowPos2f = NULL; -PFNGLWINDOWPOS2FVPROC __glewWindowPos2fv = NULL; -PFNGLWINDOWPOS2IPROC __glewWindowPos2i = NULL; -PFNGLWINDOWPOS2IVPROC __glewWindowPos2iv = NULL; -PFNGLWINDOWPOS2SPROC __glewWindowPos2s = NULL; -PFNGLWINDOWPOS2SVPROC __glewWindowPos2sv = NULL; -PFNGLWINDOWPOS3DPROC __glewWindowPos3d = NULL; -PFNGLWINDOWPOS3DVPROC __glewWindowPos3dv = NULL; -PFNGLWINDOWPOS3FPROC __glewWindowPos3f = NULL; -PFNGLWINDOWPOS3FVPROC __glewWindowPos3fv = NULL; -PFNGLWINDOWPOS3IPROC __glewWindowPos3i = NULL; -PFNGLWINDOWPOS3IVPROC __glewWindowPos3iv = NULL; -PFNGLWINDOWPOS3SPROC __glewWindowPos3s = NULL; -PFNGLWINDOWPOS3SVPROC __glewWindowPos3sv = NULL; - -PFNGLBEGINQUERYPROC __glewBeginQuery = NULL; -PFNGLBINDBUFFERPROC __glewBindBuffer = NULL; -PFNGLBUFFERDATAPROC __glewBufferData = NULL; -PFNGLBUFFERSUBDATAPROC __glewBufferSubData = NULL; -PFNGLDELETEBUFFERSPROC __glewDeleteBuffers = NULL; -PFNGLDELETEQUERIESPROC __glewDeleteQueries = NULL; -PFNGLENDQUERYPROC __glewEndQuery = NULL; -PFNGLGENBUFFERSPROC __glewGenBuffers = NULL; -PFNGLGENQUERIESPROC __glewGenQueries = NULL; -PFNGLGETBUFFERPARAMETERIVPROC __glewGetBufferParameteriv = NULL; -PFNGLGETBUFFERPOINTERVPROC __glewGetBufferPointerv = NULL; -PFNGLGETBUFFERSUBDATAPROC __glewGetBufferSubData = NULL; -PFNGLGETQUERYOBJECTIVPROC __glewGetQueryObjectiv = NULL; -PFNGLGETQUERYOBJECTUIVPROC __glewGetQueryObjectuiv = NULL; -PFNGLGETQUERYIVPROC __glewGetQueryiv = NULL; -PFNGLISBUFFERPROC __glewIsBuffer = NULL; -PFNGLISQUERYPROC __glewIsQuery = NULL; -PFNGLMAPBUFFERPROC __glewMapBuffer = NULL; -PFNGLUNMAPBUFFERPROC __glewUnmapBuffer = NULL; - -PFNGLATTACHSHADERPROC __glewAttachShader = NULL; -PFNGLBINDATTRIBLOCATIONPROC __glewBindAttribLocation = NULL; -PFNGLBLENDEQUATIONSEPARATEPROC __glewBlendEquationSeparate = NULL; -PFNGLCOMPILESHADERPROC __glewCompileShader = NULL; -PFNGLCREATEPROGRAMPROC __glewCreateProgram = NULL; -PFNGLCREATESHADERPROC __glewCreateShader = NULL; -PFNGLDELETEPROGRAMPROC __glewDeleteProgram = NULL; -PFNGLDELETESHADERPROC __glewDeleteShader = NULL; -PFNGLDETACHSHADERPROC __glewDetachShader = NULL; -PFNGLDISABLEVERTEXATTRIBARRAYPROC __glewDisableVertexAttribArray = NULL; -PFNGLDRAWBUFFERSPROC __glewDrawBuffers = NULL; -PFNGLENABLEVERTEXATTRIBARRAYPROC __glewEnableVertexAttribArray = NULL; -PFNGLGETACTIVEATTRIBPROC __glewGetActiveAttrib = NULL; -PFNGLGETACTIVEUNIFORMPROC __glewGetActiveUniform = NULL; -PFNGLGETATTACHEDSHADERSPROC __glewGetAttachedShaders = NULL; -PFNGLGETATTRIBLOCATIONPROC __glewGetAttribLocation = NULL; -PFNGLGETPROGRAMINFOLOGPROC __glewGetProgramInfoLog = NULL; -PFNGLGETPROGRAMIVPROC __glewGetProgramiv = NULL; -PFNGLGETSHADERINFOLOGPROC __glewGetShaderInfoLog = NULL; -PFNGLGETSHADERSOURCEPROC __glewGetShaderSource = NULL; -PFNGLGETSHADERIVPROC __glewGetShaderiv = NULL; -PFNGLGETUNIFORMLOCATIONPROC __glewGetUniformLocation = NULL; -PFNGLGETUNIFORMFVPROC __glewGetUniformfv = NULL; -PFNGLGETUNIFORMIVPROC __glewGetUniformiv = NULL; -PFNGLGETVERTEXATTRIBPOINTERVPROC __glewGetVertexAttribPointerv = NULL; -PFNGLGETVERTEXATTRIBDVPROC __glewGetVertexAttribdv = NULL; -PFNGLGETVERTEXATTRIBFVPROC __glewGetVertexAttribfv = NULL; -PFNGLGETVERTEXATTRIBIVPROC __glewGetVertexAttribiv = NULL; -PFNGLISPROGRAMPROC __glewIsProgram = NULL; -PFNGLISSHADERPROC __glewIsShader = NULL; -PFNGLLINKPROGRAMPROC __glewLinkProgram = NULL; -PFNGLSHADERSOURCEPROC __glewShaderSource = NULL; -PFNGLSTENCILFUNCSEPARATEPROC __glewStencilFuncSeparate = NULL; -PFNGLSTENCILMASKSEPARATEPROC __glewStencilMaskSeparate = NULL; -PFNGLSTENCILOPSEPARATEPROC __glewStencilOpSeparate = NULL; -PFNGLUNIFORM1FPROC __glewUniform1f = NULL; -PFNGLUNIFORM1FVPROC __glewUniform1fv = NULL; -PFNGLUNIFORM1IPROC __glewUniform1i = NULL; -PFNGLUNIFORM1IVPROC __glewUniform1iv = NULL; -PFNGLUNIFORM2FPROC __glewUniform2f = NULL; -PFNGLUNIFORM2FVPROC __glewUniform2fv = NULL; -PFNGLUNIFORM2IPROC __glewUniform2i = NULL; -PFNGLUNIFORM2IVPROC __glewUniform2iv = NULL; -PFNGLUNIFORM3FPROC __glewUniform3f = NULL; -PFNGLUNIFORM3FVPROC __glewUniform3fv = NULL; -PFNGLUNIFORM3IPROC __glewUniform3i = NULL; -PFNGLUNIFORM3IVPROC __glewUniform3iv = NULL; -PFNGLUNIFORM4FPROC __glewUniform4f = NULL; -PFNGLUNIFORM4FVPROC __glewUniform4fv = NULL; -PFNGLUNIFORM4IPROC __glewUniform4i = NULL; -PFNGLUNIFORM4IVPROC __glewUniform4iv = NULL; -PFNGLUNIFORMMATRIX2FVPROC __glewUniformMatrix2fv = NULL; -PFNGLUNIFORMMATRIX3FVPROC __glewUniformMatrix3fv = NULL; -PFNGLUNIFORMMATRIX4FVPROC __glewUniformMatrix4fv = NULL; -PFNGLUSEPROGRAMPROC __glewUseProgram = NULL; -PFNGLVALIDATEPROGRAMPROC __glewValidateProgram = NULL; -PFNGLVERTEXATTRIB1DPROC __glewVertexAttrib1d = NULL; -PFNGLVERTEXATTRIB1DVPROC __glewVertexAttrib1dv = NULL; -PFNGLVERTEXATTRIB1FPROC __glewVertexAttrib1f = NULL; -PFNGLVERTEXATTRIB1FVPROC __glewVertexAttrib1fv = NULL; -PFNGLVERTEXATTRIB1SPROC __glewVertexAttrib1s = NULL; -PFNGLVERTEXATTRIB1SVPROC __glewVertexAttrib1sv = NULL; -PFNGLVERTEXATTRIB2DPROC __glewVertexAttrib2d = NULL; -PFNGLVERTEXATTRIB2DVPROC __glewVertexAttrib2dv = NULL; -PFNGLVERTEXATTRIB2FPROC __glewVertexAttrib2f = NULL; -PFNGLVERTEXATTRIB2FVPROC __glewVertexAttrib2fv = NULL; -PFNGLVERTEXATTRIB2SPROC __glewVertexAttrib2s = NULL; -PFNGLVERTEXATTRIB2SVPROC __glewVertexAttrib2sv = NULL; -PFNGLVERTEXATTRIB3DPROC __glewVertexAttrib3d = NULL; -PFNGLVERTEXATTRIB3DVPROC __glewVertexAttrib3dv = NULL; -PFNGLVERTEXATTRIB3FPROC __glewVertexAttrib3f = NULL; -PFNGLVERTEXATTRIB3FVPROC __glewVertexAttrib3fv = NULL; -PFNGLVERTEXATTRIB3SPROC __glewVertexAttrib3s = NULL; -PFNGLVERTEXATTRIB3SVPROC __glewVertexAttrib3sv = NULL; -PFNGLVERTEXATTRIB4NBVPROC __glewVertexAttrib4Nbv = NULL; -PFNGLVERTEXATTRIB4NIVPROC __glewVertexAttrib4Niv = NULL; -PFNGLVERTEXATTRIB4NSVPROC __glewVertexAttrib4Nsv = NULL; -PFNGLVERTEXATTRIB4NUBPROC __glewVertexAttrib4Nub = NULL; -PFNGLVERTEXATTRIB4NUBVPROC __glewVertexAttrib4Nubv = NULL; -PFNGLVERTEXATTRIB4NUIVPROC __glewVertexAttrib4Nuiv = NULL; -PFNGLVERTEXATTRIB4NUSVPROC __glewVertexAttrib4Nusv = NULL; -PFNGLVERTEXATTRIB4BVPROC __glewVertexAttrib4bv = NULL; -PFNGLVERTEXATTRIB4DPROC __glewVertexAttrib4d = NULL; -PFNGLVERTEXATTRIB4DVPROC __glewVertexAttrib4dv = NULL; -PFNGLVERTEXATTRIB4FPROC __glewVertexAttrib4f = NULL; -PFNGLVERTEXATTRIB4FVPROC __glewVertexAttrib4fv = NULL; -PFNGLVERTEXATTRIB4IVPROC __glewVertexAttrib4iv = NULL; -PFNGLVERTEXATTRIB4SPROC __glewVertexAttrib4s = NULL; -PFNGLVERTEXATTRIB4SVPROC __glewVertexAttrib4sv = NULL; -PFNGLVERTEXATTRIB4UBVPROC __glewVertexAttrib4ubv = NULL; -PFNGLVERTEXATTRIB4UIVPROC __glewVertexAttrib4uiv = NULL; -PFNGLVERTEXATTRIB4USVPROC __glewVertexAttrib4usv = NULL; -PFNGLVERTEXATTRIBPOINTERPROC __glewVertexAttribPointer = NULL; - -PFNGLUNIFORMMATRIX2X3FVPROC __glewUniformMatrix2x3fv = NULL; -PFNGLUNIFORMMATRIX2X4FVPROC __glewUniformMatrix2x4fv = NULL; -PFNGLUNIFORMMATRIX3X2FVPROC __glewUniformMatrix3x2fv = NULL; -PFNGLUNIFORMMATRIX3X4FVPROC __glewUniformMatrix3x4fv = NULL; -PFNGLUNIFORMMATRIX4X2FVPROC __glewUniformMatrix4x2fv = NULL; -PFNGLUNIFORMMATRIX4X3FVPROC __glewUniformMatrix4x3fv = NULL; - -PFNGLBEGINCONDITIONALRENDERPROC __glewBeginConditionalRender = NULL; -PFNGLBEGINTRANSFORMFEEDBACKPROC __glewBeginTransformFeedback = NULL; -PFNGLBINDBUFFERBASEPROC __glewBindBufferBase = NULL; -PFNGLBINDBUFFERRANGEPROC __glewBindBufferRange = NULL; -PFNGLBINDFRAGDATALOCATIONPROC __glewBindFragDataLocation = NULL; -PFNGLCLAMPCOLORPROC __glewClampColor = NULL; -PFNGLCLEARBUFFERFIPROC __glewClearBufferfi = NULL; -PFNGLCLEARBUFFERFVPROC __glewClearBufferfv = NULL; -PFNGLCLEARBUFFERIVPROC __glewClearBufferiv = NULL; -PFNGLCLEARBUFFERUIVPROC __glewClearBufferuiv = NULL; -PFNGLCOLORMASKIPROC __glewColorMaski = NULL; -PFNGLDISABLEIPROC __glewDisablei = NULL; -PFNGLENABLEIPROC __glewEnablei = NULL; -PFNGLENDCONDITIONALRENDERPROC __glewEndConditionalRender = NULL; -PFNGLENDTRANSFORMFEEDBACKPROC __glewEndTransformFeedback = NULL; -PFNGLGETBOOLEANI_VPROC __glewGetBooleani_v = NULL; -PFNGLGETFRAGDATALOCATIONPROC __glewGetFragDataLocation = NULL; -PFNGLGETINTEGERI_VPROC __glewGetIntegeri_v = NULL; -PFNGLGETSTRINGIPROC __glewGetStringi = NULL; -PFNGLGETTEXPARAMETERIIVPROC __glewGetTexParameterIiv = NULL; -PFNGLGETTEXPARAMETERIUIVPROC __glewGetTexParameterIuiv = NULL; -PFNGLGETTRANSFORMFEEDBACKVARYINGPROC __glewGetTransformFeedbackVarying = NULL; -PFNGLGETUNIFORMUIVPROC __glewGetUniformuiv = NULL; -PFNGLGETVERTEXATTRIBIIVPROC __glewGetVertexAttribIiv = NULL; -PFNGLGETVERTEXATTRIBIUIVPROC __glewGetVertexAttribIuiv = NULL; -PFNGLISENABLEDIPROC __glewIsEnabledi = NULL; -PFNGLTEXPARAMETERIIVPROC __glewTexParameterIiv = NULL; -PFNGLTEXPARAMETERIUIVPROC __glewTexParameterIuiv = NULL; -PFNGLTRANSFORMFEEDBACKVARYINGSPROC __glewTransformFeedbackVaryings = NULL; -PFNGLUNIFORM1UIPROC __glewUniform1ui = NULL; -PFNGLUNIFORM1UIVPROC __glewUniform1uiv = NULL; -PFNGLUNIFORM2UIPROC __glewUniform2ui = NULL; -PFNGLUNIFORM2UIVPROC __glewUniform2uiv = NULL; -PFNGLUNIFORM3UIPROC __glewUniform3ui = NULL; -PFNGLUNIFORM3UIVPROC __glewUniform3uiv = NULL; -PFNGLUNIFORM4UIPROC __glewUniform4ui = NULL; -PFNGLUNIFORM4UIVPROC __glewUniform4uiv = NULL; -PFNGLVERTEXATTRIBI1IPROC __glewVertexAttribI1i = NULL; -PFNGLVERTEXATTRIBI1IVPROC __glewVertexAttribI1iv = NULL; -PFNGLVERTEXATTRIBI1UIPROC __glewVertexAttribI1ui = NULL; -PFNGLVERTEXATTRIBI1UIVPROC __glewVertexAttribI1uiv = NULL; -PFNGLVERTEXATTRIBI2IPROC __glewVertexAttribI2i = NULL; -PFNGLVERTEXATTRIBI2IVPROC __glewVertexAttribI2iv = NULL; -PFNGLVERTEXATTRIBI2UIPROC __glewVertexAttribI2ui = NULL; -PFNGLVERTEXATTRIBI2UIVPROC __glewVertexAttribI2uiv = NULL; -PFNGLVERTEXATTRIBI3IPROC __glewVertexAttribI3i = NULL; -PFNGLVERTEXATTRIBI3IVPROC __glewVertexAttribI3iv = NULL; -PFNGLVERTEXATTRIBI3UIPROC __glewVertexAttribI3ui = NULL; -PFNGLVERTEXATTRIBI3UIVPROC __glewVertexAttribI3uiv = NULL; -PFNGLVERTEXATTRIBI4BVPROC __glewVertexAttribI4bv = NULL; -PFNGLVERTEXATTRIBI4IPROC __glewVertexAttribI4i = NULL; -PFNGLVERTEXATTRIBI4IVPROC __glewVertexAttribI4iv = NULL; -PFNGLVERTEXATTRIBI4SVPROC __glewVertexAttribI4sv = NULL; -PFNGLVERTEXATTRIBI4UBVPROC __glewVertexAttribI4ubv = NULL; -PFNGLVERTEXATTRIBI4UIPROC __glewVertexAttribI4ui = NULL; -PFNGLVERTEXATTRIBI4UIVPROC __glewVertexAttribI4uiv = NULL; -PFNGLVERTEXATTRIBI4USVPROC __glewVertexAttribI4usv = NULL; -PFNGLVERTEXATTRIBIPOINTERPROC __glewVertexAttribIPointer = NULL; - -PFNGLTBUFFERMASK3DFXPROC __glewTbufferMask3DFX = NULL; - -PFNGLDRAWELEMENTARRAYAPPLEPROC __glewDrawElementArrayAPPLE = NULL; -PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC __glewDrawRangeElementArrayAPPLE = NULL; -PFNGLELEMENTPOINTERAPPLEPROC __glewElementPointerAPPLE = NULL; -PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC __glewMultiDrawElementArrayAPPLE = NULL; -PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC __glewMultiDrawRangeElementArrayAPPLE = NULL; - -PFNGLDELETEFENCESAPPLEPROC __glewDeleteFencesAPPLE = NULL; -PFNGLFINISHFENCEAPPLEPROC __glewFinishFenceAPPLE = NULL; -PFNGLFINISHOBJECTAPPLEPROC __glewFinishObjectAPPLE = NULL; -PFNGLGENFENCESAPPLEPROC __glewGenFencesAPPLE = NULL; -PFNGLISFENCEAPPLEPROC __glewIsFenceAPPLE = NULL; -PFNGLSETFENCEAPPLEPROC __glewSetFenceAPPLE = NULL; -PFNGLTESTFENCEAPPLEPROC __glewTestFenceAPPLE = NULL; -PFNGLTESTOBJECTAPPLEPROC __glewTestObjectAPPLE = NULL; - -PFNGLBUFFERPARAMETERIAPPLEPROC __glewBufferParameteriAPPLE = NULL; -PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC __glewFlushMappedBufferRangeAPPLE = NULL; - -PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC __glewGetTexParameterPointervAPPLE = NULL; -PFNGLTEXTURERANGEAPPLEPROC __glewTextureRangeAPPLE = NULL; - -PFNGLBINDVERTEXARRAYAPPLEPROC __glewBindVertexArrayAPPLE = NULL; -PFNGLDELETEVERTEXARRAYSAPPLEPROC __glewDeleteVertexArraysAPPLE = NULL; -PFNGLGENVERTEXARRAYSAPPLEPROC __glewGenVertexArraysAPPLE = NULL; -PFNGLISVERTEXARRAYAPPLEPROC __glewIsVertexArrayAPPLE = NULL; - -PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC __glewFlushVertexArrayRangeAPPLE = NULL; -PFNGLVERTEXARRAYPARAMETERIAPPLEPROC __glewVertexArrayParameteriAPPLE = NULL; -PFNGLVERTEXARRAYRANGEAPPLEPROC __glewVertexArrayRangeAPPLE = NULL; - -PFNGLCLAMPCOLORARBPROC __glewClampColorARB = NULL; - -PFNGLDRAWBUFFERSARBPROC __glewDrawBuffersARB = NULL; - -PFNGLDRAWARRAYSINSTANCEDARBPROC __glewDrawArraysInstancedARB = NULL; -PFNGLDRAWELEMENTSINSTANCEDARBPROC __glewDrawElementsInstancedARB = NULL; - -PFNGLBINDFRAMEBUFFERPROC __glewBindFramebuffer = NULL; -PFNGLBINDRENDERBUFFERPROC __glewBindRenderbuffer = NULL; -PFNGLBLITFRAMEBUFFERPROC __glewBlitFramebuffer = NULL; -PFNGLCHECKFRAMEBUFFERSTATUSPROC __glewCheckFramebufferStatus = NULL; -PFNGLDELETEFRAMEBUFFERSPROC __glewDeleteFramebuffers = NULL; -PFNGLDELETERENDERBUFFERSPROC __glewDeleteRenderbuffers = NULL; -PFNGLFRAMEBUFFERRENDERBUFFERPROC __glewFramebufferRenderbuffer = NULL; -PFNGLFRAMEBUFFERTEXTURLAYERPROC __glewFramebufferTexturLayer = NULL; -PFNGLFRAMEBUFFERTEXTURE1DPROC __glewFramebufferTexture1D = NULL; -PFNGLFRAMEBUFFERTEXTURE2DPROC __glewFramebufferTexture2D = NULL; -PFNGLFRAMEBUFFERTEXTURE3DPROC __glewFramebufferTexture3D = NULL; -PFNGLGENFRAMEBUFFERSPROC __glewGenFramebuffers = NULL; -PFNGLGENRENDERBUFFERSPROC __glewGenRenderbuffers = NULL; -PFNGLGENERATEMIPMAPPROC __glewGenerateMipmap = NULL; -PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC __glewGetFramebufferAttachmentParameteriv = NULL; -PFNGLGETRENDERBUFFERPARAMETERIVPROC __glewGetRenderbufferParameteriv = NULL; -PFNGLISFRAMEBUFFERPROC __glewIsFramebuffer = NULL; -PFNGLISRENDERBUFFERPROC __glewIsRenderbuffer = NULL; -PFNGLRENDERBUFFERSTORAGEPROC __glewRenderbufferStorage = NULL; -PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC __glewRenderbufferStorageMultisample = NULL; - -PFNGLFRAMEBUFFERTEXTUREARBPROC __glewFramebufferTextureARB = NULL; -PFNGLFRAMEBUFFERTEXTUREFACEARBPROC __glewFramebufferTextureFaceARB = NULL; -PFNGLFRAMEBUFFERTEXTURELAYERARBPROC __glewFramebufferTextureLayerARB = NULL; -PFNGLPROGRAMPARAMETERIARBPROC __glewProgramParameteriARB = NULL; - -PFNGLCOLORSUBTABLEPROC __glewColorSubTable = NULL; -PFNGLCOLORTABLEPROC __glewColorTable = NULL; -PFNGLCOLORTABLEPARAMETERFVPROC __glewColorTableParameterfv = NULL; -PFNGLCOLORTABLEPARAMETERIVPROC __glewColorTableParameteriv = NULL; -PFNGLCONVOLUTIONFILTER1DPROC __glewConvolutionFilter1D = NULL; -PFNGLCONVOLUTIONFILTER2DPROC __glewConvolutionFilter2D = NULL; -PFNGLCONVOLUTIONPARAMETERFPROC __glewConvolutionParameterf = NULL; -PFNGLCONVOLUTIONPARAMETERFVPROC __glewConvolutionParameterfv = NULL; -PFNGLCONVOLUTIONPARAMETERIPROC __glewConvolutionParameteri = NULL; -PFNGLCONVOLUTIONPARAMETERIVPROC __glewConvolutionParameteriv = NULL; -PFNGLCOPYCOLORSUBTABLEPROC __glewCopyColorSubTable = NULL; -PFNGLCOPYCOLORTABLEPROC __glewCopyColorTable = NULL; -PFNGLCOPYCONVOLUTIONFILTER1DPROC __glewCopyConvolutionFilter1D = NULL; -PFNGLCOPYCONVOLUTIONFILTER2DPROC __glewCopyConvolutionFilter2D = NULL; -PFNGLGETCOLORTABLEPROC __glewGetColorTable = NULL; -PFNGLGETCOLORTABLEPARAMETERFVPROC __glewGetColorTableParameterfv = NULL; -PFNGLGETCOLORTABLEPARAMETERIVPROC __glewGetColorTableParameteriv = NULL; -PFNGLGETCONVOLUTIONFILTERPROC __glewGetConvolutionFilter = NULL; -PFNGLGETCONVOLUTIONPARAMETERFVPROC __glewGetConvolutionParameterfv = NULL; -PFNGLGETCONVOLUTIONPARAMETERIVPROC __glewGetConvolutionParameteriv = NULL; -PFNGLGETHISTOGRAMPROC __glewGetHistogram = NULL; -PFNGLGETHISTOGRAMPARAMETERFVPROC __glewGetHistogramParameterfv = NULL; -PFNGLGETHISTOGRAMPARAMETERIVPROC __glewGetHistogramParameteriv = NULL; -PFNGLGETMINMAXPROC __glewGetMinmax = NULL; -PFNGLGETMINMAXPARAMETERFVPROC __glewGetMinmaxParameterfv = NULL; -PFNGLGETMINMAXPARAMETERIVPROC __glewGetMinmaxParameteriv = NULL; -PFNGLGETSEPARABLEFILTERPROC __glewGetSeparableFilter = NULL; -PFNGLHISTOGRAMPROC __glewHistogram = NULL; -PFNGLMINMAXPROC __glewMinmax = NULL; -PFNGLRESETHISTOGRAMPROC __glewResetHistogram = NULL; -PFNGLRESETMINMAXPROC __glewResetMinmax = NULL; -PFNGLSEPARABLEFILTER2DPROC __glewSeparableFilter2D = NULL; - -PFNGLVERTEXATTRIBDIVISORARBPROC __glewVertexAttribDivisorARB = NULL; - -PFNGLFLUSHMAPPEDBUFFERRANGEPROC __glewFlushMappedBufferRange = NULL; -PFNGLMAPBUFFERRANGEPROC __glewMapBufferRange = NULL; - -PFNGLCURRENTPALETTEMATRIXARBPROC __glewCurrentPaletteMatrixARB = NULL; -PFNGLMATRIXINDEXPOINTERARBPROC __glewMatrixIndexPointerARB = NULL; -PFNGLMATRIXINDEXUBVARBPROC __glewMatrixIndexubvARB = NULL; -PFNGLMATRIXINDEXUIVARBPROC __glewMatrixIndexuivARB = NULL; -PFNGLMATRIXINDEXUSVARBPROC __glewMatrixIndexusvARB = NULL; - -PFNGLSAMPLECOVERAGEARBPROC __glewSampleCoverageARB = NULL; - -PFNGLACTIVETEXTUREARBPROC __glewActiveTextureARB = NULL; -PFNGLCLIENTACTIVETEXTUREARBPROC __glewClientActiveTextureARB = NULL; -PFNGLMULTITEXCOORD1DARBPROC __glewMultiTexCoord1dARB = NULL; -PFNGLMULTITEXCOORD1DVARBPROC __glewMultiTexCoord1dvARB = NULL; -PFNGLMULTITEXCOORD1FARBPROC __glewMultiTexCoord1fARB = NULL; -PFNGLMULTITEXCOORD1FVARBPROC __glewMultiTexCoord1fvARB = NULL; -PFNGLMULTITEXCOORD1IARBPROC __glewMultiTexCoord1iARB = NULL; -PFNGLMULTITEXCOORD1IVARBPROC __glewMultiTexCoord1ivARB = NULL; -PFNGLMULTITEXCOORD1SARBPROC __glewMultiTexCoord1sARB = NULL; -PFNGLMULTITEXCOORD1SVARBPROC __glewMultiTexCoord1svARB = NULL; -PFNGLMULTITEXCOORD2DARBPROC __glewMultiTexCoord2dARB = NULL; -PFNGLMULTITEXCOORD2DVARBPROC __glewMultiTexCoord2dvARB = NULL; -PFNGLMULTITEXCOORD2FARBPROC __glewMultiTexCoord2fARB = NULL; -PFNGLMULTITEXCOORD2FVARBPROC __glewMultiTexCoord2fvARB = NULL; -PFNGLMULTITEXCOORD2IARBPROC __glewMultiTexCoord2iARB = NULL; -PFNGLMULTITEXCOORD2IVARBPROC __glewMultiTexCoord2ivARB = NULL; -PFNGLMULTITEXCOORD2SARBPROC __glewMultiTexCoord2sARB = NULL; -PFNGLMULTITEXCOORD2SVARBPROC __glewMultiTexCoord2svARB = NULL; -PFNGLMULTITEXCOORD3DARBPROC __glewMultiTexCoord3dARB = NULL; -PFNGLMULTITEXCOORD3DVARBPROC __glewMultiTexCoord3dvARB = NULL; -PFNGLMULTITEXCOORD3FARBPROC __glewMultiTexCoord3fARB = NULL; -PFNGLMULTITEXCOORD3FVARBPROC __glewMultiTexCoord3fvARB = NULL; -PFNGLMULTITEXCOORD3IARBPROC __glewMultiTexCoord3iARB = NULL; -PFNGLMULTITEXCOORD3IVARBPROC __glewMultiTexCoord3ivARB = NULL; -PFNGLMULTITEXCOORD3SARBPROC __glewMultiTexCoord3sARB = NULL; -PFNGLMULTITEXCOORD3SVARBPROC __glewMultiTexCoord3svARB = NULL; -PFNGLMULTITEXCOORD4DARBPROC __glewMultiTexCoord4dARB = NULL; -PFNGLMULTITEXCOORD4DVARBPROC __glewMultiTexCoord4dvARB = NULL; -PFNGLMULTITEXCOORD4FARBPROC __glewMultiTexCoord4fARB = NULL; -PFNGLMULTITEXCOORD4FVARBPROC __glewMultiTexCoord4fvARB = NULL; -PFNGLMULTITEXCOORD4IARBPROC __glewMultiTexCoord4iARB = NULL; -PFNGLMULTITEXCOORD4IVARBPROC __glewMultiTexCoord4ivARB = NULL; -PFNGLMULTITEXCOORD4SARBPROC __glewMultiTexCoord4sARB = NULL; -PFNGLMULTITEXCOORD4SVARBPROC __glewMultiTexCoord4svARB = NULL; - -PFNGLBEGINQUERYARBPROC __glewBeginQueryARB = NULL; -PFNGLDELETEQUERIESARBPROC __glewDeleteQueriesARB = NULL; -PFNGLENDQUERYARBPROC __glewEndQueryARB = NULL; -PFNGLGENQUERIESARBPROC __glewGenQueriesARB = NULL; -PFNGLGETQUERYOBJECTIVARBPROC __glewGetQueryObjectivARB = NULL; -PFNGLGETQUERYOBJECTUIVARBPROC __glewGetQueryObjectuivARB = NULL; -PFNGLGETQUERYIVARBPROC __glewGetQueryivARB = NULL; -PFNGLISQUERYARBPROC __glewIsQueryARB = NULL; - -PFNGLPOINTPARAMETERFARBPROC __glewPointParameterfARB = NULL; -PFNGLPOINTPARAMETERFVARBPROC __glewPointParameterfvARB = NULL; - -PFNGLATTACHOBJECTARBPROC __glewAttachObjectARB = NULL; -PFNGLCOMPILESHADERARBPROC __glewCompileShaderARB = NULL; -PFNGLCREATEPROGRAMOBJECTARBPROC __glewCreateProgramObjectARB = NULL; -PFNGLCREATESHADEROBJECTARBPROC __glewCreateShaderObjectARB = NULL; -PFNGLDELETEOBJECTARBPROC __glewDeleteObjectARB = NULL; -PFNGLDETACHOBJECTARBPROC __glewDetachObjectARB = NULL; -PFNGLGETACTIVEUNIFORMARBPROC __glewGetActiveUniformARB = NULL; -PFNGLGETATTACHEDOBJECTSARBPROC __glewGetAttachedObjectsARB = NULL; -PFNGLGETHANDLEARBPROC __glewGetHandleARB = NULL; -PFNGLGETINFOLOGARBPROC __glewGetInfoLogARB = NULL; -PFNGLGETOBJECTPARAMETERFVARBPROC __glewGetObjectParameterfvARB = NULL; -PFNGLGETOBJECTPARAMETERIVARBPROC __glewGetObjectParameterivARB = NULL; -PFNGLGETSHADERSOURCEARBPROC __glewGetShaderSourceARB = NULL; -PFNGLGETUNIFORMLOCATIONARBPROC __glewGetUniformLocationARB = NULL; -PFNGLGETUNIFORMFVARBPROC __glewGetUniformfvARB = NULL; -PFNGLGETUNIFORMIVARBPROC __glewGetUniformivARB = NULL; -PFNGLLINKPROGRAMARBPROC __glewLinkProgramARB = NULL; -PFNGLSHADERSOURCEARBPROC __glewShaderSourceARB = NULL; -PFNGLUNIFORM1FARBPROC __glewUniform1fARB = NULL; -PFNGLUNIFORM1FVARBPROC __glewUniform1fvARB = NULL; -PFNGLUNIFORM1IARBPROC __glewUniform1iARB = NULL; -PFNGLUNIFORM1IVARBPROC __glewUniform1ivARB = NULL; -PFNGLUNIFORM2FARBPROC __glewUniform2fARB = NULL; -PFNGLUNIFORM2FVARBPROC __glewUniform2fvARB = NULL; -PFNGLUNIFORM2IARBPROC __glewUniform2iARB = NULL; -PFNGLUNIFORM2IVARBPROC __glewUniform2ivARB = NULL; -PFNGLUNIFORM3FARBPROC __glewUniform3fARB = NULL; -PFNGLUNIFORM3FVARBPROC __glewUniform3fvARB = NULL; -PFNGLUNIFORM3IARBPROC __glewUniform3iARB = NULL; -PFNGLUNIFORM3IVARBPROC __glewUniform3ivARB = NULL; -PFNGLUNIFORM4FARBPROC __glewUniform4fARB = NULL; -PFNGLUNIFORM4FVARBPROC __glewUniform4fvARB = NULL; -PFNGLUNIFORM4IARBPROC __glewUniform4iARB = NULL; -PFNGLUNIFORM4IVARBPROC __glewUniform4ivARB = NULL; -PFNGLUNIFORMMATRIX2FVARBPROC __glewUniformMatrix2fvARB = NULL; -PFNGLUNIFORMMATRIX3FVARBPROC __glewUniformMatrix3fvARB = NULL; -PFNGLUNIFORMMATRIX4FVARBPROC __glewUniformMatrix4fvARB = NULL; -PFNGLUSEPROGRAMOBJECTARBPROC __glewUseProgramObjectARB = NULL; -PFNGLVALIDATEPROGRAMARBPROC __glewValidateProgramARB = NULL; - -PFNGLTEXBUFFERARBPROC __glewTexBufferARB = NULL; - -PFNGLCOMPRESSEDTEXIMAGE1DARBPROC __glewCompressedTexImage1DARB = NULL; -PFNGLCOMPRESSEDTEXIMAGE2DARBPROC __glewCompressedTexImage2DARB = NULL; -PFNGLCOMPRESSEDTEXIMAGE3DARBPROC __glewCompressedTexImage3DARB = NULL; -PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC __glewCompressedTexSubImage1DARB = NULL; -PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC __glewCompressedTexSubImage2DARB = NULL; -PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC __glewCompressedTexSubImage3DARB = NULL; -PFNGLGETCOMPRESSEDTEXIMAGEARBPROC __glewGetCompressedTexImageARB = NULL; - -PFNGLLOADTRANSPOSEMATRIXDARBPROC __glewLoadTransposeMatrixdARB = NULL; -PFNGLLOADTRANSPOSEMATRIXFARBPROC __glewLoadTransposeMatrixfARB = NULL; -PFNGLMULTTRANSPOSEMATRIXDARBPROC __glewMultTransposeMatrixdARB = NULL; -PFNGLMULTTRANSPOSEMATRIXFARBPROC __glewMultTransposeMatrixfARB = NULL; - -PFNGLBINDVERTEXARRAYPROC __glewBindVertexArray = NULL; -PFNGLDELETEVERTEXARRAYSPROC __glewDeleteVertexArrays = NULL; -PFNGLGENVERTEXARRAYSPROC __glewGenVertexArrays = NULL; -PFNGLISVERTEXARRAYPROC __glewIsVertexArray = NULL; - -PFNGLVERTEXBLENDARBPROC __glewVertexBlendARB = NULL; -PFNGLWEIGHTPOINTERARBPROC __glewWeightPointerARB = NULL; -PFNGLWEIGHTBVARBPROC __glewWeightbvARB = NULL; -PFNGLWEIGHTDVARBPROC __glewWeightdvARB = NULL; -PFNGLWEIGHTFVARBPROC __glewWeightfvARB = NULL; -PFNGLWEIGHTIVARBPROC __glewWeightivARB = NULL; -PFNGLWEIGHTSVARBPROC __glewWeightsvARB = NULL; -PFNGLWEIGHTUBVARBPROC __glewWeightubvARB = NULL; -PFNGLWEIGHTUIVARBPROC __glewWeightuivARB = NULL; -PFNGLWEIGHTUSVARBPROC __glewWeightusvARB = NULL; - -PFNGLBINDBUFFERARBPROC __glewBindBufferARB = NULL; -PFNGLBUFFERDATAARBPROC __glewBufferDataARB = NULL; -PFNGLBUFFERSUBDATAARBPROC __glewBufferSubDataARB = NULL; -PFNGLDELETEBUFFERSARBPROC __glewDeleteBuffersARB = NULL; -PFNGLGENBUFFERSARBPROC __glewGenBuffersARB = NULL; -PFNGLGETBUFFERPARAMETERIVARBPROC __glewGetBufferParameterivARB = NULL; -PFNGLGETBUFFERPOINTERVARBPROC __glewGetBufferPointervARB = NULL; -PFNGLGETBUFFERSUBDATAARBPROC __glewGetBufferSubDataARB = NULL; -PFNGLISBUFFERARBPROC __glewIsBufferARB = NULL; -PFNGLMAPBUFFERARBPROC __glewMapBufferARB = NULL; -PFNGLUNMAPBUFFERARBPROC __glewUnmapBufferARB = NULL; - -PFNGLBINDPROGRAMARBPROC __glewBindProgramARB = NULL; -PFNGLDELETEPROGRAMSARBPROC __glewDeleteProgramsARB = NULL; -PFNGLDISABLEVERTEXATTRIBARRAYARBPROC __glewDisableVertexAttribArrayARB = NULL; -PFNGLENABLEVERTEXATTRIBARRAYARBPROC __glewEnableVertexAttribArrayARB = NULL; -PFNGLGENPROGRAMSARBPROC __glewGenProgramsARB = NULL; -PFNGLGETPROGRAMENVPARAMETERDVARBPROC __glewGetProgramEnvParameterdvARB = NULL; -PFNGLGETPROGRAMENVPARAMETERFVARBPROC __glewGetProgramEnvParameterfvARB = NULL; -PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC __glewGetProgramLocalParameterdvARB = NULL; -PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC __glewGetProgramLocalParameterfvARB = NULL; -PFNGLGETPROGRAMSTRINGARBPROC __glewGetProgramStringARB = NULL; -PFNGLGETPROGRAMIVARBPROC __glewGetProgramivARB = NULL; -PFNGLGETVERTEXATTRIBPOINTERVARBPROC __glewGetVertexAttribPointervARB = NULL; -PFNGLGETVERTEXATTRIBDVARBPROC __glewGetVertexAttribdvARB = NULL; -PFNGLGETVERTEXATTRIBFVARBPROC __glewGetVertexAttribfvARB = NULL; -PFNGLGETVERTEXATTRIBIVARBPROC __glewGetVertexAttribivARB = NULL; -PFNGLISPROGRAMARBPROC __glewIsProgramARB = NULL; -PFNGLPROGRAMENVPARAMETER4DARBPROC __glewProgramEnvParameter4dARB = NULL; -PFNGLPROGRAMENVPARAMETER4DVARBPROC __glewProgramEnvParameter4dvARB = NULL; -PFNGLPROGRAMENVPARAMETER4FARBPROC __glewProgramEnvParameter4fARB = NULL; -PFNGLPROGRAMENVPARAMETER4FVARBPROC __glewProgramEnvParameter4fvARB = NULL; -PFNGLPROGRAMLOCALPARAMETER4DARBPROC __glewProgramLocalParameter4dARB = NULL; -PFNGLPROGRAMLOCALPARAMETER4DVARBPROC __glewProgramLocalParameter4dvARB = NULL; -PFNGLPROGRAMLOCALPARAMETER4FARBPROC __glewProgramLocalParameter4fARB = NULL; -PFNGLPROGRAMLOCALPARAMETER4FVARBPROC __glewProgramLocalParameter4fvARB = NULL; -PFNGLPROGRAMSTRINGARBPROC __glewProgramStringARB = NULL; -PFNGLVERTEXATTRIB1DARBPROC __glewVertexAttrib1dARB = NULL; -PFNGLVERTEXATTRIB1DVARBPROC __glewVertexAttrib1dvARB = NULL; -PFNGLVERTEXATTRIB1FARBPROC __glewVertexAttrib1fARB = NULL; -PFNGLVERTEXATTRIB1FVARBPROC __glewVertexAttrib1fvARB = NULL; -PFNGLVERTEXATTRIB1SARBPROC __glewVertexAttrib1sARB = NULL; -PFNGLVERTEXATTRIB1SVARBPROC __glewVertexAttrib1svARB = NULL; -PFNGLVERTEXATTRIB2DARBPROC __glewVertexAttrib2dARB = NULL; -PFNGLVERTEXATTRIB2DVARBPROC __glewVertexAttrib2dvARB = NULL; -PFNGLVERTEXATTRIB2FARBPROC __glewVertexAttrib2fARB = NULL; -PFNGLVERTEXATTRIB2FVARBPROC __glewVertexAttrib2fvARB = NULL; -PFNGLVERTEXATTRIB2SARBPROC __glewVertexAttrib2sARB = NULL; -PFNGLVERTEXATTRIB2SVARBPROC __glewVertexAttrib2svARB = NULL; -PFNGLVERTEXATTRIB3DARBPROC __glewVertexAttrib3dARB = NULL; -PFNGLVERTEXATTRIB3DVARBPROC __glewVertexAttrib3dvARB = NULL; -PFNGLVERTEXATTRIB3FARBPROC __glewVertexAttrib3fARB = NULL; -PFNGLVERTEXATTRIB3FVARBPROC __glewVertexAttrib3fvARB = NULL; -PFNGLVERTEXATTRIB3SARBPROC __glewVertexAttrib3sARB = NULL; -PFNGLVERTEXATTRIB3SVARBPROC __glewVertexAttrib3svARB = NULL; -PFNGLVERTEXATTRIB4NBVARBPROC __glewVertexAttrib4NbvARB = NULL; -PFNGLVERTEXATTRIB4NIVARBPROC __glewVertexAttrib4NivARB = NULL; -PFNGLVERTEXATTRIB4NSVARBPROC __glewVertexAttrib4NsvARB = NULL; -PFNGLVERTEXATTRIB4NUBARBPROC __glewVertexAttrib4NubARB = NULL; -PFNGLVERTEXATTRIB4NUBVARBPROC __glewVertexAttrib4NubvARB = NULL; -PFNGLVERTEXATTRIB4NUIVARBPROC __glewVertexAttrib4NuivARB = NULL; -PFNGLVERTEXATTRIB4NUSVARBPROC __glewVertexAttrib4NusvARB = NULL; -PFNGLVERTEXATTRIB4BVARBPROC __glewVertexAttrib4bvARB = NULL; -PFNGLVERTEXATTRIB4DARBPROC __glewVertexAttrib4dARB = NULL; -PFNGLVERTEXATTRIB4DVARBPROC __glewVertexAttrib4dvARB = NULL; -PFNGLVERTEXATTRIB4FARBPROC __glewVertexAttrib4fARB = NULL; -PFNGLVERTEXATTRIB4FVARBPROC __glewVertexAttrib4fvARB = NULL; -PFNGLVERTEXATTRIB4IVARBPROC __glewVertexAttrib4ivARB = NULL; -PFNGLVERTEXATTRIB4SARBPROC __glewVertexAttrib4sARB = NULL; -PFNGLVERTEXATTRIB4SVARBPROC __glewVertexAttrib4svARB = NULL; -PFNGLVERTEXATTRIB4UBVARBPROC __glewVertexAttrib4ubvARB = NULL; -PFNGLVERTEXATTRIB4UIVARBPROC __glewVertexAttrib4uivARB = NULL; -PFNGLVERTEXATTRIB4USVARBPROC __glewVertexAttrib4usvARB = NULL; -PFNGLVERTEXATTRIBPOINTERARBPROC __glewVertexAttribPointerARB = NULL; - -PFNGLBINDATTRIBLOCATIONARBPROC __glewBindAttribLocationARB = NULL; -PFNGLGETACTIVEATTRIBARBPROC __glewGetActiveAttribARB = NULL; -PFNGLGETATTRIBLOCATIONARBPROC __glewGetAttribLocationARB = NULL; - -PFNGLWINDOWPOS2DARBPROC __glewWindowPos2dARB = NULL; -PFNGLWINDOWPOS2DVARBPROC __glewWindowPos2dvARB = NULL; -PFNGLWINDOWPOS2FARBPROC __glewWindowPos2fARB = NULL; -PFNGLWINDOWPOS2FVARBPROC __glewWindowPos2fvARB = NULL; -PFNGLWINDOWPOS2IARBPROC __glewWindowPos2iARB = NULL; -PFNGLWINDOWPOS2IVARBPROC __glewWindowPos2ivARB = NULL; -PFNGLWINDOWPOS2SARBPROC __glewWindowPos2sARB = NULL; -PFNGLWINDOWPOS2SVARBPROC __glewWindowPos2svARB = NULL; -PFNGLWINDOWPOS3DARBPROC __glewWindowPos3dARB = NULL; -PFNGLWINDOWPOS3DVARBPROC __glewWindowPos3dvARB = NULL; -PFNGLWINDOWPOS3FARBPROC __glewWindowPos3fARB = NULL; -PFNGLWINDOWPOS3FVARBPROC __glewWindowPos3fvARB = NULL; -PFNGLWINDOWPOS3IARBPROC __glewWindowPos3iARB = NULL; -PFNGLWINDOWPOS3IVARBPROC __glewWindowPos3ivARB = NULL; -PFNGLWINDOWPOS3SARBPROC __glewWindowPos3sARB = NULL; -PFNGLWINDOWPOS3SVARBPROC __glewWindowPos3svARB = NULL; - -PFNGLDRAWBUFFERSATIPROC __glewDrawBuffersATI = NULL; - -PFNGLDRAWELEMENTARRAYATIPROC __glewDrawElementArrayATI = NULL; -PFNGLDRAWRANGEELEMENTARRAYATIPROC __glewDrawRangeElementArrayATI = NULL; -PFNGLELEMENTPOINTERATIPROC __glewElementPointerATI = NULL; - -PFNGLGETTEXBUMPPARAMETERFVATIPROC __glewGetTexBumpParameterfvATI = NULL; -PFNGLGETTEXBUMPPARAMETERIVATIPROC __glewGetTexBumpParameterivATI = NULL; -PFNGLTEXBUMPPARAMETERFVATIPROC __glewTexBumpParameterfvATI = NULL; -PFNGLTEXBUMPPARAMETERIVATIPROC __glewTexBumpParameterivATI = NULL; - -PFNGLALPHAFRAGMENTOP1ATIPROC __glewAlphaFragmentOp1ATI = NULL; -PFNGLALPHAFRAGMENTOP2ATIPROC __glewAlphaFragmentOp2ATI = NULL; -PFNGLALPHAFRAGMENTOP3ATIPROC __glewAlphaFragmentOp3ATI = NULL; -PFNGLBEGINFRAGMENTSHADERATIPROC __glewBeginFragmentShaderATI = NULL; -PFNGLBINDFRAGMENTSHADERATIPROC __glewBindFragmentShaderATI = NULL; -PFNGLCOLORFRAGMENTOP1ATIPROC __glewColorFragmentOp1ATI = NULL; -PFNGLCOLORFRAGMENTOP2ATIPROC __glewColorFragmentOp2ATI = NULL; -PFNGLCOLORFRAGMENTOP3ATIPROC __glewColorFragmentOp3ATI = NULL; -PFNGLDELETEFRAGMENTSHADERATIPROC __glewDeleteFragmentShaderATI = NULL; -PFNGLENDFRAGMENTSHADERATIPROC __glewEndFragmentShaderATI = NULL; -PFNGLGENFRAGMENTSHADERSATIPROC __glewGenFragmentShadersATI = NULL; -PFNGLPASSTEXCOORDATIPROC __glewPassTexCoordATI = NULL; -PFNGLSAMPLEMAPATIPROC __glewSampleMapATI = NULL; -PFNGLSETFRAGMENTSHADERCONSTANTATIPROC __glewSetFragmentShaderConstantATI = NULL; - -PFNGLMAPOBJECTBUFFERATIPROC __glewMapObjectBufferATI = NULL; -PFNGLUNMAPOBJECTBUFFERATIPROC __glewUnmapObjectBufferATI = NULL; - -PFNGLPNTRIANGLESFATIPROC __glPNTrianglewesfATI = NULL; -PFNGLPNTRIANGLESIATIPROC __glPNTrianglewesiATI = NULL; - -PFNGLSTENCILFUNCSEPARATEATIPROC __glewStencilFuncSeparateATI = NULL; -PFNGLSTENCILOPSEPARATEATIPROC __glewStencilOpSeparateATI = NULL; - -PFNGLARRAYOBJECTATIPROC __glewArrayObjectATI = NULL; -PFNGLFREEOBJECTBUFFERATIPROC __glewFreeObjectBufferATI = NULL; -PFNGLGETARRAYOBJECTFVATIPROC __glewGetArrayObjectfvATI = NULL; -PFNGLGETARRAYOBJECTIVATIPROC __glewGetArrayObjectivATI = NULL; -PFNGLGETOBJECTBUFFERFVATIPROC __glewGetObjectBufferfvATI = NULL; -PFNGLGETOBJECTBUFFERIVATIPROC __glewGetObjectBufferivATI = NULL; -PFNGLGETVARIANTARRAYOBJECTFVATIPROC __glewGetVariantArrayObjectfvATI = NULL; -PFNGLGETVARIANTARRAYOBJECTIVATIPROC __glewGetVariantArrayObjectivATI = NULL; -PFNGLISOBJECTBUFFERATIPROC __glewIsObjectBufferATI = NULL; -PFNGLNEWOBJECTBUFFERATIPROC __glewNewObjectBufferATI = NULL; -PFNGLUPDATEOBJECTBUFFERATIPROC __glewUpdateObjectBufferATI = NULL; -PFNGLVARIANTARRAYOBJECTATIPROC __glewVariantArrayObjectATI = NULL; - -PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC __glewGetVertexAttribArrayObjectfvATI = NULL; -PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC __glewGetVertexAttribArrayObjectivATI = NULL; -PFNGLVERTEXATTRIBARRAYOBJECTATIPROC __glewVertexAttribArrayObjectATI = NULL; - -PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC __glewClientActiveVertexStreamATI = NULL; -PFNGLNORMALSTREAM3BATIPROC __glewNormalStream3bATI = NULL; -PFNGLNORMALSTREAM3BVATIPROC __glewNormalStream3bvATI = NULL; -PFNGLNORMALSTREAM3DATIPROC __glewNormalStream3dATI = NULL; -PFNGLNORMALSTREAM3DVATIPROC __glewNormalStream3dvATI = NULL; -PFNGLNORMALSTREAM3FATIPROC __glewNormalStream3fATI = NULL; -PFNGLNORMALSTREAM3FVATIPROC __glewNormalStream3fvATI = NULL; -PFNGLNORMALSTREAM3IATIPROC __glewNormalStream3iATI = NULL; -PFNGLNORMALSTREAM3IVATIPROC __glewNormalStream3ivATI = NULL; -PFNGLNORMALSTREAM3SATIPROC __glewNormalStream3sATI = NULL; -PFNGLNORMALSTREAM3SVATIPROC __glewNormalStream3svATI = NULL; -PFNGLVERTEXBLENDENVFATIPROC __glewVertexBlendEnvfATI = NULL; -PFNGLVERTEXBLENDENVIATIPROC __glewVertexBlendEnviATI = NULL; -PFNGLVERTEXSTREAM2DATIPROC __glewVertexStream2dATI = NULL; -PFNGLVERTEXSTREAM2DVATIPROC __glewVertexStream2dvATI = NULL; -PFNGLVERTEXSTREAM2FATIPROC __glewVertexStream2fATI = NULL; -PFNGLVERTEXSTREAM2FVATIPROC __glewVertexStream2fvATI = NULL; -PFNGLVERTEXSTREAM2IATIPROC __glewVertexStream2iATI = NULL; -PFNGLVERTEXSTREAM2IVATIPROC __glewVertexStream2ivATI = NULL; -PFNGLVERTEXSTREAM2SATIPROC __glewVertexStream2sATI = NULL; -PFNGLVERTEXSTREAM2SVATIPROC __glewVertexStream2svATI = NULL; -PFNGLVERTEXSTREAM3DATIPROC __glewVertexStream3dATI = NULL; -PFNGLVERTEXSTREAM3DVATIPROC __glewVertexStream3dvATI = NULL; -PFNGLVERTEXSTREAM3FATIPROC __glewVertexStream3fATI = NULL; -PFNGLVERTEXSTREAM3FVATIPROC __glewVertexStream3fvATI = NULL; -PFNGLVERTEXSTREAM3IATIPROC __glewVertexStream3iATI = NULL; -PFNGLVERTEXSTREAM3IVATIPROC __glewVertexStream3ivATI = NULL; -PFNGLVERTEXSTREAM3SATIPROC __glewVertexStream3sATI = NULL; -PFNGLVERTEXSTREAM3SVATIPROC __glewVertexStream3svATI = NULL; -PFNGLVERTEXSTREAM4DATIPROC __glewVertexStream4dATI = NULL; -PFNGLVERTEXSTREAM4DVATIPROC __glewVertexStream4dvATI = NULL; -PFNGLVERTEXSTREAM4FATIPROC __glewVertexStream4fATI = NULL; -PFNGLVERTEXSTREAM4FVATIPROC __glewVertexStream4fvATI = NULL; -PFNGLVERTEXSTREAM4IATIPROC __glewVertexStream4iATI = NULL; -PFNGLVERTEXSTREAM4IVATIPROC __glewVertexStream4ivATI = NULL; -PFNGLVERTEXSTREAM4SATIPROC __glewVertexStream4sATI = NULL; -PFNGLVERTEXSTREAM4SVATIPROC __glewVertexStream4svATI = NULL; - -PFNGLGETUNIFORMBUFFERSIZEEXTPROC __glewGetUniformBufferSizeEXT = NULL; -PFNGLGETUNIFORMOFFSETEXTPROC __glewGetUniformOffsetEXT = NULL; -PFNGLUNIFORMBUFFEREXTPROC __glewUniformBufferEXT = NULL; - -PFNGLBLENDCOLOREXTPROC __glewBlendColorEXT = NULL; - -PFNGLBLENDEQUATIONSEPARATEEXTPROC __glewBlendEquationSeparateEXT = NULL; - -PFNGLBLENDFUNCSEPARATEEXTPROC __glewBlendFuncSeparateEXT = NULL; - -PFNGLBLENDEQUATIONEXTPROC __glewBlendEquationEXT = NULL; - -PFNGLCOLORSUBTABLEEXTPROC __glewColorSubTableEXT = NULL; -PFNGLCOPYCOLORSUBTABLEEXTPROC __glewCopyColorSubTableEXT = NULL; - -PFNGLLOCKARRAYSEXTPROC __glewLockArraysEXT = NULL; -PFNGLUNLOCKARRAYSEXTPROC __glewUnlockArraysEXT = NULL; - -PFNGLCONVOLUTIONFILTER1DEXTPROC __glewConvolutionFilter1DEXT = NULL; -PFNGLCONVOLUTIONFILTER2DEXTPROC __glewConvolutionFilter2DEXT = NULL; -PFNGLCONVOLUTIONPARAMETERFEXTPROC __glewConvolutionParameterfEXT = NULL; -PFNGLCONVOLUTIONPARAMETERFVEXTPROC __glewConvolutionParameterfvEXT = NULL; -PFNGLCONVOLUTIONPARAMETERIEXTPROC __glewConvolutionParameteriEXT = NULL; -PFNGLCONVOLUTIONPARAMETERIVEXTPROC __glewConvolutionParameterivEXT = NULL; -PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC __glewCopyConvolutionFilter1DEXT = NULL; -PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC __glewCopyConvolutionFilter2DEXT = NULL; -PFNGLGETCONVOLUTIONFILTEREXTPROC __glewGetConvolutionFilterEXT = NULL; -PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC __glewGetConvolutionParameterfvEXT = NULL; -PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC __glewGetConvolutionParameterivEXT = NULL; -PFNGLGETSEPARABLEFILTEREXTPROC __glewGetSeparableFilterEXT = NULL; -PFNGLSEPARABLEFILTER2DEXTPROC __glewSeparableFilter2DEXT = NULL; - -PFNGLBINORMALPOINTEREXTPROC __glewBinormalPointerEXT = NULL; -PFNGLTANGENTPOINTEREXTPROC __glewTangentPointerEXT = NULL; - -PFNGLCOPYTEXIMAGE1DEXTPROC __glewCopyTexImage1DEXT = NULL; -PFNGLCOPYTEXIMAGE2DEXTPROC __glewCopyTexImage2DEXT = NULL; -PFNGLCOPYTEXSUBIMAGE1DEXTPROC __glewCopyTexSubImage1DEXT = NULL; -PFNGLCOPYTEXSUBIMAGE2DEXTPROC __glewCopyTexSubImage2DEXT = NULL; -PFNGLCOPYTEXSUBIMAGE3DEXTPROC __glewCopyTexSubImage3DEXT = NULL; - -PFNGLCULLPARAMETERDVEXTPROC __glewCullParameterdvEXT = NULL; -PFNGLCULLPARAMETERFVEXTPROC __glewCullParameterfvEXT = NULL; - -PFNGLDEPTHBOUNDSEXTPROC __glewDepthBoundsEXT = NULL; - -PFNGLBINDMULTITEXTUREEXTPROC __glewBindMultiTextureEXT = NULL; -PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC __glewCheckNamedFramebufferStatusEXT = NULL; -PFNGLCLIENTATTRIBDEFAULTEXTPROC __glewClientAttribDefaultEXT = NULL; -PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC __glewCompressedMultiTexImage1DEXT = NULL; -PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC __glewCompressedMultiTexImage2DEXT = NULL; -PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC __glewCompressedMultiTexImage3DEXT = NULL; -PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC __glewCompressedMultiTexSubImage1DEXT = NULL; -PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC __glewCompressedMultiTexSubImage2DEXT = NULL; -PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC __glewCompressedMultiTexSubImage3DEXT = NULL; -PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC __glewCompressedTextureImage1DEXT = NULL; -PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC __glewCompressedTextureImage2DEXT = NULL; -PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC __glewCompressedTextureImage3DEXT = NULL; -PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC __glewCompressedTextureSubImage1DEXT = NULL; -PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC __glewCompressedTextureSubImage2DEXT = NULL; -PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC __glewCompressedTextureSubImage3DEXT = NULL; -PFNGLCOPYMULTITEXIMAGE1DEXTPROC __glewCopyMultiTexImage1DEXT = NULL; -PFNGLCOPYMULTITEXIMAGE2DEXTPROC __glewCopyMultiTexImage2DEXT = NULL; -PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC __glewCopyMultiTexSubImage1DEXT = NULL; -PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC __glewCopyMultiTexSubImage2DEXT = NULL; -PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC __glewCopyMultiTexSubImage3DEXT = NULL; -PFNGLCOPYTEXTUREIMAGE1DEXTPROC __glewCopyTextureImage1DEXT = NULL; -PFNGLCOPYTEXTUREIMAGE2DEXTPROC __glewCopyTextureImage2DEXT = NULL; -PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC __glewCopyTextureSubImage1DEXT = NULL; -PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC __glewCopyTextureSubImage2DEXT = NULL; -PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC __glewCopyTextureSubImage3DEXT = NULL; -PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC __glewDisableClientStateIndexedEXT = NULL; -PFNGLENABLECLIENTSTATEINDEXEDEXTPROC __glewEnableClientStateIndexedEXT = NULL; -PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC __glewFramebufferDrawBufferEXT = NULL; -PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC __glewFramebufferDrawBuffersEXT = NULL; -PFNGLFRAMEBUFFERREADBUFFEREXTPROC __glewFramebufferReadBufferEXT = NULL; -PFNGLGENERATEMULTITEXMIPMAPEXTPROC __glewGenerateMultiTexMipmapEXT = NULL; -PFNGLGENERATETEXTUREMIPMAPEXTPROC __glewGenerateTextureMipmapEXT = NULL; -PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC __glewGetCompressedMultiTexImageEXT = NULL; -PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC __glewGetCompressedTextureImageEXT = NULL; -PFNGLGETDOUBLEINDEXEDVEXTPROC __glewGetDoubleIndexedvEXT = NULL; -PFNGLGETFLOATINDEXEDVEXTPROC __glewGetFloatIndexedvEXT = NULL; -PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC __glewGetFramebufferParameterivEXT = NULL; -PFNGLGETMULTITEXENVFVEXTPROC __glewGetMultiTexEnvfvEXT = NULL; -PFNGLGETMULTITEXENVIVEXTPROC __glewGetMultiTexEnvivEXT = NULL; -PFNGLGETMULTITEXGENDVEXTPROC __glewGetMultiTexGendvEXT = NULL; -PFNGLGETMULTITEXGENFVEXTPROC __glewGetMultiTexGenfvEXT = NULL; -PFNGLGETMULTITEXGENIVEXTPROC __glewGetMultiTexGenivEXT = NULL; -PFNGLGETMULTITEXIMAGEEXTPROC __glewGetMultiTexImageEXT = NULL; -PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC __glewGetMultiTexLevelParameterfvEXT = NULL; -PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC __glewGetMultiTexLevelParameterivEXT = NULL; -PFNGLGETMULTITEXPARAMETERIIVEXTPROC __glewGetMultiTexParameterIivEXT = NULL; -PFNGLGETMULTITEXPARAMETERIUIVEXTPROC __glewGetMultiTexParameterIuivEXT = NULL; -PFNGLGETMULTITEXPARAMETERFVEXTPROC __glewGetMultiTexParameterfvEXT = NULL; -PFNGLGETMULTITEXPARAMETERIVEXTPROC __glewGetMultiTexParameterivEXT = NULL; -PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC __glewGetNamedBufferParameterivEXT = NULL; -PFNGLGETNAMEDBUFFERPOINTERVEXTPROC __glewGetNamedBufferPointervEXT = NULL; -PFNGLGETNAMEDBUFFERSUBDATAEXTPROC __glewGetNamedBufferSubDataEXT = NULL; -PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetNamedFramebufferAttachmentParameterivEXT = NULL; -PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC __glewGetNamedProgramLocalParameterIivEXT = NULL; -PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC __glewGetNamedProgramLocalParameterIuivEXT = NULL; -PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC __glewGetNamedProgramLocalParameterdvEXT = NULL; -PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC __glewGetNamedProgramLocalParameterfvEXT = NULL; -PFNGLGETNAMEDPROGRAMSTRINGEXTPROC __glewGetNamedProgramStringEXT = NULL; -PFNGLGETNAMEDPROGRAMIVEXTPROC __glewGetNamedProgramivEXT = NULL; -PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC __glewGetNamedRenderbufferParameterivEXT = NULL; -PFNGLGETPOINTERINDEXEDVEXTPROC __glewGetPointerIndexedvEXT = NULL; -PFNGLGETTEXTUREIMAGEEXTPROC __glewGetTextureImageEXT = NULL; -PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC __glewGetTextureLevelParameterfvEXT = NULL; -PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC __glewGetTextureLevelParameterivEXT = NULL; -PFNGLGETTEXTUREPARAMETERIIVEXTPROC __glewGetTextureParameterIivEXT = NULL; -PFNGLGETTEXTUREPARAMETERIUIVEXTPROC __glewGetTextureParameterIuivEXT = NULL; -PFNGLGETTEXTUREPARAMETERFVEXTPROC __glewGetTextureParameterfvEXT = NULL; -PFNGLGETTEXTUREPARAMETERIVEXTPROC __glewGetTextureParameterivEXT = NULL; -PFNGLMAPNAMEDBUFFEREXTPROC __glewMapNamedBufferEXT = NULL; -PFNGLMATRIXFRUSTUMEXTPROC __glewMatrixFrustumEXT = NULL; -PFNGLMATRIXLOADIDENTITYEXTPROC __glewMatrixLoadIdentityEXT = NULL; -PFNGLMATRIXLOADTRANSPOSEDEXTPROC __glewMatrixLoadTransposedEXT = NULL; -PFNGLMATRIXLOADTRANSPOSEFEXTPROC __glewMatrixLoadTransposefEXT = NULL; -PFNGLMATRIXLOADDEXTPROC __glewMatrixLoaddEXT = NULL; -PFNGLMATRIXLOADFEXTPROC __glewMatrixLoadfEXT = NULL; -PFNGLMATRIXMULTTRANSPOSEDEXTPROC __glewMatrixMultTransposedEXT = NULL; -PFNGLMATRIXMULTTRANSPOSEFEXTPROC __glewMatrixMultTransposefEXT = NULL; -PFNGLMATRIXMULTDEXTPROC __glewMatrixMultdEXT = NULL; -PFNGLMATRIXMULTFEXTPROC __glewMatrixMultfEXT = NULL; -PFNGLMATRIXORTHOEXTPROC __glewMatrixOrthoEXT = NULL; -PFNGLMATRIXPOPEXTPROC __glewMatrixPopEXT = NULL; -PFNGLMATRIXPUSHEXTPROC __glewMatrixPushEXT = NULL; -PFNGLMATRIXROTATEDEXTPROC __glewMatrixRotatedEXT = NULL; -PFNGLMATRIXROTATEFEXTPROC __glewMatrixRotatefEXT = NULL; -PFNGLMATRIXSCALEDEXTPROC __glewMatrixScaledEXT = NULL; -PFNGLMATRIXSCALEFEXTPROC __glewMatrixScalefEXT = NULL; -PFNGLMATRIXTRANSLATEDEXTPROC __glewMatrixTranslatedEXT = NULL; -PFNGLMATRIXTRANSLATEFEXTPROC __glewMatrixTranslatefEXT = NULL; -PFNGLMULTITEXBUFFEREXTPROC __glewMultiTexBufferEXT = NULL; -PFNGLMULTITEXCOORDPOINTEREXTPROC __glewMultiTexCoordPointerEXT = NULL; -PFNGLMULTITEXENVFEXTPROC __glewMultiTexEnvfEXT = NULL; -PFNGLMULTITEXENVFVEXTPROC __glewMultiTexEnvfvEXT = NULL; -PFNGLMULTITEXENVIEXTPROC __glewMultiTexEnviEXT = NULL; -PFNGLMULTITEXENVIVEXTPROC __glewMultiTexEnvivEXT = NULL; -PFNGLMULTITEXGENDEXTPROC __glewMultiTexGendEXT = NULL; -PFNGLMULTITEXGENDVEXTPROC __glewMultiTexGendvEXT = NULL; -PFNGLMULTITEXGENFEXTPROC __glewMultiTexGenfEXT = NULL; -PFNGLMULTITEXGENFVEXTPROC __glewMultiTexGenfvEXT = NULL; -PFNGLMULTITEXGENIEXTPROC __glewMultiTexGeniEXT = NULL; -PFNGLMULTITEXGENIVEXTPROC __glewMultiTexGenivEXT = NULL; -PFNGLMULTITEXIMAGE1DEXTPROC __glewMultiTexImage1DEXT = NULL; -PFNGLMULTITEXIMAGE2DEXTPROC __glewMultiTexImage2DEXT = NULL; -PFNGLMULTITEXIMAGE3DEXTPROC __glewMultiTexImage3DEXT = NULL; -PFNGLMULTITEXPARAMETERIIVEXTPROC __glewMultiTexParameterIivEXT = NULL; -PFNGLMULTITEXPARAMETERIUIVEXTPROC __glewMultiTexParameterIuivEXT = NULL; -PFNGLMULTITEXPARAMETERFEXTPROC __glewMultiTexParameterfEXT = NULL; -PFNGLMULTITEXPARAMETERFVEXTPROC __glewMultiTexParameterfvEXT = NULL; -PFNGLMULTITEXPARAMETERIEXTPROC __glewMultiTexParameteriEXT = NULL; -PFNGLMULTITEXPARAMETERIVEXTPROC __glewMultiTexParameterivEXT = NULL; -PFNGLMULTITEXRENDERBUFFEREXTPROC __glewMultiTexRenderbufferEXT = NULL; -PFNGLMULTITEXSUBIMAGE1DEXTPROC __glewMultiTexSubImage1DEXT = NULL; -PFNGLMULTITEXSUBIMAGE2DEXTPROC __glewMultiTexSubImage2DEXT = NULL; -PFNGLMULTITEXSUBIMAGE3DEXTPROC __glewMultiTexSubImage3DEXT = NULL; -PFNGLNAMEDBUFFERDATAEXTPROC __glewNamedBufferDataEXT = NULL; -PFNGLNAMEDBUFFERSUBDATAEXTPROC __glewNamedBufferSubDataEXT = NULL; -PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC __glewNamedFramebufferRenderbufferEXT = NULL; -PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC __glewNamedFramebufferTexture1DEXT = NULL; -PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC __glewNamedFramebufferTexture2DEXT = NULL; -PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC __glewNamedFramebufferTexture3DEXT = NULL; -PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC __glewNamedFramebufferTextureEXT = NULL; -PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC __glewNamedFramebufferTextureFaceEXT = NULL; -PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC __glewNamedFramebufferTextureLayerEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC __glewNamedProgramLocalParameter4dEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC __glewNamedProgramLocalParameter4dvEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC __glewNamedProgramLocalParameter4fEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC __glewNamedProgramLocalParameter4fvEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC __glewNamedProgramLocalParameterI4iEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC __glewNamedProgramLocalParameterI4ivEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC __glewNamedProgramLocalParameterI4uiEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC __glewNamedProgramLocalParameterI4uivEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC __glewNamedProgramLocalParameters4fvEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC __glewNamedProgramLocalParametersI4ivEXT = NULL; -PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC __glewNamedProgramLocalParametersI4uivEXT = NULL; -PFNGLNAMEDPROGRAMSTRINGEXTPROC __glewNamedProgramStringEXT = NULL; -PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC __glewNamedRenderbufferStorageEXT = NULL; -PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC __glewNamedRenderbufferStorageMultisampleCoverageEXT = NULL; -PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewNamedRenderbufferStorageMultisampleEXT = NULL; -PFNGLPROGRAMUNIFORM1FEXTPROC __glewProgramUniform1fEXT = NULL; -PFNGLPROGRAMUNIFORM1FVEXTPROC __glewProgramUniform1fvEXT = NULL; -PFNGLPROGRAMUNIFORM1IEXTPROC __glewProgramUniform1iEXT = NULL; -PFNGLPROGRAMUNIFORM1IVEXTPROC __glewProgramUniform1ivEXT = NULL; -PFNGLPROGRAMUNIFORM1UIEXTPROC __glewProgramUniform1uiEXT = NULL; -PFNGLPROGRAMUNIFORM1UIVEXTPROC __glewProgramUniform1uivEXT = NULL; -PFNGLPROGRAMUNIFORM2FEXTPROC __glewProgramUniform2fEXT = NULL; -PFNGLPROGRAMUNIFORM2FVEXTPROC __glewProgramUniform2fvEXT = NULL; -PFNGLPROGRAMUNIFORM2IEXTPROC __glewProgramUniform2iEXT = NULL; -PFNGLPROGRAMUNIFORM2IVEXTPROC __glewProgramUniform2ivEXT = NULL; -PFNGLPROGRAMUNIFORM2UIEXTPROC __glewProgramUniform2uiEXT = NULL; -PFNGLPROGRAMUNIFORM2UIVEXTPROC __glewProgramUniform2uivEXT = NULL; -PFNGLPROGRAMUNIFORM3FEXTPROC __glewProgramUniform3fEXT = NULL; -PFNGLPROGRAMUNIFORM3FVEXTPROC __glewProgramUniform3fvEXT = NULL; -PFNGLPROGRAMUNIFORM3IEXTPROC __glewProgramUniform3iEXT = NULL; -PFNGLPROGRAMUNIFORM3IVEXTPROC __glewProgramUniform3ivEXT = NULL; -PFNGLPROGRAMUNIFORM3UIEXTPROC __glewProgramUniform3uiEXT = NULL; -PFNGLPROGRAMUNIFORM3UIVEXTPROC __glewProgramUniform3uivEXT = NULL; -PFNGLPROGRAMUNIFORM4FEXTPROC __glewProgramUniform4fEXT = NULL; -PFNGLPROGRAMUNIFORM4FVEXTPROC __glewProgramUniform4fvEXT = NULL; -PFNGLPROGRAMUNIFORM4IEXTPROC __glewProgramUniform4iEXT = NULL; -PFNGLPROGRAMUNIFORM4IVEXTPROC __glewProgramUniform4ivEXT = NULL; -PFNGLPROGRAMUNIFORM4UIEXTPROC __glewProgramUniform4uiEXT = NULL; -PFNGLPROGRAMUNIFORM4UIVEXTPROC __glewProgramUniform4uivEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC __glewProgramUniformMatrix2fvEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC __glewProgramUniformMatrix2x3fvEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC __glewProgramUniformMatrix2x4fvEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC __glewProgramUniformMatrix3fvEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC __glewProgramUniformMatrix3x2fvEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC __glewProgramUniformMatrix3x4fvEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC __glewProgramUniformMatrix4fvEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC __glewProgramUniformMatrix4x2fvEXT = NULL; -PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC __glewProgramUniformMatrix4x3fvEXT = NULL; -PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC __glewPushClientAttribDefaultEXT = NULL; -PFNGLTEXTUREBUFFEREXTPROC __glewTextureBufferEXT = NULL; -PFNGLTEXTUREIMAGE1DEXTPROC __glewTextureImage1DEXT = NULL; -PFNGLTEXTUREIMAGE2DEXTPROC __glewTextureImage2DEXT = NULL; -PFNGLTEXTUREIMAGE3DEXTPROC __glewTextureImage3DEXT = NULL; -PFNGLTEXTUREPARAMETERIIVEXTPROC __glewTextureParameterIivEXT = NULL; -PFNGLTEXTUREPARAMETERIUIVEXTPROC __glewTextureParameterIuivEXT = NULL; -PFNGLTEXTUREPARAMETERFEXTPROC __glewTextureParameterfEXT = NULL; -PFNGLTEXTUREPARAMETERFVEXTPROC __glewTextureParameterfvEXT = NULL; -PFNGLTEXTUREPARAMETERIEXTPROC __glewTextureParameteriEXT = NULL; -PFNGLTEXTUREPARAMETERIVEXTPROC __glewTextureParameterivEXT = NULL; -PFNGLTEXTURERENDERBUFFEREXTPROC __glewTextureRenderbufferEXT = NULL; -PFNGLTEXTURESUBIMAGE1DEXTPROC __glewTextureSubImage1DEXT = NULL; -PFNGLTEXTURESUBIMAGE2DEXTPROC __glewTextureSubImage2DEXT = NULL; -PFNGLTEXTURESUBIMAGE3DEXTPROC __glewTextureSubImage3DEXT = NULL; -PFNGLUNMAPNAMEDBUFFEREXTPROC __glewUnmapNamedBufferEXT = NULL; - -PFNGLCOLORMASKINDEXEDEXTPROC __glewColorMaskIndexedEXT = NULL; -PFNGLDISABLEINDEXEDEXTPROC __glewDisableIndexedEXT = NULL; -PFNGLENABLEINDEXEDEXTPROC __glewEnableIndexedEXT = NULL; -PFNGLGETBOOLEANINDEXEDVEXTPROC __glewGetBooleanIndexedvEXT = NULL; -PFNGLGETINTEGERINDEXEDVEXTPROC __glewGetIntegerIndexedvEXT = NULL; -PFNGLISENABLEDINDEXEDEXTPROC __glewIsEnabledIndexedEXT = NULL; - -PFNGLDRAWARRAYSINSTANCEDEXTPROC __glewDrawArraysInstancedEXT = NULL; -PFNGLDRAWELEMENTSINSTANCEDEXTPROC __glewDrawElementsInstancedEXT = NULL; - -PFNGLDRAWRANGEELEMENTSEXTPROC __glewDrawRangeElementsEXT = NULL; - -PFNGLFOGCOORDPOINTEREXTPROC __glewFogCoordPointerEXT = NULL; -PFNGLFOGCOORDDEXTPROC __glewFogCoorddEXT = NULL; -PFNGLFOGCOORDDVEXTPROC __glewFogCoorddvEXT = NULL; -PFNGLFOGCOORDFEXTPROC __glewFogCoordfEXT = NULL; -PFNGLFOGCOORDFVEXTPROC __glewFogCoordfvEXT = NULL; - -PFNGLFRAGMENTCOLORMATERIALEXTPROC __glewFragmentColorMaterialEXT = NULL; -PFNGLFRAGMENTLIGHTMODELFEXTPROC __glewFragmentLightModelfEXT = NULL; -PFNGLFRAGMENTLIGHTMODELFVEXTPROC __glewFragmentLightModelfvEXT = NULL; -PFNGLFRAGMENTLIGHTMODELIEXTPROC __glewFragmentLightModeliEXT = NULL; -PFNGLFRAGMENTLIGHTMODELIVEXTPROC __glewFragmentLightModelivEXT = NULL; -PFNGLFRAGMENTLIGHTFEXTPROC __glewFragmentLightfEXT = NULL; -PFNGLFRAGMENTLIGHTFVEXTPROC __glewFragmentLightfvEXT = NULL; -PFNGLFRAGMENTLIGHTIEXTPROC __glewFragmentLightiEXT = NULL; -PFNGLFRAGMENTLIGHTIVEXTPROC __glewFragmentLightivEXT = NULL; -PFNGLFRAGMENTMATERIALFEXTPROC __glewFragmentMaterialfEXT = NULL; -PFNGLFRAGMENTMATERIALFVEXTPROC __glewFragmentMaterialfvEXT = NULL; -PFNGLFRAGMENTMATERIALIEXTPROC __glewFragmentMaterialiEXT = NULL; -PFNGLFRAGMENTMATERIALIVEXTPROC __glewFragmentMaterialivEXT = NULL; -PFNGLGETFRAGMENTLIGHTFVEXTPROC __glewGetFragmentLightfvEXT = NULL; -PFNGLGETFRAGMENTLIGHTIVEXTPROC __glewGetFragmentLightivEXT = NULL; -PFNGLGETFRAGMENTMATERIALFVEXTPROC __glewGetFragmentMaterialfvEXT = NULL; -PFNGLGETFRAGMENTMATERIALIVEXTPROC __glewGetFragmentMaterialivEXT = NULL; -PFNGLLIGHTENVIEXTPROC __glewLightEnviEXT = NULL; - -PFNGLBLITFRAMEBUFFEREXTPROC __glewBlitFramebufferEXT = NULL; - -PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC __glewRenderbufferStorageMultisampleEXT = NULL; - -PFNGLBINDFRAMEBUFFEREXTPROC __glewBindFramebufferEXT = NULL; -PFNGLBINDRENDERBUFFEREXTPROC __glewBindRenderbufferEXT = NULL; -PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC __glewCheckFramebufferStatusEXT = NULL; -PFNGLDELETEFRAMEBUFFERSEXTPROC __glewDeleteFramebuffersEXT = NULL; -PFNGLDELETERENDERBUFFERSEXTPROC __glewDeleteRenderbuffersEXT = NULL; -PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC __glewFramebufferRenderbufferEXT = NULL; -PFNGLFRAMEBUFFERTEXTURE1DEXTPROC __glewFramebufferTexture1DEXT = NULL; -PFNGLFRAMEBUFFERTEXTURE2DEXTPROC __glewFramebufferTexture2DEXT = NULL; -PFNGLFRAMEBUFFERTEXTURE3DEXTPROC __glewFramebufferTexture3DEXT = NULL; -PFNGLGENFRAMEBUFFERSEXTPROC __glewGenFramebuffersEXT = NULL; -PFNGLGENRENDERBUFFERSEXTPROC __glewGenRenderbuffersEXT = NULL; -PFNGLGENERATEMIPMAPEXTPROC __glewGenerateMipmapEXT = NULL; -PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC __glewGetFramebufferAttachmentParameterivEXT = NULL; -PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC __glewGetRenderbufferParameterivEXT = NULL; -PFNGLISFRAMEBUFFEREXTPROC __glewIsFramebufferEXT = NULL; -PFNGLISRENDERBUFFEREXTPROC __glewIsRenderbufferEXT = NULL; -PFNGLRENDERBUFFERSTORAGEEXTPROC __glewRenderbufferStorageEXT = NULL; - -PFNGLFRAMEBUFFERTEXTUREEXTPROC __glewFramebufferTextureEXT = NULL; -PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC __glewFramebufferTextureFaceEXT = NULL; -PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC __glewFramebufferTextureLayerEXT = NULL; -PFNGLPROGRAMPARAMETERIEXTPROC __glewProgramParameteriEXT = NULL; - -PFNGLPROGRAMENVPARAMETERS4FVEXTPROC __glewProgramEnvParameters4fvEXT = NULL; -PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC __glewProgramLocalParameters4fvEXT = NULL; - -PFNGLBINDFRAGDATALOCATIONEXTPROC __glewBindFragDataLocationEXT = NULL; -PFNGLGETFRAGDATALOCATIONEXTPROC __glewGetFragDataLocationEXT = NULL; -PFNGLGETUNIFORMUIVEXTPROC __glewGetUniformuivEXT = NULL; -PFNGLGETVERTEXATTRIBIIVEXTPROC __glewGetVertexAttribIivEXT = NULL; -PFNGLGETVERTEXATTRIBIUIVEXTPROC __glewGetVertexAttribIuivEXT = NULL; -PFNGLUNIFORM1UIEXTPROC __glewUniform1uiEXT = NULL; -PFNGLUNIFORM1UIVEXTPROC __glewUniform1uivEXT = NULL; -PFNGLUNIFORM2UIEXTPROC __glewUniform2uiEXT = NULL; -PFNGLUNIFORM2UIVEXTPROC __glewUniform2uivEXT = NULL; -PFNGLUNIFORM3UIEXTPROC __glewUniform3uiEXT = NULL; -PFNGLUNIFORM3UIVEXTPROC __glewUniform3uivEXT = NULL; -PFNGLUNIFORM4UIEXTPROC __glewUniform4uiEXT = NULL; -PFNGLUNIFORM4UIVEXTPROC __glewUniform4uivEXT = NULL; -PFNGLVERTEXATTRIBI1IEXTPROC __glewVertexAttribI1iEXT = NULL; -PFNGLVERTEXATTRIBI1IVEXTPROC __glewVertexAttribI1ivEXT = NULL; -PFNGLVERTEXATTRIBI1UIEXTPROC __glewVertexAttribI1uiEXT = NULL; -PFNGLVERTEXATTRIBI1UIVEXTPROC __glewVertexAttribI1uivEXT = NULL; -PFNGLVERTEXATTRIBI2IEXTPROC __glewVertexAttribI2iEXT = NULL; -PFNGLVERTEXATTRIBI2IVEXTPROC __glewVertexAttribI2ivEXT = NULL; -PFNGLVERTEXATTRIBI2UIEXTPROC __glewVertexAttribI2uiEXT = NULL; -PFNGLVERTEXATTRIBI2UIVEXTPROC __glewVertexAttribI2uivEXT = NULL; -PFNGLVERTEXATTRIBI3IEXTPROC __glewVertexAttribI3iEXT = NULL; -PFNGLVERTEXATTRIBI3IVEXTPROC __glewVertexAttribI3ivEXT = NULL; -PFNGLVERTEXATTRIBI3UIEXTPROC __glewVertexAttribI3uiEXT = NULL; -PFNGLVERTEXATTRIBI3UIVEXTPROC __glewVertexAttribI3uivEXT = NULL; -PFNGLVERTEXATTRIBI4BVEXTPROC __glewVertexAttribI4bvEXT = NULL; -PFNGLVERTEXATTRIBI4IEXTPROC __glewVertexAttribI4iEXT = NULL; -PFNGLVERTEXATTRIBI4IVEXTPROC __glewVertexAttribI4ivEXT = NULL; -PFNGLVERTEXATTRIBI4SVEXTPROC __glewVertexAttribI4svEXT = NULL; -PFNGLVERTEXATTRIBI4UBVEXTPROC __glewVertexAttribI4ubvEXT = NULL; -PFNGLVERTEXATTRIBI4UIEXTPROC __glewVertexAttribI4uiEXT = NULL; -PFNGLVERTEXATTRIBI4UIVEXTPROC __glewVertexAttribI4uivEXT = NULL; -PFNGLVERTEXATTRIBI4USVEXTPROC __glewVertexAttribI4usvEXT = NULL; -PFNGLVERTEXATTRIBIPOINTEREXTPROC __glewVertexAttribIPointerEXT = NULL; - -PFNGLGETHISTOGRAMEXTPROC __glewGetHistogramEXT = NULL; -PFNGLGETHISTOGRAMPARAMETERFVEXTPROC __glewGetHistogramParameterfvEXT = NULL; -PFNGLGETHISTOGRAMPARAMETERIVEXTPROC __glewGetHistogramParameterivEXT = NULL; -PFNGLGETMINMAXEXTPROC __glewGetMinmaxEXT = NULL; -PFNGLGETMINMAXPARAMETERFVEXTPROC __glewGetMinmaxParameterfvEXT = NULL; -PFNGLGETMINMAXPARAMETERIVEXTPROC __glewGetMinmaxParameterivEXT = NULL; -PFNGLHISTOGRAMEXTPROC __glewHistogramEXT = NULL; -PFNGLMINMAXEXTPROC __glewMinmaxEXT = NULL; -PFNGLRESETHISTOGRAMEXTPROC __glewResetHistogramEXT = NULL; -PFNGLRESETMINMAXEXTPROC __glewResetMinmaxEXT = NULL; - -PFNGLINDEXFUNCEXTPROC __glewIndexFuncEXT = NULL; - -PFNGLINDEXMATERIALEXTPROC __glewIndexMaterialEXT = NULL; - -PFNGLAPPLYTEXTUREEXTPROC __glewApplyTextureEXT = NULL; -PFNGLTEXTURELIGHTEXTPROC __glewTextureLightEXT = NULL; -PFNGLTEXTUREMATERIALEXTPROC __glewTextureMaterialEXT = NULL; - -PFNGLMULTIDRAWARRAYSEXTPROC __glewMultiDrawArraysEXT = NULL; -PFNGLMULTIDRAWELEMENTSEXTPROC __glewMultiDrawElementsEXT = NULL; - -PFNGLSAMPLEMASKEXTPROC __glewSampleMaskEXT = NULL; -PFNGLSAMPLEPATTERNEXTPROC __glewSamplePatternEXT = NULL; - -PFNGLCOLORTABLEEXTPROC __glewColorTableEXT = NULL; -PFNGLGETCOLORTABLEEXTPROC __glewGetColorTableEXT = NULL; -PFNGLGETCOLORTABLEPARAMETERFVEXTPROC __glewGetColorTableParameterfvEXT = NULL; -PFNGLGETCOLORTABLEPARAMETERIVEXTPROC __glewGetColorTableParameterivEXT = NULL; - -PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC __glewGetPixelTransformParameterfvEXT = NULL; -PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC __glewGetPixelTransformParameterivEXT = NULL; -PFNGLPIXELTRANSFORMPARAMETERFEXTPROC __glewPixelTransformParameterfEXT = NULL; -PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC __glewPixelTransformParameterfvEXT = NULL; -PFNGLPIXELTRANSFORMPARAMETERIEXTPROC __glewPixelTransformParameteriEXT = NULL; -PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC __glewPixelTransformParameterivEXT = NULL; - -PFNGLPOINTPARAMETERFEXTPROC __glewPointParameterfEXT = NULL; -PFNGLPOINTPARAMETERFVEXTPROC __glewPointParameterfvEXT = NULL; - -PFNGLPOLYGONOFFSETEXTPROC __glewPolygonOffsetEXT = NULL; - -PFNGLBEGINSCENEEXTPROC __glewBeginSceneEXT = NULL; -PFNGLENDSCENEEXTPROC __glewEndSceneEXT = NULL; - -PFNGLSECONDARYCOLOR3BEXTPROC __glewSecondaryColor3bEXT = NULL; -PFNGLSECONDARYCOLOR3BVEXTPROC __glewSecondaryColor3bvEXT = NULL; -PFNGLSECONDARYCOLOR3DEXTPROC __glewSecondaryColor3dEXT = NULL; -PFNGLSECONDARYCOLOR3DVEXTPROC __glewSecondaryColor3dvEXT = NULL; -PFNGLSECONDARYCOLOR3FEXTPROC __glewSecondaryColor3fEXT = NULL; -PFNGLSECONDARYCOLOR3FVEXTPROC __glewSecondaryColor3fvEXT = NULL; -PFNGLSECONDARYCOLOR3IEXTPROC __glewSecondaryColor3iEXT = NULL; -PFNGLSECONDARYCOLOR3IVEXTPROC __glewSecondaryColor3ivEXT = NULL; -PFNGLSECONDARYCOLOR3SEXTPROC __glewSecondaryColor3sEXT = NULL; -PFNGLSECONDARYCOLOR3SVEXTPROC __glewSecondaryColor3svEXT = NULL; -PFNGLSECONDARYCOLOR3UBEXTPROC __glewSecondaryColor3ubEXT = NULL; -PFNGLSECONDARYCOLOR3UBVEXTPROC __glewSecondaryColor3ubvEXT = NULL; -PFNGLSECONDARYCOLOR3UIEXTPROC __glewSecondaryColor3uiEXT = NULL; -PFNGLSECONDARYCOLOR3UIVEXTPROC __glewSecondaryColor3uivEXT = NULL; -PFNGLSECONDARYCOLOR3USEXTPROC __glewSecondaryColor3usEXT = NULL; -PFNGLSECONDARYCOLOR3USVEXTPROC __glewSecondaryColor3usvEXT = NULL; -PFNGLSECONDARYCOLORPOINTEREXTPROC __glewSecondaryColorPointerEXT = NULL; - -PFNGLACTIVESTENCILFACEEXTPROC __glewActiveStencilFaceEXT = NULL; - -PFNGLTEXSUBIMAGE1DEXTPROC __glewTexSubImage1DEXT = NULL; -PFNGLTEXSUBIMAGE2DEXTPROC __glewTexSubImage2DEXT = NULL; -PFNGLTEXSUBIMAGE3DEXTPROC __glewTexSubImage3DEXT = NULL; - -PFNGLTEXIMAGE3DEXTPROC __glewTexImage3DEXT = NULL; - -PFNGLTEXBUFFEREXTPROC __glewTexBufferEXT = NULL; - -PFNGLCLEARCOLORIIEXTPROC __glewClearColorIiEXT = NULL; -PFNGLCLEARCOLORIUIEXTPROC __glewClearColorIuiEXT = NULL; -PFNGLGETTEXPARAMETERIIVEXTPROC __glewGetTexParameterIivEXT = NULL; -PFNGLGETTEXPARAMETERIUIVEXTPROC __glewGetTexParameterIuivEXT = NULL; -PFNGLTEXPARAMETERIIVEXTPROC __glewTexParameterIivEXT = NULL; -PFNGLTEXPARAMETERIUIVEXTPROC __glewTexParameterIuivEXT = NULL; - -PFNGLARETEXTURESRESIDENTEXTPROC __glewAreTexturesResidentEXT = NULL; -PFNGLBINDTEXTUREEXTPROC __glewBindTextureEXT = NULL; -PFNGLDELETETEXTURESEXTPROC __glewDeleteTexturesEXT = NULL; -PFNGLGENTEXTURESEXTPROC __glewGenTexturesEXT = NULL; -PFNGLISTEXTUREEXTPROC __glewIsTextureEXT = NULL; -PFNGLPRIORITIZETEXTURESEXTPROC __glewPrioritizeTexturesEXT = NULL; - -PFNGLTEXTURENORMALEXTPROC __glewTextureNormalEXT = NULL; - -PFNGLGETQUERYOBJECTI64VEXTPROC __glewGetQueryObjecti64vEXT = NULL; -PFNGLGETQUERYOBJECTUI64VEXTPROC __glewGetQueryObjectui64vEXT = NULL; - -PFNGLBEGINTRANSFORMFEEDBACKEXTPROC __glewBeginTransformFeedbackEXT = NULL; -PFNGLBINDBUFFERBASEEXTPROC __glewBindBufferBaseEXT = NULL; -PFNGLBINDBUFFEROFFSETEXTPROC __glewBindBufferOffsetEXT = NULL; -PFNGLBINDBUFFERRANGEEXTPROC __glewBindBufferRangeEXT = NULL; -PFNGLENDTRANSFORMFEEDBACKEXTPROC __glewEndTransformFeedbackEXT = NULL; -PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC __glewGetTransformFeedbackVaryingEXT = NULL; -PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC __glewTransformFeedbackVaryingsEXT = NULL; - -PFNGLARRAYELEMENTEXTPROC __glewArrayElementEXT = NULL; -PFNGLCOLORPOINTEREXTPROC __glewColorPointerEXT = NULL; -PFNGLDRAWARRAYSEXTPROC __glewDrawArraysEXT = NULL; -PFNGLEDGEFLAGPOINTEREXTPROC __glewEdgeFlagPointerEXT = NULL; -PFNGLGETPOINTERVEXTPROC __glewGetPointervEXT = NULL; -PFNGLINDEXPOINTEREXTPROC __glewIndexPointerEXT = NULL; -PFNGLNORMALPOINTEREXTPROC __glewNormalPointerEXT = NULL; -PFNGLTEXCOORDPOINTEREXTPROC __glewTexCoordPointerEXT = NULL; -PFNGLVERTEXPOINTEREXTPROC __glewVertexPointerEXT = NULL; - -PFNGLBEGINVERTEXSHADEREXTPROC __glewBeginVertexShaderEXT = NULL; -PFNGLBINDLIGHTPARAMETEREXTPROC __glewBindLightParameterEXT = NULL; -PFNGLBINDMATERIALPARAMETEREXTPROC __glewBindMaterialParameterEXT = NULL; -PFNGLBINDPARAMETEREXTPROC __glewBindParameterEXT = NULL; -PFNGLBINDTEXGENPARAMETEREXTPROC __glewBindTexGenParameterEXT = NULL; -PFNGLBINDTEXTUREUNITPARAMETEREXTPROC __glewBindTextureUnitParameterEXT = NULL; -PFNGLBINDVERTEXSHADEREXTPROC __glewBindVertexShaderEXT = NULL; -PFNGLDELETEVERTEXSHADEREXTPROC __glewDeleteVertexShaderEXT = NULL; -PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC __glewDisableVariantClientStateEXT = NULL; -PFNGLENABLEVARIANTCLIENTSTATEEXTPROC __glewEnableVariantClientStateEXT = NULL; -PFNGLENDVERTEXSHADEREXTPROC __glewEndVertexShaderEXT = NULL; -PFNGLEXTRACTCOMPONENTEXTPROC __glewExtractComponentEXT = NULL; -PFNGLGENSYMBOLSEXTPROC __glewGenSymbolsEXT = NULL; -PFNGLGENVERTEXSHADERSEXTPROC __glewGenVertexShadersEXT = NULL; -PFNGLGETINVARIANTBOOLEANVEXTPROC __glewGetInvariantBooleanvEXT = NULL; -PFNGLGETINVARIANTFLOATVEXTPROC __glewGetInvariantFloatvEXT = NULL; -PFNGLGETINVARIANTINTEGERVEXTPROC __glewGetInvariantIntegervEXT = NULL; -PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC __glewGetLocalConstantBooleanvEXT = NULL; -PFNGLGETLOCALCONSTANTFLOATVEXTPROC __glewGetLocalConstantFloatvEXT = NULL; -PFNGLGETLOCALCONSTANTINTEGERVEXTPROC __glewGetLocalConstantIntegervEXT = NULL; -PFNGLGETVARIANTBOOLEANVEXTPROC __glewGetVariantBooleanvEXT = NULL; -PFNGLGETVARIANTFLOATVEXTPROC __glewGetVariantFloatvEXT = NULL; -PFNGLGETVARIANTINTEGERVEXTPROC __glewGetVariantIntegervEXT = NULL; -PFNGLGETVARIANTPOINTERVEXTPROC __glewGetVariantPointervEXT = NULL; -PFNGLINSERTCOMPONENTEXTPROC __glewInsertComponentEXT = NULL; -PFNGLISVARIANTENABLEDEXTPROC __glewIsVariantEnabledEXT = NULL; -PFNGLSETINVARIANTEXTPROC __glewSetInvariantEXT = NULL; -PFNGLSETLOCALCONSTANTEXTPROC __glewSetLocalConstantEXT = NULL; -PFNGLSHADEROP1EXTPROC __glewShaderOp1EXT = NULL; -PFNGLSHADEROP2EXTPROC __glewShaderOp2EXT = NULL; -PFNGLSHADEROP3EXTPROC __glewShaderOp3EXT = NULL; -PFNGLSWIZZLEEXTPROC __glewSwizzleEXT = NULL; -PFNGLVARIANTPOINTEREXTPROC __glewVariantPointerEXT = NULL; -PFNGLVARIANTBVEXTPROC __glewVariantbvEXT = NULL; -PFNGLVARIANTDVEXTPROC __glewVariantdvEXT = NULL; -PFNGLVARIANTFVEXTPROC __glewVariantfvEXT = NULL; -PFNGLVARIANTIVEXTPROC __glewVariantivEXT = NULL; -PFNGLVARIANTSVEXTPROC __glewVariantsvEXT = NULL; -PFNGLVARIANTUBVEXTPROC __glewVariantubvEXT = NULL; -PFNGLVARIANTUIVEXTPROC __glewVariantuivEXT = NULL; -PFNGLVARIANTUSVEXTPROC __glewVariantusvEXT = NULL; -PFNGLWRITEMASKEXTPROC __glewWriteMaskEXT = NULL; - -PFNGLVERTEXWEIGHTPOINTEREXTPROC __glewVertexWeightPointerEXT = NULL; -PFNGLVERTEXWEIGHTFEXTPROC __glewVertexWeightfEXT = NULL; -PFNGLVERTEXWEIGHTFVEXTPROC __glewVertexWeightfvEXT = NULL; - -PFNGLFRAMETERMINATORGREMEDYPROC __glewFrameTerminatorGREMEDY = NULL; - -PFNGLSTRINGMARKERGREMEDYPROC __glewStringMarkerGREMEDY = NULL; - -PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC __glewGetImageTransformParameterfvHP = NULL; -PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC __glewGetImageTransformParameterivHP = NULL; -PFNGLIMAGETRANSFORMPARAMETERFHPPROC __glewImageTransformParameterfHP = NULL; -PFNGLIMAGETRANSFORMPARAMETERFVHPPROC __glewImageTransformParameterfvHP = NULL; -PFNGLIMAGETRANSFORMPARAMETERIHPPROC __glewImageTransformParameteriHP = NULL; -PFNGLIMAGETRANSFORMPARAMETERIVHPPROC __glewImageTransformParameterivHP = NULL; - -PFNGLMULTIMODEDRAWARRAYSIBMPROC __glewMultiModeDrawArraysIBM = NULL; -PFNGLMULTIMODEDRAWELEMENTSIBMPROC __glewMultiModeDrawElementsIBM = NULL; - -PFNGLCOLORPOINTERLISTIBMPROC __glewColorPointerListIBM = NULL; -PFNGLEDGEFLAGPOINTERLISTIBMPROC __glewEdgeFlagPointerListIBM = NULL; -PFNGLFOGCOORDPOINTERLISTIBMPROC __glewFogCoordPointerListIBM = NULL; -PFNGLINDEXPOINTERLISTIBMPROC __glewIndexPointerListIBM = NULL; -PFNGLNORMALPOINTERLISTIBMPROC __glewNormalPointerListIBM = NULL; -PFNGLSECONDARYCOLORPOINTERLISTIBMPROC __glewSecondaryColorPointerListIBM = NULL; -PFNGLTEXCOORDPOINTERLISTIBMPROC __glewTexCoordPointerListIBM = NULL; -PFNGLVERTEXPOINTERLISTIBMPROC __glewVertexPointerListIBM = NULL; - -PFNGLCOLORPOINTERVINTELPROC __glewColorPointervINTEL = NULL; -PFNGLNORMALPOINTERVINTELPROC __glewNormalPointervINTEL = NULL; -PFNGLTEXCOORDPOINTERVINTELPROC __glewTexCoordPointervINTEL = NULL; -PFNGLVERTEXPOINTERVINTELPROC __glewVertexPointervINTEL = NULL; - -PFNGLTEXSCISSORFUNCINTELPROC __glewTexScissorFuncINTEL = NULL; -PFNGLTEXSCISSORINTELPROC __glewTexScissorINTEL = NULL; - -PFNGLBUFFERREGIONENABLEDEXTPROC __glewBufferRegionEnabledEXT = NULL; -PFNGLDELETEBUFFERREGIONEXTPROC __glewDeleteBufferRegionEXT = NULL; -PFNGLDRAWBUFFERREGIONEXTPROC __glewDrawBufferRegionEXT = NULL; -PFNGLNEWBUFFERREGIONEXTPROC __glewNewBufferRegionEXT = NULL; -PFNGLREADBUFFERREGIONEXTPROC __glewReadBufferRegionEXT = NULL; - -PFNGLRESIZEBUFFERSMESAPROC __glewResizeBuffersMESA = NULL; - -PFNGLWINDOWPOS2DMESAPROC __glewWindowPos2dMESA = NULL; -PFNGLWINDOWPOS2DVMESAPROC __glewWindowPos2dvMESA = NULL; -PFNGLWINDOWPOS2FMESAPROC __glewWindowPos2fMESA = NULL; -PFNGLWINDOWPOS2FVMESAPROC __glewWindowPos2fvMESA = NULL; -PFNGLWINDOWPOS2IMESAPROC __glewWindowPos2iMESA = NULL; -PFNGLWINDOWPOS2IVMESAPROC __glewWindowPos2ivMESA = NULL; -PFNGLWINDOWPOS2SMESAPROC __glewWindowPos2sMESA = NULL; -PFNGLWINDOWPOS2SVMESAPROC __glewWindowPos2svMESA = NULL; -PFNGLWINDOWPOS3DMESAPROC __glewWindowPos3dMESA = NULL; -PFNGLWINDOWPOS3DVMESAPROC __glewWindowPos3dvMESA = NULL; -PFNGLWINDOWPOS3FMESAPROC __glewWindowPos3fMESA = NULL; -PFNGLWINDOWPOS3FVMESAPROC __glewWindowPos3fvMESA = NULL; -PFNGLWINDOWPOS3IMESAPROC __glewWindowPos3iMESA = NULL; -PFNGLWINDOWPOS3IVMESAPROC __glewWindowPos3ivMESA = NULL; -PFNGLWINDOWPOS3SMESAPROC __glewWindowPos3sMESA = NULL; -PFNGLWINDOWPOS3SVMESAPROC __glewWindowPos3svMESA = NULL; -PFNGLWINDOWPOS4DMESAPROC __glewWindowPos4dMESA = NULL; -PFNGLWINDOWPOS4DVMESAPROC __glewWindowPos4dvMESA = NULL; -PFNGLWINDOWPOS4FMESAPROC __glewWindowPos4fMESA = NULL; -PFNGLWINDOWPOS4FVMESAPROC __glewWindowPos4fvMESA = NULL; -PFNGLWINDOWPOS4IMESAPROC __glewWindowPos4iMESA = NULL; -PFNGLWINDOWPOS4IVMESAPROC __glewWindowPos4ivMESA = NULL; -PFNGLWINDOWPOS4SMESAPROC __glewWindowPos4sMESA = NULL; -PFNGLWINDOWPOS4SVMESAPROC __glewWindowPos4svMESA = NULL; - -PFNGLBEGINCONDITIONALRENDERNVPROC __glewBeginConditionalRenderNV = NULL; -PFNGLENDCONDITIONALRENDERNVPROC __glewEndConditionalRenderNV = NULL; - -PFNGLCLEARDEPTHDNVPROC __glewClearDepthdNV = NULL; -PFNGLDEPTHBOUNDSDNVPROC __glewDepthBoundsdNV = NULL; -PFNGLDEPTHRANGEDNVPROC __glewDepthRangedNV = NULL; - -PFNGLEVALMAPSNVPROC __glewEvalMapsNV = NULL; -PFNGLGETMAPATTRIBPARAMETERFVNVPROC __glewGetMapAttribParameterfvNV = NULL; -PFNGLGETMAPATTRIBPARAMETERIVNVPROC __glewGetMapAttribParameterivNV = NULL; -PFNGLGETMAPCONTROLPOINTSNVPROC __glewGetMapControlPointsNV = NULL; -PFNGLGETMAPPARAMETERFVNVPROC __glewGetMapParameterfvNV = NULL; -PFNGLGETMAPPARAMETERIVNVPROC __glewGetMapParameterivNV = NULL; -PFNGLMAPCONTROLPOINTSNVPROC __glewMapControlPointsNV = NULL; -PFNGLMAPPARAMETERFVNVPROC __glewMapParameterfvNV = NULL; -PFNGLMAPPARAMETERIVNVPROC __glewMapParameterivNV = NULL; - -PFNGLGETMULTISAMPLEFVNVPROC __glewGetMultisamplefvNV = NULL; -PFNGLSAMPLEMASKINDEXEDNVPROC __glewSampleMaskIndexedNV = NULL; -PFNGLTEXRENDERBUFFERNVPROC __glewTexRenderbufferNV = NULL; - -PFNGLDELETEFENCESNVPROC __glewDeleteFencesNV = NULL; -PFNGLFINISHFENCENVPROC __glewFinishFenceNV = NULL; -PFNGLGENFENCESNVPROC __glewGenFencesNV = NULL; -PFNGLGETFENCEIVNVPROC __glewGetFenceivNV = NULL; -PFNGLISFENCENVPROC __glewIsFenceNV = NULL; -PFNGLSETFENCENVPROC __glewSetFenceNV = NULL; -PFNGLTESTFENCENVPROC __glewTestFenceNV = NULL; - -PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC __glewGetProgramNamedParameterdvNV = NULL; -PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC __glewGetProgramNamedParameterfvNV = NULL; -PFNGLPROGRAMNAMEDPARAMETER4DNVPROC __glewProgramNamedParameter4dNV = NULL; -PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC __glewProgramNamedParameter4dvNV = NULL; -PFNGLPROGRAMNAMEDPARAMETER4FNVPROC __glewProgramNamedParameter4fNV = NULL; -PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC __glewProgramNamedParameter4fvNV = NULL; - -PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC __glewRenderbufferStorageMultisampleCoverageNV = NULL; - -PFNGLPROGRAMVERTEXLIMITNVPROC __glewProgramVertexLimitNV = NULL; - -PFNGLPROGRAMENVPARAMETERI4INVPROC __glewProgramEnvParameterI4iNV = NULL; -PFNGLPROGRAMENVPARAMETERI4IVNVPROC __glewProgramEnvParameterI4ivNV = NULL; -PFNGLPROGRAMENVPARAMETERI4UINVPROC __glewProgramEnvParameterI4uiNV = NULL; -PFNGLPROGRAMENVPARAMETERI4UIVNVPROC __glewProgramEnvParameterI4uivNV = NULL; -PFNGLPROGRAMENVPARAMETERSI4IVNVPROC __glewProgramEnvParametersI4ivNV = NULL; -PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC __glewProgramEnvParametersI4uivNV = NULL; -PFNGLPROGRAMLOCALPARAMETERI4INVPROC __glewProgramLocalParameterI4iNV = NULL; -PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC __glewProgramLocalParameterI4ivNV = NULL; -PFNGLPROGRAMLOCALPARAMETERI4UINVPROC __glewProgramLocalParameterI4uiNV = NULL; -PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC __glewProgramLocalParameterI4uivNV = NULL; -PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC __glewProgramLocalParametersI4ivNV = NULL; -PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC __glewProgramLocalParametersI4uivNV = NULL; - -PFNGLCOLOR3HNVPROC __glewColor3hNV = NULL; -PFNGLCOLOR3HVNVPROC __glewColor3hvNV = NULL; -PFNGLCOLOR4HNVPROC __glewColor4hNV = NULL; -PFNGLCOLOR4HVNVPROC __glewColor4hvNV = NULL; -PFNGLFOGCOORDHNVPROC __glewFogCoordhNV = NULL; -PFNGLFOGCOORDHVNVPROC __glewFogCoordhvNV = NULL; -PFNGLMULTITEXCOORD1HNVPROC __glewMultiTexCoord1hNV = NULL; -PFNGLMULTITEXCOORD1HVNVPROC __glewMultiTexCoord1hvNV = NULL; -PFNGLMULTITEXCOORD2HNVPROC __glewMultiTexCoord2hNV = NULL; -PFNGLMULTITEXCOORD2HVNVPROC __glewMultiTexCoord2hvNV = NULL; -PFNGLMULTITEXCOORD3HNVPROC __glewMultiTexCoord3hNV = NULL; -PFNGLMULTITEXCOORD3HVNVPROC __glewMultiTexCoord3hvNV = NULL; -PFNGLMULTITEXCOORD4HNVPROC __glewMultiTexCoord4hNV = NULL; -PFNGLMULTITEXCOORD4HVNVPROC __glewMultiTexCoord4hvNV = NULL; -PFNGLNORMAL3HNVPROC __glewNormal3hNV = NULL; -PFNGLNORMAL3HVNVPROC __glewNormal3hvNV = NULL; -PFNGLSECONDARYCOLOR3HNVPROC __glewSecondaryColor3hNV = NULL; -PFNGLSECONDARYCOLOR3HVNVPROC __glewSecondaryColor3hvNV = NULL; -PFNGLTEXCOORD1HNVPROC __glewTexCoord1hNV = NULL; -PFNGLTEXCOORD1HVNVPROC __glewTexCoord1hvNV = NULL; -PFNGLTEXCOORD2HNVPROC __glewTexCoord2hNV = NULL; -PFNGLTEXCOORD2HVNVPROC __glewTexCoord2hvNV = NULL; -PFNGLTEXCOORD3HNVPROC __glewTexCoord3hNV = NULL; -PFNGLTEXCOORD3HVNVPROC __glewTexCoord3hvNV = NULL; -PFNGLTEXCOORD4HNVPROC __glewTexCoord4hNV = NULL; -PFNGLTEXCOORD4HVNVPROC __glewTexCoord4hvNV = NULL; -PFNGLVERTEX2HNVPROC __glewVertex2hNV = NULL; -PFNGLVERTEX2HVNVPROC __glewVertex2hvNV = NULL; -PFNGLVERTEX3HNVPROC __glewVertex3hNV = NULL; -PFNGLVERTEX3HVNVPROC __glewVertex3hvNV = NULL; -PFNGLVERTEX4HNVPROC __glewVertex4hNV = NULL; -PFNGLVERTEX4HVNVPROC __glewVertex4hvNV = NULL; -PFNGLVERTEXATTRIB1HNVPROC __glewVertexAttrib1hNV = NULL; -PFNGLVERTEXATTRIB1HVNVPROC __glewVertexAttrib1hvNV = NULL; -PFNGLVERTEXATTRIB2HNVPROC __glewVertexAttrib2hNV = NULL; -PFNGLVERTEXATTRIB2HVNVPROC __glewVertexAttrib2hvNV = NULL; -PFNGLVERTEXATTRIB3HNVPROC __glewVertexAttrib3hNV = NULL; -PFNGLVERTEXATTRIB3HVNVPROC __glewVertexAttrib3hvNV = NULL; -PFNGLVERTEXATTRIB4HNVPROC __glewVertexAttrib4hNV = NULL; -PFNGLVERTEXATTRIB4HVNVPROC __glewVertexAttrib4hvNV = NULL; -PFNGLVERTEXATTRIBS1HVNVPROC __glewVertexAttribs1hvNV = NULL; -PFNGLVERTEXATTRIBS2HVNVPROC __glewVertexAttribs2hvNV = NULL; -PFNGLVERTEXATTRIBS3HVNVPROC __glewVertexAttribs3hvNV = NULL; -PFNGLVERTEXATTRIBS4HVNVPROC __glewVertexAttribs4hvNV = NULL; -PFNGLVERTEXWEIGHTHNVPROC __glewVertexWeighthNV = NULL; -PFNGLVERTEXWEIGHTHVNVPROC __glewVertexWeighthvNV = NULL; - -PFNGLBEGINOCCLUSIONQUERYNVPROC __glewBeginOcclusionQueryNV = NULL; -PFNGLDELETEOCCLUSIONQUERIESNVPROC __glewDeleteOcclusionQueriesNV = NULL; -PFNGLENDOCCLUSIONQUERYNVPROC __glewEndOcclusionQueryNV = NULL; -PFNGLGENOCCLUSIONQUERIESNVPROC __glewGenOcclusionQueriesNV = NULL; -PFNGLGETOCCLUSIONQUERYIVNVPROC __glewGetOcclusionQueryivNV = NULL; -PFNGLGETOCCLUSIONQUERYUIVNVPROC __glewGetOcclusionQueryuivNV = NULL; -PFNGLISOCCLUSIONQUERYNVPROC __glewIsOcclusionQueryNV = NULL; - -PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC __glewProgramBufferParametersIivNV = NULL; -PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC __glewProgramBufferParametersIuivNV = NULL; -PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC __glewProgramBufferParametersfvNV = NULL; - -PFNGLFLUSHPIXELDATARANGENVPROC __glewFlushPixelDataRangeNV = NULL; -PFNGLPIXELDATARANGENVPROC __glewPixelDataRangeNV = NULL; - -PFNGLPOINTPARAMETERINVPROC __glewPointParameteriNV = NULL; -PFNGLPOINTPARAMETERIVNVPROC __glewPointParameterivNV = NULL; - -PFNGLGETVIDEOI64VNVPROC __glewGetVideoi64vNV = NULL; -PFNGLGETVIDEOIVNVPROC __glewGetVideoivNV = NULL; -PFNGLGETVIDEOUI64VNVPROC __glewGetVideoui64vNV = NULL; -PFNGLGETVIDEOUIVNVPROC __glewGetVideouivNV = NULL; -PFNGLPRESENTFRAMEDUALFILLNVPROC __glewPresentFrameDualFillNV = NULL; -PFNGLPRESENTFRAMEKEYEDNVPROC __glewPresentFrameKeyedNV = NULL; -PFNGLVIDEOPARAMETERIVNVPROC __glewVideoParameterivNV = NULL; - -PFNGLPRIMITIVERESTARTINDEXNVPROC __glewPrimitiveRestartIndexNV = NULL; -PFNGLPRIMITIVERESTARTNVPROC __glewPrimitiveRestartNV = NULL; - -PFNGLCOMBINERINPUTNVPROC __glewCombinerInputNV = NULL; -PFNGLCOMBINEROUTPUTNVPROC __glewCombinerOutputNV = NULL; -PFNGLCOMBINERPARAMETERFNVPROC __glewCombinerParameterfNV = NULL; -PFNGLCOMBINERPARAMETERFVNVPROC __glewCombinerParameterfvNV = NULL; -PFNGLCOMBINERPARAMETERINVPROC __glewCombinerParameteriNV = NULL; -PFNGLCOMBINERPARAMETERIVNVPROC __glewCombinerParameterivNV = NULL; -PFNGLFINALCOMBINERINPUTNVPROC __glewFinalCombinerInputNV = NULL; -PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC __glewGetCombinerInputParameterfvNV = NULL; -PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC __glewGetCombinerInputParameterivNV = NULL; -PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC __glewGetCombinerOutputParameterfvNV = NULL; -PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC __glewGetCombinerOutputParameterivNV = NULL; -PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC __glewGetFinalCombinerInputParameterfvNV = NULL; -PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC __glewGetFinalCombinerInputParameterivNV = NULL; - -PFNGLCOMBINERSTAGEPARAMETERFVNVPROC __glewCombinerStageParameterfvNV = NULL; -PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC __glewGetCombinerStageParameterfvNV = NULL; - -PFNGLACTIVEVARYINGNVPROC __glewActiveVaryingNV = NULL; -PFNGLBEGINTRANSFORMFEEDBACKNVPROC __glewBeginTransformFeedbackNV = NULL; -PFNGLBINDBUFFERBASENVPROC __glewBindBufferBaseNV = NULL; -PFNGLBINDBUFFEROFFSETNVPROC __glewBindBufferOffsetNV = NULL; -PFNGLBINDBUFFERRANGENVPROC __glewBindBufferRangeNV = NULL; -PFNGLENDTRANSFORMFEEDBACKNVPROC __glewEndTransformFeedbackNV = NULL; -PFNGLGETACTIVEVARYINGNVPROC __glewGetActiveVaryingNV = NULL; -PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC __glewGetTransformFeedbackVaryingNV = NULL; -PFNGLGETVARYINGLOCATIONNVPROC __glewGetVaryingLocationNV = NULL; -PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC __glewTransformFeedbackAttribsNV = NULL; -PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC __glewTransformFeedbackVaryingsNV = NULL; - -PFNGLFLUSHVERTEXARRAYRANGENVPROC __glewFlushVertexArrayRangeNV = NULL; -PFNGLVERTEXARRAYRANGENVPROC __glewVertexArrayRangeNV = NULL; - -PFNGLAREPROGRAMSRESIDENTNVPROC __glewAreProgramsResidentNV = NULL; -PFNGLBINDPROGRAMNVPROC __glewBindProgramNV = NULL; -PFNGLDELETEPROGRAMSNVPROC __glewDeleteProgramsNV = NULL; -PFNGLEXECUTEPROGRAMNVPROC __glewExecuteProgramNV = NULL; -PFNGLGENPROGRAMSNVPROC __glewGenProgramsNV = NULL; -PFNGLGETPROGRAMPARAMETERDVNVPROC __glewGetProgramParameterdvNV = NULL; -PFNGLGETPROGRAMPARAMETERFVNVPROC __glewGetProgramParameterfvNV = NULL; -PFNGLGETPROGRAMSTRINGNVPROC __glewGetProgramStringNV = NULL; -PFNGLGETPROGRAMIVNVPROC __glewGetProgramivNV = NULL; -PFNGLGETTRACKMATRIXIVNVPROC __glewGetTrackMatrixivNV = NULL; -PFNGLGETVERTEXATTRIBPOINTERVNVPROC __glewGetVertexAttribPointervNV = NULL; -PFNGLGETVERTEXATTRIBDVNVPROC __glewGetVertexAttribdvNV = NULL; -PFNGLGETVERTEXATTRIBFVNVPROC __glewGetVertexAttribfvNV = NULL; -PFNGLGETVERTEXATTRIBIVNVPROC __glewGetVertexAttribivNV = NULL; -PFNGLISPROGRAMNVPROC __glewIsProgramNV = NULL; -PFNGLLOADPROGRAMNVPROC __glewLoadProgramNV = NULL; -PFNGLPROGRAMPARAMETER4DNVPROC __glewProgramParameter4dNV = NULL; -PFNGLPROGRAMPARAMETER4DVNVPROC __glewProgramParameter4dvNV = NULL; -PFNGLPROGRAMPARAMETER4FNVPROC __glewProgramParameter4fNV = NULL; -PFNGLPROGRAMPARAMETER4FVNVPROC __glewProgramParameter4fvNV = NULL; -PFNGLPROGRAMPARAMETERS4DVNVPROC __glewProgramParameters4dvNV = NULL; -PFNGLPROGRAMPARAMETERS4FVNVPROC __glewProgramParameters4fvNV = NULL; -PFNGLREQUESTRESIDENTPROGRAMSNVPROC __glewRequestResidentProgramsNV = NULL; -PFNGLTRACKMATRIXNVPROC __glewTrackMatrixNV = NULL; -PFNGLVERTEXATTRIB1DNVPROC __glewVertexAttrib1dNV = NULL; -PFNGLVERTEXATTRIB1DVNVPROC __glewVertexAttrib1dvNV = NULL; -PFNGLVERTEXATTRIB1FNVPROC __glewVertexAttrib1fNV = NULL; -PFNGLVERTEXATTRIB1FVNVPROC __glewVertexAttrib1fvNV = NULL; -PFNGLVERTEXATTRIB1SNVPROC __glewVertexAttrib1sNV = NULL; -PFNGLVERTEXATTRIB1SVNVPROC __glewVertexAttrib1svNV = NULL; -PFNGLVERTEXATTRIB2DNVPROC __glewVertexAttrib2dNV = NULL; -PFNGLVERTEXATTRIB2DVNVPROC __glewVertexAttrib2dvNV = NULL; -PFNGLVERTEXATTRIB2FNVPROC __glewVertexAttrib2fNV = NULL; -PFNGLVERTEXATTRIB2FVNVPROC __glewVertexAttrib2fvNV = NULL; -PFNGLVERTEXATTRIB2SNVPROC __glewVertexAttrib2sNV = NULL; -PFNGLVERTEXATTRIB2SVNVPROC __glewVertexAttrib2svNV = NULL; -PFNGLVERTEXATTRIB3DNVPROC __glewVertexAttrib3dNV = NULL; -PFNGLVERTEXATTRIB3DVNVPROC __glewVertexAttrib3dvNV = NULL; -PFNGLVERTEXATTRIB3FNVPROC __glewVertexAttrib3fNV = NULL; -PFNGLVERTEXATTRIB3FVNVPROC __glewVertexAttrib3fvNV = NULL; -PFNGLVERTEXATTRIB3SNVPROC __glewVertexAttrib3sNV = NULL; -PFNGLVERTEXATTRIB3SVNVPROC __glewVertexAttrib3svNV = NULL; -PFNGLVERTEXATTRIB4DNVPROC __glewVertexAttrib4dNV = NULL; -PFNGLVERTEXATTRIB4DVNVPROC __glewVertexAttrib4dvNV = NULL; -PFNGLVERTEXATTRIB4FNVPROC __glewVertexAttrib4fNV = NULL; -PFNGLVERTEXATTRIB4FVNVPROC __glewVertexAttrib4fvNV = NULL; -PFNGLVERTEXATTRIB4SNVPROC __glewVertexAttrib4sNV = NULL; -PFNGLVERTEXATTRIB4SVNVPROC __glewVertexAttrib4svNV = NULL; -PFNGLVERTEXATTRIB4UBNVPROC __glewVertexAttrib4ubNV = NULL; -PFNGLVERTEXATTRIB4UBVNVPROC __glewVertexAttrib4ubvNV = NULL; -PFNGLVERTEXATTRIBPOINTERNVPROC __glewVertexAttribPointerNV = NULL; -PFNGLVERTEXATTRIBS1DVNVPROC __glewVertexAttribs1dvNV = NULL; -PFNGLVERTEXATTRIBS1FVNVPROC __glewVertexAttribs1fvNV = NULL; -PFNGLVERTEXATTRIBS1SVNVPROC __glewVertexAttribs1svNV = NULL; -PFNGLVERTEXATTRIBS2DVNVPROC __glewVertexAttribs2dvNV = NULL; -PFNGLVERTEXATTRIBS2FVNVPROC __glewVertexAttribs2fvNV = NULL; -PFNGLVERTEXATTRIBS2SVNVPROC __glewVertexAttribs2svNV = NULL; -PFNGLVERTEXATTRIBS3DVNVPROC __glewVertexAttribs3dvNV = NULL; -PFNGLVERTEXATTRIBS3FVNVPROC __glewVertexAttribs3fvNV = NULL; -PFNGLVERTEXATTRIBS3SVNVPROC __glewVertexAttribs3svNV = NULL; -PFNGLVERTEXATTRIBS4DVNVPROC __glewVertexAttribs4dvNV = NULL; -PFNGLVERTEXATTRIBS4FVNVPROC __glewVertexAttribs4fvNV = NULL; -PFNGLVERTEXATTRIBS4SVNVPROC __glewVertexAttribs4svNV = NULL; -PFNGLVERTEXATTRIBS4UBVNVPROC __glewVertexAttribs4ubvNV = NULL; - -PFNGLCLEARDEPTHFOESPROC __glewClearDepthfOES = NULL; -PFNGLCLIPPLANEFOESPROC __glewClipPlanefOES = NULL; -PFNGLDEPTHRANGEFOESPROC __glewDepthRangefOES = NULL; -PFNGLFRUSTUMFOESPROC __glewFrustumfOES = NULL; -PFNGLGETCLIPPLANEFOESPROC __glewGetClipPlanefOES = NULL; -PFNGLORTHOFOESPROC __glewOrthofOES = NULL; - -PFNGLDETAILTEXFUNCSGISPROC __glewDetailTexFuncSGIS = NULL; -PFNGLGETDETAILTEXFUNCSGISPROC __glewGetDetailTexFuncSGIS = NULL; - -PFNGLFOGFUNCSGISPROC __glewFogFuncSGIS = NULL; -PFNGLGETFOGFUNCSGISPROC __glewGetFogFuncSGIS = NULL; - -PFNGLSAMPLEMASKSGISPROC __glewSampleMaskSGIS = NULL; -PFNGLSAMPLEPATTERNSGISPROC __glewSamplePatternSGIS = NULL; - -PFNGLGETSHARPENTEXFUNCSGISPROC __glewGetSharpenTexFuncSGIS = NULL; -PFNGLSHARPENTEXFUNCSGISPROC __glewSharpenTexFuncSGIS = NULL; - -PFNGLTEXIMAGE4DSGISPROC __glewTexImage4DSGIS = NULL; -PFNGLTEXSUBIMAGE4DSGISPROC __glewTexSubImage4DSGIS = NULL; - -PFNGLGETTEXFILTERFUNCSGISPROC __glewGetTexFilterFuncSGIS = NULL; -PFNGLTEXFILTERFUNCSGISPROC __glewTexFilterFuncSGIS = NULL; - -PFNGLASYNCMARKERSGIXPROC __glewAsyncMarkerSGIX = NULL; -PFNGLDELETEASYNCMARKERSSGIXPROC __glewDeleteAsyncMarkersSGIX = NULL; -PFNGLFINISHASYNCSGIXPROC __glewFinishAsyncSGIX = NULL; -PFNGLGENASYNCMARKERSSGIXPROC __glewGenAsyncMarkersSGIX = NULL; -PFNGLISASYNCMARKERSGIXPROC __glewIsAsyncMarkerSGIX = NULL; -PFNGLPOLLASYNCSGIXPROC __glewPollAsyncSGIX = NULL; - -PFNGLFLUSHRASTERSGIXPROC __glewFlushRasterSGIX = NULL; - -PFNGLTEXTUREFOGSGIXPROC __glewTextureFogSGIX = NULL; - -PFNGLFRAGMENTCOLORMATERIALSGIXPROC __glewFragmentColorMaterialSGIX = NULL; -PFNGLFRAGMENTLIGHTMODELFSGIXPROC __glewFragmentLightModelfSGIX = NULL; -PFNGLFRAGMENTLIGHTMODELFVSGIXPROC __glewFragmentLightModelfvSGIX = NULL; -PFNGLFRAGMENTLIGHTMODELISGIXPROC __glewFragmentLightModeliSGIX = NULL; -PFNGLFRAGMENTLIGHTMODELIVSGIXPROC __glewFragmentLightModelivSGIX = NULL; -PFNGLFRAGMENTLIGHTFSGIXPROC __glewFragmentLightfSGIX = NULL; -PFNGLFRAGMENTLIGHTFVSGIXPROC __glewFragmentLightfvSGIX = NULL; -PFNGLFRAGMENTLIGHTISGIXPROC __glewFragmentLightiSGIX = NULL; -PFNGLFRAGMENTLIGHTIVSGIXPROC __glewFragmentLightivSGIX = NULL; -PFNGLFRAGMENTMATERIALFSGIXPROC __glewFragmentMaterialfSGIX = NULL; -PFNGLFRAGMENTMATERIALFVSGIXPROC __glewFragmentMaterialfvSGIX = NULL; -PFNGLFRAGMENTMATERIALISGIXPROC __glewFragmentMaterialiSGIX = NULL; -PFNGLFRAGMENTMATERIALIVSGIXPROC __glewFragmentMaterialivSGIX = NULL; -PFNGLGETFRAGMENTLIGHTFVSGIXPROC __glewGetFragmentLightfvSGIX = NULL; -PFNGLGETFRAGMENTLIGHTIVSGIXPROC __glewGetFragmentLightivSGIX = NULL; -PFNGLGETFRAGMENTMATERIALFVSGIXPROC __glewGetFragmentMaterialfvSGIX = NULL; -PFNGLGETFRAGMENTMATERIALIVSGIXPROC __glewGetFragmentMaterialivSGIX = NULL; - -PFNGLFRAMEZOOMSGIXPROC __glewFrameZoomSGIX = NULL; - -PFNGLPIXELTEXGENSGIXPROC __glewPixelTexGenSGIX = NULL; - -PFNGLREFERENCEPLANESGIXPROC __glewReferencePlaneSGIX = NULL; - -PFNGLSPRITEPARAMETERFSGIXPROC __glewSpriteParameterfSGIX = NULL; -PFNGLSPRITEPARAMETERFVSGIXPROC __glewSpriteParameterfvSGIX = NULL; -PFNGLSPRITEPARAMETERISGIXPROC __glewSpriteParameteriSGIX = NULL; -PFNGLSPRITEPARAMETERIVSGIXPROC __glewSpriteParameterivSGIX = NULL; - -PFNGLTAGSAMPLEBUFFERSGIXPROC __glewTagSampleBufferSGIX = NULL; - -PFNGLCOLORTABLEPARAMETERFVSGIPROC __glewColorTableParameterfvSGI = NULL; -PFNGLCOLORTABLEPARAMETERIVSGIPROC __glewColorTableParameterivSGI = NULL; -PFNGLCOLORTABLESGIPROC __glewColorTableSGI = NULL; -PFNGLCOPYCOLORTABLESGIPROC __glewCopyColorTableSGI = NULL; -PFNGLGETCOLORTABLEPARAMETERFVSGIPROC __glewGetColorTableParameterfvSGI = NULL; -PFNGLGETCOLORTABLEPARAMETERIVSGIPROC __glewGetColorTableParameterivSGI = NULL; -PFNGLGETCOLORTABLESGIPROC __glewGetColorTableSGI = NULL; - -PFNGLFINISHTEXTURESUNXPROC __glewFinishTextureSUNX = NULL; - -PFNGLGLOBALALPHAFACTORBSUNPROC __glewGlobalAlphaFactorbSUN = NULL; -PFNGLGLOBALALPHAFACTORDSUNPROC __glewGlobalAlphaFactordSUN = NULL; -PFNGLGLOBALALPHAFACTORFSUNPROC __glewGlobalAlphaFactorfSUN = NULL; -PFNGLGLOBALALPHAFACTORISUNPROC __glewGlobalAlphaFactoriSUN = NULL; -PFNGLGLOBALALPHAFACTORSSUNPROC __glewGlobalAlphaFactorsSUN = NULL; -PFNGLGLOBALALPHAFACTORUBSUNPROC __glewGlobalAlphaFactorubSUN = NULL; -PFNGLGLOBALALPHAFACTORUISUNPROC __glewGlobalAlphaFactoruiSUN = NULL; -PFNGLGLOBALALPHAFACTORUSSUNPROC __glewGlobalAlphaFactorusSUN = NULL; - -PFNGLREADVIDEOPIXELSSUNPROC __glewReadVideoPixelsSUN = NULL; - -PFNGLREPLACEMENTCODEPOINTERSUNPROC __glewReplacementCodePointerSUN = NULL; -PFNGLREPLACEMENTCODEUBSUNPROC __glewReplacementCodeubSUN = NULL; -PFNGLREPLACEMENTCODEUBVSUNPROC __glewReplacementCodeubvSUN = NULL; -PFNGLREPLACEMENTCODEUISUNPROC __glewReplacementCodeuiSUN = NULL; -PFNGLREPLACEMENTCODEUIVSUNPROC __glewReplacementCodeuivSUN = NULL; -PFNGLREPLACEMENTCODEUSSUNPROC __glewReplacementCodeusSUN = NULL; -PFNGLREPLACEMENTCODEUSVSUNPROC __glewReplacementCodeusvSUN = NULL; - -PFNGLCOLOR3FVERTEX3FSUNPROC __glewColor3fVertex3fSUN = NULL; -PFNGLCOLOR3FVERTEX3FVSUNPROC __glewColor3fVertex3fvSUN = NULL; -PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewColor4fNormal3fVertex3fSUN = NULL; -PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewColor4fNormal3fVertex3fvSUN = NULL; -PFNGLCOLOR4UBVERTEX2FSUNPROC __glewColor4ubVertex2fSUN = NULL; -PFNGLCOLOR4UBVERTEX2FVSUNPROC __glewColor4ubVertex2fvSUN = NULL; -PFNGLCOLOR4UBVERTEX3FSUNPROC __glewColor4ubVertex3fSUN = NULL; -PFNGLCOLOR4UBVERTEX3FVSUNPROC __glewColor4ubVertex3fvSUN = NULL; -PFNGLNORMAL3FVERTEX3FSUNPROC __glewNormal3fVertex3fSUN = NULL; -PFNGLNORMAL3FVERTEX3FVSUNPROC __glewNormal3fVertex3fvSUN = NULL; -PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC __glewReplacementCodeuiColor3fVertex3fSUN = NULL; -PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor3fVertex3fvSUN = NULL; -PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fSUN = NULL; -PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiColor4fNormal3fVertex3fvSUN = NULL; -PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC __glewReplacementCodeuiColor4ubVertex3fSUN = NULL; -PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC __glewReplacementCodeuiColor4ubVertex3fvSUN = NULL; -PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiNormal3fVertex3fSUN = NULL; -PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiNormal3fVertex3fvSUN = NULL; -PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN = NULL; -PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN = NULL; -PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fSUN = NULL; -PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN = NULL; -PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fSUN = NULL; -PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC __glewReplacementCodeuiTexCoord2fVertex3fvSUN = NULL; -PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC __glewReplacementCodeuiVertex3fSUN = NULL; -PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC __glewReplacementCodeuiVertex3fvSUN = NULL; -PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC __glewTexCoord2fColor3fVertex3fSUN = NULL; -PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC __glewTexCoord2fColor3fVertex3fvSUN = NULL; -PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fSUN = NULL; -PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fColor4fNormal3fVertex3fvSUN = NULL; -PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC __glewTexCoord2fColor4ubVertex3fSUN = NULL; -PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC __glewTexCoord2fColor4ubVertex3fvSUN = NULL; -PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC __glewTexCoord2fNormal3fVertex3fSUN = NULL; -PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC __glewTexCoord2fNormal3fVertex3fvSUN = NULL; -PFNGLTEXCOORD2FVERTEX3FSUNPROC __glewTexCoord2fVertex3fSUN = NULL; -PFNGLTEXCOORD2FVERTEX3FVSUNPROC __glewTexCoord2fVertex3fvSUN = NULL; -PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fSUN = NULL; -PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC __glewTexCoord4fColor4fNormal3fVertex4fvSUN = NULL; -PFNGLTEXCOORD4FVERTEX4FSUNPROC __glewTexCoord4fVertex4fSUN = NULL; -PFNGLTEXCOORD4FVERTEX4FVSUNPROC __glewTexCoord4fVertex4fvSUN = NULL; - -PFNGLADDSWAPHINTRECTWINPROC __glewAddSwapHintRectWIN = NULL; - -#endif /* !WIN32 || !GLEW_MX */ - -#if !defined(GLEW_MX) - -GLboolean __GLEW_VERSION_1_1 = GL_FALSE; -GLboolean __GLEW_VERSION_1_2 = GL_FALSE; -GLboolean __GLEW_VERSION_1_3 = GL_FALSE; -GLboolean __GLEW_VERSION_1_4 = GL_FALSE; -GLboolean __GLEW_VERSION_1_5 = GL_FALSE; -GLboolean __GLEW_VERSION_2_0 = GL_FALSE; -GLboolean __GLEW_VERSION_2_1 = GL_FALSE; -GLboolean __GLEW_VERSION_3_0 = GL_FALSE; -GLboolean __GLEW_3DFX_multisample = GL_FALSE; -GLboolean __GLEW_3DFX_tbuffer = GL_FALSE; -GLboolean __GLEW_3DFX_texture_compression_FXT1 = GL_FALSE; -GLboolean __GLEW_APPLE_client_storage = GL_FALSE; -GLboolean __GLEW_APPLE_element_array = GL_FALSE; -GLboolean __GLEW_APPLE_fence = GL_FALSE; -GLboolean __GLEW_APPLE_float_pixels = GL_FALSE; -GLboolean __GLEW_APPLE_flush_buffer_range = GL_FALSE; -GLboolean __GLEW_APPLE_pixel_buffer = GL_FALSE; -GLboolean __GLEW_APPLE_specular_vector = GL_FALSE; -GLboolean __GLEW_APPLE_texture_range = GL_FALSE; -GLboolean __GLEW_APPLE_transform_hint = GL_FALSE; -GLboolean __GLEW_APPLE_vertex_array_object = GL_FALSE; -GLboolean __GLEW_APPLE_vertex_array_range = GL_FALSE; -GLboolean __GLEW_APPLE_ycbcr_422 = GL_FALSE; -GLboolean __GLEW_ARB_color_buffer_float = GL_FALSE; -GLboolean __GLEW_ARB_depth_buffer_float = GL_FALSE; -GLboolean __GLEW_ARB_depth_texture = GL_FALSE; -GLboolean __GLEW_ARB_draw_buffers = GL_FALSE; -GLboolean __GLEW_ARB_draw_instanced = GL_FALSE; -GLboolean __GLEW_ARB_fragment_program = GL_FALSE; -GLboolean __GLEW_ARB_fragment_program_shadow = GL_FALSE; -GLboolean __GLEW_ARB_fragment_shader = GL_FALSE; -GLboolean __GLEW_ARB_framebuffer_object = GL_FALSE; -GLboolean __GLEW_ARB_framebuffer_sRGB = GL_FALSE; -GLboolean __GLEW_ARB_geometry_shader4 = GL_FALSE; -GLboolean __GLEW_ARB_half_float_pixel = GL_FALSE; -GLboolean __GLEW_ARB_half_float_vertex = GL_FALSE; -GLboolean __GLEW_ARB_imaging = GL_FALSE; -GLboolean __GLEW_ARB_instanced_arrays = GL_FALSE; -GLboolean __GLEW_ARB_map_buffer_range = GL_FALSE; -GLboolean __GLEW_ARB_matrix_palette = GL_FALSE; -GLboolean __GLEW_ARB_multisample = GL_FALSE; -GLboolean __GLEW_ARB_multitexture = GL_FALSE; -GLboolean __GLEW_ARB_occlusion_query = GL_FALSE; -GLboolean __GLEW_ARB_pixel_buffer_object = GL_FALSE; -GLboolean __GLEW_ARB_point_parameters = GL_FALSE; -GLboolean __GLEW_ARB_point_sprite = GL_FALSE; -GLboolean __GLEW_ARB_shader_objects = GL_FALSE; -GLboolean __GLEW_ARB_shading_language_100 = GL_FALSE; -GLboolean __GLEW_ARB_shadow = GL_FALSE; -GLboolean __GLEW_ARB_shadow_ambient = GL_FALSE; -GLboolean __GLEW_ARB_texture_border_clamp = GL_FALSE; -GLboolean __GLEW_ARB_texture_buffer_object = GL_FALSE; -GLboolean __GLEW_ARB_texture_compression = GL_FALSE; -GLboolean __GLEW_ARB_texture_compression_rgtc = GL_FALSE; -GLboolean __GLEW_ARB_texture_cube_map = GL_FALSE; -GLboolean __GLEW_ARB_texture_env_add = GL_FALSE; -GLboolean __GLEW_ARB_texture_env_combine = GL_FALSE; -GLboolean __GLEW_ARB_texture_env_crossbar = GL_FALSE; -GLboolean __GLEW_ARB_texture_env_dot3 = GL_FALSE; -GLboolean __GLEW_ARB_texture_float = GL_FALSE; -GLboolean __GLEW_ARB_texture_mirrored_repeat = GL_FALSE; -GLboolean __GLEW_ARB_texture_non_power_of_two = GL_FALSE; -GLboolean __GLEW_ARB_texture_rectangle = GL_FALSE; -GLboolean __GLEW_ARB_texture_rg = GL_FALSE; -GLboolean __GLEW_ARB_transpose_matrix = GL_FALSE; -GLboolean __GLEW_ARB_vertex_array_object = GL_FALSE; -GLboolean __GLEW_ARB_vertex_blend = GL_FALSE; -GLboolean __GLEW_ARB_vertex_buffer_object = GL_FALSE; -GLboolean __GLEW_ARB_vertex_program = GL_FALSE; -GLboolean __GLEW_ARB_vertex_shader = GL_FALSE; -GLboolean __GLEW_ARB_window_pos = GL_FALSE; -GLboolean __GLEW_ATIX_point_sprites = GL_FALSE; -GLboolean __GLEW_ATIX_texture_env_combine3 = GL_FALSE; -GLboolean __GLEW_ATIX_texture_env_route = GL_FALSE; -GLboolean __GLEW_ATIX_vertex_shader_output_point_size = GL_FALSE; -GLboolean __GLEW_ATI_draw_buffers = GL_FALSE; -GLboolean __GLEW_ATI_element_array = GL_FALSE; -GLboolean __GLEW_ATI_envmap_bumpmap = GL_FALSE; -GLboolean __GLEW_ATI_fragment_shader = GL_FALSE; -GLboolean __GLEW_ATI_map_object_buffer = GL_FALSE; -GLboolean __GLEW_ATI_pn_triangles = GL_FALSE; -GLboolean __GLEW_ATI_separate_stencil = GL_FALSE; -GLboolean __GLEW_ATI_shader_texture_lod = GL_FALSE; -GLboolean __GLEW_ATI_text_fragment_shader = GL_FALSE; -GLboolean __GLEW_ATI_texture_compression_3dc = GL_FALSE; -GLboolean __GLEW_ATI_texture_env_combine3 = GL_FALSE; -GLboolean __GLEW_ATI_texture_float = GL_FALSE; -GLboolean __GLEW_ATI_texture_mirror_once = GL_FALSE; -GLboolean __GLEW_ATI_vertex_array_object = GL_FALSE; -GLboolean __GLEW_ATI_vertex_attrib_array_object = GL_FALSE; -GLboolean __GLEW_ATI_vertex_streams = GL_FALSE; -GLboolean __GLEW_EXT_422_pixels = GL_FALSE; -GLboolean __GLEW_EXT_Cg_shader = GL_FALSE; -GLboolean __GLEW_EXT_abgr = GL_FALSE; -GLboolean __GLEW_EXT_bgra = GL_FALSE; -GLboolean __GLEW_EXT_bindable_uniform = GL_FALSE; -GLboolean __GLEW_EXT_blend_color = GL_FALSE; -GLboolean __GLEW_EXT_blend_equation_separate = GL_FALSE; -GLboolean __GLEW_EXT_blend_func_separate = GL_FALSE; -GLboolean __GLEW_EXT_blend_logic_op = GL_FALSE; -GLboolean __GLEW_EXT_blend_minmax = GL_FALSE; -GLboolean __GLEW_EXT_blend_subtract = GL_FALSE; -GLboolean __GLEW_EXT_clip_volume_hint = GL_FALSE; -GLboolean __GLEW_EXT_cmyka = GL_FALSE; -GLboolean __GLEW_EXT_color_subtable = GL_FALSE; -GLboolean __GLEW_EXT_compiled_vertex_array = GL_FALSE; -GLboolean __GLEW_EXT_convolution = GL_FALSE; -GLboolean __GLEW_EXT_coordinate_frame = GL_FALSE; -GLboolean __GLEW_EXT_copy_texture = GL_FALSE; -GLboolean __GLEW_EXT_cull_vertex = GL_FALSE; -GLboolean __GLEW_EXT_depth_bounds_test = GL_FALSE; -GLboolean __GLEW_EXT_direct_state_access = GL_FALSE; -GLboolean __GLEW_EXT_draw_buffers2 = GL_FALSE; -GLboolean __GLEW_EXT_draw_instanced = GL_FALSE; -GLboolean __GLEW_EXT_draw_range_elements = GL_FALSE; -GLboolean __GLEW_EXT_fog_coord = GL_FALSE; -GLboolean __GLEW_EXT_fragment_lighting = GL_FALSE; -GLboolean __GLEW_EXT_framebuffer_blit = GL_FALSE; -GLboolean __GLEW_EXT_framebuffer_multisample = GL_FALSE; -GLboolean __GLEW_EXT_framebuffer_object = GL_FALSE; -GLboolean __GLEW_EXT_framebuffer_sRGB = GL_FALSE; -GLboolean __GLEW_EXT_geometry_shader4 = GL_FALSE; -GLboolean __GLEW_EXT_gpu_program_parameters = GL_FALSE; -GLboolean __GLEW_EXT_gpu_shader4 = GL_FALSE; -GLboolean __GLEW_EXT_histogram = GL_FALSE; -GLboolean __GLEW_EXT_index_array_formats = GL_FALSE; -GLboolean __GLEW_EXT_index_func = GL_FALSE; -GLboolean __GLEW_EXT_index_material = GL_FALSE; -GLboolean __GLEW_EXT_index_texture = GL_FALSE; -GLboolean __GLEW_EXT_light_texture = GL_FALSE; -GLboolean __GLEW_EXT_misc_attribute = GL_FALSE; -GLboolean __GLEW_EXT_multi_draw_arrays = GL_FALSE; -GLboolean __GLEW_EXT_multisample = GL_FALSE; -GLboolean __GLEW_EXT_packed_depth_stencil = GL_FALSE; -GLboolean __GLEW_EXT_packed_float = GL_FALSE; -GLboolean __GLEW_EXT_packed_pixels = GL_FALSE; -GLboolean __GLEW_EXT_paletted_texture = GL_FALSE; -GLboolean __GLEW_EXT_pixel_buffer_object = GL_FALSE; -GLboolean __GLEW_EXT_pixel_transform = GL_FALSE; -GLboolean __GLEW_EXT_pixel_transform_color_table = GL_FALSE; -GLboolean __GLEW_EXT_point_parameters = GL_FALSE; -GLboolean __GLEW_EXT_polygon_offset = GL_FALSE; -GLboolean __GLEW_EXT_rescale_normal = GL_FALSE; -GLboolean __GLEW_EXT_scene_marker = GL_FALSE; -GLboolean __GLEW_EXT_secondary_color = GL_FALSE; -GLboolean __GLEW_EXT_separate_specular_color = GL_FALSE; -GLboolean __GLEW_EXT_shadow_funcs = GL_FALSE; -GLboolean __GLEW_EXT_shared_texture_palette = GL_FALSE; -GLboolean __GLEW_EXT_stencil_clear_tag = GL_FALSE; -GLboolean __GLEW_EXT_stencil_two_side = GL_FALSE; -GLboolean __GLEW_EXT_stencil_wrap = GL_FALSE; -GLboolean __GLEW_EXT_subtexture = GL_FALSE; -GLboolean __GLEW_EXT_texture = GL_FALSE; -GLboolean __GLEW_EXT_texture3D = GL_FALSE; -GLboolean __GLEW_EXT_texture_array = GL_FALSE; -GLboolean __GLEW_EXT_texture_buffer_object = GL_FALSE; -GLboolean __GLEW_EXT_texture_compression_dxt1 = GL_FALSE; -GLboolean __GLEW_EXT_texture_compression_latc = GL_FALSE; -GLboolean __GLEW_EXT_texture_compression_rgtc = GL_FALSE; -GLboolean __GLEW_EXT_texture_compression_s3tc = GL_FALSE; -GLboolean __GLEW_EXT_texture_cube_map = GL_FALSE; -GLboolean __GLEW_EXT_texture_edge_clamp = GL_FALSE; -GLboolean __GLEW_EXT_texture_env = GL_FALSE; -GLboolean __GLEW_EXT_texture_env_add = GL_FALSE; -GLboolean __GLEW_EXT_texture_env_combine = GL_FALSE; -GLboolean __GLEW_EXT_texture_env_dot3 = GL_FALSE; -GLboolean __GLEW_EXT_texture_filter_anisotropic = GL_FALSE; -GLboolean __GLEW_EXT_texture_integer = GL_FALSE; -GLboolean __GLEW_EXT_texture_lod_bias = GL_FALSE; -GLboolean __GLEW_EXT_texture_mirror_clamp = GL_FALSE; -GLboolean __GLEW_EXT_texture_object = GL_FALSE; -GLboolean __GLEW_EXT_texture_perturb_normal = GL_FALSE; -GLboolean __GLEW_EXT_texture_rectangle = GL_FALSE; -GLboolean __GLEW_EXT_texture_sRGB = GL_FALSE; -GLboolean __GLEW_EXT_texture_shared_exponent = GL_FALSE; -GLboolean __GLEW_EXT_texture_swizzle = GL_FALSE; -GLboolean __GLEW_EXT_timer_query = GL_FALSE; -GLboolean __GLEW_EXT_transform_feedback = GL_FALSE; -GLboolean __GLEW_EXT_vertex_array = GL_FALSE; -GLboolean __GLEW_EXT_vertex_array_bgra = GL_FALSE; -GLboolean __GLEW_EXT_vertex_shader = GL_FALSE; -GLboolean __GLEW_EXT_vertex_weighting = GL_FALSE; -GLboolean __GLEW_GREMEDY_frame_terminator = GL_FALSE; -GLboolean __GLEW_GREMEDY_string_marker = GL_FALSE; -GLboolean __GLEW_HP_convolution_border_modes = GL_FALSE; -GLboolean __GLEW_HP_image_transform = GL_FALSE; -GLboolean __GLEW_HP_occlusion_test = GL_FALSE; -GLboolean __GLEW_HP_texture_lighting = GL_FALSE; -GLboolean __GLEW_IBM_cull_vertex = GL_FALSE; -GLboolean __GLEW_IBM_multimode_draw_arrays = GL_FALSE; -GLboolean __GLEW_IBM_rasterpos_clip = GL_FALSE; -GLboolean __GLEW_IBM_static_data = GL_FALSE; -GLboolean __GLEW_IBM_texture_mirrored_repeat = GL_FALSE; -GLboolean __GLEW_IBM_vertex_array_lists = GL_FALSE; -GLboolean __GLEW_INGR_color_clamp = GL_FALSE; -GLboolean __GLEW_INGR_interlace_read = GL_FALSE; -GLboolean __GLEW_INTEL_parallel_arrays = GL_FALSE; -GLboolean __GLEW_INTEL_texture_scissor = GL_FALSE; -GLboolean __GLEW_KTX_buffer_region = GL_FALSE; -GLboolean __GLEW_MESAX_texture_stack = GL_FALSE; -GLboolean __GLEW_MESA_pack_invert = GL_FALSE; -GLboolean __GLEW_MESA_resize_buffers = GL_FALSE; -GLboolean __GLEW_MESA_window_pos = GL_FALSE; -GLboolean __GLEW_MESA_ycbcr_texture = GL_FALSE; -GLboolean __GLEW_NV_blend_square = GL_FALSE; -GLboolean __GLEW_NV_conditional_render = GL_FALSE; -GLboolean __GLEW_NV_copy_depth_to_color = GL_FALSE; -GLboolean __GLEW_NV_depth_buffer_float = GL_FALSE; -GLboolean __GLEW_NV_depth_clamp = GL_FALSE; -GLboolean __GLEW_NV_depth_range_unclamped = GL_FALSE; -GLboolean __GLEW_NV_evaluators = GL_FALSE; -GLboolean __GLEW_NV_explicit_multisample = GL_FALSE; -GLboolean __GLEW_NV_fence = GL_FALSE; -GLboolean __GLEW_NV_float_buffer = GL_FALSE; -GLboolean __GLEW_NV_fog_distance = GL_FALSE; -GLboolean __GLEW_NV_fragment_program = GL_FALSE; -GLboolean __GLEW_NV_fragment_program2 = GL_FALSE; -GLboolean __GLEW_NV_fragment_program4 = GL_FALSE; -GLboolean __GLEW_NV_fragment_program_option = GL_FALSE; -GLboolean __GLEW_NV_framebuffer_multisample_coverage = GL_FALSE; -GLboolean __GLEW_NV_geometry_program4 = GL_FALSE; -GLboolean __GLEW_NV_geometry_shader4 = GL_FALSE; -GLboolean __GLEW_NV_gpu_program4 = GL_FALSE; -GLboolean __GLEW_NV_half_float = GL_FALSE; -GLboolean __GLEW_NV_light_max_exponent = GL_FALSE; -GLboolean __GLEW_NV_multisample_filter_hint = GL_FALSE; -GLboolean __GLEW_NV_occlusion_query = GL_FALSE; -GLboolean __GLEW_NV_packed_depth_stencil = GL_FALSE; -GLboolean __GLEW_NV_parameter_buffer_object = GL_FALSE; -GLboolean __GLEW_NV_pixel_data_range = GL_FALSE; -GLboolean __GLEW_NV_point_sprite = GL_FALSE; -GLboolean __GLEW_NV_present_video = GL_FALSE; -GLboolean __GLEW_NV_primitive_restart = GL_FALSE; -GLboolean __GLEW_NV_register_combiners = GL_FALSE; -GLboolean __GLEW_NV_register_combiners2 = GL_FALSE; -GLboolean __GLEW_NV_texgen_emboss = GL_FALSE; -GLboolean __GLEW_NV_texgen_reflection = GL_FALSE; -GLboolean __GLEW_NV_texture_compression_vtc = GL_FALSE; -GLboolean __GLEW_NV_texture_env_combine4 = GL_FALSE; -GLboolean __GLEW_NV_texture_expand_normal = GL_FALSE; -GLboolean __GLEW_NV_texture_rectangle = GL_FALSE; -GLboolean __GLEW_NV_texture_shader = GL_FALSE; -GLboolean __GLEW_NV_texture_shader2 = GL_FALSE; -GLboolean __GLEW_NV_texture_shader3 = GL_FALSE; -GLboolean __GLEW_NV_transform_feedback = GL_FALSE; -GLboolean __GLEW_NV_vertex_array_range = GL_FALSE; -GLboolean __GLEW_NV_vertex_array_range2 = GL_FALSE; -GLboolean __GLEW_NV_vertex_program = GL_FALSE; -GLboolean __GLEW_NV_vertex_program1_1 = GL_FALSE; -GLboolean __GLEW_NV_vertex_program2 = GL_FALSE; -GLboolean __GLEW_NV_vertex_program2_option = GL_FALSE; -GLboolean __GLEW_NV_vertex_program3 = GL_FALSE; -GLboolean __GLEW_NV_vertex_program4 = GL_FALSE; -GLboolean __GLEW_OES_byte_coordinates = GL_FALSE; -GLboolean __GLEW_OES_compressed_paletted_texture = GL_FALSE; -GLboolean __GLEW_OES_read_format = GL_FALSE; -GLboolean __GLEW_OES_single_precision = GL_FALSE; -GLboolean __GLEW_OML_interlace = GL_FALSE; -GLboolean __GLEW_OML_resample = GL_FALSE; -GLboolean __GLEW_OML_subsample = GL_FALSE; -GLboolean __GLEW_PGI_misc_hints = GL_FALSE; -GLboolean __GLEW_PGI_vertex_hints = GL_FALSE; -GLboolean __GLEW_REND_screen_coordinates = GL_FALSE; -GLboolean __GLEW_S3_s3tc = GL_FALSE; -GLboolean __GLEW_SGIS_color_range = GL_FALSE; -GLboolean __GLEW_SGIS_detail_texture = GL_FALSE; -GLboolean __GLEW_SGIS_fog_function = GL_FALSE; -GLboolean __GLEW_SGIS_generate_mipmap = GL_FALSE; -GLboolean __GLEW_SGIS_multisample = GL_FALSE; -GLboolean __GLEW_SGIS_pixel_texture = GL_FALSE; -GLboolean __GLEW_SGIS_point_line_texgen = GL_FALSE; -GLboolean __GLEW_SGIS_sharpen_texture = GL_FALSE; -GLboolean __GLEW_SGIS_texture4D = GL_FALSE; -GLboolean __GLEW_SGIS_texture_border_clamp = GL_FALSE; -GLboolean __GLEW_SGIS_texture_edge_clamp = GL_FALSE; -GLboolean __GLEW_SGIS_texture_filter4 = GL_FALSE; -GLboolean __GLEW_SGIS_texture_lod = GL_FALSE; -GLboolean __GLEW_SGIS_texture_select = GL_FALSE; -GLboolean __GLEW_SGIX_async = GL_FALSE; -GLboolean __GLEW_SGIX_async_histogram = GL_FALSE; -GLboolean __GLEW_SGIX_async_pixel = GL_FALSE; -GLboolean __GLEW_SGIX_blend_alpha_minmax = GL_FALSE; -GLboolean __GLEW_SGIX_clipmap = GL_FALSE; -GLboolean __GLEW_SGIX_convolution_accuracy = GL_FALSE; -GLboolean __GLEW_SGIX_depth_texture = GL_FALSE; -GLboolean __GLEW_SGIX_flush_raster = GL_FALSE; -GLboolean __GLEW_SGIX_fog_offset = GL_FALSE; -GLboolean __GLEW_SGIX_fog_texture = GL_FALSE; -GLboolean __GLEW_SGIX_fragment_specular_lighting = GL_FALSE; -GLboolean __GLEW_SGIX_framezoom = GL_FALSE; -GLboolean __GLEW_SGIX_interlace = GL_FALSE; -GLboolean __GLEW_SGIX_ir_instrument1 = GL_FALSE; -GLboolean __GLEW_SGIX_list_priority = GL_FALSE; -GLboolean __GLEW_SGIX_pixel_texture = GL_FALSE; -GLboolean __GLEW_SGIX_pixel_texture_bits = GL_FALSE; -GLboolean __GLEW_SGIX_reference_plane = GL_FALSE; -GLboolean __GLEW_SGIX_resample = GL_FALSE; -GLboolean __GLEW_SGIX_shadow = GL_FALSE; -GLboolean __GLEW_SGIX_shadow_ambient = GL_FALSE; -GLboolean __GLEW_SGIX_sprite = GL_FALSE; -GLboolean __GLEW_SGIX_tag_sample_buffer = GL_FALSE; -GLboolean __GLEW_SGIX_texture_add_env = GL_FALSE; -GLboolean __GLEW_SGIX_texture_coordinate_clamp = GL_FALSE; -GLboolean __GLEW_SGIX_texture_lod_bias = GL_FALSE; -GLboolean __GLEW_SGIX_texture_multi_buffer = GL_FALSE; -GLboolean __GLEW_SGIX_texture_range = GL_FALSE; -GLboolean __GLEW_SGIX_texture_scale_bias = GL_FALSE; -GLboolean __GLEW_SGIX_vertex_preclip = GL_FALSE; -GLboolean __GLEW_SGIX_vertex_preclip_hint = GL_FALSE; -GLboolean __GLEW_SGIX_ycrcb = GL_FALSE; -GLboolean __GLEW_SGI_color_matrix = GL_FALSE; -GLboolean __GLEW_SGI_color_table = GL_FALSE; -GLboolean __GLEW_SGI_texture_color_table = GL_FALSE; -GLboolean __GLEW_SUNX_constant_data = GL_FALSE; -GLboolean __GLEW_SUN_convolution_border_modes = GL_FALSE; -GLboolean __GLEW_SUN_global_alpha = GL_FALSE; -GLboolean __GLEW_SUN_mesh_array = GL_FALSE; -GLboolean __GLEW_SUN_read_video_pixels = GL_FALSE; -GLboolean __GLEW_SUN_slice_accum = GL_FALSE; -GLboolean __GLEW_SUN_triangle_list = GL_FALSE; -GLboolean __GLEW_SUN_vertex = GL_FALSE; -GLboolean __GLEW_WIN_phong_shading = GL_FALSE; -GLboolean __GLEW_WIN_specular_fog = GL_FALSE; -GLboolean __GLEW_WIN_swap_hint = GL_FALSE; - -#endif /* !GLEW_MX */ - -#ifdef GL_VERSION_1_2 - -static GLboolean _glewInit_GL_VERSION_1_2 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glCopyTexSubImage3D")) == NULL) || r; - r = ((glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)glewGetProcAddress((const GLubyte*)"glDrawRangeElements")) == NULL) || r; - r = ((glTexImage3D = (PFNGLTEXIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glTexImage3D")) == NULL) || r; - r = ((glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glTexSubImage3D")) == NULL) || r; - - return r; -} - -#endif /* GL_VERSION_1_2 */ - -#ifdef GL_VERSION_1_3 - -static GLboolean _glewInit_GL_VERSION_1_3 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glActiveTexture = (PFNGLACTIVETEXTUREPROC)glewGetProcAddress((const GLubyte*)"glActiveTexture")) == NULL) || r; - r = ((glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC)glewGetProcAddress((const GLubyte*)"glClientActiveTexture")) == NULL) || r; - r = ((glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage1D")) == NULL) || r; - r = ((glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage2D")) == NULL) || r; - r = ((glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage3D")) == NULL) || r; - r = ((glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage1D")) == NULL) || r; - r = ((glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage2D")) == NULL) || r; - r = ((glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage3D")) == NULL) || r; - r = ((glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)glewGetProcAddress((const GLubyte*)"glGetCompressedTexImage")) == NULL) || r; - r = ((glLoadTransposeMatrixd = (PFNGLLOADTRANSPOSEMATRIXDPROC)glewGetProcAddress((const GLubyte*)"glLoadTransposeMatrixd")) == NULL) || r; - r = ((glLoadTransposeMatrixf = (PFNGLLOADTRANSPOSEMATRIXFPROC)glewGetProcAddress((const GLubyte*)"glLoadTransposeMatrixf")) == NULL) || r; - r = ((glMultTransposeMatrixd = (PFNGLMULTTRANSPOSEMATRIXDPROC)glewGetProcAddress((const GLubyte*)"glMultTransposeMatrixd")) == NULL) || r; - r = ((glMultTransposeMatrixf = (PFNGLMULTTRANSPOSEMATRIXFPROC)glewGetProcAddress((const GLubyte*)"glMultTransposeMatrixf")) == NULL) || r; - r = ((glMultiTexCoord1d = (PFNGLMULTITEXCOORD1DPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1d")) == NULL) || r; - r = ((glMultiTexCoord1dv = (PFNGLMULTITEXCOORD1DVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1dv")) == NULL) || r; - r = ((glMultiTexCoord1f = (PFNGLMULTITEXCOORD1FPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1f")) == NULL) || r; - r = ((glMultiTexCoord1fv = (PFNGLMULTITEXCOORD1FVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1fv")) == NULL) || r; - r = ((glMultiTexCoord1i = (PFNGLMULTITEXCOORD1IPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1i")) == NULL) || r; - r = ((glMultiTexCoord1iv = (PFNGLMULTITEXCOORD1IVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1iv")) == NULL) || r; - r = ((glMultiTexCoord1s = (PFNGLMULTITEXCOORD1SPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1s")) == NULL) || r; - r = ((glMultiTexCoord1sv = (PFNGLMULTITEXCOORD1SVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1sv")) == NULL) || r; - r = ((glMultiTexCoord2d = (PFNGLMULTITEXCOORD2DPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2d")) == NULL) || r; - r = ((glMultiTexCoord2dv = (PFNGLMULTITEXCOORD2DVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2dv")) == NULL) || r; - r = ((glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2f")) == NULL) || r; - r = ((glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2fv")) == NULL) || r; - r = ((glMultiTexCoord2i = (PFNGLMULTITEXCOORD2IPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2i")) == NULL) || r; - r = ((glMultiTexCoord2iv = (PFNGLMULTITEXCOORD2IVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2iv")) == NULL) || r; - r = ((glMultiTexCoord2s = (PFNGLMULTITEXCOORD2SPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2s")) == NULL) || r; - r = ((glMultiTexCoord2sv = (PFNGLMULTITEXCOORD2SVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2sv")) == NULL) || r; - r = ((glMultiTexCoord3d = (PFNGLMULTITEXCOORD3DPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3d")) == NULL) || r; - r = ((glMultiTexCoord3dv = (PFNGLMULTITEXCOORD3DVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3dv")) == NULL) || r; - r = ((glMultiTexCoord3f = (PFNGLMULTITEXCOORD3FPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3f")) == NULL) || r; - r = ((glMultiTexCoord3fv = (PFNGLMULTITEXCOORD3FVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3fv")) == NULL) || r; - r = ((glMultiTexCoord3i = (PFNGLMULTITEXCOORD3IPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3i")) == NULL) || r; - r = ((glMultiTexCoord3iv = (PFNGLMULTITEXCOORD3IVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3iv")) == NULL) || r; - r = ((glMultiTexCoord3s = (PFNGLMULTITEXCOORD3SPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3s")) == NULL) || r; - r = ((glMultiTexCoord3sv = (PFNGLMULTITEXCOORD3SVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3sv")) == NULL) || r; - r = ((glMultiTexCoord4d = (PFNGLMULTITEXCOORD4DPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4d")) == NULL) || r; - r = ((glMultiTexCoord4dv = (PFNGLMULTITEXCOORD4DVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4dv")) == NULL) || r; - r = ((glMultiTexCoord4f = (PFNGLMULTITEXCOORD4FPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4f")) == NULL) || r; - r = ((glMultiTexCoord4fv = (PFNGLMULTITEXCOORD4FVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4fv")) == NULL) || r; - r = ((glMultiTexCoord4i = (PFNGLMULTITEXCOORD4IPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4i")) == NULL) || r; - r = ((glMultiTexCoord4iv = (PFNGLMULTITEXCOORD4IVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4iv")) == NULL) || r; - r = ((glMultiTexCoord4s = (PFNGLMULTITEXCOORD4SPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4s")) == NULL) || r; - r = ((glMultiTexCoord4sv = (PFNGLMULTITEXCOORD4SVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4sv")) == NULL) || r; - r = ((glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC)glewGetProcAddress((const GLubyte*)"glSampleCoverage")) == NULL) || r; - - return r; -} - -#endif /* GL_VERSION_1_3 */ - -#ifdef GL_VERSION_1_4 - -static GLboolean _glewInit_GL_VERSION_1_4 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBlendColor = (PFNGLBLENDCOLORPROC)glewGetProcAddress((const GLubyte*)"glBlendColor")) == NULL) || r; - r = ((glBlendEquation = (PFNGLBLENDEQUATIONPROC)glewGetProcAddress((const GLubyte*)"glBlendEquation")) == NULL) || r; - r = ((glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)glewGetProcAddress((const GLubyte*)"glBlendFuncSeparate")) == NULL) || r; - r = ((glFogCoordPointer = (PFNGLFOGCOORDPOINTERPROC)glewGetProcAddress((const GLubyte*)"glFogCoordPointer")) == NULL) || r; - r = ((glFogCoordd = (PFNGLFOGCOORDDPROC)glewGetProcAddress((const GLubyte*)"glFogCoordd")) == NULL) || r; - r = ((glFogCoorddv = (PFNGLFOGCOORDDVPROC)glewGetProcAddress((const GLubyte*)"glFogCoorddv")) == NULL) || r; - r = ((glFogCoordf = (PFNGLFOGCOORDFPROC)glewGetProcAddress((const GLubyte*)"glFogCoordf")) == NULL) || r; - r = ((glFogCoordfv = (PFNGLFOGCOORDFVPROC)glewGetProcAddress((const GLubyte*)"glFogCoordfv")) == NULL) || r; - r = ((glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawArrays")) == NULL) || r; - r = ((glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawElements")) == NULL) || r; - r = ((glPointParameterf = (PFNGLPOINTPARAMETERFPROC)glewGetProcAddress((const GLubyte*)"glPointParameterf")) == NULL) || r; - r = ((glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glPointParameterfv")) == NULL) || r; - r = ((glPointParameteri = (PFNGLPOINTPARAMETERIPROC)glewGetProcAddress((const GLubyte*)"glPointParameteri")) == NULL) || r; - r = ((glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glPointParameteriv")) == NULL) || r; - r = ((glSecondaryColor3b = (PFNGLSECONDARYCOLOR3BPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3b")) == NULL) || r; - r = ((glSecondaryColor3bv = (PFNGLSECONDARYCOLOR3BVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3bv")) == NULL) || r; - r = ((glSecondaryColor3d = (PFNGLSECONDARYCOLOR3DPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3d")) == NULL) || r; - r = ((glSecondaryColor3dv = (PFNGLSECONDARYCOLOR3DVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3dv")) == NULL) || r; - r = ((glSecondaryColor3f = (PFNGLSECONDARYCOLOR3FPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3f")) == NULL) || r; - r = ((glSecondaryColor3fv = (PFNGLSECONDARYCOLOR3FVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3fv")) == NULL) || r; - r = ((glSecondaryColor3i = (PFNGLSECONDARYCOLOR3IPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3i")) == NULL) || r; - r = ((glSecondaryColor3iv = (PFNGLSECONDARYCOLOR3IVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3iv")) == NULL) || r; - r = ((glSecondaryColor3s = (PFNGLSECONDARYCOLOR3SPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3s")) == NULL) || r; - r = ((glSecondaryColor3sv = (PFNGLSECONDARYCOLOR3SVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3sv")) == NULL) || r; - r = ((glSecondaryColor3ub = (PFNGLSECONDARYCOLOR3UBPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ub")) == NULL) || r; - r = ((glSecondaryColor3ubv = (PFNGLSECONDARYCOLOR3UBVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ubv")) == NULL) || r; - r = ((glSecondaryColor3ui = (PFNGLSECONDARYCOLOR3UIPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ui")) == NULL) || r; - r = ((glSecondaryColor3uiv = (PFNGLSECONDARYCOLOR3UIVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3uiv")) == NULL) || r; - r = ((glSecondaryColor3us = (PFNGLSECONDARYCOLOR3USPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3us")) == NULL) || r; - r = ((glSecondaryColor3usv = (PFNGLSECONDARYCOLOR3USVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3usv")) == NULL) || r; - r = ((glSecondaryColorPointer = (PFNGLSECONDARYCOLORPOINTERPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColorPointer")) == NULL) || r; - r = ((glWindowPos2d = (PFNGLWINDOWPOS2DPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2d")) == NULL) || r; - r = ((glWindowPos2dv = (PFNGLWINDOWPOS2DVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2dv")) == NULL) || r; - r = ((glWindowPos2f = (PFNGLWINDOWPOS2FPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2f")) == NULL) || r; - r = ((glWindowPos2fv = (PFNGLWINDOWPOS2FVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2fv")) == NULL) || r; - r = ((glWindowPos2i = (PFNGLWINDOWPOS2IPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2i")) == NULL) || r; - r = ((glWindowPos2iv = (PFNGLWINDOWPOS2IVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2iv")) == NULL) || r; - r = ((glWindowPos2s = (PFNGLWINDOWPOS2SPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2s")) == NULL) || r; - r = ((glWindowPos2sv = (PFNGLWINDOWPOS2SVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2sv")) == NULL) || r; - r = ((glWindowPos3d = (PFNGLWINDOWPOS3DPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3d")) == NULL) || r; - r = ((glWindowPos3dv = (PFNGLWINDOWPOS3DVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3dv")) == NULL) || r; - r = ((glWindowPos3f = (PFNGLWINDOWPOS3FPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3f")) == NULL) || r; - r = ((glWindowPos3fv = (PFNGLWINDOWPOS3FVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3fv")) == NULL) || r; - r = ((glWindowPos3i = (PFNGLWINDOWPOS3IPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3i")) == NULL) || r; - r = ((glWindowPos3iv = (PFNGLWINDOWPOS3IVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3iv")) == NULL) || r; - r = ((glWindowPos3s = (PFNGLWINDOWPOS3SPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3s")) == NULL) || r; - r = ((glWindowPos3sv = (PFNGLWINDOWPOS3SVPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3sv")) == NULL) || r; - - return r; -} - -#endif /* GL_VERSION_1_4 */ - -#ifdef GL_VERSION_1_5 - -static GLboolean _glewInit_GL_VERSION_1_5 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBeginQuery = (PFNGLBEGINQUERYPROC)glewGetProcAddress((const GLubyte*)"glBeginQuery")) == NULL) || r; - r = ((glBindBuffer = (PFNGLBINDBUFFERPROC)glewGetProcAddress((const GLubyte*)"glBindBuffer")) == NULL) || r; - r = ((glBufferData = (PFNGLBUFFERDATAPROC)glewGetProcAddress((const GLubyte*)"glBufferData")) == NULL) || r; - r = ((glBufferSubData = (PFNGLBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)"glBufferSubData")) == NULL) || r; - r = ((glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteBuffers")) == NULL) || r; - r = ((glDeleteQueries = (PFNGLDELETEQUERIESPROC)glewGetProcAddress((const GLubyte*)"glDeleteQueries")) == NULL) || r; - r = ((glEndQuery = (PFNGLENDQUERYPROC)glewGetProcAddress((const GLubyte*)"glEndQuery")) == NULL) || r; - r = ((glGenBuffers = (PFNGLGENBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glGenBuffers")) == NULL) || r; - r = ((glGenQueries = (PFNGLGENQUERIESPROC)glewGetProcAddress((const GLubyte*)"glGenQueries")) == NULL) || r; - r = ((glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetBufferParameteriv")) == NULL) || r; - r = ((glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC)glewGetProcAddress((const GLubyte*)"glGetBufferPointerv")) == NULL) || r; - r = ((glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)glewGetProcAddress((const GLubyte*)"glGetBufferSubData")) == NULL) || r; - r = ((glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectiv")) == NULL) || r; - r = ((glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectuiv")) == NULL) || r; - r = ((glGetQueryiv = (PFNGLGETQUERYIVPROC)glewGetProcAddress((const GLubyte*)"glGetQueryiv")) == NULL) || r; - r = ((glIsBuffer = (PFNGLISBUFFERPROC)glewGetProcAddress((const GLubyte*)"glIsBuffer")) == NULL) || r; - r = ((glIsQuery = (PFNGLISQUERYPROC)glewGetProcAddress((const GLubyte*)"glIsQuery")) == NULL) || r; - r = ((glMapBuffer = (PFNGLMAPBUFFERPROC)glewGetProcAddress((const GLubyte*)"glMapBuffer")) == NULL) || r; - r = ((glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)glewGetProcAddress((const GLubyte*)"glUnmapBuffer")) == NULL) || r; - - return r; -} - -#endif /* GL_VERSION_1_5 */ - -#ifdef GL_VERSION_2_0 - -static GLboolean _glewInit_GL_VERSION_2_0 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glAttachShader = (PFNGLATTACHSHADERPROC)glewGetProcAddress((const GLubyte*)"glAttachShader")) == NULL) || r; - r = ((glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)glewGetProcAddress((const GLubyte*)"glBindAttribLocation")) == NULL) || r; - r = ((glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationSeparate")) == NULL) || r; - r = ((glCompileShader = (PFNGLCOMPILESHADERPROC)glewGetProcAddress((const GLubyte*)"glCompileShader")) == NULL) || r; - r = ((glCreateProgram = (PFNGLCREATEPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glCreateProgram")) == NULL) || r; - r = ((glCreateShader = (PFNGLCREATESHADERPROC)glewGetProcAddress((const GLubyte*)"glCreateShader")) == NULL) || r; - r = ((glDeleteProgram = (PFNGLDELETEPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glDeleteProgram")) == NULL) || r; - r = ((glDeleteShader = (PFNGLDELETESHADERPROC)glewGetProcAddress((const GLubyte*)"glDeleteShader")) == NULL) || r; - r = ((glDetachShader = (PFNGLDETACHSHADERPROC)glewGetProcAddress((const GLubyte*)"glDetachShader")) == NULL) || r; - r = ((glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)glewGetProcAddress((const GLubyte*)"glDisableVertexAttribArray")) == NULL) || r; - r = ((glDrawBuffers = (PFNGLDRAWBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDrawBuffers")) == NULL) || r; - r = ((glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)glewGetProcAddress((const GLubyte*)"glEnableVertexAttribArray")) == NULL) || r; - r = ((glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)glewGetProcAddress((const GLubyte*)"glGetActiveAttrib")) == NULL) || r; - r = ((glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)glewGetProcAddress((const GLubyte*)"glGetActiveUniform")) == NULL) || r; - r = ((glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)glewGetProcAddress((const GLubyte*)"glGetAttachedShaders")) == NULL) || r; - r = ((glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)glewGetProcAddress((const GLubyte*)"glGetAttribLocation")) == NULL) || r; - r = ((glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)glewGetProcAddress((const GLubyte*)"glGetProgramInfoLog")) == NULL) || r; - r = ((glGetProgramiv = (PFNGLGETPROGRAMIVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramiv")) == NULL) || r; - r = ((glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)glewGetProcAddress((const GLubyte*)"glGetShaderInfoLog")) == NULL) || r; - r = ((glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)glewGetProcAddress((const GLubyte*)"glGetShaderSource")) == NULL) || r; - r = ((glGetShaderiv = (PFNGLGETSHADERIVPROC)glewGetProcAddress((const GLubyte*)"glGetShaderiv")) == NULL) || r; - r = ((glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)glewGetProcAddress((const GLubyte*)"glGetUniformLocation")) == NULL) || r; - r = ((glGetUniformfv = (PFNGLGETUNIFORMFVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformfv")) == NULL) || r; - r = ((glGetUniformiv = (PFNGLGETUNIFORMIVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformiv")) == NULL) || r; - r = ((glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribPointerv")) == NULL) || r; - r = ((glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribdv")) == NULL) || r; - r = ((glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribfv")) == NULL) || r; - r = ((glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribiv")) == NULL) || r; - r = ((glIsProgram = (PFNGLISPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glIsProgram")) == NULL) || r; - r = ((glIsShader = (PFNGLISSHADERPROC)glewGetProcAddress((const GLubyte*)"glIsShader")) == NULL) || r; - r = ((glLinkProgram = (PFNGLLINKPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glLinkProgram")) == NULL) || r; - r = ((glShaderSource = (PFNGLSHADERSOURCEPROC)glewGetProcAddress((const GLubyte*)"glShaderSource")) == NULL) || r; - r = ((glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)glewGetProcAddress((const GLubyte*)"glStencilFuncSeparate")) == NULL) || r; - r = ((glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC)glewGetProcAddress((const GLubyte*)"glStencilMaskSeparate")) == NULL) || r; - r = ((glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)glewGetProcAddress((const GLubyte*)"glStencilOpSeparate")) == NULL) || r; - r = ((glUniform1f = (PFNGLUNIFORM1FPROC)glewGetProcAddress((const GLubyte*)"glUniform1f")) == NULL) || r; - r = ((glUniform1fv = (PFNGLUNIFORM1FVPROC)glewGetProcAddress((const GLubyte*)"glUniform1fv")) == NULL) || r; - r = ((glUniform1i = (PFNGLUNIFORM1IPROC)glewGetProcAddress((const GLubyte*)"glUniform1i")) == NULL) || r; - r = ((glUniform1iv = (PFNGLUNIFORM1IVPROC)glewGetProcAddress((const GLubyte*)"glUniform1iv")) == NULL) || r; - r = ((glUniform2f = (PFNGLUNIFORM2FPROC)glewGetProcAddress((const GLubyte*)"glUniform2f")) == NULL) || r; - r = ((glUniform2fv = (PFNGLUNIFORM2FVPROC)glewGetProcAddress((const GLubyte*)"glUniform2fv")) == NULL) || r; - r = ((glUniform2i = (PFNGLUNIFORM2IPROC)glewGetProcAddress((const GLubyte*)"glUniform2i")) == NULL) || r; - r = ((glUniform2iv = (PFNGLUNIFORM2IVPROC)glewGetProcAddress((const GLubyte*)"glUniform2iv")) == NULL) || r; - r = ((glUniform3f = (PFNGLUNIFORM3FPROC)glewGetProcAddress((const GLubyte*)"glUniform3f")) == NULL) || r; - r = ((glUniform3fv = (PFNGLUNIFORM3FVPROC)glewGetProcAddress((const GLubyte*)"glUniform3fv")) == NULL) || r; - r = ((glUniform3i = (PFNGLUNIFORM3IPROC)glewGetProcAddress((const GLubyte*)"glUniform3i")) == NULL) || r; - r = ((glUniform3iv = (PFNGLUNIFORM3IVPROC)glewGetProcAddress((const GLubyte*)"glUniform3iv")) == NULL) || r; - r = ((glUniform4f = (PFNGLUNIFORM4FPROC)glewGetProcAddress((const GLubyte*)"glUniform4f")) == NULL) || r; - r = ((glUniform4fv = (PFNGLUNIFORM4FVPROC)glewGetProcAddress((const GLubyte*)"glUniform4fv")) == NULL) || r; - r = ((glUniform4i = (PFNGLUNIFORM4IPROC)glewGetProcAddress((const GLubyte*)"glUniform4i")) == NULL) || r; - r = ((glUniform4iv = (PFNGLUNIFORM4IVPROC)glewGetProcAddress((const GLubyte*)"glUniform4iv")) == NULL) || r; - r = ((glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix2fv")) == NULL) || r; - r = ((glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix3fv")) == NULL) || r; - r = ((glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix4fv")) == NULL) || r; - r = ((glUseProgram = (PFNGLUSEPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glUseProgram")) == NULL) || r; - r = ((glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)glewGetProcAddress((const GLubyte*)"glValidateProgram")) == NULL) || r; - r = ((glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1d")) == NULL) || r; - r = ((glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1dv")) == NULL) || r; - r = ((glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1f")) == NULL) || r; - r = ((glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1fv")) == NULL) || r; - r = ((glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1s")) == NULL) || r; - r = ((glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1sv")) == NULL) || r; - r = ((glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2d")) == NULL) || r; - r = ((glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2dv")) == NULL) || r; - r = ((glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2f")) == NULL) || r; - r = ((glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2fv")) == NULL) || r; - r = ((glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2s")) == NULL) || r; - r = ((glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2sv")) == NULL) || r; - r = ((glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3d")) == NULL) || r; - r = ((glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3dv")) == NULL) || r; - r = ((glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3f")) == NULL) || r; - r = ((glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3fv")) == NULL) || r; - r = ((glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3s")) == NULL) || r; - r = ((glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3sv")) == NULL) || r; - r = ((glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nbv")) == NULL) || r; - r = ((glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Niv")) == NULL) || r; - r = ((glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nsv")) == NULL) || r; - r = ((glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nub")) == NULL) || r; - r = ((glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nubv")) == NULL) || r; - r = ((glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nuiv")) == NULL) || r; - r = ((glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4Nusv")) == NULL) || r; - r = ((glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4bv")) == NULL) || r; - r = ((glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4d")) == NULL) || r; - r = ((glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4dv")) == NULL) || r; - r = ((glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4f")) == NULL) || r; - r = ((glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4fv")) == NULL) || r; - r = ((glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4iv")) == NULL) || r; - r = ((glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4s")) == NULL) || r; - r = ((glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4sv")) == NULL) || r; - r = ((glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4ubv")) == NULL) || r; - r = ((glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4uiv")) == NULL) || r; - r = ((glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4usv")) == NULL) || r; - r = ((glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribPointer")) == NULL) || r; - - return r; -} - -#endif /* GL_VERSION_2_0 */ - -#ifdef GL_VERSION_2_1 - -static GLboolean _glewInit_GL_VERSION_2_1 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix2x3fv")) == NULL) || r; - r = ((glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix2x4fv")) == NULL) || r; - r = ((glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix3x2fv")) == NULL) || r; - r = ((glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix3x4fv")) == NULL) || r; - r = ((glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix4x2fv")) == NULL) || r; - r = ((glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix4x3fv")) == NULL) || r; - - return r; -} - -#endif /* GL_VERSION_2_1 */ - -#ifdef GL_VERSION_3_0 - -static GLboolean _glewInit_GL_VERSION_3_0 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC)glewGetProcAddress((const GLubyte*)"glBeginConditionalRender")) == NULL) || r; - r = ((glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glBeginTransformFeedback")) == NULL) || r; - r = ((glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)glewGetProcAddress((const GLubyte*)"glBindBufferBase")) == NULL) || r; - r = ((glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)"glBindBufferRange")) == NULL) || r; - r = ((glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)glewGetProcAddress((const GLubyte*)"glBindFragDataLocation")) == NULL) || r; - r = ((glClampColor = (PFNGLCLAMPCOLORPROC)glewGetProcAddress((const GLubyte*)"glClampColor")) == NULL) || r; - r = ((glClearBufferfi = (PFNGLCLEARBUFFERFIPROC)glewGetProcAddress((const GLubyte*)"glClearBufferfi")) == NULL) || r; - r = ((glClearBufferfv = (PFNGLCLEARBUFFERFVPROC)glewGetProcAddress((const GLubyte*)"glClearBufferfv")) == NULL) || r; - r = ((glClearBufferiv = (PFNGLCLEARBUFFERIVPROC)glewGetProcAddress((const GLubyte*)"glClearBufferiv")) == NULL) || r; - r = ((glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC)glewGetProcAddress((const GLubyte*)"glClearBufferuiv")) == NULL) || r; - r = ((glColorMaski = (PFNGLCOLORMASKIPROC)glewGetProcAddress((const GLubyte*)"glColorMaski")) == NULL) || r; - r = ((glDisablei = (PFNGLDISABLEIPROC)glewGetProcAddress((const GLubyte*)"glDisablei")) == NULL) || r; - r = ((glEnablei = (PFNGLENABLEIPROC)glewGetProcAddress((const GLubyte*)"glEnablei")) == NULL) || r; - r = ((glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC)glewGetProcAddress((const GLubyte*)"glEndConditionalRender")) == NULL) || r; - r = ((glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)glewGetProcAddress((const GLubyte*)"glEndTransformFeedback")) == NULL) || r; - r = ((glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC)glewGetProcAddress((const GLubyte*)"glGetBooleani_v")) == NULL) || r; - r = ((glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC)glewGetProcAddress((const GLubyte*)"glGetFragDataLocation")) == NULL) || r; - r = ((glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)glewGetProcAddress((const GLubyte*)"glGetIntegeri_v")) == NULL) || r; - r = ((glGetStringi = (PFNGLGETSTRINGIPROC)glewGetProcAddress((const GLubyte*)"glGetStringi")) == NULL) || r; - r = ((glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterIiv")) == NULL) || r; - r = ((glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterIuiv")) == NULL) || r; - r = ((glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)glewGetProcAddress((const GLubyte*)"glGetTransformFeedbackVarying")) == NULL) || r; - r = ((glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC)glewGetProcAddress((const GLubyte*)"glGetUniformuiv")) == NULL) || r; - r = ((glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribIiv")) == NULL) || r; - r = ((glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribIuiv")) == NULL) || r; - r = ((glIsEnabledi = (PFNGLISENABLEDIPROC)glewGetProcAddress((const GLubyte*)"glIsEnabledi")) == NULL) || r; - r = ((glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC)glewGetProcAddress((const GLubyte*)"glTexParameterIiv")) == NULL) || r; - r = ((glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC)glewGetProcAddress((const GLubyte*)"glTexParameterIuiv")) == NULL) || r; - r = ((glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)glewGetProcAddress((const GLubyte*)"glTransformFeedbackVaryings")) == NULL) || r; - r = ((glUniform1ui = (PFNGLUNIFORM1UIPROC)glewGetProcAddress((const GLubyte*)"glUniform1ui")) == NULL) || r; - r = ((glUniform1uiv = (PFNGLUNIFORM1UIVPROC)glewGetProcAddress((const GLubyte*)"glUniform1uiv")) == NULL) || r; - r = ((glUniform2ui = (PFNGLUNIFORM2UIPROC)glewGetProcAddress((const GLubyte*)"glUniform2ui")) == NULL) || r; - r = ((glUniform2uiv = (PFNGLUNIFORM2UIVPROC)glewGetProcAddress((const GLubyte*)"glUniform2uiv")) == NULL) || r; - r = ((glUniform3ui = (PFNGLUNIFORM3UIPROC)glewGetProcAddress((const GLubyte*)"glUniform3ui")) == NULL) || r; - r = ((glUniform3uiv = (PFNGLUNIFORM3UIVPROC)glewGetProcAddress((const GLubyte*)"glUniform3uiv")) == NULL) || r; - r = ((glUniform4ui = (PFNGLUNIFORM4UIPROC)glewGetProcAddress((const GLubyte*)"glUniform4ui")) == NULL) || r; - r = ((glUniform4uiv = (PFNGLUNIFORM4UIVPROC)glewGetProcAddress((const GLubyte*)"glUniform4uiv")) == NULL) || r; - r = ((glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1i")) == NULL) || r; - r = ((glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1iv")) == NULL) || r; - r = ((glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1ui")) == NULL) || r; - r = ((glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1uiv")) == NULL) || r; - r = ((glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2i")) == NULL) || r; - r = ((glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2iv")) == NULL) || r; - r = ((glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2ui")) == NULL) || r; - r = ((glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2uiv")) == NULL) || r; - r = ((glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3i")) == NULL) || r; - r = ((glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3iv")) == NULL) || r; - r = ((glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3ui")) == NULL) || r; - r = ((glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3uiv")) == NULL) || r; - r = ((glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4bv")) == NULL) || r; - r = ((glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4i")) == NULL) || r; - r = ((glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4iv")) == NULL) || r; - r = ((glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4sv")) == NULL) || r; - r = ((glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4ubv")) == NULL) || r; - r = ((glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4ui")) == NULL) || r; - r = ((glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4uiv")) == NULL) || r; - r = ((glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4usv")) == NULL) || r; - r = ((glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribIPointer")) == NULL) || r; - - return r; -} - -#endif /* GL_VERSION_3_0 */ - -#ifdef GL_3DFX_multisample - -#endif /* GL_3DFX_multisample */ - -#ifdef GL_3DFX_tbuffer - -static GLboolean _glewInit_GL_3DFX_tbuffer (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTbufferMask3DFX = (PFNGLTBUFFERMASK3DFXPROC)glewGetProcAddress((const GLubyte*)"glTbufferMask3DFX")) == NULL) || r; - - return r; -} - -#endif /* GL_3DFX_tbuffer */ - -#ifdef GL_3DFX_texture_compression_FXT1 - -#endif /* GL_3DFX_texture_compression_FXT1 */ - -#ifdef GL_APPLE_client_storage - -#endif /* GL_APPLE_client_storage */ - -#ifdef GL_APPLE_element_array - -static GLboolean _glewInit_GL_APPLE_element_array (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDrawElementArrayAPPLE = (PFNGLDRAWELEMENTARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glDrawElementArrayAPPLE")) == NULL) || r; - r = ((glDrawRangeElementArrayAPPLE = (PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glDrawRangeElementArrayAPPLE")) == NULL) || r; - r = ((glElementPointerAPPLE = (PFNGLELEMENTPOINTERAPPLEPROC)glewGetProcAddress((const GLubyte*)"glElementPointerAPPLE")) == NULL) || r; - r = ((glMultiDrawElementArrayAPPLE = (PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawElementArrayAPPLE")) == NULL) || r; - r = ((glMultiDrawRangeElementArrayAPPLE = (PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawRangeElementArrayAPPLE")) == NULL) || r; - - return r; -} - -#endif /* GL_APPLE_element_array */ - -#ifdef GL_APPLE_fence - -static GLboolean _glewInit_GL_APPLE_fence (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDeleteFencesAPPLE = (PFNGLDELETEFENCESAPPLEPROC)glewGetProcAddress((const GLubyte*)"glDeleteFencesAPPLE")) == NULL) || r; - r = ((glFinishFenceAPPLE = (PFNGLFINISHFENCEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glFinishFenceAPPLE")) == NULL) || r; - r = ((glFinishObjectAPPLE = (PFNGLFINISHOBJECTAPPLEPROC)glewGetProcAddress((const GLubyte*)"glFinishObjectAPPLE")) == NULL) || r; - r = ((glGenFencesAPPLE = (PFNGLGENFENCESAPPLEPROC)glewGetProcAddress((const GLubyte*)"glGenFencesAPPLE")) == NULL) || r; - r = ((glIsFenceAPPLE = (PFNGLISFENCEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glIsFenceAPPLE")) == NULL) || r; - r = ((glSetFenceAPPLE = (PFNGLSETFENCEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glSetFenceAPPLE")) == NULL) || r; - r = ((glTestFenceAPPLE = (PFNGLTESTFENCEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glTestFenceAPPLE")) == NULL) || r; - r = ((glTestObjectAPPLE = (PFNGLTESTOBJECTAPPLEPROC)glewGetProcAddress((const GLubyte*)"glTestObjectAPPLE")) == NULL) || r; - - return r; -} - -#endif /* GL_APPLE_fence */ - -#ifdef GL_APPLE_float_pixels - -#endif /* GL_APPLE_float_pixels */ - -#ifdef GL_APPLE_flush_buffer_range - -static GLboolean _glewInit_GL_APPLE_flush_buffer_range (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBufferParameteriAPPLE = (PFNGLBUFFERPARAMETERIAPPLEPROC)glewGetProcAddress((const GLubyte*)"glBufferParameteriAPPLE")) == NULL) || r; - r = ((glFlushMappedBufferRangeAPPLE = (PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glFlushMappedBufferRangeAPPLE")) == NULL) || r; - - return r; -} - -#endif /* GL_APPLE_flush_buffer_range */ - -#ifdef GL_APPLE_pixel_buffer - -#endif /* GL_APPLE_pixel_buffer */ - -#ifdef GL_APPLE_specular_vector - -#endif /* GL_APPLE_specular_vector */ - -#ifdef GL_APPLE_texture_range - -static GLboolean _glewInit_GL_APPLE_texture_range (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetTexParameterPointervAPPLE = (PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterPointervAPPLE")) == NULL) || r; - r = ((glTextureRangeAPPLE = (PFNGLTEXTURERANGEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glTextureRangeAPPLE")) == NULL) || r; - - return r; -} - -#endif /* GL_APPLE_texture_range */ - -#ifdef GL_APPLE_transform_hint - -#endif /* GL_APPLE_transform_hint */ - -#ifdef GL_APPLE_vertex_array_object - -static GLboolean _glewInit_GL_APPLE_vertex_array_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindVertexArrayAPPLE = (PFNGLBINDVERTEXARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glBindVertexArrayAPPLE")) == NULL) || r; - r = ((glDeleteVertexArraysAPPLE = (PFNGLDELETEVERTEXARRAYSAPPLEPROC)glewGetProcAddress((const GLubyte*)"glDeleteVertexArraysAPPLE")) == NULL) || r; - r = ((glGenVertexArraysAPPLE = (PFNGLGENVERTEXARRAYSAPPLEPROC)glewGetProcAddress((const GLubyte*)"glGenVertexArraysAPPLE")) == NULL) || r; - r = ((glIsVertexArrayAPPLE = (PFNGLISVERTEXARRAYAPPLEPROC)glewGetProcAddress((const GLubyte*)"glIsVertexArrayAPPLE")) == NULL) || r; - - return r; -} - -#endif /* GL_APPLE_vertex_array_object */ - -#ifdef GL_APPLE_vertex_array_range - -static GLboolean _glewInit_GL_APPLE_vertex_array_range (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFlushVertexArrayRangeAPPLE = (PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glFlushVertexArrayRangeAPPLE")) == NULL) || r; - r = ((glVertexArrayParameteriAPPLE = (PFNGLVERTEXARRAYPARAMETERIAPPLEPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayParameteriAPPLE")) == NULL) || r; - r = ((glVertexArrayRangeAPPLE = (PFNGLVERTEXARRAYRANGEAPPLEPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayRangeAPPLE")) == NULL) || r; - - return r; -} - -#endif /* GL_APPLE_vertex_array_range */ - -#ifdef GL_APPLE_ycbcr_422 - -#endif /* GL_APPLE_ycbcr_422 */ - -#ifdef GL_ARB_color_buffer_float - -static GLboolean _glewInit_GL_ARB_color_buffer_float (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glClampColorARB = (PFNGLCLAMPCOLORARBPROC)glewGetProcAddress((const GLubyte*)"glClampColorARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_color_buffer_float */ - -#ifdef GL_ARB_depth_buffer_float - -#endif /* GL_ARB_depth_buffer_float */ - -#ifdef GL_ARB_depth_texture - -#endif /* GL_ARB_depth_texture */ - -#ifdef GL_ARB_draw_buffers - -static GLboolean _glewInit_GL_ARB_draw_buffers (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDrawBuffersARB = (PFNGLDRAWBUFFERSARBPROC)glewGetProcAddress((const GLubyte*)"glDrawBuffersARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_draw_buffers */ - -#ifdef GL_ARB_draw_instanced - -static GLboolean _glewInit_GL_ARB_draw_instanced (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDrawArraysInstancedARB = (PFNGLDRAWARRAYSINSTANCEDARBPROC)glewGetProcAddress((const GLubyte*)"glDrawArraysInstancedARB")) == NULL) || r; - r = ((glDrawElementsInstancedARB = (PFNGLDRAWELEMENTSINSTANCEDARBPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsInstancedARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_draw_instanced */ - -#ifdef GL_ARB_fragment_program - -#endif /* GL_ARB_fragment_program */ - -#ifdef GL_ARB_fragment_program_shadow - -#endif /* GL_ARB_fragment_program_shadow */ - -#ifdef GL_ARB_fragment_shader - -#endif /* GL_ARB_fragment_shader */ - -#ifdef GL_ARB_framebuffer_object - -static GLboolean _glewInit_GL_ARB_framebuffer_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)"glBindFramebuffer")) == NULL) || r; - r = ((glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)glewGetProcAddress((const GLubyte*)"glBindRenderbuffer")) == NULL) || r; - r = ((glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)"glBlitFramebuffer")) == NULL) || r; - r = ((glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)glewGetProcAddress((const GLubyte*)"glCheckFramebufferStatus")) == NULL) || r; - r = ((glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteFramebuffers")) == NULL) || r; - r = ((glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glDeleteRenderbuffers")) == NULL) || r; - r = ((glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)glewGetProcAddress((const GLubyte*)"glFramebufferRenderbuffer")) == NULL) || r; - r = ((glFramebufferTexturLayer = (PFNGLFRAMEBUFFERTEXTURLAYERPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexturLayer")) == NULL) || r; - r = ((glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture1D")) == NULL) || r; - r = ((glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture2D")) == NULL) || r; - r = ((glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture3D")) == NULL) || r; - r = ((glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glGenFramebuffers")) == NULL) || r; - r = ((glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)glewGetProcAddress((const GLubyte*)"glGenRenderbuffers")) == NULL) || r; - r = ((glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)glewGetProcAddress((const GLubyte*)"glGenerateMipmap")) == NULL) || r; - r = ((glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetFramebufferAttachmentParameteriv")) == NULL) || r; - r = ((glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetRenderbufferParameteriv")) == NULL) || r; - r = ((glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)glewGetProcAddress((const GLubyte*)"glIsFramebuffer")) == NULL) || r; - r = ((glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)glewGetProcAddress((const GLubyte*)"glIsRenderbuffer")) == NULL) || r; - r = ((glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)glewGetProcAddress((const GLubyte*)"glRenderbufferStorage")) == NULL) || r; - r = ((glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)glewGetProcAddress((const GLubyte*)"glRenderbufferStorageMultisample")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_framebuffer_object */ - -#ifdef GL_ARB_framebuffer_sRGB - -#endif /* GL_ARB_framebuffer_sRGB */ - -#ifdef GL_ARB_geometry_shader4 - -static GLboolean _glewInit_GL_ARB_geometry_shader4 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFramebufferTextureARB = (PFNGLFRAMEBUFFERTEXTUREARBPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureARB")) == NULL) || r; - r = ((glFramebufferTextureFaceARB = (PFNGLFRAMEBUFFERTEXTUREFACEARBPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureFaceARB")) == NULL) || r; - r = ((glFramebufferTextureLayerARB = (PFNGLFRAMEBUFFERTEXTURELAYERARBPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureLayerARB")) == NULL) || r; - r = ((glProgramParameteriARB = (PFNGLPROGRAMPARAMETERIARBPROC)glewGetProcAddress((const GLubyte*)"glProgramParameteriARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_geometry_shader4 */ - -#ifdef GL_ARB_half_float_pixel - -#endif /* GL_ARB_half_float_pixel */ - -#ifdef GL_ARB_half_float_vertex - -#endif /* GL_ARB_half_float_vertex */ - -#ifdef GL_ARB_imaging - -static GLboolean _glewInit_GL_ARB_imaging (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBlendEquation = (PFNGLBLENDEQUATIONPROC)glewGetProcAddress((const GLubyte*)"glBlendEquation")) == NULL) || r; - r = ((glColorSubTable = (PFNGLCOLORSUBTABLEPROC)glewGetProcAddress((const GLubyte*)"glColorSubTable")) == NULL) || r; - r = ((glColorTable = (PFNGLCOLORTABLEPROC)glewGetProcAddress((const GLubyte*)"glColorTable")) == NULL) || r; - r = ((glColorTableParameterfv = (PFNGLCOLORTABLEPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glColorTableParameterfv")) == NULL) || r; - r = ((glColorTableParameteriv = (PFNGLCOLORTABLEPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glColorTableParameteriv")) == NULL) || r; - r = ((glConvolutionFilter1D = (PFNGLCONVOLUTIONFILTER1DPROC)glewGetProcAddress((const GLubyte*)"glConvolutionFilter1D")) == NULL) || r; - r = ((glConvolutionFilter2D = (PFNGLCONVOLUTIONFILTER2DPROC)glewGetProcAddress((const GLubyte*)"glConvolutionFilter2D")) == NULL) || r; - r = ((glConvolutionParameterf = (PFNGLCONVOLUTIONPARAMETERFPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameterf")) == NULL) || r; - r = ((glConvolutionParameterfv = (PFNGLCONVOLUTIONPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameterfv")) == NULL) || r; - r = ((glConvolutionParameteri = (PFNGLCONVOLUTIONPARAMETERIPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameteri")) == NULL) || r; - r = ((glConvolutionParameteriv = (PFNGLCONVOLUTIONPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameteriv")) == NULL) || r; - r = ((glCopyColorSubTable = (PFNGLCOPYCOLORSUBTABLEPROC)glewGetProcAddress((const GLubyte*)"glCopyColorSubTable")) == NULL) || r; - r = ((glCopyColorTable = (PFNGLCOPYCOLORTABLEPROC)glewGetProcAddress((const GLubyte*)"glCopyColorTable")) == NULL) || r; - r = ((glCopyConvolutionFilter1D = (PFNGLCOPYCONVOLUTIONFILTER1DPROC)glewGetProcAddress((const GLubyte*)"glCopyConvolutionFilter1D")) == NULL) || r; - r = ((glCopyConvolutionFilter2D = (PFNGLCOPYCONVOLUTIONFILTER2DPROC)glewGetProcAddress((const GLubyte*)"glCopyConvolutionFilter2D")) == NULL) || r; - r = ((glGetColorTable = (PFNGLGETCOLORTABLEPROC)glewGetProcAddress((const GLubyte*)"glGetColorTable")) == NULL) || r; - r = ((glGetColorTableParameterfv = (PFNGLGETCOLORTABLEPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameterfv")) == NULL) || r; - r = ((glGetColorTableParameteriv = (PFNGLGETCOLORTABLEPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameteriv")) == NULL) || r; - r = ((glGetConvolutionFilter = (PFNGLGETCONVOLUTIONFILTERPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionFilter")) == NULL) || r; - r = ((glGetConvolutionParameterfv = (PFNGLGETCONVOLUTIONPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionParameterfv")) == NULL) || r; - r = ((glGetConvolutionParameteriv = (PFNGLGETCONVOLUTIONPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionParameteriv")) == NULL) || r; - r = ((glGetHistogram = (PFNGLGETHISTOGRAMPROC)glewGetProcAddress((const GLubyte*)"glGetHistogram")) == NULL) || r; - r = ((glGetHistogramParameterfv = (PFNGLGETHISTOGRAMPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glGetHistogramParameterfv")) == NULL) || r; - r = ((glGetHistogramParameteriv = (PFNGLGETHISTOGRAMPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetHistogramParameteriv")) == NULL) || r; - r = ((glGetMinmax = (PFNGLGETMINMAXPROC)glewGetProcAddress((const GLubyte*)"glGetMinmax")) == NULL) || r; - r = ((glGetMinmaxParameterfv = (PFNGLGETMINMAXPARAMETERFVPROC)glewGetProcAddress((const GLubyte*)"glGetMinmaxParameterfv")) == NULL) || r; - r = ((glGetMinmaxParameteriv = (PFNGLGETMINMAXPARAMETERIVPROC)glewGetProcAddress((const GLubyte*)"glGetMinmaxParameteriv")) == NULL) || r; - r = ((glGetSeparableFilter = (PFNGLGETSEPARABLEFILTERPROC)glewGetProcAddress((const GLubyte*)"glGetSeparableFilter")) == NULL) || r; - r = ((glHistogram = (PFNGLHISTOGRAMPROC)glewGetProcAddress((const GLubyte*)"glHistogram")) == NULL) || r; - r = ((glMinmax = (PFNGLMINMAXPROC)glewGetProcAddress((const GLubyte*)"glMinmax")) == NULL) || r; - r = ((glResetHistogram = (PFNGLRESETHISTOGRAMPROC)glewGetProcAddress((const GLubyte*)"glResetHistogram")) == NULL) || r; - r = ((glResetMinmax = (PFNGLRESETMINMAXPROC)glewGetProcAddress((const GLubyte*)"glResetMinmax")) == NULL) || r; - r = ((glSeparableFilter2D = (PFNGLSEPARABLEFILTER2DPROC)glewGetProcAddress((const GLubyte*)"glSeparableFilter2D")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_imaging */ - -#ifdef GL_ARB_instanced_arrays - -static GLboolean _glewInit_GL_ARB_instanced_arrays (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glVertexAttribDivisorARB = (PFNGLVERTEXATTRIBDIVISORARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribDivisorARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_instanced_arrays */ - -#ifdef GL_ARB_map_buffer_range - -static GLboolean _glewInit_GL_ARB_map_buffer_range (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)"glFlushMappedBufferRange")) == NULL) || r; - r = ((glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)glewGetProcAddress((const GLubyte*)"glMapBufferRange")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_map_buffer_range */ - -#ifdef GL_ARB_matrix_palette - -static GLboolean _glewInit_GL_ARB_matrix_palette (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glCurrentPaletteMatrixARB = (PFNGLCURRENTPALETTEMATRIXARBPROC)glewGetProcAddress((const GLubyte*)"glCurrentPaletteMatrixARB")) == NULL) || r; - r = ((glMatrixIndexPointerARB = (PFNGLMATRIXINDEXPOINTERARBPROC)glewGetProcAddress((const GLubyte*)"glMatrixIndexPointerARB")) == NULL) || r; - r = ((glMatrixIndexubvARB = (PFNGLMATRIXINDEXUBVARBPROC)glewGetProcAddress((const GLubyte*)"glMatrixIndexubvARB")) == NULL) || r; - r = ((glMatrixIndexuivARB = (PFNGLMATRIXINDEXUIVARBPROC)glewGetProcAddress((const GLubyte*)"glMatrixIndexuivARB")) == NULL) || r; - r = ((glMatrixIndexusvARB = (PFNGLMATRIXINDEXUSVARBPROC)glewGetProcAddress((const GLubyte*)"glMatrixIndexusvARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_matrix_palette */ - -#ifdef GL_ARB_multisample - -static GLboolean _glewInit_GL_ARB_multisample (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glSampleCoverageARB = (PFNGLSAMPLECOVERAGEARBPROC)glewGetProcAddress((const GLubyte*)"glSampleCoverageARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_multisample */ - -#ifdef GL_ARB_multitexture - -static GLboolean _glewInit_GL_ARB_multitexture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)glewGetProcAddress((const GLubyte*)"glActiveTextureARB")) == NULL) || r; - r = ((glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)glewGetProcAddress((const GLubyte*)"glClientActiveTextureARB")) == NULL) || r; - r = ((glMultiTexCoord1dARB = (PFNGLMULTITEXCOORD1DARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1dARB")) == NULL) || r; - r = ((glMultiTexCoord1dvARB = (PFNGLMULTITEXCOORD1DVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1dvARB")) == NULL) || r; - r = ((glMultiTexCoord1fARB = (PFNGLMULTITEXCOORD1FARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1fARB")) == NULL) || r; - r = ((glMultiTexCoord1fvARB = (PFNGLMULTITEXCOORD1FVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1fvARB")) == NULL) || r; - r = ((glMultiTexCoord1iARB = (PFNGLMULTITEXCOORD1IARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1iARB")) == NULL) || r; - r = ((glMultiTexCoord1ivARB = (PFNGLMULTITEXCOORD1IVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1ivARB")) == NULL) || r; - r = ((glMultiTexCoord1sARB = (PFNGLMULTITEXCOORD1SARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1sARB")) == NULL) || r; - r = ((glMultiTexCoord1svARB = (PFNGLMULTITEXCOORD1SVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1svARB")) == NULL) || r; - r = ((glMultiTexCoord2dARB = (PFNGLMULTITEXCOORD2DARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2dARB")) == NULL) || r; - r = ((glMultiTexCoord2dvARB = (PFNGLMULTITEXCOORD2DVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2dvARB")) == NULL) || r; - r = ((glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2fARB")) == NULL) || r; - r = ((glMultiTexCoord2fvARB = (PFNGLMULTITEXCOORD2FVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2fvARB")) == NULL) || r; - r = ((glMultiTexCoord2iARB = (PFNGLMULTITEXCOORD2IARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2iARB")) == NULL) || r; - r = ((glMultiTexCoord2ivARB = (PFNGLMULTITEXCOORD2IVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2ivARB")) == NULL) || r; - r = ((glMultiTexCoord2sARB = (PFNGLMULTITEXCOORD2SARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2sARB")) == NULL) || r; - r = ((glMultiTexCoord2svARB = (PFNGLMULTITEXCOORD2SVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2svARB")) == NULL) || r; - r = ((glMultiTexCoord3dARB = (PFNGLMULTITEXCOORD3DARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3dARB")) == NULL) || r; - r = ((glMultiTexCoord3dvARB = (PFNGLMULTITEXCOORD3DVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3dvARB")) == NULL) || r; - r = ((glMultiTexCoord3fARB = (PFNGLMULTITEXCOORD3FARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3fARB")) == NULL) || r; - r = ((glMultiTexCoord3fvARB = (PFNGLMULTITEXCOORD3FVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3fvARB")) == NULL) || r; - r = ((glMultiTexCoord3iARB = (PFNGLMULTITEXCOORD3IARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3iARB")) == NULL) || r; - r = ((glMultiTexCoord3ivARB = (PFNGLMULTITEXCOORD3IVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3ivARB")) == NULL) || r; - r = ((glMultiTexCoord3sARB = (PFNGLMULTITEXCOORD3SARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3sARB")) == NULL) || r; - r = ((glMultiTexCoord3svARB = (PFNGLMULTITEXCOORD3SVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3svARB")) == NULL) || r; - r = ((glMultiTexCoord4dARB = (PFNGLMULTITEXCOORD4DARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4dARB")) == NULL) || r; - r = ((glMultiTexCoord4dvARB = (PFNGLMULTITEXCOORD4DVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4dvARB")) == NULL) || r; - r = ((glMultiTexCoord4fARB = (PFNGLMULTITEXCOORD4FARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4fARB")) == NULL) || r; - r = ((glMultiTexCoord4fvARB = (PFNGLMULTITEXCOORD4FVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4fvARB")) == NULL) || r; - r = ((glMultiTexCoord4iARB = (PFNGLMULTITEXCOORD4IARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4iARB")) == NULL) || r; - r = ((glMultiTexCoord4ivARB = (PFNGLMULTITEXCOORD4IVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4ivARB")) == NULL) || r; - r = ((glMultiTexCoord4sARB = (PFNGLMULTITEXCOORD4SARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4sARB")) == NULL) || r; - r = ((glMultiTexCoord4svARB = (PFNGLMULTITEXCOORD4SVARBPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4svARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_multitexture */ - -#ifdef GL_ARB_occlusion_query - -static GLboolean _glewInit_GL_ARB_occlusion_query (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBeginQueryARB = (PFNGLBEGINQUERYARBPROC)glewGetProcAddress((const GLubyte*)"glBeginQueryARB")) == NULL) || r; - r = ((glDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC)glewGetProcAddress((const GLubyte*)"glDeleteQueriesARB")) == NULL) || r; - r = ((glEndQueryARB = (PFNGLENDQUERYARBPROC)glewGetProcAddress((const GLubyte*)"glEndQueryARB")) == NULL) || r; - r = ((glGenQueriesARB = (PFNGLGENQUERIESARBPROC)glewGetProcAddress((const GLubyte*)"glGenQueriesARB")) == NULL) || r; - r = ((glGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectivARB")) == NULL) || r; - r = ((glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectuivARB")) == NULL) || r; - r = ((glGetQueryivARB = (PFNGLGETQUERYIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetQueryivARB")) == NULL) || r; - r = ((glIsQueryARB = (PFNGLISQUERYARBPROC)glewGetProcAddress((const GLubyte*)"glIsQueryARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_occlusion_query */ - -#ifdef GL_ARB_pixel_buffer_object - -#endif /* GL_ARB_pixel_buffer_object */ - -#ifdef GL_ARB_point_parameters - -static GLboolean _glewInit_GL_ARB_point_parameters (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glPointParameterfARB = (PFNGLPOINTPARAMETERFARBPROC)glewGetProcAddress((const GLubyte*)"glPointParameterfARB")) == NULL) || r; - r = ((glPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC)glewGetProcAddress((const GLubyte*)"glPointParameterfvARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_point_parameters */ - -#ifdef GL_ARB_point_sprite - -#endif /* GL_ARB_point_sprite */ - -#ifdef GL_ARB_shader_objects - -static GLboolean _glewInit_GL_ARB_shader_objects (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glAttachObjectARB")) == NULL) || r; - r = ((glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)glewGetProcAddress((const GLubyte*)"glCompileShaderARB")) == NULL) || r; - r = ((glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glCreateProgramObjectARB")) == NULL) || r; - r = ((glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glCreateShaderObjectARB")) == NULL) || r; - r = ((glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glDeleteObjectARB")) == NULL) || r; - r = ((glDetachObjectARB = (PFNGLDETACHOBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glDetachObjectARB")) == NULL) || r; - r = ((glGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC)glewGetProcAddress((const GLubyte*)"glGetActiveUniformARB")) == NULL) || r; - r = ((glGetAttachedObjectsARB = (PFNGLGETATTACHEDOBJECTSARBPROC)glewGetProcAddress((const GLubyte*)"glGetAttachedObjectsARB")) == NULL) || r; - r = ((glGetHandleARB = (PFNGLGETHANDLEARBPROC)glewGetProcAddress((const GLubyte*)"glGetHandleARB")) == NULL) || r; - r = ((glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)glewGetProcAddress((const GLubyte*)"glGetInfoLogARB")) == NULL) || r; - r = ((glGetObjectParameterfvARB = (PFNGLGETOBJECTPARAMETERFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetObjectParameterfvARB")) == NULL) || r; - r = ((glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetObjectParameterivARB")) == NULL) || r; - r = ((glGetShaderSourceARB = (PFNGLGETSHADERSOURCEARBPROC)glewGetProcAddress((const GLubyte*)"glGetShaderSourceARB")) == NULL) || r; - r = ((glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)glewGetProcAddress((const GLubyte*)"glGetUniformLocationARB")) == NULL) || r; - r = ((glGetUniformfvARB = (PFNGLGETUNIFORMFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetUniformfvARB")) == NULL) || r; - r = ((glGetUniformivARB = (PFNGLGETUNIFORMIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetUniformivARB")) == NULL) || r; - r = ((glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)glewGetProcAddress((const GLubyte*)"glLinkProgramARB")) == NULL) || r; - r = ((glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)glewGetProcAddress((const GLubyte*)"glShaderSourceARB")) == NULL) || r; - r = ((glUniform1fARB = (PFNGLUNIFORM1FARBPROC)glewGetProcAddress((const GLubyte*)"glUniform1fARB")) == NULL) || r; - r = ((glUniform1fvARB = (PFNGLUNIFORM1FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform1fvARB")) == NULL) || r; - r = ((glUniform1iARB = (PFNGLUNIFORM1IARBPROC)glewGetProcAddress((const GLubyte*)"glUniform1iARB")) == NULL) || r; - r = ((glUniform1ivARB = (PFNGLUNIFORM1IVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform1ivARB")) == NULL) || r; - r = ((glUniform2fARB = (PFNGLUNIFORM2FARBPROC)glewGetProcAddress((const GLubyte*)"glUniform2fARB")) == NULL) || r; - r = ((glUniform2fvARB = (PFNGLUNIFORM2FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform2fvARB")) == NULL) || r; - r = ((glUniform2iARB = (PFNGLUNIFORM2IARBPROC)glewGetProcAddress((const GLubyte*)"glUniform2iARB")) == NULL) || r; - r = ((glUniform2ivARB = (PFNGLUNIFORM2IVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform2ivARB")) == NULL) || r; - r = ((glUniform3fARB = (PFNGLUNIFORM3FARBPROC)glewGetProcAddress((const GLubyte*)"glUniform3fARB")) == NULL) || r; - r = ((glUniform3fvARB = (PFNGLUNIFORM3FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform3fvARB")) == NULL) || r; - r = ((glUniform3iARB = (PFNGLUNIFORM3IARBPROC)glewGetProcAddress((const GLubyte*)"glUniform3iARB")) == NULL) || r; - r = ((glUniform3ivARB = (PFNGLUNIFORM3IVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform3ivARB")) == NULL) || r; - r = ((glUniform4fARB = (PFNGLUNIFORM4FARBPROC)glewGetProcAddress((const GLubyte*)"glUniform4fARB")) == NULL) || r; - r = ((glUniform4fvARB = (PFNGLUNIFORM4FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform4fvARB")) == NULL) || r; - r = ((glUniform4iARB = (PFNGLUNIFORM4IARBPROC)glewGetProcAddress((const GLubyte*)"glUniform4iARB")) == NULL) || r; - r = ((glUniform4ivARB = (PFNGLUNIFORM4IVARBPROC)glewGetProcAddress((const GLubyte*)"glUniform4ivARB")) == NULL) || r; - r = ((glUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix2fvARB")) == NULL) || r; - r = ((glUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix3fvARB")) == NULL) || r; - r = ((glUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC)glewGetProcAddress((const GLubyte*)"glUniformMatrix4fvARB")) == NULL) || r; - r = ((glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)glewGetProcAddress((const GLubyte*)"glUseProgramObjectARB")) == NULL) || r; - r = ((glValidateProgramARB = (PFNGLVALIDATEPROGRAMARBPROC)glewGetProcAddress((const GLubyte*)"glValidateProgramARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_shader_objects */ - -#ifdef GL_ARB_shading_language_100 - -#endif /* GL_ARB_shading_language_100 */ - -#ifdef GL_ARB_shadow - -#endif /* GL_ARB_shadow */ - -#ifdef GL_ARB_shadow_ambient - -#endif /* GL_ARB_shadow_ambient */ - -#ifdef GL_ARB_texture_border_clamp - -#endif /* GL_ARB_texture_border_clamp */ - -#ifdef GL_ARB_texture_buffer_object - -static GLboolean _glewInit_GL_ARB_texture_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTexBufferARB = (PFNGLTEXBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"glTexBufferARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_texture_buffer_object */ - -#ifdef GL_ARB_texture_compression - -static GLboolean _glewInit_GL_ARB_texture_compression (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glCompressedTexImage1DARB = (PFNGLCOMPRESSEDTEXIMAGE1DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage1DARB")) == NULL) || r; - r = ((glCompressedTexImage2DARB = (PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage2DARB")) == NULL) || r; - r = ((glCompressedTexImage3DARB = (PFNGLCOMPRESSEDTEXIMAGE3DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexImage3DARB")) == NULL) || r; - r = ((glCompressedTexSubImage1DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage1DARB")) == NULL) || r; - r = ((glCompressedTexSubImage2DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage2DARB")) == NULL) || r; - r = ((glCompressedTexSubImage3DARB = (PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC)glewGetProcAddress((const GLubyte*)"glCompressedTexSubImage3DARB")) == NULL) || r; - r = ((glGetCompressedTexImageARB = (PFNGLGETCOMPRESSEDTEXIMAGEARBPROC)glewGetProcAddress((const GLubyte*)"glGetCompressedTexImageARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_texture_compression */ - -#ifdef GL_ARB_texture_compression_rgtc - -#endif /* GL_ARB_texture_compression_rgtc */ - -#ifdef GL_ARB_texture_cube_map - -#endif /* GL_ARB_texture_cube_map */ - -#ifdef GL_ARB_texture_env_add - -#endif /* GL_ARB_texture_env_add */ - -#ifdef GL_ARB_texture_env_combine - -#endif /* GL_ARB_texture_env_combine */ - -#ifdef GL_ARB_texture_env_crossbar - -#endif /* GL_ARB_texture_env_crossbar */ - -#ifdef GL_ARB_texture_env_dot3 - -#endif /* GL_ARB_texture_env_dot3 */ - -#ifdef GL_ARB_texture_float - -#endif /* GL_ARB_texture_float */ - -#ifdef GL_ARB_texture_mirrored_repeat - -#endif /* GL_ARB_texture_mirrored_repeat */ - -#ifdef GL_ARB_texture_non_power_of_two - -#endif /* GL_ARB_texture_non_power_of_two */ - -#ifdef GL_ARB_texture_rectangle - -#endif /* GL_ARB_texture_rectangle */ - -#ifdef GL_ARB_texture_rg - -#endif /* GL_ARB_texture_rg */ - -#ifdef GL_ARB_transpose_matrix - -static GLboolean _glewInit_GL_ARB_transpose_matrix (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glLoadTransposeMatrixdARB = (PFNGLLOADTRANSPOSEMATRIXDARBPROC)glewGetProcAddress((const GLubyte*)"glLoadTransposeMatrixdARB")) == NULL) || r; - r = ((glLoadTransposeMatrixfARB = (PFNGLLOADTRANSPOSEMATRIXFARBPROC)glewGetProcAddress((const GLubyte*)"glLoadTransposeMatrixfARB")) == NULL) || r; - r = ((glMultTransposeMatrixdARB = (PFNGLMULTTRANSPOSEMATRIXDARBPROC)glewGetProcAddress((const GLubyte*)"glMultTransposeMatrixdARB")) == NULL) || r; - r = ((glMultTransposeMatrixfARB = (PFNGLMULTTRANSPOSEMATRIXFARBPROC)glewGetProcAddress((const GLubyte*)"glMultTransposeMatrixfARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_transpose_matrix */ - -#ifdef GL_ARB_vertex_array_object - -static GLboolean _glewInit_GL_ARB_vertex_array_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)glewGetProcAddress((const GLubyte*)"glBindVertexArray")) == NULL) || r; - r = ((glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)glewGetProcAddress((const GLubyte*)"glDeleteVertexArrays")) == NULL) || r; - r = ((glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)glewGetProcAddress((const GLubyte*)"glGenVertexArrays")) == NULL) || r; - r = ((glIsVertexArray = (PFNGLISVERTEXARRAYPROC)glewGetProcAddress((const GLubyte*)"glIsVertexArray")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_vertex_array_object */ - -#ifdef GL_ARB_vertex_blend - -static GLboolean _glewInit_GL_ARB_vertex_blend (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glVertexBlendARB = (PFNGLVERTEXBLENDARBPROC)glewGetProcAddress((const GLubyte*)"glVertexBlendARB")) == NULL) || r; - r = ((glWeightPointerARB = (PFNGLWEIGHTPOINTERARBPROC)glewGetProcAddress((const GLubyte*)"glWeightPointerARB")) == NULL) || r; - r = ((glWeightbvARB = (PFNGLWEIGHTBVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightbvARB")) == NULL) || r; - r = ((glWeightdvARB = (PFNGLWEIGHTDVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightdvARB")) == NULL) || r; - r = ((glWeightfvARB = (PFNGLWEIGHTFVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightfvARB")) == NULL) || r; - r = ((glWeightivARB = (PFNGLWEIGHTIVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightivARB")) == NULL) || r; - r = ((glWeightsvARB = (PFNGLWEIGHTSVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightsvARB")) == NULL) || r; - r = ((glWeightubvARB = (PFNGLWEIGHTUBVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightubvARB")) == NULL) || r; - r = ((glWeightuivARB = (PFNGLWEIGHTUIVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightuivARB")) == NULL) || r; - r = ((glWeightusvARB = (PFNGLWEIGHTUSVARBPROC)glewGetProcAddress((const GLubyte*)"glWeightusvARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_vertex_blend */ - -#ifdef GL_ARB_vertex_buffer_object - -static GLboolean _glewInit_GL_ARB_vertex_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindBufferARB = (PFNGLBINDBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"glBindBufferARB")) == NULL) || r; - r = ((glBufferDataARB = (PFNGLBUFFERDATAARBPROC)glewGetProcAddress((const GLubyte*)"glBufferDataARB")) == NULL) || r; - r = ((glBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC)glewGetProcAddress((const GLubyte*)"glBufferSubDataARB")) == NULL) || r; - r = ((glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)glewGetProcAddress((const GLubyte*)"glDeleteBuffersARB")) == NULL) || r; - r = ((glGenBuffersARB = (PFNGLGENBUFFERSARBPROC)glewGetProcAddress((const GLubyte*)"glGenBuffersARB")) == NULL) || r; - r = ((glGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetBufferParameterivARB")) == NULL) || r; - r = ((glGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC)glewGetProcAddress((const GLubyte*)"glGetBufferPointervARB")) == NULL) || r; - r = ((glGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC)glewGetProcAddress((const GLubyte*)"glGetBufferSubDataARB")) == NULL) || r; - r = ((glIsBufferARB = (PFNGLISBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"glIsBufferARB")) == NULL) || r; - r = ((glMapBufferARB = (PFNGLMAPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"glMapBufferARB")) == NULL) || r; - r = ((glUnmapBufferARB = (PFNGLUNMAPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"glUnmapBufferARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_vertex_buffer_object */ - -#ifdef GL_ARB_vertex_program - -static GLboolean _glewInit_GL_ARB_vertex_program (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindProgramARB = (PFNGLBINDPROGRAMARBPROC)glewGetProcAddress((const GLubyte*)"glBindProgramARB")) == NULL) || r; - r = ((glDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC)glewGetProcAddress((const GLubyte*)"glDeleteProgramsARB")) == NULL) || r; - r = ((glDisableVertexAttribArrayARB = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)glewGetProcAddress((const GLubyte*)"glDisableVertexAttribArrayARB")) == NULL) || r; - r = ((glEnableVertexAttribArrayARB = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)glewGetProcAddress((const GLubyte*)"glEnableVertexAttribArrayARB")) == NULL) || r; - r = ((glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC)glewGetProcAddress((const GLubyte*)"glGenProgramsARB")) == NULL) || r; - r = ((glGetProgramEnvParameterdvARB = (PFNGLGETPROGRAMENVPARAMETERDVARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramEnvParameterdvARB")) == NULL) || r; - r = ((glGetProgramEnvParameterfvARB = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramEnvParameterfvARB")) == NULL) || r; - r = ((glGetProgramLocalParameterdvARB = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramLocalParameterdvARB")) == NULL) || r; - r = ((glGetProgramLocalParameterfvARB = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramLocalParameterfvARB")) == NULL) || r; - r = ((glGetProgramStringARB = (PFNGLGETPROGRAMSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramStringARB")) == NULL) || r; - r = ((glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetProgramivARB")) == NULL) || r; - r = ((glGetVertexAttribPointervARB = (PFNGLGETVERTEXATTRIBPOINTERVARBPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribPointervARB")) == NULL) || r; - r = ((glGetVertexAttribdvARB = (PFNGLGETVERTEXATTRIBDVARBPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribdvARB")) == NULL) || r; - r = ((glGetVertexAttribfvARB = (PFNGLGETVERTEXATTRIBFVARBPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribfvARB")) == NULL) || r; - r = ((glGetVertexAttribivARB = (PFNGLGETVERTEXATTRIBIVARBPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribivARB")) == NULL) || r; - r = ((glIsProgramARB = (PFNGLISPROGRAMARBPROC)glewGetProcAddress((const GLubyte*)"glIsProgramARB")) == NULL) || r; - r = ((glProgramEnvParameter4dARB = (PFNGLPROGRAMENVPARAMETER4DARBPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameter4dARB")) == NULL) || r; - r = ((glProgramEnvParameter4dvARB = (PFNGLPROGRAMENVPARAMETER4DVARBPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameter4dvARB")) == NULL) || r; - r = ((glProgramEnvParameter4fARB = (PFNGLPROGRAMENVPARAMETER4FARBPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameter4fARB")) == NULL) || r; - r = ((glProgramEnvParameter4fvARB = (PFNGLPROGRAMENVPARAMETER4FVARBPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameter4fvARB")) == NULL) || r; - r = ((glProgramLocalParameter4dARB = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameter4dARB")) == NULL) || r; - r = ((glProgramLocalParameter4dvARB = (PFNGLPROGRAMLOCALPARAMETER4DVARBPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameter4dvARB")) == NULL) || r; - r = ((glProgramLocalParameter4fARB = (PFNGLPROGRAMLOCALPARAMETER4FARBPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameter4fARB")) == NULL) || r; - r = ((glProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameter4fvARB")) == NULL) || r; - r = ((glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"glProgramStringARB")) == NULL) || r; - r = ((glVertexAttrib1dARB = (PFNGLVERTEXATTRIB1DARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1dARB")) == NULL) || r; - r = ((glVertexAttrib1dvARB = (PFNGLVERTEXATTRIB1DVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1dvARB")) == NULL) || r; - r = ((glVertexAttrib1fARB = (PFNGLVERTEXATTRIB1FARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1fARB")) == NULL) || r; - r = ((glVertexAttrib1fvARB = (PFNGLVERTEXATTRIB1FVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1fvARB")) == NULL) || r; - r = ((glVertexAttrib1sARB = (PFNGLVERTEXATTRIB1SARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1sARB")) == NULL) || r; - r = ((glVertexAttrib1svARB = (PFNGLVERTEXATTRIB1SVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1svARB")) == NULL) || r; - r = ((glVertexAttrib2dARB = (PFNGLVERTEXATTRIB2DARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2dARB")) == NULL) || r; - r = ((glVertexAttrib2dvARB = (PFNGLVERTEXATTRIB2DVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2dvARB")) == NULL) || r; - r = ((glVertexAttrib2fARB = (PFNGLVERTEXATTRIB2FARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2fARB")) == NULL) || r; - r = ((glVertexAttrib2fvARB = (PFNGLVERTEXATTRIB2FVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2fvARB")) == NULL) || r; - r = ((glVertexAttrib2sARB = (PFNGLVERTEXATTRIB2SARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2sARB")) == NULL) || r; - r = ((glVertexAttrib2svARB = (PFNGLVERTEXATTRIB2SVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2svARB")) == NULL) || r; - r = ((glVertexAttrib3dARB = (PFNGLVERTEXATTRIB3DARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3dARB")) == NULL) || r; - r = ((glVertexAttrib3dvARB = (PFNGLVERTEXATTRIB3DVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3dvARB")) == NULL) || r; - r = ((glVertexAttrib3fARB = (PFNGLVERTEXATTRIB3FARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3fARB")) == NULL) || r; - r = ((glVertexAttrib3fvARB = (PFNGLVERTEXATTRIB3FVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3fvARB")) == NULL) || r; - r = ((glVertexAttrib3sARB = (PFNGLVERTEXATTRIB3SARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3sARB")) == NULL) || r; - r = ((glVertexAttrib3svARB = (PFNGLVERTEXATTRIB3SVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3svARB")) == NULL) || r; - r = ((glVertexAttrib4NbvARB = (PFNGLVERTEXATTRIB4NBVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NbvARB")) == NULL) || r; - r = ((glVertexAttrib4NivARB = (PFNGLVERTEXATTRIB4NIVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NivARB")) == NULL) || r; - r = ((glVertexAttrib4NsvARB = (PFNGLVERTEXATTRIB4NSVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NsvARB")) == NULL) || r; - r = ((glVertexAttrib4NubARB = (PFNGLVERTEXATTRIB4NUBARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NubARB")) == NULL) || r; - r = ((glVertexAttrib4NubvARB = (PFNGLVERTEXATTRIB4NUBVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NubvARB")) == NULL) || r; - r = ((glVertexAttrib4NuivARB = (PFNGLVERTEXATTRIB4NUIVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NuivARB")) == NULL) || r; - r = ((glVertexAttrib4NusvARB = (PFNGLVERTEXATTRIB4NUSVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4NusvARB")) == NULL) || r; - r = ((glVertexAttrib4bvARB = (PFNGLVERTEXATTRIB4BVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4bvARB")) == NULL) || r; - r = ((glVertexAttrib4dARB = (PFNGLVERTEXATTRIB4DARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4dARB")) == NULL) || r; - r = ((glVertexAttrib4dvARB = (PFNGLVERTEXATTRIB4DVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4dvARB")) == NULL) || r; - r = ((glVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4fARB")) == NULL) || r; - r = ((glVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4fvARB")) == NULL) || r; - r = ((glVertexAttrib4ivARB = (PFNGLVERTEXATTRIB4IVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4ivARB")) == NULL) || r; - r = ((glVertexAttrib4sARB = (PFNGLVERTEXATTRIB4SARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4sARB")) == NULL) || r; - r = ((glVertexAttrib4svARB = (PFNGLVERTEXATTRIB4SVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4svARB")) == NULL) || r; - r = ((glVertexAttrib4ubvARB = (PFNGLVERTEXATTRIB4UBVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4ubvARB")) == NULL) || r; - r = ((glVertexAttrib4uivARB = (PFNGLVERTEXATTRIB4UIVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4uivARB")) == NULL) || r; - r = ((glVertexAttrib4usvARB = (PFNGLVERTEXATTRIB4USVARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4usvARB")) == NULL) || r; - r = ((glVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribPointerARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_vertex_program */ - -#ifdef GL_ARB_vertex_shader - -static GLboolean _glewInit_GL_ARB_vertex_shader (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC)glewGetProcAddress((const GLubyte*)"glBindAttribLocationARB")) == NULL) || r; - r = ((glGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC)glewGetProcAddress((const GLubyte*)"glGetActiveAttribARB")) == NULL) || r; - r = ((glGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC)glewGetProcAddress((const GLubyte*)"glGetAttribLocationARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_vertex_shader */ - -#ifdef GL_ARB_window_pos - -static GLboolean _glewInit_GL_ARB_window_pos (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glWindowPos2dARB = (PFNGLWINDOWPOS2DARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2dARB")) == NULL) || r; - r = ((glWindowPos2dvARB = (PFNGLWINDOWPOS2DVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2dvARB")) == NULL) || r; - r = ((glWindowPos2fARB = (PFNGLWINDOWPOS2FARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2fARB")) == NULL) || r; - r = ((glWindowPos2fvARB = (PFNGLWINDOWPOS2FVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2fvARB")) == NULL) || r; - r = ((glWindowPos2iARB = (PFNGLWINDOWPOS2IARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2iARB")) == NULL) || r; - r = ((glWindowPos2ivARB = (PFNGLWINDOWPOS2IVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2ivARB")) == NULL) || r; - r = ((glWindowPos2sARB = (PFNGLWINDOWPOS2SARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2sARB")) == NULL) || r; - r = ((glWindowPos2svARB = (PFNGLWINDOWPOS2SVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2svARB")) == NULL) || r; - r = ((glWindowPos3dARB = (PFNGLWINDOWPOS3DARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3dARB")) == NULL) || r; - r = ((glWindowPos3dvARB = (PFNGLWINDOWPOS3DVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3dvARB")) == NULL) || r; - r = ((glWindowPos3fARB = (PFNGLWINDOWPOS3FARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3fARB")) == NULL) || r; - r = ((glWindowPos3fvARB = (PFNGLWINDOWPOS3FVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3fvARB")) == NULL) || r; - r = ((glWindowPos3iARB = (PFNGLWINDOWPOS3IARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3iARB")) == NULL) || r; - r = ((glWindowPos3ivARB = (PFNGLWINDOWPOS3IVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3ivARB")) == NULL) || r; - r = ((glWindowPos3sARB = (PFNGLWINDOWPOS3SARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3sARB")) == NULL) || r; - r = ((glWindowPos3svARB = (PFNGLWINDOWPOS3SVARBPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3svARB")) == NULL) || r; - - return r; -} - -#endif /* GL_ARB_window_pos */ - -#ifdef GL_ATIX_point_sprites - -#endif /* GL_ATIX_point_sprites */ - -#ifdef GL_ATIX_texture_env_combine3 - -#endif /* GL_ATIX_texture_env_combine3 */ - -#ifdef GL_ATIX_texture_env_route - -#endif /* GL_ATIX_texture_env_route */ - -#ifdef GL_ATIX_vertex_shader_output_point_size - -#endif /* GL_ATIX_vertex_shader_output_point_size */ - -#ifdef GL_ATI_draw_buffers - -static GLboolean _glewInit_GL_ATI_draw_buffers (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDrawBuffersATI = (PFNGLDRAWBUFFERSATIPROC)glewGetProcAddress((const GLubyte*)"glDrawBuffersATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_draw_buffers */ - -#ifdef GL_ATI_element_array - -static GLboolean _glewInit_GL_ATI_element_array (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDrawElementArrayATI = (PFNGLDRAWELEMENTARRAYATIPROC)glewGetProcAddress((const GLubyte*)"glDrawElementArrayATI")) == NULL) || r; - r = ((glDrawRangeElementArrayATI = (PFNGLDRAWRANGEELEMENTARRAYATIPROC)glewGetProcAddress((const GLubyte*)"glDrawRangeElementArrayATI")) == NULL) || r; - r = ((glElementPointerATI = (PFNGLELEMENTPOINTERATIPROC)glewGetProcAddress((const GLubyte*)"glElementPointerATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_element_array */ - -#ifdef GL_ATI_envmap_bumpmap - -static GLboolean _glewInit_GL_ATI_envmap_bumpmap (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetTexBumpParameterfvATI = (PFNGLGETTEXBUMPPARAMETERFVATIPROC)glewGetProcAddress((const GLubyte*)"glGetTexBumpParameterfvATI")) == NULL) || r; - r = ((glGetTexBumpParameterivATI = (PFNGLGETTEXBUMPPARAMETERIVATIPROC)glewGetProcAddress((const GLubyte*)"glGetTexBumpParameterivATI")) == NULL) || r; - r = ((glTexBumpParameterfvATI = (PFNGLTEXBUMPPARAMETERFVATIPROC)glewGetProcAddress((const GLubyte*)"glTexBumpParameterfvATI")) == NULL) || r; - r = ((glTexBumpParameterivATI = (PFNGLTEXBUMPPARAMETERIVATIPROC)glewGetProcAddress((const GLubyte*)"glTexBumpParameterivATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_envmap_bumpmap */ - -#ifdef GL_ATI_fragment_shader - -static GLboolean _glewInit_GL_ATI_fragment_shader (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glAlphaFragmentOp1ATI = (PFNGLALPHAFRAGMENTOP1ATIPROC)glewGetProcAddress((const GLubyte*)"glAlphaFragmentOp1ATI")) == NULL) || r; - r = ((glAlphaFragmentOp2ATI = (PFNGLALPHAFRAGMENTOP2ATIPROC)glewGetProcAddress((const GLubyte*)"glAlphaFragmentOp2ATI")) == NULL) || r; - r = ((glAlphaFragmentOp3ATI = (PFNGLALPHAFRAGMENTOP3ATIPROC)glewGetProcAddress((const GLubyte*)"glAlphaFragmentOp3ATI")) == NULL) || r; - r = ((glBeginFragmentShaderATI = (PFNGLBEGINFRAGMENTSHADERATIPROC)glewGetProcAddress((const GLubyte*)"glBeginFragmentShaderATI")) == NULL) || r; - r = ((glBindFragmentShaderATI = (PFNGLBINDFRAGMENTSHADERATIPROC)glewGetProcAddress((const GLubyte*)"glBindFragmentShaderATI")) == NULL) || r; - r = ((glColorFragmentOp1ATI = (PFNGLCOLORFRAGMENTOP1ATIPROC)glewGetProcAddress((const GLubyte*)"glColorFragmentOp1ATI")) == NULL) || r; - r = ((glColorFragmentOp2ATI = (PFNGLCOLORFRAGMENTOP2ATIPROC)glewGetProcAddress((const GLubyte*)"glColorFragmentOp2ATI")) == NULL) || r; - r = ((glColorFragmentOp3ATI = (PFNGLCOLORFRAGMENTOP3ATIPROC)glewGetProcAddress((const GLubyte*)"glColorFragmentOp3ATI")) == NULL) || r; - r = ((glDeleteFragmentShaderATI = (PFNGLDELETEFRAGMENTSHADERATIPROC)glewGetProcAddress((const GLubyte*)"glDeleteFragmentShaderATI")) == NULL) || r; - r = ((glEndFragmentShaderATI = (PFNGLENDFRAGMENTSHADERATIPROC)glewGetProcAddress((const GLubyte*)"glEndFragmentShaderATI")) == NULL) || r; - r = ((glGenFragmentShadersATI = (PFNGLGENFRAGMENTSHADERSATIPROC)glewGetProcAddress((const GLubyte*)"glGenFragmentShadersATI")) == NULL) || r; - r = ((glPassTexCoordATI = (PFNGLPASSTEXCOORDATIPROC)glewGetProcAddress((const GLubyte*)"glPassTexCoordATI")) == NULL) || r; - r = ((glSampleMapATI = (PFNGLSAMPLEMAPATIPROC)glewGetProcAddress((const GLubyte*)"glSampleMapATI")) == NULL) || r; - r = ((glSetFragmentShaderConstantATI = (PFNGLSETFRAGMENTSHADERCONSTANTATIPROC)glewGetProcAddress((const GLubyte*)"glSetFragmentShaderConstantATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_fragment_shader */ - -#ifdef GL_ATI_map_object_buffer - -static GLboolean _glewInit_GL_ATI_map_object_buffer (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glMapObjectBufferATI = (PFNGLMAPOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glMapObjectBufferATI")) == NULL) || r; - r = ((glUnmapObjectBufferATI = (PFNGLUNMAPOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glUnmapObjectBufferATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_map_object_buffer */ - -#ifdef GL_ATI_pn_triangles - -static GLboolean _glewInit_GL_ATI_pn_triangles (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glPNTrianglesfATI = (PFNGLPNTRIANGLESFATIPROC)glewGetProcAddress((const GLubyte*)"glPNTrianglesfATI")) == NULL) || r; - r = ((glPNTrianglesiATI = (PFNGLPNTRIANGLESIATIPROC)glewGetProcAddress((const GLubyte*)"glPNTrianglesiATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_pn_triangles */ - -#ifdef GL_ATI_separate_stencil - -static GLboolean _glewInit_GL_ATI_separate_stencil (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glStencilFuncSeparateATI = (PFNGLSTENCILFUNCSEPARATEATIPROC)glewGetProcAddress((const GLubyte*)"glStencilFuncSeparateATI")) == NULL) || r; - r = ((glStencilOpSeparateATI = (PFNGLSTENCILOPSEPARATEATIPROC)glewGetProcAddress((const GLubyte*)"glStencilOpSeparateATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_separate_stencil */ - -#ifdef GL_ATI_shader_texture_lod - -#endif /* GL_ATI_shader_texture_lod */ - -#ifdef GL_ATI_text_fragment_shader - -#endif /* GL_ATI_text_fragment_shader */ - -#ifdef GL_ATI_texture_compression_3dc - -#endif /* GL_ATI_texture_compression_3dc */ - -#ifdef GL_ATI_texture_env_combine3 - -#endif /* GL_ATI_texture_env_combine3 */ - -#ifdef GL_ATI_texture_float - -#endif /* GL_ATI_texture_float */ - -#ifdef GL_ATI_texture_mirror_once - -#endif /* GL_ATI_texture_mirror_once */ - -#ifdef GL_ATI_vertex_array_object - -static GLboolean _glewInit_GL_ATI_vertex_array_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glArrayObjectATI = (PFNGLARRAYOBJECTATIPROC)glewGetProcAddress((const GLubyte*)"glArrayObjectATI")) == NULL) || r; - r = ((glFreeObjectBufferATI = (PFNGLFREEOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glFreeObjectBufferATI")) == NULL) || r; - r = ((glGetArrayObjectfvATI = (PFNGLGETARRAYOBJECTFVATIPROC)glewGetProcAddress((const GLubyte*)"glGetArrayObjectfvATI")) == NULL) || r; - r = ((glGetArrayObjectivATI = (PFNGLGETARRAYOBJECTIVATIPROC)glewGetProcAddress((const GLubyte*)"glGetArrayObjectivATI")) == NULL) || r; - r = ((glGetObjectBufferfvATI = (PFNGLGETOBJECTBUFFERFVATIPROC)glewGetProcAddress((const GLubyte*)"glGetObjectBufferfvATI")) == NULL) || r; - r = ((glGetObjectBufferivATI = (PFNGLGETOBJECTBUFFERIVATIPROC)glewGetProcAddress((const GLubyte*)"glGetObjectBufferivATI")) == NULL) || r; - r = ((glGetVariantArrayObjectfvATI = (PFNGLGETVARIANTARRAYOBJECTFVATIPROC)glewGetProcAddress((const GLubyte*)"glGetVariantArrayObjectfvATI")) == NULL) || r; - r = ((glGetVariantArrayObjectivATI = (PFNGLGETVARIANTARRAYOBJECTIVATIPROC)glewGetProcAddress((const GLubyte*)"glGetVariantArrayObjectivATI")) == NULL) || r; - r = ((glIsObjectBufferATI = (PFNGLISOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glIsObjectBufferATI")) == NULL) || r; - r = ((glNewObjectBufferATI = (PFNGLNEWOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glNewObjectBufferATI")) == NULL) || r; - r = ((glUpdateObjectBufferATI = (PFNGLUPDATEOBJECTBUFFERATIPROC)glewGetProcAddress((const GLubyte*)"glUpdateObjectBufferATI")) == NULL) || r; - r = ((glVariantArrayObjectATI = (PFNGLVARIANTARRAYOBJECTATIPROC)glewGetProcAddress((const GLubyte*)"glVariantArrayObjectATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_vertex_array_object */ - -#ifdef GL_ATI_vertex_attrib_array_object - -static GLboolean _glewInit_GL_ATI_vertex_attrib_array_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetVertexAttribArrayObjectfvATI = (PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribArrayObjectfvATI")) == NULL) || r; - r = ((glGetVertexAttribArrayObjectivATI = (PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribArrayObjectivATI")) == NULL) || r; - r = ((glVertexAttribArrayObjectATI = (PFNGLVERTEXATTRIBARRAYOBJECTATIPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribArrayObjectATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_vertex_attrib_array_object */ - -#ifdef GL_ATI_vertex_streams - -static GLboolean _glewInit_GL_ATI_vertex_streams (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glClientActiveVertexStreamATI = (PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC)glewGetProcAddress((const GLubyte*)"glClientActiveVertexStreamATI")) == NULL) || r; - r = ((glNormalStream3bATI = (PFNGLNORMALSTREAM3BATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3bATI")) == NULL) || r; - r = ((glNormalStream3bvATI = (PFNGLNORMALSTREAM3BVATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3bvATI")) == NULL) || r; - r = ((glNormalStream3dATI = (PFNGLNORMALSTREAM3DATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3dATI")) == NULL) || r; - r = ((glNormalStream3dvATI = (PFNGLNORMALSTREAM3DVATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3dvATI")) == NULL) || r; - r = ((glNormalStream3fATI = (PFNGLNORMALSTREAM3FATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3fATI")) == NULL) || r; - r = ((glNormalStream3fvATI = (PFNGLNORMALSTREAM3FVATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3fvATI")) == NULL) || r; - r = ((glNormalStream3iATI = (PFNGLNORMALSTREAM3IATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3iATI")) == NULL) || r; - r = ((glNormalStream3ivATI = (PFNGLNORMALSTREAM3IVATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3ivATI")) == NULL) || r; - r = ((glNormalStream3sATI = (PFNGLNORMALSTREAM3SATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3sATI")) == NULL) || r; - r = ((glNormalStream3svATI = (PFNGLNORMALSTREAM3SVATIPROC)glewGetProcAddress((const GLubyte*)"glNormalStream3svATI")) == NULL) || r; - r = ((glVertexBlendEnvfATI = (PFNGLVERTEXBLENDENVFATIPROC)glewGetProcAddress((const GLubyte*)"glVertexBlendEnvfATI")) == NULL) || r; - r = ((glVertexBlendEnviATI = (PFNGLVERTEXBLENDENVIATIPROC)glewGetProcAddress((const GLubyte*)"glVertexBlendEnviATI")) == NULL) || r; - r = ((glVertexStream2dATI = (PFNGLVERTEXSTREAM2DATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2dATI")) == NULL) || r; - r = ((glVertexStream2dvATI = (PFNGLVERTEXSTREAM2DVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2dvATI")) == NULL) || r; - r = ((glVertexStream2fATI = (PFNGLVERTEXSTREAM2FATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2fATI")) == NULL) || r; - r = ((glVertexStream2fvATI = (PFNGLVERTEXSTREAM2FVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2fvATI")) == NULL) || r; - r = ((glVertexStream2iATI = (PFNGLVERTEXSTREAM2IATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2iATI")) == NULL) || r; - r = ((glVertexStream2ivATI = (PFNGLVERTEXSTREAM2IVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2ivATI")) == NULL) || r; - r = ((glVertexStream2sATI = (PFNGLVERTEXSTREAM2SATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2sATI")) == NULL) || r; - r = ((glVertexStream2svATI = (PFNGLVERTEXSTREAM2SVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream2svATI")) == NULL) || r; - r = ((glVertexStream3dATI = (PFNGLVERTEXSTREAM3DATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3dATI")) == NULL) || r; - r = ((glVertexStream3dvATI = (PFNGLVERTEXSTREAM3DVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3dvATI")) == NULL) || r; - r = ((glVertexStream3fATI = (PFNGLVERTEXSTREAM3FATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3fATI")) == NULL) || r; - r = ((glVertexStream3fvATI = (PFNGLVERTEXSTREAM3FVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3fvATI")) == NULL) || r; - r = ((glVertexStream3iATI = (PFNGLVERTEXSTREAM3IATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3iATI")) == NULL) || r; - r = ((glVertexStream3ivATI = (PFNGLVERTEXSTREAM3IVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3ivATI")) == NULL) || r; - r = ((glVertexStream3sATI = (PFNGLVERTEXSTREAM3SATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3sATI")) == NULL) || r; - r = ((glVertexStream3svATI = (PFNGLVERTEXSTREAM3SVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream3svATI")) == NULL) || r; - r = ((glVertexStream4dATI = (PFNGLVERTEXSTREAM4DATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4dATI")) == NULL) || r; - r = ((glVertexStream4dvATI = (PFNGLVERTEXSTREAM4DVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4dvATI")) == NULL) || r; - r = ((glVertexStream4fATI = (PFNGLVERTEXSTREAM4FATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4fATI")) == NULL) || r; - r = ((glVertexStream4fvATI = (PFNGLVERTEXSTREAM4FVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4fvATI")) == NULL) || r; - r = ((glVertexStream4iATI = (PFNGLVERTEXSTREAM4IATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4iATI")) == NULL) || r; - r = ((glVertexStream4ivATI = (PFNGLVERTEXSTREAM4IVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4ivATI")) == NULL) || r; - r = ((glVertexStream4sATI = (PFNGLVERTEXSTREAM4SATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4sATI")) == NULL) || r; - r = ((glVertexStream4svATI = (PFNGLVERTEXSTREAM4SVATIPROC)glewGetProcAddress((const GLubyte*)"glVertexStream4svATI")) == NULL) || r; - - return r; -} - -#endif /* GL_ATI_vertex_streams */ - -#ifdef GL_EXT_422_pixels - -#endif /* GL_EXT_422_pixels */ - -#ifdef GL_EXT_Cg_shader - -#endif /* GL_EXT_Cg_shader */ - -#ifdef GL_EXT_abgr - -#endif /* GL_EXT_abgr */ - -#ifdef GL_EXT_bgra - -#endif /* GL_EXT_bgra */ - -#ifdef GL_EXT_bindable_uniform - -static GLboolean _glewInit_GL_EXT_bindable_uniform (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetUniformBufferSizeEXT = (PFNGLGETUNIFORMBUFFERSIZEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetUniformBufferSizeEXT")) == NULL) || r; - r = ((glGetUniformOffsetEXT = (PFNGLGETUNIFORMOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glGetUniformOffsetEXT")) == NULL) || r; - r = ((glUniformBufferEXT = (PFNGLUNIFORMBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glUniformBufferEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_bindable_uniform */ - -#ifdef GL_EXT_blend_color - -static GLboolean _glewInit_GL_EXT_blend_color (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBlendColorEXT = (PFNGLBLENDCOLOREXTPROC)glewGetProcAddress((const GLubyte*)"glBlendColorEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_blend_color */ - -#ifdef GL_EXT_blend_equation_separate - -static GLboolean _glewInit_GL_EXT_blend_equation_separate (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBlendEquationSeparateEXT = (PFNGLBLENDEQUATIONSEPARATEEXTPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationSeparateEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_blend_equation_separate */ - -#ifdef GL_EXT_blend_func_separate - -static GLboolean _glewInit_GL_EXT_blend_func_separate (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBlendFuncSeparateEXT = (PFNGLBLENDFUNCSEPARATEEXTPROC)glewGetProcAddress((const GLubyte*)"glBlendFuncSeparateEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_blend_func_separate */ - -#ifdef GL_EXT_blend_logic_op - -#endif /* GL_EXT_blend_logic_op */ - -#ifdef GL_EXT_blend_minmax - -static GLboolean _glewInit_GL_EXT_blend_minmax (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBlendEquationEXT = (PFNGLBLENDEQUATIONEXTPROC)glewGetProcAddress((const GLubyte*)"glBlendEquationEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_blend_minmax */ - -#ifdef GL_EXT_blend_subtract - -#endif /* GL_EXT_blend_subtract */ - -#ifdef GL_EXT_clip_volume_hint - -#endif /* GL_EXT_clip_volume_hint */ - -#ifdef GL_EXT_cmyka - -#endif /* GL_EXT_cmyka */ - -#ifdef GL_EXT_color_subtable - -static GLboolean _glewInit_GL_EXT_color_subtable (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glColorSubTableEXT = (PFNGLCOLORSUBTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"glColorSubTableEXT")) == NULL) || r; - r = ((glCopyColorSubTableEXT = (PFNGLCOPYCOLORSUBTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyColorSubTableEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_color_subtable */ - -#ifdef GL_EXT_compiled_vertex_array - -static GLboolean _glewInit_GL_EXT_compiled_vertex_array (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glLockArraysEXT = (PFNGLLOCKARRAYSEXTPROC)glewGetProcAddress((const GLubyte*)"glLockArraysEXT")) == NULL) || r; - r = ((glUnlockArraysEXT = (PFNGLUNLOCKARRAYSEXTPROC)glewGetProcAddress((const GLubyte*)"glUnlockArraysEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_compiled_vertex_array */ - -#ifdef GL_EXT_convolution - -static GLboolean _glewInit_GL_EXT_convolution (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glConvolutionFilter1DEXT = (PFNGLCONVOLUTIONFILTER1DEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionFilter1DEXT")) == NULL) || r; - r = ((glConvolutionFilter2DEXT = (PFNGLCONVOLUTIONFILTER2DEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionFilter2DEXT")) == NULL) || r; - r = ((glConvolutionParameterfEXT = (PFNGLCONVOLUTIONPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameterfEXT")) == NULL) || r; - r = ((glConvolutionParameterfvEXT = (PFNGLCONVOLUTIONPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameterfvEXT")) == NULL) || r; - r = ((glConvolutionParameteriEXT = (PFNGLCONVOLUTIONPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameteriEXT")) == NULL) || r; - r = ((glConvolutionParameterivEXT = (PFNGLCONVOLUTIONPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glConvolutionParameterivEXT")) == NULL) || r; - r = ((glCopyConvolutionFilter1DEXT = (PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyConvolutionFilter1DEXT")) == NULL) || r; - r = ((glCopyConvolutionFilter2DEXT = (PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyConvolutionFilter2DEXT")) == NULL) || r; - r = ((glGetConvolutionFilterEXT = (PFNGLGETCONVOLUTIONFILTEREXTPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionFilterEXT")) == NULL) || r; - r = ((glGetConvolutionParameterfvEXT = (PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionParameterfvEXT")) == NULL) || r; - r = ((glGetConvolutionParameterivEXT = (PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetConvolutionParameterivEXT")) == NULL) || r; - r = ((glGetSeparableFilterEXT = (PFNGLGETSEPARABLEFILTEREXTPROC)glewGetProcAddress((const GLubyte*)"glGetSeparableFilterEXT")) == NULL) || r; - r = ((glSeparableFilter2DEXT = (PFNGLSEPARABLEFILTER2DEXTPROC)glewGetProcAddress((const GLubyte*)"glSeparableFilter2DEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_convolution */ - -#ifdef GL_EXT_coordinate_frame - -static GLboolean _glewInit_GL_EXT_coordinate_frame (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBinormalPointerEXT = (PFNGLBINORMALPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glBinormalPointerEXT")) == NULL) || r; - r = ((glTangentPointerEXT = (PFNGLTANGENTPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glTangentPointerEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_coordinate_frame */ - -#ifdef GL_EXT_copy_texture - -static GLboolean _glewInit_GL_EXT_copy_texture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glCopyTexImage1DEXT = (PFNGLCOPYTEXIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTexImage1DEXT")) == NULL) || r; - r = ((glCopyTexImage2DEXT = (PFNGLCOPYTEXIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTexImage2DEXT")) == NULL) || r; - r = ((glCopyTexSubImage1DEXT = (PFNGLCOPYTEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTexSubImage1DEXT")) == NULL) || r; - r = ((glCopyTexSubImage2DEXT = (PFNGLCOPYTEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTexSubImage2DEXT")) == NULL) || r; - r = ((glCopyTexSubImage3DEXT = (PFNGLCOPYTEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTexSubImage3DEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_copy_texture */ - -#ifdef GL_EXT_cull_vertex - -static GLboolean _glewInit_GL_EXT_cull_vertex (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glCullParameterdvEXT = (PFNGLCULLPARAMETERDVEXTPROC)glewGetProcAddress((const GLubyte*)"glCullParameterdvEXT")) == NULL) || r; - r = ((glCullParameterfvEXT = (PFNGLCULLPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glCullParameterfvEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_cull_vertex */ - -#ifdef GL_EXT_depth_bounds_test - -static GLboolean _glewInit_GL_EXT_depth_bounds_test (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDepthBoundsEXT = (PFNGLDEPTHBOUNDSEXTPROC)glewGetProcAddress((const GLubyte*)"glDepthBoundsEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_depth_bounds_test */ - -#ifdef GL_EXT_direct_state_access - -static GLboolean _glewInit_GL_EXT_direct_state_access (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindMultiTextureEXT = (PFNGLBINDMULTITEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glBindMultiTextureEXT")) == NULL) || r; - r = ((glCheckNamedFramebufferStatusEXT = (PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC)glewGetProcAddress((const GLubyte*)"glCheckNamedFramebufferStatusEXT")) == NULL) || r; - r = ((glClientAttribDefaultEXT = (PFNGLCLIENTATTRIBDEFAULTEXTPROC)glewGetProcAddress((const GLubyte*)"glClientAttribDefaultEXT")) == NULL) || r; - r = ((glCompressedMultiTexImage1DEXT = (PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexImage1DEXT")) == NULL) || r; - r = ((glCompressedMultiTexImage2DEXT = (PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexImage2DEXT")) == NULL) || r; - r = ((glCompressedMultiTexImage3DEXT = (PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexImage3DEXT")) == NULL) || r; - r = ((glCompressedMultiTexSubImage1DEXT = (PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexSubImage1DEXT")) == NULL) || r; - r = ((glCompressedMultiTexSubImage2DEXT = (PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexSubImage2DEXT")) == NULL) || r; - r = ((glCompressedMultiTexSubImage3DEXT = (PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedMultiTexSubImage3DEXT")) == NULL) || r; - r = ((glCompressedTextureImage1DEXT = (PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureImage1DEXT")) == NULL) || r; - r = ((glCompressedTextureImage2DEXT = (PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureImage2DEXT")) == NULL) || r; - r = ((glCompressedTextureImage3DEXT = (PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureImage3DEXT")) == NULL) || r; - r = ((glCompressedTextureSubImage1DEXT = (PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureSubImage1DEXT")) == NULL) || r; - r = ((glCompressedTextureSubImage2DEXT = (PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureSubImage2DEXT")) == NULL) || r; - r = ((glCompressedTextureSubImage3DEXT = (PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCompressedTextureSubImage3DEXT")) == NULL) || r; - r = ((glCopyMultiTexImage1DEXT = (PFNGLCOPYMULTITEXIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyMultiTexImage1DEXT")) == NULL) || r; - r = ((glCopyMultiTexImage2DEXT = (PFNGLCOPYMULTITEXIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyMultiTexImage2DEXT")) == NULL) || r; - r = ((glCopyMultiTexSubImage1DEXT = (PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyMultiTexSubImage1DEXT")) == NULL) || r; - r = ((glCopyMultiTexSubImage2DEXT = (PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyMultiTexSubImage2DEXT")) == NULL) || r; - r = ((glCopyMultiTexSubImage3DEXT = (PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyMultiTexSubImage3DEXT")) == NULL) || r; - r = ((glCopyTextureImage1DEXT = (PFNGLCOPYTEXTUREIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureImage1DEXT")) == NULL) || r; - r = ((glCopyTextureImage2DEXT = (PFNGLCOPYTEXTUREIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureImage2DEXT")) == NULL) || r; - r = ((glCopyTextureSubImage1DEXT = (PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureSubImage1DEXT")) == NULL) || r; - r = ((glCopyTextureSubImage2DEXT = (PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureSubImage2DEXT")) == NULL) || r; - r = ((glCopyTextureSubImage3DEXT = (PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glCopyTextureSubImage3DEXT")) == NULL) || r; - r = ((glDisableClientStateIndexedEXT = (PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glDisableClientStateIndexedEXT")) == NULL) || r; - r = ((glEnableClientStateIndexedEXT = (PFNGLENABLECLIENTSTATEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glEnableClientStateIndexedEXT")) == NULL) || r; - r = ((glFramebufferDrawBufferEXT = (PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferDrawBufferEXT")) == NULL) || r; - r = ((glFramebufferDrawBuffersEXT = (PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferDrawBuffersEXT")) == NULL) || r; - r = ((glFramebufferReadBufferEXT = (PFNGLFRAMEBUFFERREADBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferReadBufferEXT")) == NULL) || r; - r = ((glGenerateMultiTexMipmapEXT = (PFNGLGENERATEMULTITEXMIPMAPEXTPROC)glewGetProcAddress((const GLubyte*)"glGenerateMultiTexMipmapEXT")) == NULL) || r; - r = ((glGenerateTextureMipmapEXT = (PFNGLGENERATETEXTUREMIPMAPEXTPROC)glewGetProcAddress((const GLubyte*)"glGenerateTextureMipmapEXT")) == NULL) || r; - r = ((glGetCompressedMultiTexImageEXT = (PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetCompressedMultiTexImageEXT")) == NULL) || r; - r = ((glGetCompressedTextureImageEXT = (PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetCompressedTextureImageEXT")) == NULL) || r; - r = ((glGetDoubleIndexedvEXT = (PFNGLGETDOUBLEINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetDoubleIndexedvEXT")) == NULL) || r; - r = ((glGetFloatIndexedvEXT = (PFNGLGETFLOATINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFloatIndexedvEXT")) == NULL) || r; - r = ((glGetFramebufferParameterivEXT = (PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFramebufferParameterivEXT")) == NULL) || r; - r = ((glGetMultiTexEnvfvEXT = (PFNGLGETMULTITEXENVFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexEnvfvEXT")) == NULL) || r; - r = ((glGetMultiTexEnvivEXT = (PFNGLGETMULTITEXENVIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexEnvivEXT")) == NULL) || r; - r = ((glGetMultiTexGendvEXT = (PFNGLGETMULTITEXGENDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexGendvEXT")) == NULL) || r; - r = ((glGetMultiTexGenfvEXT = (PFNGLGETMULTITEXGENFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexGenfvEXT")) == NULL) || r; - r = ((glGetMultiTexGenivEXT = (PFNGLGETMULTITEXGENIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexGenivEXT")) == NULL) || r; - r = ((glGetMultiTexImageEXT = (PFNGLGETMULTITEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexImageEXT")) == NULL) || r; - r = ((glGetMultiTexLevelParameterfvEXT = (PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexLevelParameterfvEXT")) == NULL) || r; - r = ((glGetMultiTexLevelParameterivEXT = (PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexLevelParameterivEXT")) == NULL) || r; - r = ((glGetMultiTexParameterIivEXT = (PFNGLGETMULTITEXPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexParameterIivEXT")) == NULL) || r; - r = ((glGetMultiTexParameterIuivEXT = (PFNGLGETMULTITEXPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexParameterIuivEXT")) == NULL) || r; - r = ((glGetMultiTexParameterfvEXT = (PFNGLGETMULTITEXPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexParameterfvEXT")) == NULL) || r; - r = ((glGetMultiTexParameterivEXT = (PFNGLGETMULTITEXPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMultiTexParameterivEXT")) == NULL) || r; - r = ((glGetNamedBufferParameterivEXT = (PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedBufferParameterivEXT")) == NULL) || r; - r = ((glGetNamedBufferPointervEXT = (PFNGLGETNAMEDBUFFERPOINTERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedBufferPointervEXT")) == NULL) || r; - r = ((glGetNamedBufferSubDataEXT = (PFNGLGETNAMEDBUFFERSUBDATAEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedBufferSubDataEXT")) == NULL) || r; - r = ((glGetNamedFramebufferAttachmentParameterivEXT = (PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedFramebufferAttachmentParameterivEXT")) == NULL) || r; - r = ((glGetNamedProgramLocalParameterIivEXT = (PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramLocalParameterIivEXT")) == NULL) || r; - r = ((glGetNamedProgramLocalParameterIuivEXT = (PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramLocalParameterIuivEXT")) == NULL) || r; - r = ((glGetNamedProgramLocalParameterdvEXT = (PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramLocalParameterdvEXT")) == NULL) || r; - r = ((glGetNamedProgramLocalParameterfvEXT = (PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramLocalParameterfvEXT")) == NULL) || r; - r = ((glGetNamedProgramStringEXT = (PFNGLGETNAMEDPROGRAMSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramStringEXT")) == NULL) || r; - r = ((glGetNamedProgramivEXT = (PFNGLGETNAMEDPROGRAMIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedProgramivEXT")) == NULL) || r; - r = ((glGetNamedRenderbufferParameterivEXT = (PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetNamedRenderbufferParameterivEXT")) == NULL) || r; - r = ((glGetPointerIndexedvEXT = (PFNGLGETPOINTERINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetPointerIndexedvEXT")) == NULL) || r; - r = ((glGetTextureImageEXT = (PFNGLGETTEXTUREIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureImageEXT")) == NULL) || r; - r = ((glGetTextureLevelParameterfvEXT = (PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureLevelParameterfvEXT")) == NULL) || r; - r = ((glGetTextureLevelParameterivEXT = (PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureLevelParameterivEXT")) == NULL) || r; - r = ((glGetTextureParameterIivEXT = (PFNGLGETTEXTUREPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterIivEXT")) == NULL) || r; - r = ((glGetTextureParameterIuivEXT = (PFNGLGETTEXTUREPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterIuivEXT")) == NULL) || r; - r = ((glGetTextureParameterfvEXT = (PFNGLGETTEXTUREPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterfvEXT")) == NULL) || r; - r = ((glGetTextureParameterivEXT = (PFNGLGETTEXTUREPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTextureParameterivEXT")) == NULL) || r; - r = ((glMapNamedBufferEXT = (PFNGLMAPNAMEDBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glMapNamedBufferEXT")) == NULL) || r; - r = ((glMatrixFrustumEXT = (PFNGLMATRIXFRUSTUMEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixFrustumEXT")) == NULL) || r; - r = ((glMatrixLoadIdentityEXT = (PFNGLMATRIXLOADIDENTITYEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoadIdentityEXT")) == NULL) || r; - r = ((glMatrixLoadTransposedEXT = (PFNGLMATRIXLOADTRANSPOSEDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoadTransposedEXT")) == NULL) || r; - r = ((glMatrixLoadTransposefEXT = (PFNGLMATRIXLOADTRANSPOSEFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoadTransposefEXT")) == NULL) || r; - r = ((glMatrixLoaddEXT = (PFNGLMATRIXLOADDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoaddEXT")) == NULL) || r; - r = ((glMatrixLoadfEXT = (PFNGLMATRIXLOADFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixLoadfEXT")) == NULL) || r; - r = ((glMatrixMultTransposedEXT = (PFNGLMATRIXMULTTRANSPOSEDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixMultTransposedEXT")) == NULL) || r; - r = ((glMatrixMultTransposefEXT = (PFNGLMATRIXMULTTRANSPOSEFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixMultTransposefEXT")) == NULL) || r; - r = ((glMatrixMultdEXT = (PFNGLMATRIXMULTDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixMultdEXT")) == NULL) || r; - r = ((glMatrixMultfEXT = (PFNGLMATRIXMULTFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixMultfEXT")) == NULL) || r; - r = ((glMatrixOrthoEXT = (PFNGLMATRIXORTHOEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixOrthoEXT")) == NULL) || r; - r = ((glMatrixPopEXT = (PFNGLMATRIXPOPEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixPopEXT")) == NULL) || r; - r = ((glMatrixPushEXT = (PFNGLMATRIXPUSHEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixPushEXT")) == NULL) || r; - r = ((glMatrixRotatedEXT = (PFNGLMATRIXROTATEDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixRotatedEXT")) == NULL) || r; - r = ((glMatrixRotatefEXT = (PFNGLMATRIXROTATEFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixRotatefEXT")) == NULL) || r; - r = ((glMatrixScaledEXT = (PFNGLMATRIXSCALEDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixScaledEXT")) == NULL) || r; - r = ((glMatrixScalefEXT = (PFNGLMATRIXSCALEFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixScalefEXT")) == NULL) || r; - r = ((glMatrixTranslatedEXT = (PFNGLMATRIXTRANSLATEDEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixTranslatedEXT")) == NULL) || r; - r = ((glMatrixTranslatefEXT = (PFNGLMATRIXTRANSLATEFEXTPROC)glewGetProcAddress((const GLubyte*)"glMatrixTranslatefEXT")) == NULL) || r; - r = ((glMultiTexBufferEXT = (PFNGLMULTITEXBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexBufferEXT")) == NULL) || r; - r = ((glMultiTexCoordPointerEXT = (PFNGLMULTITEXCOORDPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoordPointerEXT")) == NULL) || r; - r = ((glMultiTexEnvfEXT = (PFNGLMULTITEXENVFEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexEnvfEXT")) == NULL) || r; - r = ((glMultiTexEnvfvEXT = (PFNGLMULTITEXENVFVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexEnvfvEXT")) == NULL) || r; - r = ((glMultiTexEnviEXT = (PFNGLMULTITEXENVIEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexEnviEXT")) == NULL) || r; - r = ((glMultiTexEnvivEXT = (PFNGLMULTITEXENVIVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexEnvivEXT")) == NULL) || r; - r = ((glMultiTexGendEXT = (PFNGLMULTITEXGENDEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGendEXT")) == NULL) || r; - r = ((glMultiTexGendvEXT = (PFNGLMULTITEXGENDVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGendvEXT")) == NULL) || r; - r = ((glMultiTexGenfEXT = (PFNGLMULTITEXGENFEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGenfEXT")) == NULL) || r; - r = ((glMultiTexGenfvEXT = (PFNGLMULTITEXGENFVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGenfvEXT")) == NULL) || r; - r = ((glMultiTexGeniEXT = (PFNGLMULTITEXGENIEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGeniEXT")) == NULL) || r; - r = ((glMultiTexGenivEXT = (PFNGLMULTITEXGENIVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexGenivEXT")) == NULL) || r; - r = ((glMultiTexImage1DEXT = (PFNGLMULTITEXIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexImage1DEXT")) == NULL) || r; - r = ((glMultiTexImage2DEXT = (PFNGLMULTITEXIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexImage2DEXT")) == NULL) || r; - r = ((glMultiTexImage3DEXT = (PFNGLMULTITEXIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexImage3DEXT")) == NULL) || r; - r = ((glMultiTexParameterIivEXT = (PFNGLMULTITEXPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameterIivEXT")) == NULL) || r; - r = ((glMultiTexParameterIuivEXT = (PFNGLMULTITEXPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameterIuivEXT")) == NULL) || r; - r = ((glMultiTexParameterfEXT = (PFNGLMULTITEXPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameterfEXT")) == NULL) || r; - r = ((glMultiTexParameterfvEXT = (PFNGLMULTITEXPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameterfvEXT")) == NULL) || r; - r = ((glMultiTexParameteriEXT = (PFNGLMULTITEXPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameteriEXT")) == NULL) || r; - r = ((glMultiTexParameterivEXT = (PFNGLMULTITEXPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexParameterivEXT")) == NULL) || r; - r = ((glMultiTexRenderbufferEXT = (PFNGLMULTITEXRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexRenderbufferEXT")) == NULL) || r; - r = ((glMultiTexSubImage1DEXT = (PFNGLMULTITEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexSubImage1DEXT")) == NULL) || r; - r = ((glMultiTexSubImage2DEXT = (PFNGLMULTITEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexSubImage2DEXT")) == NULL) || r; - r = ((glMultiTexSubImage3DEXT = (PFNGLMULTITEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiTexSubImage3DEXT")) == NULL) || r; - r = ((glNamedBufferDataEXT = (PFNGLNAMEDBUFFERDATAEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedBufferDataEXT")) == NULL) || r; - r = ((glNamedBufferSubDataEXT = (PFNGLNAMEDBUFFERSUBDATAEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedBufferSubDataEXT")) == NULL) || r; - r = ((glNamedFramebufferRenderbufferEXT = (PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferRenderbufferEXT")) == NULL) || r; - r = ((glNamedFramebufferTexture1DEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTexture1DEXT")) == NULL) || r; - r = ((glNamedFramebufferTexture2DEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTexture2DEXT")) == NULL) || r; - r = ((glNamedFramebufferTexture3DEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTexture3DEXT")) == NULL) || r; - r = ((glNamedFramebufferTextureEXT = (PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTextureEXT")) == NULL) || r; - r = ((glNamedFramebufferTextureFaceEXT = (PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTextureFaceEXT")) == NULL) || r; - r = ((glNamedFramebufferTextureLayerEXT = (PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC)glewGetProcAddress((const GLubyte*)"glNamedFramebufferTextureLayerEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameter4dEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameter4dEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameter4dvEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameter4dvEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameter4fEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameter4fEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameter4fvEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameter4fvEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameterI4iEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameterI4iEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameterI4ivEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameterI4ivEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameterI4uiEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameterI4uiEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameterI4uivEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameterI4uivEXT")) == NULL) || r; - r = ((glNamedProgramLocalParameters4fvEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParameters4fvEXT")) == NULL) || r; - r = ((glNamedProgramLocalParametersI4ivEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParametersI4ivEXT")) == NULL) || r; - r = ((glNamedProgramLocalParametersI4uivEXT = (PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramLocalParametersI4uivEXT")) == NULL) || r; - r = ((glNamedProgramStringEXT = (PFNGLNAMEDPROGRAMSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedProgramStringEXT")) == NULL) || r; - r = ((glNamedRenderbufferStorageEXT = (PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedRenderbufferStorageEXT")) == NULL) || r; - r = ((glNamedRenderbufferStorageMultisampleCoverageEXT = (PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedRenderbufferStorageMultisampleCoverageEXT")) == NULL) || r; - r = ((glNamedRenderbufferStorageMultisampleEXT = (PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)glewGetProcAddress((const GLubyte*)"glNamedRenderbufferStorageMultisampleEXT")) == NULL) || r; - r = ((glProgramUniform1fEXT = (PFNGLPROGRAMUNIFORM1FEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1fEXT")) == NULL) || r; - r = ((glProgramUniform1fvEXT = (PFNGLPROGRAMUNIFORM1FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1fvEXT")) == NULL) || r; - r = ((glProgramUniform1iEXT = (PFNGLPROGRAMUNIFORM1IEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1iEXT")) == NULL) || r; - r = ((glProgramUniform1ivEXT = (PFNGLPROGRAMUNIFORM1IVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1ivEXT")) == NULL) || r; - r = ((glProgramUniform1uiEXT = (PFNGLPROGRAMUNIFORM1UIEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1uiEXT")) == NULL) || r; - r = ((glProgramUniform1uivEXT = (PFNGLPROGRAMUNIFORM1UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform1uivEXT")) == NULL) || r; - r = ((glProgramUniform2fEXT = (PFNGLPROGRAMUNIFORM2FEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2fEXT")) == NULL) || r; - r = ((glProgramUniform2fvEXT = (PFNGLPROGRAMUNIFORM2FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2fvEXT")) == NULL) || r; - r = ((glProgramUniform2iEXT = (PFNGLPROGRAMUNIFORM2IEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2iEXT")) == NULL) || r; - r = ((glProgramUniform2ivEXT = (PFNGLPROGRAMUNIFORM2IVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2ivEXT")) == NULL) || r; - r = ((glProgramUniform2uiEXT = (PFNGLPROGRAMUNIFORM2UIEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2uiEXT")) == NULL) || r; - r = ((glProgramUniform2uivEXT = (PFNGLPROGRAMUNIFORM2UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform2uivEXT")) == NULL) || r; - r = ((glProgramUniform3fEXT = (PFNGLPROGRAMUNIFORM3FEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3fEXT")) == NULL) || r; - r = ((glProgramUniform3fvEXT = (PFNGLPROGRAMUNIFORM3FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3fvEXT")) == NULL) || r; - r = ((glProgramUniform3iEXT = (PFNGLPROGRAMUNIFORM3IEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3iEXT")) == NULL) || r; - r = ((glProgramUniform3ivEXT = (PFNGLPROGRAMUNIFORM3IVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3ivEXT")) == NULL) || r; - r = ((glProgramUniform3uiEXT = (PFNGLPROGRAMUNIFORM3UIEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3uiEXT")) == NULL) || r; - r = ((glProgramUniform3uivEXT = (PFNGLPROGRAMUNIFORM3UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform3uivEXT")) == NULL) || r; - r = ((glProgramUniform4fEXT = (PFNGLPROGRAMUNIFORM4FEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4fEXT")) == NULL) || r; - r = ((glProgramUniform4fvEXT = (PFNGLPROGRAMUNIFORM4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4fvEXT")) == NULL) || r; - r = ((glProgramUniform4iEXT = (PFNGLPROGRAMUNIFORM4IEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4iEXT")) == NULL) || r; - r = ((glProgramUniform4ivEXT = (PFNGLPROGRAMUNIFORM4IVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4ivEXT")) == NULL) || r; - r = ((glProgramUniform4uiEXT = (PFNGLPROGRAMUNIFORM4UIEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4uiEXT")) == NULL) || r; - r = ((glProgramUniform4uivEXT = (PFNGLPROGRAMUNIFORM4UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniform4uivEXT")) == NULL) || r; - r = ((glProgramUniformMatrix2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix2fvEXT")) == NULL) || r; - r = ((glProgramUniformMatrix2x3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix2x3fvEXT")) == NULL) || r; - r = ((glProgramUniformMatrix2x4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix2x4fvEXT")) == NULL) || r; - r = ((glProgramUniformMatrix3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix3fvEXT")) == NULL) || r; - r = ((glProgramUniformMatrix3x2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix3x2fvEXT")) == NULL) || r; - r = ((glProgramUniformMatrix3x4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix3x4fvEXT")) == NULL) || r; - r = ((glProgramUniformMatrix4fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix4fvEXT")) == NULL) || r; - r = ((glProgramUniformMatrix4x2fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix4x2fvEXT")) == NULL) || r; - r = ((glProgramUniformMatrix4x3fvEXT = (PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramUniformMatrix4x3fvEXT")) == NULL) || r; - r = ((glPushClientAttribDefaultEXT = (PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC)glewGetProcAddress((const GLubyte*)"glPushClientAttribDefaultEXT")) == NULL) || r; - r = ((glTextureBufferEXT = (PFNGLTEXTUREBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glTextureBufferEXT")) == NULL) || r; - r = ((glTextureImage1DEXT = (PFNGLTEXTUREIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureImage1DEXT")) == NULL) || r; - r = ((glTextureImage2DEXT = (PFNGLTEXTUREIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureImage2DEXT")) == NULL) || r; - r = ((glTextureImage3DEXT = (PFNGLTEXTUREIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureImage3DEXT")) == NULL) || r; - r = ((glTextureParameterIivEXT = (PFNGLTEXTUREPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterIivEXT")) == NULL) || r; - r = ((glTextureParameterIuivEXT = (PFNGLTEXTUREPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterIuivEXT")) == NULL) || r; - r = ((glTextureParameterfEXT = (PFNGLTEXTUREPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterfEXT")) == NULL) || r; - r = ((glTextureParameterfvEXT = (PFNGLTEXTUREPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterfvEXT")) == NULL) || r; - r = ((glTextureParameteriEXT = (PFNGLTEXTUREPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameteriEXT")) == NULL) || r; - r = ((glTextureParameterivEXT = (PFNGLTEXTUREPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureParameterivEXT")) == NULL) || r; - r = ((glTextureRenderbufferEXT = (PFNGLTEXTURERENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glTextureRenderbufferEXT")) == NULL) || r; - r = ((glTextureSubImage1DEXT = (PFNGLTEXTURESUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureSubImage1DEXT")) == NULL) || r; - r = ((glTextureSubImage2DEXT = (PFNGLTEXTURESUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureSubImage2DEXT")) == NULL) || r; - r = ((glTextureSubImage3DEXT = (PFNGLTEXTURESUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureSubImage3DEXT")) == NULL) || r; - r = ((glUnmapNamedBufferEXT = (PFNGLUNMAPNAMEDBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glUnmapNamedBufferEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_direct_state_access */ - -#ifdef GL_EXT_draw_buffers2 - -static GLboolean _glewInit_GL_EXT_draw_buffers2 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glColorMaskIndexedEXT = (PFNGLCOLORMASKINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glColorMaskIndexedEXT")) == NULL) || r; - r = ((glDisableIndexedEXT = (PFNGLDISABLEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glDisableIndexedEXT")) == NULL) || r; - r = ((glEnableIndexedEXT = (PFNGLENABLEINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glEnableIndexedEXT")) == NULL) || r; - r = ((glGetBooleanIndexedvEXT = (PFNGLGETBOOLEANINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetBooleanIndexedvEXT")) == NULL) || r; - r = ((glGetIntegerIndexedvEXT = (PFNGLGETINTEGERINDEXEDVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetIntegerIndexedvEXT")) == NULL) || r; - r = ((glIsEnabledIndexedEXT = (PFNGLISENABLEDINDEXEDEXTPROC)glewGetProcAddress((const GLubyte*)"glIsEnabledIndexedEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_draw_buffers2 */ - -#ifdef GL_EXT_draw_instanced - -static GLboolean _glewInit_GL_EXT_draw_instanced (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDrawArraysInstancedEXT = (PFNGLDRAWARRAYSINSTANCEDEXTPROC)glewGetProcAddress((const GLubyte*)"glDrawArraysInstancedEXT")) == NULL) || r; - r = ((glDrawElementsInstancedEXT = (PFNGLDRAWELEMENTSINSTANCEDEXTPROC)glewGetProcAddress((const GLubyte*)"glDrawElementsInstancedEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_draw_instanced */ - -#ifdef GL_EXT_draw_range_elements - -static GLboolean _glewInit_GL_EXT_draw_range_elements (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDrawRangeElementsEXT = (PFNGLDRAWRANGEELEMENTSEXTPROC)glewGetProcAddress((const GLubyte*)"glDrawRangeElementsEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_draw_range_elements */ - -#ifdef GL_EXT_fog_coord - -static GLboolean _glewInit_GL_EXT_fog_coord (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFogCoordPointerEXT = (PFNGLFOGCOORDPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glFogCoordPointerEXT")) == NULL) || r; - r = ((glFogCoorddEXT = (PFNGLFOGCOORDDEXTPROC)glewGetProcAddress((const GLubyte*)"glFogCoorddEXT")) == NULL) || r; - r = ((glFogCoorddvEXT = (PFNGLFOGCOORDDVEXTPROC)glewGetProcAddress((const GLubyte*)"glFogCoorddvEXT")) == NULL) || r; - r = ((glFogCoordfEXT = (PFNGLFOGCOORDFEXTPROC)glewGetProcAddress((const GLubyte*)"glFogCoordfEXT")) == NULL) || r; - r = ((glFogCoordfvEXT = (PFNGLFOGCOORDFVEXTPROC)glewGetProcAddress((const GLubyte*)"glFogCoordfvEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_fog_coord */ - -#ifdef GL_EXT_fragment_lighting - -static GLboolean _glewInit_GL_EXT_fragment_lighting (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFragmentColorMaterialEXT = (PFNGLFRAGMENTCOLORMATERIALEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentColorMaterialEXT")) == NULL) || r; - r = ((glFragmentLightModelfEXT = (PFNGLFRAGMENTLIGHTMODELFEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelfEXT")) == NULL) || r; - r = ((glFragmentLightModelfvEXT = (PFNGLFRAGMENTLIGHTMODELFVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelfvEXT")) == NULL) || r; - r = ((glFragmentLightModeliEXT = (PFNGLFRAGMENTLIGHTMODELIEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModeliEXT")) == NULL) || r; - r = ((glFragmentLightModelivEXT = (PFNGLFRAGMENTLIGHTMODELIVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelivEXT")) == NULL) || r; - r = ((glFragmentLightfEXT = (PFNGLFRAGMENTLIGHTFEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightfEXT")) == NULL) || r; - r = ((glFragmentLightfvEXT = (PFNGLFRAGMENTLIGHTFVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightfvEXT")) == NULL) || r; - r = ((glFragmentLightiEXT = (PFNGLFRAGMENTLIGHTIEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightiEXT")) == NULL) || r; - r = ((glFragmentLightivEXT = (PFNGLFRAGMENTLIGHTIVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightivEXT")) == NULL) || r; - r = ((glFragmentMaterialfEXT = (PFNGLFRAGMENTMATERIALFEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialfEXT")) == NULL) || r; - r = ((glFragmentMaterialfvEXT = (PFNGLFRAGMENTMATERIALFVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialfvEXT")) == NULL) || r; - r = ((glFragmentMaterialiEXT = (PFNGLFRAGMENTMATERIALIEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialiEXT")) == NULL) || r; - r = ((glFragmentMaterialivEXT = (PFNGLFRAGMENTMATERIALIVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialivEXT")) == NULL) || r; - r = ((glGetFragmentLightfvEXT = (PFNGLGETFRAGMENTLIGHTFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentLightfvEXT")) == NULL) || r; - r = ((glGetFragmentLightivEXT = (PFNGLGETFRAGMENTLIGHTIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentLightivEXT")) == NULL) || r; - r = ((glGetFragmentMaterialfvEXT = (PFNGLGETFRAGMENTMATERIALFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentMaterialfvEXT")) == NULL) || r; - r = ((glGetFragmentMaterialivEXT = (PFNGLGETFRAGMENTMATERIALIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentMaterialivEXT")) == NULL) || r; - r = ((glLightEnviEXT = (PFNGLLIGHTENVIEXTPROC)glewGetProcAddress((const GLubyte*)"glLightEnviEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_fragment_lighting */ - -#ifdef GL_EXT_framebuffer_blit - -static GLboolean _glewInit_GL_EXT_framebuffer_blit (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBlitFramebufferEXT = (PFNGLBLITFRAMEBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glBlitFramebufferEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_framebuffer_blit */ - -#ifdef GL_EXT_framebuffer_multisample - -static GLboolean _glewInit_GL_EXT_framebuffer_multisample (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glRenderbufferStorageMultisampleEXT = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)glewGetProcAddress((const GLubyte*)"glRenderbufferStorageMultisampleEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_framebuffer_multisample */ - -#ifdef GL_EXT_framebuffer_object - -static GLboolean _glewInit_GL_EXT_framebuffer_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindFramebufferEXT")) == NULL) || r; - r = ((glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindRenderbufferEXT")) == NULL) || r; - r = ((glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)glewGetProcAddress((const GLubyte*)"glCheckFramebufferStatusEXT")) == NULL) || r; - r = ((glDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)"glDeleteFramebuffersEXT")) == NULL) || r; - r = ((glDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)"glDeleteRenderbuffersEXT")) == NULL) || r; - r = ((glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferRenderbufferEXT")) == NULL) || r; - r = ((glFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture1DEXT")) == NULL) || r; - r = ((glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture2DEXT")) == NULL) || r; - r = ((glFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTexture3DEXT")) == NULL) || r; - r = ((glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)"glGenFramebuffersEXT")) == NULL) || r; - r = ((glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC)glewGetProcAddress((const GLubyte*)"glGenRenderbuffersEXT")) == NULL) || r; - r = ((glGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC)glewGetProcAddress((const GLubyte*)"glGenerateMipmapEXT")) == NULL) || r; - r = ((glGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFramebufferAttachmentParameterivEXT")) == NULL) || r; - r = ((glGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetRenderbufferParameterivEXT")) == NULL) || r; - r = ((glIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glIsFramebufferEXT")) == NULL) || r; - r = ((glIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glIsRenderbufferEXT")) == NULL) || r; - r = ((glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glRenderbufferStorageEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_framebuffer_object */ - -#ifdef GL_EXT_framebuffer_sRGB - -#endif /* GL_EXT_framebuffer_sRGB */ - -#ifdef GL_EXT_geometry_shader4 - -static GLboolean _glewInit_GL_EXT_geometry_shader4 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFramebufferTextureEXT = (PFNGLFRAMEBUFFERTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureEXT")) == NULL) || r; - r = ((glFramebufferTextureFaceEXT = (PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureFaceEXT")) == NULL) || r; - r = ((glFramebufferTextureLayerEXT = (PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC)glewGetProcAddress((const GLubyte*)"glFramebufferTextureLayerEXT")) == NULL) || r; - r = ((glProgramParameteriEXT = (PFNGLPROGRAMPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramParameteriEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_geometry_shader4 */ - -#ifdef GL_EXT_gpu_program_parameters - -static GLboolean _glewInit_GL_EXT_gpu_program_parameters (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glProgramEnvParameters4fvEXT = (PFNGLPROGRAMENVPARAMETERS4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameters4fvEXT")) == NULL) || r; - r = ((glProgramLocalParameters4fvEXT = (PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameters4fvEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_gpu_program_parameters */ - -#ifdef GL_EXT_gpu_shader4 - -static GLboolean _glewInit_GL_EXT_gpu_shader4 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBindFragDataLocationEXT = (PFNGLBINDFRAGDATALOCATIONEXTPROC)glewGetProcAddress((const GLubyte*)"glBindFragDataLocationEXT")) == NULL) || r; - r = ((glGetFragDataLocationEXT = (PFNGLGETFRAGDATALOCATIONEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragDataLocationEXT")) == NULL) || r; - r = ((glGetUniformuivEXT = (PFNGLGETUNIFORMUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetUniformuivEXT")) == NULL) || r; - r = ((glGetVertexAttribIivEXT = (PFNGLGETVERTEXATTRIBIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribIivEXT")) == NULL) || r; - r = ((glGetVertexAttribIuivEXT = (PFNGLGETVERTEXATTRIBIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribIuivEXT")) == NULL) || r; - r = ((glUniform1uiEXT = (PFNGLUNIFORM1UIEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform1uiEXT")) == NULL) || r; - r = ((glUniform1uivEXT = (PFNGLUNIFORM1UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform1uivEXT")) == NULL) || r; - r = ((glUniform2uiEXT = (PFNGLUNIFORM2UIEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform2uiEXT")) == NULL) || r; - r = ((glUniform2uivEXT = (PFNGLUNIFORM2UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform2uivEXT")) == NULL) || r; - r = ((glUniform3uiEXT = (PFNGLUNIFORM3UIEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform3uiEXT")) == NULL) || r; - r = ((glUniform3uivEXT = (PFNGLUNIFORM3UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform3uivEXT")) == NULL) || r; - r = ((glUniform4uiEXT = (PFNGLUNIFORM4UIEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform4uiEXT")) == NULL) || r; - r = ((glUniform4uivEXT = (PFNGLUNIFORM4UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glUniform4uivEXT")) == NULL) || r; - r = ((glVertexAttribI1iEXT = (PFNGLVERTEXATTRIBI1IEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1iEXT")) == NULL) || r; - r = ((glVertexAttribI1ivEXT = (PFNGLVERTEXATTRIBI1IVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1ivEXT")) == NULL) || r; - r = ((glVertexAttribI1uiEXT = (PFNGLVERTEXATTRIBI1UIEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1uiEXT")) == NULL) || r; - r = ((glVertexAttribI1uivEXT = (PFNGLVERTEXATTRIBI1UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI1uivEXT")) == NULL) || r; - r = ((glVertexAttribI2iEXT = (PFNGLVERTEXATTRIBI2IEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2iEXT")) == NULL) || r; - r = ((glVertexAttribI2ivEXT = (PFNGLVERTEXATTRIBI2IVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2ivEXT")) == NULL) || r; - r = ((glVertexAttribI2uiEXT = (PFNGLVERTEXATTRIBI2UIEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2uiEXT")) == NULL) || r; - r = ((glVertexAttribI2uivEXT = (PFNGLVERTEXATTRIBI2UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI2uivEXT")) == NULL) || r; - r = ((glVertexAttribI3iEXT = (PFNGLVERTEXATTRIBI3IEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3iEXT")) == NULL) || r; - r = ((glVertexAttribI3ivEXT = (PFNGLVERTEXATTRIBI3IVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3ivEXT")) == NULL) || r; - r = ((glVertexAttribI3uiEXT = (PFNGLVERTEXATTRIBI3UIEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3uiEXT")) == NULL) || r; - r = ((glVertexAttribI3uivEXT = (PFNGLVERTEXATTRIBI3UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI3uivEXT")) == NULL) || r; - r = ((glVertexAttribI4bvEXT = (PFNGLVERTEXATTRIBI4BVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4bvEXT")) == NULL) || r; - r = ((glVertexAttribI4iEXT = (PFNGLVERTEXATTRIBI4IEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4iEXT")) == NULL) || r; - r = ((glVertexAttribI4ivEXT = (PFNGLVERTEXATTRIBI4IVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4ivEXT")) == NULL) || r; - r = ((glVertexAttribI4svEXT = (PFNGLVERTEXATTRIBI4SVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4svEXT")) == NULL) || r; - r = ((glVertexAttribI4ubvEXT = (PFNGLVERTEXATTRIBI4UBVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4ubvEXT")) == NULL) || r; - r = ((glVertexAttribI4uiEXT = (PFNGLVERTEXATTRIBI4UIEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4uiEXT")) == NULL) || r; - r = ((glVertexAttribI4uivEXT = (PFNGLVERTEXATTRIBI4UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4uivEXT")) == NULL) || r; - r = ((glVertexAttribI4usvEXT = (PFNGLVERTEXATTRIBI4USVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribI4usvEXT")) == NULL) || r; - r = ((glVertexAttribIPointerEXT = (PFNGLVERTEXATTRIBIPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribIPointerEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_gpu_shader4 */ - -#ifdef GL_EXT_histogram - -static GLboolean _glewInit_GL_EXT_histogram (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetHistogramEXT = (PFNGLGETHISTOGRAMEXTPROC)glewGetProcAddress((const GLubyte*)"glGetHistogramEXT")) == NULL) || r; - r = ((glGetHistogramParameterfvEXT = (PFNGLGETHISTOGRAMPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetHistogramParameterfvEXT")) == NULL) || r; - r = ((glGetHistogramParameterivEXT = (PFNGLGETHISTOGRAMPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetHistogramParameterivEXT")) == NULL) || r; - r = ((glGetMinmaxEXT = (PFNGLGETMINMAXEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMinmaxEXT")) == NULL) || r; - r = ((glGetMinmaxParameterfvEXT = (PFNGLGETMINMAXPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMinmaxParameterfvEXT")) == NULL) || r; - r = ((glGetMinmaxParameterivEXT = (PFNGLGETMINMAXPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetMinmaxParameterivEXT")) == NULL) || r; - r = ((glHistogramEXT = (PFNGLHISTOGRAMEXTPROC)glewGetProcAddress((const GLubyte*)"glHistogramEXT")) == NULL) || r; - r = ((glMinmaxEXT = (PFNGLMINMAXEXTPROC)glewGetProcAddress((const GLubyte*)"glMinmaxEXT")) == NULL) || r; - r = ((glResetHistogramEXT = (PFNGLRESETHISTOGRAMEXTPROC)glewGetProcAddress((const GLubyte*)"glResetHistogramEXT")) == NULL) || r; - r = ((glResetMinmaxEXT = (PFNGLRESETMINMAXEXTPROC)glewGetProcAddress((const GLubyte*)"glResetMinmaxEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_histogram */ - -#ifdef GL_EXT_index_array_formats - -#endif /* GL_EXT_index_array_formats */ - -#ifdef GL_EXT_index_func - -static GLboolean _glewInit_GL_EXT_index_func (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glIndexFuncEXT = (PFNGLINDEXFUNCEXTPROC)glewGetProcAddress((const GLubyte*)"glIndexFuncEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_index_func */ - -#ifdef GL_EXT_index_material - -static GLboolean _glewInit_GL_EXT_index_material (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glIndexMaterialEXT = (PFNGLINDEXMATERIALEXTPROC)glewGetProcAddress((const GLubyte*)"glIndexMaterialEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_index_material */ - -#ifdef GL_EXT_index_texture - -#endif /* GL_EXT_index_texture */ - -#ifdef GL_EXT_light_texture - -static GLboolean _glewInit_GL_EXT_light_texture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glApplyTextureEXT = (PFNGLAPPLYTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glApplyTextureEXT")) == NULL) || r; - r = ((glTextureLightEXT = (PFNGLTEXTURELIGHTEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureLightEXT")) == NULL) || r; - r = ((glTextureMaterialEXT = (PFNGLTEXTUREMATERIALEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureMaterialEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_light_texture */ - -#ifdef GL_EXT_misc_attribute - -#endif /* GL_EXT_misc_attribute */ - -#ifdef GL_EXT_multi_draw_arrays - -static GLboolean _glewInit_GL_EXT_multi_draw_arrays (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawArraysEXT")) == NULL) || r; - r = ((glMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC)glewGetProcAddress((const GLubyte*)"glMultiDrawElementsEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_multi_draw_arrays */ - -#ifdef GL_EXT_multisample - -static GLboolean _glewInit_GL_EXT_multisample (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glSampleMaskEXT = (PFNGLSAMPLEMASKEXTPROC)glewGetProcAddress((const GLubyte*)"glSampleMaskEXT")) == NULL) || r; - r = ((glSamplePatternEXT = (PFNGLSAMPLEPATTERNEXTPROC)glewGetProcAddress((const GLubyte*)"glSamplePatternEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_multisample */ - -#ifdef GL_EXT_packed_depth_stencil - -#endif /* GL_EXT_packed_depth_stencil */ - -#ifdef GL_EXT_packed_float - -#endif /* GL_EXT_packed_float */ - -#ifdef GL_EXT_packed_pixels - -#endif /* GL_EXT_packed_pixels */ - -#ifdef GL_EXT_paletted_texture - -static GLboolean _glewInit_GL_EXT_paletted_texture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glColorTableEXT = (PFNGLCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"glColorTableEXT")) == NULL) || r; - r = ((glGetColorTableEXT = (PFNGLGETCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableEXT")) == NULL) || r; - r = ((glGetColorTableParameterfvEXT = (PFNGLGETCOLORTABLEPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameterfvEXT")) == NULL) || r; - r = ((glGetColorTableParameterivEXT = (PFNGLGETCOLORTABLEPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameterivEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_paletted_texture */ - -#ifdef GL_EXT_pixel_buffer_object - -#endif /* GL_EXT_pixel_buffer_object */ - -#ifdef GL_EXT_pixel_transform - -static GLboolean _glewInit_GL_EXT_pixel_transform (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetPixelTransformParameterfvEXT = (PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetPixelTransformParameterfvEXT")) == NULL) || r; - r = ((glGetPixelTransformParameterivEXT = (PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetPixelTransformParameterivEXT")) == NULL) || r; - r = ((glPixelTransformParameterfEXT = (PFNGLPIXELTRANSFORMPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)"glPixelTransformParameterfEXT")) == NULL) || r; - r = ((glPixelTransformParameterfvEXT = (PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glPixelTransformParameterfvEXT")) == NULL) || r; - r = ((glPixelTransformParameteriEXT = (PFNGLPIXELTRANSFORMPARAMETERIEXTPROC)glewGetProcAddress((const GLubyte*)"glPixelTransformParameteriEXT")) == NULL) || r; - r = ((glPixelTransformParameterivEXT = (PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC)glewGetProcAddress((const GLubyte*)"glPixelTransformParameterivEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_pixel_transform */ - -#ifdef GL_EXT_pixel_transform_color_table - -#endif /* GL_EXT_pixel_transform_color_table */ - -#ifdef GL_EXT_point_parameters - -static GLboolean _glewInit_GL_EXT_point_parameters (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glPointParameterfEXT = (PFNGLPOINTPARAMETERFEXTPROC)glewGetProcAddress((const GLubyte*)"glPointParameterfEXT")) == NULL) || r; - r = ((glPointParameterfvEXT = (PFNGLPOINTPARAMETERFVEXTPROC)glewGetProcAddress((const GLubyte*)"glPointParameterfvEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_point_parameters */ - -#ifdef GL_EXT_polygon_offset - -static GLboolean _glewInit_GL_EXT_polygon_offset (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glPolygonOffsetEXT = (PFNGLPOLYGONOFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glPolygonOffsetEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_polygon_offset */ - -#ifdef GL_EXT_rescale_normal - -#endif /* GL_EXT_rescale_normal */ - -#ifdef GL_EXT_scene_marker - -static GLboolean _glewInit_GL_EXT_scene_marker (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBeginSceneEXT = (PFNGLBEGINSCENEEXTPROC)glewGetProcAddress((const GLubyte*)"glBeginSceneEXT")) == NULL) || r; - r = ((glEndSceneEXT = (PFNGLENDSCENEEXTPROC)glewGetProcAddress((const GLubyte*)"glEndSceneEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_scene_marker */ - -#ifdef GL_EXT_secondary_color - -static GLboolean _glewInit_GL_EXT_secondary_color (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glSecondaryColor3bEXT = (PFNGLSECONDARYCOLOR3BEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3bEXT")) == NULL) || r; - r = ((glSecondaryColor3bvEXT = (PFNGLSECONDARYCOLOR3BVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3bvEXT")) == NULL) || r; - r = ((glSecondaryColor3dEXT = (PFNGLSECONDARYCOLOR3DEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3dEXT")) == NULL) || r; - r = ((glSecondaryColor3dvEXT = (PFNGLSECONDARYCOLOR3DVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3dvEXT")) == NULL) || r; - r = ((glSecondaryColor3fEXT = (PFNGLSECONDARYCOLOR3FEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3fEXT")) == NULL) || r; - r = ((glSecondaryColor3fvEXT = (PFNGLSECONDARYCOLOR3FVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3fvEXT")) == NULL) || r; - r = ((glSecondaryColor3iEXT = (PFNGLSECONDARYCOLOR3IEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3iEXT")) == NULL) || r; - r = ((glSecondaryColor3ivEXT = (PFNGLSECONDARYCOLOR3IVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ivEXT")) == NULL) || r; - r = ((glSecondaryColor3sEXT = (PFNGLSECONDARYCOLOR3SEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3sEXT")) == NULL) || r; - r = ((glSecondaryColor3svEXT = (PFNGLSECONDARYCOLOR3SVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3svEXT")) == NULL) || r; - r = ((glSecondaryColor3ubEXT = (PFNGLSECONDARYCOLOR3UBEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ubEXT")) == NULL) || r; - r = ((glSecondaryColor3ubvEXT = (PFNGLSECONDARYCOLOR3UBVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3ubvEXT")) == NULL) || r; - r = ((glSecondaryColor3uiEXT = (PFNGLSECONDARYCOLOR3UIEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3uiEXT")) == NULL) || r; - r = ((glSecondaryColor3uivEXT = (PFNGLSECONDARYCOLOR3UIVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3uivEXT")) == NULL) || r; - r = ((glSecondaryColor3usEXT = (PFNGLSECONDARYCOLOR3USEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3usEXT")) == NULL) || r; - r = ((glSecondaryColor3usvEXT = (PFNGLSECONDARYCOLOR3USVEXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3usvEXT")) == NULL) || r; - r = ((glSecondaryColorPointerEXT = (PFNGLSECONDARYCOLORPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColorPointerEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_secondary_color */ - -#ifdef GL_EXT_separate_specular_color - -#endif /* GL_EXT_separate_specular_color */ - -#ifdef GL_EXT_shadow_funcs - -#endif /* GL_EXT_shadow_funcs */ - -#ifdef GL_EXT_shared_texture_palette - -#endif /* GL_EXT_shared_texture_palette */ - -#ifdef GL_EXT_stencil_clear_tag - -#endif /* GL_EXT_stencil_clear_tag */ - -#ifdef GL_EXT_stencil_two_side - -static GLboolean _glewInit_GL_EXT_stencil_two_side (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glActiveStencilFaceEXT = (PFNGLACTIVESTENCILFACEEXTPROC)glewGetProcAddress((const GLubyte*)"glActiveStencilFaceEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_stencil_two_side */ - -#ifdef GL_EXT_stencil_wrap - -#endif /* GL_EXT_stencil_wrap */ - -#ifdef GL_EXT_subtexture - -static GLboolean _glewInit_GL_EXT_subtexture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTexSubImage1DEXT = (PFNGLTEXSUBIMAGE1DEXTPROC)glewGetProcAddress((const GLubyte*)"glTexSubImage1DEXT")) == NULL) || r; - r = ((glTexSubImage2DEXT = (PFNGLTEXSUBIMAGE2DEXTPROC)glewGetProcAddress((const GLubyte*)"glTexSubImage2DEXT")) == NULL) || r; - r = ((glTexSubImage3DEXT = (PFNGLTEXSUBIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glTexSubImage3DEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_subtexture */ - -#ifdef GL_EXT_texture - -#endif /* GL_EXT_texture */ - -#ifdef GL_EXT_texture3D - -static GLboolean _glewInit_GL_EXT_texture3D (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTexImage3DEXT = (PFNGLTEXIMAGE3DEXTPROC)glewGetProcAddress((const GLubyte*)"glTexImage3DEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_texture3D */ - -#ifdef GL_EXT_texture_array - -#endif /* GL_EXT_texture_array */ - -#ifdef GL_EXT_texture_buffer_object - -static GLboolean _glewInit_GL_EXT_texture_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTexBufferEXT = (PFNGLTEXBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"glTexBufferEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_texture_buffer_object */ - -#ifdef GL_EXT_texture_compression_dxt1 - -#endif /* GL_EXT_texture_compression_dxt1 */ - -#ifdef GL_EXT_texture_compression_latc - -#endif /* GL_EXT_texture_compression_latc */ - -#ifdef GL_EXT_texture_compression_rgtc - -#endif /* GL_EXT_texture_compression_rgtc */ - -#ifdef GL_EXT_texture_compression_s3tc - -#endif /* GL_EXT_texture_compression_s3tc */ - -#ifdef GL_EXT_texture_cube_map - -#endif /* GL_EXT_texture_cube_map */ - -#ifdef GL_EXT_texture_edge_clamp - -#endif /* GL_EXT_texture_edge_clamp */ - -#ifdef GL_EXT_texture_env - -#endif /* GL_EXT_texture_env */ - -#ifdef GL_EXT_texture_env_add - -#endif /* GL_EXT_texture_env_add */ - -#ifdef GL_EXT_texture_env_combine - -#endif /* GL_EXT_texture_env_combine */ - -#ifdef GL_EXT_texture_env_dot3 - -#endif /* GL_EXT_texture_env_dot3 */ - -#ifdef GL_EXT_texture_filter_anisotropic - -#endif /* GL_EXT_texture_filter_anisotropic */ - -#ifdef GL_EXT_texture_integer - -static GLboolean _glewInit_GL_EXT_texture_integer (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glClearColorIiEXT = (PFNGLCLEARCOLORIIEXTPROC)glewGetProcAddress((const GLubyte*)"glClearColorIiEXT")) == NULL) || r; - r = ((glClearColorIuiEXT = (PFNGLCLEARCOLORIUIEXTPROC)glewGetProcAddress((const GLubyte*)"glClearColorIuiEXT")) == NULL) || r; - r = ((glGetTexParameterIivEXT = (PFNGLGETTEXPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterIivEXT")) == NULL) || r; - r = ((glGetTexParameterIuivEXT = (PFNGLGETTEXPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTexParameterIuivEXT")) == NULL) || r; - r = ((glTexParameterIivEXT = (PFNGLTEXPARAMETERIIVEXTPROC)glewGetProcAddress((const GLubyte*)"glTexParameterIivEXT")) == NULL) || r; - r = ((glTexParameterIuivEXT = (PFNGLTEXPARAMETERIUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glTexParameterIuivEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_texture_integer */ - -#ifdef GL_EXT_texture_lod_bias - -#endif /* GL_EXT_texture_lod_bias */ - -#ifdef GL_EXT_texture_mirror_clamp - -#endif /* GL_EXT_texture_mirror_clamp */ - -#ifdef GL_EXT_texture_object - -static GLboolean _glewInit_GL_EXT_texture_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glAreTexturesResidentEXT = (PFNGLARETEXTURESRESIDENTEXTPROC)glewGetProcAddress((const GLubyte*)"glAreTexturesResidentEXT")) == NULL) || r; - r = ((glBindTextureEXT = (PFNGLBINDTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glBindTextureEXT")) == NULL) || r; - r = ((glDeleteTexturesEXT = (PFNGLDELETETEXTURESEXTPROC)glewGetProcAddress((const GLubyte*)"glDeleteTexturesEXT")) == NULL) || r; - r = ((glGenTexturesEXT = (PFNGLGENTEXTURESEXTPROC)glewGetProcAddress((const GLubyte*)"glGenTexturesEXT")) == NULL) || r; - r = ((glIsTextureEXT = (PFNGLISTEXTUREEXTPROC)glewGetProcAddress((const GLubyte*)"glIsTextureEXT")) == NULL) || r; - r = ((glPrioritizeTexturesEXT = (PFNGLPRIORITIZETEXTURESEXTPROC)glewGetProcAddress((const GLubyte*)"glPrioritizeTexturesEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_texture_object */ - -#ifdef GL_EXT_texture_perturb_normal - -static GLboolean _glewInit_GL_EXT_texture_perturb_normal (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTextureNormalEXT = (PFNGLTEXTURENORMALEXTPROC)glewGetProcAddress((const GLubyte*)"glTextureNormalEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_texture_perturb_normal */ - -#ifdef GL_EXT_texture_rectangle - -#endif /* GL_EXT_texture_rectangle */ - -#ifdef GL_EXT_texture_sRGB - -#endif /* GL_EXT_texture_sRGB */ - -#ifdef GL_EXT_texture_shared_exponent - -#endif /* GL_EXT_texture_shared_exponent */ - -#ifdef GL_EXT_texture_swizzle - -#endif /* GL_EXT_texture_swizzle */ - -#ifdef GL_EXT_timer_query - -static GLboolean _glewInit_GL_EXT_timer_query (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetQueryObjecti64vEXT = (PFNGLGETQUERYOBJECTI64VEXTPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjecti64vEXT")) == NULL) || r; - r = ((glGetQueryObjectui64vEXT = (PFNGLGETQUERYOBJECTUI64VEXTPROC)glewGetProcAddress((const GLubyte*)"glGetQueryObjectui64vEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_timer_query */ - -#ifdef GL_EXT_transform_feedback - -static GLboolean _glewInit_GL_EXT_transform_feedback (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBeginTransformFeedbackEXT = (PFNGLBEGINTRANSFORMFEEDBACKEXTPROC)glewGetProcAddress((const GLubyte*)"glBeginTransformFeedbackEXT")) == NULL) || r; - r = ((glBindBufferBaseEXT = (PFNGLBINDBUFFERBASEEXTPROC)glewGetProcAddress((const GLubyte*)"glBindBufferBaseEXT")) == NULL) || r; - r = ((glBindBufferOffsetEXT = (PFNGLBINDBUFFEROFFSETEXTPROC)glewGetProcAddress((const GLubyte*)"glBindBufferOffsetEXT")) == NULL) || r; - r = ((glBindBufferRangeEXT = (PFNGLBINDBUFFERRANGEEXTPROC)glewGetProcAddress((const GLubyte*)"glBindBufferRangeEXT")) == NULL) || r; - r = ((glEndTransformFeedbackEXT = (PFNGLENDTRANSFORMFEEDBACKEXTPROC)glewGetProcAddress((const GLubyte*)"glEndTransformFeedbackEXT")) == NULL) || r; - r = ((glGetTransformFeedbackVaryingEXT = (PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC)glewGetProcAddress((const GLubyte*)"glGetTransformFeedbackVaryingEXT")) == NULL) || r; - r = ((glTransformFeedbackVaryingsEXT = (PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC)glewGetProcAddress((const GLubyte*)"glTransformFeedbackVaryingsEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_transform_feedback */ - -#ifdef GL_EXT_vertex_array - -static GLboolean _glewInit_GL_EXT_vertex_array (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glArrayElementEXT = (PFNGLARRAYELEMENTEXTPROC)glewGetProcAddress((const GLubyte*)"glArrayElementEXT")) == NULL) || r; - r = ((glColorPointerEXT = (PFNGLCOLORPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glColorPointerEXT")) == NULL) || r; - r = ((glDrawArraysEXT = (PFNGLDRAWARRAYSEXTPROC)glewGetProcAddress((const GLubyte*)"glDrawArraysEXT")) == NULL) || r; - r = ((glEdgeFlagPointerEXT = (PFNGLEDGEFLAGPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glEdgeFlagPointerEXT")) == NULL) || r; - r = ((glGetPointervEXT = (PFNGLGETPOINTERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetPointervEXT")) == NULL) || r; - r = ((glIndexPointerEXT = (PFNGLINDEXPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glIndexPointerEXT")) == NULL) || r; - r = ((glNormalPointerEXT = (PFNGLNORMALPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glNormalPointerEXT")) == NULL) || r; - r = ((glTexCoordPointerEXT = (PFNGLTEXCOORDPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glTexCoordPointerEXT")) == NULL) || r; - r = ((glVertexPointerEXT = (PFNGLVERTEXPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glVertexPointerEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_vertex_array */ - -#ifdef GL_EXT_vertex_array_bgra - -#endif /* GL_EXT_vertex_array_bgra */ - -#ifdef GL_EXT_vertex_shader - -static GLboolean _glewInit_GL_EXT_vertex_shader (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBeginVertexShaderEXT = (PFNGLBEGINVERTEXSHADEREXTPROC)glewGetProcAddress((const GLubyte*)"glBeginVertexShaderEXT")) == NULL) || r; - r = ((glBindLightParameterEXT = (PFNGLBINDLIGHTPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindLightParameterEXT")) == NULL) || r; - r = ((glBindMaterialParameterEXT = (PFNGLBINDMATERIALPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindMaterialParameterEXT")) == NULL) || r; - r = ((glBindParameterEXT = (PFNGLBINDPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindParameterEXT")) == NULL) || r; - r = ((glBindTexGenParameterEXT = (PFNGLBINDTEXGENPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindTexGenParameterEXT")) == NULL) || r; - r = ((glBindTextureUnitParameterEXT = (PFNGLBINDTEXTUREUNITPARAMETEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindTextureUnitParameterEXT")) == NULL) || r; - r = ((glBindVertexShaderEXT = (PFNGLBINDVERTEXSHADEREXTPROC)glewGetProcAddress((const GLubyte*)"glBindVertexShaderEXT")) == NULL) || r; - r = ((glDeleteVertexShaderEXT = (PFNGLDELETEVERTEXSHADEREXTPROC)glewGetProcAddress((const GLubyte*)"glDeleteVertexShaderEXT")) == NULL) || r; - r = ((glDisableVariantClientStateEXT = (PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC)glewGetProcAddress((const GLubyte*)"glDisableVariantClientStateEXT")) == NULL) || r; - r = ((glEnableVariantClientStateEXT = (PFNGLENABLEVARIANTCLIENTSTATEEXTPROC)glewGetProcAddress((const GLubyte*)"glEnableVariantClientStateEXT")) == NULL) || r; - r = ((glEndVertexShaderEXT = (PFNGLENDVERTEXSHADEREXTPROC)glewGetProcAddress((const GLubyte*)"glEndVertexShaderEXT")) == NULL) || r; - r = ((glExtractComponentEXT = (PFNGLEXTRACTCOMPONENTEXTPROC)glewGetProcAddress((const GLubyte*)"glExtractComponentEXT")) == NULL) || r; - r = ((glGenSymbolsEXT = (PFNGLGENSYMBOLSEXTPROC)glewGetProcAddress((const GLubyte*)"glGenSymbolsEXT")) == NULL) || r; - r = ((glGenVertexShadersEXT = (PFNGLGENVERTEXSHADERSEXTPROC)glewGetProcAddress((const GLubyte*)"glGenVertexShadersEXT")) == NULL) || r; - r = ((glGetInvariantBooleanvEXT = (PFNGLGETINVARIANTBOOLEANVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetInvariantBooleanvEXT")) == NULL) || r; - r = ((glGetInvariantFloatvEXT = (PFNGLGETINVARIANTFLOATVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetInvariantFloatvEXT")) == NULL) || r; - r = ((glGetInvariantIntegervEXT = (PFNGLGETINVARIANTINTEGERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetInvariantIntegervEXT")) == NULL) || r; - r = ((glGetLocalConstantBooleanvEXT = (PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetLocalConstantBooleanvEXT")) == NULL) || r; - r = ((glGetLocalConstantFloatvEXT = (PFNGLGETLOCALCONSTANTFLOATVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetLocalConstantFloatvEXT")) == NULL) || r; - r = ((glGetLocalConstantIntegervEXT = (PFNGLGETLOCALCONSTANTINTEGERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetLocalConstantIntegervEXT")) == NULL) || r; - r = ((glGetVariantBooleanvEXT = (PFNGLGETVARIANTBOOLEANVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVariantBooleanvEXT")) == NULL) || r; - r = ((glGetVariantFloatvEXT = (PFNGLGETVARIANTFLOATVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVariantFloatvEXT")) == NULL) || r; - r = ((glGetVariantIntegervEXT = (PFNGLGETVARIANTINTEGERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVariantIntegervEXT")) == NULL) || r; - r = ((glGetVariantPointervEXT = (PFNGLGETVARIANTPOINTERVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetVariantPointervEXT")) == NULL) || r; - r = ((glInsertComponentEXT = (PFNGLINSERTCOMPONENTEXTPROC)glewGetProcAddress((const GLubyte*)"glInsertComponentEXT")) == NULL) || r; - r = ((glIsVariantEnabledEXT = (PFNGLISVARIANTENABLEDEXTPROC)glewGetProcAddress((const GLubyte*)"glIsVariantEnabledEXT")) == NULL) || r; - r = ((glSetInvariantEXT = (PFNGLSETINVARIANTEXTPROC)glewGetProcAddress((const GLubyte*)"glSetInvariantEXT")) == NULL) || r; - r = ((glSetLocalConstantEXT = (PFNGLSETLOCALCONSTANTEXTPROC)glewGetProcAddress((const GLubyte*)"glSetLocalConstantEXT")) == NULL) || r; - r = ((glShaderOp1EXT = (PFNGLSHADEROP1EXTPROC)glewGetProcAddress((const GLubyte*)"glShaderOp1EXT")) == NULL) || r; - r = ((glShaderOp2EXT = (PFNGLSHADEROP2EXTPROC)glewGetProcAddress((const GLubyte*)"glShaderOp2EXT")) == NULL) || r; - r = ((glShaderOp3EXT = (PFNGLSHADEROP3EXTPROC)glewGetProcAddress((const GLubyte*)"glShaderOp3EXT")) == NULL) || r; - r = ((glSwizzleEXT = (PFNGLSWIZZLEEXTPROC)glewGetProcAddress((const GLubyte*)"glSwizzleEXT")) == NULL) || r; - r = ((glVariantPointerEXT = (PFNGLVARIANTPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glVariantPointerEXT")) == NULL) || r; - r = ((glVariantbvEXT = (PFNGLVARIANTBVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantbvEXT")) == NULL) || r; - r = ((glVariantdvEXT = (PFNGLVARIANTDVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantdvEXT")) == NULL) || r; - r = ((glVariantfvEXT = (PFNGLVARIANTFVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantfvEXT")) == NULL) || r; - r = ((glVariantivEXT = (PFNGLVARIANTIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantivEXT")) == NULL) || r; - r = ((glVariantsvEXT = (PFNGLVARIANTSVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantsvEXT")) == NULL) || r; - r = ((glVariantubvEXT = (PFNGLVARIANTUBVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantubvEXT")) == NULL) || r; - r = ((glVariantuivEXT = (PFNGLVARIANTUIVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantuivEXT")) == NULL) || r; - r = ((glVariantusvEXT = (PFNGLVARIANTUSVEXTPROC)glewGetProcAddress((const GLubyte*)"glVariantusvEXT")) == NULL) || r; - r = ((glWriteMaskEXT = (PFNGLWRITEMASKEXTPROC)glewGetProcAddress((const GLubyte*)"glWriteMaskEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_vertex_shader */ - -#ifdef GL_EXT_vertex_weighting - -static GLboolean _glewInit_GL_EXT_vertex_weighting (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glVertexWeightPointerEXT = (PFNGLVERTEXWEIGHTPOINTEREXTPROC)glewGetProcAddress((const GLubyte*)"glVertexWeightPointerEXT")) == NULL) || r; - r = ((glVertexWeightfEXT = (PFNGLVERTEXWEIGHTFEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexWeightfEXT")) == NULL) || r; - r = ((glVertexWeightfvEXT = (PFNGLVERTEXWEIGHTFVEXTPROC)glewGetProcAddress((const GLubyte*)"glVertexWeightfvEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_EXT_vertex_weighting */ - -#ifdef GL_GREMEDY_frame_terminator - -static GLboolean _glewInit_GL_GREMEDY_frame_terminator (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFrameTerminatorGREMEDY = (PFNGLFRAMETERMINATORGREMEDYPROC)glewGetProcAddress((const GLubyte*)"glFrameTerminatorGREMEDY")) == NULL) || r; - - return r; -} - -#endif /* GL_GREMEDY_frame_terminator */ - -#ifdef GL_GREMEDY_string_marker - -static GLboolean _glewInit_GL_GREMEDY_string_marker (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glStringMarkerGREMEDY = (PFNGLSTRINGMARKERGREMEDYPROC)glewGetProcAddress((const GLubyte*)"glStringMarkerGREMEDY")) == NULL) || r; - - return r; -} - -#endif /* GL_GREMEDY_string_marker */ - -#ifdef GL_HP_convolution_border_modes - -#endif /* GL_HP_convolution_border_modes */ - -#ifdef GL_HP_image_transform - -static GLboolean _glewInit_GL_HP_image_transform (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetImageTransformParameterfvHP = (PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC)glewGetProcAddress((const GLubyte*)"glGetImageTransformParameterfvHP")) == NULL) || r; - r = ((glGetImageTransformParameterivHP = (PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC)glewGetProcAddress((const GLubyte*)"glGetImageTransformParameterivHP")) == NULL) || r; - r = ((glImageTransformParameterfHP = (PFNGLIMAGETRANSFORMPARAMETERFHPPROC)glewGetProcAddress((const GLubyte*)"glImageTransformParameterfHP")) == NULL) || r; - r = ((glImageTransformParameterfvHP = (PFNGLIMAGETRANSFORMPARAMETERFVHPPROC)glewGetProcAddress((const GLubyte*)"glImageTransformParameterfvHP")) == NULL) || r; - r = ((glImageTransformParameteriHP = (PFNGLIMAGETRANSFORMPARAMETERIHPPROC)glewGetProcAddress((const GLubyte*)"glImageTransformParameteriHP")) == NULL) || r; - r = ((glImageTransformParameterivHP = (PFNGLIMAGETRANSFORMPARAMETERIVHPPROC)glewGetProcAddress((const GLubyte*)"glImageTransformParameterivHP")) == NULL) || r; - - return r; -} - -#endif /* GL_HP_image_transform */ - -#ifdef GL_HP_occlusion_test - -#endif /* GL_HP_occlusion_test */ - -#ifdef GL_HP_texture_lighting - -#endif /* GL_HP_texture_lighting */ - -#ifdef GL_IBM_cull_vertex - -#endif /* GL_IBM_cull_vertex */ - -#ifdef GL_IBM_multimode_draw_arrays - -static GLboolean _glewInit_GL_IBM_multimode_draw_arrays (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glMultiModeDrawArraysIBM = (PFNGLMULTIMODEDRAWARRAYSIBMPROC)glewGetProcAddress((const GLubyte*)"glMultiModeDrawArraysIBM")) == NULL) || r; - r = ((glMultiModeDrawElementsIBM = (PFNGLMULTIMODEDRAWELEMENTSIBMPROC)glewGetProcAddress((const GLubyte*)"glMultiModeDrawElementsIBM")) == NULL) || r; - - return r; -} - -#endif /* GL_IBM_multimode_draw_arrays */ - -#ifdef GL_IBM_rasterpos_clip - -#endif /* GL_IBM_rasterpos_clip */ - -#ifdef GL_IBM_static_data - -#endif /* GL_IBM_static_data */ - -#ifdef GL_IBM_texture_mirrored_repeat - -#endif /* GL_IBM_texture_mirrored_repeat */ - -#ifdef GL_IBM_vertex_array_lists - -static GLboolean _glewInit_GL_IBM_vertex_array_lists (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glColorPointerListIBM = (PFNGLCOLORPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glColorPointerListIBM")) == NULL) || r; - r = ((glEdgeFlagPointerListIBM = (PFNGLEDGEFLAGPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glEdgeFlagPointerListIBM")) == NULL) || r; - r = ((glFogCoordPointerListIBM = (PFNGLFOGCOORDPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glFogCoordPointerListIBM")) == NULL) || r; - r = ((glIndexPointerListIBM = (PFNGLINDEXPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glIndexPointerListIBM")) == NULL) || r; - r = ((glNormalPointerListIBM = (PFNGLNORMALPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glNormalPointerListIBM")) == NULL) || r; - r = ((glSecondaryColorPointerListIBM = (PFNGLSECONDARYCOLORPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColorPointerListIBM")) == NULL) || r; - r = ((glTexCoordPointerListIBM = (PFNGLTEXCOORDPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glTexCoordPointerListIBM")) == NULL) || r; - r = ((glVertexPointerListIBM = (PFNGLVERTEXPOINTERLISTIBMPROC)glewGetProcAddress((const GLubyte*)"glVertexPointerListIBM")) == NULL) || r; - - return r; -} - -#endif /* GL_IBM_vertex_array_lists */ - -#ifdef GL_INGR_color_clamp - -#endif /* GL_INGR_color_clamp */ - -#ifdef GL_INGR_interlace_read - -#endif /* GL_INGR_interlace_read */ - -#ifdef GL_INTEL_parallel_arrays - -static GLboolean _glewInit_GL_INTEL_parallel_arrays (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glColorPointervINTEL = (PFNGLCOLORPOINTERVINTELPROC)glewGetProcAddress((const GLubyte*)"glColorPointervINTEL")) == NULL) || r; - r = ((glNormalPointervINTEL = (PFNGLNORMALPOINTERVINTELPROC)glewGetProcAddress((const GLubyte*)"glNormalPointervINTEL")) == NULL) || r; - r = ((glTexCoordPointervINTEL = (PFNGLTEXCOORDPOINTERVINTELPROC)glewGetProcAddress((const GLubyte*)"glTexCoordPointervINTEL")) == NULL) || r; - r = ((glVertexPointervINTEL = (PFNGLVERTEXPOINTERVINTELPROC)glewGetProcAddress((const GLubyte*)"glVertexPointervINTEL")) == NULL) || r; - - return r; -} - -#endif /* GL_INTEL_parallel_arrays */ - -#ifdef GL_INTEL_texture_scissor - -static GLboolean _glewInit_GL_INTEL_texture_scissor (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTexScissorFuncINTEL = (PFNGLTEXSCISSORFUNCINTELPROC)glewGetProcAddress((const GLubyte*)"glTexScissorFuncINTEL")) == NULL) || r; - r = ((glTexScissorINTEL = (PFNGLTEXSCISSORINTELPROC)glewGetProcAddress((const GLubyte*)"glTexScissorINTEL")) == NULL) || r; - - return r; -} - -#endif /* GL_INTEL_texture_scissor */ - -#ifdef GL_KTX_buffer_region - -static GLboolean _glewInit_GL_KTX_buffer_region (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBufferRegionEnabledEXT = (PFNGLBUFFERREGIONENABLEDEXTPROC)glewGetProcAddress((const GLubyte*)"glBufferRegionEnabledEXT")) == NULL) || r; - r = ((glDeleteBufferRegionEXT = (PFNGLDELETEBUFFERREGIONEXTPROC)glewGetProcAddress((const GLubyte*)"glDeleteBufferRegionEXT")) == NULL) || r; - r = ((glDrawBufferRegionEXT = (PFNGLDRAWBUFFERREGIONEXTPROC)glewGetProcAddress((const GLubyte*)"glDrawBufferRegionEXT")) == NULL) || r; - r = ((glNewBufferRegionEXT = (PFNGLNEWBUFFERREGIONEXTPROC)glewGetProcAddress((const GLubyte*)"glNewBufferRegionEXT")) == NULL) || r; - r = ((glReadBufferRegionEXT = (PFNGLREADBUFFERREGIONEXTPROC)glewGetProcAddress((const GLubyte*)"glReadBufferRegionEXT")) == NULL) || r; - - return r; -} - -#endif /* GL_KTX_buffer_region */ - -#ifdef GL_MESAX_texture_stack - -#endif /* GL_MESAX_texture_stack */ - -#ifdef GL_MESA_pack_invert - -#endif /* GL_MESA_pack_invert */ - -#ifdef GL_MESA_resize_buffers - -static GLboolean _glewInit_GL_MESA_resize_buffers (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glResizeBuffersMESA = (PFNGLRESIZEBUFFERSMESAPROC)glewGetProcAddress((const GLubyte*)"glResizeBuffersMESA")) == NULL) || r; - - return r; -} - -#endif /* GL_MESA_resize_buffers */ - -#ifdef GL_MESA_window_pos - -static GLboolean _glewInit_GL_MESA_window_pos (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glWindowPos2dMESA = (PFNGLWINDOWPOS2DMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2dMESA")) == NULL) || r; - r = ((glWindowPos2dvMESA = (PFNGLWINDOWPOS2DVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2dvMESA")) == NULL) || r; - r = ((glWindowPos2fMESA = (PFNGLWINDOWPOS2FMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2fMESA")) == NULL) || r; - r = ((glWindowPos2fvMESA = (PFNGLWINDOWPOS2FVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2fvMESA")) == NULL) || r; - r = ((glWindowPos2iMESA = (PFNGLWINDOWPOS2IMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2iMESA")) == NULL) || r; - r = ((glWindowPos2ivMESA = (PFNGLWINDOWPOS2IVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2ivMESA")) == NULL) || r; - r = ((glWindowPos2sMESA = (PFNGLWINDOWPOS2SMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2sMESA")) == NULL) || r; - r = ((glWindowPos2svMESA = (PFNGLWINDOWPOS2SVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos2svMESA")) == NULL) || r; - r = ((glWindowPos3dMESA = (PFNGLWINDOWPOS3DMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3dMESA")) == NULL) || r; - r = ((glWindowPos3dvMESA = (PFNGLWINDOWPOS3DVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3dvMESA")) == NULL) || r; - r = ((glWindowPos3fMESA = (PFNGLWINDOWPOS3FMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3fMESA")) == NULL) || r; - r = ((glWindowPos3fvMESA = (PFNGLWINDOWPOS3FVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3fvMESA")) == NULL) || r; - r = ((glWindowPos3iMESA = (PFNGLWINDOWPOS3IMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3iMESA")) == NULL) || r; - r = ((glWindowPos3ivMESA = (PFNGLWINDOWPOS3IVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3ivMESA")) == NULL) || r; - r = ((glWindowPos3sMESA = (PFNGLWINDOWPOS3SMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3sMESA")) == NULL) || r; - r = ((glWindowPos3svMESA = (PFNGLWINDOWPOS3SVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos3svMESA")) == NULL) || r; - r = ((glWindowPos4dMESA = (PFNGLWINDOWPOS4DMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4dMESA")) == NULL) || r; - r = ((glWindowPos4dvMESA = (PFNGLWINDOWPOS4DVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4dvMESA")) == NULL) || r; - r = ((glWindowPos4fMESA = (PFNGLWINDOWPOS4FMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4fMESA")) == NULL) || r; - r = ((glWindowPos4fvMESA = (PFNGLWINDOWPOS4FVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4fvMESA")) == NULL) || r; - r = ((glWindowPos4iMESA = (PFNGLWINDOWPOS4IMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4iMESA")) == NULL) || r; - r = ((glWindowPos4ivMESA = (PFNGLWINDOWPOS4IVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4ivMESA")) == NULL) || r; - r = ((glWindowPos4sMESA = (PFNGLWINDOWPOS4SMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4sMESA")) == NULL) || r; - r = ((glWindowPos4svMESA = (PFNGLWINDOWPOS4SVMESAPROC)glewGetProcAddress((const GLubyte*)"glWindowPos4svMESA")) == NULL) || r; - - return r; -} - -#endif /* GL_MESA_window_pos */ - -#ifdef GL_MESA_ycbcr_texture - -#endif /* GL_MESA_ycbcr_texture */ - -#ifdef GL_NV_blend_square - -#endif /* GL_NV_blend_square */ - -#ifdef GL_NV_conditional_render - -static GLboolean _glewInit_GL_NV_conditional_render (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBeginConditionalRenderNV = (PFNGLBEGINCONDITIONALRENDERNVPROC)glewGetProcAddress((const GLubyte*)"glBeginConditionalRenderNV")) == NULL) || r; - r = ((glEndConditionalRenderNV = (PFNGLENDCONDITIONALRENDERNVPROC)glewGetProcAddress((const GLubyte*)"glEndConditionalRenderNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_conditional_render */ - -#ifdef GL_NV_copy_depth_to_color - -#endif /* GL_NV_copy_depth_to_color */ - -#ifdef GL_NV_depth_buffer_float - -static GLboolean _glewInit_GL_NV_depth_buffer_float (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glClearDepthdNV = (PFNGLCLEARDEPTHDNVPROC)glewGetProcAddress((const GLubyte*)"glClearDepthdNV")) == NULL) || r; - r = ((glDepthBoundsdNV = (PFNGLDEPTHBOUNDSDNVPROC)glewGetProcAddress((const GLubyte*)"glDepthBoundsdNV")) == NULL) || r; - r = ((glDepthRangedNV = (PFNGLDEPTHRANGEDNVPROC)glewGetProcAddress((const GLubyte*)"glDepthRangedNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_depth_buffer_float */ - -#ifdef GL_NV_depth_clamp - -#endif /* GL_NV_depth_clamp */ - -#ifdef GL_NV_depth_range_unclamped - -#endif /* GL_NV_depth_range_unclamped */ - -#ifdef GL_NV_evaluators - -static GLboolean _glewInit_GL_NV_evaluators (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glEvalMapsNV = (PFNGLEVALMAPSNVPROC)glewGetProcAddress((const GLubyte*)"glEvalMapsNV")) == NULL) || r; - r = ((glGetMapAttribParameterfvNV = (PFNGLGETMAPATTRIBPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetMapAttribParameterfvNV")) == NULL) || r; - r = ((glGetMapAttribParameterivNV = (PFNGLGETMAPATTRIBPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetMapAttribParameterivNV")) == NULL) || r; - r = ((glGetMapControlPointsNV = (PFNGLGETMAPCONTROLPOINTSNVPROC)glewGetProcAddress((const GLubyte*)"glGetMapControlPointsNV")) == NULL) || r; - r = ((glGetMapParameterfvNV = (PFNGLGETMAPPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetMapParameterfvNV")) == NULL) || r; - r = ((glGetMapParameterivNV = (PFNGLGETMAPPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetMapParameterivNV")) == NULL) || r; - r = ((glMapControlPointsNV = (PFNGLMAPCONTROLPOINTSNVPROC)glewGetProcAddress((const GLubyte*)"glMapControlPointsNV")) == NULL) || r; - r = ((glMapParameterfvNV = (PFNGLMAPPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glMapParameterfvNV")) == NULL) || r; - r = ((glMapParameterivNV = (PFNGLMAPPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glMapParameterivNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_evaluators */ - -#ifdef GL_NV_explicit_multisample - -static GLboolean _glewInit_GL_NV_explicit_multisample (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetMultisamplefvNV = (PFNGLGETMULTISAMPLEFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetMultisamplefvNV")) == NULL) || r; - r = ((glSampleMaskIndexedNV = (PFNGLSAMPLEMASKINDEXEDNVPROC)glewGetProcAddress((const GLubyte*)"glSampleMaskIndexedNV")) == NULL) || r; - r = ((glTexRenderbufferNV = (PFNGLTEXRENDERBUFFERNVPROC)glewGetProcAddress((const GLubyte*)"glTexRenderbufferNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_explicit_multisample */ - -#ifdef GL_NV_fence - -static GLboolean _glewInit_GL_NV_fence (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDeleteFencesNV = (PFNGLDELETEFENCESNVPROC)glewGetProcAddress((const GLubyte*)"glDeleteFencesNV")) == NULL) || r; - r = ((glFinishFenceNV = (PFNGLFINISHFENCENVPROC)glewGetProcAddress((const GLubyte*)"glFinishFenceNV")) == NULL) || r; - r = ((glGenFencesNV = (PFNGLGENFENCESNVPROC)glewGetProcAddress((const GLubyte*)"glGenFencesNV")) == NULL) || r; - r = ((glGetFenceivNV = (PFNGLGETFENCEIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetFenceivNV")) == NULL) || r; - r = ((glIsFenceNV = (PFNGLISFENCENVPROC)glewGetProcAddress((const GLubyte*)"glIsFenceNV")) == NULL) || r; - r = ((glSetFenceNV = (PFNGLSETFENCENVPROC)glewGetProcAddress((const GLubyte*)"glSetFenceNV")) == NULL) || r; - r = ((glTestFenceNV = (PFNGLTESTFENCENVPROC)glewGetProcAddress((const GLubyte*)"glTestFenceNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_fence */ - -#ifdef GL_NV_float_buffer - -#endif /* GL_NV_float_buffer */ - -#ifdef GL_NV_fog_distance - -#endif /* GL_NV_fog_distance */ - -#ifdef GL_NV_fragment_program - -static GLboolean _glewInit_GL_NV_fragment_program (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetProgramNamedParameterdvNV = (PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramNamedParameterdvNV")) == NULL) || r; - r = ((glGetProgramNamedParameterfvNV = (PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramNamedParameterfvNV")) == NULL) || r; - r = ((glProgramNamedParameter4dNV = (PFNGLPROGRAMNAMEDPARAMETER4DNVPROC)glewGetProcAddress((const GLubyte*)"glProgramNamedParameter4dNV")) == NULL) || r; - r = ((glProgramNamedParameter4dvNV = (PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramNamedParameter4dvNV")) == NULL) || r; - r = ((glProgramNamedParameter4fNV = (PFNGLPROGRAMNAMEDPARAMETER4FNVPROC)glewGetProcAddress((const GLubyte*)"glProgramNamedParameter4fNV")) == NULL) || r; - r = ((glProgramNamedParameter4fvNV = (PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramNamedParameter4fvNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_fragment_program */ - -#ifdef GL_NV_fragment_program2 - -#endif /* GL_NV_fragment_program2 */ - -#ifdef GL_NV_fragment_program4 - -#endif /* GL_NV_fragment_program4 */ - -#ifdef GL_NV_fragment_program_option - -#endif /* GL_NV_fragment_program_option */ - -#ifdef GL_NV_framebuffer_multisample_coverage - -static GLboolean _glewInit_GL_NV_framebuffer_multisample_coverage (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glRenderbufferStorageMultisampleCoverageNV = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC)glewGetProcAddress((const GLubyte*)"glRenderbufferStorageMultisampleCoverageNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_framebuffer_multisample_coverage */ - -#ifdef GL_NV_geometry_program4 - -static GLboolean _glewInit_GL_NV_geometry_program4 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glProgramVertexLimitNV = (PFNGLPROGRAMVERTEXLIMITNVPROC)glewGetProcAddress((const GLubyte*)"glProgramVertexLimitNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_geometry_program4 */ - -#ifdef GL_NV_geometry_shader4 - -#endif /* GL_NV_geometry_shader4 */ - -#ifdef GL_NV_gpu_program4 - -static GLboolean _glewInit_GL_NV_gpu_program4 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glProgramEnvParameterI4iNV = (PFNGLPROGRAMENVPARAMETERI4INVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameterI4iNV")) == NULL) || r; - r = ((glProgramEnvParameterI4ivNV = (PFNGLPROGRAMENVPARAMETERI4IVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameterI4ivNV")) == NULL) || r; - r = ((glProgramEnvParameterI4uiNV = (PFNGLPROGRAMENVPARAMETERI4UINVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameterI4uiNV")) == NULL) || r; - r = ((glProgramEnvParameterI4uivNV = (PFNGLPROGRAMENVPARAMETERI4UIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParameterI4uivNV")) == NULL) || r; - r = ((glProgramEnvParametersI4ivNV = (PFNGLPROGRAMENVPARAMETERSI4IVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParametersI4ivNV")) == NULL) || r; - r = ((glProgramEnvParametersI4uivNV = (PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramEnvParametersI4uivNV")) == NULL) || r; - r = ((glProgramLocalParameterI4iNV = (PFNGLPROGRAMLOCALPARAMETERI4INVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameterI4iNV")) == NULL) || r; - r = ((glProgramLocalParameterI4ivNV = (PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameterI4ivNV")) == NULL) || r; - r = ((glProgramLocalParameterI4uiNV = (PFNGLPROGRAMLOCALPARAMETERI4UINVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameterI4uiNV")) == NULL) || r; - r = ((glProgramLocalParameterI4uivNV = (PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParameterI4uivNV")) == NULL) || r; - r = ((glProgramLocalParametersI4ivNV = (PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParametersI4ivNV")) == NULL) || r; - r = ((glProgramLocalParametersI4uivNV = (PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramLocalParametersI4uivNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_gpu_program4 */ - -#ifdef GL_NV_half_float - -static GLboolean _glewInit_GL_NV_half_float (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glColor3hNV = (PFNGLCOLOR3HNVPROC)glewGetProcAddress((const GLubyte*)"glColor3hNV")) == NULL) || r; - r = ((glColor3hvNV = (PFNGLCOLOR3HVNVPROC)glewGetProcAddress((const GLubyte*)"glColor3hvNV")) == NULL) || r; - r = ((glColor4hNV = (PFNGLCOLOR4HNVPROC)glewGetProcAddress((const GLubyte*)"glColor4hNV")) == NULL) || r; - r = ((glColor4hvNV = (PFNGLCOLOR4HVNVPROC)glewGetProcAddress((const GLubyte*)"glColor4hvNV")) == NULL) || r; - r = ((glFogCoordhNV = (PFNGLFOGCOORDHNVPROC)glewGetProcAddress((const GLubyte*)"glFogCoordhNV")) == NULL) || r; - r = ((glFogCoordhvNV = (PFNGLFOGCOORDHVNVPROC)glewGetProcAddress((const GLubyte*)"glFogCoordhvNV")) == NULL) || r; - r = ((glMultiTexCoord1hNV = (PFNGLMULTITEXCOORD1HNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1hNV")) == NULL) || r; - r = ((glMultiTexCoord1hvNV = (PFNGLMULTITEXCOORD1HVNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord1hvNV")) == NULL) || r; - r = ((glMultiTexCoord2hNV = (PFNGLMULTITEXCOORD2HNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2hNV")) == NULL) || r; - r = ((glMultiTexCoord2hvNV = (PFNGLMULTITEXCOORD2HVNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord2hvNV")) == NULL) || r; - r = ((glMultiTexCoord3hNV = (PFNGLMULTITEXCOORD3HNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3hNV")) == NULL) || r; - r = ((glMultiTexCoord3hvNV = (PFNGLMULTITEXCOORD3HVNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord3hvNV")) == NULL) || r; - r = ((glMultiTexCoord4hNV = (PFNGLMULTITEXCOORD4HNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4hNV")) == NULL) || r; - r = ((glMultiTexCoord4hvNV = (PFNGLMULTITEXCOORD4HVNVPROC)glewGetProcAddress((const GLubyte*)"glMultiTexCoord4hvNV")) == NULL) || r; - r = ((glNormal3hNV = (PFNGLNORMAL3HNVPROC)glewGetProcAddress((const GLubyte*)"glNormal3hNV")) == NULL) || r; - r = ((glNormal3hvNV = (PFNGLNORMAL3HVNVPROC)glewGetProcAddress((const GLubyte*)"glNormal3hvNV")) == NULL) || r; - r = ((glSecondaryColor3hNV = (PFNGLSECONDARYCOLOR3HNVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3hNV")) == NULL) || r; - r = ((glSecondaryColor3hvNV = (PFNGLSECONDARYCOLOR3HVNVPROC)glewGetProcAddress((const GLubyte*)"glSecondaryColor3hvNV")) == NULL) || r; - r = ((glTexCoord1hNV = (PFNGLTEXCOORD1HNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord1hNV")) == NULL) || r; - r = ((glTexCoord1hvNV = (PFNGLTEXCOORD1HVNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord1hvNV")) == NULL) || r; - r = ((glTexCoord2hNV = (PFNGLTEXCOORD2HNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2hNV")) == NULL) || r; - r = ((glTexCoord2hvNV = (PFNGLTEXCOORD2HVNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2hvNV")) == NULL) || r; - r = ((glTexCoord3hNV = (PFNGLTEXCOORD3HNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord3hNV")) == NULL) || r; - r = ((glTexCoord3hvNV = (PFNGLTEXCOORD3HVNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord3hvNV")) == NULL) || r; - r = ((glTexCoord4hNV = (PFNGLTEXCOORD4HNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4hNV")) == NULL) || r; - r = ((glTexCoord4hvNV = (PFNGLTEXCOORD4HVNVPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4hvNV")) == NULL) || r; - r = ((glVertex2hNV = (PFNGLVERTEX2HNVPROC)glewGetProcAddress((const GLubyte*)"glVertex2hNV")) == NULL) || r; - r = ((glVertex2hvNV = (PFNGLVERTEX2HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertex2hvNV")) == NULL) || r; - r = ((glVertex3hNV = (PFNGLVERTEX3HNVPROC)glewGetProcAddress((const GLubyte*)"glVertex3hNV")) == NULL) || r; - r = ((glVertex3hvNV = (PFNGLVERTEX3HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertex3hvNV")) == NULL) || r; - r = ((glVertex4hNV = (PFNGLVERTEX4HNVPROC)glewGetProcAddress((const GLubyte*)"glVertex4hNV")) == NULL) || r; - r = ((glVertex4hvNV = (PFNGLVERTEX4HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertex4hvNV")) == NULL) || r; - r = ((glVertexAttrib1hNV = (PFNGLVERTEXATTRIB1HNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1hNV")) == NULL) || r; - r = ((glVertexAttrib1hvNV = (PFNGLVERTEXATTRIB1HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1hvNV")) == NULL) || r; - r = ((glVertexAttrib2hNV = (PFNGLVERTEXATTRIB2HNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2hNV")) == NULL) || r; - r = ((glVertexAttrib2hvNV = (PFNGLVERTEXATTRIB2HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2hvNV")) == NULL) || r; - r = ((glVertexAttrib3hNV = (PFNGLVERTEXATTRIB3HNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3hNV")) == NULL) || r; - r = ((glVertexAttrib3hvNV = (PFNGLVERTEXATTRIB3HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3hvNV")) == NULL) || r; - r = ((glVertexAttrib4hNV = (PFNGLVERTEXATTRIB4HNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4hNV")) == NULL) || r; - r = ((glVertexAttrib4hvNV = (PFNGLVERTEXATTRIB4HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4hvNV")) == NULL) || r; - r = ((glVertexAttribs1hvNV = (PFNGLVERTEXATTRIBS1HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs1hvNV")) == NULL) || r; - r = ((glVertexAttribs2hvNV = (PFNGLVERTEXATTRIBS2HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs2hvNV")) == NULL) || r; - r = ((glVertexAttribs3hvNV = (PFNGLVERTEXATTRIBS3HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs3hvNV")) == NULL) || r; - r = ((glVertexAttribs4hvNV = (PFNGLVERTEXATTRIBS4HVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs4hvNV")) == NULL) || r; - r = ((glVertexWeighthNV = (PFNGLVERTEXWEIGHTHNVPROC)glewGetProcAddress((const GLubyte*)"glVertexWeighthNV")) == NULL) || r; - r = ((glVertexWeighthvNV = (PFNGLVERTEXWEIGHTHVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexWeighthvNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_half_float */ - -#ifdef GL_NV_light_max_exponent - -#endif /* GL_NV_light_max_exponent */ - -#ifdef GL_NV_multisample_filter_hint - -#endif /* GL_NV_multisample_filter_hint */ - -#ifdef GL_NV_occlusion_query - -static GLboolean _glewInit_GL_NV_occlusion_query (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glBeginOcclusionQueryNV = (PFNGLBEGINOCCLUSIONQUERYNVPROC)glewGetProcAddress((const GLubyte*)"glBeginOcclusionQueryNV")) == NULL) || r; - r = ((glDeleteOcclusionQueriesNV = (PFNGLDELETEOCCLUSIONQUERIESNVPROC)glewGetProcAddress((const GLubyte*)"glDeleteOcclusionQueriesNV")) == NULL) || r; - r = ((glEndOcclusionQueryNV = (PFNGLENDOCCLUSIONQUERYNVPROC)glewGetProcAddress((const GLubyte*)"glEndOcclusionQueryNV")) == NULL) || r; - r = ((glGenOcclusionQueriesNV = (PFNGLGENOCCLUSIONQUERIESNVPROC)glewGetProcAddress((const GLubyte*)"glGenOcclusionQueriesNV")) == NULL) || r; - r = ((glGetOcclusionQueryivNV = (PFNGLGETOCCLUSIONQUERYIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetOcclusionQueryivNV")) == NULL) || r; - r = ((glGetOcclusionQueryuivNV = (PFNGLGETOCCLUSIONQUERYUIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetOcclusionQueryuivNV")) == NULL) || r; - r = ((glIsOcclusionQueryNV = (PFNGLISOCCLUSIONQUERYNVPROC)glewGetProcAddress((const GLubyte*)"glIsOcclusionQueryNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_occlusion_query */ - -#ifdef GL_NV_packed_depth_stencil - -#endif /* GL_NV_packed_depth_stencil */ - -#ifdef GL_NV_parameter_buffer_object - -static GLboolean _glewInit_GL_NV_parameter_buffer_object (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glProgramBufferParametersIivNV = (PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramBufferParametersIivNV")) == NULL) || r; - r = ((glProgramBufferParametersIuivNV = (PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramBufferParametersIuivNV")) == NULL) || r; - r = ((glProgramBufferParametersfvNV = (PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramBufferParametersfvNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_parameter_buffer_object */ - -#ifdef GL_NV_pixel_data_range - -static GLboolean _glewInit_GL_NV_pixel_data_range (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFlushPixelDataRangeNV = (PFNGLFLUSHPIXELDATARANGENVPROC)glewGetProcAddress((const GLubyte*)"glFlushPixelDataRangeNV")) == NULL) || r; - r = ((glPixelDataRangeNV = (PFNGLPIXELDATARANGENVPROC)glewGetProcAddress((const GLubyte*)"glPixelDataRangeNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_pixel_data_range */ - -#ifdef GL_NV_point_sprite - -static GLboolean _glewInit_GL_NV_point_sprite (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glPointParameteriNV = (PFNGLPOINTPARAMETERINVPROC)glewGetProcAddress((const GLubyte*)"glPointParameteriNV")) == NULL) || r; - r = ((glPointParameterivNV = (PFNGLPOINTPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glPointParameterivNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_point_sprite */ - -#ifdef GL_NV_present_video - -static GLboolean _glewInit_GL_NV_present_video (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetVideoi64vNV = (PFNGLGETVIDEOI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideoi64vNV")) == NULL) || r; - r = ((glGetVideoivNV = (PFNGLGETVIDEOIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideoivNV")) == NULL) || r; - r = ((glGetVideoui64vNV = (PFNGLGETVIDEOUI64VNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideoui64vNV")) == NULL) || r; - r = ((glGetVideouivNV = (PFNGLGETVIDEOUIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVideouivNV")) == NULL) || r; - r = ((glPresentFrameDualFillNV = (PFNGLPRESENTFRAMEDUALFILLNVPROC)glewGetProcAddress((const GLubyte*)"glPresentFrameDualFillNV")) == NULL) || r; - r = ((glPresentFrameKeyedNV = (PFNGLPRESENTFRAMEKEYEDNVPROC)glewGetProcAddress((const GLubyte*)"glPresentFrameKeyedNV")) == NULL) || r; - r = ((glVideoParameterivNV = (PFNGLVIDEOPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glVideoParameterivNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_present_video */ - -#ifdef GL_NV_primitive_restart - -static GLboolean _glewInit_GL_NV_primitive_restart (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glPrimitiveRestartIndexNV = (PFNGLPRIMITIVERESTARTINDEXNVPROC)glewGetProcAddress((const GLubyte*)"glPrimitiveRestartIndexNV")) == NULL) || r; - r = ((glPrimitiveRestartNV = (PFNGLPRIMITIVERESTARTNVPROC)glewGetProcAddress((const GLubyte*)"glPrimitiveRestartNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_primitive_restart */ - -#ifdef GL_NV_register_combiners - -static GLboolean _glewInit_GL_NV_register_combiners (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glCombinerInputNV = (PFNGLCOMBINERINPUTNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerInputNV")) == NULL) || r; - r = ((glCombinerOutputNV = (PFNGLCOMBINEROUTPUTNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerOutputNV")) == NULL) || r; - r = ((glCombinerParameterfNV = (PFNGLCOMBINERPARAMETERFNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerParameterfNV")) == NULL) || r; - r = ((glCombinerParameterfvNV = (PFNGLCOMBINERPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerParameterfvNV")) == NULL) || r; - r = ((glCombinerParameteriNV = (PFNGLCOMBINERPARAMETERINVPROC)glewGetProcAddress((const GLubyte*)"glCombinerParameteriNV")) == NULL) || r; - r = ((glCombinerParameterivNV = (PFNGLCOMBINERPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerParameterivNV")) == NULL) || r; - r = ((glFinalCombinerInputNV = (PFNGLFINALCOMBINERINPUTNVPROC)glewGetProcAddress((const GLubyte*)"glFinalCombinerInputNV")) == NULL) || r; - r = ((glGetCombinerInputParameterfvNV = (PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetCombinerInputParameterfvNV")) == NULL) || r; - r = ((glGetCombinerInputParameterivNV = (PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetCombinerInputParameterivNV")) == NULL) || r; - r = ((glGetCombinerOutputParameterfvNV = (PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetCombinerOutputParameterfvNV")) == NULL) || r; - r = ((glGetCombinerOutputParameterivNV = (PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetCombinerOutputParameterivNV")) == NULL) || r; - r = ((glGetFinalCombinerInputParameterfvNV = (PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetFinalCombinerInputParameterfvNV")) == NULL) || r; - r = ((glGetFinalCombinerInputParameterivNV = (PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetFinalCombinerInputParameterivNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_register_combiners */ - -#ifdef GL_NV_register_combiners2 - -static GLboolean _glewInit_GL_NV_register_combiners2 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glCombinerStageParameterfvNV = (PFNGLCOMBINERSTAGEPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glCombinerStageParameterfvNV")) == NULL) || r; - r = ((glGetCombinerStageParameterfvNV = (PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetCombinerStageParameterfvNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_register_combiners2 */ - -#ifdef GL_NV_texgen_emboss - -#endif /* GL_NV_texgen_emboss */ - -#ifdef GL_NV_texgen_reflection - -#endif /* GL_NV_texgen_reflection */ - -#ifdef GL_NV_texture_compression_vtc - -#endif /* GL_NV_texture_compression_vtc */ - -#ifdef GL_NV_texture_env_combine4 - -#endif /* GL_NV_texture_env_combine4 */ - -#ifdef GL_NV_texture_expand_normal - -#endif /* GL_NV_texture_expand_normal */ - -#ifdef GL_NV_texture_rectangle - -#endif /* GL_NV_texture_rectangle */ - -#ifdef GL_NV_texture_shader - -#endif /* GL_NV_texture_shader */ - -#ifdef GL_NV_texture_shader2 - -#endif /* GL_NV_texture_shader2 */ - -#ifdef GL_NV_texture_shader3 - -#endif /* GL_NV_texture_shader3 */ - -#ifdef GL_NV_transform_feedback - -static GLboolean _glewInit_GL_NV_transform_feedback (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glActiveVaryingNV = (PFNGLACTIVEVARYINGNVPROC)glewGetProcAddress((const GLubyte*)"glActiveVaryingNV")) == NULL) || r; - r = ((glBeginTransformFeedbackNV = (PFNGLBEGINTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)"glBeginTransformFeedbackNV")) == NULL) || r; - r = ((glBindBufferBaseNV = (PFNGLBINDBUFFERBASENVPROC)glewGetProcAddress((const GLubyte*)"glBindBufferBaseNV")) == NULL) || r; - r = ((glBindBufferOffsetNV = (PFNGLBINDBUFFEROFFSETNVPROC)glewGetProcAddress((const GLubyte*)"glBindBufferOffsetNV")) == NULL) || r; - r = ((glBindBufferRangeNV = (PFNGLBINDBUFFERRANGENVPROC)glewGetProcAddress((const GLubyte*)"glBindBufferRangeNV")) == NULL) || r; - r = ((glEndTransformFeedbackNV = (PFNGLENDTRANSFORMFEEDBACKNVPROC)glewGetProcAddress((const GLubyte*)"glEndTransformFeedbackNV")) == NULL) || r; - r = ((glGetActiveVaryingNV = (PFNGLGETACTIVEVARYINGNVPROC)glewGetProcAddress((const GLubyte*)"glGetActiveVaryingNV")) == NULL) || r; - r = ((glGetTransformFeedbackVaryingNV = (PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC)glewGetProcAddress((const GLubyte*)"glGetTransformFeedbackVaryingNV")) == NULL) || r; - r = ((glGetVaryingLocationNV = (PFNGLGETVARYINGLOCATIONNVPROC)glewGetProcAddress((const GLubyte*)"glGetVaryingLocationNV")) == NULL) || r; - r = ((glTransformFeedbackAttribsNV = (PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC)glewGetProcAddress((const GLubyte*)"glTransformFeedbackAttribsNV")) == NULL) || r; - r = ((glTransformFeedbackVaryingsNV = (PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC)glewGetProcAddress((const GLubyte*)"glTransformFeedbackVaryingsNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_transform_feedback */ - -#ifdef GL_NV_vertex_array_range - -static GLboolean _glewInit_GL_NV_vertex_array_range (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFlushVertexArrayRangeNV = (PFNGLFLUSHVERTEXARRAYRANGENVPROC)glewGetProcAddress((const GLubyte*)"glFlushVertexArrayRangeNV")) == NULL) || r; - r = ((glVertexArrayRangeNV = (PFNGLVERTEXARRAYRANGENVPROC)glewGetProcAddress((const GLubyte*)"glVertexArrayRangeNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_vertex_array_range */ - -#ifdef GL_NV_vertex_array_range2 - -#endif /* GL_NV_vertex_array_range2 */ - -#ifdef GL_NV_vertex_program - -static GLboolean _glewInit_GL_NV_vertex_program (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glAreProgramsResidentNV = (PFNGLAREPROGRAMSRESIDENTNVPROC)glewGetProcAddress((const GLubyte*)"glAreProgramsResidentNV")) == NULL) || r; - r = ((glBindProgramNV = (PFNGLBINDPROGRAMNVPROC)glewGetProcAddress((const GLubyte*)"glBindProgramNV")) == NULL) || r; - r = ((glDeleteProgramsNV = (PFNGLDELETEPROGRAMSNVPROC)glewGetProcAddress((const GLubyte*)"glDeleteProgramsNV")) == NULL) || r; - r = ((glExecuteProgramNV = (PFNGLEXECUTEPROGRAMNVPROC)glewGetProcAddress((const GLubyte*)"glExecuteProgramNV")) == NULL) || r; - r = ((glGenProgramsNV = (PFNGLGENPROGRAMSNVPROC)glewGetProcAddress((const GLubyte*)"glGenProgramsNV")) == NULL) || r; - r = ((glGetProgramParameterdvNV = (PFNGLGETPROGRAMPARAMETERDVNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramParameterdvNV")) == NULL) || r; - r = ((glGetProgramParameterfvNV = (PFNGLGETPROGRAMPARAMETERFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramParameterfvNV")) == NULL) || r; - r = ((glGetProgramStringNV = (PFNGLGETPROGRAMSTRINGNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramStringNV")) == NULL) || r; - r = ((glGetProgramivNV = (PFNGLGETPROGRAMIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetProgramivNV")) == NULL) || r; - r = ((glGetTrackMatrixivNV = (PFNGLGETTRACKMATRIXIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetTrackMatrixivNV")) == NULL) || r; - r = ((glGetVertexAttribPointervNV = (PFNGLGETVERTEXATTRIBPOINTERVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribPointervNV")) == NULL) || r; - r = ((glGetVertexAttribdvNV = (PFNGLGETVERTEXATTRIBDVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribdvNV")) == NULL) || r; - r = ((glGetVertexAttribfvNV = (PFNGLGETVERTEXATTRIBFVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribfvNV")) == NULL) || r; - r = ((glGetVertexAttribivNV = (PFNGLGETVERTEXATTRIBIVNVPROC)glewGetProcAddress((const GLubyte*)"glGetVertexAttribivNV")) == NULL) || r; - r = ((glIsProgramNV = (PFNGLISPROGRAMNVPROC)glewGetProcAddress((const GLubyte*)"glIsProgramNV")) == NULL) || r; - r = ((glLoadProgramNV = (PFNGLLOADPROGRAMNVPROC)glewGetProcAddress((const GLubyte*)"glLoadProgramNV")) == NULL) || r; - r = ((glProgramParameter4dNV = (PFNGLPROGRAMPARAMETER4DNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameter4dNV")) == NULL) || r; - r = ((glProgramParameter4dvNV = (PFNGLPROGRAMPARAMETER4DVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameter4dvNV")) == NULL) || r; - r = ((glProgramParameter4fNV = (PFNGLPROGRAMPARAMETER4FNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameter4fNV")) == NULL) || r; - r = ((glProgramParameter4fvNV = (PFNGLPROGRAMPARAMETER4FVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameter4fvNV")) == NULL) || r; - r = ((glProgramParameters4dvNV = (PFNGLPROGRAMPARAMETERS4DVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameters4dvNV")) == NULL) || r; - r = ((glProgramParameters4fvNV = (PFNGLPROGRAMPARAMETERS4FVNVPROC)glewGetProcAddress((const GLubyte*)"glProgramParameters4fvNV")) == NULL) || r; - r = ((glRequestResidentProgramsNV = (PFNGLREQUESTRESIDENTPROGRAMSNVPROC)glewGetProcAddress((const GLubyte*)"glRequestResidentProgramsNV")) == NULL) || r; - r = ((glTrackMatrixNV = (PFNGLTRACKMATRIXNVPROC)glewGetProcAddress((const GLubyte*)"glTrackMatrixNV")) == NULL) || r; - r = ((glVertexAttrib1dNV = (PFNGLVERTEXATTRIB1DNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1dNV")) == NULL) || r; - r = ((glVertexAttrib1dvNV = (PFNGLVERTEXATTRIB1DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1dvNV")) == NULL) || r; - r = ((glVertexAttrib1fNV = (PFNGLVERTEXATTRIB1FNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1fNV")) == NULL) || r; - r = ((glVertexAttrib1fvNV = (PFNGLVERTEXATTRIB1FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1fvNV")) == NULL) || r; - r = ((glVertexAttrib1sNV = (PFNGLVERTEXATTRIB1SNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1sNV")) == NULL) || r; - r = ((glVertexAttrib1svNV = (PFNGLVERTEXATTRIB1SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib1svNV")) == NULL) || r; - r = ((glVertexAttrib2dNV = (PFNGLVERTEXATTRIB2DNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2dNV")) == NULL) || r; - r = ((glVertexAttrib2dvNV = (PFNGLVERTEXATTRIB2DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2dvNV")) == NULL) || r; - r = ((glVertexAttrib2fNV = (PFNGLVERTEXATTRIB2FNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2fNV")) == NULL) || r; - r = ((glVertexAttrib2fvNV = (PFNGLVERTEXATTRIB2FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2fvNV")) == NULL) || r; - r = ((glVertexAttrib2sNV = (PFNGLVERTEXATTRIB2SNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2sNV")) == NULL) || r; - r = ((glVertexAttrib2svNV = (PFNGLVERTEXATTRIB2SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib2svNV")) == NULL) || r; - r = ((glVertexAttrib3dNV = (PFNGLVERTEXATTRIB3DNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3dNV")) == NULL) || r; - r = ((glVertexAttrib3dvNV = (PFNGLVERTEXATTRIB3DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3dvNV")) == NULL) || r; - r = ((glVertexAttrib3fNV = (PFNGLVERTEXATTRIB3FNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3fNV")) == NULL) || r; - r = ((glVertexAttrib3fvNV = (PFNGLVERTEXATTRIB3FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3fvNV")) == NULL) || r; - r = ((glVertexAttrib3sNV = (PFNGLVERTEXATTRIB3SNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3sNV")) == NULL) || r; - r = ((glVertexAttrib3svNV = (PFNGLVERTEXATTRIB3SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib3svNV")) == NULL) || r; - r = ((glVertexAttrib4dNV = (PFNGLVERTEXATTRIB4DNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4dNV")) == NULL) || r; - r = ((glVertexAttrib4dvNV = (PFNGLVERTEXATTRIB4DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4dvNV")) == NULL) || r; - r = ((glVertexAttrib4fNV = (PFNGLVERTEXATTRIB4FNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4fNV")) == NULL) || r; - r = ((glVertexAttrib4fvNV = (PFNGLVERTEXATTRIB4FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4fvNV")) == NULL) || r; - r = ((glVertexAttrib4sNV = (PFNGLVERTEXATTRIB4SNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4sNV")) == NULL) || r; - r = ((glVertexAttrib4svNV = (PFNGLVERTEXATTRIB4SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4svNV")) == NULL) || r; - r = ((glVertexAttrib4ubNV = (PFNGLVERTEXATTRIB4UBNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4ubNV")) == NULL) || r; - r = ((glVertexAttrib4ubvNV = (PFNGLVERTEXATTRIB4UBVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttrib4ubvNV")) == NULL) || r; - r = ((glVertexAttribPointerNV = (PFNGLVERTEXATTRIBPOINTERNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribPointerNV")) == NULL) || r; - r = ((glVertexAttribs1dvNV = (PFNGLVERTEXATTRIBS1DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs1dvNV")) == NULL) || r; - r = ((glVertexAttribs1fvNV = (PFNGLVERTEXATTRIBS1FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs1fvNV")) == NULL) || r; - r = ((glVertexAttribs1svNV = (PFNGLVERTEXATTRIBS1SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs1svNV")) == NULL) || r; - r = ((glVertexAttribs2dvNV = (PFNGLVERTEXATTRIBS2DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs2dvNV")) == NULL) || r; - r = ((glVertexAttribs2fvNV = (PFNGLVERTEXATTRIBS2FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs2fvNV")) == NULL) || r; - r = ((glVertexAttribs2svNV = (PFNGLVERTEXATTRIBS2SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs2svNV")) == NULL) || r; - r = ((glVertexAttribs3dvNV = (PFNGLVERTEXATTRIBS3DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs3dvNV")) == NULL) || r; - r = ((glVertexAttribs3fvNV = (PFNGLVERTEXATTRIBS3FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs3fvNV")) == NULL) || r; - r = ((glVertexAttribs3svNV = (PFNGLVERTEXATTRIBS3SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs3svNV")) == NULL) || r; - r = ((glVertexAttribs4dvNV = (PFNGLVERTEXATTRIBS4DVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs4dvNV")) == NULL) || r; - r = ((glVertexAttribs4fvNV = (PFNGLVERTEXATTRIBS4FVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs4fvNV")) == NULL) || r; - r = ((glVertexAttribs4svNV = (PFNGLVERTEXATTRIBS4SVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs4svNV")) == NULL) || r; - r = ((glVertexAttribs4ubvNV = (PFNGLVERTEXATTRIBS4UBVNVPROC)glewGetProcAddress((const GLubyte*)"glVertexAttribs4ubvNV")) == NULL) || r; - - return r; -} - -#endif /* GL_NV_vertex_program */ - -#ifdef GL_NV_vertex_program1_1 - -#endif /* GL_NV_vertex_program1_1 */ - -#ifdef GL_NV_vertex_program2 - -#endif /* GL_NV_vertex_program2 */ - -#ifdef GL_NV_vertex_program2_option - -#endif /* GL_NV_vertex_program2_option */ - -#ifdef GL_NV_vertex_program3 - -#endif /* GL_NV_vertex_program3 */ - -#ifdef GL_NV_vertex_program4 - -#endif /* GL_NV_vertex_program4 */ - -#ifdef GL_OES_byte_coordinates - -#endif /* GL_OES_byte_coordinates */ - -#ifdef GL_OES_compressed_paletted_texture - -#endif /* GL_OES_compressed_paletted_texture */ - -#ifdef GL_OES_read_format - -#endif /* GL_OES_read_format */ - -#ifdef GL_OES_single_precision - -static GLboolean _glewInit_GL_OES_single_precision (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glClearDepthfOES = (PFNGLCLEARDEPTHFOESPROC)glewGetProcAddress((const GLubyte*)"glClearDepthfOES")) == NULL) || r; - r = ((glClipPlanefOES = (PFNGLCLIPPLANEFOESPROC)glewGetProcAddress((const GLubyte*)"glClipPlanefOES")) == NULL) || r; - r = ((glDepthRangefOES = (PFNGLDEPTHRANGEFOESPROC)glewGetProcAddress((const GLubyte*)"glDepthRangefOES")) == NULL) || r; - r = ((glFrustumfOES = (PFNGLFRUSTUMFOESPROC)glewGetProcAddress((const GLubyte*)"glFrustumfOES")) == NULL) || r; - r = ((glGetClipPlanefOES = (PFNGLGETCLIPPLANEFOESPROC)glewGetProcAddress((const GLubyte*)"glGetClipPlanefOES")) == NULL) || r; - r = ((glOrthofOES = (PFNGLORTHOFOESPROC)glewGetProcAddress((const GLubyte*)"glOrthofOES")) == NULL) || r; - - return r; -} - -#endif /* GL_OES_single_precision */ - -#ifdef GL_OML_interlace - -#endif /* GL_OML_interlace */ - -#ifdef GL_OML_resample - -#endif /* GL_OML_resample */ - -#ifdef GL_OML_subsample - -#endif /* GL_OML_subsample */ - -#ifdef GL_PGI_misc_hints - -#endif /* GL_PGI_misc_hints */ - -#ifdef GL_PGI_vertex_hints - -#endif /* GL_PGI_vertex_hints */ - -#ifdef GL_REND_screen_coordinates - -#endif /* GL_REND_screen_coordinates */ - -#ifdef GL_S3_s3tc - -#endif /* GL_S3_s3tc */ - -#ifdef GL_SGIS_color_range - -#endif /* GL_SGIS_color_range */ - -#ifdef GL_SGIS_detail_texture - -static GLboolean _glewInit_GL_SGIS_detail_texture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glDetailTexFuncSGIS = (PFNGLDETAILTEXFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glDetailTexFuncSGIS")) == NULL) || r; - r = ((glGetDetailTexFuncSGIS = (PFNGLGETDETAILTEXFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glGetDetailTexFuncSGIS")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIS_detail_texture */ - -#ifdef GL_SGIS_fog_function - -static GLboolean _glewInit_GL_SGIS_fog_function (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFogFuncSGIS = (PFNGLFOGFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glFogFuncSGIS")) == NULL) || r; - r = ((glGetFogFuncSGIS = (PFNGLGETFOGFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glGetFogFuncSGIS")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIS_fog_function */ - -#ifdef GL_SGIS_generate_mipmap - -#endif /* GL_SGIS_generate_mipmap */ - -#ifdef GL_SGIS_multisample - -static GLboolean _glewInit_GL_SGIS_multisample (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glSampleMaskSGIS = (PFNGLSAMPLEMASKSGISPROC)glewGetProcAddress((const GLubyte*)"glSampleMaskSGIS")) == NULL) || r; - r = ((glSamplePatternSGIS = (PFNGLSAMPLEPATTERNSGISPROC)glewGetProcAddress((const GLubyte*)"glSamplePatternSGIS")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIS_multisample */ - -#ifdef GL_SGIS_pixel_texture - -#endif /* GL_SGIS_pixel_texture */ - -#ifdef GL_SGIS_point_line_texgen - -#endif /* GL_SGIS_point_line_texgen */ - -#ifdef GL_SGIS_sharpen_texture - -static GLboolean _glewInit_GL_SGIS_sharpen_texture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetSharpenTexFuncSGIS = (PFNGLGETSHARPENTEXFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glGetSharpenTexFuncSGIS")) == NULL) || r; - r = ((glSharpenTexFuncSGIS = (PFNGLSHARPENTEXFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glSharpenTexFuncSGIS")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIS_sharpen_texture */ - -#ifdef GL_SGIS_texture4D - -static GLboolean _glewInit_GL_SGIS_texture4D (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTexImage4DSGIS = (PFNGLTEXIMAGE4DSGISPROC)glewGetProcAddress((const GLubyte*)"glTexImage4DSGIS")) == NULL) || r; - r = ((glTexSubImage4DSGIS = (PFNGLTEXSUBIMAGE4DSGISPROC)glewGetProcAddress((const GLubyte*)"glTexSubImage4DSGIS")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIS_texture4D */ - -#ifdef GL_SGIS_texture_border_clamp - -#endif /* GL_SGIS_texture_border_clamp */ - -#ifdef GL_SGIS_texture_edge_clamp - -#endif /* GL_SGIS_texture_edge_clamp */ - -#ifdef GL_SGIS_texture_filter4 - -static GLboolean _glewInit_GL_SGIS_texture_filter4 (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGetTexFilterFuncSGIS = (PFNGLGETTEXFILTERFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glGetTexFilterFuncSGIS")) == NULL) || r; - r = ((glTexFilterFuncSGIS = (PFNGLTEXFILTERFUNCSGISPROC)glewGetProcAddress((const GLubyte*)"glTexFilterFuncSGIS")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIS_texture_filter4 */ - -#ifdef GL_SGIS_texture_lod - -#endif /* GL_SGIS_texture_lod */ - -#ifdef GL_SGIS_texture_select - -#endif /* GL_SGIS_texture_select */ - -#ifdef GL_SGIX_async - -static GLboolean _glewInit_GL_SGIX_async (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glAsyncMarkerSGIX = (PFNGLASYNCMARKERSGIXPROC)glewGetProcAddress((const GLubyte*)"glAsyncMarkerSGIX")) == NULL) || r; - r = ((glDeleteAsyncMarkersSGIX = (PFNGLDELETEASYNCMARKERSSGIXPROC)glewGetProcAddress((const GLubyte*)"glDeleteAsyncMarkersSGIX")) == NULL) || r; - r = ((glFinishAsyncSGIX = (PFNGLFINISHASYNCSGIXPROC)glewGetProcAddress((const GLubyte*)"glFinishAsyncSGIX")) == NULL) || r; - r = ((glGenAsyncMarkersSGIX = (PFNGLGENASYNCMARKERSSGIXPROC)glewGetProcAddress((const GLubyte*)"glGenAsyncMarkersSGIX")) == NULL) || r; - r = ((glIsAsyncMarkerSGIX = (PFNGLISASYNCMARKERSGIXPROC)glewGetProcAddress((const GLubyte*)"glIsAsyncMarkerSGIX")) == NULL) || r; - r = ((glPollAsyncSGIX = (PFNGLPOLLASYNCSGIXPROC)glewGetProcAddress((const GLubyte*)"glPollAsyncSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_async */ - -#ifdef GL_SGIX_async_histogram - -#endif /* GL_SGIX_async_histogram */ - -#ifdef GL_SGIX_async_pixel - -#endif /* GL_SGIX_async_pixel */ - -#ifdef GL_SGIX_blend_alpha_minmax - -#endif /* GL_SGIX_blend_alpha_minmax */ - -#ifdef GL_SGIX_clipmap - -#endif /* GL_SGIX_clipmap */ - -#ifdef GL_SGIX_convolution_accuracy - -#endif /* GL_SGIX_convolution_accuracy */ - -#ifdef GL_SGIX_depth_texture - -#endif /* GL_SGIX_depth_texture */ - -#ifdef GL_SGIX_flush_raster - -static GLboolean _glewInit_GL_SGIX_flush_raster (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFlushRasterSGIX = (PFNGLFLUSHRASTERSGIXPROC)glewGetProcAddress((const GLubyte*)"glFlushRasterSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_flush_raster */ - -#ifdef GL_SGIX_fog_offset - -#endif /* GL_SGIX_fog_offset */ - -#ifdef GL_SGIX_fog_texture - -static GLboolean _glewInit_GL_SGIX_fog_texture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTextureFogSGIX = (PFNGLTEXTUREFOGSGIXPROC)glewGetProcAddress((const GLubyte*)"glTextureFogSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_fog_texture */ - -#ifdef GL_SGIX_fragment_specular_lighting - -static GLboolean _glewInit_GL_SGIX_fragment_specular_lighting (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFragmentColorMaterialSGIX = (PFNGLFRAGMENTCOLORMATERIALSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentColorMaterialSGIX")) == NULL) || r; - r = ((glFragmentLightModelfSGIX = (PFNGLFRAGMENTLIGHTMODELFSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelfSGIX")) == NULL) || r; - r = ((glFragmentLightModelfvSGIX = (PFNGLFRAGMENTLIGHTMODELFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelfvSGIX")) == NULL) || r; - r = ((glFragmentLightModeliSGIX = (PFNGLFRAGMENTLIGHTMODELISGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModeliSGIX")) == NULL) || r; - r = ((glFragmentLightModelivSGIX = (PFNGLFRAGMENTLIGHTMODELIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelivSGIX")) == NULL) || r; - r = ((glFragmentLightfSGIX = (PFNGLFRAGMENTLIGHTFSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightfSGIX")) == NULL) || r; - r = ((glFragmentLightfvSGIX = (PFNGLFRAGMENTLIGHTFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightfvSGIX")) == NULL) || r; - r = ((glFragmentLightiSGIX = (PFNGLFRAGMENTLIGHTISGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightiSGIX")) == NULL) || r; - r = ((glFragmentLightivSGIX = (PFNGLFRAGMENTLIGHTIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightivSGIX")) == NULL) || r; - r = ((glFragmentMaterialfSGIX = (PFNGLFRAGMENTMATERIALFSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialfSGIX")) == NULL) || r; - r = ((glFragmentMaterialfvSGIX = (PFNGLFRAGMENTMATERIALFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialfvSGIX")) == NULL) || r; - r = ((glFragmentMaterialiSGIX = (PFNGLFRAGMENTMATERIALISGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialiSGIX")) == NULL) || r; - r = ((glFragmentMaterialivSGIX = (PFNGLFRAGMENTMATERIALIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialivSGIX")) == NULL) || r; - r = ((glGetFragmentLightfvSGIX = (PFNGLGETFRAGMENTLIGHTFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentLightfvSGIX")) == NULL) || r; - r = ((glGetFragmentLightivSGIX = (PFNGLGETFRAGMENTLIGHTIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentLightivSGIX")) == NULL) || r; - r = ((glGetFragmentMaterialfvSGIX = (PFNGLGETFRAGMENTMATERIALFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentMaterialfvSGIX")) == NULL) || r; - r = ((glGetFragmentMaterialivSGIX = (PFNGLGETFRAGMENTMATERIALIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentMaterialivSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_fragment_specular_lighting */ - -#ifdef GL_SGIX_framezoom - -static GLboolean _glewInit_GL_SGIX_framezoom (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFrameZoomSGIX = (PFNGLFRAMEZOOMSGIXPROC)glewGetProcAddress((const GLubyte*)"glFrameZoomSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_framezoom */ - -#ifdef GL_SGIX_interlace - -#endif /* GL_SGIX_interlace */ - -#ifdef GL_SGIX_ir_instrument1 - -#endif /* GL_SGIX_ir_instrument1 */ - -#ifdef GL_SGIX_list_priority - -#endif /* GL_SGIX_list_priority */ - -#ifdef GL_SGIX_pixel_texture - -static GLboolean _glewInit_GL_SGIX_pixel_texture (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glPixelTexGenSGIX = (PFNGLPIXELTEXGENSGIXPROC)glewGetProcAddress((const GLubyte*)"glPixelTexGenSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_pixel_texture */ - -#ifdef GL_SGIX_pixel_texture_bits - -#endif /* GL_SGIX_pixel_texture_bits */ - -#ifdef GL_SGIX_reference_plane - -static GLboolean _glewInit_GL_SGIX_reference_plane (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glReferencePlaneSGIX = (PFNGLREFERENCEPLANESGIXPROC)glewGetProcAddress((const GLubyte*)"glReferencePlaneSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_reference_plane */ - -#ifdef GL_SGIX_resample - -#endif /* GL_SGIX_resample */ - -#ifdef GL_SGIX_shadow - -#endif /* GL_SGIX_shadow */ - -#ifdef GL_SGIX_shadow_ambient - -#endif /* GL_SGIX_shadow_ambient */ - -#ifdef GL_SGIX_sprite - -static GLboolean _glewInit_GL_SGIX_sprite (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glSpriteParameterfSGIX = (PFNGLSPRITEPARAMETERFSGIXPROC)glewGetProcAddress((const GLubyte*)"glSpriteParameterfSGIX")) == NULL) || r; - r = ((glSpriteParameterfvSGIX = (PFNGLSPRITEPARAMETERFVSGIXPROC)glewGetProcAddress((const GLubyte*)"glSpriteParameterfvSGIX")) == NULL) || r; - r = ((glSpriteParameteriSGIX = (PFNGLSPRITEPARAMETERISGIXPROC)glewGetProcAddress((const GLubyte*)"glSpriteParameteriSGIX")) == NULL) || r; - r = ((glSpriteParameterivSGIX = (PFNGLSPRITEPARAMETERIVSGIXPROC)glewGetProcAddress((const GLubyte*)"glSpriteParameterivSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_sprite */ - -#ifdef GL_SGIX_tag_sample_buffer - -static GLboolean _glewInit_GL_SGIX_tag_sample_buffer (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glTagSampleBufferSGIX = (PFNGLTAGSAMPLEBUFFERSGIXPROC)glewGetProcAddress((const GLubyte*)"glTagSampleBufferSGIX")) == NULL) || r; - - return r; -} - -#endif /* GL_SGIX_tag_sample_buffer */ - -#ifdef GL_SGIX_texture_add_env - -#endif /* GL_SGIX_texture_add_env */ - -#ifdef GL_SGIX_texture_coordinate_clamp - -#endif /* GL_SGIX_texture_coordinate_clamp */ - -#ifdef GL_SGIX_texture_lod_bias - -#endif /* GL_SGIX_texture_lod_bias */ - -#ifdef GL_SGIX_texture_multi_buffer - -#endif /* GL_SGIX_texture_multi_buffer */ - -#ifdef GL_SGIX_texture_range - -#endif /* GL_SGIX_texture_range */ - -#ifdef GL_SGIX_texture_scale_bias - -#endif /* GL_SGIX_texture_scale_bias */ - -#ifdef GL_SGIX_vertex_preclip - -#endif /* GL_SGIX_vertex_preclip */ - -#ifdef GL_SGIX_vertex_preclip_hint - -#endif /* GL_SGIX_vertex_preclip_hint */ - -#ifdef GL_SGIX_ycrcb - -#endif /* GL_SGIX_ycrcb */ - -#ifdef GL_SGI_color_matrix - -#endif /* GL_SGI_color_matrix */ - -#ifdef GL_SGI_color_table - -static GLboolean _glewInit_GL_SGI_color_table (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glColorTableParameterfvSGI = (PFNGLCOLORTABLEPARAMETERFVSGIPROC)glewGetProcAddress((const GLubyte*)"glColorTableParameterfvSGI")) == NULL) || r; - r = ((glColorTableParameterivSGI = (PFNGLCOLORTABLEPARAMETERIVSGIPROC)glewGetProcAddress((const GLubyte*)"glColorTableParameterivSGI")) == NULL) || r; - r = ((glColorTableSGI = (PFNGLCOLORTABLESGIPROC)glewGetProcAddress((const GLubyte*)"glColorTableSGI")) == NULL) || r; - r = ((glCopyColorTableSGI = (PFNGLCOPYCOLORTABLESGIPROC)glewGetProcAddress((const GLubyte*)"glCopyColorTableSGI")) == NULL) || r; - r = ((glGetColorTableParameterfvSGI = (PFNGLGETCOLORTABLEPARAMETERFVSGIPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameterfvSGI")) == NULL) || r; - r = ((glGetColorTableParameterivSGI = (PFNGLGETCOLORTABLEPARAMETERIVSGIPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableParameterivSGI")) == NULL) || r; - r = ((glGetColorTableSGI = (PFNGLGETCOLORTABLESGIPROC)glewGetProcAddress((const GLubyte*)"glGetColorTableSGI")) == NULL) || r; - - return r; -} - -#endif /* GL_SGI_color_table */ - -#ifdef GL_SGI_texture_color_table - -#endif /* GL_SGI_texture_color_table */ - -#ifdef GL_SUNX_constant_data - -static GLboolean _glewInit_GL_SUNX_constant_data (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glFinishTextureSUNX = (PFNGLFINISHTEXTURESUNXPROC)glewGetProcAddress((const GLubyte*)"glFinishTextureSUNX")) == NULL) || r; - - return r; -} - -#endif /* GL_SUNX_constant_data */ - -#ifdef GL_SUN_convolution_border_modes - -#endif /* GL_SUN_convolution_border_modes */ - -#ifdef GL_SUN_global_alpha - -static GLboolean _glewInit_GL_SUN_global_alpha (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glGlobalAlphaFactorbSUN = (PFNGLGLOBALALPHAFACTORBSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactorbSUN")) == NULL) || r; - r = ((glGlobalAlphaFactordSUN = (PFNGLGLOBALALPHAFACTORDSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactordSUN")) == NULL) || r; - r = ((glGlobalAlphaFactorfSUN = (PFNGLGLOBALALPHAFACTORFSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactorfSUN")) == NULL) || r; - r = ((glGlobalAlphaFactoriSUN = (PFNGLGLOBALALPHAFACTORISUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactoriSUN")) == NULL) || r; - r = ((glGlobalAlphaFactorsSUN = (PFNGLGLOBALALPHAFACTORSSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactorsSUN")) == NULL) || r; - r = ((glGlobalAlphaFactorubSUN = (PFNGLGLOBALALPHAFACTORUBSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactorubSUN")) == NULL) || r; - r = ((glGlobalAlphaFactoruiSUN = (PFNGLGLOBALALPHAFACTORUISUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactoruiSUN")) == NULL) || r; - r = ((glGlobalAlphaFactorusSUN = (PFNGLGLOBALALPHAFACTORUSSUNPROC)glewGetProcAddress((const GLubyte*)"glGlobalAlphaFactorusSUN")) == NULL) || r; - - return r; -} - -#endif /* GL_SUN_global_alpha */ - -#ifdef GL_SUN_mesh_array - -#endif /* GL_SUN_mesh_array */ - -#ifdef GL_SUN_read_video_pixels - -static GLboolean _glewInit_GL_SUN_read_video_pixels (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glReadVideoPixelsSUN = (PFNGLREADVIDEOPIXELSSUNPROC)glewGetProcAddress((const GLubyte*)"glReadVideoPixelsSUN")) == NULL) || r; - - return r; -} - -#endif /* GL_SUN_read_video_pixels */ - -#ifdef GL_SUN_slice_accum - -#endif /* GL_SUN_slice_accum */ - -#ifdef GL_SUN_triangle_list - -static GLboolean _glewInit_GL_SUN_triangle_list (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glReplacementCodePointerSUN = (PFNGLREPLACEMENTCODEPOINTERSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodePointerSUN")) == NULL) || r; - r = ((glReplacementCodeubSUN = (PFNGLREPLACEMENTCODEUBSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeubSUN")) == NULL) || r; - r = ((glReplacementCodeubvSUN = (PFNGLREPLACEMENTCODEUBVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeubvSUN")) == NULL) || r; - r = ((glReplacementCodeuiSUN = (PFNGLREPLACEMENTCODEUISUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiSUN")) == NULL) || r; - r = ((glReplacementCodeuivSUN = (PFNGLREPLACEMENTCODEUIVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuivSUN")) == NULL) || r; - r = ((glReplacementCodeusSUN = (PFNGLREPLACEMENTCODEUSSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeusSUN")) == NULL) || r; - r = ((glReplacementCodeusvSUN = (PFNGLREPLACEMENTCODEUSVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeusvSUN")) == NULL) || r; - - return r; -} - -#endif /* GL_SUN_triangle_list */ - -#ifdef GL_SUN_vertex - -static GLboolean _glewInit_GL_SUN_vertex (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glColor3fVertex3fSUN = (PFNGLCOLOR3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glColor3fVertex3fSUN")) == NULL) || r; - r = ((glColor3fVertex3fvSUN = (PFNGLCOLOR3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glColor3fVertex3fvSUN")) == NULL) || r; - r = ((glColor4fNormal3fVertex3fSUN = (PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4fNormal3fVertex3fSUN")) == NULL) || r; - r = ((glColor4fNormal3fVertex3fvSUN = (PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4fNormal3fVertex3fvSUN")) == NULL) || r; - r = ((glColor4ubVertex2fSUN = (PFNGLCOLOR4UBVERTEX2FSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4ubVertex2fSUN")) == NULL) || r; - r = ((glColor4ubVertex2fvSUN = (PFNGLCOLOR4UBVERTEX2FVSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4ubVertex2fvSUN")) == NULL) || r; - r = ((glColor4ubVertex3fSUN = (PFNGLCOLOR4UBVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4ubVertex3fSUN")) == NULL) || r; - r = ((glColor4ubVertex3fvSUN = (PFNGLCOLOR4UBVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glColor4ubVertex3fvSUN")) == NULL) || r; - r = ((glNormal3fVertex3fSUN = (PFNGLNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glNormal3fVertex3fSUN")) == NULL) || r; - r = ((glNormal3fVertex3fvSUN = (PFNGLNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glNormal3fVertex3fvSUN")) == NULL) || r; - r = ((glReplacementCodeuiColor3fVertex3fSUN = (PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor3fVertex3fSUN")) == NULL) || r; - r = ((glReplacementCodeuiColor3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor3fVertex3fvSUN")) == NULL) || r; - r = ((glReplacementCodeuiColor4fNormal3fVertex3fSUN = (PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor4fNormal3fVertex3fSUN")) == NULL) || r; - r = ((glReplacementCodeuiColor4fNormal3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor4fNormal3fVertex3fvSUN")) == NULL) || r; - r = ((glReplacementCodeuiColor4ubVertex3fSUN = (PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor4ubVertex3fSUN")) == NULL) || r; - r = ((glReplacementCodeuiColor4ubVertex3fvSUN = (PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiColor4ubVertex3fvSUN")) == NULL) || r; - r = ((glReplacementCodeuiNormal3fVertex3fSUN = (PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiNormal3fVertex3fSUN")) == NULL) || r; - r = ((glReplacementCodeuiNormal3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiNormal3fVertex3fvSUN")) == NULL) || r; - r = ((glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN")) == NULL) || r; - r = ((glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN")) == NULL) || r; - r = ((glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN")) == NULL) || r; - r = ((glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN")) == NULL) || r; - r = ((glReplacementCodeuiTexCoord2fVertex3fSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fVertex3fSUN")) == NULL) || r; - r = ((glReplacementCodeuiTexCoord2fVertex3fvSUN = (PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiTexCoord2fVertex3fvSUN")) == NULL) || r; - r = ((glReplacementCodeuiVertex3fSUN = (PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiVertex3fSUN")) == NULL) || r; - r = ((glReplacementCodeuiVertex3fvSUN = (PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glReplacementCodeuiVertex3fvSUN")) == NULL) || r; - r = ((glTexCoord2fColor3fVertex3fSUN = (PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor3fVertex3fSUN")) == NULL) || r; - r = ((glTexCoord2fColor3fVertex3fvSUN = (PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor3fVertex3fvSUN")) == NULL) || r; - r = ((glTexCoord2fColor4fNormal3fVertex3fSUN = (PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor4fNormal3fVertex3fSUN")) == NULL) || r; - r = ((glTexCoord2fColor4fNormal3fVertex3fvSUN = (PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor4fNormal3fVertex3fvSUN")) == NULL) || r; - r = ((glTexCoord2fColor4ubVertex3fSUN = (PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor4ubVertex3fSUN")) == NULL) || r; - r = ((glTexCoord2fColor4ubVertex3fvSUN = (PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fColor4ubVertex3fvSUN")) == NULL) || r; - r = ((glTexCoord2fNormal3fVertex3fSUN = (PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fNormal3fVertex3fSUN")) == NULL) || r; - r = ((glTexCoord2fNormal3fVertex3fvSUN = (PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fNormal3fVertex3fvSUN")) == NULL) || r; - r = ((glTexCoord2fVertex3fSUN = (PFNGLTEXCOORD2FVERTEX3FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fVertex3fSUN")) == NULL) || r; - r = ((glTexCoord2fVertex3fvSUN = (PFNGLTEXCOORD2FVERTEX3FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord2fVertex3fvSUN")) == NULL) || r; - r = ((glTexCoord4fColor4fNormal3fVertex4fSUN = (PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4fColor4fNormal3fVertex4fSUN")) == NULL) || r; - r = ((glTexCoord4fColor4fNormal3fVertex4fvSUN = (PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4fColor4fNormal3fVertex4fvSUN")) == NULL) || r; - r = ((glTexCoord4fVertex4fSUN = (PFNGLTEXCOORD4FVERTEX4FSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4fVertex4fSUN")) == NULL) || r; - r = ((glTexCoord4fVertex4fvSUN = (PFNGLTEXCOORD4FVERTEX4FVSUNPROC)glewGetProcAddress((const GLubyte*)"glTexCoord4fVertex4fvSUN")) == NULL) || r; - - return r; -} - -#endif /* GL_SUN_vertex */ - -#ifdef GL_WIN_phong_shading - -#endif /* GL_WIN_phong_shading */ - -#ifdef GL_WIN_specular_fog - -#endif /* GL_WIN_specular_fog */ - -#ifdef GL_WIN_swap_hint - -static GLboolean _glewInit_GL_WIN_swap_hint (GLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glAddSwapHintRectWIN = (PFNGLADDSWAPHINTRECTWINPROC)glewGetProcAddress((const GLubyte*)"glAddSwapHintRectWIN")) == NULL) || r; - - return r; -} - -#endif /* GL_WIN_swap_hint */ - -/* ------------------------------------------------------------------------- */ - -/* - * Search for name in the extensions string. Use of strstr() - * is not sufficient because extension names can be prefixes of - * other extension names. Could use strtok() but the constant - * string returned by glGetString might be in read-only memory. - */ -GLboolean glewGetExtension (const char* name) -{ - GLubyte* p; - GLubyte* end; - GLuint len = _glewStrLen((const GLubyte*)name); - p = (GLubyte*)glGetString(GL_EXTENSIONS); - if (0 == p) return GL_FALSE; - end = p + _glewStrLen(p); - while (p < end) - { - GLuint n = _glewStrCLen(p, ' '); - if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE; - p += n+1; - } - return GL_FALSE; -} - -/* ------------------------------------------------------------------------- */ - -#ifndef GLEW_MX -static -#endif -GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) -{ - const GLubyte* s; - GLuint dot, major, minor; - /* query opengl version */ - s = glGetString(GL_VERSION); - dot = _glewStrCLen(s, '.'); - major = dot-1; - minor = dot+1; - if (dot == 0 || s[minor] == '\0') - return GLEW_ERROR_NO_GL_VERSION; - if (s[major] == '1' && s[minor] == '0') - { - return GLEW_ERROR_GL_VERSION_10_ONLY; - } - else - { - CONST_CAST(GLEW_VERSION_1_1) = GL_TRUE; - if (s[major] >= '2') - { - CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_3) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_4) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_5) = GL_TRUE; - CONST_CAST(GLEW_VERSION_2_0) = GL_TRUE; - if (s[minor] >= '1') - { - CONST_CAST(GLEW_VERSION_2_1) = GL_TRUE; - } - } - else - { - if (s[minor] >= '5') - { - CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_3) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_4) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_5) = GL_TRUE; - CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE; - } - if (s[minor] == '4') - { - CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_3) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_4) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_5) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE; - } - if (s[minor] == '3') - { - CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_3) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_4) = GL_FALSE; - CONST_CAST(GLEW_VERSION_1_5) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE; - } - if (s[minor] == '2') - { - CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE; - CONST_CAST(GLEW_VERSION_1_3) = GL_FALSE; - CONST_CAST(GLEW_VERSION_1_4) = GL_FALSE; - CONST_CAST(GLEW_VERSION_1_5) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE; - } - if (s[minor] < '2') - { - CONST_CAST(GLEW_VERSION_1_2) = GL_FALSE; - CONST_CAST(GLEW_VERSION_1_3) = GL_FALSE; - CONST_CAST(GLEW_VERSION_1_4) = GL_FALSE; - CONST_CAST(GLEW_VERSION_1_5) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE; - CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE; - } - } - } - /* initialize extensions */ -#ifdef GL_VERSION_1_2 - if (glewExperimental || GLEW_VERSION_1_2) CONST_CAST(GLEW_VERSION_1_2) = !_glewInit_GL_VERSION_1_2(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_VERSION_1_2 */ -#ifdef GL_VERSION_1_3 - if (glewExperimental || GLEW_VERSION_1_3) CONST_CAST(GLEW_VERSION_1_3) = !_glewInit_GL_VERSION_1_3(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_VERSION_1_3 */ -#ifdef GL_VERSION_1_4 - if (glewExperimental || GLEW_VERSION_1_4) CONST_CAST(GLEW_VERSION_1_4) = !_glewInit_GL_VERSION_1_4(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_VERSION_1_4 */ -#ifdef GL_VERSION_1_5 - if (glewExperimental || GLEW_VERSION_1_5) CONST_CAST(GLEW_VERSION_1_5) = !_glewInit_GL_VERSION_1_5(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_VERSION_1_5 */ -#ifdef GL_VERSION_2_0 - if (glewExperimental || GLEW_VERSION_2_0) CONST_CAST(GLEW_VERSION_2_0) = !_glewInit_GL_VERSION_2_0(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_VERSION_2_0 */ -#ifdef GL_VERSION_2_1 - if (glewExperimental || GLEW_VERSION_2_1) CONST_CAST(GLEW_VERSION_2_1) = !_glewInit_GL_VERSION_2_1(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_VERSION_2_1 */ -#ifdef GL_VERSION_3_0 - if (glewExperimental || GLEW_VERSION_3_0) CONST_CAST(GLEW_VERSION_3_0) = !_glewInit_GL_VERSION_3_0(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_VERSION_3_0 */ -#ifdef GL_3DFX_multisample - CONST_CAST(GLEW_3DFX_multisample) = glewGetExtension("GL_3DFX_multisample"); -#endif /* GL_3DFX_multisample */ -#ifdef GL_3DFX_tbuffer - CONST_CAST(GLEW_3DFX_tbuffer) = glewGetExtension("GL_3DFX_tbuffer"); - if (glewExperimental || GLEW_3DFX_tbuffer) CONST_CAST(GLEW_3DFX_tbuffer) = !_glewInit_GL_3DFX_tbuffer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_3DFX_tbuffer */ -#ifdef GL_3DFX_texture_compression_FXT1 - CONST_CAST(GLEW_3DFX_texture_compression_FXT1) = glewGetExtension("GL_3DFX_texture_compression_FXT1"); -#endif /* GL_3DFX_texture_compression_FXT1 */ -#ifdef GL_APPLE_client_storage - CONST_CAST(GLEW_APPLE_client_storage) = glewGetExtension("GL_APPLE_client_storage"); -#endif /* GL_APPLE_client_storage */ -#ifdef GL_APPLE_element_array - CONST_CAST(GLEW_APPLE_element_array) = glewGetExtension("GL_APPLE_element_array"); - if (glewExperimental || GLEW_APPLE_element_array) CONST_CAST(GLEW_APPLE_element_array) = !_glewInit_GL_APPLE_element_array(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_APPLE_element_array */ -#ifdef GL_APPLE_fence - CONST_CAST(GLEW_APPLE_fence) = glewGetExtension("GL_APPLE_fence"); - if (glewExperimental || GLEW_APPLE_fence) CONST_CAST(GLEW_APPLE_fence) = !_glewInit_GL_APPLE_fence(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_APPLE_fence */ -#ifdef GL_APPLE_float_pixels - CONST_CAST(GLEW_APPLE_float_pixels) = glewGetExtension("GL_APPLE_float_pixels"); -#endif /* GL_APPLE_float_pixels */ -#ifdef GL_APPLE_flush_buffer_range - CONST_CAST(GLEW_APPLE_flush_buffer_range) = glewGetExtension("GL_APPLE_flush_buffer_range"); - if (glewExperimental || GLEW_APPLE_flush_buffer_range) CONST_CAST(GLEW_APPLE_flush_buffer_range) = !_glewInit_GL_APPLE_flush_buffer_range(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_APPLE_flush_buffer_range */ -#ifdef GL_APPLE_pixel_buffer - CONST_CAST(GLEW_APPLE_pixel_buffer) = glewGetExtension("GL_APPLE_pixel_buffer"); -#endif /* GL_APPLE_pixel_buffer */ -#ifdef GL_APPLE_specular_vector - CONST_CAST(GLEW_APPLE_specular_vector) = glewGetExtension("GL_APPLE_specular_vector"); -#endif /* GL_APPLE_specular_vector */ -#ifdef GL_APPLE_texture_range - CONST_CAST(GLEW_APPLE_texture_range) = glewGetExtension("GL_APPLE_texture_range"); - if (glewExperimental || GLEW_APPLE_texture_range) CONST_CAST(GLEW_APPLE_texture_range) = !_glewInit_GL_APPLE_texture_range(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_APPLE_texture_range */ -#ifdef GL_APPLE_transform_hint - CONST_CAST(GLEW_APPLE_transform_hint) = glewGetExtension("GL_APPLE_transform_hint"); -#endif /* GL_APPLE_transform_hint */ -#ifdef GL_APPLE_vertex_array_object - CONST_CAST(GLEW_APPLE_vertex_array_object) = glewGetExtension("GL_APPLE_vertex_array_object"); - if (glewExperimental || GLEW_APPLE_vertex_array_object) CONST_CAST(GLEW_APPLE_vertex_array_object) = !_glewInit_GL_APPLE_vertex_array_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_APPLE_vertex_array_object */ -#ifdef GL_APPLE_vertex_array_range - CONST_CAST(GLEW_APPLE_vertex_array_range) = glewGetExtension("GL_APPLE_vertex_array_range"); - if (glewExperimental || GLEW_APPLE_vertex_array_range) CONST_CAST(GLEW_APPLE_vertex_array_range) = !_glewInit_GL_APPLE_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_APPLE_vertex_array_range */ -#ifdef GL_APPLE_ycbcr_422 - CONST_CAST(GLEW_APPLE_ycbcr_422) = glewGetExtension("GL_APPLE_ycbcr_422"); -#endif /* GL_APPLE_ycbcr_422 */ -#ifdef GL_ARB_color_buffer_float - CONST_CAST(GLEW_ARB_color_buffer_float) = glewGetExtension("GL_ARB_color_buffer_float"); - if (glewExperimental || GLEW_ARB_color_buffer_float) CONST_CAST(GLEW_ARB_color_buffer_float) = !_glewInit_GL_ARB_color_buffer_float(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_color_buffer_float */ -#ifdef GL_ARB_depth_buffer_float - CONST_CAST(GLEW_ARB_depth_buffer_float) = glewGetExtension("GL_ARB_depth_buffer_float"); -#endif /* GL_ARB_depth_buffer_float */ -#ifdef GL_ARB_depth_texture - CONST_CAST(GLEW_ARB_depth_texture) = glewGetExtension("GL_ARB_depth_texture"); -#endif /* GL_ARB_depth_texture */ -#ifdef GL_ARB_draw_buffers - CONST_CAST(GLEW_ARB_draw_buffers) = glewGetExtension("GL_ARB_draw_buffers"); - if (glewExperimental || GLEW_ARB_draw_buffers) CONST_CAST(GLEW_ARB_draw_buffers) = !_glewInit_GL_ARB_draw_buffers(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_draw_buffers */ -#ifdef GL_ARB_draw_instanced - CONST_CAST(GLEW_ARB_draw_instanced) = glewGetExtension("GL_ARB_draw_instanced"); - if (glewExperimental || GLEW_ARB_draw_instanced) CONST_CAST(GLEW_ARB_draw_instanced) = !_glewInit_GL_ARB_draw_instanced(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_draw_instanced */ -#ifdef GL_ARB_fragment_program - CONST_CAST(GLEW_ARB_fragment_program) = glewGetExtension("GL_ARB_fragment_program"); -#endif /* GL_ARB_fragment_program */ -#ifdef GL_ARB_fragment_program_shadow - CONST_CAST(GLEW_ARB_fragment_program_shadow) = glewGetExtension("GL_ARB_fragment_program_shadow"); -#endif /* GL_ARB_fragment_program_shadow */ -#ifdef GL_ARB_fragment_shader - CONST_CAST(GLEW_ARB_fragment_shader) = glewGetExtension("GL_ARB_fragment_shader"); -#endif /* GL_ARB_fragment_shader */ -#ifdef GL_ARB_framebuffer_object - CONST_CAST(GLEW_ARB_framebuffer_object) = glewGetExtension("GL_ARB_framebuffer_object"); - if (glewExperimental || GLEW_ARB_framebuffer_object) CONST_CAST(GLEW_ARB_framebuffer_object) = !_glewInit_GL_ARB_framebuffer_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_framebuffer_object */ -#ifdef GL_ARB_framebuffer_sRGB - CONST_CAST(GLEW_ARB_framebuffer_sRGB) = glewGetExtension("GL_ARB_framebuffer_sRGB"); -#endif /* GL_ARB_framebuffer_sRGB */ -#ifdef GL_ARB_geometry_shader4 - CONST_CAST(GLEW_ARB_geometry_shader4) = glewGetExtension("GL_ARB_geometry_shader4"); - if (glewExperimental || GLEW_ARB_geometry_shader4) CONST_CAST(GLEW_ARB_geometry_shader4) = !_glewInit_GL_ARB_geometry_shader4(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_geometry_shader4 */ -#ifdef GL_ARB_half_float_pixel - CONST_CAST(GLEW_ARB_half_float_pixel) = glewGetExtension("GL_ARB_half_float_pixel"); -#endif /* GL_ARB_half_float_pixel */ -#ifdef GL_ARB_half_float_vertex - CONST_CAST(GLEW_ARB_half_float_vertex) = glewGetExtension("GL_ARB_half_float_vertex"); -#endif /* GL_ARB_half_float_vertex */ -#ifdef GL_ARB_imaging - CONST_CAST(GLEW_ARB_imaging) = glewGetExtension("GL_ARB_imaging"); - if (glewExperimental || GLEW_ARB_imaging) CONST_CAST(GLEW_ARB_imaging) = !_glewInit_GL_ARB_imaging(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_imaging */ -#ifdef GL_ARB_instanced_arrays - CONST_CAST(GLEW_ARB_instanced_arrays) = glewGetExtension("GL_ARB_instanced_arrays"); - if (glewExperimental || GLEW_ARB_instanced_arrays) CONST_CAST(GLEW_ARB_instanced_arrays) = !_glewInit_GL_ARB_instanced_arrays(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_instanced_arrays */ -#ifdef GL_ARB_map_buffer_range - CONST_CAST(GLEW_ARB_map_buffer_range) = glewGetExtension("GL_ARB_map_buffer_range"); - if (glewExperimental || GLEW_ARB_map_buffer_range) CONST_CAST(GLEW_ARB_map_buffer_range) = !_glewInit_GL_ARB_map_buffer_range(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_map_buffer_range */ -#ifdef GL_ARB_matrix_palette - CONST_CAST(GLEW_ARB_matrix_palette) = glewGetExtension("GL_ARB_matrix_palette"); - if (glewExperimental || GLEW_ARB_matrix_palette) CONST_CAST(GLEW_ARB_matrix_palette) = !_glewInit_GL_ARB_matrix_palette(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_matrix_palette */ -#ifdef GL_ARB_multisample - CONST_CAST(GLEW_ARB_multisample) = glewGetExtension("GL_ARB_multisample"); - if (glewExperimental || GLEW_ARB_multisample) CONST_CAST(GLEW_ARB_multisample) = !_glewInit_GL_ARB_multisample(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_multisample */ -#ifdef GL_ARB_multitexture - CONST_CAST(GLEW_ARB_multitexture) = glewGetExtension("GL_ARB_multitexture"); - if (glewExperimental || GLEW_ARB_multitexture) CONST_CAST(GLEW_ARB_multitexture) = !_glewInit_GL_ARB_multitexture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_multitexture */ -#ifdef GL_ARB_occlusion_query - CONST_CAST(GLEW_ARB_occlusion_query) = glewGetExtension("GL_ARB_occlusion_query"); - if (glewExperimental || GLEW_ARB_occlusion_query) CONST_CAST(GLEW_ARB_occlusion_query) = !_glewInit_GL_ARB_occlusion_query(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_occlusion_query */ -#ifdef GL_ARB_pixel_buffer_object - CONST_CAST(GLEW_ARB_pixel_buffer_object) = glewGetExtension("GL_ARB_pixel_buffer_object"); -#endif /* GL_ARB_pixel_buffer_object */ -#ifdef GL_ARB_point_parameters - CONST_CAST(GLEW_ARB_point_parameters) = glewGetExtension("GL_ARB_point_parameters"); - if (glewExperimental || GLEW_ARB_point_parameters) CONST_CAST(GLEW_ARB_point_parameters) = !_glewInit_GL_ARB_point_parameters(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_point_parameters */ -#ifdef GL_ARB_point_sprite - CONST_CAST(GLEW_ARB_point_sprite) = glewGetExtension("GL_ARB_point_sprite"); -#endif /* GL_ARB_point_sprite */ -#ifdef GL_ARB_shader_objects - CONST_CAST(GLEW_ARB_shader_objects) = glewGetExtension("GL_ARB_shader_objects"); - if (glewExperimental || GLEW_ARB_shader_objects) CONST_CAST(GLEW_ARB_shader_objects) = !_glewInit_GL_ARB_shader_objects(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_shader_objects */ -#ifdef GL_ARB_shading_language_100 - CONST_CAST(GLEW_ARB_shading_language_100) = glewGetExtension("GL_ARB_shading_language_100"); -#endif /* GL_ARB_shading_language_100 */ -#ifdef GL_ARB_shadow - CONST_CAST(GLEW_ARB_shadow) = glewGetExtension("GL_ARB_shadow"); -#endif /* GL_ARB_shadow */ -#ifdef GL_ARB_shadow_ambient - CONST_CAST(GLEW_ARB_shadow_ambient) = glewGetExtension("GL_ARB_shadow_ambient"); -#endif /* GL_ARB_shadow_ambient */ -#ifdef GL_ARB_texture_border_clamp - CONST_CAST(GLEW_ARB_texture_border_clamp) = glewGetExtension("GL_ARB_texture_border_clamp"); -#endif /* GL_ARB_texture_border_clamp */ -#ifdef GL_ARB_texture_buffer_object - CONST_CAST(GLEW_ARB_texture_buffer_object) = glewGetExtension("GL_ARB_texture_buffer_object"); - if (glewExperimental || GLEW_ARB_texture_buffer_object) CONST_CAST(GLEW_ARB_texture_buffer_object) = !_glewInit_GL_ARB_texture_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_texture_buffer_object */ -#ifdef GL_ARB_texture_compression - CONST_CAST(GLEW_ARB_texture_compression) = glewGetExtension("GL_ARB_texture_compression"); - if (glewExperimental || GLEW_ARB_texture_compression) CONST_CAST(GLEW_ARB_texture_compression) = !_glewInit_GL_ARB_texture_compression(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_texture_compression */ -#ifdef GL_ARB_texture_compression_rgtc - CONST_CAST(GLEW_ARB_texture_compression_rgtc) = glewGetExtension("GL_ARB_texture_compression_rgtc"); -#endif /* GL_ARB_texture_compression_rgtc */ -#ifdef GL_ARB_texture_cube_map - CONST_CAST(GLEW_ARB_texture_cube_map) = glewGetExtension("GL_ARB_texture_cube_map"); -#endif /* GL_ARB_texture_cube_map */ -#ifdef GL_ARB_texture_env_add - CONST_CAST(GLEW_ARB_texture_env_add) = glewGetExtension("GL_ARB_texture_env_add"); -#endif /* GL_ARB_texture_env_add */ -#ifdef GL_ARB_texture_env_combine - CONST_CAST(GLEW_ARB_texture_env_combine) = glewGetExtension("GL_ARB_texture_env_combine"); -#endif /* GL_ARB_texture_env_combine */ -#ifdef GL_ARB_texture_env_crossbar - CONST_CAST(GLEW_ARB_texture_env_crossbar) = glewGetExtension("GL_ARB_texture_env_crossbar"); -#endif /* GL_ARB_texture_env_crossbar */ -#ifdef GL_ARB_texture_env_dot3 - CONST_CAST(GLEW_ARB_texture_env_dot3) = glewGetExtension("GL_ARB_texture_env_dot3"); -#endif /* GL_ARB_texture_env_dot3 */ -#ifdef GL_ARB_texture_float - CONST_CAST(GLEW_ARB_texture_float) = glewGetExtension("GL_ARB_texture_float"); -#endif /* GL_ARB_texture_float */ -#ifdef GL_ARB_texture_mirrored_repeat - CONST_CAST(GLEW_ARB_texture_mirrored_repeat) = glewGetExtension("GL_ARB_texture_mirrored_repeat"); -#endif /* GL_ARB_texture_mirrored_repeat */ -#ifdef GL_ARB_texture_non_power_of_two - CONST_CAST(GLEW_ARB_texture_non_power_of_two) = glewGetExtension("GL_ARB_texture_non_power_of_two"); -#endif /* GL_ARB_texture_non_power_of_two */ -#ifdef GL_ARB_texture_rectangle - CONST_CAST(GLEW_ARB_texture_rectangle) = glewGetExtension("GL_ARB_texture_rectangle"); -#endif /* GL_ARB_texture_rectangle */ -#ifdef GL_ARB_texture_rg - CONST_CAST(GLEW_ARB_texture_rg) = glewGetExtension("GL_ARB_texture_rg"); -#endif /* GL_ARB_texture_rg */ -#ifdef GL_ARB_transpose_matrix - CONST_CAST(GLEW_ARB_transpose_matrix) = glewGetExtension("GL_ARB_transpose_matrix"); - if (glewExperimental || GLEW_ARB_transpose_matrix) CONST_CAST(GLEW_ARB_transpose_matrix) = !_glewInit_GL_ARB_transpose_matrix(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_transpose_matrix */ -#ifdef GL_ARB_vertex_array_object - CONST_CAST(GLEW_ARB_vertex_array_object) = glewGetExtension("GL_ARB_vertex_array_object"); - if (glewExperimental || GLEW_ARB_vertex_array_object) CONST_CAST(GLEW_ARB_vertex_array_object) = !_glewInit_GL_ARB_vertex_array_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_vertex_array_object */ -#ifdef GL_ARB_vertex_blend - CONST_CAST(GLEW_ARB_vertex_blend) = glewGetExtension("GL_ARB_vertex_blend"); - if (glewExperimental || GLEW_ARB_vertex_blend) CONST_CAST(GLEW_ARB_vertex_blend) = !_glewInit_GL_ARB_vertex_blend(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_vertex_blend */ -#ifdef GL_ARB_vertex_buffer_object - CONST_CAST(GLEW_ARB_vertex_buffer_object) = glewGetExtension("GL_ARB_vertex_buffer_object"); - if (glewExperimental || GLEW_ARB_vertex_buffer_object) CONST_CAST(GLEW_ARB_vertex_buffer_object) = !_glewInit_GL_ARB_vertex_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_vertex_buffer_object */ -#ifdef GL_ARB_vertex_program - CONST_CAST(GLEW_ARB_vertex_program) = glewGetExtension("GL_ARB_vertex_program"); - if (glewExperimental || GLEW_ARB_vertex_program) CONST_CAST(GLEW_ARB_vertex_program) = !_glewInit_GL_ARB_vertex_program(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_vertex_program */ -#ifdef GL_ARB_vertex_shader - CONST_CAST(GLEW_ARB_vertex_shader) = glewGetExtension("GL_ARB_vertex_shader"); - if (glewExperimental || GLEW_ARB_vertex_shader) CONST_CAST(GLEW_ARB_vertex_shader) = !_glewInit_GL_ARB_vertex_shader(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_vertex_shader */ -#ifdef GL_ARB_window_pos - CONST_CAST(GLEW_ARB_window_pos) = glewGetExtension("GL_ARB_window_pos"); - if (glewExperimental || GLEW_ARB_window_pos) CONST_CAST(GLEW_ARB_window_pos) = !_glewInit_GL_ARB_window_pos(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ARB_window_pos */ -#ifdef GL_ATIX_point_sprites - CONST_CAST(GLEW_ATIX_point_sprites) = glewGetExtension("GL_ATIX_point_sprites"); -#endif /* GL_ATIX_point_sprites */ -#ifdef GL_ATIX_texture_env_combine3 - CONST_CAST(GLEW_ATIX_texture_env_combine3) = glewGetExtension("GL_ATIX_texture_env_combine3"); -#endif /* GL_ATIX_texture_env_combine3 */ -#ifdef GL_ATIX_texture_env_route - CONST_CAST(GLEW_ATIX_texture_env_route) = glewGetExtension("GL_ATIX_texture_env_route"); -#endif /* GL_ATIX_texture_env_route */ -#ifdef GL_ATIX_vertex_shader_output_point_size - CONST_CAST(GLEW_ATIX_vertex_shader_output_point_size) = glewGetExtension("GL_ATIX_vertex_shader_output_point_size"); -#endif /* GL_ATIX_vertex_shader_output_point_size */ -#ifdef GL_ATI_draw_buffers - CONST_CAST(GLEW_ATI_draw_buffers) = glewGetExtension("GL_ATI_draw_buffers"); - if (glewExperimental || GLEW_ATI_draw_buffers) CONST_CAST(GLEW_ATI_draw_buffers) = !_glewInit_GL_ATI_draw_buffers(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_draw_buffers */ -#ifdef GL_ATI_element_array - CONST_CAST(GLEW_ATI_element_array) = glewGetExtension("GL_ATI_element_array"); - if (glewExperimental || GLEW_ATI_element_array) CONST_CAST(GLEW_ATI_element_array) = !_glewInit_GL_ATI_element_array(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_element_array */ -#ifdef GL_ATI_envmap_bumpmap - CONST_CAST(GLEW_ATI_envmap_bumpmap) = glewGetExtension("GL_ATI_envmap_bumpmap"); - if (glewExperimental || GLEW_ATI_envmap_bumpmap) CONST_CAST(GLEW_ATI_envmap_bumpmap) = !_glewInit_GL_ATI_envmap_bumpmap(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_envmap_bumpmap */ -#ifdef GL_ATI_fragment_shader - CONST_CAST(GLEW_ATI_fragment_shader) = glewGetExtension("GL_ATI_fragment_shader"); - if (glewExperimental || GLEW_ATI_fragment_shader) CONST_CAST(GLEW_ATI_fragment_shader) = !_glewInit_GL_ATI_fragment_shader(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_fragment_shader */ -#ifdef GL_ATI_map_object_buffer - CONST_CAST(GLEW_ATI_map_object_buffer) = glewGetExtension("GL_ATI_map_object_buffer"); - if (glewExperimental || GLEW_ATI_map_object_buffer) CONST_CAST(GLEW_ATI_map_object_buffer) = !_glewInit_GL_ATI_map_object_buffer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_map_object_buffer */ -#ifdef GL_ATI_pn_triangles - CONST_CAST(GLEW_ATI_pn_triangles) = glewGetExtension("GL_ATI_pn_triangles"); - if (glewExperimental || GLEW_ATI_pn_triangles) CONST_CAST(GLEW_ATI_pn_triangles) = !_glewInit_GL_ATI_pn_triangles(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_pn_triangles */ -#ifdef GL_ATI_separate_stencil - CONST_CAST(GLEW_ATI_separate_stencil) = glewGetExtension("GL_ATI_separate_stencil"); - if (glewExperimental || GLEW_ATI_separate_stencil) CONST_CAST(GLEW_ATI_separate_stencil) = !_glewInit_GL_ATI_separate_stencil(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_separate_stencil */ -#ifdef GL_ATI_shader_texture_lod - CONST_CAST(GLEW_ATI_shader_texture_lod) = glewGetExtension("GL_ATI_shader_texture_lod"); -#endif /* GL_ATI_shader_texture_lod */ -#ifdef GL_ATI_text_fragment_shader - CONST_CAST(GLEW_ATI_text_fragment_shader) = glewGetExtension("GL_ATI_text_fragment_shader"); -#endif /* GL_ATI_text_fragment_shader */ -#ifdef GL_ATI_texture_compression_3dc - CONST_CAST(GLEW_ATI_texture_compression_3dc) = glewGetExtension("GL_ATI_texture_compression_3dc"); -#endif /* GL_ATI_texture_compression_3dc */ -#ifdef GL_ATI_texture_env_combine3 - CONST_CAST(GLEW_ATI_texture_env_combine3) = glewGetExtension("GL_ATI_texture_env_combine3"); -#endif /* GL_ATI_texture_env_combine3 */ -#ifdef GL_ATI_texture_float - CONST_CAST(GLEW_ATI_texture_float) = glewGetExtension("GL_ATI_texture_float"); -#endif /* GL_ATI_texture_float */ -#ifdef GL_ATI_texture_mirror_once - CONST_CAST(GLEW_ATI_texture_mirror_once) = glewGetExtension("GL_ATI_texture_mirror_once"); -#endif /* GL_ATI_texture_mirror_once */ -#ifdef GL_ATI_vertex_array_object - CONST_CAST(GLEW_ATI_vertex_array_object) = glewGetExtension("GL_ATI_vertex_array_object"); - if (glewExperimental || GLEW_ATI_vertex_array_object) CONST_CAST(GLEW_ATI_vertex_array_object) = !_glewInit_GL_ATI_vertex_array_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_vertex_array_object */ -#ifdef GL_ATI_vertex_attrib_array_object - CONST_CAST(GLEW_ATI_vertex_attrib_array_object) = glewGetExtension("GL_ATI_vertex_attrib_array_object"); - if (glewExperimental || GLEW_ATI_vertex_attrib_array_object) CONST_CAST(GLEW_ATI_vertex_attrib_array_object) = !_glewInit_GL_ATI_vertex_attrib_array_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_vertex_attrib_array_object */ -#ifdef GL_ATI_vertex_streams - CONST_CAST(GLEW_ATI_vertex_streams) = glewGetExtension("GL_ATI_vertex_streams"); - if (glewExperimental || GLEW_ATI_vertex_streams) CONST_CAST(GLEW_ATI_vertex_streams) = !_glewInit_GL_ATI_vertex_streams(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_ATI_vertex_streams */ -#ifdef GL_EXT_422_pixels - CONST_CAST(GLEW_EXT_422_pixels) = glewGetExtension("GL_EXT_422_pixels"); -#endif /* GL_EXT_422_pixels */ -#ifdef GL_EXT_Cg_shader - CONST_CAST(GLEW_EXT_Cg_shader) = glewGetExtension("GL_EXT_Cg_shader"); -#endif /* GL_EXT_Cg_shader */ -#ifdef GL_EXT_abgr - CONST_CAST(GLEW_EXT_abgr) = glewGetExtension("GL_EXT_abgr"); -#endif /* GL_EXT_abgr */ -#ifdef GL_EXT_bgra - CONST_CAST(GLEW_EXT_bgra) = glewGetExtension("GL_EXT_bgra"); -#endif /* GL_EXT_bgra */ -#ifdef GL_EXT_bindable_uniform - CONST_CAST(GLEW_EXT_bindable_uniform) = glewGetExtension("GL_EXT_bindable_uniform"); - if (glewExperimental || GLEW_EXT_bindable_uniform) CONST_CAST(GLEW_EXT_bindable_uniform) = !_glewInit_GL_EXT_bindable_uniform(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_bindable_uniform */ -#ifdef GL_EXT_blend_color - CONST_CAST(GLEW_EXT_blend_color) = glewGetExtension("GL_EXT_blend_color"); - if (glewExperimental || GLEW_EXT_blend_color) CONST_CAST(GLEW_EXT_blend_color) = !_glewInit_GL_EXT_blend_color(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_blend_color */ -#ifdef GL_EXT_blend_equation_separate - CONST_CAST(GLEW_EXT_blend_equation_separate) = glewGetExtension("GL_EXT_blend_equation_separate"); - if (glewExperimental || GLEW_EXT_blend_equation_separate) CONST_CAST(GLEW_EXT_blend_equation_separate) = !_glewInit_GL_EXT_blend_equation_separate(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_blend_equation_separate */ -#ifdef GL_EXT_blend_func_separate - CONST_CAST(GLEW_EXT_blend_func_separate) = glewGetExtension("GL_EXT_blend_func_separate"); - if (glewExperimental || GLEW_EXT_blend_func_separate) CONST_CAST(GLEW_EXT_blend_func_separate) = !_glewInit_GL_EXT_blend_func_separate(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_blend_func_separate */ -#ifdef GL_EXT_blend_logic_op - CONST_CAST(GLEW_EXT_blend_logic_op) = glewGetExtension("GL_EXT_blend_logic_op"); -#endif /* GL_EXT_blend_logic_op */ -#ifdef GL_EXT_blend_minmax - CONST_CAST(GLEW_EXT_blend_minmax) = glewGetExtension("GL_EXT_blend_minmax"); - if (glewExperimental || GLEW_EXT_blend_minmax) CONST_CAST(GLEW_EXT_blend_minmax) = !_glewInit_GL_EXT_blend_minmax(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_blend_minmax */ -#ifdef GL_EXT_blend_subtract - CONST_CAST(GLEW_EXT_blend_subtract) = glewGetExtension("GL_EXT_blend_subtract"); -#endif /* GL_EXT_blend_subtract */ -#ifdef GL_EXT_clip_volume_hint - CONST_CAST(GLEW_EXT_clip_volume_hint) = glewGetExtension("GL_EXT_clip_volume_hint"); -#endif /* GL_EXT_clip_volume_hint */ -#ifdef GL_EXT_cmyka - CONST_CAST(GLEW_EXT_cmyka) = glewGetExtension("GL_EXT_cmyka"); -#endif /* GL_EXT_cmyka */ -#ifdef GL_EXT_color_subtable - CONST_CAST(GLEW_EXT_color_subtable) = glewGetExtension("GL_EXT_color_subtable"); - if (glewExperimental || GLEW_EXT_color_subtable) CONST_CAST(GLEW_EXT_color_subtable) = !_glewInit_GL_EXT_color_subtable(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_color_subtable */ -#ifdef GL_EXT_compiled_vertex_array - CONST_CAST(GLEW_EXT_compiled_vertex_array) = glewGetExtension("GL_EXT_compiled_vertex_array"); - if (glewExperimental || GLEW_EXT_compiled_vertex_array) CONST_CAST(GLEW_EXT_compiled_vertex_array) = !_glewInit_GL_EXT_compiled_vertex_array(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_compiled_vertex_array */ -#ifdef GL_EXT_convolution - CONST_CAST(GLEW_EXT_convolution) = glewGetExtension("GL_EXT_convolution"); - if (glewExperimental || GLEW_EXT_convolution) CONST_CAST(GLEW_EXT_convolution) = !_glewInit_GL_EXT_convolution(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_convolution */ -#ifdef GL_EXT_coordinate_frame - CONST_CAST(GLEW_EXT_coordinate_frame) = glewGetExtension("GL_EXT_coordinate_frame"); - if (glewExperimental || GLEW_EXT_coordinate_frame) CONST_CAST(GLEW_EXT_coordinate_frame) = !_glewInit_GL_EXT_coordinate_frame(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_coordinate_frame */ -#ifdef GL_EXT_copy_texture - CONST_CAST(GLEW_EXT_copy_texture) = glewGetExtension("GL_EXT_copy_texture"); - if (glewExperimental || GLEW_EXT_copy_texture) CONST_CAST(GLEW_EXT_copy_texture) = !_glewInit_GL_EXT_copy_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_copy_texture */ -#ifdef GL_EXT_cull_vertex - CONST_CAST(GLEW_EXT_cull_vertex) = glewGetExtension("GL_EXT_cull_vertex"); - if (glewExperimental || GLEW_EXT_cull_vertex) CONST_CAST(GLEW_EXT_cull_vertex) = !_glewInit_GL_EXT_cull_vertex(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_cull_vertex */ -#ifdef GL_EXT_depth_bounds_test - CONST_CAST(GLEW_EXT_depth_bounds_test) = glewGetExtension("GL_EXT_depth_bounds_test"); - if (glewExperimental || GLEW_EXT_depth_bounds_test) CONST_CAST(GLEW_EXT_depth_bounds_test) = !_glewInit_GL_EXT_depth_bounds_test(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_depth_bounds_test */ -#ifdef GL_EXT_direct_state_access - CONST_CAST(GLEW_EXT_direct_state_access) = glewGetExtension("GL_EXT_direct_state_access"); - if (glewExperimental || GLEW_EXT_direct_state_access) CONST_CAST(GLEW_EXT_direct_state_access) = !_glewInit_GL_EXT_direct_state_access(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_direct_state_access */ -#ifdef GL_EXT_draw_buffers2 - CONST_CAST(GLEW_EXT_draw_buffers2) = glewGetExtension("GL_EXT_draw_buffers2"); - if (glewExperimental || GLEW_EXT_draw_buffers2) CONST_CAST(GLEW_EXT_draw_buffers2) = !_glewInit_GL_EXT_draw_buffers2(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_draw_buffers2 */ -#ifdef GL_EXT_draw_instanced - CONST_CAST(GLEW_EXT_draw_instanced) = glewGetExtension("GL_EXT_draw_instanced"); - if (glewExperimental || GLEW_EXT_draw_instanced) CONST_CAST(GLEW_EXT_draw_instanced) = !_glewInit_GL_EXT_draw_instanced(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_draw_instanced */ -#ifdef GL_EXT_draw_range_elements - CONST_CAST(GLEW_EXT_draw_range_elements) = glewGetExtension("GL_EXT_draw_range_elements"); - if (glewExperimental || GLEW_EXT_draw_range_elements) CONST_CAST(GLEW_EXT_draw_range_elements) = !_glewInit_GL_EXT_draw_range_elements(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_draw_range_elements */ -#ifdef GL_EXT_fog_coord - CONST_CAST(GLEW_EXT_fog_coord) = glewGetExtension("GL_EXT_fog_coord"); - if (glewExperimental || GLEW_EXT_fog_coord) CONST_CAST(GLEW_EXT_fog_coord) = !_glewInit_GL_EXT_fog_coord(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_fog_coord */ -#ifdef GL_EXT_fragment_lighting - CONST_CAST(GLEW_EXT_fragment_lighting) = glewGetExtension("GL_EXT_fragment_lighting"); - if (glewExperimental || GLEW_EXT_fragment_lighting) CONST_CAST(GLEW_EXT_fragment_lighting) = !_glewInit_GL_EXT_fragment_lighting(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_fragment_lighting */ -#ifdef GL_EXT_framebuffer_blit - CONST_CAST(GLEW_EXT_framebuffer_blit) = glewGetExtension("GL_EXT_framebuffer_blit"); - if (glewExperimental || GLEW_EXT_framebuffer_blit) CONST_CAST(GLEW_EXT_framebuffer_blit) = !_glewInit_GL_EXT_framebuffer_blit(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_framebuffer_blit */ -#ifdef GL_EXT_framebuffer_multisample - CONST_CAST(GLEW_EXT_framebuffer_multisample) = glewGetExtension("GL_EXT_framebuffer_multisample"); - if (glewExperimental || GLEW_EXT_framebuffer_multisample) CONST_CAST(GLEW_EXT_framebuffer_multisample) = !_glewInit_GL_EXT_framebuffer_multisample(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_framebuffer_multisample */ -#ifdef GL_EXT_framebuffer_object - CONST_CAST(GLEW_EXT_framebuffer_object) = glewGetExtension("GL_EXT_framebuffer_object"); - if (glewExperimental || GLEW_EXT_framebuffer_object) CONST_CAST(GLEW_EXT_framebuffer_object) = !_glewInit_GL_EXT_framebuffer_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_framebuffer_object */ -#ifdef GL_EXT_framebuffer_sRGB - CONST_CAST(GLEW_EXT_framebuffer_sRGB) = glewGetExtension("GL_EXT_framebuffer_sRGB"); -#endif /* GL_EXT_framebuffer_sRGB */ -#ifdef GL_EXT_geometry_shader4 - CONST_CAST(GLEW_EXT_geometry_shader4) = glewGetExtension("GL_EXT_geometry_shader4"); - if (glewExperimental || GLEW_EXT_geometry_shader4) CONST_CAST(GLEW_EXT_geometry_shader4) = !_glewInit_GL_EXT_geometry_shader4(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_geometry_shader4 */ -#ifdef GL_EXT_gpu_program_parameters - CONST_CAST(GLEW_EXT_gpu_program_parameters) = glewGetExtension("GL_EXT_gpu_program_parameters"); - if (glewExperimental || GLEW_EXT_gpu_program_parameters) CONST_CAST(GLEW_EXT_gpu_program_parameters) = !_glewInit_GL_EXT_gpu_program_parameters(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_gpu_program_parameters */ -#ifdef GL_EXT_gpu_shader4 - CONST_CAST(GLEW_EXT_gpu_shader4) = glewGetExtension("GL_EXT_gpu_shader4"); - if (glewExperimental || GLEW_EXT_gpu_shader4) CONST_CAST(GLEW_EXT_gpu_shader4) = !_glewInit_GL_EXT_gpu_shader4(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_gpu_shader4 */ -#ifdef GL_EXT_histogram - CONST_CAST(GLEW_EXT_histogram) = glewGetExtension("GL_EXT_histogram"); - if (glewExperimental || GLEW_EXT_histogram) CONST_CAST(GLEW_EXT_histogram) = !_glewInit_GL_EXT_histogram(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_histogram */ -#ifdef GL_EXT_index_array_formats - CONST_CAST(GLEW_EXT_index_array_formats) = glewGetExtension("GL_EXT_index_array_formats"); -#endif /* GL_EXT_index_array_formats */ -#ifdef GL_EXT_index_func - CONST_CAST(GLEW_EXT_index_func) = glewGetExtension("GL_EXT_index_func"); - if (glewExperimental || GLEW_EXT_index_func) CONST_CAST(GLEW_EXT_index_func) = !_glewInit_GL_EXT_index_func(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_index_func */ -#ifdef GL_EXT_index_material - CONST_CAST(GLEW_EXT_index_material) = glewGetExtension("GL_EXT_index_material"); - if (glewExperimental || GLEW_EXT_index_material) CONST_CAST(GLEW_EXT_index_material) = !_glewInit_GL_EXT_index_material(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_index_material */ -#ifdef GL_EXT_index_texture - CONST_CAST(GLEW_EXT_index_texture) = glewGetExtension("GL_EXT_index_texture"); -#endif /* GL_EXT_index_texture */ -#ifdef GL_EXT_light_texture - CONST_CAST(GLEW_EXT_light_texture) = glewGetExtension("GL_EXT_light_texture"); - if (glewExperimental || GLEW_EXT_light_texture) CONST_CAST(GLEW_EXT_light_texture) = !_glewInit_GL_EXT_light_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_light_texture */ -#ifdef GL_EXT_misc_attribute - CONST_CAST(GLEW_EXT_misc_attribute) = glewGetExtension("GL_EXT_misc_attribute"); -#endif /* GL_EXT_misc_attribute */ -#ifdef GL_EXT_multi_draw_arrays - CONST_CAST(GLEW_EXT_multi_draw_arrays) = glewGetExtension("GL_EXT_multi_draw_arrays"); - if (glewExperimental || GLEW_EXT_multi_draw_arrays) CONST_CAST(GLEW_EXT_multi_draw_arrays) = !_glewInit_GL_EXT_multi_draw_arrays(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_multi_draw_arrays */ -#ifdef GL_EXT_multisample - CONST_CAST(GLEW_EXT_multisample) = glewGetExtension("GL_EXT_multisample"); - if (glewExperimental || GLEW_EXT_multisample) CONST_CAST(GLEW_EXT_multisample) = !_glewInit_GL_EXT_multisample(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_multisample */ -#ifdef GL_EXT_packed_depth_stencil - CONST_CAST(GLEW_EXT_packed_depth_stencil) = glewGetExtension("GL_EXT_packed_depth_stencil"); -#endif /* GL_EXT_packed_depth_stencil */ -#ifdef GL_EXT_packed_float - CONST_CAST(GLEW_EXT_packed_float) = glewGetExtension("GL_EXT_packed_float"); -#endif /* GL_EXT_packed_float */ -#ifdef GL_EXT_packed_pixels - CONST_CAST(GLEW_EXT_packed_pixels) = glewGetExtension("GL_EXT_packed_pixels"); -#endif /* GL_EXT_packed_pixels */ -#ifdef GL_EXT_paletted_texture - CONST_CAST(GLEW_EXT_paletted_texture) = glewGetExtension("GL_EXT_paletted_texture"); - if (glewExperimental || GLEW_EXT_paletted_texture) CONST_CAST(GLEW_EXT_paletted_texture) = !_glewInit_GL_EXT_paletted_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_paletted_texture */ -#ifdef GL_EXT_pixel_buffer_object - CONST_CAST(GLEW_EXT_pixel_buffer_object) = glewGetExtension("GL_EXT_pixel_buffer_object"); -#endif /* GL_EXT_pixel_buffer_object */ -#ifdef GL_EXT_pixel_transform - CONST_CAST(GLEW_EXT_pixel_transform) = glewGetExtension("GL_EXT_pixel_transform"); - if (glewExperimental || GLEW_EXT_pixel_transform) CONST_CAST(GLEW_EXT_pixel_transform) = !_glewInit_GL_EXT_pixel_transform(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_pixel_transform */ -#ifdef GL_EXT_pixel_transform_color_table - CONST_CAST(GLEW_EXT_pixel_transform_color_table) = glewGetExtension("GL_EXT_pixel_transform_color_table"); -#endif /* GL_EXT_pixel_transform_color_table */ -#ifdef GL_EXT_point_parameters - CONST_CAST(GLEW_EXT_point_parameters) = glewGetExtension("GL_EXT_point_parameters"); - if (glewExperimental || GLEW_EXT_point_parameters) CONST_CAST(GLEW_EXT_point_parameters) = !_glewInit_GL_EXT_point_parameters(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_point_parameters */ -#ifdef GL_EXT_polygon_offset - CONST_CAST(GLEW_EXT_polygon_offset) = glewGetExtension("GL_EXT_polygon_offset"); - if (glewExperimental || GLEW_EXT_polygon_offset) CONST_CAST(GLEW_EXT_polygon_offset) = !_glewInit_GL_EXT_polygon_offset(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_polygon_offset */ -#ifdef GL_EXT_rescale_normal - CONST_CAST(GLEW_EXT_rescale_normal) = glewGetExtension("GL_EXT_rescale_normal"); -#endif /* GL_EXT_rescale_normal */ -#ifdef GL_EXT_scene_marker - CONST_CAST(GLEW_EXT_scene_marker) = glewGetExtension("GL_EXT_scene_marker"); - if (glewExperimental || GLEW_EXT_scene_marker) CONST_CAST(GLEW_EXT_scene_marker) = !_glewInit_GL_EXT_scene_marker(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_scene_marker */ -#ifdef GL_EXT_secondary_color - CONST_CAST(GLEW_EXT_secondary_color) = glewGetExtension("GL_EXT_secondary_color"); - if (glewExperimental || GLEW_EXT_secondary_color) CONST_CAST(GLEW_EXT_secondary_color) = !_glewInit_GL_EXT_secondary_color(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_secondary_color */ -#ifdef GL_EXT_separate_specular_color - CONST_CAST(GLEW_EXT_separate_specular_color) = glewGetExtension("GL_EXT_separate_specular_color"); -#endif /* GL_EXT_separate_specular_color */ -#ifdef GL_EXT_shadow_funcs - CONST_CAST(GLEW_EXT_shadow_funcs) = glewGetExtension("GL_EXT_shadow_funcs"); -#endif /* GL_EXT_shadow_funcs */ -#ifdef GL_EXT_shared_texture_palette - CONST_CAST(GLEW_EXT_shared_texture_palette) = glewGetExtension("GL_EXT_shared_texture_palette"); -#endif /* GL_EXT_shared_texture_palette */ -#ifdef GL_EXT_stencil_clear_tag - CONST_CAST(GLEW_EXT_stencil_clear_tag) = glewGetExtension("GL_EXT_stencil_clear_tag"); -#endif /* GL_EXT_stencil_clear_tag */ -#ifdef GL_EXT_stencil_two_side - CONST_CAST(GLEW_EXT_stencil_two_side) = glewGetExtension("GL_EXT_stencil_two_side"); - if (glewExperimental || GLEW_EXT_stencil_two_side) CONST_CAST(GLEW_EXT_stencil_two_side) = !_glewInit_GL_EXT_stencil_two_side(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_stencil_two_side */ -#ifdef GL_EXT_stencil_wrap - CONST_CAST(GLEW_EXT_stencil_wrap) = glewGetExtension("GL_EXT_stencil_wrap"); -#endif /* GL_EXT_stencil_wrap */ -#ifdef GL_EXT_subtexture - CONST_CAST(GLEW_EXT_subtexture) = glewGetExtension("GL_EXT_subtexture"); - if (glewExperimental || GLEW_EXT_subtexture) CONST_CAST(GLEW_EXT_subtexture) = !_glewInit_GL_EXT_subtexture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_subtexture */ -#ifdef GL_EXT_texture - CONST_CAST(GLEW_EXT_texture) = glewGetExtension("GL_EXT_texture"); -#endif /* GL_EXT_texture */ -#ifdef GL_EXT_texture3D - CONST_CAST(GLEW_EXT_texture3D) = glewGetExtension("GL_EXT_texture3D"); - if (glewExperimental || GLEW_EXT_texture3D) CONST_CAST(GLEW_EXT_texture3D) = !_glewInit_GL_EXT_texture3D(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_texture3D */ -#ifdef GL_EXT_texture_array - CONST_CAST(GLEW_EXT_texture_array) = glewGetExtension("GL_EXT_texture_array"); -#endif /* GL_EXT_texture_array */ -#ifdef GL_EXT_texture_buffer_object - CONST_CAST(GLEW_EXT_texture_buffer_object) = glewGetExtension("GL_EXT_texture_buffer_object"); - if (glewExperimental || GLEW_EXT_texture_buffer_object) CONST_CAST(GLEW_EXT_texture_buffer_object) = !_glewInit_GL_EXT_texture_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_texture_buffer_object */ -#ifdef GL_EXT_texture_compression_dxt1 - CONST_CAST(GLEW_EXT_texture_compression_dxt1) = glewGetExtension("GL_EXT_texture_compression_dxt1"); -#endif /* GL_EXT_texture_compression_dxt1 */ -#ifdef GL_EXT_texture_compression_latc - CONST_CAST(GLEW_EXT_texture_compression_latc) = glewGetExtension("GL_EXT_texture_compression_latc"); -#endif /* GL_EXT_texture_compression_latc */ -#ifdef GL_EXT_texture_compression_rgtc - CONST_CAST(GLEW_EXT_texture_compression_rgtc) = glewGetExtension("GL_EXT_texture_compression_rgtc"); -#endif /* GL_EXT_texture_compression_rgtc */ -#ifdef GL_EXT_texture_compression_s3tc - CONST_CAST(GLEW_EXT_texture_compression_s3tc) = glewGetExtension("GL_EXT_texture_compression_s3tc"); -#endif /* GL_EXT_texture_compression_s3tc */ -#ifdef GL_EXT_texture_cube_map - CONST_CAST(GLEW_EXT_texture_cube_map) = glewGetExtension("GL_EXT_texture_cube_map"); -#endif /* GL_EXT_texture_cube_map */ -#ifdef GL_EXT_texture_edge_clamp - CONST_CAST(GLEW_EXT_texture_edge_clamp) = glewGetExtension("GL_EXT_texture_edge_clamp"); -#endif /* GL_EXT_texture_edge_clamp */ -#ifdef GL_EXT_texture_env - CONST_CAST(GLEW_EXT_texture_env) = glewGetExtension("GL_EXT_texture_env"); -#endif /* GL_EXT_texture_env */ -#ifdef GL_EXT_texture_env_add - CONST_CAST(GLEW_EXT_texture_env_add) = glewGetExtension("GL_EXT_texture_env_add"); -#endif /* GL_EXT_texture_env_add */ -#ifdef GL_EXT_texture_env_combine - CONST_CAST(GLEW_EXT_texture_env_combine) = glewGetExtension("GL_EXT_texture_env_combine"); -#endif /* GL_EXT_texture_env_combine */ -#ifdef GL_EXT_texture_env_dot3 - CONST_CAST(GLEW_EXT_texture_env_dot3) = glewGetExtension("GL_EXT_texture_env_dot3"); -#endif /* GL_EXT_texture_env_dot3 */ -#ifdef GL_EXT_texture_filter_anisotropic - CONST_CAST(GLEW_EXT_texture_filter_anisotropic) = glewGetExtension("GL_EXT_texture_filter_anisotropic"); -#endif /* GL_EXT_texture_filter_anisotropic */ -#ifdef GL_EXT_texture_integer - CONST_CAST(GLEW_EXT_texture_integer) = glewGetExtension("GL_EXT_texture_integer"); - if (glewExperimental || GLEW_EXT_texture_integer) CONST_CAST(GLEW_EXT_texture_integer) = !_glewInit_GL_EXT_texture_integer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_texture_integer */ -#ifdef GL_EXT_texture_lod_bias - CONST_CAST(GLEW_EXT_texture_lod_bias) = glewGetExtension("GL_EXT_texture_lod_bias"); -#endif /* GL_EXT_texture_lod_bias */ -#ifdef GL_EXT_texture_mirror_clamp - CONST_CAST(GLEW_EXT_texture_mirror_clamp) = glewGetExtension("GL_EXT_texture_mirror_clamp"); -#endif /* GL_EXT_texture_mirror_clamp */ -#ifdef GL_EXT_texture_object - CONST_CAST(GLEW_EXT_texture_object) = glewGetExtension("GL_EXT_texture_object"); - if (glewExperimental || GLEW_EXT_texture_object) CONST_CAST(GLEW_EXT_texture_object) = !_glewInit_GL_EXT_texture_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_texture_object */ -#ifdef GL_EXT_texture_perturb_normal - CONST_CAST(GLEW_EXT_texture_perturb_normal) = glewGetExtension("GL_EXT_texture_perturb_normal"); - if (glewExperimental || GLEW_EXT_texture_perturb_normal) CONST_CAST(GLEW_EXT_texture_perturb_normal) = !_glewInit_GL_EXT_texture_perturb_normal(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_texture_perturb_normal */ -#ifdef GL_EXT_texture_rectangle - CONST_CAST(GLEW_EXT_texture_rectangle) = glewGetExtension("GL_EXT_texture_rectangle"); -#endif /* GL_EXT_texture_rectangle */ -#ifdef GL_EXT_texture_sRGB - CONST_CAST(GLEW_EXT_texture_sRGB) = glewGetExtension("GL_EXT_texture_sRGB"); -#endif /* GL_EXT_texture_sRGB */ -#ifdef GL_EXT_texture_shared_exponent - CONST_CAST(GLEW_EXT_texture_shared_exponent) = glewGetExtension("GL_EXT_texture_shared_exponent"); -#endif /* GL_EXT_texture_shared_exponent */ -#ifdef GL_EXT_texture_swizzle - CONST_CAST(GLEW_EXT_texture_swizzle) = glewGetExtension("GL_EXT_texture_swizzle"); -#endif /* GL_EXT_texture_swizzle */ -#ifdef GL_EXT_timer_query - CONST_CAST(GLEW_EXT_timer_query) = glewGetExtension("GL_EXT_timer_query"); - if (glewExperimental || GLEW_EXT_timer_query) CONST_CAST(GLEW_EXT_timer_query) = !_glewInit_GL_EXT_timer_query(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_timer_query */ -#ifdef GL_EXT_transform_feedback - CONST_CAST(GLEW_EXT_transform_feedback) = glewGetExtension("GL_EXT_transform_feedback"); - if (glewExperimental || GLEW_EXT_transform_feedback) CONST_CAST(GLEW_EXT_transform_feedback) = !_glewInit_GL_EXT_transform_feedback(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_transform_feedback */ -#ifdef GL_EXT_vertex_array - CONST_CAST(GLEW_EXT_vertex_array) = glewGetExtension("GL_EXT_vertex_array"); - if (glewExperimental || GLEW_EXT_vertex_array) CONST_CAST(GLEW_EXT_vertex_array) = !_glewInit_GL_EXT_vertex_array(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_vertex_array */ -#ifdef GL_EXT_vertex_array_bgra - CONST_CAST(GLEW_EXT_vertex_array_bgra) = glewGetExtension("GL_EXT_vertex_array_bgra"); -#endif /* GL_EXT_vertex_array_bgra */ -#ifdef GL_EXT_vertex_shader - CONST_CAST(GLEW_EXT_vertex_shader) = glewGetExtension("GL_EXT_vertex_shader"); - if (glewExperimental || GLEW_EXT_vertex_shader) CONST_CAST(GLEW_EXT_vertex_shader) = !_glewInit_GL_EXT_vertex_shader(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_vertex_shader */ -#ifdef GL_EXT_vertex_weighting - CONST_CAST(GLEW_EXT_vertex_weighting) = glewGetExtension("GL_EXT_vertex_weighting"); - if (glewExperimental || GLEW_EXT_vertex_weighting) CONST_CAST(GLEW_EXT_vertex_weighting) = !_glewInit_GL_EXT_vertex_weighting(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_EXT_vertex_weighting */ -#ifdef GL_GREMEDY_frame_terminator - CONST_CAST(GLEW_GREMEDY_frame_terminator) = glewGetExtension("GL_GREMEDY_frame_terminator"); - if (glewExperimental || GLEW_GREMEDY_frame_terminator) CONST_CAST(GLEW_GREMEDY_frame_terminator) = !_glewInit_GL_GREMEDY_frame_terminator(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_GREMEDY_frame_terminator */ -#ifdef GL_GREMEDY_string_marker - CONST_CAST(GLEW_GREMEDY_string_marker) = glewGetExtension("GL_GREMEDY_string_marker"); - if (glewExperimental || GLEW_GREMEDY_string_marker) CONST_CAST(GLEW_GREMEDY_string_marker) = !_glewInit_GL_GREMEDY_string_marker(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_GREMEDY_string_marker */ -#ifdef GL_HP_convolution_border_modes - CONST_CAST(GLEW_HP_convolution_border_modes) = glewGetExtension("GL_HP_convolution_border_modes"); -#endif /* GL_HP_convolution_border_modes */ -#ifdef GL_HP_image_transform - CONST_CAST(GLEW_HP_image_transform) = glewGetExtension("GL_HP_image_transform"); - if (glewExperimental || GLEW_HP_image_transform) CONST_CAST(GLEW_HP_image_transform) = !_glewInit_GL_HP_image_transform(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_HP_image_transform */ -#ifdef GL_HP_occlusion_test - CONST_CAST(GLEW_HP_occlusion_test) = glewGetExtension("GL_HP_occlusion_test"); -#endif /* GL_HP_occlusion_test */ -#ifdef GL_HP_texture_lighting - CONST_CAST(GLEW_HP_texture_lighting) = glewGetExtension("GL_HP_texture_lighting"); -#endif /* GL_HP_texture_lighting */ -#ifdef GL_IBM_cull_vertex - CONST_CAST(GLEW_IBM_cull_vertex) = glewGetExtension("GL_IBM_cull_vertex"); -#endif /* GL_IBM_cull_vertex */ -#ifdef GL_IBM_multimode_draw_arrays - CONST_CAST(GLEW_IBM_multimode_draw_arrays) = glewGetExtension("GL_IBM_multimode_draw_arrays"); - if (glewExperimental || GLEW_IBM_multimode_draw_arrays) CONST_CAST(GLEW_IBM_multimode_draw_arrays) = !_glewInit_GL_IBM_multimode_draw_arrays(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_IBM_multimode_draw_arrays */ -#ifdef GL_IBM_rasterpos_clip - CONST_CAST(GLEW_IBM_rasterpos_clip) = glewGetExtension("GL_IBM_rasterpos_clip"); -#endif /* GL_IBM_rasterpos_clip */ -#ifdef GL_IBM_static_data - CONST_CAST(GLEW_IBM_static_data) = glewGetExtension("GL_IBM_static_data"); -#endif /* GL_IBM_static_data */ -#ifdef GL_IBM_texture_mirrored_repeat - CONST_CAST(GLEW_IBM_texture_mirrored_repeat) = glewGetExtension("GL_IBM_texture_mirrored_repeat"); -#endif /* GL_IBM_texture_mirrored_repeat */ -#ifdef GL_IBM_vertex_array_lists - CONST_CAST(GLEW_IBM_vertex_array_lists) = glewGetExtension("GL_IBM_vertex_array_lists"); - if (glewExperimental || GLEW_IBM_vertex_array_lists) CONST_CAST(GLEW_IBM_vertex_array_lists) = !_glewInit_GL_IBM_vertex_array_lists(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_IBM_vertex_array_lists */ -#ifdef GL_INGR_color_clamp - CONST_CAST(GLEW_INGR_color_clamp) = glewGetExtension("GL_INGR_color_clamp"); -#endif /* GL_INGR_color_clamp */ -#ifdef GL_INGR_interlace_read - CONST_CAST(GLEW_INGR_interlace_read) = glewGetExtension("GL_INGR_interlace_read"); -#endif /* GL_INGR_interlace_read */ -#ifdef GL_INTEL_parallel_arrays - CONST_CAST(GLEW_INTEL_parallel_arrays) = glewGetExtension("GL_INTEL_parallel_arrays"); - if (glewExperimental || GLEW_INTEL_parallel_arrays) CONST_CAST(GLEW_INTEL_parallel_arrays) = !_glewInit_GL_INTEL_parallel_arrays(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_INTEL_parallel_arrays */ -#ifdef GL_INTEL_texture_scissor - CONST_CAST(GLEW_INTEL_texture_scissor) = glewGetExtension("GL_INTEL_texture_scissor"); - if (glewExperimental || GLEW_INTEL_texture_scissor) CONST_CAST(GLEW_INTEL_texture_scissor) = !_glewInit_GL_INTEL_texture_scissor(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_INTEL_texture_scissor */ -#ifdef GL_KTX_buffer_region - CONST_CAST(GLEW_KTX_buffer_region) = glewGetExtension("GL_KTX_buffer_region"); - if (glewExperimental || GLEW_KTX_buffer_region) CONST_CAST(GLEW_KTX_buffer_region) = !_glewInit_GL_KTX_buffer_region(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_KTX_buffer_region */ -#ifdef GL_MESAX_texture_stack - CONST_CAST(GLEW_MESAX_texture_stack) = glewGetExtension("GL_MESAX_texture_stack"); -#endif /* GL_MESAX_texture_stack */ -#ifdef GL_MESA_pack_invert - CONST_CAST(GLEW_MESA_pack_invert) = glewGetExtension("GL_MESA_pack_invert"); -#endif /* GL_MESA_pack_invert */ -#ifdef GL_MESA_resize_buffers - CONST_CAST(GLEW_MESA_resize_buffers) = glewGetExtension("GL_MESA_resize_buffers"); - if (glewExperimental || GLEW_MESA_resize_buffers) CONST_CAST(GLEW_MESA_resize_buffers) = !_glewInit_GL_MESA_resize_buffers(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_MESA_resize_buffers */ -#ifdef GL_MESA_window_pos - CONST_CAST(GLEW_MESA_window_pos) = glewGetExtension("GL_MESA_window_pos"); - if (glewExperimental || GLEW_MESA_window_pos) CONST_CAST(GLEW_MESA_window_pos) = !_glewInit_GL_MESA_window_pos(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_MESA_window_pos */ -#ifdef GL_MESA_ycbcr_texture - CONST_CAST(GLEW_MESA_ycbcr_texture) = glewGetExtension("GL_MESA_ycbcr_texture"); -#endif /* GL_MESA_ycbcr_texture */ -#ifdef GL_NV_blend_square - CONST_CAST(GLEW_NV_blend_square) = glewGetExtension("GL_NV_blend_square"); -#endif /* GL_NV_blend_square */ -#ifdef GL_NV_conditional_render - CONST_CAST(GLEW_NV_conditional_render) = glewGetExtension("GL_NV_conditional_render"); - if (glewExperimental || GLEW_NV_conditional_render) CONST_CAST(GLEW_NV_conditional_render) = !_glewInit_GL_NV_conditional_render(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_conditional_render */ -#ifdef GL_NV_copy_depth_to_color - CONST_CAST(GLEW_NV_copy_depth_to_color) = glewGetExtension("GL_NV_copy_depth_to_color"); -#endif /* GL_NV_copy_depth_to_color */ -#ifdef GL_NV_depth_buffer_float - CONST_CAST(GLEW_NV_depth_buffer_float) = glewGetExtension("GL_NV_depth_buffer_float"); - if (glewExperimental || GLEW_NV_depth_buffer_float) CONST_CAST(GLEW_NV_depth_buffer_float) = !_glewInit_GL_NV_depth_buffer_float(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_depth_buffer_float */ -#ifdef GL_NV_depth_clamp - CONST_CAST(GLEW_NV_depth_clamp) = glewGetExtension("GL_NV_depth_clamp"); -#endif /* GL_NV_depth_clamp */ -#ifdef GL_NV_depth_range_unclamped - CONST_CAST(GLEW_NV_depth_range_unclamped) = glewGetExtension("GL_NV_depth_range_unclamped"); -#endif /* GL_NV_depth_range_unclamped */ -#ifdef GL_NV_evaluators - CONST_CAST(GLEW_NV_evaluators) = glewGetExtension("GL_NV_evaluators"); - if (glewExperimental || GLEW_NV_evaluators) CONST_CAST(GLEW_NV_evaluators) = !_glewInit_GL_NV_evaluators(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_evaluators */ -#ifdef GL_NV_explicit_multisample - CONST_CAST(GLEW_NV_explicit_multisample) = glewGetExtension("GL_NV_explicit_multisample"); - if (glewExperimental || GLEW_NV_explicit_multisample) CONST_CAST(GLEW_NV_explicit_multisample) = !_glewInit_GL_NV_explicit_multisample(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_explicit_multisample */ -#ifdef GL_NV_fence - CONST_CAST(GLEW_NV_fence) = glewGetExtension("GL_NV_fence"); - if (glewExperimental || GLEW_NV_fence) CONST_CAST(GLEW_NV_fence) = !_glewInit_GL_NV_fence(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_fence */ -#ifdef GL_NV_float_buffer - CONST_CAST(GLEW_NV_float_buffer) = glewGetExtension("GL_NV_float_buffer"); -#endif /* GL_NV_float_buffer */ -#ifdef GL_NV_fog_distance - CONST_CAST(GLEW_NV_fog_distance) = glewGetExtension("GL_NV_fog_distance"); -#endif /* GL_NV_fog_distance */ -#ifdef GL_NV_fragment_program - CONST_CAST(GLEW_NV_fragment_program) = glewGetExtension("GL_NV_fragment_program"); - if (glewExperimental || GLEW_NV_fragment_program) CONST_CAST(GLEW_NV_fragment_program) = !_glewInit_GL_NV_fragment_program(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_fragment_program */ -#ifdef GL_NV_fragment_program2 - CONST_CAST(GLEW_NV_fragment_program2) = glewGetExtension("GL_NV_fragment_program2"); -#endif /* GL_NV_fragment_program2 */ -#ifdef GL_NV_fragment_program4 - CONST_CAST(GLEW_NV_fragment_program4) = glewGetExtension("GL_NV_fragment_program4"); -#endif /* GL_NV_fragment_program4 */ -#ifdef GL_NV_fragment_program_option - CONST_CAST(GLEW_NV_fragment_program_option) = glewGetExtension("GL_NV_fragment_program_option"); -#endif /* GL_NV_fragment_program_option */ -#ifdef GL_NV_framebuffer_multisample_coverage - CONST_CAST(GLEW_NV_framebuffer_multisample_coverage) = glewGetExtension("GL_NV_framebuffer_multisample_coverage"); - if (glewExperimental || GLEW_NV_framebuffer_multisample_coverage) CONST_CAST(GLEW_NV_framebuffer_multisample_coverage) = !_glewInit_GL_NV_framebuffer_multisample_coverage(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_framebuffer_multisample_coverage */ -#ifdef GL_NV_geometry_program4 - CONST_CAST(GLEW_NV_geometry_program4) = glewGetExtension("GL_NV_geometry_program4"); - if (glewExperimental || GLEW_NV_geometry_program4) CONST_CAST(GLEW_NV_geometry_program4) = !_glewInit_GL_NV_geometry_program4(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_geometry_program4 */ -#ifdef GL_NV_geometry_shader4 - CONST_CAST(GLEW_NV_geometry_shader4) = glewGetExtension("GL_NV_geometry_shader4"); -#endif /* GL_NV_geometry_shader4 */ -#ifdef GL_NV_gpu_program4 - CONST_CAST(GLEW_NV_gpu_program4) = glewGetExtension("GL_NV_gpu_program4"); - if (glewExperimental || GLEW_NV_gpu_program4) CONST_CAST(GLEW_NV_gpu_program4) = !_glewInit_GL_NV_gpu_program4(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_gpu_program4 */ -#ifdef GL_NV_half_float - CONST_CAST(GLEW_NV_half_float) = glewGetExtension("GL_NV_half_float"); - if (glewExperimental || GLEW_NV_half_float) CONST_CAST(GLEW_NV_half_float) = !_glewInit_GL_NV_half_float(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_half_float */ -#ifdef GL_NV_light_max_exponent - CONST_CAST(GLEW_NV_light_max_exponent) = glewGetExtension("GL_NV_light_max_exponent"); -#endif /* GL_NV_light_max_exponent */ -#ifdef GL_NV_multisample_filter_hint - CONST_CAST(GLEW_NV_multisample_filter_hint) = glewGetExtension("GL_NV_multisample_filter_hint"); -#endif /* GL_NV_multisample_filter_hint */ -#ifdef GL_NV_occlusion_query - CONST_CAST(GLEW_NV_occlusion_query) = glewGetExtension("GL_NV_occlusion_query"); - if (glewExperimental || GLEW_NV_occlusion_query) CONST_CAST(GLEW_NV_occlusion_query) = !_glewInit_GL_NV_occlusion_query(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_occlusion_query */ -#ifdef GL_NV_packed_depth_stencil - CONST_CAST(GLEW_NV_packed_depth_stencil) = glewGetExtension("GL_NV_packed_depth_stencil"); -#endif /* GL_NV_packed_depth_stencil */ -#ifdef GL_NV_parameter_buffer_object - CONST_CAST(GLEW_NV_parameter_buffer_object) = glewGetExtension("GL_NV_parameter_buffer_object"); - if (glewExperimental || GLEW_NV_parameter_buffer_object) CONST_CAST(GLEW_NV_parameter_buffer_object) = !_glewInit_GL_NV_parameter_buffer_object(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_parameter_buffer_object */ -#ifdef GL_NV_pixel_data_range - CONST_CAST(GLEW_NV_pixel_data_range) = glewGetExtension("GL_NV_pixel_data_range"); - if (glewExperimental || GLEW_NV_pixel_data_range) CONST_CAST(GLEW_NV_pixel_data_range) = !_glewInit_GL_NV_pixel_data_range(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_pixel_data_range */ -#ifdef GL_NV_point_sprite - CONST_CAST(GLEW_NV_point_sprite) = glewGetExtension("GL_NV_point_sprite"); - if (glewExperimental || GLEW_NV_point_sprite) CONST_CAST(GLEW_NV_point_sprite) = !_glewInit_GL_NV_point_sprite(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_point_sprite */ -#ifdef GL_NV_present_video - CONST_CAST(GLEW_NV_present_video) = glewGetExtension("GL_NV_present_video"); - if (glewExperimental || GLEW_NV_present_video) CONST_CAST(GLEW_NV_present_video) = !_glewInit_GL_NV_present_video(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_present_video */ -#ifdef GL_NV_primitive_restart - CONST_CAST(GLEW_NV_primitive_restart) = glewGetExtension("GL_NV_primitive_restart"); - if (glewExperimental || GLEW_NV_primitive_restart) CONST_CAST(GLEW_NV_primitive_restart) = !_glewInit_GL_NV_primitive_restart(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_primitive_restart */ -#ifdef GL_NV_register_combiners - CONST_CAST(GLEW_NV_register_combiners) = glewGetExtension("GL_NV_register_combiners"); - if (glewExperimental || GLEW_NV_register_combiners) CONST_CAST(GLEW_NV_register_combiners) = !_glewInit_GL_NV_register_combiners(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_register_combiners */ -#ifdef GL_NV_register_combiners2 - CONST_CAST(GLEW_NV_register_combiners2) = glewGetExtension("GL_NV_register_combiners2"); - if (glewExperimental || GLEW_NV_register_combiners2) CONST_CAST(GLEW_NV_register_combiners2) = !_glewInit_GL_NV_register_combiners2(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_register_combiners2 */ -#ifdef GL_NV_texgen_emboss - CONST_CAST(GLEW_NV_texgen_emboss) = glewGetExtension("GL_NV_texgen_emboss"); -#endif /* GL_NV_texgen_emboss */ -#ifdef GL_NV_texgen_reflection - CONST_CAST(GLEW_NV_texgen_reflection) = glewGetExtension("GL_NV_texgen_reflection"); -#endif /* GL_NV_texgen_reflection */ -#ifdef GL_NV_texture_compression_vtc - CONST_CAST(GLEW_NV_texture_compression_vtc) = glewGetExtension("GL_NV_texture_compression_vtc"); -#endif /* GL_NV_texture_compression_vtc */ -#ifdef GL_NV_texture_env_combine4 - CONST_CAST(GLEW_NV_texture_env_combine4) = glewGetExtension("GL_NV_texture_env_combine4"); -#endif /* GL_NV_texture_env_combine4 */ -#ifdef GL_NV_texture_expand_normal - CONST_CAST(GLEW_NV_texture_expand_normal) = glewGetExtension("GL_NV_texture_expand_normal"); -#endif /* GL_NV_texture_expand_normal */ -#ifdef GL_NV_texture_rectangle - CONST_CAST(GLEW_NV_texture_rectangle) = glewGetExtension("GL_NV_texture_rectangle"); -#endif /* GL_NV_texture_rectangle */ -#ifdef GL_NV_texture_shader - CONST_CAST(GLEW_NV_texture_shader) = glewGetExtension("GL_NV_texture_shader"); -#endif /* GL_NV_texture_shader */ -#ifdef GL_NV_texture_shader2 - CONST_CAST(GLEW_NV_texture_shader2) = glewGetExtension("GL_NV_texture_shader2"); -#endif /* GL_NV_texture_shader2 */ -#ifdef GL_NV_texture_shader3 - CONST_CAST(GLEW_NV_texture_shader3) = glewGetExtension("GL_NV_texture_shader3"); -#endif /* GL_NV_texture_shader3 */ -#ifdef GL_NV_transform_feedback - CONST_CAST(GLEW_NV_transform_feedback) = glewGetExtension("GL_NV_transform_feedback"); - if (glewExperimental || GLEW_NV_transform_feedback) CONST_CAST(GLEW_NV_transform_feedback) = !_glewInit_GL_NV_transform_feedback(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_transform_feedback */ -#ifdef GL_NV_vertex_array_range - CONST_CAST(GLEW_NV_vertex_array_range) = glewGetExtension("GL_NV_vertex_array_range"); - if (glewExperimental || GLEW_NV_vertex_array_range) CONST_CAST(GLEW_NV_vertex_array_range) = !_glewInit_GL_NV_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_vertex_array_range */ -#ifdef GL_NV_vertex_array_range2 - CONST_CAST(GLEW_NV_vertex_array_range2) = glewGetExtension("GL_NV_vertex_array_range2"); -#endif /* GL_NV_vertex_array_range2 */ -#ifdef GL_NV_vertex_program - CONST_CAST(GLEW_NV_vertex_program) = glewGetExtension("GL_NV_vertex_program"); - if (glewExperimental || GLEW_NV_vertex_program) CONST_CAST(GLEW_NV_vertex_program) = !_glewInit_GL_NV_vertex_program(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_NV_vertex_program */ -#ifdef GL_NV_vertex_program1_1 - CONST_CAST(GLEW_NV_vertex_program1_1) = glewGetExtension("GL_NV_vertex_program1_1"); -#endif /* GL_NV_vertex_program1_1 */ -#ifdef GL_NV_vertex_program2 - CONST_CAST(GLEW_NV_vertex_program2) = glewGetExtension("GL_NV_vertex_program2"); -#endif /* GL_NV_vertex_program2 */ -#ifdef GL_NV_vertex_program2_option - CONST_CAST(GLEW_NV_vertex_program2_option) = glewGetExtension("GL_NV_vertex_program2_option"); -#endif /* GL_NV_vertex_program2_option */ -#ifdef GL_NV_vertex_program3 - CONST_CAST(GLEW_NV_vertex_program3) = glewGetExtension("GL_NV_vertex_program3"); -#endif /* GL_NV_vertex_program3 */ -#ifdef GL_NV_vertex_program4 - CONST_CAST(GLEW_NV_vertex_program4) = glewGetExtension("GL_NV_vertex_program4"); -#endif /* GL_NV_vertex_program4 */ -#ifdef GL_OES_byte_coordinates - CONST_CAST(GLEW_OES_byte_coordinates) = glewGetExtension("GL_OES_byte_coordinates"); -#endif /* GL_OES_byte_coordinates */ -#ifdef GL_OES_compressed_paletted_texture - CONST_CAST(GLEW_OES_compressed_paletted_texture) = glewGetExtension("GL_OES_compressed_paletted_texture"); -#endif /* GL_OES_compressed_paletted_texture */ -#ifdef GL_OES_read_format - CONST_CAST(GLEW_OES_read_format) = glewGetExtension("GL_OES_read_format"); -#endif /* GL_OES_read_format */ -#ifdef GL_OES_single_precision - CONST_CAST(GLEW_OES_single_precision) = glewGetExtension("GL_OES_single_precision"); - if (glewExperimental || GLEW_OES_single_precision) CONST_CAST(GLEW_OES_single_precision) = !_glewInit_GL_OES_single_precision(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_OES_single_precision */ -#ifdef GL_OML_interlace - CONST_CAST(GLEW_OML_interlace) = glewGetExtension("GL_OML_interlace"); -#endif /* GL_OML_interlace */ -#ifdef GL_OML_resample - CONST_CAST(GLEW_OML_resample) = glewGetExtension("GL_OML_resample"); -#endif /* GL_OML_resample */ -#ifdef GL_OML_subsample - CONST_CAST(GLEW_OML_subsample) = glewGetExtension("GL_OML_subsample"); -#endif /* GL_OML_subsample */ -#ifdef GL_PGI_misc_hints - CONST_CAST(GLEW_PGI_misc_hints) = glewGetExtension("GL_PGI_misc_hints"); -#endif /* GL_PGI_misc_hints */ -#ifdef GL_PGI_vertex_hints - CONST_CAST(GLEW_PGI_vertex_hints) = glewGetExtension("GL_PGI_vertex_hints"); -#endif /* GL_PGI_vertex_hints */ -#ifdef GL_REND_screen_coordinates - CONST_CAST(GLEW_REND_screen_coordinates) = glewGetExtension("GL_REND_screen_coordinates"); -#endif /* GL_REND_screen_coordinates */ -#ifdef GL_S3_s3tc - CONST_CAST(GLEW_S3_s3tc) = glewGetExtension("GL_S3_s3tc"); -#endif /* GL_S3_s3tc */ -#ifdef GL_SGIS_color_range - CONST_CAST(GLEW_SGIS_color_range) = glewGetExtension("GL_SGIS_color_range"); -#endif /* GL_SGIS_color_range */ -#ifdef GL_SGIS_detail_texture - CONST_CAST(GLEW_SGIS_detail_texture) = glewGetExtension("GL_SGIS_detail_texture"); - if (glewExperimental || GLEW_SGIS_detail_texture) CONST_CAST(GLEW_SGIS_detail_texture) = !_glewInit_GL_SGIS_detail_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIS_detail_texture */ -#ifdef GL_SGIS_fog_function - CONST_CAST(GLEW_SGIS_fog_function) = glewGetExtension("GL_SGIS_fog_function"); - if (glewExperimental || GLEW_SGIS_fog_function) CONST_CAST(GLEW_SGIS_fog_function) = !_glewInit_GL_SGIS_fog_function(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIS_fog_function */ -#ifdef GL_SGIS_generate_mipmap - CONST_CAST(GLEW_SGIS_generate_mipmap) = glewGetExtension("GL_SGIS_generate_mipmap"); -#endif /* GL_SGIS_generate_mipmap */ -#ifdef GL_SGIS_multisample - CONST_CAST(GLEW_SGIS_multisample) = glewGetExtension("GL_SGIS_multisample"); - if (glewExperimental || GLEW_SGIS_multisample) CONST_CAST(GLEW_SGIS_multisample) = !_glewInit_GL_SGIS_multisample(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIS_multisample */ -#ifdef GL_SGIS_pixel_texture - CONST_CAST(GLEW_SGIS_pixel_texture) = glewGetExtension("GL_SGIS_pixel_texture"); -#endif /* GL_SGIS_pixel_texture */ -#ifdef GL_SGIS_point_line_texgen - CONST_CAST(GLEW_SGIS_point_line_texgen) = glewGetExtension("GL_SGIS_point_line_texgen"); -#endif /* GL_SGIS_point_line_texgen */ -#ifdef GL_SGIS_sharpen_texture - CONST_CAST(GLEW_SGIS_sharpen_texture) = glewGetExtension("GL_SGIS_sharpen_texture"); - if (glewExperimental || GLEW_SGIS_sharpen_texture) CONST_CAST(GLEW_SGIS_sharpen_texture) = !_glewInit_GL_SGIS_sharpen_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIS_sharpen_texture */ -#ifdef GL_SGIS_texture4D - CONST_CAST(GLEW_SGIS_texture4D) = glewGetExtension("GL_SGIS_texture4D"); - if (glewExperimental || GLEW_SGIS_texture4D) CONST_CAST(GLEW_SGIS_texture4D) = !_glewInit_GL_SGIS_texture4D(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIS_texture4D */ -#ifdef GL_SGIS_texture_border_clamp - CONST_CAST(GLEW_SGIS_texture_border_clamp) = glewGetExtension("GL_SGIS_texture_border_clamp"); -#endif /* GL_SGIS_texture_border_clamp */ -#ifdef GL_SGIS_texture_edge_clamp - CONST_CAST(GLEW_SGIS_texture_edge_clamp) = glewGetExtension("GL_SGIS_texture_edge_clamp"); -#endif /* GL_SGIS_texture_edge_clamp */ -#ifdef GL_SGIS_texture_filter4 - CONST_CAST(GLEW_SGIS_texture_filter4) = glewGetExtension("GL_SGIS_texture_filter4"); - if (glewExperimental || GLEW_SGIS_texture_filter4) CONST_CAST(GLEW_SGIS_texture_filter4) = !_glewInit_GL_SGIS_texture_filter4(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIS_texture_filter4 */ -#ifdef GL_SGIS_texture_lod - CONST_CAST(GLEW_SGIS_texture_lod) = glewGetExtension("GL_SGIS_texture_lod"); -#endif /* GL_SGIS_texture_lod */ -#ifdef GL_SGIS_texture_select - CONST_CAST(GLEW_SGIS_texture_select) = glewGetExtension("GL_SGIS_texture_select"); -#endif /* GL_SGIS_texture_select */ -#ifdef GL_SGIX_async - CONST_CAST(GLEW_SGIX_async) = glewGetExtension("GL_SGIX_async"); - if (glewExperimental || GLEW_SGIX_async) CONST_CAST(GLEW_SGIX_async) = !_glewInit_GL_SGIX_async(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_async */ -#ifdef GL_SGIX_async_histogram - CONST_CAST(GLEW_SGIX_async_histogram) = glewGetExtension("GL_SGIX_async_histogram"); -#endif /* GL_SGIX_async_histogram */ -#ifdef GL_SGIX_async_pixel - CONST_CAST(GLEW_SGIX_async_pixel) = glewGetExtension("GL_SGIX_async_pixel"); -#endif /* GL_SGIX_async_pixel */ -#ifdef GL_SGIX_blend_alpha_minmax - CONST_CAST(GLEW_SGIX_blend_alpha_minmax) = glewGetExtension("GL_SGIX_blend_alpha_minmax"); -#endif /* GL_SGIX_blend_alpha_minmax */ -#ifdef GL_SGIX_clipmap - CONST_CAST(GLEW_SGIX_clipmap) = glewGetExtension("GL_SGIX_clipmap"); -#endif /* GL_SGIX_clipmap */ -#ifdef GL_SGIX_convolution_accuracy - CONST_CAST(GLEW_SGIX_convolution_accuracy) = glewGetExtension("GL_SGIX_convolution_accuracy"); -#endif /* GL_SGIX_convolution_accuracy */ -#ifdef GL_SGIX_depth_texture - CONST_CAST(GLEW_SGIX_depth_texture) = glewGetExtension("GL_SGIX_depth_texture"); -#endif /* GL_SGIX_depth_texture */ -#ifdef GL_SGIX_flush_raster - CONST_CAST(GLEW_SGIX_flush_raster) = glewGetExtension("GL_SGIX_flush_raster"); - if (glewExperimental || GLEW_SGIX_flush_raster) CONST_CAST(GLEW_SGIX_flush_raster) = !_glewInit_GL_SGIX_flush_raster(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_flush_raster */ -#ifdef GL_SGIX_fog_offset - CONST_CAST(GLEW_SGIX_fog_offset) = glewGetExtension("GL_SGIX_fog_offset"); -#endif /* GL_SGIX_fog_offset */ -#ifdef GL_SGIX_fog_texture - CONST_CAST(GLEW_SGIX_fog_texture) = glewGetExtension("GL_SGIX_fog_texture"); - if (glewExperimental || GLEW_SGIX_fog_texture) CONST_CAST(GLEW_SGIX_fog_texture) = !_glewInit_GL_SGIX_fog_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_fog_texture */ -#ifdef GL_SGIX_fragment_specular_lighting - CONST_CAST(GLEW_SGIX_fragment_specular_lighting) = glewGetExtension("GL_SGIX_fragment_specular_lighting"); - if (glewExperimental || GLEW_SGIX_fragment_specular_lighting) CONST_CAST(GLEW_SGIX_fragment_specular_lighting) = !_glewInit_GL_SGIX_fragment_specular_lighting(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_fragment_specular_lighting */ -#ifdef GL_SGIX_framezoom - CONST_CAST(GLEW_SGIX_framezoom) = glewGetExtension("GL_SGIX_framezoom"); - if (glewExperimental || GLEW_SGIX_framezoom) CONST_CAST(GLEW_SGIX_framezoom) = !_glewInit_GL_SGIX_framezoom(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_framezoom */ -#ifdef GL_SGIX_interlace - CONST_CAST(GLEW_SGIX_interlace) = glewGetExtension("GL_SGIX_interlace"); -#endif /* GL_SGIX_interlace */ -#ifdef GL_SGIX_ir_instrument1 - CONST_CAST(GLEW_SGIX_ir_instrument1) = glewGetExtension("GL_SGIX_ir_instrument1"); -#endif /* GL_SGIX_ir_instrument1 */ -#ifdef GL_SGIX_list_priority - CONST_CAST(GLEW_SGIX_list_priority) = glewGetExtension("GL_SGIX_list_priority"); -#endif /* GL_SGIX_list_priority */ -#ifdef GL_SGIX_pixel_texture - CONST_CAST(GLEW_SGIX_pixel_texture) = glewGetExtension("GL_SGIX_pixel_texture"); - if (glewExperimental || GLEW_SGIX_pixel_texture) CONST_CAST(GLEW_SGIX_pixel_texture) = !_glewInit_GL_SGIX_pixel_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_pixel_texture */ -#ifdef GL_SGIX_pixel_texture_bits - CONST_CAST(GLEW_SGIX_pixel_texture_bits) = glewGetExtension("GL_SGIX_pixel_texture_bits"); -#endif /* GL_SGIX_pixel_texture_bits */ -#ifdef GL_SGIX_reference_plane - CONST_CAST(GLEW_SGIX_reference_plane) = glewGetExtension("GL_SGIX_reference_plane"); - if (glewExperimental || GLEW_SGIX_reference_plane) CONST_CAST(GLEW_SGIX_reference_plane) = !_glewInit_GL_SGIX_reference_plane(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_reference_plane */ -#ifdef GL_SGIX_resample - CONST_CAST(GLEW_SGIX_resample) = glewGetExtension("GL_SGIX_resample"); -#endif /* GL_SGIX_resample */ -#ifdef GL_SGIX_shadow - CONST_CAST(GLEW_SGIX_shadow) = glewGetExtension("GL_SGIX_shadow"); -#endif /* GL_SGIX_shadow */ -#ifdef GL_SGIX_shadow_ambient - CONST_CAST(GLEW_SGIX_shadow_ambient) = glewGetExtension("GL_SGIX_shadow_ambient"); -#endif /* GL_SGIX_shadow_ambient */ -#ifdef GL_SGIX_sprite - CONST_CAST(GLEW_SGIX_sprite) = glewGetExtension("GL_SGIX_sprite"); - if (glewExperimental || GLEW_SGIX_sprite) CONST_CAST(GLEW_SGIX_sprite) = !_glewInit_GL_SGIX_sprite(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_sprite */ -#ifdef GL_SGIX_tag_sample_buffer - CONST_CAST(GLEW_SGIX_tag_sample_buffer) = glewGetExtension("GL_SGIX_tag_sample_buffer"); - if (glewExperimental || GLEW_SGIX_tag_sample_buffer) CONST_CAST(GLEW_SGIX_tag_sample_buffer) = !_glewInit_GL_SGIX_tag_sample_buffer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGIX_tag_sample_buffer */ -#ifdef GL_SGIX_texture_add_env - CONST_CAST(GLEW_SGIX_texture_add_env) = glewGetExtension("GL_SGIX_texture_add_env"); -#endif /* GL_SGIX_texture_add_env */ -#ifdef GL_SGIX_texture_coordinate_clamp - CONST_CAST(GLEW_SGIX_texture_coordinate_clamp) = glewGetExtension("GL_SGIX_texture_coordinate_clamp"); -#endif /* GL_SGIX_texture_coordinate_clamp */ -#ifdef GL_SGIX_texture_lod_bias - CONST_CAST(GLEW_SGIX_texture_lod_bias) = glewGetExtension("GL_SGIX_texture_lod_bias"); -#endif /* GL_SGIX_texture_lod_bias */ -#ifdef GL_SGIX_texture_multi_buffer - CONST_CAST(GLEW_SGIX_texture_multi_buffer) = glewGetExtension("GL_SGIX_texture_multi_buffer"); -#endif /* GL_SGIX_texture_multi_buffer */ -#ifdef GL_SGIX_texture_range - CONST_CAST(GLEW_SGIX_texture_range) = glewGetExtension("GL_SGIX_texture_range"); -#endif /* GL_SGIX_texture_range */ -#ifdef GL_SGIX_texture_scale_bias - CONST_CAST(GLEW_SGIX_texture_scale_bias) = glewGetExtension("GL_SGIX_texture_scale_bias"); -#endif /* GL_SGIX_texture_scale_bias */ -#ifdef GL_SGIX_vertex_preclip - CONST_CAST(GLEW_SGIX_vertex_preclip) = glewGetExtension("GL_SGIX_vertex_preclip"); -#endif /* GL_SGIX_vertex_preclip */ -#ifdef GL_SGIX_vertex_preclip_hint - CONST_CAST(GLEW_SGIX_vertex_preclip_hint) = glewGetExtension("GL_SGIX_vertex_preclip_hint"); -#endif /* GL_SGIX_vertex_preclip_hint */ -#ifdef GL_SGIX_ycrcb - CONST_CAST(GLEW_SGIX_ycrcb) = glewGetExtension("GL_SGIX_ycrcb"); -#endif /* GL_SGIX_ycrcb */ -#ifdef GL_SGI_color_matrix - CONST_CAST(GLEW_SGI_color_matrix) = glewGetExtension("GL_SGI_color_matrix"); -#endif /* GL_SGI_color_matrix */ -#ifdef GL_SGI_color_table - CONST_CAST(GLEW_SGI_color_table) = glewGetExtension("GL_SGI_color_table"); - if (glewExperimental || GLEW_SGI_color_table) CONST_CAST(GLEW_SGI_color_table) = !_glewInit_GL_SGI_color_table(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SGI_color_table */ -#ifdef GL_SGI_texture_color_table - CONST_CAST(GLEW_SGI_texture_color_table) = glewGetExtension("GL_SGI_texture_color_table"); -#endif /* GL_SGI_texture_color_table */ -#ifdef GL_SUNX_constant_data - CONST_CAST(GLEW_SUNX_constant_data) = glewGetExtension("GL_SUNX_constant_data"); - if (glewExperimental || GLEW_SUNX_constant_data) CONST_CAST(GLEW_SUNX_constant_data) = !_glewInit_GL_SUNX_constant_data(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SUNX_constant_data */ -#ifdef GL_SUN_convolution_border_modes - CONST_CAST(GLEW_SUN_convolution_border_modes) = glewGetExtension("GL_SUN_convolution_border_modes"); -#endif /* GL_SUN_convolution_border_modes */ -#ifdef GL_SUN_global_alpha - CONST_CAST(GLEW_SUN_global_alpha) = glewGetExtension("GL_SUN_global_alpha"); - if (glewExperimental || GLEW_SUN_global_alpha) CONST_CAST(GLEW_SUN_global_alpha) = !_glewInit_GL_SUN_global_alpha(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SUN_global_alpha */ -#ifdef GL_SUN_mesh_array - CONST_CAST(GLEW_SUN_mesh_array) = glewGetExtension("GL_SUN_mesh_array"); -#endif /* GL_SUN_mesh_array */ -#ifdef GL_SUN_read_video_pixels - CONST_CAST(GLEW_SUN_read_video_pixels) = glewGetExtension("GL_SUN_read_video_pixels"); - if (glewExperimental || GLEW_SUN_read_video_pixels) CONST_CAST(GLEW_SUN_read_video_pixels) = !_glewInit_GL_SUN_read_video_pixels(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SUN_read_video_pixels */ -#ifdef GL_SUN_slice_accum - CONST_CAST(GLEW_SUN_slice_accum) = glewGetExtension("GL_SUN_slice_accum"); -#endif /* GL_SUN_slice_accum */ -#ifdef GL_SUN_triangle_list - CONST_CAST(GLEW_SUN_triangle_list) = glewGetExtension("GL_SUN_triangle_list"); - if (glewExperimental || GLEW_SUN_triangle_list) CONST_CAST(GLEW_SUN_triangle_list) = !_glewInit_GL_SUN_triangle_list(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SUN_triangle_list */ -#ifdef GL_SUN_vertex - CONST_CAST(GLEW_SUN_vertex) = glewGetExtension("GL_SUN_vertex"); - if (glewExperimental || GLEW_SUN_vertex) CONST_CAST(GLEW_SUN_vertex) = !_glewInit_GL_SUN_vertex(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_SUN_vertex */ -#ifdef GL_WIN_phong_shading - CONST_CAST(GLEW_WIN_phong_shading) = glewGetExtension("GL_WIN_phong_shading"); -#endif /* GL_WIN_phong_shading */ -#ifdef GL_WIN_specular_fog - CONST_CAST(GLEW_WIN_specular_fog) = glewGetExtension("GL_WIN_specular_fog"); -#endif /* GL_WIN_specular_fog */ -#ifdef GL_WIN_swap_hint - CONST_CAST(GLEW_WIN_swap_hint) = glewGetExtension("GL_WIN_swap_hint"); - if (glewExperimental || GLEW_WIN_swap_hint) CONST_CAST(GLEW_WIN_swap_hint) = !_glewInit_GL_WIN_swap_hint(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GL_WIN_swap_hint */ - - return GLEW_OK; -} - - -#if defined(_WIN32) - -#if !defined(GLEW_MX) - -PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL = NULL; - -PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB = NULL; -PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB = NULL; -PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB = NULL; -PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB = NULL; - -PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB = NULL; - -PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB = NULL; - -PFNWGLGETCURRENTREADDCARBPROC __wglewGetCurrentReadDCARB = NULL; -PFNWGLMAKECONTEXTCURRENTARBPROC __wglewMakeContextCurrentARB = NULL; - -PFNWGLCREATEPBUFFERARBPROC __wglewCreatePbufferARB = NULL; -PFNWGLDESTROYPBUFFERARBPROC __wglewDestroyPbufferARB = NULL; -PFNWGLGETPBUFFERDCARBPROC __wglewGetPbufferDCARB = NULL; -PFNWGLQUERYPBUFFERARBPROC __wglewQueryPbufferARB = NULL; -PFNWGLRELEASEPBUFFERDCARBPROC __wglewReleasePbufferDCARB = NULL; - -PFNWGLCHOOSEPIXELFORMATARBPROC __wglewChoosePixelFormatARB = NULL; -PFNWGLGETPIXELFORMATATTRIBFVARBPROC __wglewGetPixelFormatAttribfvARB = NULL; -PFNWGLGETPIXELFORMATATTRIBIVARBPROC __wglewGetPixelFormatAttribivARB = NULL; - -PFNWGLBINDTEXIMAGEARBPROC __wglewBindTexImageARB = NULL; -PFNWGLRELEASETEXIMAGEARBPROC __wglewReleaseTexImageARB = NULL; -PFNWGLSETPBUFFERATTRIBARBPROC __wglewSetPbufferAttribARB = NULL; - -PFNWGLBINDDISPLAYCOLORTABLEEXTPROC __wglewBindDisplayColorTableEXT = NULL; -PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC __wglewCreateDisplayColorTableEXT = NULL; -PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC __wglewDestroyDisplayColorTableEXT = NULL; -PFNWGLLOADDISPLAYCOLORTABLEEXTPROC __wglewLoadDisplayColorTableEXT = NULL; - -PFNWGLGETEXTENSIONSSTRINGEXTPROC __wglewGetExtensionsStringEXT = NULL; - -PFNWGLGETCURRENTREADDCEXTPROC __wglewGetCurrentReadDCEXT = NULL; -PFNWGLMAKECONTEXTCURRENTEXTPROC __wglewMakeContextCurrentEXT = NULL; - -PFNWGLCREATEPBUFFEREXTPROC __wglewCreatePbufferEXT = NULL; -PFNWGLDESTROYPBUFFEREXTPROC __wglewDestroyPbufferEXT = NULL; -PFNWGLGETPBUFFERDCEXTPROC __wglewGetPbufferDCEXT = NULL; -PFNWGLQUERYPBUFFEREXTPROC __wglewQueryPbufferEXT = NULL; -PFNWGLRELEASEPBUFFERDCEXTPROC __wglewReleasePbufferDCEXT = NULL; - -PFNWGLCHOOSEPIXELFORMATEXTPROC __wglewChoosePixelFormatEXT = NULL; -PFNWGLGETPIXELFORMATATTRIBFVEXTPROC __wglewGetPixelFormatAttribfvEXT = NULL; -PFNWGLGETPIXELFORMATATTRIBIVEXTPROC __wglewGetPixelFormatAttribivEXT = NULL; - -PFNWGLGETSWAPINTERVALEXTPROC __wglewGetSwapIntervalEXT = NULL; -PFNWGLSWAPINTERVALEXTPROC __wglewSwapIntervalEXT = NULL; - -PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC __wglewGetDigitalVideoParametersI3D = NULL; -PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC __wglewSetDigitalVideoParametersI3D = NULL; - -PFNWGLGETGAMMATABLEI3DPROC __wglewGetGammaTableI3D = NULL; -PFNWGLGETGAMMATABLEPARAMETERSI3DPROC __wglewGetGammaTableParametersI3D = NULL; -PFNWGLSETGAMMATABLEI3DPROC __wglewSetGammaTableI3D = NULL; -PFNWGLSETGAMMATABLEPARAMETERSI3DPROC __wglewSetGammaTableParametersI3D = NULL; - -PFNWGLDISABLEGENLOCKI3DPROC __wglewDisableGenlockI3D = NULL; -PFNWGLENABLEGENLOCKI3DPROC __wglewEnableGenlockI3D = NULL; -PFNWGLGENLOCKSAMPLERATEI3DPROC __wglewGenlockSampleRateI3D = NULL; -PFNWGLGENLOCKSOURCEDELAYI3DPROC __wglewGenlockSourceDelayI3D = NULL; -PFNWGLGENLOCKSOURCEEDGEI3DPROC __wglewGenlockSourceEdgeI3D = NULL; -PFNWGLGENLOCKSOURCEI3DPROC __wglewGenlockSourceI3D = NULL; -PFNWGLGETGENLOCKSAMPLERATEI3DPROC __wglewGetGenlockSampleRateI3D = NULL; -PFNWGLGETGENLOCKSOURCEDELAYI3DPROC __wglewGetGenlockSourceDelayI3D = NULL; -PFNWGLGETGENLOCKSOURCEEDGEI3DPROC __wglewGetGenlockSourceEdgeI3D = NULL; -PFNWGLGETGENLOCKSOURCEI3DPROC __wglewGetGenlockSourceI3D = NULL; -PFNWGLISENABLEDGENLOCKI3DPROC __wglewIsEnabledGenlockI3D = NULL; -PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC __wglewQueryGenlockMaxSourceDelayI3D = NULL; - -PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC __wglewAssociateImageBufferEventsI3D = NULL; -PFNWGLCREATEIMAGEBUFFERI3DPROC __wglewCreateImageBufferI3D = NULL; -PFNWGLDESTROYIMAGEBUFFERI3DPROC __wglewDestroyImageBufferI3D = NULL; -PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC __wglewReleaseImageBufferEventsI3D = NULL; - -PFNWGLDISABLEFRAMELOCKI3DPROC __wglewDisableFrameLockI3D = NULL; -PFNWGLENABLEFRAMELOCKI3DPROC __wglewEnableFrameLockI3D = NULL; -PFNWGLISENABLEDFRAMELOCKI3DPROC __wglewIsEnabledFrameLockI3D = NULL; -PFNWGLQUERYFRAMELOCKMASTERI3DPROC __wglewQueryFrameLockMasterI3D = NULL; - -PFNWGLBEGINFRAMETRACKINGI3DPROC __wglewBeginFrameTrackingI3D = NULL; -PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D = NULL; -PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D = NULL; -PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D = NULL; - -PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV = NULL; -PFNWGLDELETEDCNVPROC __wglewDeleteDCNV = NULL; -PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV = NULL; -PFNWGLENUMGPUSFROMAFFINITYDCNVPROC __wglewEnumGpusFromAffinityDCNV = NULL; -PFNWGLENUMGPUSNVPROC __wglewEnumGpusNV = NULL; - -PFNWGLBINDVIDEODEVICENVPROC __wglewBindVideoDeviceNV = NULL; -PFNWGLENUMERATEVIDEODEVICESNVPROC __wglewEnumerateVideoDevicesNV = NULL; -PFNWGLQUERYCURRENTCONTEXTNVPROC __wglewQueryCurrentContextNV = NULL; - -PFNWGLBINDSWAPBARRIERNVPROC __wglewBindSwapBarrierNV = NULL; -PFNWGLJOINSWAPGROUPNVPROC __wglewJoinSwapGroupNV = NULL; -PFNWGLQUERYFRAMECOUNTNVPROC __wglewQueryFrameCountNV = NULL; -PFNWGLQUERYMAXSWAPGROUPSNVPROC __wglewQueryMaxSwapGroupsNV = NULL; -PFNWGLQUERYSWAPGROUPNVPROC __wglewQuerySwapGroupNV = NULL; -PFNWGLRESETFRAMECOUNTNVPROC __wglewResetFrameCountNV = NULL; - -PFNWGLALLOCATEMEMORYNVPROC __wglewAllocateMemoryNV = NULL; -PFNWGLFREEMEMORYNVPROC __wglewFreeMemoryNV = NULL; - -PFNWGLBINDVIDEOIMAGENVPROC __wglewBindVideoImageNV = NULL; -PFNWGLGETVIDEODEVICENVPROC __wglewGetVideoDeviceNV = NULL; -PFNWGLGETVIDEOINFONVPROC __wglewGetVideoInfoNV = NULL; -PFNWGLRELEASEVIDEODEVICENVPROC __wglewReleaseVideoDeviceNV = NULL; -PFNWGLRELEASEVIDEOIMAGENVPROC __wglewReleaseVideoImageNV = NULL; -PFNWGLSENDPBUFFERTOVIDEONVPROC __wglewSendPbufferToVideoNV = NULL; - -PFNWGLGETMSCRATEOMLPROC __wglewGetMscRateOML = NULL; -PFNWGLGETSYNCVALUESOMLPROC __wglewGetSyncValuesOML = NULL; -PFNWGLSWAPBUFFERSMSCOMLPROC __wglewSwapBuffersMscOML = NULL; -PFNWGLSWAPLAYERBUFFERSMSCOMLPROC __wglewSwapLayerBuffersMscOML = NULL; -PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML = NULL; -PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML = NULL; -GLboolean __WGLEW_3DFX_multisample = GL_FALSE; -GLboolean __WGLEW_3DL_stereo_control = GL_FALSE; -GLboolean __WGLEW_ARB_buffer_region = GL_FALSE; -GLboolean __WGLEW_ARB_create_context = GL_FALSE; -GLboolean __WGLEW_ARB_extensions_string = GL_FALSE; -GLboolean __WGLEW_ARB_framebuffer_sRGB = GL_FALSE; -GLboolean __WGLEW_ARB_make_current_read = GL_FALSE; -GLboolean __WGLEW_ARB_multisample = GL_FALSE; -GLboolean __WGLEW_ARB_pbuffer = GL_FALSE; -GLboolean __WGLEW_ARB_pixel_format = GL_FALSE; -GLboolean __WGLEW_ARB_pixel_format_float = GL_FALSE; -GLboolean __WGLEW_ARB_render_texture = GL_FALSE; -GLboolean __WGLEW_ATI_pixel_format_float = GL_FALSE; -GLboolean __WGLEW_ATI_render_texture_rectangle = GL_FALSE; -GLboolean __WGLEW_EXT_depth_float = GL_FALSE; -GLboolean __WGLEW_EXT_display_color_table = GL_FALSE; -GLboolean __WGLEW_EXT_extensions_string = GL_FALSE; -GLboolean __WGLEW_EXT_framebuffer_sRGB = GL_FALSE; -GLboolean __WGLEW_EXT_make_current_read = GL_FALSE; -GLboolean __WGLEW_EXT_multisample = GL_FALSE; -GLboolean __WGLEW_EXT_pbuffer = GL_FALSE; -GLboolean __WGLEW_EXT_pixel_format = GL_FALSE; -GLboolean __WGLEW_EXT_pixel_format_packed_float = GL_FALSE; -GLboolean __WGLEW_EXT_swap_control = GL_FALSE; -GLboolean __WGLEW_I3D_digital_video_control = GL_FALSE; -GLboolean __WGLEW_I3D_gamma = GL_FALSE; -GLboolean __WGLEW_I3D_genlock = GL_FALSE; -GLboolean __WGLEW_I3D_image_buffer = GL_FALSE; -GLboolean __WGLEW_I3D_swap_frame_lock = GL_FALSE; -GLboolean __WGLEW_I3D_swap_frame_usage = GL_FALSE; -GLboolean __WGLEW_NV_float_buffer = GL_FALSE; -GLboolean __WGLEW_NV_gpu_affinity = GL_FALSE; -GLboolean __WGLEW_NV_present_video = GL_FALSE; -GLboolean __WGLEW_NV_render_depth_texture = GL_FALSE; -GLboolean __WGLEW_NV_render_texture_rectangle = GL_FALSE; -GLboolean __WGLEW_NV_swap_group = GL_FALSE; -GLboolean __WGLEW_NV_vertex_array_range = GL_FALSE; -GLboolean __WGLEW_NV_video_output = GL_FALSE; -GLboolean __WGLEW_OML_sync_control = GL_FALSE; - -#endif /* !GLEW_MX */ - -#ifdef WGL_3DFX_multisample - -#endif /* WGL_3DFX_multisample */ - -#ifdef WGL_3DL_stereo_control - -static GLboolean _glewInit_WGL_3DL_stereo_control (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglSetStereoEmitterState3DL = (PFNWGLSETSTEREOEMITTERSTATE3DLPROC)glewGetProcAddress((const GLubyte*)"wglSetStereoEmitterState3DL")) == NULL) || r; - - return r; -} - -#endif /* WGL_3DL_stereo_control */ - -#ifdef WGL_ARB_buffer_region - -static GLboolean _glewInit_WGL_ARB_buffer_region (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglCreateBufferRegionARB = (PFNWGLCREATEBUFFERREGIONARBPROC)glewGetProcAddress((const GLubyte*)"wglCreateBufferRegionARB")) == NULL) || r; - r = ((wglDeleteBufferRegionARB = (PFNWGLDELETEBUFFERREGIONARBPROC)glewGetProcAddress((const GLubyte*)"wglDeleteBufferRegionARB")) == NULL) || r; - r = ((wglRestoreBufferRegionARB = (PFNWGLRESTOREBUFFERREGIONARBPROC)glewGetProcAddress((const GLubyte*)"wglRestoreBufferRegionARB")) == NULL) || r; - r = ((wglSaveBufferRegionARB = (PFNWGLSAVEBUFFERREGIONARBPROC)glewGetProcAddress((const GLubyte*)"wglSaveBufferRegionARB")) == NULL) || r; - - return r; -} - -#endif /* WGL_ARB_buffer_region */ - -#ifdef WGL_ARB_create_context - -static GLboolean _glewInit_WGL_ARB_create_context (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)glewGetProcAddress((const GLubyte*)"wglCreateContextAttribsARB")) == NULL) || r; - - return r; -} - -#endif /* WGL_ARB_create_context */ - -#ifdef WGL_ARB_extensions_string - -static GLboolean _glewInit_WGL_ARB_extensions_string (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"wglGetExtensionsStringARB")) == NULL) || r; - - return r; -} - -#endif /* WGL_ARB_extensions_string */ - -#ifdef WGL_ARB_framebuffer_sRGB - -#endif /* WGL_ARB_framebuffer_sRGB */ - -#ifdef WGL_ARB_make_current_read - -static GLboolean _glewInit_WGL_ARB_make_current_read (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglGetCurrentReadDCARB = (PFNWGLGETCURRENTREADDCARBPROC)glewGetProcAddress((const GLubyte*)"wglGetCurrentReadDCARB")) == NULL) || r; - r = ((wglMakeContextCurrentARB = (PFNWGLMAKECONTEXTCURRENTARBPROC)glewGetProcAddress((const GLubyte*)"wglMakeContextCurrentARB")) == NULL) || r; - - return r; -} - -#endif /* WGL_ARB_make_current_read */ - -#ifdef WGL_ARB_multisample - -#endif /* WGL_ARB_multisample */ - -#ifdef WGL_ARB_pbuffer - -static GLboolean _glewInit_WGL_ARB_pbuffer (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"wglCreatePbufferARB")) == NULL) || r; - r = ((wglDestroyPbufferARB = (PFNWGLDESTROYPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"wglDestroyPbufferARB")) == NULL) || r; - r = ((wglGetPbufferDCARB = (PFNWGLGETPBUFFERDCARBPROC)glewGetProcAddress((const GLubyte*)"wglGetPbufferDCARB")) == NULL) || r; - r = ((wglQueryPbufferARB = (PFNWGLQUERYPBUFFERARBPROC)glewGetProcAddress((const GLubyte*)"wglQueryPbufferARB")) == NULL) || r; - r = ((wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)glewGetProcAddress((const GLubyte*)"wglReleasePbufferDCARB")) == NULL) || r; - - return r; -} - -#endif /* WGL_ARB_pbuffer */ - -#ifdef WGL_ARB_pixel_format - -static GLboolean _glewInit_WGL_ARB_pixel_format (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)glewGetProcAddress((const GLubyte*)"wglChoosePixelFormatARB")) == NULL) || r; - r = ((wglGetPixelFormatAttribfvARB = (PFNWGLGETPIXELFORMATATTRIBFVARBPROC)glewGetProcAddress((const GLubyte*)"wglGetPixelFormatAttribfvARB")) == NULL) || r; - r = ((wglGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)glewGetProcAddress((const GLubyte*)"wglGetPixelFormatAttribivARB")) == NULL) || r; - - return r; -} - -#endif /* WGL_ARB_pixel_format */ - -#ifdef WGL_ARB_pixel_format_float - -#endif /* WGL_ARB_pixel_format_float */ - -#ifdef WGL_ARB_render_texture - -static GLboolean _glewInit_WGL_ARB_render_texture (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglBindTexImageARB = (PFNWGLBINDTEXIMAGEARBPROC)glewGetProcAddress((const GLubyte*)"wglBindTexImageARB")) == NULL) || r; - r = ((wglReleaseTexImageARB = (PFNWGLRELEASETEXIMAGEARBPROC)glewGetProcAddress((const GLubyte*)"wglReleaseTexImageARB")) == NULL) || r; - r = ((wglSetPbufferAttribARB = (PFNWGLSETPBUFFERATTRIBARBPROC)glewGetProcAddress((const GLubyte*)"wglSetPbufferAttribARB")) == NULL) || r; - - return r; -} - -#endif /* WGL_ARB_render_texture */ - -#ifdef WGL_ATI_pixel_format_float - -#endif /* WGL_ATI_pixel_format_float */ - -#ifdef WGL_ATI_render_texture_rectangle - -#endif /* WGL_ATI_render_texture_rectangle */ - -#ifdef WGL_EXT_depth_float - -#endif /* WGL_EXT_depth_float */ - -#ifdef WGL_EXT_display_color_table - -static GLboolean _glewInit_WGL_EXT_display_color_table (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglBindDisplayColorTableEXT = (PFNWGLBINDDISPLAYCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"wglBindDisplayColorTableEXT")) == NULL) || r; - r = ((wglCreateDisplayColorTableEXT = (PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"wglCreateDisplayColorTableEXT")) == NULL) || r; - r = ((wglDestroyDisplayColorTableEXT = (PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"wglDestroyDisplayColorTableEXT")) == NULL) || r; - r = ((wglLoadDisplayColorTableEXT = (PFNWGLLOADDISPLAYCOLORTABLEEXTPROC)glewGetProcAddress((const GLubyte*)"wglLoadDisplayColorTableEXT")) == NULL) || r; - - return r; -} - -#endif /* WGL_EXT_display_color_table */ - -#ifdef WGL_EXT_extensions_string - -static GLboolean _glewInit_WGL_EXT_extensions_string (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetExtensionsStringEXT")) == NULL) || r; - - return r; -} - -#endif /* WGL_EXT_extensions_string */ - -#ifdef WGL_EXT_framebuffer_sRGB - -#endif /* WGL_EXT_framebuffer_sRGB */ - -#ifdef WGL_EXT_make_current_read - -static GLboolean _glewInit_WGL_EXT_make_current_read (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglGetCurrentReadDCEXT = (PFNWGLGETCURRENTREADDCEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetCurrentReadDCEXT")) == NULL) || r; - r = ((wglMakeContextCurrentEXT = (PFNWGLMAKECONTEXTCURRENTEXTPROC)glewGetProcAddress((const GLubyte*)"wglMakeContextCurrentEXT")) == NULL) || r; - - return r; -} - -#endif /* WGL_EXT_make_current_read */ - -#ifdef WGL_EXT_multisample - -#endif /* WGL_EXT_multisample */ - -#ifdef WGL_EXT_pbuffer - -static GLboolean _glewInit_WGL_EXT_pbuffer (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglCreatePbufferEXT = (PFNWGLCREATEPBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"wglCreatePbufferEXT")) == NULL) || r; - r = ((wglDestroyPbufferEXT = (PFNWGLDESTROYPBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"wglDestroyPbufferEXT")) == NULL) || r; - r = ((wglGetPbufferDCEXT = (PFNWGLGETPBUFFERDCEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetPbufferDCEXT")) == NULL) || r; - r = ((wglQueryPbufferEXT = (PFNWGLQUERYPBUFFEREXTPROC)glewGetProcAddress((const GLubyte*)"wglQueryPbufferEXT")) == NULL) || r; - r = ((wglReleasePbufferDCEXT = (PFNWGLRELEASEPBUFFERDCEXTPROC)glewGetProcAddress((const GLubyte*)"wglReleasePbufferDCEXT")) == NULL) || r; - - return r; -} - -#endif /* WGL_EXT_pbuffer */ - -#ifdef WGL_EXT_pixel_format - -static GLboolean _glewInit_WGL_EXT_pixel_format (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglChoosePixelFormatEXT = (PFNWGLCHOOSEPIXELFORMATEXTPROC)glewGetProcAddress((const GLubyte*)"wglChoosePixelFormatEXT")) == NULL) || r; - r = ((wglGetPixelFormatAttribfvEXT = (PFNWGLGETPIXELFORMATATTRIBFVEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetPixelFormatAttribfvEXT")) == NULL) || r; - r = ((wglGetPixelFormatAttribivEXT = (PFNWGLGETPIXELFORMATATTRIBIVEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetPixelFormatAttribivEXT")) == NULL) || r; - - return r; -} - -#endif /* WGL_EXT_pixel_format */ - -#ifdef WGL_EXT_pixel_format_packed_float - -#endif /* WGL_EXT_pixel_format_packed_float */ - -#ifdef WGL_EXT_swap_control - -static GLboolean _glewInit_WGL_EXT_swap_control (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetSwapIntervalEXT")) == NULL) || r; - r = ((wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)glewGetProcAddress((const GLubyte*)"wglSwapIntervalEXT")) == NULL) || r; - - return r; -} - -#endif /* WGL_EXT_swap_control */ - -#ifdef WGL_I3D_digital_video_control - -static GLboolean _glewInit_WGL_I3D_digital_video_control (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglGetDigitalVideoParametersI3D = (PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetDigitalVideoParametersI3D")) == NULL) || r; - r = ((wglSetDigitalVideoParametersI3D = (PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC)glewGetProcAddress((const GLubyte*)"wglSetDigitalVideoParametersI3D")) == NULL) || r; - - return r; -} - -#endif /* WGL_I3D_digital_video_control */ - -#ifdef WGL_I3D_gamma - -static GLboolean _glewInit_WGL_I3D_gamma (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglGetGammaTableI3D = (PFNWGLGETGAMMATABLEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGammaTableI3D")) == NULL) || r; - r = ((wglGetGammaTableParametersI3D = (PFNWGLGETGAMMATABLEPARAMETERSI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGammaTableParametersI3D")) == NULL) || r; - r = ((wglSetGammaTableI3D = (PFNWGLSETGAMMATABLEI3DPROC)glewGetProcAddress((const GLubyte*)"wglSetGammaTableI3D")) == NULL) || r; - r = ((wglSetGammaTableParametersI3D = (PFNWGLSETGAMMATABLEPARAMETERSI3DPROC)glewGetProcAddress((const GLubyte*)"wglSetGammaTableParametersI3D")) == NULL) || r; - - return r; -} - -#endif /* WGL_I3D_gamma */ - -#ifdef WGL_I3D_genlock - -static GLboolean _glewInit_WGL_I3D_genlock (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglDisableGenlockI3D = (PFNWGLDISABLEGENLOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglDisableGenlockI3D")) == NULL) || r; - r = ((wglEnableGenlockI3D = (PFNWGLENABLEGENLOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglEnableGenlockI3D")) == NULL) || r; - r = ((wglGenlockSampleRateI3D = (PFNWGLGENLOCKSAMPLERATEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGenlockSampleRateI3D")) == NULL) || r; - r = ((wglGenlockSourceDelayI3D = (PFNWGLGENLOCKSOURCEDELAYI3DPROC)glewGetProcAddress((const GLubyte*)"wglGenlockSourceDelayI3D")) == NULL) || r; - r = ((wglGenlockSourceEdgeI3D = (PFNWGLGENLOCKSOURCEEDGEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGenlockSourceEdgeI3D")) == NULL) || r; - r = ((wglGenlockSourceI3D = (PFNWGLGENLOCKSOURCEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGenlockSourceI3D")) == NULL) || r; - r = ((wglGetGenlockSampleRateI3D = (PFNWGLGETGENLOCKSAMPLERATEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGenlockSampleRateI3D")) == NULL) || r; - r = ((wglGetGenlockSourceDelayI3D = (PFNWGLGETGENLOCKSOURCEDELAYI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGenlockSourceDelayI3D")) == NULL) || r; - r = ((wglGetGenlockSourceEdgeI3D = (PFNWGLGETGENLOCKSOURCEEDGEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGenlockSourceEdgeI3D")) == NULL) || r; - r = ((wglGetGenlockSourceI3D = (PFNWGLGETGENLOCKSOURCEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetGenlockSourceI3D")) == NULL) || r; - r = ((wglIsEnabledGenlockI3D = (PFNWGLISENABLEDGENLOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglIsEnabledGenlockI3D")) == NULL) || r; - r = ((wglQueryGenlockMaxSourceDelayI3D = (PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC)glewGetProcAddress((const GLubyte*)"wglQueryGenlockMaxSourceDelayI3D")) == NULL) || r; - - return r; -} - -#endif /* WGL_I3D_genlock */ - -#ifdef WGL_I3D_image_buffer - -static GLboolean _glewInit_WGL_I3D_image_buffer (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglAssociateImageBufferEventsI3D = (PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC)glewGetProcAddress((const GLubyte*)"wglAssociateImageBufferEventsI3D")) == NULL) || r; - r = ((wglCreateImageBufferI3D = (PFNWGLCREATEIMAGEBUFFERI3DPROC)glewGetProcAddress((const GLubyte*)"wglCreateImageBufferI3D")) == NULL) || r; - r = ((wglDestroyImageBufferI3D = (PFNWGLDESTROYIMAGEBUFFERI3DPROC)glewGetProcAddress((const GLubyte*)"wglDestroyImageBufferI3D")) == NULL) || r; - r = ((wglReleaseImageBufferEventsI3D = (PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC)glewGetProcAddress((const GLubyte*)"wglReleaseImageBufferEventsI3D")) == NULL) || r; - - return r; -} - -#endif /* WGL_I3D_image_buffer */ - -#ifdef WGL_I3D_swap_frame_lock - -static GLboolean _glewInit_WGL_I3D_swap_frame_lock (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglDisableFrameLockI3D = (PFNWGLDISABLEFRAMELOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglDisableFrameLockI3D")) == NULL) || r; - r = ((wglEnableFrameLockI3D = (PFNWGLENABLEFRAMELOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglEnableFrameLockI3D")) == NULL) || r; - r = ((wglIsEnabledFrameLockI3D = (PFNWGLISENABLEDFRAMELOCKI3DPROC)glewGetProcAddress((const GLubyte*)"wglIsEnabledFrameLockI3D")) == NULL) || r; - r = ((wglQueryFrameLockMasterI3D = (PFNWGLQUERYFRAMELOCKMASTERI3DPROC)glewGetProcAddress((const GLubyte*)"wglQueryFrameLockMasterI3D")) == NULL) || r; - - return r; -} - -#endif /* WGL_I3D_swap_frame_lock */ - -#ifdef WGL_I3D_swap_frame_usage - -static GLboolean _glewInit_WGL_I3D_swap_frame_usage (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglBeginFrameTrackingI3D = (PFNWGLBEGINFRAMETRACKINGI3DPROC)glewGetProcAddress((const GLubyte*)"wglBeginFrameTrackingI3D")) == NULL) || r; - r = ((wglEndFrameTrackingI3D = (PFNWGLENDFRAMETRACKINGI3DPROC)glewGetProcAddress((const GLubyte*)"wglEndFrameTrackingI3D")) == NULL) || r; - r = ((wglGetFrameUsageI3D = (PFNWGLGETFRAMEUSAGEI3DPROC)glewGetProcAddress((const GLubyte*)"wglGetFrameUsageI3D")) == NULL) || r; - r = ((wglQueryFrameTrackingI3D = (PFNWGLQUERYFRAMETRACKINGI3DPROC)glewGetProcAddress((const GLubyte*)"wglQueryFrameTrackingI3D")) == NULL) || r; - - return r; -} - -#endif /* WGL_I3D_swap_frame_usage */ - -#ifdef WGL_NV_float_buffer - -#endif /* WGL_NV_float_buffer */ - -#ifdef WGL_NV_gpu_affinity - -static GLboolean _glewInit_WGL_NV_gpu_affinity (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglCreateAffinityDCNV = (PFNWGLCREATEAFFINITYDCNVPROC)glewGetProcAddress((const GLubyte*)"wglCreateAffinityDCNV")) == NULL) || r; - r = ((wglDeleteDCNV = (PFNWGLDELETEDCNVPROC)glewGetProcAddress((const GLubyte*)"wglDeleteDCNV")) == NULL) || r; - r = ((wglEnumGpuDevicesNV = (PFNWGLENUMGPUDEVICESNVPROC)glewGetProcAddress((const GLubyte*)"wglEnumGpuDevicesNV")) == NULL) || r; - r = ((wglEnumGpusFromAffinityDCNV = (PFNWGLENUMGPUSFROMAFFINITYDCNVPROC)glewGetProcAddress((const GLubyte*)"wglEnumGpusFromAffinityDCNV")) == NULL) || r; - r = ((wglEnumGpusNV = (PFNWGLENUMGPUSNVPROC)glewGetProcAddress((const GLubyte*)"wglEnumGpusNV")) == NULL) || r; - - return r; -} - -#endif /* WGL_NV_gpu_affinity */ - -#ifdef WGL_NV_present_video - -static GLboolean _glewInit_WGL_NV_present_video (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglBindVideoDeviceNV = (PFNWGLBINDVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"wglBindVideoDeviceNV")) == NULL) || r; - r = ((wglEnumerateVideoDevicesNV = (PFNWGLENUMERATEVIDEODEVICESNVPROC)glewGetProcAddress((const GLubyte*)"wglEnumerateVideoDevicesNV")) == NULL) || r; - r = ((wglQueryCurrentContextNV = (PFNWGLQUERYCURRENTCONTEXTNVPROC)glewGetProcAddress((const GLubyte*)"wglQueryCurrentContextNV")) == NULL) || r; - - return r; -} - -#endif /* WGL_NV_present_video */ - -#ifdef WGL_NV_render_depth_texture - -#endif /* WGL_NV_render_depth_texture */ - -#ifdef WGL_NV_render_texture_rectangle - -#endif /* WGL_NV_render_texture_rectangle */ - -#ifdef WGL_NV_swap_group - -static GLboolean _glewInit_WGL_NV_swap_group (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglBindSwapBarrierNV = (PFNWGLBINDSWAPBARRIERNVPROC)glewGetProcAddress((const GLubyte*)"wglBindSwapBarrierNV")) == NULL) || r; - r = ((wglJoinSwapGroupNV = (PFNWGLJOINSWAPGROUPNVPROC)glewGetProcAddress((const GLubyte*)"wglJoinSwapGroupNV")) == NULL) || r; - r = ((wglQueryFrameCountNV = (PFNWGLQUERYFRAMECOUNTNVPROC)glewGetProcAddress((const GLubyte*)"wglQueryFrameCountNV")) == NULL) || r; - r = ((wglQueryMaxSwapGroupsNV = (PFNWGLQUERYMAXSWAPGROUPSNVPROC)glewGetProcAddress((const GLubyte*)"wglQueryMaxSwapGroupsNV")) == NULL) || r; - r = ((wglQuerySwapGroupNV = (PFNWGLQUERYSWAPGROUPNVPROC)glewGetProcAddress((const GLubyte*)"wglQuerySwapGroupNV")) == NULL) || r; - r = ((wglResetFrameCountNV = (PFNWGLRESETFRAMECOUNTNVPROC)glewGetProcAddress((const GLubyte*)"wglResetFrameCountNV")) == NULL) || r; - - return r; -} - -#endif /* WGL_NV_swap_group */ - -#ifdef WGL_NV_vertex_array_range - -static GLboolean _glewInit_WGL_NV_vertex_array_range (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglAllocateMemoryNV = (PFNWGLALLOCATEMEMORYNVPROC)glewGetProcAddress((const GLubyte*)"wglAllocateMemoryNV")) == NULL) || r; - r = ((wglFreeMemoryNV = (PFNWGLFREEMEMORYNVPROC)glewGetProcAddress((const GLubyte*)"wglFreeMemoryNV")) == NULL) || r; - - return r; -} - -#endif /* WGL_NV_vertex_array_range */ - -#ifdef WGL_NV_video_output - -static GLboolean _glewInit_WGL_NV_video_output (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglBindVideoImageNV = (PFNWGLBINDVIDEOIMAGENVPROC)glewGetProcAddress((const GLubyte*)"wglBindVideoImageNV")) == NULL) || r; - r = ((wglGetVideoDeviceNV = (PFNWGLGETVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"wglGetVideoDeviceNV")) == NULL) || r; - r = ((wglGetVideoInfoNV = (PFNWGLGETVIDEOINFONVPROC)glewGetProcAddress((const GLubyte*)"wglGetVideoInfoNV")) == NULL) || r; - r = ((wglReleaseVideoDeviceNV = (PFNWGLRELEASEVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"wglReleaseVideoDeviceNV")) == NULL) || r; - r = ((wglReleaseVideoImageNV = (PFNWGLRELEASEVIDEOIMAGENVPROC)glewGetProcAddress((const GLubyte*)"wglReleaseVideoImageNV")) == NULL) || r; - r = ((wglSendPbufferToVideoNV = (PFNWGLSENDPBUFFERTOVIDEONVPROC)glewGetProcAddress((const GLubyte*)"wglSendPbufferToVideoNV")) == NULL) || r; - - return r; -} - -#endif /* WGL_NV_video_output */ - -#ifdef WGL_OML_sync_control - -static GLboolean _glewInit_WGL_OML_sync_control (WGLEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((wglGetMscRateOML = (PFNWGLGETMSCRATEOMLPROC)glewGetProcAddress((const GLubyte*)"wglGetMscRateOML")) == NULL) || r; - r = ((wglGetSyncValuesOML = (PFNWGLGETSYNCVALUESOMLPROC)glewGetProcAddress((const GLubyte*)"wglGetSyncValuesOML")) == NULL) || r; - r = ((wglSwapBuffersMscOML = (PFNWGLSWAPBUFFERSMSCOMLPROC)glewGetProcAddress((const GLubyte*)"wglSwapBuffersMscOML")) == NULL) || r; - r = ((wglSwapLayerBuffersMscOML = (PFNWGLSWAPLAYERBUFFERSMSCOMLPROC)glewGetProcAddress((const GLubyte*)"wglSwapLayerBuffersMscOML")) == NULL) || r; - r = ((wglWaitForMscOML = (PFNWGLWAITFORMSCOMLPROC)glewGetProcAddress((const GLubyte*)"wglWaitForMscOML")) == NULL) || r; - r = ((wglWaitForSbcOML = (PFNWGLWAITFORSBCOMLPROC)glewGetProcAddress((const GLubyte*)"wglWaitForSbcOML")) == NULL) || r; - - return r; -} - -#endif /* WGL_OML_sync_control */ - -/* ------------------------------------------------------------------------- */ - -static PFNWGLGETEXTENSIONSSTRINGARBPROC _wglewGetExtensionsStringARB = NULL; -static PFNWGLGETEXTENSIONSSTRINGEXTPROC _wglewGetExtensionsStringEXT = NULL; - -GLboolean wglewGetExtension (const char* name) -{ - GLubyte* p; - GLubyte* end; - GLuint len = _glewStrLen((const GLubyte*)name); - if (_wglewGetExtensionsStringARB == NULL) - if (_wglewGetExtensionsStringEXT == NULL) - return GL_FALSE; - else - p = (GLubyte*)_wglewGetExtensionsStringEXT(); - else - p = (GLubyte*)_wglewGetExtensionsStringARB(wglGetCurrentDC()); - if (0 == p) return GL_FALSE; - end = p + _glewStrLen(p); - while (p < end) - { - GLuint n = _glewStrCLen(p, ' '); - if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE; - p += n+1; - } - return GL_FALSE; -} - -GLenum wglewContextInit (WGLEW_CONTEXT_ARG_DEF_LIST) -{ - GLboolean crippled; - /* find wgl extension string query functions */ - _wglewGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)glewGetProcAddress((const GLubyte*)"wglGetExtensionsStringARB"); - _wglewGetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)glewGetProcAddress((const GLubyte*)"wglGetExtensionsStringEXT"); - /* initialize extensions */ - crippled = _wglewGetExtensionsStringARB == NULL && _wglewGetExtensionsStringEXT == NULL; -#ifdef WGL_3DFX_multisample - CONST_CAST(WGLEW_3DFX_multisample) = wglewGetExtension("WGL_3DFX_multisample"); -#endif /* WGL_3DFX_multisample */ -#ifdef WGL_3DL_stereo_control - CONST_CAST(WGLEW_3DL_stereo_control) = wglewGetExtension("WGL_3DL_stereo_control"); - if (glewExperimental || WGLEW_3DL_stereo_control|| crippled) CONST_CAST(WGLEW_3DL_stereo_control)= !_glewInit_WGL_3DL_stereo_control(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_3DL_stereo_control */ -#ifdef WGL_ARB_buffer_region - CONST_CAST(WGLEW_ARB_buffer_region) = wglewGetExtension("WGL_ARB_buffer_region"); - if (glewExperimental || WGLEW_ARB_buffer_region|| crippled) CONST_CAST(WGLEW_ARB_buffer_region)= !_glewInit_WGL_ARB_buffer_region(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_ARB_buffer_region */ -#ifdef WGL_ARB_create_context - CONST_CAST(WGLEW_ARB_create_context) = wglewGetExtension("WGL_ARB_create_context"); - if (glewExperimental || WGLEW_ARB_create_context|| crippled) CONST_CAST(WGLEW_ARB_create_context)= !_glewInit_WGL_ARB_create_context(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_ARB_create_context */ -#ifdef WGL_ARB_extensions_string - CONST_CAST(WGLEW_ARB_extensions_string) = wglewGetExtension("WGL_ARB_extensions_string"); - if (glewExperimental || WGLEW_ARB_extensions_string|| crippled) CONST_CAST(WGLEW_ARB_extensions_string)= !_glewInit_WGL_ARB_extensions_string(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_ARB_extensions_string */ -#ifdef WGL_ARB_framebuffer_sRGB - CONST_CAST(WGLEW_ARB_framebuffer_sRGB) = wglewGetExtension("WGL_ARB_framebuffer_sRGB"); -#endif /* WGL_ARB_framebuffer_sRGB */ -#ifdef WGL_ARB_make_current_read - CONST_CAST(WGLEW_ARB_make_current_read) = wglewGetExtension("WGL_ARB_make_current_read"); - if (glewExperimental || WGLEW_ARB_make_current_read|| crippled) CONST_CAST(WGLEW_ARB_make_current_read)= !_glewInit_WGL_ARB_make_current_read(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_ARB_make_current_read */ -#ifdef WGL_ARB_multisample - CONST_CAST(WGLEW_ARB_multisample) = wglewGetExtension("WGL_ARB_multisample"); -#endif /* WGL_ARB_multisample */ -#ifdef WGL_ARB_pbuffer - CONST_CAST(WGLEW_ARB_pbuffer) = wglewGetExtension("WGL_ARB_pbuffer"); - if (glewExperimental || WGLEW_ARB_pbuffer|| crippled) CONST_CAST(WGLEW_ARB_pbuffer)= !_glewInit_WGL_ARB_pbuffer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_ARB_pbuffer */ -#ifdef WGL_ARB_pixel_format - CONST_CAST(WGLEW_ARB_pixel_format) = wglewGetExtension("WGL_ARB_pixel_format"); - if (glewExperimental || WGLEW_ARB_pixel_format|| crippled) CONST_CAST(WGLEW_ARB_pixel_format)= !_glewInit_WGL_ARB_pixel_format(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_ARB_pixel_format */ -#ifdef WGL_ARB_pixel_format_float - CONST_CAST(WGLEW_ARB_pixel_format_float) = wglewGetExtension("WGL_ARB_pixel_format_float"); -#endif /* WGL_ARB_pixel_format_float */ -#ifdef WGL_ARB_render_texture - CONST_CAST(WGLEW_ARB_render_texture) = wglewGetExtension("WGL_ARB_render_texture"); - if (glewExperimental || WGLEW_ARB_render_texture|| crippled) CONST_CAST(WGLEW_ARB_render_texture)= !_glewInit_WGL_ARB_render_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_ARB_render_texture */ -#ifdef WGL_ATI_pixel_format_float - CONST_CAST(WGLEW_ATI_pixel_format_float) = wglewGetExtension("WGL_ATI_pixel_format_float"); -#endif /* WGL_ATI_pixel_format_float */ -#ifdef WGL_ATI_render_texture_rectangle - CONST_CAST(WGLEW_ATI_render_texture_rectangle) = wglewGetExtension("WGL_ATI_render_texture_rectangle"); -#endif /* WGL_ATI_render_texture_rectangle */ -#ifdef WGL_EXT_depth_float - CONST_CAST(WGLEW_EXT_depth_float) = wglewGetExtension("WGL_EXT_depth_float"); -#endif /* WGL_EXT_depth_float */ -#ifdef WGL_EXT_display_color_table - CONST_CAST(WGLEW_EXT_display_color_table) = wglewGetExtension("WGL_EXT_display_color_table"); - if (glewExperimental || WGLEW_EXT_display_color_table|| crippled) CONST_CAST(WGLEW_EXT_display_color_table)= !_glewInit_WGL_EXT_display_color_table(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_EXT_display_color_table */ -#ifdef WGL_EXT_extensions_string - CONST_CAST(WGLEW_EXT_extensions_string) = wglewGetExtension("WGL_EXT_extensions_string"); - if (glewExperimental || WGLEW_EXT_extensions_string|| crippled) CONST_CAST(WGLEW_EXT_extensions_string)= !_glewInit_WGL_EXT_extensions_string(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_EXT_extensions_string */ -#ifdef WGL_EXT_framebuffer_sRGB - CONST_CAST(WGLEW_EXT_framebuffer_sRGB) = wglewGetExtension("WGL_EXT_framebuffer_sRGB"); -#endif /* WGL_EXT_framebuffer_sRGB */ -#ifdef WGL_EXT_make_current_read - CONST_CAST(WGLEW_EXT_make_current_read) = wglewGetExtension("WGL_EXT_make_current_read"); - if (glewExperimental || WGLEW_EXT_make_current_read|| crippled) CONST_CAST(WGLEW_EXT_make_current_read)= !_glewInit_WGL_EXT_make_current_read(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_EXT_make_current_read */ -#ifdef WGL_EXT_multisample - CONST_CAST(WGLEW_EXT_multisample) = wglewGetExtension("WGL_EXT_multisample"); -#endif /* WGL_EXT_multisample */ -#ifdef WGL_EXT_pbuffer - CONST_CAST(WGLEW_EXT_pbuffer) = wglewGetExtension("WGL_EXT_pbuffer"); - if (glewExperimental || WGLEW_EXT_pbuffer|| crippled) CONST_CAST(WGLEW_EXT_pbuffer)= !_glewInit_WGL_EXT_pbuffer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_EXT_pbuffer */ -#ifdef WGL_EXT_pixel_format - CONST_CAST(WGLEW_EXT_pixel_format) = wglewGetExtension("WGL_EXT_pixel_format"); - if (glewExperimental || WGLEW_EXT_pixel_format|| crippled) CONST_CAST(WGLEW_EXT_pixel_format)= !_glewInit_WGL_EXT_pixel_format(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_EXT_pixel_format */ -#ifdef WGL_EXT_pixel_format_packed_float - CONST_CAST(WGLEW_EXT_pixel_format_packed_float) = wglewGetExtension("WGL_EXT_pixel_format_packed_float"); -#endif /* WGL_EXT_pixel_format_packed_float */ -#ifdef WGL_EXT_swap_control - CONST_CAST(WGLEW_EXT_swap_control) = wglewGetExtension("WGL_EXT_swap_control"); - if (glewExperimental || WGLEW_EXT_swap_control|| crippled) CONST_CAST(WGLEW_EXT_swap_control)= !_glewInit_WGL_EXT_swap_control(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_EXT_swap_control */ -#ifdef WGL_I3D_digital_video_control - CONST_CAST(WGLEW_I3D_digital_video_control) = wglewGetExtension("WGL_I3D_digital_video_control"); - if (glewExperimental || WGLEW_I3D_digital_video_control|| crippled) CONST_CAST(WGLEW_I3D_digital_video_control)= !_glewInit_WGL_I3D_digital_video_control(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_I3D_digital_video_control */ -#ifdef WGL_I3D_gamma - CONST_CAST(WGLEW_I3D_gamma) = wglewGetExtension("WGL_I3D_gamma"); - if (glewExperimental || WGLEW_I3D_gamma|| crippled) CONST_CAST(WGLEW_I3D_gamma)= !_glewInit_WGL_I3D_gamma(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_I3D_gamma */ -#ifdef WGL_I3D_genlock - CONST_CAST(WGLEW_I3D_genlock) = wglewGetExtension("WGL_I3D_genlock"); - if (glewExperimental || WGLEW_I3D_genlock|| crippled) CONST_CAST(WGLEW_I3D_genlock)= !_glewInit_WGL_I3D_genlock(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_I3D_genlock */ -#ifdef WGL_I3D_image_buffer - CONST_CAST(WGLEW_I3D_image_buffer) = wglewGetExtension("WGL_I3D_image_buffer"); - if (glewExperimental || WGLEW_I3D_image_buffer|| crippled) CONST_CAST(WGLEW_I3D_image_buffer)= !_glewInit_WGL_I3D_image_buffer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_I3D_image_buffer */ -#ifdef WGL_I3D_swap_frame_lock - CONST_CAST(WGLEW_I3D_swap_frame_lock) = wglewGetExtension("WGL_I3D_swap_frame_lock"); - if (glewExperimental || WGLEW_I3D_swap_frame_lock|| crippled) CONST_CAST(WGLEW_I3D_swap_frame_lock)= !_glewInit_WGL_I3D_swap_frame_lock(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_I3D_swap_frame_lock */ -#ifdef WGL_I3D_swap_frame_usage - CONST_CAST(WGLEW_I3D_swap_frame_usage) = wglewGetExtension("WGL_I3D_swap_frame_usage"); - if (glewExperimental || WGLEW_I3D_swap_frame_usage|| crippled) CONST_CAST(WGLEW_I3D_swap_frame_usage)= !_glewInit_WGL_I3D_swap_frame_usage(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_I3D_swap_frame_usage */ -#ifdef WGL_NV_float_buffer - CONST_CAST(WGLEW_NV_float_buffer) = wglewGetExtension("WGL_NV_float_buffer"); -#endif /* WGL_NV_float_buffer */ -#ifdef WGL_NV_gpu_affinity - CONST_CAST(WGLEW_NV_gpu_affinity) = wglewGetExtension("WGL_NV_gpu_affinity"); - if (glewExperimental || WGLEW_NV_gpu_affinity|| crippled) CONST_CAST(WGLEW_NV_gpu_affinity)= !_glewInit_WGL_NV_gpu_affinity(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_NV_gpu_affinity */ -#ifdef WGL_NV_present_video - CONST_CAST(WGLEW_NV_present_video) = wglewGetExtension("WGL_NV_present_video"); - if (glewExperimental || WGLEW_NV_present_video|| crippled) CONST_CAST(WGLEW_NV_present_video)= !_glewInit_WGL_NV_present_video(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_NV_present_video */ -#ifdef WGL_NV_render_depth_texture - CONST_CAST(WGLEW_NV_render_depth_texture) = wglewGetExtension("WGL_NV_render_depth_texture"); -#endif /* WGL_NV_render_depth_texture */ -#ifdef WGL_NV_render_texture_rectangle - CONST_CAST(WGLEW_NV_render_texture_rectangle) = wglewGetExtension("WGL_NV_render_texture_rectangle"); -#endif /* WGL_NV_render_texture_rectangle */ -#ifdef WGL_NV_swap_group - CONST_CAST(WGLEW_NV_swap_group) = wglewGetExtension("WGL_NV_swap_group"); - if (glewExperimental || WGLEW_NV_swap_group|| crippled) CONST_CAST(WGLEW_NV_swap_group)= !_glewInit_WGL_NV_swap_group(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_NV_swap_group */ -#ifdef WGL_NV_vertex_array_range - CONST_CAST(WGLEW_NV_vertex_array_range) = wglewGetExtension("WGL_NV_vertex_array_range"); - if (glewExperimental || WGLEW_NV_vertex_array_range|| crippled) CONST_CAST(WGLEW_NV_vertex_array_range)= !_glewInit_WGL_NV_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_NV_vertex_array_range */ -#ifdef WGL_NV_video_output - CONST_CAST(WGLEW_NV_video_output) = wglewGetExtension("WGL_NV_video_output"); - if (glewExperimental || WGLEW_NV_video_output|| crippled) CONST_CAST(WGLEW_NV_video_output)= !_glewInit_WGL_NV_video_output(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_NV_video_output */ -#ifdef WGL_OML_sync_control - CONST_CAST(WGLEW_OML_sync_control) = wglewGetExtension("WGL_OML_sync_control"); - if (glewExperimental || WGLEW_OML_sync_control|| crippled) CONST_CAST(WGLEW_OML_sync_control)= !_glewInit_WGL_OML_sync_control(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* WGL_OML_sync_control */ - - return GLEW_OK; -} - -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) - -PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay = NULL; - -PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig = NULL; -PFNGLXCREATENEWCONTEXTPROC __glewXCreateNewContext = NULL; -PFNGLXCREATEPBUFFERPROC __glewXCreatePbuffer = NULL; -PFNGLXCREATEPIXMAPPROC __glewXCreatePixmap = NULL; -PFNGLXCREATEWINDOWPROC __glewXCreateWindow = NULL; -PFNGLXDESTROYPBUFFERPROC __glewXDestroyPbuffer = NULL; -PFNGLXDESTROYPIXMAPPROC __glewXDestroyPixmap = NULL; -PFNGLXDESTROYWINDOWPROC __glewXDestroyWindow = NULL; -PFNGLXGETCURRENTREADDRAWABLEPROC __glewXGetCurrentReadDrawable = NULL; -PFNGLXGETFBCONFIGATTRIBPROC __glewXGetFBConfigAttrib = NULL; -PFNGLXGETFBCONFIGSPROC __glewXGetFBConfigs = NULL; -PFNGLXGETSELECTEDEVENTPROC __glewXGetSelectedEvent = NULL; -PFNGLXGETVISUALFROMFBCONFIGPROC __glewXGetVisualFromFBConfig = NULL; -PFNGLXMAKECONTEXTCURRENTPROC __glewXMakeContextCurrent = NULL; -PFNGLXQUERYCONTEXTPROC __glewXQueryContext = NULL; -PFNGLXQUERYDRAWABLEPROC __glewXQueryDrawable = NULL; -PFNGLXSELECTEVENTPROC __glewXSelectEvent = NULL; - -PFNGLXCREATECONTEXTATTRIBSARBPROC __glewXCreateContextAttribsARB = NULL; - -PFNGLXBINDTEXIMAGEATIPROC __glewXBindTexImageATI = NULL; -PFNGLXDRAWABLEATTRIBATIPROC __glewXDrawableAttribATI = NULL; -PFNGLXRELEASETEXIMAGEATIPROC __glewXReleaseTexImageATI = NULL; - -PFNGLXFREECONTEXTEXTPROC __glewXFreeContextEXT = NULL; -PFNGLXGETCONTEXTIDEXTPROC __glewXGetContextIDEXT = NULL; -PFNGLXIMPORTCONTEXTEXTPROC __glewXImportContextEXT = NULL; -PFNGLXQUERYCONTEXTINFOEXTPROC __glewXQueryContextInfoEXT = NULL; - -PFNGLXBINDTEXIMAGEEXTPROC __glewXBindTexImageEXT = NULL; -PFNGLXRELEASETEXIMAGEEXTPROC __glewXReleaseTexImageEXT = NULL; - -PFNGLXGETAGPOFFSETMESAPROC __glewXGetAGPOffsetMESA = NULL; - -PFNGLXCOPYSUBBUFFERMESAPROC __glewXCopySubBufferMESA = NULL; - -PFNGLXCREATEGLXPIXMAPMESAPROC __glewXCreateGLXPixmapMESA = NULL; - -PFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA = NULL; - -PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA = NULL; - -PFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV = NULL; -PFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV = NULL; - -PFNGLXBINDSWAPBARRIERNVPROC __glewXBindSwapBarrierNV = NULL; -PFNGLXJOINSWAPGROUPNVPROC __glewXJoinSwapGroupNV = NULL; -PFNGLXQUERYFRAMECOUNTNVPROC __glewXQueryFrameCountNV = NULL; -PFNGLXQUERYMAXSWAPGROUPSNVPROC __glewXQueryMaxSwapGroupsNV = NULL; -PFNGLXQUERYSWAPGROUPNVPROC __glewXQuerySwapGroupNV = NULL; -PFNGLXRESETFRAMECOUNTNVPROC __glewXResetFrameCountNV = NULL; - -PFNGLXALLOCATEMEMORYNVPROC __glewXAllocateMemoryNV = NULL; -PFNGLXFREEMEMORYNVPROC __glewXFreeMemoryNV = NULL; - -PFNGLXBINDVIDEOIMAGENVPROC __glewXBindVideoImageNV = NULL; -PFNGLXGETVIDEODEVICENVPROC __glewXGetVideoDeviceNV = NULL; -PFNGLXGETVIDEOINFONVPROC __glewXGetVideoInfoNV = NULL; -PFNGLXRELEASEVIDEODEVICENVPROC __glewXReleaseVideoDeviceNV = NULL; -PFNGLXRELEASEVIDEOIMAGENVPROC __glewXReleaseVideoImageNV = NULL; -PFNGLXSENDPBUFFERTOVIDEONVPROC __glewXSendPbufferToVideoNV = NULL; - -#ifdef GLX_OML_sync_control -PFNGLXGETMSCRATEOMLPROC __glewXGetMscRateOML = NULL; -PFNGLXGETSYNCVALUESOMLPROC __glewXGetSyncValuesOML = NULL; -PFNGLXSWAPBUFFERSMSCOMLPROC __glewXSwapBuffersMscOML = NULL; -PFNGLXWAITFORMSCOMLPROC __glewXWaitForMscOML = NULL; -PFNGLXWAITFORSBCOMLPROC __glewXWaitForSbcOML = NULL; -#endif - -PFNGLXCHOOSEFBCONFIGSGIXPROC __glewXChooseFBConfigSGIX = NULL; -PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC __glewXCreateContextWithConfigSGIX = NULL; -PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC __glewXCreateGLXPixmapWithConfigSGIX = NULL; -PFNGLXGETFBCONFIGATTRIBSGIXPROC __glewXGetFBConfigAttribSGIX = NULL; -PFNGLXGETFBCONFIGFROMVISUALSGIXPROC __glewXGetFBConfigFromVisualSGIX = NULL; -PFNGLXGETVISUALFROMFBCONFIGSGIXPROC __glewXGetVisualFromFBConfigSGIX = NULL; - -PFNGLXBINDHYPERPIPESGIXPROC __glewXBindHyperpipeSGIX = NULL; -PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC __glewXDestroyHyperpipeConfigSGIX = NULL; -PFNGLXHYPERPIPEATTRIBSGIXPROC __glewXHyperpipeAttribSGIX = NULL; -PFNGLXHYPERPIPECONFIGSGIXPROC __glewXHyperpipeConfigSGIX = NULL; -PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC __glewXQueryHyperpipeAttribSGIX = NULL; -PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC __glewXQueryHyperpipeBestAttribSGIX = NULL; -PFNGLXQUERYHYPERPIPECONFIGSGIXPROC __glewXQueryHyperpipeConfigSGIX = NULL; -PFNGLXQUERYHYPERPIPENETWORKSGIXPROC __glewXQueryHyperpipeNetworkSGIX = NULL; - -PFNGLXCREATEGLXPBUFFERSGIXPROC __glewXCreateGLXPbufferSGIX = NULL; -PFNGLXDESTROYGLXPBUFFERSGIXPROC __glewXDestroyGLXPbufferSGIX = NULL; -PFNGLXGETSELECTEDEVENTSGIXPROC __glewXGetSelectedEventSGIX = NULL; -PFNGLXQUERYGLXPBUFFERSGIXPROC __glewXQueryGLXPbufferSGIX = NULL; -PFNGLXSELECTEVENTSGIXPROC __glewXSelectEventSGIX = NULL; - -PFNGLXBINDSWAPBARRIERSGIXPROC __glewXBindSwapBarrierSGIX = NULL; -PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC __glewXQueryMaxSwapBarriersSGIX = NULL; - -PFNGLXJOINSWAPGROUPSGIXPROC __glewXJoinSwapGroupSGIX = NULL; - -PFNGLXBINDCHANNELTOWINDOWSGIXPROC __glewXBindChannelToWindowSGIX = NULL; -PFNGLXCHANNELRECTSGIXPROC __glewXChannelRectSGIX = NULL; -PFNGLXCHANNELRECTSYNCSGIXPROC __glewXChannelRectSyncSGIX = NULL; -PFNGLXQUERYCHANNELDELTASSGIXPROC __glewXQueryChannelDeltasSGIX = NULL; -PFNGLXQUERYCHANNELRECTSGIXPROC __glewXQueryChannelRectSGIX = NULL; - -PFNGLXCUSHIONSGIPROC __glewXCushionSGI = NULL; - -PFNGLXGETCURRENTREADDRAWABLESGIPROC __glewXGetCurrentReadDrawableSGI = NULL; -PFNGLXMAKECURRENTREADSGIPROC __glewXMakeCurrentReadSGI = NULL; - -PFNGLXSWAPINTERVALSGIPROC __glewXSwapIntervalSGI = NULL; - -PFNGLXGETVIDEOSYNCSGIPROC __glewXGetVideoSyncSGI = NULL; -PFNGLXWAITVIDEOSYNCSGIPROC __glewXWaitVideoSyncSGI = NULL; - -PFNGLXGETTRANSPARENTINDEXSUNPROC __glewXGetTransparentIndexSUN = NULL; - -PFNGLXGETVIDEORESIZESUNPROC __glewXGetVideoResizeSUN = NULL; -PFNGLXVIDEORESIZESUNPROC __glewXVideoResizeSUN = NULL; - -#if !defined(GLEW_MX) - -GLboolean __GLXEW_VERSION_1_0 = GL_FALSE; -GLboolean __GLXEW_VERSION_1_1 = GL_FALSE; -GLboolean __GLXEW_VERSION_1_2 = GL_FALSE; -GLboolean __GLXEW_VERSION_1_3 = GL_FALSE; -GLboolean __GLXEW_VERSION_1_4 = GL_FALSE; -GLboolean __GLXEW_3DFX_multisample = GL_FALSE; -GLboolean __GLXEW_ARB_create_context = GL_FALSE; -GLboolean __GLXEW_ARB_fbconfig_float = GL_FALSE; -GLboolean __GLXEW_ARB_framebuffer_sRGB = GL_FALSE; -GLboolean __GLXEW_ARB_get_proc_address = GL_FALSE; -GLboolean __GLXEW_ARB_multisample = GL_FALSE; -GLboolean __GLXEW_ATI_pixel_format_float = GL_FALSE; -GLboolean __GLXEW_ATI_render_texture = GL_FALSE; -GLboolean __GLXEW_EXT_fbconfig_packed_float = GL_FALSE; -GLboolean __GLXEW_EXT_framebuffer_sRGB = GL_FALSE; -GLboolean __GLXEW_EXT_import_context = GL_FALSE; -GLboolean __GLXEW_EXT_scene_marker = GL_FALSE; -GLboolean __GLXEW_EXT_texture_from_pixmap = GL_FALSE; -GLboolean __GLXEW_EXT_visual_info = GL_FALSE; -GLboolean __GLXEW_EXT_visual_rating = GL_FALSE; -GLboolean __GLXEW_MESA_agp_offset = GL_FALSE; -GLboolean __GLXEW_MESA_copy_sub_buffer = GL_FALSE; -GLboolean __GLXEW_MESA_pixmap_colormap = GL_FALSE; -GLboolean __GLXEW_MESA_release_buffers = GL_FALSE; -GLboolean __GLXEW_MESA_set_3dfx_mode = GL_FALSE; -GLboolean __GLXEW_NV_float_buffer = GL_FALSE; -GLboolean __GLXEW_NV_present_video = GL_FALSE; -GLboolean __GLXEW_NV_swap_group = GL_FALSE; -GLboolean __GLXEW_NV_vertex_array_range = GL_FALSE; -GLboolean __GLXEW_NV_video_output = GL_FALSE; -GLboolean __GLXEW_OML_swap_method = GL_FALSE; -#ifdef GLX_OML_sync_control -GLboolean __GLXEW_OML_sync_control = GL_FALSE; -#endif -GLboolean __GLXEW_SGIS_blended_overlay = GL_FALSE; -GLboolean __GLXEW_SGIS_color_range = GL_FALSE; -GLboolean __GLXEW_SGIS_multisample = GL_FALSE; -GLboolean __GLXEW_SGIS_shared_multisample = GL_FALSE; -GLboolean __GLXEW_SGIX_fbconfig = GL_FALSE; -GLboolean __GLXEW_SGIX_hyperpipe = GL_FALSE; -GLboolean __GLXEW_SGIX_pbuffer = GL_FALSE; -GLboolean __GLXEW_SGIX_swap_barrier = GL_FALSE; -GLboolean __GLXEW_SGIX_swap_group = GL_FALSE; -GLboolean __GLXEW_SGIX_video_resize = GL_FALSE; -GLboolean __GLXEW_SGIX_visual_select_group = GL_FALSE; -GLboolean __GLXEW_SGI_cushion = GL_FALSE; -GLboolean __GLXEW_SGI_make_current_read = GL_FALSE; -GLboolean __GLXEW_SGI_swap_control = GL_FALSE; -GLboolean __GLXEW_SGI_video_sync = GL_FALSE; -GLboolean __GLXEW_SUN_get_transparent_index = GL_FALSE; -GLboolean __GLXEW_SUN_video_resize = GL_FALSE; - -#endif /* !GLEW_MX */ - -#ifdef GLX_VERSION_1_2 - -static GLboolean _glewInit_GLX_VERSION_1_2 (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXGetCurrentDisplay = (PFNGLXGETCURRENTDISPLAYPROC)glewGetProcAddress((const GLubyte*)"glXGetCurrentDisplay")) == NULL) || r; - - return r; -} - -#endif /* GLX_VERSION_1_2 */ - -#ifdef GLX_VERSION_1_3 - -static GLboolean _glewInit_GLX_VERSION_1_3 (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC)glewGetProcAddress((const GLubyte*)"glXChooseFBConfig")) == NULL) || r; - r = ((glXCreateNewContext = (PFNGLXCREATENEWCONTEXTPROC)glewGetProcAddress((const GLubyte*)"glXCreateNewContext")) == NULL) || r; - r = ((glXCreatePbuffer = (PFNGLXCREATEPBUFFERPROC)glewGetProcAddress((const GLubyte*)"glXCreatePbuffer")) == NULL) || r; - r = ((glXCreatePixmap = (PFNGLXCREATEPIXMAPPROC)glewGetProcAddress((const GLubyte*)"glXCreatePixmap")) == NULL) || r; - r = ((glXCreateWindow = (PFNGLXCREATEWINDOWPROC)glewGetProcAddress((const GLubyte*)"glXCreateWindow")) == NULL) || r; - r = ((glXDestroyPbuffer = (PFNGLXDESTROYPBUFFERPROC)glewGetProcAddress((const GLubyte*)"glXDestroyPbuffer")) == NULL) || r; - r = ((glXDestroyPixmap = (PFNGLXDESTROYPIXMAPPROC)glewGetProcAddress((const GLubyte*)"glXDestroyPixmap")) == NULL) || r; - r = ((glXDestroyWindow = (PFNGLXDESTROYWINDOWPROC)glewGetProcAddress((const GLubyte*)"glXDestroyWindow")) == NULL) || r; - r = ((glXGetCurrentReadDrawable = (PFNGLXGETCURRENTREADDRAWABLEPROC)glewGetProcAddress((const GLubyte*)"glXGetCurrentReadDrawable")) == NULL) || r; - r = ((glXGetFBConfigAttrib = (PFNGLXGETFBCONFIGATTRIBPROC)glewGetProcAddress((const GLubyte*)"glXGetFBConfigAttrib")) == NULL) || r; - r = ((glXGetFBConfigs = (PFNGLXGETFBCONFIGSPROC)glewGetProcAddress((const GLubyte*)"glXGetFBConfigs")) == NULL) || r; - r = ((glXGetSelectedEvent = (PFNGLXGETSELECTEDEVENTPROC)glewGetProcAddress((const GLubyte*)"glXGetSelectedEvent")) == NULL) || r; - r = ((glXGetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)glewGetProcAddress((const GLubyte*)"glXGetVisualFromFBConfig")) == NULL) || r; - r = ((glXMakeContextCurrent = (PFNGLXMAKECONTEXTCURRENTPROC)glewGetProcAddress((const GLubyte*)"glXMakeContextCurrent")) == NULL) || r; - r = ((glXQueryContext = (PFNGLXQUERYCONTEXTPROC)glewGetProcAddress((const GLubyte*)"glXQueryContext")) == NULL) || r; - r = ((glXQueryDrawable = (PFNGLXQUERYDRAWABLEPROC)glewGetProcAddress((const GLubyte*)"glXQueryDrawable")) == NULL) || r; - r = ((glXSelectEvent = (PFNGLXSELECTEVENTPROC)glewGetProcAddress((const GLubyte*)"glXSelectEvent")) == NULL) || r; - - return r; -} - -#endif /* GLX_VERSION_1_3 */ - -#ifdef GLX_VERSION_1_4 - -#endif /* GLX_VERSION_1_4 */ - -#ifdef GLX_3DFX_multisample - -#endif /* GLX_3DFX_multisample */ - -#ifdef GLX_ARB_create_context - -static GLboolean _glewInit_GLX_ARB_create_context (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glewGetProcAddress((const GLubyte*)"glXCreateContextAttribsARB")) == NULL) || r; - - return r; -} - -#endif /* GLX_ARB_create_context */ - -#ifdef GLX_ARB_fbconfig_float - -#endif /* GLX_ARB_fbconfig_float */ - -#ifdef GLX_ARB_framebuffer_sRGB - -#endif /* GLX_ARB_framebuffer_sRGB */ - -#ifdef GLX_ARB_get_proc_address - -#endif /* GLX_ARB_get_proc_address */ - -#ifdef GLX_ARB_multisample - -#endif /* GLX_ARB_multisample */ - -#ifdef GLX_ATI_pixel_format_float - -#endif /* GLX_ATI_pixel_format_float */ - -#ifdef GLX_ATI_render_texture - -static GLboolean _glewInit_GLX_ATI_render_texture (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXBindTexImageATI = (PFNGLXBINDTEXIMAGEATIPROC)glewGetProcAddress((const GLubyte*)"glXBindTexImageATI")) == NULL) || r; - r = ((glXDrawableAttribATI = (PFNGLXDRAWABLEATTRIBATIPROC)glewGetProcAddress((const GLubyte*)"glXDrawableAttribATI")) == NULL) || r; - r = ((glXReleaseTexImageATI = (PFNGLXRELEASETEXIMAGEATIPROC)glewGetProcAddress((const GLubyte*)"glXReleaseTexImageATI")) == NULL) || r; - - return r; -} - -#endif /* GLX_ATI_render_texture */ - -#ifdef GLX_EXT_fbconfig_packed_float - -#endif /* GLX_EXT_fbconfig_packed_float */ - -#ifdef GLX_EXT_framebuffer_sRGB - -#endif /* GLX_EXT_framebuffer_sRGB */ - -#ifdef GLX_EXT_import_context - -static GLboolean _glewInit_GLX_EXT_import_context (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXFreeContextEXT = (PFNGLXFREECONTEXTEXTPROC)glewGetProcAddress((const GLubyte*)"glXFreeContextEXT")) == NULL) || r; - r = ((glXGetContextIDEXT = (PFNGLXGETCONTEXTIDEXTPROC)glewGetProcAddress((const GLubyte*)"glXGetContextIDEXT")) == NULL) || r; - r = ((glXImportContextEXT = (PFNGLXIMPORTCONTEXTEXTPROC)glewGetProcAddress((const GLubyte*)"glXImportContextEXT")) == NULL) || r; - r = ((glXQueryContextInfoEXT = (PFNGLXQUERYCONTEXTINFOEXTPROC)glewGetProcAddress((const GLubyte*)"glXQueryContextInfoEXT")) == NULL) || r; - - return r; -} - -#endif /* GLX_EXT_import_context */ - -#ifdef GLX_EXT_scene_marker - -#endif /* GLX_EXT_scene_marker */ - -#ifdef GLX_EXT_texture_from_pixmap - -static GLboolean _glewInit_GLX_EXT_texture_from_pixmap (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXBindTexImageEXT = (PFNGLXBINDTEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glXBindTexImageEXT")) == NULL) || r; - r = ((glXReleaseTexImageEXT = (PFNGLXRELEASETEXIMAGEEXTPROC)glewGetProcAddress((const GLubyte*)"glXReleaseTexImageEXT")) == NULL) || r; - - return r; -} - -#endif /* GLX_EXT_texture_from_pixmap */ - -#ifdef GLX_EXT_visual_info - -#endif /* GLX_EXT_visual_info */ - -#ifdef GLX_EXT_visual_rating - -#endif /* GLX_EXT_visual_rating */ - -#ifdef GLX_MESA_agp_offset - -static GLboolean _glewInit_GLX_MESA_agp_offset (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXGetAGPOffsetMESA = (PFNGLXGETAGPOFFSETMESAPROC)glewGetProcAddress((const GLubyte*)"glXGetAGPOffsetMESA")) == NULL) || r; - - return r; -} - -#endif /* GLX_MESA_agp_offset */ - -#ifdef GLX_MESA_copy_sub_buffer - -static GLboolean _glewInit_GLX_MESA_copy_sub_buffer (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXCopySubBufferMESA = (PFNGLXCOPYSUBBUFFERMESAPROC)glewGetProcAddress((const GLubyte*)"glXCopySubBufferMESA")) == NULL) || r; - - return r; -} - -#endif /* GLX_MESA_copy_sub_buffer */ - -#ifdef GLX_MESA_pixmap_colormap - -static GLboolean _glewInit_GLX_MESA_pixmap_colormap (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXCreateGLXPixmapMESA = (PFNGLXCREATEGLXPIXMAPMESAPROC)glewGetProcAddress((const GLubyte*)"glXCreateGLXPixmapMESA")) == NULL) || r; - - return r; -} - -#endif /* GLX_MESA_pixmap_colormap */ - -#ifdef GLX_MESA_release_buffers - -static GLboolean _glewInit_GLX_MESA_release_buffers (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXReleaseBuffersMESA = (PFNGLXRELEASEBUFFERSMESAPROC)glewGetProcAddress((const GLubyte*)"glXReleaseBuffersMESA")) == NULL) || r; - - return r; -} - -#endif /* GLX_MESA_release_buffers */ - -#ifdef GLX_MESA_set_3dfx_mode - -static GLboolean _glewInit_GLX_MESA_set_3dfx_mode (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXSet3DfxModeMESA = (PFNGLXSET3DFXMODEMESAPROC)glewGetProcAddress((const GLubyte*)"glXSet3DfxModeMESA")) == NULL) || r; - - return r; -} - -#endif /* GLX_MESA_set_3dfx_mode */ - -#ifdef GLX_NV_float_buffer - -#endif /* GLX_NV_float_buffer */ - -#ifdef GLX_NV_present_video - -static GLboolean _glewInit_GLX_NV_present_video (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXBindVideoDeviceNV = (PFNGLXBINDVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"glXBindVideoDeviceNV")) == NULL) || r; - r = ((glXEnumerateVideoDevicesNV = (PFNGLXENUMERATEVIDEODEVICESNVPROC)glewGetProcAddress((const GLubyte*)"glXEnumerateVideoDevicesNV")) == NULL) || r; - - return r; -} - -#endif /* GLX_NV_present_video */ - -#ifdef GLX_NV_swap_group - -static GLboolean _glewInit_GLX_NV_swap_group (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXBindSwapBarrierNV = (PFNGLXBINDSWAPBARRIERNVPROC)glewGetProcAddress((const GLubyte*)"glXBindSwapBarrierNV")) == NULL) || r; - r = ((glXJoinSwapGroupNV = (PFNGLXJOINSWAPGROUPNVPROC)glewGetProcAddress((const GLubyte*)"glXJoinSwapGroupNV")) == NULL) || r; - r = ((glXQueryFrameCountNV = (PFNGLXQUERYFRAMECOUNTNVPROC)glewGetProcAddress((const GLubyte*)"glXQueryFrameCountNV")) == NULL) || r; - r = ((glXQueryMaxSwapGroupsNV = (PFNGLXQUERYMAXSWAPGROUPSNVPROC)glewGetProcAddress((const GLubyte*)"glXQueryMaxSwapGroupsNV")) == NULL) || r; - r = ((glXQuerySwapGroupNV = (PFNGLXQUERYSWAPGROUPNVPROC)glewGetProcAddress((const GLubyte*)"glXQuerySwapGroupNV")) == NULL) || r; - r = ((glXResetFrameCountNV = (PFNGLXRESETFRAMECOUNTNVPROC)glewGetProcAddress((const GLubyte*)"glXResetFrameCountNV")) == NULL) || r; - - return r; -} - -#endif /* GLX_NV_swap_group */ - -#ifdef GLX_NV_vertex_array_range - -static GLboolean _glewInit_GLX_NV_vertex_array_range (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXAllocateMemoryNV = (PFNGLXALLOCATEMEMORYNVPROC)glewGetProcAddress((const GLubyte*)"glXAllocateMemoryNV")) == NULL) || r; - r = ((glXFreeMemoryNV = (PFNGLXFREEMEMORYNVPROC)glewGetProcAddress((const GLubyte*)"glXFreeMemoryNV")) == NULL) || r; - - return r; -} - -#endif /* GLX_NV_vertex_array_range */ - -#ifdef GLX_NV_video_output - -static GLboolean _glewInit_GLX_NV_video_output (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXBindVideoImageNV = (PFNGLXBINDVIDEOIMAGENVPROC)glewGetProcAddress((const GLubyte*)"glXBindVideoImageNV")) == NULL) || r; - r = ((glXGetVideoDeviceNV = (PFNGLXGETVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"glXGetVideoDeviceNV")) == NULL) || r; - r = ((glXGetVideoInfoNV = (PFNGLXGETVIDEOINFONVPROC)glewGetProcAddress((const GLubyte*)"glXGetVideoInfoNV")) == NULL) || r; - r = ((glXReleaseVideoDeviceNV = (PFNGLXRELEASEVIDEODEVICENVPROC)glewGetProcAddress((const GLubyte*)"glXReleaseVideoDeviceNV")) == NULL) || r; - r = ((glXReleaseVideoImageNV = (PFNGLXRELEASEVIDEOIMAGENVPROC)glewGetProcAddress((const GLubyte*)"glXReleaseVideoImageNV")) == NULL) || r; - r = ((glXSendPbufferToVideoNV = (PFNGLXSENDPBUFFERTOVIDEONVPROC)glewGetProcAddress((const GLubyte*)"glXSendPbufferToVideoNV")) == NULL) || r; - - return r; -} - -#endif /* GLX_NV_video_output */ - -#ifdef GLX_OML_swap_method - -#endif /* GLX_OML_swap_method */ - -#if defined(GLX_OML_sync_control) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -#include - -static GLboolean _glewInit_GLX_OML_sync_control (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXGetMscRateOML = (PFNGLXGETMSCRATEOMLPROC)glewGetProcAddress((const GLubyte*)"glXGetMscRateOML")) == NULL) || r; - r = ((glXGetSyncValuesOML = (PFNGLXGETSYNCVALUESOMLPROC)glewGetProcAddress((const GLubyte*)"glXGetSyncValuesOML")) == NULL) || r; - r = ((glXSwapBuffersMscOML = (PFNGLXSWAPBUFFERSMSCOMLPROC)glewGetProcAddress((const GLubyte*)"glXSwapBuffersMscOML")) == NULL) || r; - r = ((glXWaitForMscOML = (PFNGLXWAITFORMSCOMLPROC)glewGetProcAddress((const GLubyte*)"glXWaitForMscOML")) == NULL) || r; - r = ((glXWaitForSbcOML = (PFNGLXWAITFORSBCOMLPROC)glewGetProcAddress((const GLubyte*)"glXWaitForSbcOML")) == NULL) || r; - - return r; -} - -#endif /* GLX_OML_sync_control */ - -#ifdef GLX_SGIS_blended_overlay - -#endif /* GLX_SGIS_blended_overlay */ - -#ifdef GLX_SGIS_color_range - -#endif /* GLX_SGIS_color_range */ - -#ifdef GLX_SGIS_multisample - -#endif /* GLX_SGIS_multisample */ - -#ifdef GLX_SGIS_shared_multisample - -#endif /* GLX_SGIS_shared_multisample */ - -#ifdef GLX_SGIX_fbconfig - -static GLboolean _glewInit_GLX_SGIX_fbconfig (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXChooseFBConfigSGIX = (PFNGLXCHOOSEFBCONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXChooseFBConfigSGIX")) == NULL) || r; - r = ((glXCreateContextWithConfigSGIX = (PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXCreateContextWithConfigSGIX")) == NULL) || r; - r = ((glXCreateGLXPixmapWithConfigSGIX = (PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXCreateGLXPixmapWithConfigSGIX")) == NULL) || r; - r = ((glXGetFBConfigAttribSGIX = (PFNGLXGETFBCONFIGATTRIBSGIXPROC)glewGetProcAddress((const GLubyte*)"glXGetFBConfigAttribSGIX")) == NULL) || r; - r = ((glXGetFBConfigFromVisualSGIX = (PFNGLXGETFBCONFIGFROMVISUALSGIXPROC)glewGetProcAddress((const GLubyte*)"glXGetFBConfigFromVisualSGIX")) == NULL) || r; - r = ((glXGetVisualFromFBConfigSGIX = (PFNGLXGETVISUALFROMFBCONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXGetVisualFromFBConfigSGIX")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGIX_fbconfig */ - -#ifdef GLX_SGIX_hyperpipe - -static GLboolean _glewInit_GLX_SGIX_hyperpipe (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXBindHyperpipeSGIX = (PFNGLXBINDHYPERPIPESGIXPROC)glewGetProcAddress((const GLubyte*)"glXBindHyperpipeSGIX")) == NULL) || r; - r = ((glXDestroyHyperpipeConfigSGIX = (PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXDestroyHyperpipeConfigSGIX")) == NULL) || r; - r = ((glXHyperpipeAttribSGIX = (PFNGLXHYPERPIPEATTRIBSGIXPROC)glewGetProcAddress((const GLubyte*)"glXHyperpipeAttribSGIX")) == NULL) || r; - r = ((glXHyperpipeConfigSGIX = (PFNGLXHYPERPIPECONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXHyperpipeConfigSGIX")) == NULL) || r; - r = ((glXQueryHyperpipeAttribSGIX = (PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryHyperpipeAttribSGIX")) == NULL) || r; - r = ((glXQueryHyperpipeBestAttribSGIX = (PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryHyperpipeBestAttribSGIX")) == NULL) || r; - r = ((glXQueryHyperpipeConfigSGIX = (PFNGLXQUERYHYPERPIPECONFIGSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryHyperpipeConfigSGIX")) == NULL) || r; - r = ((glXQueryHyperpipeNetworkSGIX = (PFNGLXQUERYHYPERPIPENETWORKSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryHyperpipeNetworkSGIX")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGIX_hyperpipe */ - -#ifdef GLX_SGIX_pbuffer - -static GLboolean _glewInit_GLX_SGIX_pbuffer (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXCreateGLXPbufferSGIX = (PFNGLXCREATEGLXPBUFFERSGIXPROC)glewGetProcAddress((const GLubyte*)"glXCreateGLXPbufferSGIX")) == NULL) || r; - r = ((glXDestroyGLXPbufferSGIX = (PFNGLXDESTROYGLXPBUFFERSGIXPROC)glewGetProcAddress((const GLubyte*)"glXDestroyGLXPbufferSGIX")) == NULL) || r; - r = ((glXGetSelectedEventSGIX = (PFNGLXGETSELECTEDEVENTSGIXPROC)glewGetProcAddress((const GLubyte*)"glXGetSelectedEventSGIX")) == NULL) || r; - r = ((glXQueryGLXPbufferSGIX = (PFNGLXQUERYGLXPBUFFERSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryGLXPbufferSGIX")) == NULL) || r; - r = ((glXSelectEventSGIX = (PFNGLXSELECTEVENTSGIXPROC)glewGetProcAddress((const GLubyte*)"glXSelectEventSGIX")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGIX_pbuffer */ - -#ifdef GLX_SGIX_swap_barrier - -static GLboolean _glewInit_GLX_SGIX_swap_barrier (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXBindSwapBarrierSGIX = (PFNGLXBINDSWAPBARRIERSGIXPROC)glewGetProcAddress((const GLubyte*)"glXBindSwapBarrierSGIX")) == NULL) || r; - r = ((glXQueryMaxSwapBarriersSGIX = (PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryMaxSwapBarriersSGIX")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGIX_swap_barrier */ - -#ifdef GLX_SGIX_swap_group - -static GLboolean _glewInit_GLX_SGIX_swap_group (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXJoinSwapGroupSGIX = (PFNGLXJOINSWAPGROUPSGIXPROC)glewGetProcAddress((const GLubyte*)"glXJoinSwapGroupSGIX")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGIX_swap_group */ - -#ifdef GLX_SGIX_video_resize - -static GLboolean _glewInit_GLX_SGIX_video_resize (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXBindChannelToWindowSGIX = (PFNGLXBINDCHANNELTOWINDOWSGIXPROC)glewGetProcAddress((const GLubyte*)"glXBindChannelToWindowSGIX")) == NULL) || r; - r = ((glXChannelRectSGIX = (PFNGLXCHANNELRECTSGIXPROC)glewGetProcAddress((const GLubyte*)"glXChannelRectSGIX")) == NULL) || r; - r = ((glXChannelRectSyncSGIX = (PFNGLXCHANNELRECTSYNCSGIXPROC)glewGetProcAddress((const GLubyte*)"glXChannelRectSyncSGIX")) == NULL) || r; - r = ((glXQueryChannelDeltasSGIX = (PFNGLXQUERYCHANNELDELTASSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryChannelDeltasSGIX")) == NULL) || r; - r = ((glXQueryChannelRectSGIX = (PFNGLXQUERYCHANNELRECTSGIXPROC)glewGetProcAddress((const GLubyte*)"glXQueryChannelRectSGIX")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGIX_video_resize */ - -#ifdef GLX_SGIX_visual_select_group - -#endif /* GLX_SGIX_visual_select_group */ - -#ifdef GLX_SGI_cushion - -static GLboolean _glewInit_GLX_SGI_cushion (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXCushionSGI = (PFNGLXCUSHIONSGIPROC)glewGetProcAddress((const GLubyte*)"glXCushionSGI")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGI_cushion */ - -#ifdef GLX_SGI_make_current_read - -static GLboolean _glewInit_GLX_SGI_make_current_read (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXGetCurrentReadDrawableSGI = (PFNGLXGETCURRENTREADDRAWABLESGIPROC)glewGetProcAddress((const GLubyte*)"glXGetCurrentReadDrawableSGI")) == NULL) || r; - r = ((glXMakeCurrentReadSGI = (PFNGLXMAKECURRENTREADSGIPROC)glewGetProcAddress((const GLubyte*)"glXMakeCurrentReadSGI")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGI_make_current_read */ - -#ifdef GLX_SGI_swap_control - -static GLboolean _glewInit_GLX_SGI_swap_control (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)glewGetProcAddress((const GLubyte*)"glXSwapIntervalSGI")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGI_swap_control */ - -#ifdef GLX_SGI_video_sync - -static GLboolean _glewInit_GLX_SGI_video_sync (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXGetVideoSyncSGI = (PFNGLXGETVIDEOSYNCSGIPROC)glewGetProcAddress((const GLubyte*)"glXGetVideoSyncSGI")) == NULL) || r; - r = ((glXWaitVideoSyncSGI = (PFNGLXWAITVIDEOSYNCSGIPROC)glewGetProcAddress((const GLubyte*)"glXWaitVideoSyncSGI")) == NULL) || r; - - return r; -} - -#endif /* GLX_SGI_video_sync */ - -#ifdef GLX_SUN_get_transparent_index - -static GLboolean _glewInit_GLX_SUN_get_transparent_index (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXGetTransparentIndexSUN = (PFNGLXGETTRANSPARENTINDEXSUNPROC)glewGetProcAddress((const GLubyte*)"glXGetTransparentIndexSUN")) == NULL) || r; - - return r; -} - -#endif /* GLX_SUN_get_transparent_index */ - -#ifdef GLX_SUN_video_resize - -static GLboolean _glewInit_GLX_SUN_video_resize (GLXEW_CONTEXT_ARG_DEF_INIT) -{ - GLboolean r = GL_FALSE; - - r = ((glXGetVideoResizeSUN = (PFNGLXGETVIDEORESIZESUNPROC)glewGetProcAddress((const GLubyte*)"glXGetVideoResizeSUN")) == NULL) || r; - r = ((glXVideoResizeSUN = (PFNGLXVIDEORESIZESUNPROC)glewGetProcAddress((const GLubyte*)"glXVideoResizeSUN")) == NULL) || r; - - return r; -} - -#endif /* GLX_SUN_video_resize */ - -/* ------------------------------------------------------------------------ */ - -GLboolean glxewGetExtension (const char* name) -{ - GLubyte* p; - GLubyte* end; - GLuint len = _glewStrLen((const GLubyte*)name); -/* if (glXQueryExtensionsString == NULL || glXGetCurrentDisplay == NULL) return GL_FALSE; */ -/* p = (GLubyte*)glXQueryExtensionsString(glXGetCurrentDisplay(), DefaultScreen(glXGetCurrentDisplay())); */ - if (glXGetClientString == NULL || glXGetCurrentDisplay == NULL) return GL_FALSE; - p = (GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS); - if (0 == p) return GL_FALSE; - end = p + _glewStrLen(p); - while (p < end) - { - GLuint n = _glewStrCLen(p, ' '); - if (len == n && _glewStrSame((const GLubyte*)name, p, n)) return GL_TRUE; - p += n+1; - } - return GL_FALSE; -} - -GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST) -{ - int major, minor; - /* initialize core GLX 1.2 */ - if (_glewInit_GLX_VERSION_1_2(GLEW_CONTEXT_ARG_VAR_INIT)) return GLEW_ERROR_GLX_VERSION_11_ONLY; - /* initialize flags */ - CONST_CAST(GLXEW_VERSION_1_0) = GL_TRUE; - CONST_CAST(GLXEW_VERSION_1_1) = GL_TRUE; - CONST_CAST(GLXEW_VERSION_1_2) = GL_TRUE; - CONST_CAST(GLXEW_VERSION_1_3) = GL_TRUE; - CONST_CAST(GLXEW_VERSION_1_4) = GL_TRUE; - /* query GLX version */ - glXQueryVersion(glXGetCurrentDisplay(), &major, &minor); - if (major == 1 && minor <= 3) - { - switch (minor) - { - case 3: - CONST_CAST(GLXEW_VERSION_1_4) = GL_FALSE; - break; - case 2: - CONST_CAST(GLXEW_VERSION_1_4) = GL_FALSE; - CONST_CAST(GLXEW_VERSION_1_3) = GL_FALSE; - break; - default: - return GLEW_ERROR_GLX_VERSION_11_ONLY; - break; - } - } - /* initialize extensions */ -#ifdef GLX_VERSION_1_3 - if (glewExperimental || GLXEW_VERSION_1_3) CONST_CAST(GLXEW_VERSION_1_3) = !_glewInit_GLX_VERSION_1_3(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_VERSION_1_3 */ -#ifdef GLX_3DFX_multisample - CONST_CAST(GLXEW_3DFX_multisample) = glxewGetExtension("GLX_3DFX_multisample"); -#endif /* GLX_3DFX_multisample */ -#ifdef GLX_ARB_create_context - CONST_CAST(GLXEW_ARB_create_context) = glxewGetExtension("GLX_ARB_create_context"); - if (glewExperimental || GLXEW_ARB_create_context) CONST_CAST(GLXEW_ARB_create_context) = !_glewInit_GLX_ARB_create_context(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_ARB_create_context */ -#ifdef GLX_ARB_fbconfig_float - CONST_CAST(GLXEW_ARB_fbconfig_float) = glxewGetExtension("GLX_ARB_fbconfig_float"); -#endif /* GLX_ARB_fbconfig_float */ -#ifdef GLX_ARB_framebuffer_sRGB - CONST_CAST(GLXEW_ARB_framebuffer_sRGB) = glxewGetExtension("GLX_ARB_framebuffer_sRGB"); -#endif /* GLX_ARB_framebuffer_sRGB */ -#ifdef GLX_ARB_get_proc_address - CONST_CAST(GLXEW_ARB_get_proc_address) = glxewGetExtension("GLX_ARB_get_proc_address"); -#endif /* GLX_ARB_get_proc_address */ -#ifdef GLX_ARB_multisample - CONST_CAST(GLXEW_ARB_multisample) = glxewGetExtension("GLX_ARB_multisample"); -#endif /* GLX_ARB_multisample */ -#ifdef GLX_ATI_pixel_format_float - CONST_CAST(GLXEW_ATI_pixel_format_float) = glxewGetExtension("GLX_ATI_pixel_format_float"); -#endif /* GLX_ATI_pixel_format_float */ -#ifdef GLX_ATI_render_texture - CONST_CAST(GLXEW_ATI_render_texture) = glxewGetExtension("GLX_ATI_render_texture"); - if (glewExperimental || GLXEW_ATI_render_texture) CONST_CAST(GLXEW_ATI_render_texture) = !_glewInit_GLX_ATI_render_texture(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_ATI_render_texture */ -#ifdef GLX_EXT_fbconfig_packed_float - CONST_CAST(GLXEW_EXT_fbconfig_packed_float) = glxewGetExtension("GLX_EXT_fbconfig_packed_float"); -#endif /* GLX_EXT_fbconfig_packed_float */ -#ifdef GLX_EXT_framebuffer_sRGB - CONST_CAST(GLXEW_EXT_framebuffer_sRGB) = glxewGetExtension("GLX_EXT_framebuffer_sRGB"); -#endif /* GLX_EXT_framebuffer_sRGB */ -#ifdef GLX_EXT_import_context - CONST_CAST(GLXEW_EXT_import_context) = glxewGetExtension("GLX_EXT_import_context"); - if (glewExperimental || GLXEW_EXT_import_context) CONST_CAST(GLXEW_EXT_import_context) = !_glewInit_GLX_EXT_import_context(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_EXT_import_context */ -#ifdef GLX_EXT_scene_marker - CONST_CAST(GLXEW_EXT_scene_marker) = glxewGetExtension("GLX_EXT_scene_marker"); -#endif /* GLX_EXT_scene_marker */ -#ifdef GLX_EXT_texture_from_pixmap - CONST_CAST(GLXEW_EXT_texture_from_pixmap) = glxewGetExtension("GLX_EXT_texture_from_pixmap"); - if (glewExperimental || GLXEW_EXT_texture_from_pixmap) CONST_CAST(GLXEW_EXT_texture_from_pixmap) = !_glewInit_GLX_EXT_texture_from_pixmap(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_EXT_texture_from_pixmap */ -#ifdef GLX_EXT_visual_info - CONST_CAST(GLXEW_EXT_visual_info) = glxewGetExtension("GLX_EXT_visual_info"); -#endif /* GLX_EXT_visual_info */ -#ifdef GLX_EXT_visual_rating - CONST_CAST(GLXEW_EXT_visual_rating) = glxewGetExtension("GLX_EXT_visual_rating"); -#endif /* GLX_EXT_visual_rating */ -#ifdef GLX_MESA_agp_offset - CONST_CAST(GLXEW_MESA_agp_offset) = glxewGetExtension("GLX_MESA_agp_offset"); - if (glewExperimental || GLXEW_MESA_agp_offset) CONST_CAST(GLXEW_MESA_agp_offset) = !_glewInit_GLX_MESA_agp_offset(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_MESA_agp_offset */ -#ifdef GLX_MESA_copy_sub_buffer - CONST_CAST(GLXEW_MESA_copy_sub_buffer) = glxewGetExtension("GLX_MESA_copy_sub_buffer"); - if (glewExperimental || GLXEW_MESA_copy_sub_buffer) CONST_CAST(GLXEW_MESA_copy_sub_buffer) = !_glewInit_GLX_MESA_copy_sub_buffer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_MESA_copy_sub_buffer */ -#ifdef GLX_MESA_pixmap_colormap - CONST_CAST(GLXEW_MESA_pixmap_colormap) = glxewGetExtension("GLX_MESA_pixmap_colormap"); - if (glewExperimental || GLXEW_MESA_pixmap_colormap) CONST_CAST(GLXEW_MESA_pixmap_colormap) = !_glewInit_GLX_MESA_pixmap_colormap(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_MESA_pixmap_colormap */ -#ifdef GLX_MESA_release_buffers - CONST_CAST(GLXEW_MESA_release_buffers) = glxewGetExtension("GLX_MESA_release_buffers"); - if (glewExperimental || GLXEW_MESA_release_buffers) CONST_CAST(GLXEW_MESA_release_buffers) = !_glewInit_GLX_MESA_release_buffers(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_MESA_release_buffers */ -#ifdef GLX_MESA_set_3dfx_mode - CONST_CAST(GLXEW_MESA_set_3dfx_mode) = glxewGetExtension("GLX_MESA_set_3dfx_mode"); - if (glewExperimental || GLXEW_MESA_set_3dfx_mode) CONST_CAST(GLXEW_MESA_set_3dfx_mode) = !_glewInit_GLX_MESA_set_3dfx_mode(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_MESA_set_3dfx_mode */ -#ifdef GLX_NV_float_buffer - CONST_CAST(GLXEW_NV_float_buffer) = glxewGetExtension("GLX_NV_float_buffer"); -#endif /* GLX_NV_float_buffer */ -#ifdef GLX_NV_present_video - CONST_CAST(GLXEW_NV_present_video) = glxewGetExtension("GLX_NV_present_video"); - if (glewExperimental || GLXEW_NV_present_video) CONST_CAST(GLXEW_NV_present_video) = !_glewInit_GLX_NV_present_video(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_NV_present_video */ -#ifdef GLX_NV_swap_group - CONST_CAST(GLXEW_NV_swap_group) = glxewGetExtension("GLX_NV_swap_group"); - if (glewExperimental || GLXEW_NV_swap_group) CONST_CAST(GLXEW_NV_swap_group) = !_glewInit_GLX_NV_swap_group(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_NV_swap_group */ -#ifdef GLX_NV_vertex_array_range - CONST_CAST(GLXEW_NV_vertex_array_range) = glxewGetExtension("GLX_NV_vertex_array_range"); - if (glewExperimental || GLXEW_NV_vertex_array_range) CONST_CAST(GLXEW_NV_vertex_array_range) = !_glewInit_GLX_NV_vertex_array_range(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_NV_vertex_array_range */ -#ifdef GLX_NV_video_output - CONST_CAST(GLXEW_NV_video_output) = glxewGetExtension("GLX_NV_video_output"); - if (glewExperimental || GLXEW_NV_video_output) CONST_CAST(GLXEW_NV_video_output) = !_glewInit_GLX_NV_video_output(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_NV_video_output */ -#ifdef GLX_OML_swap_method - CONST_CAST(GLXEW_OML_swap_method) = glxewGetExtension("GLX_OML_swap_method"); -#endif /* GLX_OML_swap_method */ -#if defined(GLX_OML_sync_control) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -#include - CONST_CAST(GLXEW_OML_sync_control) = glxewGetExtension("GLX_OML_sync_control"); - if (glewExperimental || GLXEW_OML_sync_control) CONST_CAST(GLXEW_OML_sync_control) = !_glewInit_GLX_OML_sync_control(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_OML_sync_control */ -#ifdef GLX_SGIS_blended_overlay - CONST_CAST(GLXEW_SGIS_blended_overlay) = glxewGetExtension("GLX_SGIS_blended_overlay"); -#endif /* GLX_SGIS_blended_overlay */ -#ifdef GLX_SGIS_color_range - CONST_CAST(GLXEW_SGIS_color_range) = glxewGetExtension("GLX_SGIS_color_range"); -#endif /* GLX_SGIS_color_range */ -#ifdef GLX_SGIS_multisample - CONST_CAST(GLXEW_SGIS_multisample) = glxewGetExtension("GLX_SGIS_multisample"); -#endif /* GLX_SGIS_multisample */ -#ifdef GLX_SGIS_shared_multisample - CONST_CAST(GLXEW_SGIS_shared_multisample) = glxewGetExtension("GLX_SGIS_shared_multisample"); -#endif /* GLX_SGIS_shared_multisample */ -#ifdef GLX_SGIX_fbconfig - CONST_CAST(GLXEW_SGIX_fbconfig) = glxewGetExtension("GLX_SGIX_fbconfig"); - if (glewExperimental || GLXEW_SGIX_fbconfig) CONST_CAST(GLXEW_SGIX_fbconfig) = !_glewInit_GLX_SGIX_fbconfig(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGIX_fbconfig */ -#ifdef GLX_SGIX_hyperpipe - CONST_CAST(GLXEW_SGIX_hyperpipe) = glxewGetExtension("GLX_SGIX_hyperpipe"); - if (glewExperimental || GLXEW_SGIX_hyperpipe) CONST_CAST(GLXEW_SGIX_hyperpipe) = !_glewInit_GLX_SGIX_hyperpipe(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGIX_hyperpipe */ -#ifdef GLX_SGIX_pbuffer - CONST_CAST(GLXEW_SGIX_pbuffer) = glxewGetExtension("GLX_SGIX_pbuffer"); - if (glewExperimental || GLXEW_SGIX_pbuffer) CONST_CAST(GLXEW_SGIX_pbuffer) = !_glewInit_GLX_SGIX_pbuffer(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGIX_pbuffer */ -#ifdef GLX_SGIX_swap_barrier - CONST_CAST(GLXEW_SGIX_swap_barrier) = glxewGetExtension("GLX_SGIX_swap_barrier"); - if (glewExperimental || GLXEW_SGIX_swap_barrier) CONST_CAST(GLXEW_SGIX_swap_barrier) = !_glewInit_GLX_SGIX_swap_barrier(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGIX_swap_barrier */ -#ifdef GLX_SGIX_swap_group - CONST_CAST(GLXEW_SGIX_swap_group) = glxewGetExtension("GLX_SGIX_swap_group"); - if (glewExperimental || GLXEW_SGIX_swap_group) CONST_CAST(GLXEW_SGIX_swap_group) = !_glewInit_GLX_SGIX_swap_group(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGIX_swap_group */ -#ifdef GLX_SGIX_video_resize - CONST_CAST(GLXEW_SGIX_video_resize) = glxewGetExtension("GLX_SGIX_video_resize"); - if (glewExperimental || GLXEW_SGIX_video_resize) CONST_CAST(GLXEW_SGIX_video_resize) = !_glewInit_GLX_SGIX_video_resize(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGIX_video_resize */ -#ifdef GLX_SGIX_visual_select_group - CONST_CAST(GLXEW_SGIX_visual_select_group) = glxewGetExtension("GLX_SGIX_visual_select_group"); -#endif /* GLX_SGIX_visual_select_group */ -#ifdef GLX_SGI_cushion - CONST_CAST(GLXEW_SGI_cushion) = glxewGetExtension("GLX_SGI_cushion"); - if (glewExperimental || GLXEW_SGI_cushion) CONST_CAST(GLXEW_SGI_cushion) = !_glewInit_GLX_SGI_cushion(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGI_cushion */ -#ifdef GLX_SGI_make_current_read - CONST_CAST(GLXEW_SGI_make_current_read) = glxewGetExtension("GLX_SGI_make_current_read"); - if (glewExperimental || GLXEW_SGI_make_current_read) CONST_CAST(GLXEW_SGI_make_current_read) = !_glewInit_GLX_SGI_make_current_read(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGI_make_current_read */ -#ifdef GLX_SGI_swap_control - CONST_CAST(GLXEW_SGI_swap_control) = glxewGetExtension("GLX_SGI_swap_control"); - if (glewExperimental || GLXEW_SGI_swap_control) CONST_CAST(GLXEW_SGI_swap_control) = !_glewInit_GLX_SGI_swap_control(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGI_swap_control */ -#ifdef GLX_SGI_video_sync - CONST_CAST(GLXEW_SGI_video_sync) = glxewGetExtension("GLX_SGI_video_sync"); - if (glewExperimental || GLXEW_SGI_video_sync) CONST_CAST(GLXEW_SGI_video_sync) = !_glewInit_GLX_SGI_video_sync(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SGI_video_sync */ -#ifdef GLX_SUN_get_transparent_index - CONST_CAST(GLXEW_SUN_get_transparent_index) = glxewGetExtension("GLX_SUN_get_transparent_index"); - if (glewExperimental || GLXEW_SUN_get_transparent_index) CONST_CAST(GLXEW_SUN_get_transparent_index) = !_glewInit_GLX_SUN_get_transparent_index(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SUN_get_transparent_index */ -#ifdef GLX_SUN_video_resize - CONST_CAST(GLXEW_SUN_video_resize) = glxewGetExtension("GLX_SUN_video_resize"); - if (glewExperimental || GLXEW_SUN_video_resize) CONST_CAST(GLXEW_SUN_video_resize) = !_glewInit_GLX_SUN_video_resize(GLEW_CONTEXT_ARG_VAR_INIT); -#endif /* GLX_SUN_video_resize */ - - return GLEW_OK; -} - -#endif /* !__APPLE__ || GLEW_APPLE_GLX */ - -/* ------------------------------------------------------------------------ */ - -const GLubyte* glewGetErrorString (GLenum error) -{ - static const GLubyte* _glewErrorString[] = - { - (const GLubyte*)"No error", - (const GLubyte*)"Missing GL version", - (const GLubyte*)"GL 1.1 and up are not supported", - (const GLubyte*)"GLX 1.2 and up are not supported", - (const GLubyte*)"Unknown error" - }; - const int max_error = sizeof(_glewErrorString)/sizeof(*_glewErrorString) - 1; - return _glewErrorString[(int)error > max_error ? max_error : (int)error]; -} - -const GLubyte* glewGetString (GLenum name) -{ - static const GLubyte* _glewString[] = - { - (const GLubyte*)NULL, - (const GLubyte*)"1.5.1", - (const GLubyte*)"1", - (const GLubyte*)"5", - (const GLubyte*)"1" - }; - const int max_string = sizeof(_glewString)/sizeof(*_glewString) - 1; - return _glewString[(int)name > max_string ? 0 : (int)name]; -} - -/* ------------------------------------------------------------------------ */ - -GLboolean glewExperimental = GL_FALSE; - -#if !defined(GLEW_MX) - -#if defined(_WIN32) -extern GLenum wglewContextInit (void); -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */ -extern GLenum glxewContextInit (void); -#endif /* _WIN32 */ - -GLenum glewInit () -{ - GLenum r; - if ( (r = glewContextInit()) ) return r; -#if defined(_WIN32) - return wglewContextInit(); -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) /* _UNIX */ - return glxewContextInit(); -#else - return r; -#endif /* _WIN32 */ -} - -#endif /* !GLEW_MX */ -#ifdef GLEW_MX -GLboolean glewContextIsSupported (GLEWContext* ctx, const char* name) -#else -GLboolean glewIsSupported (const char* name) -#endif -{ - GLubyte* pos = (GLubyte*)name; - GLuint len = _glewStrLen(pos); - GLboolean ret = GL_TRUE; - while (ret && len > 0) - { - if (_glewStrSame1(&pos, &len, (const GLubyte*)"GL_", 3)) - { - if (_glewStrSame2(&pos, &len, (const GLubyte*)"VERSION_", 8)) - { -#ifdef GL_VERSION_1_2 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_2", 3)) - { - ret = GLEW_VERSION_1_2; - continue; - } -#endif -#ifdef GL_VERSION_1_3 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_3", 3)) - { - ret = GLEW_VERSION_1_3; - continue; - } -#endif -#ifdef GL_VERSION_1_4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_4", 3)) - { - ret = GLEW_VERSION_1_4; - continue; - } -#endif -#ifdef GL_VERSION_1_5 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_5", 3)) - { - ret = GLEW_VERSION_1_5; - continue; - } -#endif -#ifdef GL_VERSION_2_0 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"2_0", 3)) - { - ret = GLEW_VERSION_2_0; - continue; - } -#endif -#ifdef GL_VERSION_2_1 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"2_1", 3)) - { - ret = GLEW_VERSION_2_1; - continue; - } -#endif -#ifdef GL_VERSION_3_0 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"3_0", 3)) - { - ret = GLEW_VERSION_3_0; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"3DFX_", 5)) - { -#ifdef GL_3DFX_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = GLEW_3DFX_multisample; - continue; - } -#endif -#ifdef GL_3DFX_tbuffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"tbuffer", 7)) - { - ret = GLEW_3DFX_tbuffer; - continue; - } -#endif -#ifdef GL_3DFX_texture_compression_FXT1 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_FXT1", 24)) - { - ret = GLEW_3DFX_texture_compression_FXT1; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"APPLE_", 6)) - { -#ifdef GL_APPLE_client_storage - if (_glewStrSame3(&pos, &len, (const GLubyte*)"client_storage", 14)) - { - ret = GLEW_APPLE_client_storage; - continue; - } -#endif -#ifdef GL_APPLE_element_array - if (_glewStrSame3(&pos, &len, (const GLubyte*)"element_array", 13)) - { - ret = GLEW_APPLE_element_array; - continue; - } -#endif -#ifdef GL_APPLE_fence - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fence", 5)) - { - ret = GLEW_APPLE_fence; - continue; - } -#endif -#ifdef GL_APPLE_float_pixels - if (_glewStrSame3(&pos, &len, (const GLubyte*)"float_pixels", 12)) - { - ret = GLEW_APPLE_float_pixels; - continue; - } -#endif -#ifdef GL_APPLE_flush_buffer_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"flush_buffer_range", 18)) - { - ret = GLEW_APPLE_flush_buffer_range; - continue; - } -#endif -#ifdef GL_APPLE_pixel_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_buffer", 12)) - { - ret = GLEW_APPLE_pixel_buffer; - continue; - } -#endif -#ifdef GL_APPLE_specular_vector - if (_glewStrSame3(&pos, &len, (const GLubyte*)"specular_vector", 15)) - { - ret = GLEW_APPLE_specular_vector; - continue; - } -#endif -#ifdef GL_APPLE_texture_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_range", 13)) - { - ret = GLEW_APPLE_texture_range; - continue; - } -#endif -#ifdef GL_APPLE_transform_hint - if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_hint", 14)) - { - ret = GLEW_APPLE_transform_hint; - continue; - } -#endif -#ifdef GL_APPLE_vertex_array_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_object", 19)) - { - ret = GLEW_APPLE_vertex_array_object; - continue; - } -#endif -#ifdef GL_APPLE_vertex_array_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_range", 18)) - { - ret = GLEW_APPLE_vertex_array_range; - continue; - } -#endif -#ifdef GL_APPLE_ycbcr_422 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"ycbcr_422", 9)) - { - ret = GLEW_APPLE_ycbcr_422; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"ARB_", 4)) - { -#ifdef GL_ARB_color_buffer_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_buffer_float", 18)) - { - ret = GLEW_ARB_color_buffer_float; - continue; - } -#endif -#ifdef GL_ARB_depth_buffer_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_buffer_float", 18)) - { - ret = GLEW_ARB_depth_buffer_float; - continue; - } -#endif -#ifdef GL_ARB_depth_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_texture", 13)) - { - ret = GLEW_ARB_depth_texture; - continue; - } -#endif -#ifdef GL_ARB_draw_buffers - if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_buffers", 12)) - { - ret = GLEW_ARB_draw_buffers; - continue; - } -#endif -#ifdef GL_ARB_draw_instanced - if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_instanced", 14)) - { - ret = GLEW_ARB_draw_instanced; - continue; - } -#endif -#ifdef GL_ARB_fragment_program - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program", 16)) - { - ret = GLEW_ARB_fragment_program; - continue; - } -#endif -#ifdef GL_ARB_fragment_program_shadow - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program_shadow", 23)) - { - ret = GLEW_ARB_fragment_program_shadow; - continue; - } -#endif -#ifdef GL_ARB_fragment_shader - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_shader", 15)) - { - ret = GLEW_ARB_fragment_shader; - continue; - } -#endif -#ifdef GL_ARB_framebuffer_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_object", 18)) - { - ret = GLEW_ARB_framebuffer_object; - continue; - } -#endif -#ifdef GL_ARB_framebuffer_sRGB - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) - { - ret = GLEW_ARB_framebuffer_sRGB; - continue; - } -#endif -#ifdef GL_ARB_geometry_shader4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"geometry_shader4", 16)) - { - ret = GLEW_ARB_geometry_shader4; - continue; - } -#endif -#ifdef GL_ARB_half_float_pixel - if (_glewStrSame3(&pos, &len, (const GLubyte*)"half_float_pixel", 16)) - { - ret = GLEW_ARB_half_float_pixel; - continue; - } -#endif -#ifdef GL_ARB_half_float_vertex - if (_glewStrSame3(&pos, &len, (const GLubyte*)"half_float_vertex", 17)) - { - ret = GLEW_ARB_half_float_vertex; - continue; - } -#endif -#ifdef GL_ARB_imaging - if (_glewStrSame3(&pos, &len, (const GLubyte*)"imaging", 7)) - { - ret = GLEW_ARB_imaging; - continue; - } -#endif -#ifdef GL_ARB_instanced_arrays - if (_glewStrSame3(&pos, &len, (const GLubyte*)"instanced_arrays", 16)) - { - ret = GLEW_ARB_instanced_arrays; - continue; - } -#endif -#ifdef GL_ARB_map_buffer_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"map_buffer_range", 16)) - { - ret = GLEW_ARB_map_buffer_range; - continue; - } -#endif -#ifdef GL_ARB_matrix_palette - if (_glewStrSame3(&pos, &len, (const GLubyte*)"matrix_palette", 14)) - { - ret = GLEW_ARB_matrix_palette; - continue; - } -#endif -#ifdef GL_ARB_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = GLEW_ARB_multisample; - continue; - } -#endif -#ifdef GL_ARB_multitexture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multitexture", 12)) - { - ret = GLEW_ARB_multitexture; - continue; - } -#endif -#ifdef GL_ARB_occlusion_query - if (_glewStrSame3(&pos, &len, (const GLubyte*)"occlusion_query", 15)) - { - ret = GLEW_ARB_occlusion_query; - continue; - } -#endif -#ifdef GL_ARB_pixel_buffer_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_buffer_object", 19)) - { - ret = GLEW_ARB_pixel_buffer_object; - continue; - } -#endif -#ifdef GL_ARB_point_parameters - if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_parameters", 16)) - { - ret = GLEW_ARB_point_parameters; - continue; - } -#endif -#ifdef GL_ARB_point_sprite - if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_sprite", 12)) - { - ret = GLEW_ARB_point_sprite; - continue; - } -#endif -#ifdef GL_ARB_shader_objects - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_objects", 14)) - { - ret = GLEW_ARB_shader_objects; - continue; - } -#endif -#ifdef GL_ARB_shading_language_100 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shading_language_100", 20)) - { - ret = GLEW_ARB_shading_language_100; - continue; - } -#endif -#ifdef GL_ARB_shadow - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow", 6)) - { - ret = GLEW_ARB_shadow; - continue; - } -#endif -#ifdef GL_ARB_shadow_ambient - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow_ambient", 14)) - { - ret = GLEW_ARB_shadow_ambient; - continue; - } -#endif -#ifdef GL_ARB_texture_border_clamp - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_border_clamp", 20)) - { - ret = GLEW_ARB_texture_border_clamp; - continue; - } -#endif -#ifdef GL_ARB_texture_buffer_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_buffer_object", 21)) - { - ret = GLEW_ARB_texture_buffer_object; - continue; - } -#endif -#ifdef GL_ARB_texture_compression - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression", 19)) - { - ret = GLEW_ARB_texture_compression; - continue; - } -#endif -#ifdef GL_ARB_texture_compression_rgtc - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_rgtc", 24)) - { - ret = GLEW_ARB_texture_compression_rgtc; - continue; - } -#endif -#ifdef GL_ARB_texture_cube_map - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_cube_map", 16)) - { - ret = GLEW_ARB_texture_cube_map; - continue; - } -#endif -#ifdef GL_ARB_texture_env_add - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_add", 15)) - { - ret = GLEW_ARB_texture_env_add; - continue; - } -#endif -#ifdef GL_ARB_texture_env_combine - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_combine", 19)) - { - ret = GLEW_ARB_texture_env_combine; - continue; - } -#endif -#ifdef GL_ARB_texture_env_crossbar - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_crossbar", 20)) - { - ret = GLEW_ARB_texture_env_crossbar; - continue; - } -#endif -#ifdef GL_ARB_texture_env_dot3 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_dot3", 16)) - { - ret = GLEW_ARB_texture_env_dot3; - continue; - } -#endif -#ifdef GL_ARB_texture_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_float", 13)) - { - ret = GLEW_ARB_texture_float; - continue; - } -#endif -#ifdef GL_ARB_texture_mirrored_repeat - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_mirrored_repeat", 23)) - { - ret = GLEW_ARB_texture_mirrored_repeat; - continue; - } -#endif -#ifdef GL_ARB_texture_non_power_of_two - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_non_power_of_two", 24)) - { - ret = GLEW_ARB_texture_non_power_of_two; - continue; - } -#endif -#ifdef GL_ARB_texture_rectangle - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_rectangle", 17)) - { - ret = GLEW_ARB_texture_rectangle; - continue; - } -#endif -#ifdef GL_ARB_texture_rg - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_rg", 10)) - { - ret = GLEW_ARB_texture_rg; - continue; - } -#endif -#ifdef GL_ARB_transpose_matrix - if (_glewStrSame3(&pos, &len, (const GLubyte*)"transpose_matrix", 16)) - { - ret = GLEW_ARB_transpose_matrix; - continue; - } -#endif -#ifdef GL_ARB_vertex_array_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_object", 19)) - { - ret = GLEW_ARB_vertex_array_object; - continue; - } -#endif -#ifdef GL_ARB_vertex_blend - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_blend", 12)) - { - ret = GLEW_ARB_vertex_blend; - continue; - } -#endif -#ifdef GL_ARB_vertex_buffer_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_buffer_object", 20)) - { - ret = GLEW_ARB_vertex_buffer_object; - continue; - } -#endif -#ifdef GL_ARB_vertex_program - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program", 14)) - { - ret = GLEW_ARB_vertex_program; - continue; - } -#endif -#ifdef GL_ARB_vertex_shader - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_shader", 13)) - { - ret = GLEW_ARB_vertex_shader; - continue; - } -#endif -#ifdef GL_ARB_window_pos - if (_glewStrSame3(&pos, &len, (const GLubyte*)"window_pos", 10)) - { - ret = GLEW_ARB_window_pos; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"ATIX_", 5)) - { -#ifdef GL_ATIX_point_sprites - if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_sprites", 13)) - { - ret = GLEW_ATIX_point_sprites; - continue; - } -#endif -#ifdef GL_ATIX_texture_env_combine3 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_combine3", 20)) - { - ret = GLEW_ATIX_texture_env_combine3; - continue; - } -#endif -#ifdef GL_ATIX_texture_env_route - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_route", 17)) - { - ret = GLEW_ATIX_texture_env_route; - continue; - } -#endif -#ifdef GL_ATIX_vertex_shader_output_point_size - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_shader_output_point_size", 31)) - { - ret = GLEW_ATIX_vertex_shader_output_point_size; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"ATI_", 4)) - { -#ifdef GL_ATI_draw_buffers - if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_buffers", 12)) - { - ret = GLEW_ATI_draw_buffers; - continue; - } -#endif -#ifdef GL_ATI_element_array - if (_glewStrSame3(&pos, &len, (const GLubyte*)"element_array", 13)) - { - ret = GLEW_ATI_element_array; - continue; - } -#endif -#ifdef GL_ATI_envmap_bumpmap - if (_glewStrSame3(&pos, &len, (const GLubyte*)"envmap_bumpmap", 14)) - { - ret = GLEW_ATI_envmap_bumpmap; - continue; - } -#endif -#ifdef GL_ATI_fragment_shader - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_shader", 15)) - { - ret = GLEW_ATI_fragment_shader; - continue; - } -#endif -#ifdef GL_ATI_map_object_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"map_object_buffer", 17)) - { - ret = GLEW_ATI_map_object_buffer; - continue; - } -#endif -#ifdef GL_ATI_pn_triangles - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pn_triangles", 12)) - { - ret = GLEW_ATI_pn_triangles; - continue; - } -#endif -#ifdef GL_ATI_separate_stencil - if (_glewStrSame3(&pos, &len, (const GLubyte*)"separate_stencil", 16)) - { - ret = GLEW_ATI_separate_stencil; - continue; - } -#endif -#ifdef GL_ATI_shader_texture_lod - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shader_texture_lod", 18)) - { - ret = GLEW_ATI_shader_texture_lod; - continue; - } -#endif -#ifdef GL_ATI_text_fragment_shader - if (_glewStrSame3(&pos, &len, (const GLubyte*)"text_fragment_shader", 20)) - { - ret = GLEW_ATI_text_fragment_shader; - continue; - } -#endif -#ifdef GL_ATI_texture_compression_3dc - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_3dc", 23)) - { - ret = GLEW_ATI_texture_compression_3dc; - continue; - } -#endif -#ifdef GL_ATI_texture_env_combine3 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_combine3", 20)) - { - ret = GLEW_ATI_texture_env_combine3; - continue; - } -#endif -#ifdef GL_ATI_texture_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_float", 13)) - { - ret = GLEW_ATI_texture_float; - continue; - } -#endif -#ifdef GL_ATI_texture_mirror_once - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_mirror_once", 19)) - { - ret = GLEW_ATI_texture_mirror_once; - continue; - } -#endif -#ifdef GL_ATI_vertex_array_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_object", 19)) - { - ret = GLEW_ATI_vertex_array_object; - continue; - } -#endif -#ifdef GL_ATI_vertex_attrib_array_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_attrib_array_object", 26)) - { - ret = GLEW_ATI_vertex_attrib_array_object; - continue; - } -#endif -#ifdef GL_ATI_vertex_streams - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_streams", 14)) - { - ret = GLEW_ATI_vertex_streams; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"EXT_", 4)) - { -#ifdef GL_EXT_422_pixels - if (_glewStrSame3(&pos, &len, (const GLubyte*)"422_pixels", 10)) - { - ret = GLEW_EXT_422_pixels; - continue; - } -#endif -#ifdef GL_EXT_Cg_shader - if (_glewStrSame3(&pos, &len, (const GLubyte*)"Cg_shader", 9)) - { - ret = GLEW_EXT_Cg_shader; - continue; - } -#endif -#ifdef GL_EXT_abgr - if (_glewStrSame3(&pos, &len, (const GLubyte*)"abgr", 4)) - { - ret = GLEW_EXT_abgr; - continue; - } -#endif -#ifdef GL_EXT_bgra - if (_glewStrSame3(&pos, &len, (const GLubyte*)"bgra", 4)) - { - ret = GLEW_EXT_bgra; - continue; - } -#endif -#ifdef GL_EXT_bindable_uniform - if (_glewStrSame3(&pos, &len, (const GLubyte*)"bindable_uniform", 16)) - { - ret = GLEW_EXT_bindable_uniform; - continue; - } -#endif -#ifdef GL_EXT_blend_color - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_color", 11)) - { - ret = GLEW_EXT_blend_color; - continue; - } -#endif -#ifdef GL_EXT_blend_equation_separate - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_equation_separate", 23)) - { - ret = GLEW_EXT_blend_equation_separate; - continue; - } -#endif -#ifdef GL_EXT_blend_func_separate - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_func_separate", 19)) - { - ret = GLEW_EXT_blend_func_separate; - continue; - } -#endif -#ifdef GL_EXT_blend_logic_op - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_logic_op", 14)) - { - ret = GLEW_EXT_blend_logic_op; - continue; - } -#endif -#ifdef GL_EXT_blend_minmax - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_minmax", 12)) - { - ret = GLEW_EXT_blend_minmax; - continue; - } -#endif -#ifdef GL_EXT_blend_subtract - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_subtract", 14)) - { - ret = GLEW_EXT_blend_subtract; - continue; - } -#endif -#ifdef GL_EXT_clip_volume_hint - if (_glewStrSame3(&pos, &len, (const GLubyte*)"clip_volume_hint", 16)) - { - ret = GLEW_EXT_clip_volume_hint; - continue; - } -#endif -#ifdef GL_EXT_cmyka - if (_glewStrSame3(&pos, &len, (const GLubyte*)"cmyka", 5)) - { - ret = GLEW_EXT_cmyka; - continue; - } -#endif -#ifdef GL_EXT_color_subtable - if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_subtable", 14)) - { - ret = GLEW_EXT_color_subtable; - continue; - } -#endif -#ifdef GL_EXT_compiled_vertex_array - if (_glewStrSame3(&pos, &len, (const GLubyte*)"compiled_vertex_array", 21)) - { - ret = GLEW_EXT_compiled_vertex_array; - continue; - } -#endif -#ifdef GL_EXT_convolution - if (_glewStrSame3(&pos, &len, (const GLubyte*)"convolution", 11)) - { - ret = GLEW_EXT_convolution; - continue; - } -#endif -#ifdef GL_EXT_coordinate_frame - if (_glewStrSame3(&pos, &len, (const GLubyte*)"coordinate_frame", 16)) - { - ret = GLEW_EXT_coordinate_frame; - continue; - } -#endif -#ifdef GL_EXT_copy_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_texture", 12)) - { - ret = GLEW_EXT_copy_texture; - continue; - } -#endif -#ifdef GL_EXT_cull_vertex - if (_glewStrSame3(&pos, &len, (const GLubyte*)"cull_vertex", 11)) - { - ret = GLEW_EXT_cull_vertex; - continue; - } -#endif -#ifdef GL_EXT_depth_bounds_test - if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_bounds_test", 17)) - { - ret = GLEW_EXT_depth_bounds_test; - continue; - } -#endif -#ifdef GL_EXT_direct_state_access - if (_glewStrSame3(&pos, &len, (const GLubyte*)"direct_state_access", 19)) - { - ret = GLEW_EXT_direct_state_access; - continue; - } -#endif -#ifdef GL_EXT_draw_buffers2 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_buffers2", 13)) - { - ret = GLEW_EXT_draw_buffers2; - continue; - } -#endif -#ifdef GL_EXT_draw_instanced - if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_instanced", 14)) - { - ret = GLEW_EXT_draw_instanced; - continue; - } -#endif -#ifdef GL_EXT_draw_range_elements - if (_glewStrSame3(&pos, &len, (const GLubyte*)"draw_range_elements", 19)) - { - ret = GLEW_EXT_draw_range_elements; - continue; - } -#endif -#ifdef GL_EXT_fog_coord - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fog_coord", 9)) - { - ret = GLEW_EXT_fog_coord; - continue; - } -#endif -#ifdef GL_EXT_fragment_lighting - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_lighting", 17)) - { - ret = GLEW_EXT_fragment_lighting; - continue; - } -#endif -#ifdef GL_EXT_framebuffer_blit - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_blit", 16)) - { - ret = GLEW_EXT_framebuffer_blit; - continue; - } -#endif -#ifdef GL_EXT_framebuffer_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_multisample", 23)) - { - ret = GLEW_EXT_framebuffer_multisample; - continue; - } -#endif -#ifdef GL_EXT_framebuffer_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_object", 18)) - { - ret = GLEW_EXT_framebuffer_object; - continue; - } -#endif -#ifdef GL_EXT_framebuffer_sRGB - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) - { - ret = GLEW_EXT_framebuffer_sRGB; - continue; - } -#endif -#ifdef GL_EXT_geometry_shader4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"geometry_shader4", 16)) - { - ret = GLEW_EXT_geometry_shader4; - continue; - } -#endif -#ifdef GL_EXT_gpu_program_parameters - if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_program_parameters", 22)) - { - ret = GLEW_EXT_gpu_program_parameters; - continue; - } -#endif -#ifdef GL_EXT_gpu_shader4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_shader4", 11)) - { - ret = GLEW_EXT_gpu_shader4; - continue; - } -#endif -#ifdef GL_EXT_histogram - if (_glewStrSame3(&pos, &len, (const GLubyte*)"histogram", 9)) - { - ret = GLEW_EXT_histogram; - continue; - } -#endif -#ifdef GL_EXT_index_array_formats - if (_glewStrSame3(&pos, &len, (const GLubyte*)"index_array_formats", 19)) - { - ret = GLEW_EXT_index_array_formats; - continue; - } -#endif -#ifdef GL_EXT_index_func - if (_glewStrSame3(&pos, &len, (const GLubyte*)"index_func", 10)) - { - ret = GLEW_EXT_index_func; - continue; - } -#endif -#ifdef GL_EXT_index_material - if (_glewStrSame3(&pos, &len, (const GLubyte*)"index_material", 14)) - { - ret = GLEW_EXT_index_material; - continue; - } -#endif -#ifdef GL_EXT_index_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"index_texture", 13)) - { - ret = GLEW_EXT_index_texture; - continue; - } -#endif -#ifdef GL_EXT_light_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"light_texture", 13)) - { - ret = GLEW_EXT_light_texture; - continue; - } -#endif -#ifdef GL_EXT_misc_attribute - if (_glewStrSame3(&pos, &len, (const GLubyte*)"misc_attribute", 14)) - { - ret = GLEW_EXT_misc_attribute; - continue; - } -#endif -#ifdef GL_EXT_multi_draw_arrays - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multi_draw_arrays", 17)) - { - ret = GLEW_EXT_multi_draw_arrays; - continue; - } -#endif -#ifdef GL_EXT_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = GLEW_EXT_multisample; - continue; - } -#endif -#ifdef GL_EXT_packed_depth_stencil - if (_glewStrSame3(&pos, &len, (const GLubyte*)"packed_depth_stencil", 20)) - { - ret = GLEW_EXT_packed_depth_stencil; - continue; - } -#endif -#ifdef GL_EXT_packed_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"packed_float", 12)) - { - ret = GLEW_EXT_packed_float; - continue; - } -#endif -#ifdef GL_EXT_packed_pixels - if (_glewStrSame3(&pos, &len, (const GLubyte*)"packed_pixels", 13)) - { - ret = GLEW_EXT_packed_pixels; - continue; - } -#endif -#ifdef GL_EXT_paletted_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"paletted_texture", 16)) - { - ret = GLEW_EXT_paletted_texture; - continue; - } -#endif -#ifdef GL_EXT_pixel_buffer_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_buffer_object", 19)) - { - ret = GLEW_EXT_pixel_buffer_object; - continue; - } -#endif -#ifdef GL_EXT_pixel_transform - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_transform", 15)) - { - ret = GLEW_EXT_pixel_transform; - continue; - } -#endif -#ifdef GL_EXT_pixel_transform_color_table - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_transform_color_table", 27)) - { - ret = GLEW_EXT_pixel_transform_color_table; - continue; - } -#endif -#ifdef GL_EXT_point_parameters - if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_parameters", 16)) - { - ret = GLEW_EXT_point_parameters; - continue; - } -#endif -#ifdef GL_EXT_polygon_offset - if (_glewStrSame3(&pos, &len, (const GLubyte*)"polygon_offset", 14)) - { - ret = GLEW_EXT_polygon_offset; - continue; - } -#endif -#ifdef GL_EXT_rescale_normal - if (_glewStrSame3(&pos, &len, (const GLubyte*)"rescale_normal", 14)) - { - ret = GLEW_EXT_rescale_normal; - continue; - } -#endif -#ifdef GL_EXT_scene_marker - if (_glewStrSame3(&pos, &len, (const GLubyte*)"scene_marker", 12)) - { - ret = GLEW_EXT_scene_marker; - continue; - } -#endif -#ifdef GL_EXT_secondary_color - if (_glewStrSame3(&pos, &len, (const GLubyte*)"secondary_color", 15)) - { - ret = GLEW_EXT_secondary_color; - continue; - } -#endif -#ifdef GL_EXT_separate_specular_color - if (_glewStrSame3(&pos, &len, (const GLubyte*)"separate_specular_color", 23)) - { - ret = GLEW_EXT_separate_specular_color; - continue; - } -#endif -#ifdef GL_EXT_shadow_funcs - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow_funcs", 12)) - { - ret = GLEW_EXT_shadow_funcs; - continue; - } -#endif -#ifdef GL_EXT_shared_texture_palette - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shared_texture_palette", 22)) - { - ret = GLEW_EXT_shared_texture_palette; - continue; - } -#endif -#ifdef GL_EXT_stencil_clear_tag - if (_glewStrSame3(&pos, &len, (const GLubyte*)"stencil_clear_tag", 17)) - { - ret = GLEW_EXT_stencil_clear_tag; - continue; - } -#endif -#ifdef GL_EXT_stencil_two_side - if (_glewStrSame3(&pos, &len, (const GLubyte*)"stencil_two_side", 16)) - { - ret = GLEW_EXT_stencil_two_side; - continue; - } -#endif -#ifdef GL_EXT_stencil_wrap - if (_glewStrSame3(&pos, &len, (const GLubyte*)"stencil_wrap", 12)) - { - ret = GLEW_EXT_stencil_wrap; - continue; - } -#endif -#ifdef GL_EXT_subtexture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"subtexture", 10)) - { - ret = GLEW_EXT_subtexture; - continue; - } -#endif -#ifdef GL_EXT_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture", 7)) - { - ret = GLEW_EXT_texture; - continue; - } -#endif -#ifdef GL_EXT_texture3D - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture3D", 9)) - { - ret = GLEW_EXT_texture3D; - continue; - } -#endif -#ifdef GL_EXT_texture_array - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_array", 13)) - { - ret = GLEW_EXT_texture_array; - continue; - } -#endif -#ifdef GL_EXT_texture_buffer_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_buffer_object", 21)) - { - ret = GLEW_EXT_texture_buffer_object; - continue; - } -#endif -#ifdef GL_EXT_texture_compression_dxt1 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_dxt1", 24)) - { - ret = GLEW_EXT_texture_compression_dxt1; - continue; - } -#endif -#ifdef GL_EXT_texture_compression_latc - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_latc", 24)) - { - ret = GLEW_EXT_texture_compression_latc; - continue; - } -#endif -#ifdef GL_EXT_texture_compression_rgtc - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_rgtc", 24)) - { - ret = GLEW_EXT_texture_compression_rgtc; - continue; - } -#endif -#ifdef GL_EXT_texture_compression_s3tc - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_s3tc", 24)) - { - ret = GLEW_EXT_texture_compression_s3tc; - continue; - } -#endif -#ifdef GL_EXT_texture_cube_map - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_cube_map", 16)) - { - ret = GLEW_EXT_texture_cube_map; - continue; - } -#endif -#ifdef GL_EXT_texture_edge_clamp - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_edge_clamp", 18)) - { - ret = GLEW_EXT_texture_edge_clamp; - continue; - } -#endif -#ifdef GL_EXT_texture_env - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env", 11)) - { - ret = GLEW_EXT_texture_env; - continue; - } -#endif -#ifdef GL_EXT_texture_env_add - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_add", 15)) - { - ret = GLEW_EXT_texture_env_add; - continue; - } -#endif -#ifdef GL_EXT_texture_env_combine - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_combine", 19)) - { - ret = GLEW_EXT_texture_env_combine; - continue; - } -#endif -#ifdef GL_EXT_texture_env_dot3 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_dot3", 16)) - { - ret = GLEW_EXT_texture_env_dot3; - continue; - } -#endif -#ifdef GL_EXT_texture_filter_anisotropic - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_filter_anisotropic", 26)) - { - ret = GLEW_EXT_texture_filter_anisotropic; - continue; - } -#endif -#ifdef GL_EXT_texture_integer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_integer", 15)) - { - ret = GLEW_EXT_texture_integer; - continue; - } -#endif -#ifdef GL_EXT_texture_lod_bias - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_lod_bias", 16)) - { - ret = GLEW_EXT_texture_lod_bias; - continue; - } -#endif -#ifdef GL_EXT_texture_mirror_clamp - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_mirror_clamp", 20)) - { - ret = GLEW_EXT_texture_mirror_clamp; - continue; - } -#endif -#ifdef GL_EXT_texture_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_object", 14)) - { - ret = GLEW_EXT_texture_object; - continue; - } -#endif -#ifdef GL_EXT_texture_perturb_normal - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_perturb_normal", 22)) - { - ret = GLEW_EXT_texture_perturb_normal; - continue; - } -#endif -#ifdef GL_EXT_texture_rectangle - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_rectangle", 17)) - { - ret = GLEW_EXT_texture_rectangle; - continue; - } -#endif -#ifdef GL_EXT_texture_sRGB - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_sRGB", 12)) - { - ret = GLEW_EXT_texture_sRGB; - continue; - } -#endif -#ifdef GL_EXT_texture_shared_exponent - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_shared_exponent", 23)) - { - ret = GLEW_EXT_texture_shared_exponent; - continue; - } -#endif -#ifdef GL_EXT_texture_swizzle - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_swizzle", 15)) - { - ret = GLEW_EXT_texture_swizzle; - continue; - } -#endif -#ifdef GL_EXT_timer_query - if (_glewStrSame3(&pos, &len, (const GLubyte*)"timer_query", 11)) - { - ret = GLEW_EXT_timer_query; - continue; - } -#endif -#ifdef GL_EXT_transform_feedback - if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_feedback", 18)) - { - ret = GLEW_EXT_transform_feedback; - continue; - } -#endif -#ifdef GL_EXT_vertex_array - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array", 12)) - { - ret = GLEW_EXT_vertex_array; - continue; - } -#endif -#ifdef GL_EXT_vertex_array_bgra - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_bgra", 17)) - { - ret = GLEW_EXT_vertex_array_bgra; - continue; - } -#endif -#ifdef GL_EXT_vertex_shader - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_shader", 13)) - { - ret = GLEW_EXT_vertex_shader; - continue; - } -#endif -#ifdef GL_EXT_vertex_weighting - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_weighting", 16)) - { - ret = GLEW_EXT_vertex_weighting; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"GREMEDY_", 8)) - { -#ifdef GL_GREMEDY_frame_terminator - if (_glewStrSame3(&pos, &len, (const GLubyte*)"frame_terminator", 16)) - { - ret = GLEW_GREMEDY_frame_terminator; - continue; - } -#endif -#ifdef GL_GREMEDY_string_marker - if (_glewStrSame3(&pos, &len, (const GLubyte*)"string_marker", 13)) - { - ret = GLEW_GREMEDY_string_marker; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"HP_", 3)) - { -#ifdef GL_HP_convolution_border_modes - if (_glewStrSame3(&pos, &len, (const GLubyte*)"convolution_border_modes", 24)) - { - ret = GLEW_HP_convolution_border_modes; - continue; - } -#endif -#ifdef GL_HP_image_transform - if (_glewStrSame3(&pos, &len, (const GLubyte*)"image_transform", 15)) - { - ret = GLEW_HP_image_transform; - continue; - } -#endif -#ifdef GL_HP_occlusion_test - if (_glewStrSame3(&pos, &len, (const GLubyte*)"occlusion_test", 14)) - { - ret = GLEW_HP_occlusion_test; - continue; - } -#endif -#ifdef GL_HP_texture_lighting - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_lighting", 16)) - { - ret = GLEW_HP_texture_lighting; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"IBM_", 4)) - { -#ifdef GL_IBM_cull_vertex - if (_glewStrSame3(&pos, &len, (const GLubyte*)"cull_vertex", 11)) - { - ret = GLEW_IBM_cull_vertex; - continue; - } -#endif -#ifdef GL_IBM_multimode_draw_arrays - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multimode_draw_arrays", 21)) - { - ret = GLEW_IBM_multimode_draw_arrays; - continue; - } -#endif -#ifdef GL_IBM_rasterpos_clip - if (_glewStrSame3(&pos, &len, (const GLubyte*)"rasterpos_clip", 14)) - { - ret = GLEW_IBM_rasterpos_clip; - continue; - } -#endif -#ifdef GL_IBM_static_data - if (_glewStrSame3(&pos, &len, (const GLubyte*)"static_data", 11)) - { - ret = GLEW_IBM_static_data; - continue; - } -#endif -#ifdef GL_IBM_texture_mirrored_repeat - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_mirrored_repeat", 23)) - { - ret = GLEW_IBM_texture_mirrored_repeat; - continue; - } -#endif -#ifdef GL_IBM_vertex_array_lists - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_lists", 18)) - { - ret = GLEW_IBM_vertex_array_lists; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"INGR_", 5)) - { -#ifdef GL_INGR_color_clamp - if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_clamp", 11)) - { - ret = GLEW_INGR_color_clamp; - continue; - } -#endif -#ifdef GL_INGR_interlace_read - if (_glewStrSame3(&pos, &len, (const GLubyte*)"interlace_read", 14)) - { - ret = GLEW_INGR_interlace_read; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"INTEL_", 6)) - { -#ifdef GL_INTEL_parallel_arrays - if (_glewStrSame3(&pos, &len, (const GLubyte*)"parallel_arrays", 15)) - { - ret = GLEW_INTEL_parallel_arrays; - continue; - } -#endif -#ifdef GL_INTEL_texture_scissor - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_scissor", 15)) - { - ret = GLEW_INTEL_texture_scissor; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"KTX_", 4)) - { -#ifdef GL_KTX_buffer_region - if (_glewStrSame3(&pos, &len, (const GLubyte*)"buffer_region", 13)) - { - ret = GLEW_KTX_buffer_region; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"MESAX_", 6)) - { -#ifdef GL_MESAX_texture_stack - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_stack", 13)) - { - ret = GLEW_MESAX_texture_stack; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"MESA_", 5)) - { -#ifdef GL_MESA_pack_invert - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pack_invert", 11)) - { - ret = GLEW_MESA_pack_invert; - continue; - } -#endif -#ifdef GL_MESA_resize_buffers - if (_glewStrSame3(&pos, &len, (const GLubyte*)"resize_buffers", 14)) - { - ret = GLEW_MESA_resize_buffers; - continue; - } -#endif -#ifdef GL_MESA_window_pos - if (_glewStrSame3(&pos, &len, (const GLubyte*)"window_pos", 10)) - { - ret = GLEW_MESA_window_pos; - continue; - } -#endif -#ifdef GL_MESA_ycbcr_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"ycbcr_texture", 13)) - { - ret = GLEW_MESA_ycbcr_texture; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"NV_", 3)) - { -#ifdef GL_NV_blend_square - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_square", 12)) - { - ret = GLEW_NV_blend_square; - continue; - } -#endif -#ifdef GL_NV_conditional_render - if (_glewStrSame3(&pos, &len, (const GLubyte*)"conditional_render", 18)) - { - ret = GLEW_NV_conditional_render; - continue; - } -#endif -#ifdef GL_NV_copy_depth_to_color - if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_depth_to_color", 19)) - { - ret = GLEW_NV_copy_depth_to_color; - continue; - } -#endif -#ifdef GL_NV_depth_buffer_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_buffer_float", 18)) - { - ret = GLEW_NV_depth_buffer_float; - continue; - } -#endif -#ifdef GL_NV_depth_clamp - if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_clamp", 11)) - { - ret = GLEW_NV_depth_clamp; - continue; - } -#endif -#ifdef GL_NV_depth_range_unclamped - if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_range_unclamped", 21)) - { - ret = GLEW_NV_depth_range_unclamped; - continue; - } -#endif -#ifdef GL_NV_evaluators - if (_glewStrSame3(&pos, &len, (const GLubyte*)"evaluators", 10)) - { - ret = GLEW_NV_evaluators; - continue; - } -#endif -#ifdef GL_NV_explicit_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"explicit_multisample", 20)) - { - ret = GLEW_NV_explicit_multisample; - continue; - } -#endif -#ifdef GL_NV_fence - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fence", 5)) - { - ret = GLEW_NV_fence; - continue; - } -#endif -#ifdef GL_NV_float_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"float_buffer", 12)) - { - ret = GLEW_NV_float_buffer; - continue; - } -#endif -#ifdef GL_NV_fog_distance - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fog_distance", 12)) - { - ret = GLEW_NV_fog_distance; - continue; - } -#endif -#ifdef GL_NV_fragment_program - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program", 16)) - { - ret = GLEW_NV_fragment_program; - continue; - } -#endif -#ifdef GL_NV_fragment_program2 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program2", 17)) - { - ret = GLEW_NV_fragment_program2; - continue; - } -#endif -#ifdef GL_NV_fragment_program4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program4", 17)) - { - ret = GLEW_NV_fragment_program4; - continue; - } -#endif -#ifdef GL_NV_fragment_program_option - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_program_option", 23)) - { - ret = GLEW_NV_fragment_program_option; - continue; - } -#endif -#ifdef GL_NV_framebuffer_multisample_coverage - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_multisample_coverage", 32)) - { - ret = GLEW_NV_framebuffer_multisample_coverage; - continue; - } -#endif -#ifdef GL_NV_geometry_program4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"geometry_program4", 17)) - { - ret = GLEW_NV_geometry_program4; - continue; - } -#endif -#ifdef GL_NV_geometry_shader4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"geometry_shader4", 16)) - { - ret = GLEW_NV_geometry_shader4; - continue; - } -#endif -#ifdef GL_NV_gpu_program4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_program4", 12)) - { - ret = GLEW_NV_gpu_program4; - continue; - } -#endif -#ifdef GL_NV_half_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"half_float", 10)) - { - ret = GLEW_NV_half_float; - continue; - } -#endif -#ifdef GL_NV_light_max_exponent - if (_glewStrSame3(&pos, &len, (const GLubyte*)"light_max_exponent", 18)) - { - ret = GLEW_NV_light_max_exponent; - continue; - } -#endif -#ifdef GL_NV_multisample_filter_hint - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample_filter_hint", 23)) - { - ret = GLEW_NV_multisample_filter_hint; - continue; - } -#endif -#ifdef GL_NV_occlusion_query - if (_glewStrSame3(&pos, &len, (const GLubyte*)"occlusion_query", 15)) - { - ret = GLEW_NV_occlusion_query; - continue; - } -#endif -#ifdef GL_NV_packed_depth_stencil - if (_glewStrSame3(&pos, &len, (const GLubyte*)"packed_depth_stencil", 20)) - { - ret = GLEW_NV_packed_depth_stencil; - continue; - } -#endif -#ifdef GL_NV_parameter_buffer_object - if (_glewStrSame3(&pos, &len, (const GLubyte*)"parameter_buffer_object", 23)) - { - ret = GLEW_NV_parameter_buffer_object; - continue; - } -#endif -#ifdef GL_NV_pixel_data_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_data_range", 16)) - { - ret = GLEW_NV_pixel_data_range; - continue; - } -#endif -#ifdef GL_NV_point_sprite - if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_sprite", 12)) - { - ret = GLEW_NV_point_sprite; - continue; - } -#endif -#ifdef GL_NV_present_video - if (_glewStrSame3(&pos, &len, (const GLubyte*)"present_video", 13)) - { - ret = GLEW_NV_present_video; - continue; - } -#endif -#ifdef GL_NV_primitive_restart - if (_glewStrSame3(&pos, &len, (const GLubyte*)"primitive_restart", 17)) - { - ret = GLEW_NV_primitive_restart; - continue; - } -#endif -#ifdef GL_NV_register_combiners - if (_glewStrSame3(&pos, &len, (const GLubyte*)"register_combiners", 18)) - { - ret = GLEW_NV_register_combiners; - continue; - } -#endif -#ifdef GL_NV_register_combiners2 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"register_combiners2", 19)) - { - ret = GLEW_NV_register_combiners2; - continue; - } -#endif -#ifdef GL_NV_texgen_emboss - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texgen_emboss", 13)) - { - ret = GLEW_NV_texgen_emboss; - continue; - } -#endif -#ifdef GL_NV_texgen_reflection - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texgen_reflection", 17)) - { - ret = GLEW_NV_texgen_reflection; - continue; - } -#endif -#ifdef GL_NV_texture_compression_vtc - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_compression_vtc", 23)) - { - ret = GLEW_NV_texture_compression_vtc; - continue; - } -#endif -#ifdef GL_NV_texture_env_combine4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_env_combine4", 20)) - { - ret = GLEW_NV_texture_env_combine4; - continue; - } -#endif -#ifdef GL_NV_texture_expand_normal - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_expand_normal", 21)) - { - ret = GLEW_NV_texture_expand_normal; - continue; - } -#endif -#ifdef GL_NV_texture_rectangle - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_rectangle", 17)) - { - ret = GLEW_NV_texture_rectangle; - continue; - } -#endif -#ifdef GL_NV_texture_shader - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_shader", 14)) - { - ret = GLEW_NV_texture_shader; - continue; - } -#endif -#ifdef GL_NV_texture_shader2 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_shader2", 15)) - { - ret = GLEW_NV_texture_shader2; - continue; - } -#endif -#ifdef GL_NV_texture_shader3 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_shader3", 15)) - { - ret = GLEW_NV_texture_shader3; - continue; - } -#endif -#ifdef GL_NV_transform_feedback - if (_glewStrSame3(&pos, &len, (const GLubyte*)"transform_feedback", 18)) - { - ret = GLEW_NV_transform_feedback; - continue; - } -#endif -#ifdef GL_NV_vertex_array_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_range", 18)) - { - ret = GLEW_NV_vertex_array_range; - continue; - } -#endif -#ifdef GL_NV_vertex_array_range2 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_range2", 19)) - { - ret = GLEW_NV_vertex_array_range2; - continue; - } -#endif -#ifdef GL_NV_vertex_program - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program", 14)) - { - ret = GLEW_NV_vertex_program; - continue; - } -#endif -#ifdef GL_NV_vertex_program1_1 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program1_1", 17)) - { - ret = GLEW_NV_vertex_program1_1; - continue; - } -#endif -#ifdef GL_NV_vertex_program2 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program2", 15)) - { - ret = GLEW_NV_vertex_program2; - continue; - } -#endif -#ifdef GL_NV_vertex_program2_option - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program2_option", 22)) - { - ret = GLEW_NV_vertex_program2_option; - continue; - } -#endif -#ifdef GL_NV_vertex_program3 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program3", 15)) - { - ret = GLEW_NV_vertex_program3; - continue; - } -#endif -#ifdef GL_NV_vertex_program4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_program4", 15)) - { - ret = GLEW_NV_vertex_program4; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"OES_", 4)) - { -#ifdef GL_OES_byte_coordinates - if (_glewStrSame3(&pos, &len, (const GLubyte*)"byte_coordinates", 16)) - { - ret = GLEW_OES_byte_coordinates; - continue; - } -#endif -#ifdef GL_OES_compressed_paletted_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"compressed_paletted_texture", 27)) - { - ret = GLEW_OES_compressed_paletted_texture; - continue; - } -#endif -#ifdef GL_OES_read_format - if (_glewStrSame3(&pos, &len, (const GLubyte*)"read_format", 11)) - { - ret = GLEW_OES_read_format; - continue; - } -#endif -#ifdef GL_OES_single_precision - if (_glewStrSame3(&pos, &len, (const GLubyte*)"single_precision", 16)) - { - ret = GLEW_OES_single_precision; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"OML_", 4)) - { -#ifdef GL_OML_interlace - if (_glewStrSame3(&pos, &len, (const GLubyte*)"interlace", 9)) - { - ret = GLEW_OML_interlace; - continue; - } -#endif -#ifdef GL_OML_resample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"resample", 8)) - { - ret = GLEW_OML_resample; - continue; - } -#endif -#ifdef GL_OML_subsample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"subsample", 9)) - { - ret = GLEW_OML_subsample; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"PGI_", 4)) - { -#ifdef GL_PGI_misc_hints - if (_glewStrSame3(&pos, &len, (const GLubyte*)"misc_hints", 10)) - { - ret = GLEW_PGI_misc_hints; - continue; - } -#endif -#ifdef GL_PGI_vertex_hints - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_hints", 12)) - { - ret = GLEW_PGI_vertex_hints; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"REND_", 5)) - { -#ifdef GL_REND_screen_coordinates - if (_glewStrSame3(&pos, &len, (const GLubyte*)"screen_coordinates", 18)) - { - ret = GLEW_REND_screen_coordinates; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"S3_", 3)) - { -#ifdef GL_S3_s3tc - if (_glewStrSame3(&pos, &len, (const GLubyte*)"s3tc", 4)) - { - ret = GLEW_S3_s3tc; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGIS_", 5)) - { -#ifdef GL_SGIS_color_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_range", 11)) - { - ret = GLEW_SGIS_color_range; - continue; - } -#endif -#ifdef GL_SGIS_detail_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"detail_texture", 14)) - { - ret = GLEW_SGIS_detail_texture; - continue; - } -#endif -#ifdef GL_SGIS_fog_function - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fog_function", 12)) - { - ret = GLEW_SGIS_fog_function; - continue; - } -#endif -#ifdef GL_SGIS_generate_mipmap - if (_glewStrSame3(&pos, &len, (const GLubyte*)"generate_mipmap", 15)) - { - ret = GLEW_SGIS_generate_mipmap; - continue; - } -#endif -#ifdef GL_SGIS_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = GLEW_SGIS_multisample; - continue; - } -#endif -#ifdef GL_SGIS_pixel_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_texture", 13)) - { - ret = GLEW_SGIS_pixel_texture; - continue; - } -#endif -#ifdef GL_SGIS_point_line_texgen - if (_glewStrSame3(&pos, &len, (const GLubyte*)"point_line_texgen", 17)) - { - ret = GLEW_SGIS_point_line_texgen; - continue; - } -#endif -#ifdef GL_SGIS_sharpen_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"sharpen_texture", 15)) - { - ret = GLEW_SGIS_sharpen_texture; - continue; - } -#endif -#ifdef GL_SGIS_texture4D - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture4D", 9)) - { - ret = GLEW_SGIS_texture4D; - continue; - } -#endif -#ifdef GL_SGIS_texture_border_clamp - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_border_clamp", 20)) - { - ret = GLEW_SGIS_texture_border_clamp; - continue; - } -#endif -#ifdef GL_SGIS_texture_edge_clamp - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_edge_clamp", 18)) - { - ret = GLEW_SGIS_texture_edge_clamp; - continue; - } -#endif -#ifdef GL_SGIS_texture_filter4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_filter4", 15)) - { - ret = GLEW_SGIS_texture_filter4; - continue; - } -#endif -#ifdef GL_SGIS_texture_lod - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_lod", 11)) - { - ret = GLEW_SGIS_texture_lod; - continue; - } -#endif -#ifdef GL_SGIS_texture_select - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_select", 14)) - { - ret = GLEW_SGIS_texture_select; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGIX_", 5)) - { -#ifdef GL_SGIX_async - if (_glewStrSame3(&pos, &len, (const GLubyte*)"async", 5)) - { - ret = GLEW_SGIX_async; - continue; - } -#endif -#ifdef GL_SGIX_async_histogram - if (_glewStrSame3(&pos, &len, (const GLubyte*)"async_histogram", 15)) - { - ret = GLEW_SGIX_async_histogram; - continue; - } -#endif -#ifdef GL_SGIX_async_pixel - if (_glewStrSame3(&pos, &len, (const GLubyte*)"async_pixel", 11)) - { - ret = GLEW_SGIX_async_pixel; - continue; - } -#endif -#ifdef GL_SGIX_blend_alpha_minmax - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blend_alpha_minmax", 18)) - { - ret = GLEW_SGIX_blend_alpha_minmax; - continue; - } -#endif -#ifdef GL_SGIX_clipmap - if (_glewStrSame3(&pos, &len, (const GLubyte*)"clipmap", 7)) - { - ret = GLEW_SGIX_clipmap; - continue; - } -#endif -#ifdef GL_SGIX_convolution_accuracy - if (_glewStrSame3(&pos, &len, (const GLubyte*)"convolution_accuracy", 20)) - { - ret = GLEW_SGIX_convolution_accuracy; - continue; - } -#endif -#ifdef GL_SGIX_depth_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_texture", 13)) - { - ret = GLEW_SGIX_depth_texture; - continue; - } -#endif -#ifdef GL_SGIX_flush_raster - if (_glewStrSame3(&pos, &len, (const GLubyte*)"flush_raster", 12)) - { - ret = GLEW_SGIX_flush_raster; - continue; - } -#endif -#ifdef GL_SGIX_fog_offset - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fog_offset", 10)) - { - ret = GLEW_SGIX_fog_offset; - continue; - } -#endif -#ifdef GL_SGIX_fog_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fog_texture", 11)) - { - ret = GLEW_SGIX_fog_texture; - continue; - } -#endif -#ifdef GL_SGIX_fragment_specular_lighting - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fragment_specular_lighting", 26)) - { - ret = GLEW_SGIX_fragment_specular_lighting; - continue; - } -#endif -#ifdef GL_SGIX_framezoom - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framezoom", 9)) - { - ret = GLEW_SGIX_framezoom; - continue; - } -#endif -#ifdef GL_SGIX_interlace - if (_glewStrSame3(&pos, &len, (const GLubyte*)"interlace", 9)) - { - ret = GLEW_SGIX_interlace; - continue; - } -#endif -#ifdef GL_SGIX_ir_instrument1 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"ir_instrument1", 14)) - { - ret = GLEW_SGIX_ir_instrument1; - continue; - } -#endif -#ifdef GL_SGIX_list_priority - if (_glewStrSame3(&pos, &len, (const GLubyte*)"list_priority", 13)) - { - ret = GLEW_SGIX_list_priority; - continue; - } -#endif -#ifdef GL_SGIX_pixel_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_texture", 13)) - { - ret = GLEW_SGIX_pixel_texture; - continue; - } -#endif -#ifdef GL_SGIX_pixel_texture_bits - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_texture_bits", 18)) - { - ret = GLEW_SGIX_pixel_texture_bits; - continue; - } -#endif -#ifdef GL_SGIX_reference_plane - if (_glewStrSame3(&pos, &len, (const GLubyte*)"reference_plane", 15)) - { - ret = GLEW_SGIX_reference_plane; - continue; - } -#endif -#ifdef GL_SGIX_resample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"resample", 8)) - { - ret = GLEW_SGIX_resample; - continue; - } -#endif -#ifdef GL_SGIX_shadow - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow", 6)) - { - ret = GLEW_SGIX_shadow; - continue; - } -#endif -#ifdef GL_SGIX_shadow_ambient - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shadow_ambient", 14)) - { - ret = GLEW_SGIX_shadow_ambient; - continue; - } -#endif -#ifdef GL_SGIX_sprite - if (_glewStrSame3(&pos, &len, (const GLubyte*)"sprite", 6)) - { - ret = GLEW_SGIX_sprite; - continue; - } -#endif -#ifdef GL_SGIX_tag_sample_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"tag_sample_buffer", 17)) - { - ret = GLEW_SGIX_tag_sample_buffer; - continue; - } -#endif -#ifdef GL_SGIX_texture_add_env - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_add_env", 15)) - { - ret = GLEW_SGIX_texture_add_env; - continue; - } -#endif -#ifdef GL_SGIX_texture_coordinate_clamp - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_coordinate_clamp", 24)) - { - ret = GLEW_SGIX_texture_coordinate_clamp; - continue; - } -#endif -#ifdef GL_SGIX_texture_lod_bias - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_lod_bias", 16)) - { - ret = GLEW_SGIX_texture_lod_bias; - continue; - } -#endif -#ifdef GL_SGIX_texture_multi_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_multi_buffer", 20)) - { - ret = GLEW_SGIX_texture_multi_buffer; - continue; - } -#endif -#ifdef GL_SGIX_texture_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_range", 13)) - { - ret = GLEW_SGIX_texture_range; - continue; - } -#endif -#ifdef GL_SGIX_texture_scale_bias - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_scale_bias", 18)) - { - ret = GLEW_SGIX_texture_scale_bias; - continue; - } -#endif -#ifdef GL_SGIX_vertex_preclip - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_preclip", 14)) - { - ret = GLEW_SGIX_vertex_preclip; - continue; - } -#endif -#ifdef GL_SGIX_vertex_preclip_hint - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_preclip_hint", 19)) - { - ret = GLEW_SGIX_vertex_preclip_hint; - continue; - } -#endif -#ifdef GL_SGIX_ycrcb - if (_glewStrSame3(&pos, &len, (const GLubyte*)"ycrcb", 5)) - { - ret = GLEW_SGIX_ycrcb; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGI_", 4)) - { -#ifdef GL_SGI_color_matrix - if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_matrix", 12)) - { - ret = GLEW_SGI_color_matrix; - continue; - } -#endif -#ifdef GL_SGI_color_table - if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_table", 11)) - { - ret = GLEW_SGI_color_table; - continue; - } -#endif -#ifdef GL_SGI_texture_color_table - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_color_table", 19)) - { - ret = GLEW_SGI_texture_color_table; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SUNX_", 5)) - { -#ifdef GL_SUNX_constant_data - if (_glewStrSame3(&pos, &len, (const GLubyte*)"constant_data", 13)) - { - ret = GLEW_SUNX_constant_data; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SUN_", 4)) - { -#ifdef GL_SUN_convolution_border_modes - if (_glewStrSame3(&pos, &len, (const GLubyte*)"convolution_border_modes", 24)) - { - ret = GLEW_SUN_convolution_border_modes; - continue; - } -#endif -#ifdef GL_SUN_global_alpha - if (_glewStrSame3(&pos, &len, (const GLubyte*)"global_alpha", 12)) - { - ret = GLEW_SUN_global_alpha; - continue; - } -#endif -#ifdef GL_SUN_mesh_array - if (_glewStrSame3(&pos, &len, (const GLubyte*)"mesh_array", 10)) - { - ret = GLEW_SUN_mesh_array; - continue; - } -#endif -#ifdef GL_SUN_read_video_pixels - if (_glewStrSame3(&pos, &len, (const GLubyte*)"read_video_pixels", 17)) - { - ret = GLEW_SUN_read_video_pixels; - continue; - } -#endif -#ifdef GL_SUN_slice_accum - if (_glewStrSame3(&pos, &len, (const GLubyte*)"slice_accum", 11)) - { - ret = GLEW_SUN_slice_accum; - continue; - } -#endif -#ifdef GL_SUN_triangle_list - if (_glewStrSame3(&pos, &len, (const GLubyte*)"triangle_list", 13)) - { - ret = GLEW_SUN_triangle_list; - continue; - } -#endif -#ifdef GL_SUN_vertex - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex", 6)) - { - ret = GLEW_SUN_vertex; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"WIN_", 4)) - { -#ifdef GL_WIN_phong_shading - if (_glewStrSame3(&pos, &len, (const GLubyte*)"phong_shading", 13)) - { - ret = GLEW_WIN_phong_shading; - continue; - } -#endif -#ifdef GL_WIN_specular_fog - if (_glewStrSame3(&pos, &len, (const GLubyte*)"specular_fog", 12)) - { - ret = GLEW_WIN_specular_fog; - continue; - } -#endif -#ifdef GL_WIN_swap_hint - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_hint", 9)) - { - ret = GLEW_WIN_swap_hint; - continue; - } -#endif - } - } - ret = (len == 0); - } - return ret; -} - -#if defined(_WIN32) - -#if defined(GLEW_MX) -GLboolean wglewContextIsSupported (WGLEWContext* ctx, const char* name) -#else -GLboolean wglewIsSupported (const char* name) -#endif -{ - GLubyte* pos = (GLubyte*)name; - GLuint len = _glewStrLen(pos); - GLboolean ret = GL_TRUE; - while (ret && len > 0) - { - if (_glewStrSame1(&pos, &len, (const GLubyte*)"WGL_", 4)) - { - if (_glewStrSame2(&pos, &len, (const GLubyte*)"3DFX_", 5)) - { -#ifdef WGL_3DFX_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = WGLEW_3DFX_multisample; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"3DL_", 4)) - { -#ifdef WGL_3DL_stereo_control - if (_glewStrSame3(&pos, &len, (const GLubyte*)"stereo_control", 14)) - { - ret = WGLEW_3DL_stereo_control; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"ARB_", 4)) - { -#ifdef WGL_ARB_buffer_region - if (_glewStrSame3(&pos, &len, (const GLubyte*)"buffer_region", 13)) - { - ret = WGLEW_ARB_buffer_region; - continue; - } -#endif -#ifdef WGL_ARB_create_context - if (_glewStrSame3(&pos, &len, (const GLubyte*)"create_context", 14)) - { - ret = WGLEW_ARB_create_context; - continue; - } -#endif -#ifdef WGL_ARB_extensions_string - if (_glewStrSame3(&pos, &len, (const GLubyte*)"extensions_string", 17)) - { - ret = WGLEW_ARB_extensions_string; - continue; - } -#endif -#ifdef WGL_ARB_framebuffer_sRGB - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) - { - ret = WGLEW_ARB_framebuffer_sRGB; - continue; - } -#endif -#ifdef WGL_ARB_make_current_read - if (_glewStrSame3(&pos, &len, (const GLubyte*)"make_current_read", 17)) - { - ret = WGLEW_ARB_make_current_read; - continue; - } -#endif -#ifdef WGL_ARB_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = WGLEW_ARB_multisample; - continue; - } -#endif -#ifdef WGL_ARB_pbuffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pbuffer", 7)) - { - ret = WGLEW_ARB_pbuffer; - continue; - } -#endif -#ifdef WGL_ARB_pixel_format - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format", 12)) - { - ret = WGLEW_ARB_pixel_format; - continue; - } -#endif -#ifdef WGL_ARB_pixel_format_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format_float", 18)) - { - ret = WGLEW_ARB_pixel_format_float; - continue; - } -#endif -#ifdef WGL_ARB_render_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"render_texture", 14)) - { - ret = WGLEW_ARB_render_texture; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"ATI_", 4)) - { -#ifdef WGL_ATI_pixel_format_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format_float", 18)) - { - ret = WGLEW_ATI_pixel_format_float; - continue; - } -#endif -#ifdef WGL_ATI_render_texture_rectangle - if (_glewStrSame3(&pos, &len, (const GLubyte*)"render_texture_rectangle", 24)) - { - ret = WGLEW_ATI_render_texture_rectangle; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"EXT_", 4)) - { -#ifdef WGL_EXT_depth_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"depth_float", 11)) - { - ret = WGLEW_EXT_depth_float; - continue; - } -#endif -#ifdef WGL_EXT_display_color_table - if (_glewStrSame3(&pos, &len, (const GLubyte*)"display_color_table", 19)) - { - ret = WGLEW_EXT_display_color_table; - continue; - } -#endif -#ifdef WGL_EXT_extensions_string - if (_glewStrSame3(&pos, &len, (const GLubyte*)"extensions_string", 17)) - { - ret = WGLEW_EXT_extensions_string; - continue; - } -#endif -#ifdef WGL_EXT_framebuffer_sRGB - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) - { - ret = WGLEW_EXT_framebuffer_sRGB; - continue; - } -#endif -#ifdef WGL_EXT_make_current_read - if (_glewStrSame3(&pos, &len, (const GLubyte*)"make_current_read", 17)) - { - ret = WGLEW_EXT_make_current_read; - continue; - } -#endif -#ifdef WGL_EXT_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = WGLEW_EXT_multisample; - continue; - } -#endif -#ifdef WGL_EXT_pbuffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pbuffer", 7)) - { - ret = WGLEW_EXT_pbuffer; - continue; - } -#endif -#ifdef WGL_EXT_pixel_format - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format", 12)) - { - ret = WGLEW_EXT_pixel_format; - continue; - } -#endif -#ifdef WGL_EXT_pixel_format_packed_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format_packed_float", 25)) - { - ret = WGLEW_EXT_pixel_format_packed_float; - continue; - } -#endif -#ifdef WGL_EXT_swap_control - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_control", 12)) - { - ret = WGLEW_EXT_swap_control; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"I3D_", 4)) - { -#ifdef WGL_I3D_digital_video_control - if (_glewStrSame3(&pos, &len, (const GLubyte*)"digital_video_control", 21)) - { - ret = WGLEW_I3D_digital_video_control; - continue; - } -#endif -#ifdef WGL_I3D_gamma - if (_glewStrSame3(&pos, &len, (const GLubyte*)"gamma", 5)) - { - ret = WGLEW_I3D_gamma; - continue; - } -#endif -#ifdef WGL_I3D_genlock - if (_glewStrSame3(&pos, &len, (const GLubyte*)"genlock", 7)) - { - ret = WGLEW_I3D_genlock; - continue; - } -#endif -#ifdef WGL_I3D_image_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"image_buffer", 12)) - { - ret = WGLEW_I3D_image_buffer; - continue; - } -#endif -#ifdef WGL_I3D_swap_frame_lock - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_frame_lock", 15)) - { - ret = WGLEW_I3D_swap_frame_lock; - continue; - } -#endif -#ifdef WGL_I3D_swap_frame_usage - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_frame_usage", 16)) - { - ret = WGLEW_I3D_swap_frame_usage; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"NV_", 3)) - { -#ifdef WGL_NV_float_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"float_buffer", 12)) - { - ret = WGLEW_NV_float_buffer; - continue; - } -#endif -#ifdef WGL_NV_gpu_affinity - if (_glewStrSame3(&pos, &len, (const GLubyte*)"gpu_affinity", 12)) - { - ret = WGLEW_NV_gpu_affinity; - continue; - } -#endif -#ifdef WGL_NV_present_video - if (_glewStrSame3(&pos, &len, (const GLubyte*)"present_video", 13)) - { - ret = WGLEW_NV_present_video; - continue; - } -#endif -#ifdef WGL_NV_render_depth_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"render_depth_texture", 20)) - { - ret = WGLEW_NV_render_depth_texture; - continue; - } -#endif -#ifdef WGL_NV_render_texture_rectangle - if (_glewStrSame3(&pos, &len, (const GLubyte*)"render_texture_rectangle", 24)) - { - ret = WGLEW_NV_render_texture_rectangle; - continue; - } -#endif -#ifdef WGL_NV_swap_group - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_group", 10)) - { - ret = WGLEW_NV_swap_group; - continue; - } -#endif -#ifdef WGL_NV_vertex_array_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_range", 18)) - { - ret = WGLEW_NV_vertex_array_range; - continue; - } -#endif -#ifdef WGL_NV_video_output - if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_output", 12)) - { - ret = WGLEW_NV_video_output; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"OML_", 4)) - { -#ifdef WGL_OML_sync_control - if (_glewStrSame3(&pos, &len, (const GLubyte*)"sync_control", 12)) - { - ret = WGLEW_OML_sync_control; - continue; - } -#endif - } - } - ret = (len == 0); - } - return ret; -} - -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) - -#if defined(GLEW_MX) -GLboolean glxewContextIsSupported (GLXEWContext* ctx, const char* name) -#else -GLboolean glxewIsSupported (const char* name) -#endif -{ - GLubyte* pos = (GLubyte*)name; - GLuint len = _glewStrLen(pos); - GLboolean ret = GL_TRUE; - while (ret && len > 0) - { - if(_glewStrSame1(&pos, &len, (const GLubyte*)"GLX_", 4)) - { - if (_glewStrSame2(&pos, &len, (const GLubyte*)"VERSION_", 8)) - { -#ifdef GLX_VERSION_1_2 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_2", 3)) - { - ret = GLXEW_VERSION_1_2; - continue; - } -#endif -#ifdef GLX_VERSION_1_3 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_3", 3)) - { - ret = GLXEW_VERSION_1_3; - continue; - } -#endif -#ifdef GLX_VERSION_1_4 - if (_glewStrSame3(&pos, &len, (const GLubyte*)"1_4", 3)) - { - ret = GLXEW_VERSION_1_4; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"3DFX_", 5)) - { -#ifdef GLX_3DFX_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = GLXEW_3DFX_multisample; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"ARB_", 4)) - { -#ifdef GLX_ARB_create_context - if (_glewStrSame3(&pos, &len, (const GLubyte*)"create_context", 14)) - { - ret = GLXEW_ARB_create_context; - continue; - } -#endif -#ifdef GLX_ARB_fbconfig_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fbconfig_float", 14)) - { - ret = GLXEW_ARB_fbconfig_float; - continue; - } -#endif -#ifdef GLX_ARB_framebuffer_sRGB - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) - { - ret = GLXEW_ARB_framebuffer_sRGB; - continue; - } -#endif -#ifdef GLX_ARB_get_proc_address - if (_glewStrSame3(&pos, &len, (const GLubyte*)"get_proc_address", 16)) - { - ret = GLXEW_ARB_get_proc_address; - continue; - } -#endif -#ifdef GLX_ARB_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = GLXEW_ARB_multisample; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"ATI_", 4)) - { -#ifdef GLX_ATI_pixel_format_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixel_format_float", 18)) - { - ret = GLXEW_ATI_pixel_format_float; - continue; - } -#endif -#ifdef GLX_ATI_render_texture - if (_glewStrSame3(&pos, &len, (const GLubyte*)"render_texture", 14)) - { - ret = GLXEW_ATI_render_texture; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"EXT_", 4)) - { -#ifdef GLX_EXT_fbconfig_packed_float - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fbconfig_packed_float", 21)) - { - ret = GLXEW_EXT_fbconfig_packed_float; - continue; - } -#endif -#ifdef GLX_EXT_framebuffer_sRGB - if (_glewStrSame3(&pos, &len, (const GLubyte*)"framebuffer_sRGB", 16)) - { - ret = GLXEW_EXT_framebuffer_sRGB; - continue; - } -#endif -#ifdef GLX_EXT_import_context - if (_glewStrSame3(&pos, &len, (const GLubyte*)"import_context", 14)) - { - ret = GLXEW_EXT_import_context; - continue; - } -#endif -#ifdef GLX_EXT_scene_marker - if (_glewStrSame3(&pos, &len, (const GLubyte*)"scene_marker", 12)) - { - ret = GLXEW_EXT_scene_marker; - continue; - } -#endif -#ifdef GLX_EXT_texture_from_pixmap - if (_glewStrSame3(&pos, &len, (const GLubyte*)"texture_from_pixmap", 19)) - { - ret = GLXEW_EXT_texture_from_pixmap; - continue; - } -#endif -#ifdef GLX_EXT_visual_info - if (_glewStrSame3(&pos, &len, (const GLubyte*)"visual_info", 11)) - { - ret = GLXEW_EXT_visual_info; - continue; - } -#endif -#ifdef GLX_EXT_visual_rating - if (_glewStrSame3(&pos, &len, (const GLubyte*)"visual_rating", 13)) - { - ret = GLXEW_EXT_visual_rating; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"MESA_", 5)) - { -#ifdef GLX_MESA_agp_offset - if (_glewStrSame3(&pos, &len, (const GLubyte*)"agp_offset", 10)) - { - ret = GLXEW_MESA_agp_offset; - continue; - } -#endif -#ifdef GLX_MESA_copy_sub_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"copy_sub_buffer", 15)) - { - ret = GLXEW_MESA_copy_sub_buffer; - continue; - } -#endif -#ifdef GLX_MESA_pixmap_colormap - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pixmap_colormap", 15)) - { - ret = GLXEW_MESA_pixmap_colormap; - continue; - } -#endif -#ifdef GLX_MESA_release_buffers - if (_glewStrSame3(&pos, &len, (const GLubyte*)"release_buffers", 15)) - { - ret = GLXEW_MESA_release_buffers; - continue; - } -#endif -#ifdef GLX_MESA_set_3dfx_mode - if (_glewStrSame3(&pos, &len, (const GLubyte*)"set_3dfx_mode", 13)) - { - ret = GLXEW_MESA_set_3dfx_mode; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"NV_", 3)) - { -#ifdef GLX_NV_float_buffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"float_buffer", 12)) - { - ret = GLXEW_NV_float_buffer; - continue; - } -#endif -#ifdef GLX_NV_present_video - if (_glewStrSame3(&pos, &len, (const GLubyte*)"present_video", 13)) - { - ret = GLXEW_NV_present_video; - continue; - } -#endif -#ifdef GLX_NV_swap_group - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_group", 10)) - { - ret = GLXEW_NV_swap_group; - continue; - } -#endif -#ifdef GLX_NV_vertex_array_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"vertex_array_range", 18)) - { - ret = GLXEW_NV_vertex_array_range; - continue; - } -#endif -#ifdef GLX_NV_video_output - if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_output", 12)) - { - ret = GLXEW_NV_video_output; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"OML_", 4)) - { -#ifdef GLX_OML_swap_method - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_method", 11)) - { - ret = GLXEW_OML_swap_method; - continue; - } -#endif -#if defined(GLX_OML_sync_control) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -#include - if (_glewStrSame3(&pos, &len, (const GLubyte*)"sync_control", 12)) - { - ret = GLXEW_OML_sync_control; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGIS_", 5)) - { -#ifdef GLX_SGIS_blended_overlay - if (_glewStrSame3(&pos, &len, (const GLubyte*)"blended_overlay", 15)) - { - ret = GLXEW_SGIS_blended_overlay; - continue; - } -#endif -#ifdef GLX_SGIS_color_range - if (_glewStrSame3(&pos, &len, (const GLubyte*)"color_range", 11)) - { - ret = GLXEW_SGIS_color_range; - continue; - } -#endif -#ifdef GLX_SGIS_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"multisample", 11)) - { - ret = GLXEW_SGIS_multisample; - continue; - } -#endif -#ifdef GLX_SGIS_shared_multisample - if (_glewStrSame3(&pos, &len, (const GLubyte*)"shared_multisample", 18)) - { - ret = GLXEW_SGIS_shared_multisample; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGIX_", 5)) - { -#ifdef GLX_SGIX_fbconfig - if (_glewStrSame3(&pos, &len, (const GLubyte*)"fbconfig", 8)) - { - ret = GLXEW_SGIX_fbconfig; - continue; - } -#endif -#ifdef GLX_SGIX_hyperpipe - if (_glewStrSame3(&pos, &len, (const GLubyte*)"hyperpipe", 9)) - { - ret = GLXEW_SGIX_hyperpipe; - continue; - } -#endif -#ifdef GLX_SGIX_pbuffer - if (_glewStrSame3(&pos, &len, (const GLubyte*)"pbuffer", 7)) - { - ret = GLXEW_SGIX_pbuffer; - continue; - } -#endif -#ifdef GLX_SGIX_swap_barrier - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_barrier", 12)) - { - ret = GLXEW_SGIX_swap_barrier; - continue; - } -#endif -#ifdef GLX_SGIX_swap_group - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_group", 10)) - { - ret = GLXEW_SGIX_swap_group; - continue; - } -#endif -#ifdef GLX_SGIX_video_resize - if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_resize", 12)) - { - ret = GLXEW_SGIX_video_resize; - continue; - } -#endif -#ifdef GLX_SGIX_visual_select_group - if (_glewStrSame3(&pos, &len, (const GLubyte*)"visual_select_group", 19)) - { - ret = GLXEW_SGIX_visual_select_group; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SGI_", 4)) - { -#ifdef GLX_SGI_cushion - if (_glewStrSame3(&pos, &len, (const GLubyte*)"cushion", 7)) - { - ret = GLXEW_SGI_cushion; - continue; - } -#endif -#ifdef GLX_SGI_make_current_read - if (_glewStrSame3(&pos, &len, (const GLubyte*)"make_current_read", 17)) - { - ret = GLXEW_SGI_make_current_read; - continue; - } -#endif -#ifdef GLX_SGI_swap_control - if (_glewStrSame3(&pos, &len, (const GLubyte*)"swap_control", 12)) - { - ret = GLXEW_SGI_swap_control; - continue; - } -#endif -#ifdef GLX_SGI_video_sync - if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_sync", 10)) - { - ret = GLXEW_SGI_video_sync; - continue; - } -#endif - } - if (_glewStrSame2(&pos, &len, (const GLubyte*)"SUN_", 4)) - { -#ifdef GLX_SUN_get_transparent_index - if (_glewStrSame3(&pos, &len, (const GLubyte*)"get_transparent_index", 21)) - { - ret = GLXEW_SUN_get_transparent_index; - continue; - } -#endif -#ifdef GLX_SUN_video_resize - if (_glewStrSame3(&pos, &len, (const GLubyte*)"video_resize", 12)) - { - ret = GLXEW_SUN_video_resize; - continue; - } -#endif - } - } - ret = (len == 0); - } - return ret; -} - -#endif /* _WIN32 */ diff --git a/oversampling/WDL/lice/glew/src/glewinfo.c b/oversampling/WDL/lice/glew/src/glewinfo.c deleted file mode 100644 index 13c6d05..0000000 --- a/oversampling/WDL/lice/glew/src/glewinfo.c +++ /dev/null @@ -1,7180 +0,0 @@ -/* -** The OpenGL Extension Wrangler Library -** Copyright (C) 2002-2008, Milan Ikits -** Copyright (C) 2002-2008, Marcelo E. Magallon -** Copyright (C) 2002, Lev Povalahev -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** -** * Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** * The name of the author may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -** THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include -#include -#include -#include -#if defined(_WIN32) -#include -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) -#include -#endif - -static FILE* f; - -#ifdef GLEW_MX -GLEWContext _glewctx; -#define glewGetContext() (&_glewctx) -#ifdef _WIN32 -WGLEWContext _wglewctx; -#define wglewGetContext() (&_wglewctx) -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) -GLXEWContext _glxewctx; -#define glxewGetContext() (&_glxewctx) -#endif -#endif - -#if defined(_WIN32) -GLboolean glewCreateContext (int* pixelformat); -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) -GLboolean glewCreateContext (const char* display, int* visual); -#else -GLboolean glewCreateContext (); -#endif - -#if defined(_WIN32) || !defined(__APPLE__) || defined(GLEW_APPLE_GLX) -GLboolean glewParseArgs (int argc, char** argv, char** display, int* visual); -#endif - -void glewDestroyContext (); - -/* ------------------------------------------------------------------------- */ - -static void glewPrintExt (const char* name, GLboolean def1, GLboolean def2, GLboolean def3) -{ - unsigned int i; - fprintf(f, "\n%s:", name); - for (i=0; i<62-strlen(name); i++) fprintf(f, " "); - fprintf(f, "%s ", def1 ? "OK" : "MISSING"); - if (def1 != def2) - fprintf(f, "[%s] ", def2 ? "OK" : "MISSING"); - if (def1 != def3) - fprintf(f, "[%s]\n", def3 ? "OK" : "MISSING"); - else - fprintf(f, "\n"); - for (i=0; i= 199901L) -#include - -static void _glewInfo_GLX_OML_sync_control (void) -{ - glewPrintExt("GLX_OML_sync_control", GLXEW_OML_sync_control, glxewIsSupported("GLX_OML_sync_control"), glxewGetExtension("GLX_OML_sync_control")); - - glewInfoFunc("glXGetMscRateOML", glXGetMscRateOML == NULL); - glewInfoFunc("glXGetSyncValuesOML", glXGetSyncValuesOML == NULL); - glewInfoFunc("glXSwapBuffersMscOML", glXSwapBuffersMscOML == NULL); - glewInfoFunc("glXWaitForMscOML", glXWaitForMscOML == NULL); - glewInfoFunc("glXWaitForSbcOML", glXWaitForSbcOML == NULL); -} - -#endif /* GLX_OML_sync_control */ - -#ifdef GLX_SGIS_blended_overlay - -static void _glewInfo_GLX_SGIS_blended_overlay (void) -{ - glewPrintExt("GLX_SGIS_blended_overlay", GLXEW_SGIS_blended_overlay, glxewIsSupported("GLX_SGIS_blended_overlay"), glxewGetExtension("GLX_SGIS_blended_overlay")); -} - -#endif /* GLX_SGIS_blended_overlay */ - -#ifdef GLX_SGIS_color_range - -static void _glewInfo_GLX_SGIS_color_range (void) -{ - glewPrintExt("GLX_SGIS_color_range", GLXEW_SGIS_color_range, glxewIsSupported("GLX_SGIS_color_range"), glxewGetExtension("GLX_SGIS_color_range")); -} - -#endif /* GLX_SGIS_color_range */ - -#ifdef GLX_SGIS_multisample - -static void _glewInfo_GLX_SGIS_multisample (void) -{ - glewPrintExt("GLX_SGIS_multisample", GLXEW_SGIS_multisample, glxewIsSupported("GLX_SGIS_multisample"), glxewGetExtension("GLX_SGIS_multisample")); -} - -#endif /* GLX_SGIS_multisample */ - -#ifdef GLX_SGIS_shared_multisample - -static void _glewInfo_GLX_SGIS_shared_multisample (void) -{ - glewPrintExt("GLX_SGIS_shared_multisample", GLXEW_SGIS_shared_multisample, glxewIsSupported("GLX_SGIS_shared_multisample"), glxewGetExtension("GLX_SGIS_shared_multisample")); -} - -#endif /* GLX_SGIS_shared_multisample */ - -#ifdef GLX_SGIX_fbconfig - -static void _glewInfo_GLX_SGIX_fbconfig (void) -{ - glewPrintExt("GLX_SGIX_fbconfig", GLXEW_SGIX_fbconfig, glxewIsSupported("GLX_SGIX_fbconfig"), glxewGetExtension("GLX_SGIX_fbconfig")); - - glewInfoFunc("glXChooseFBConfigSGIX", glXChooseFBConfigSGIX == NULL); - glewInfoFunc("glXCreateContextWithConfigSGIX", glXCreateContextWithConfigSGIX == NULL); - glewInfoFunc("glXCreateGLXPixmapWithConfigSGIX", glXCreateGLXPixmapWithConfigSGIX == NULL); - glewInfoFunc("glXGetFBConfigAttribSGIX", glXGetFBConfigAttribSGIX == NULL); - glewInfoFunc("glXGetFBConfigFromVisualSGIX", glXGetFBConfigFromVisualSGIX == NULL); - glewInfoFunc("glXGetVisualFromFBConfigSGIX", glXGetVisualFromFBConfigSGIX == NULL); -} - -#endif /* GLX_SGIX_fbconfig */ - -#ifdef GLX_SGIX_hyperpipe - -static void _glewInfo_GLX_SGIX_hyperpipe (void) -{ - glewPrintExt("GLX_SGIX_hyperpipe", GLXEW_SGIX_hyperpipe, glxewIsSupported("GLX_SGIX_hyperpipe"), glxewGetExtension("GLX_SGIX_hyperpipe")); - - glewInfoFunc("glXBindHyperpipeSGIX", glXBindHyperpipeSGIX == NULL); - glewInfoFunc("glXDestroyHyperpipeConfigSGIX", glXDestroyHyperpipeConfigSGIX == NULL); - glewInfoFunc("glXHyperpipeAttribSGIX", glXHyperpipeAttribSGIX == NULL); - glewInfoFunc("glXHyperpipeConfigSGIX", glXHyperpipeConfigSGIX == NULL); - glewInfoFunc("glXQueryHyperpipeAttribSGIX", glXQueryHyperpipeAttribSGIX == NULL); - glewInfoFunc("glXQueryHyperpipeBestAttribSGIX", glXQueryHyperpipeBestAttribSGIX == NULL); - glewInfoFunc("glXQueryHyperpipeConfigSGIX", glXQueryHyperpipeConfigSGIX == NULL); - glewInfoFunc("glXQueryHyperpipeNetworkSGIX", glXQueryHyperpipeNetworkSGIX == NULL); -} - -#endif /* GLX_SGIX_hyperpipe */ - -#ifdef GLX_SGIX_pbuffer - -static void _glewInfo_GLX_SGIX_pbuffer (void) -{ - glewPrintExt("GLX_SGIX_pbuffer", GLXEW_SGIX_pbuffer, glxewIsSupported("GLX_SGIX_pbuffer"), glxewGetExtension("GLX_SGIX_pbuffer")); - - glewInfoFunc("glXCreateGLXPbufferSGIX", glXCreateGLXPbufferSGIX == NULL); - glewInfoFunc("glXDestroyGLXPbufferSGIX", glXDestroyGLXPbufferSGIX == NULL); - glewInfoFunc("glXGetSelectedEventSGIX", glXGetSelectedEventSGIX == NULL); - glewInfoFunc("glXQueryGLXPbufferSGIX", glXQueryGLXPbufferSGIX == NULL); - glewInfoFunc("glXSelectEventSGIX", glXSelectEventSGIX == NULL); -} - -#endif /* GLX_SGIX_pbuffer */ - -#ifdef GLX_SGIX_swap_barrier - -static void _glewInfo_GLX_SGIX_swap_barrier (void) -{ - glewPrintExt("GLX_SGIX_swap_barrier", GLXEW_SGIX_swap_barrier, glxewIsSupported("GLX_SGIX_swap_barrier"), glxewGetExtension("GLX_SGIX_swap_barrier")); - - glewInfoFunc("glXBindSwapBarrierSGIX", glXBindSwapBarrierSGIX == NULL); - glewInfoFunc("glXQueryMaxSwapBarriersSGIX", glXQueryMaxSwapBarriersSGIX == NULL); -} - -#endif /* GLX_SGIX_swap_barrier */ - -#ifdef GLX_SGIX_swap_group - -static void _glewInfo_GLX_SGIX_swap_group (void) -{ - glewPrintExt("GLX_SGIX_swap_group", GLXEW_SGIX_swap_group, glxewIsSupported("GLX_SGIX_swap_group"), glxewGetExtension("GLX_SGIX_swap_group")); - - glewInfoFunc("glXJoinSwapGroupSGIX", glXJoinSwapGroupSGIX == NULL); -} - -#endif /* GLX_SGIX_swap_group */ - -#ifdef GLX_SGIX_video_resize - -static void _glewInfo_GLX_SGIX_video_resize (void) -{ - glewPrintExt("GLX_SGIX_video_resize", GLXEW_SGIX_video_resize, glxewIsSupported("GLX_SGIX_video_resize"), glxewGetExtension("GLX_SGIX_video_resize")); - - glewInfoFunc("glXBindChannelToWindowSGIX", glXBindChannelToWindowSGIX == NULL); - glewInfoFunc("glXChannelRectSGIX", glXChannelRectSGIX == NULL); - glewInfoFunc("glXChannelRectSyncSGIX", glXChannelRectSyncSGIX == NULL); - glewInfoFunc("glXQueryChannelDeltasSGIX", glXQueryChannelDeltasSGIX == NULL); - glewInfoFunc("glXQueryChannelRectSGIX", glXQueryChannelRectSGIX == NULL); -} - -#endif /* GLX_SGIX_video_resize */ - -#ifdef GLX_SGIX_visual_select_group - -static void _glewInfo_GLX_SGIX_visual_select_group (void) -{ - glewPrintExt("GLX_SGIX_visual_select_group", GLXEW_SGIX_visual_select_group, glxewIsSupported("GLX_SGIX_visual_select_group"), glxewGetExtension("GLX_SGIX_visual_select_group")); -} - -#endif /* GLX_SGIX_visual_select_group */ - -#ifdef GLX_SGI_cushion - -static void _glewInfo_GLX_SGI_cushion (void) -{ - glewPrintExt("GLX_SGI_cushion", GLXEW_SGI_cushion, glxewIsSupported("GLX_SGI_cushion"), glxewGetExtension("GLX_SGI_cushion")); - - glewInfoFunc("glXCushionSGI", glXCushionSGI == NULL); -} - -#endif /* GLX_SGI_cushion */ - -#ifdef GLX_SGI_make_current_read - -static void _glewInfo_GLX_SGI_make_current_read (void) -{ - glewPrintExt("GLX_SGI_make_current_read", GLXEW_SGI_make_current_read, glxewIsSupported("GLX_SGI_make_current_read"), glxewGetExtension("GLX_SGI_make_current_read")); - - glewInfoFunc("glXGetCurrentReadDrawableSGI", glXGetCurrentReadDrawableSGI == NULL); - glewInfoFunc("glXMakeCurrentReadSGI", glXMakeCurrentReadSGI == NULL); -} - -#endif /* GLX_SGI_make_current_read */ - -#ifdef GLX_SGI_swap_control - -static void _glewInfo_GLX_SGI_swap_control (void) -{ - glewPrintExt("GLX_SGI_swap_control", GLXEW_SGI_swap_control, glxewIsSupported("GLX_SGI_swap_control"), glxewGetExtension("GLX_SGI_swap_control")); - - glewInfoFunc("glXSwapIntervalSGI", glXSwapIntervalSGI == NULL); -} - -#endif /* GLX_SGI_swap_control */ - -#ifdef GLX_SGI_video_sync - -static void _glewInfo_GLX_SGI_video_sync (void) -{ - glewPrintExt("GLX_SGI_video_sync", GLXEW_SGI_video_sync, glxewIsSupported("GLX_SGI_video_sync"), glxewGetExtension("GLX_SGI_video_sync")); - - glewInfoFunc("glXGetVideoSyncSGI", glXGetVideoSyncSGI == NULL); - glewInfoFunc("glXWaitVideoSyncSGI", glXWaitVideoSyncSGI == NULL); -} - -#endif /* GLX_SGI_video_sync */ - -#ifdef GLX_SUN_get_transparent_index - -static void _glewInfo_GLX_SUN_get_transparent_index (void) -{ - glewPrintExt("GLX_SUN_get_transparent_index", GLXEW_SUN_get_transparent_index, glxewIsSupported("GLX_SUN_get_transparent_index"), glxewGetExtension("GLX_SUN_get_transparent_index")); - - glewInfoFunc("glXGetTransparentIndexSUN", glXGetTransparentIndexSUN == NULL); -} - -#endif /* GLX_SUN_get_transparent_index */ - -#ifdef GLX_SUN_video_resize - -static void _glewInfo_GLX_SUN_video_resize (void) -{ - glewPrintExt("GLX_SUN_video_resize", GLXEW_SUN_video_resize, glxewIsSupported("GLX_SUN_video_resize"), glxewGetExtension("GLX_SUN_video_resize")); - - glewInfoFunc("glXGetVideoResizeSUN", glXGetVideoResizeSUN == NULL); - glewInfoFunc("glXVideoResizeSUN", glXVideoResizeSUN == NULL); -} - -#endif /* GLX_SUN_video_resize */ - -#endif /* _WIN32 */ - -/* ------------------------------------------------------------------------ */ - -static void glewInfo (void) -{ -#ifdef GL_VERSION_1_1 - _glewInfo_GL_VERSION_1_1(); -#endif /* GL_VERSION_1_1 */ -#ifdef GL_VERSION_1_2 - _glewInfo_GL_VERSION_1_2(); -#endif /* GL_VERSION_1_2 */ -#ifdef GL_VERSION_1_3 - _glewInfo_GL_VERSION_1_3(); -#endif /* GL_VERSION_1_3 */ -#ifdef GL_VERSION_1_4 - _glewInfo_GL_VERSION_1_4(); -#endif /* GL_VERSION_1_4 */ -#ifdef GL_VERSION_1_5 - _glewInfo_GL_VERSION_1_5(); -#endif /* GL_VERSION_1_5 */ -#ifdef GL_VERSION_2_0 - _glewInfo_GL_VERSION_2_0(); -#endif /* GL_VERSION_2_0 */ -#ifdef GL_VERSION_2_1 - _glewInfo_GL_VERSION_2_1(); -#endif /* GL_VERSION_2_1 */ -#ifdef GL_VERSION_3_0 - _glewInfo_GL_VERSION_3_0(); -#endif /* GL_VERSION_3_0 */ -#ifdef GL_3DFX_multisample - _glewInfo_GL_3DFX_multisample(); -#endif /* GL_3DFX_multisample */ -#ifdef GL_3DFX_tbuffer - _glewInfo_GL_3DFX_tbuffer(); -#endif /* GL_3DFX_tbuffer */ -#ifdef GL_3DFX_texture_compression_FXT1 - _glewInfo_GL_3DFX_texture_compression_FXT1(); -#endif /* GL_3DFX_texture_compression_FXT1 */ -#ifdef GL_APPLE_client_storage - _glewInfo_GL_APPLE_client_storage(); -#endif /* GL_APPLE_client_storage */ -#ifdef GL_APPLE_element_array - _glewInfo_GL_APPLE_element_array(); -#endif /* GL_APPLE_element_array */ -#ifdef GL_APPLE_fence - _glewInfo_GL_APPLE_fence(); -#endif /* GL_APPLE_fence */ -#ifdef GL_APPLE_float_pixels - _glewInfo_GL_APPLE_float_pixels(); -#endif /* GL_APPLE_float_pixels */ -#ifdef GL_APPLE_flush_buffer_range - _glewInfo_GL_APPLE_flush_buffer_range(); -#endif /* GL_APPLE_flush_buffer_range */ -#ifdef GL_APPLE_pixel_buffer - _glewInfo_GL_APPLE_pixel_buffer(); -#endif /* GL_APPLE_pixel_buffer */ -#ifdef GL_APPLE_specular_vector - _glewInfo_GL_APPLE_specular_vector(); -#endif /* GL_APPLE_specular_vector */ -#ifdef GL_APPLE_texture_range - _glewInfo_GL_APPLE_texture_range(); -#endif /* GL_APPLE_texture_range */ -#ifdef GL_APPLE_transform_hint - _glewInfo_GL_APPLE_transform_hint(); -#endif /* GL_APPLE_transform_hint */ -#ifdef GL_APPLE_vertex_array_object - _glewInfo_GL_APPLE_vertex_array_object(); -#endif /* GL_APPLE_vertex_array_object */ -#ifdef GL_APPLE_vertex_array_range - _glewInfo_GL_APPLE_vertex_array_range(); -#endif /* GL_APPLE_vertex_array_range */ -#ifdef GL_APPLE_ycbcr_422 - _glewInfo_GL_APPLE_ycbcr_422(); -#endif /* GL_APPLE_ycbcr_422 */ -#ifdef GL_ARB_color_buffer_float - _glewInfo_GL_ARB_color_buffer_float(); -#endif /* GL_ARB_color_buffer_float */ -#ifdef GL_ARB_depth_buffer_float - _glewInfo_GL_ARB_depth_buffer_float(); -#endif /* GL_ARB_depth_buffer_float */ -#ifdef GL_ARB_depth_texture - _glewInfo_GL_ARB_depth_texture(); -#endif /* GL_ARB_depth_texture */ -#ifdef GL_ARB_draw_buffers - _glewInfo_GL_ARB_draw_buffers(); -#endif /* GL_ARB_draw_buffers */ -#ifdef GL_ARB_draw_instanced - _glewInfo_GL_ARB_draw_instanced(); -#endif /* GL_ARB_draw_instanced */ -#ifdef GL_ARB_fragment_program - _glewInfo_GL_ARB_fragment_program(); -#endif /* GL_ARB_fragment_program */ -#ifdef GL_ARB_fragment_program_shadow - _glewInfo_GL_ARB_fragment_program_shadow(); -#endif /* GL_ARB_fragment_program_shadow */ -#ifdef GL_ARB_fragment_shader - _glewInfo_GL_ARB_fragment_shader(); -#endif /* GL_ARB_fragment_shader */ -#ifdef GL_ARB_framebuffer_object - _glewInfo_GL_ARB_framebuffer_object(); -#endif /* GL_ARB_framebuffer_object */ -#ifdef GL_ARB_framebuffer_sRGB - _glewInfo_GL_ARB_framebuffer_sRGB(); -#endif /* GL_ARB_framebuffer_sRGB */ -#ifdef GL_ARB_geometry_shader4 - _glewInfo_GL_ARB_geometry_shader4(); -#endif /* GL_ARB_geometry_shader4 */ -#ifdef GL_ARB_half_float_pixel - _glewInfo_GL_ARB_half_float_pixel(); -#endif /* GL_ARB_half_float_pixel */ -#ifdef GL_ARB_half_float_vertex - _glewInfo_GL_ARB_half_float_vertex(); -#endif /* GL_ARB_half_float_vertex */ -#ifdef GL_ARB_imaging - _glewInfo_GL_ARB_imaging(); -#endif /* GL_ARB_imaging */ -#ifdef GL_ARB_instanced_arrays - _glewInfo_GL_ARB_instanced_arrays(); -#endif /* GL_ARB_instanced_arrays */ -#ifdef GL_ARB_map_buffer_range - _glewInfo_GL_ARB_map_buffer_range(); -#endif /* GL_ARB_map_buffer_range */ -#ifdef GL_ARB_matrix_palette - _glewInfo_GL_ARB_matrix_palette(); -#endif /* GL_ARB_matrix_palette */ -#ifdef GL_ARB_multisample - _glewInfo_GL_ARB_multisample(); -#endif /* GL_ARB_multisample */ -#ifdef GL_ARB_multitexture - _glewInfo_GL_ARB_multitexture(); -#endif /* GL_ARB_multitexture */ -#ifdef GL_ARB_occlusion_query - _glewInfo_GL_ARB_occlusion_query(); -#endif /* GL_ARB_occlusion_query */ -#ifdef GL_ARB_pixel_buffer_object - _glewInfo_GL_ARB_pixel_buffer_object(); -#endif /* GL_ARB_pixel_buffer_object */ -#ifdef GL_ARB_point_parameters - _glewInfo_GL_ARB_point_parameters(); -#endif /* GL_ARB_point_parameters */ -#ifdef GL_ARB_point_sprite - _glewInfo_GL_ARB_point_sprite(); -#endif /* GL_ARB_point_sprite */ -#ifdef GL_ARB_shader_objects - _glewInfo_GL_ARB_shader_objects(); -#endif /* GL_ARB_shader_objects */ -#ifdef GL_ARB_shading_language_100 - _glewInfo_GL_ARB_shading_language_100(); -#endif /* GL_ARB_shading_language_100 */ -#ifdef GL_ARB_shadow - _glewInfo_GL_ARB_shadow(); -#endif /* GL_ARB_shadow */ -#ifdef GL_ARB_shadow_ambient - _glewInfo_GL_ARB_shadow_ambient(); -#endif /* GL_ARB_shadow_ambient */ -#ifdef GL_ARB_texture_border_clamp - _glewInfo_GL_ARB_texture_border_clamp(); -#endif /* GL_ARB_texture_border_clamp */ -#ifdef GL_ARB_texture_buffer_object - _glewInfo_GL_ARB_texture_buffer_object(); -#endif /* GL_ARB_texture_buffer_object */ -#ifdef GL_ARB_texture_compression - _glewInfo_GL_ARB_texture_compression(); -#endif /* GL_ARB_texture_compression */ -#ifdef GL_ARB_texture_compression_rgtc - _glewInfo_GL_ARB_texture_compression_rgtc(); -#endif /* GL_ARB_texture_compression_rgtc */ -#ifdef GL_ARB_texture_cube_map - _glewInfo_GL_ARB_texture_cube_map(); -#endif /* GL_ARB_texture_cube_map */ -#ifdef GL_ARB_texture_env_add - _glewInfo_GL_ARB_texture_env_add(); -#endif /* GL_ARB_texture_env_add */ -#ifdef GL_ARB_texture_env_combine - _glewInfo_GL_ARB_texture_env_combine(); -#endif /* GL_ARB_texture_env_combine */ -#ifdef GL_ARB_texture_env_crossbar - _glewInfo_GL_ARB_texture_env_crossbar(); -#endif /* GL_ARB_texture_env_crossbar */ -#ifdef GL_ARB_texture_env_dot3 - _glewInfo_GL_ARB_texture_env_dot3(); -#endif /* GL_ARB_texture_env_dot3 */ -#ifdef GL_ARB_texture_float - _glewInfo_GL_ARB_texture_float(); -#endif /* GL_ARB_texture_float */ -#ifdef GL_ARB_texture_mirrored_repeat - _glewInfo_GL_ARB_texture_mirrored_repeat(); -#endif /* GL_ARB_texture_mirrored_repeat */ -#ifdef GL_ARB_texture_non_power_of_two - _glewInfo_GL_ARB_texture_non_power_of_two(); -#endif /* GL_ARB_texture_non_power_of_two */ -#ifdef GL_ARB_texture_rectangle - _glewInfo_GL_ARB_texture_rectangle(); -#endif /* GL_ARB_texture_rectangle */ -#ifdef GL_ARB_texture_rg - _glewInfo_GL_ARB_texture_rg(); -#endif /* GL_ARB_texture_rg */ -#ifdef GL_ARB_transpose_matrix - _glewInfo_GL_ARB_transpose_matrix(); -#endif /* GL_ARB_transpose_matrix */ -#ifdef GL_ARB_vertex_array_object - _glewInfo_GL_ARB_vertex_array_object(); -#endif /* GL_ARB_vertex_array_object */ -#ifdef GL_ARB_vertex_blend - _glewInfo_GL_ARB_vertex_blend(); -#endif /* GL_ARB_vertex_blend */ -#ifdef GL_ARB_vertex_buffer_object - _glewInfo_GL_ARB_vertex_buffer_object(); -#endif /* GL_ARB_vertex_buffer_object */ -#ifdef GL_ARB_vertex_program - _glewInfo_GL_ARB_vertex_program(); -#endif /* GL_ARB_vertex_program */ -#ifdef GL_ARB_vertex_shader - _glewInfo_GL_ARB_vertex_shader(); -#endif /* GL_ARB_vertex_shader */ -#ifdef GL_ARB_window_pos - _glewInfo_GL_ARB_window_pos(); -#endif /* GL_ARB_window_pos */ -#ifdef GL_ATIX_point_sprites - _glewInfo_GL_ATIX_point_sprites(); -#endif /* GL_ATIX_point_sprites */ -#ifdef GL_ATIX_texture_env_combine3 - _glewInfo_GL_ATIX_texture_env_combine3(); -#endif /* GL_ATIX_texture_env_combine3 */ -#ifdef GL_ATIX_texture_env_route - _glewInfo_GL_ATIX_texture_env_route(); -#endif /* GL_ATIX_texture_env_route */ -#ifdef GL_ATIX_vertex_shader_output_point_size - _glewInfo_GL_ATIX_vertex_shader_output_point_size(); -#endif /* GL_ATIX_vertex_shader_output_point_size */ -#ifdef GL_ATI_draw_buffers - _glewInfo_GL_ATI_draw_buffers(); -#endif /* GL_ATI_draw_buffers */ -#ifdef GL_ATI_element_array - _glewInfo_GL_ATI_element_array(); -#endif /* GL_ATI_element_array */ -#ifdef GL_ATI_envmap_bumpmap - _glewInfo_GL_ATI_envmap_bumpmap(); -#endif /* GL_ATI_envmap_bumpmap */ -#ifdef GL_ATI_fragment_shader - _glewInfo_GL_ATI_fragment_shader(); -#endif /* GL_ATI_fragment_shader */ -#ifdef GL_ATI_map_object_buffer - _glewInfo_GL_ATI_map_object_buffer(); -#endif /* GL_ATI_map_object_buffer */ -#ifdef GL_ATI_pn_triangles - _glewInfo_GL_ATI_pn_triangles(); -#endif /* GL_ATI_pn_triangles */ -#ifdef GL_ATI_separate_stencil - _glewInfo_GL_ATI_separate_stencil(); -#endif /* GL_ATI_separate_stencil */ -#ifdef GL_ATI_shader_texture_lod - _glewInfo_GL_ATI_shader_texture_lod(); -#endif /* GL_ATI_shader_texture_lod */ -#ifdef GL_ATI_text_fragment_shader - _glewInfo_GL_ATI_text_fragment_shader(); -#endif /* GL_ATI_text_fragment_shader */ -#ifdef GL_ATI_texture_compression_3dc - _glewInfo_GL_ATI_texture_compression_3dc(); -#endif /* GL_ATI_texture_compression_3dc */ -#ifdef GL_ATI_texture_env_combine3 - _glewInfo_GL_ATI_texture_env_combine3(); -#endif /* GL_ATI_texture_env_combine3 */ -#ifdef GL_ATI_texture_float - _glewInfo_GL_ATI_texture_float(); -#endif /* GL_ATI_texture_float */ -#ifdef GL_ATI_texture_mirror_once - _glewInfo_GL_ATI_texture_mirror_once(); -#endif /* GL_ATI_texture_mirror_once */ -#ifdef GL_ATI_vertex_array_object - _glewInfo_GL_ATI_vertex_array_object(); -#endif /* GL_ATI_vertex_array_object */ -#ifdef GL_ATI_vertex_attrib_array_object - _glewInfo_GL_ATI_vertex_attrib_array_object(); -#endif /* GL_ATI_vertex_attrib_array_object */ -#ifdef GL_ATI_vertex_streams - _glewInfo_GL_ATI_vertex_streams(); -#endif /* GL_ATI_vertex_streams */ -#ifdef GL_EXT_422_pixels - _glewInfo_GL_EXT_422_pixels(); -#endif /* GL_EXT_422_pixels */ -#ifdef GL_EXT_Cg_shader - _glewInfo_GL_EXT_Cg_shader(); -#endif /* GL_EXT_Cg_shader */ -#ifdef GL_EXT_abgr - _glewInfo_GL_EXT_abgr(); -#endif /* GL_EXT_abgr */ -#ifdef GL_EXT_bgra - _glewInfo_GL_EXT_bgra(); -#endif /* GL_EXT_bgra */ -#ifdef GL_EXT_bindable_uniform - _glewInfo_GL_EXT_bindable_uniform(); -#endif /* GL_EXT_bindable_uniform */ -#ifdef GL_EXT_blend_color - _glewInfo_GL_EXT_blend_color(); -#endif /* GL_EXT_blend_color */ -#ifdef GL_EXT_blend_equation_separate - _glewInfo_GL_EXT_blend_equation_separate(); -#endif /* GL_EXT_blend_equation_separate */ -#ifdef GL_EXT_blend_func_separate - _glewInfo_GL_EXT_blend_func_separate(); -#endif /* GL_EXT_blend_func_separate */ -#ifdef GL_EXT_blend_logic_op - _glewInfo_GL_EXT_blend_logic_op(); -#endif /* GL_EXT_blend_logic_op */ -#ifdef GL_EXT_blend_minmax - _glewInfo_GL_EXT_blend_minmax(); -#endif /* GL_EXT_blend_minmax */ -#ifdef GL_EXT_blend_subtract - _glewInfo_GL_EXT_blend_subtract(); -#endif /* GL_EXT_blend_subtract */ -#ifdef GL_EXT_clip_volume_hint - _glewInfo_GL_EXT_clip_volume_hint(); -#endif /* GL_EXT_clip_volume_hint */ -#ifdef GL_EXT_cmyka - _glewInfo_GL_EXT_cmyka(); -#endif /* GL_EXT_cmyka */ -#ifdef GL_EXT_color_subtable - _glewInfo_GL_EXT_color_subtable(); -#endif /* GL_EXT_color_subtable */ -#ifdef GL_EXT_compiled_vertex_array - _glewInfo_GL_EXT_compiled_vertex_array(); -#endif /* GL_EXT_compiled_vertex_array */ -#ifdef GL_EXT_convolution - _glewInfo_GL_EXT_convolution(); -#endif /* GL_EXT_convolution */ -#ifdef GL_EXT_coordinate_frame - _glewInfo_GL_EXT_coordinate_frame(); -#endif /* GL_EXT_coordinate_frame */ -#ifdef GL_EXT_copy_texture - _glewInfo_GL_EXT_copy_texture(); -#endif /* GL_EXT_copy_texture */ -#ifdef GL_EXT_cull_vertex - _glewInfo_GL_EXT_cull_vertex(); -#endif /* GL_EXT_cull_vertex */ -#ifdef GL_EXT_depth_bounds_test - _glewInfo_GL_EXT_depth_bounds_test(); -#endif /* GL_EXT_depth_bounds_test */ -#ifdef GL_EXT_direct_state_access - _glewInfo_GL_EXT_direct_state_access(); -#endif /* GL_EXT_direct_state_access */ -#ifdef GL_EXT_draw_buffers2 - _glewInfo_GL_EXT_draw_buffers2(); -#endif /* GL_EXT_draw_buffers2 */ -#ifdef GL_EXT_draw_instanced - _glewInfo_GL_EXT_draw_instanced(); -#endif /* GL_EXT_draw_instanced */ -#ifdef GL_EXT_draw_range_elements - _glewInfo_GL_EXT_draw_range_elements(); -#endif /* GL_EXT_draw_range_elements */ -#ifdef GL_EXT_fog_coord - _glewInfo_GL_EXT_fog_coord(); -#endif /* GL_EXT_fog_coord */ -#ifdef GL_EXT_fragment_lighting - _glewInfo_GL_EXT_fragment_lighting(); -#endif /* GL_EXT_fragment_lighting */ -#ifdef GL_EXT_framebuffer_blit - _glewInfo_GL_EXT_framebuffer_blit(); -#endif /* GL_EXT_framebuffer_blit */ -#ifdef GL_EXT_framebuffer_multisample - _glewInfo_GL_EXT_framebuffer_multisample(); -#endif /* GL_EXT_framebuffer_multisample */ -#ifdef GL_EXT_framebuffer_object - _glewInfo_GL_EXT_framebuffer_object(); -#endif /* GL_EXT_framebuffer_object */ -#ifdef GL_EXT_framebuffer_sRGB - _glewInfo_GL_EXT_framebuffer_sRGB(); -#endif /* GL_EXT_framebuffer_sRGB */ -#ifdef GL_EXT_geometry_shader4 - _glewInfo_GL_EXT_geometry_shader4(); -#endif /* GL_EXT_geometry_shader4 */ -#ifdef GL_EXT_gpu_program_parameters - _glewInfo_GL_EXT_gpu_program_parameters(); -#endif /* GL_EXT_gpu_program_parameters */ -#ifdef GL_EXT_gpu_shader4 - _glewInfo_GL_EXT_gpu_shader4(); -#endif /* GL_EXT_gpu_shader4 */ -#ifdef GL_EXT_histogram - _glewInfo_GL_EXT_histogram(); -#endif /* GL_EXT_histogram */ -#ifdef GL_EXT_index_array_formats - _glewInfo_GL_EXT_index_array_formats(); -#endif /* GL_EXT_index_array_formats */ -#ifdef GL_EXT_index_func - _glewInfo_GL_EXT_index_func(); -#endif /* GL_EXT_index_func */ -#ifdef GL_EXT_index_material - _glewInfo_GL_EXT_index_material(); -#endif /* GL_EXT_index_material */ -#ifdef GL_EXT_index_texture - _glewInfo_GL_EXT_index_texture(); -#endif /* GL_EXT_index_texture */ -#ifdef GL_EXT_light_texture - _glewInfo_GL_EXT_light_texture(); -#endif /* GL_EXT_light_texture */ -#ifdef GL_EXT_misc_attribute - _glewInfo_GL_EXT_misc_attribute(); -#endif /* GL_EXT_misc_attribute */ -#ifdef GL_EXT_multi_draw_arrays - _glewInfo_GL_EXT_multi_draw_arrays(); -#endif /* GL_EXT_multi_draw_arrays */ -#ifdef GL_EXT_multisample - _glewInfo_GL_EXT_multisample(); -#endif /* GL_EXT_multisample */ -#ifdef GL_EXT_packed_depth_stencil - _glewInfo_GL_EXT_packed_depth_stencil(); -#endif /* GL_EXT_packed_depth_stencil */ -#ifdef GL_EXT_packed_float - _glewInfo_GL_EXT_packed_float(); -#endif /* GL_EXT_packed_float */ -#ifdef GL_EXT_packed_pixels - _glewInfo_GL_EXT_packed_pixels(); -#endif /* GL_EXT_packed_pixels */ -#ifdef GL_EXT_paletted_texture - _glewInfo_GL_EXT_paletted_texture(); -#endif /* GL_EXT_paletted_texture */ -#ifdef GL_EXT_pixel_buffer_object - _glewInfo_GL_EXT_pixel_buffer_object(); -#endif /* GL_EXT_pixel_buffer_object */ -#ifdef GL_EXT_pixel_transform - _glewInfo_GL_EXT_pixel_transform(); -#endif /* GL_EXT_pixel_transform */ -#ifdef GL_EXT_pixel_transform_color_table - _glewInfo_GL_EXT_pixel_transform_color_table(); -#endif /* GL_EXT_pixel_transform_color_table */ -#ifdef GL_EXT_point_parameters - _glewInfo_GL_EXT_point_parameters(); -#endif /* GL_EXT_point_parameters */ -#ifdef GL_EXT_polygon_offset - _glewInfo_GL_EXT_polygon_offset(); -#endif /* GL_EXT_polygon_offset */ -#ifdef GL_EXT_rescale_normal - _glewInfo_GL_EXT_rescale_normal(); -#endif /* GL_EXT_rescale_normal */ -#ifdef GL_EXT_scene_marker - _glewInfo_GL_EXT_scene_marker(); -#endif /* GL_EXT_scene_marker */ -#ifdef GL_EXT_secondary_color - _glewInfo_GL_EXT_secondary_color(); -#endif /* GL_EXT_secondary_color */ -#ifdef GL_EXT_separate_specular_color - _glewInfo_GL_EXT_separate_specular_color(); -#endif /* GL_EXT_separate_specular_color */ -#ifdef GL_EXT_shadow_funcs - _glewInfo_GL_EXT_shadow_funcs(); -#endif /* GL_EXT_shadow_funcs */ -#ifdef GL_EXT_shared_texture_palette - _glewInfo_GL_EXT_shared_texture_palette(); -#endif /* GL_EXT_shared_texture_palette */ -#ifdef GL_EXT_stencil_clear_tag - _glewInfo_GL_EXT_stencil_clear_tag(); -#endif /* GL_EXT_stencil_clear_tag */ -#ifdef GL_EXT_stencil_two_side - _glewInfo_GL_EXT_stencil_two_side(); -#endif /* GL_EXT_stencil_two_side */ -#ifdef GL_EXT_stencil_wrap - _glewInfo_GL_EXT_stencil_wrap(); -#endif /* GL_EXT_stencil_wrap */ -#ifdef GL_EXT_subtexture - _glewInfo_GL_EXT_subtexture(); -#endif /* GL_EXT_subtexture */ -#ifdef GL_EXT_texture - _glewInfo_GL_EXT_texture(); -#endif /* GL_EXT_texture */ -#ifdef GL_EXT_texture3D - _glewInfo_GL_EXT_texture3D(); -#endif /* GL_EXT_texture3D */ -#ifdef GL_EXT_texture_array - _glewInfo_GL_EXT_texture_array(); -#endif /* GL_EXT_texture_array */ -#ifdef GL_EXT_texture_buffer_object - _glewInfo_GL_EXT_texture_buffer_object(); -#endif /* GL_EXT_texture_buffer_object */ -#ifdef GL_EXT_texture_compression_dxt1 - _glewInfo_GL_EXT_texture_compression_dxt1(); -#endif /* GL_EXT_texture_compression_dxt1 */ -#ifdef GL_EXT_texture_compression_latc - _glewInfo_GL_EXT_texture_compression_latc(); -#endif /* GL_EXT_texture_compression_latc */ -#ifdef GL_EXT_texture_compression_rgtc - _glewInfo_GL_EXT_texture_compression_rgtc(); -#endif /* GL_EXT_texture_compression_rgtc */ -#ifdef GL_EXT_texture_compression_s3tc - _glewInfo_GL_EXT_texture_compression_s3tc(); -#endif /* GL_EXT_texture_compression_s3tc */ -#ifdef GL_EXT_texture_cube_map - _glewInfo_GL_EXT_texture_cube_map(); -#endif /* GL_EXT_texture_cube_map */ -#ifdef GL_EXT_texture_edge_clamp - _glewInfo_GL_EXT_texture_edge_clamp(); -#endif /* GL_EXT_texture_edge_clamp */ -#ifdef GL_EXT_texture_env - _glewInfo_GL_EXT_texture_env(); -#endif /* GL_EXT_texture_env */ -#ifdef GL_EXT_texture_env_add - _glewInfo_GL_EXT_texture_env_add(); -#endif /* GL_EXT_texture_env_add */ -#ifdef GL_EXT_texture_env_combine - _glewInfo_GL_EXT_texture_env_combine(); -#endif /* GL_EXT_texture_env_combine */ -#ifdef GL_EXT_texture_env_dot3 - _glewInfo_GL_EXT_texture_env_dot3(); -#endif /* GL_EXT_texture_env_dot3 */ -#ifdef GL_EXT_texture_filter_anisotropic - _glewInfo_GL_EXT_texture_filter_anisotropic(); -#endif /* GL_EXT_texture_filter_anisotropic */ -#ifdef GL_EXT_texture_integer - _glewInfo_GL_EXT_texture_integer(); -#endif /* GL_EXT_texture_integer */ -#ifdef GL_EXT_texture_lod_bias - _glewInfo_GL_EXT_texture_lod_bias(); -#endif /* GL_EXT_texture_lod_bias */ -#ifdef GL_EXT_texture_mirror_clamp - _glewInfo_GL_EXT_texture_mirror_clamp(); -#endif /* GL_EXT_texture_mirror_clamp */ -#ifdef GL_EXT_texture_object - _glewInfo_GL_EXT_texture_object(); -#endif /* GL_EXT_texture_object */ -#ifdef GL_EXT_texture_perturb_normal - _glewInfo_GL_EXT_texture_perturb_normal(); -#endif /* GL_EXT_texture_perturb_normal */ -#ifdef GL_EXT_texture_rectangle - _glewInfo_GL_EXT_texture_rectangle(); -#endif /* GL_EXT_texture_rectangle */ -#ifdef GL_EXT_texture_sRGB - _glewInfo_GL_EXT_texture_sRGB(); -#endif /* GL_EXT_texture_sRGB */ -#ifdef GL_EXT_texture_shared_exponent - _glewInfo_GL_EXT_texture_shared_exponent(); -#endif /* GL_EXT_texture_shared_exponent */ -#ifdef GL_EXT_texture_swizzle - _glewInfo_GL_EXT_texture_swizzle(); -#endif /* GL_EXT_texture_swizzle */ -#ifdef GL_EXT_timer_query - _glewInfo_GL_EXT_timer_query(); -#endif /* GL_EXT_timer_query */ -#ifdef GL_EXT_transform_feedback - _glewInfo_GL_EXT_transform_feedback(); -#endif /* GL_EXT_transform_feedback */ -#ifdef GL_EXT_vertex_array - _glewInfo_GL_EXT_vertex_array(); -#endif /* GL_EXT_vertex_array */ -#ifdef GL_EXT_vertex_array_bgra - _glewInfo_GL_EXT_vertex_array_bgra(); -#endif /* GL_EXT_vertex_array_bgra */ -#ifdef GL_EXT_vertex_shader - _glewInfo_GL_EXT_vertex_shader(); -#endif /* GL_EXT_vertex_shader */ -#ifdef GL_EXT_vertex_weighting - _glewInfo_GL_EXT_vertex_weighting(); -#endif /* GL_EXT_vertex_weighting */ -#ifdef GL_GREMEDY_frame_terminator - _glewInfo_GL_GREMEDY_frame_terminator(); -#endif /* GL_GREMEDY_frame_terminator */ -#ifdef GL_GREMEDY_string_marker - _glewInfo_GL_GREMEDY_string_marker(); -#endif /* GL_GREMEDY_string_marker */ -#ifdef GL_HP_convolution_border_modes - _glewInfo_GL_HP_convolution_border_modes(); -#endif /* GL_HP_convolution_border_modes */ -#ifdef GL_HP_image_transform - _glewInfo_GL_HP_image_transform(); -#endif /* GL_HP_image_transform */ -#ifdef GL_HP_occlusion_test - _glewInfo_GL_HP_occlusion_test(); -#endif /* GL_HP_occlusion_test */ -#ifdef GL_HP_texture_lighting - _glewInfo_GL_HP_texture_lighting(); -#endif /* GL_HP_texture_lighting */ -#ifdef GL_IBM_cull_vertex - _glewInfo_GL_IBM_cull_vertex(); -#endif /* GL_IBM_cull_vertex */ -#ifdef GL_IBM_multimode_draw_arrays - _glewInfo_GL_IBM_multimode_draw_arrays(); -#endif /* GL_IBM_multimode_draw_arrays */ -#ifdef GL_IBM_rasterpos_clip - _glewInfo_GL_IBM_rasterpos_clip(); -#endif /* GL_IBM_rasterpos_clip */ -#ifdef GL_IBM_static_data - _glewInfo_GL_IBM_static_data(); -#endif /* GL_IBM_static_data */ -#ifdef GL_IBM_texture_mirrored_repeat - _glewInfo_GL_IBM_texture_mirrored_repeat(); -#endif /* GL_IBM_texture_mirrored_repeat */ -#ifdef GL_IBM_vertex_array_lists - _glewInfo_GL_IBM_vertex_array_lists(); -#endif /* GL_IBM_vertex_array_lists */ -#ifdef GL_INGR_color_clamp - _glewInfo_GL_INGR_color_clamp(); -#endif /* GL_INGR_color_clamp */ -#ifdef GL_INGR_interlace_read - _glewInfo_GL_INGR_interlace_read(); -#endif /* GL_INGR_interlace_read */ -#ifdef GL_INTEL_parallel_arrays - _glewInfo_GL_INTEL_parallel_arrays(); -#endif /* GL_INTEL_parallel_arrays */ -#ifdef GL_INTEL_texture_scissor - _glewInfo_GL_INTEL_texture_scissor(); -#endif /* GL_INTEL_texture_scissor */ -#ifdef GL_KTX_buffer_region - _glewInfo_GL_KTX_buffer_region(); -#endif /* GL_KTX_buffer_region */ -#ifdef GL_MESAX_texture_stack - _glewInfo_GL_MESAX_texture_stack(); -#endif /* GL_MESAX_texture_stack */ -#ifdef GL_MESA_pack_invert - _glewInfo_GL_MESA_pack_invert(); -#endif /* GL_MESA_pack_invert */ -#ifdef GL_MESA_resize_buffers - _glewInfo_GL_MESA_resize_buffers(); -#endif /* GL_MESA_resize_buffers */ -#ifdef GL_MESA_window_pos - _glewInfo_GL_MESA_window_pos(); -#endif /* GL_MESA_window_pos */ -#ifdef GL_MESA_ycbcr_texture - _glewInfo_GL_MESA_ycbcr_texture(); -#endif /* GL_MESA_ycbcr_texture */ -#ifdef GL_NV_blend_square - _glewInfo_GL_NV_blend_square(); -#endif /* GL_NV_blend_square */ -#ifdef GL_NV_conditional_render - _glewInfo_GL_NV_conditional_render(); -#endif /* GL_NV_conditional_render */ -#ifdef GL_NV_copy_depth_to_color - _glewInfo_GL_NV_copy_depth_to_color(); -#endif /* GL_NV_copy_depth_to_color */ -#ifdef GL_NV_depth_buffer_float - _glewInfo_GL_NV_depth_buffer_float(); -#endif /* GL_NV_depth_buffer_float */ -#ifdef GL_NV_depth_clamp - _glewInfo_GL_NV_depth_clamp(); -#endif /* GL_NV_depth_clamp */ -#ifdef GL_NV_depth_range_unclamped - _glewInfo_GL_NV_depth_range_unclamped(); -#endif /* GL_NV_depth_range_unclamped */ -#ifdef GL_NV_evaluators - _glewInfo_GL_NV_evaluators(); -#endif /* GL_NV_evaluators */ -#ifdef GL_NV_explicit_multisample - _glewInfo_GL_NV_explicit_multisample(); -#endif /* GL_NV_explicit_multisample */ -#ifdef GL_NV_fence - _glewInfo_GL_NV_fence(); -#endif /* GL_NV_fence */ -#ifdef GL_NV_float_buffer - _glewInfo_GL_NV_float_buffer(); -#endif /* GL_NV_float_buffer */ -#ifdef GL_NV_fog_distance - _glewInfo_GL_NV_fog_distance(); -#endif /* GL_NV_fog_distance */ -#ifdef GL_NV_fragment_program - _glewInfo_GL_NV_fragment_program(); -#endif /* GL_NV_fragment_program */ -#ifdef GL_NV_fragment_program2 - _glewInfo_GL_NV_fragment_program2(); -#endif /* GL_NV_fragment_program2 */ -#ifdef GL_NV_fragment_program4 - _glewInfo_GL_NV_fragment_program4(); -#endif /* GL_NV_fragment_program4 */ -#ifdef GL_NV_fragment_program_option - _glewInfo_GL_NV_fragment_program_option(); -#endif /* GL_NV_fragment_program_option */ -#ifdef GL_NV_framebuffer_multisample_coverage - _glewInfo_GL_NV_framebuffer_multisample_coverage(); -#endif /* GL_NV_framebuffer_multisample_coverage */ -#ifdef GL_NV_geometry_program4 - _glewInfo_GL_NV_geometry_program4(); -#endif /* GL_NV_geometry_program4 */ -#ifdef GL_NV_geometry_shader4 - _glewInfo_GL_NV_geometry_shader4(); -#endif /* GL_NV_geometry_shader4 */ -#ifdef GL_NV_gpu_program4 - _glewInfo_GL_NV_gpu_program4(); -#endif /* GL_NV_gpu_program4 */ -#ifdef GL_NV_half_float - _glewInfo_GL_NV_half_float(); -#endif /* GL_NV_half_float */ -#ifdef GL_NV_light_max_exponent - _glewInfo_GL_NV_light_max_exponent(); -#endif /* GL_NV_light_max_exponent */ -#ifdef GL_NV_multisample_filter_hint - _glewInfo_GL_NV_multisample_filter_hint(); -#endif /* GL_NV_multisample_filter_hint */ -#ifdef GL_NV_occlusion_query - _glewInfo_GL_NV_occlusion_query(); -#endif /* GL_NV_occlusion_query */ -#ifdef GL_NV_packed_depth_stencil - _glewInfo_GL_NV_packed_depth_stencil(); -#endif /* GL_NV_packed_depth_stencil */ -#ifdef GL_NV_parameter_buffer_object - _glewInfo_GL_NV_parameter_buffer_object(); -#endif /* GL_NV_parameter_buffer_object */ -#ifdef GL_NV_pixel_data_range - _glewInfo_GL_NV_pixel_data_range(); -#endif /* GL_NV_pixel_data_range */ -#ifdef GL_NV_point_sprite - _glewInfo_GL_NV_point_sprite(); -#endif /* GL_NV_point_sprite */ -#ifdef GL_NV_present_video - _glewInfo_GL_NV_present_video(); -#endif /* GL_NV_present_video */ -#ifdef GL_NV_primitive_restart - _glewInfo_GL_NV_primitive_restart(); -#endif /* GL_NV_primitive_restart */ -#ifdef GL_NV_register_combiners - _glewInfo_GL_NV_register_combiners(); -#endif /* GL_NV_register_combiners */ -#ifdef GL_NV_register_combiners2 - _glewInfo_GL_NV_register_combiners2(); -#endif /* GL_NV_register_combiners2 */ -#ifdef GL_NV_texgen_emboss - _glewInfo_GL_NV_texgen_emboss(); -#endif /* GL_NV_texgen_emboss */ -#ifdef GL_NV_texgen_reflection - _glewInfo_GL_NV_texgen_reflection(); -#endif /* GL_NV_texgen_reflection */ -#ifdef GL_NV_texture_compression_vtc - _glewInfo_GL_NV_texture_compression_vtc(); -#endif /* GL_NV_texture_compression_vtc */ -#ifdef GL_NV_texture_env_combine4 - _glewInfo_GL_NV_texture_env_combine4(); -#endif /* GL_NV_texture_env_combine4 */ -#ifdef GL_NV_texture_expand_normal - _glewInfo_GL_NV_texture_expand_normal(); -#endif /* GL_NV_texture_expand_normal */ -#ifdef GL_NV_texture_rectangle - _glewInfo_GL_NV_texture_rectangle(); -#endif /* GL_NV_texture_rectangle */ -#ifdef GL_NV_texture_shader - _glewInfo_GL_NV_texture_shader(); -#endif /* GL_NV_texture_shader */ -#ifdef GL_NV_texture_shader2 - _glewInfo_GL_NV_texture_shader2(); -#endif /* GL_NV_texture_shader2 */ -#ifdef GL_NV_texture_shader3 - _glewInfo_GL_NV_texture_shader3(); -#endif /* GL_NV_texture_shader3 */ -#ifdef GL_NV_transform_feedback - _glewInfo_GL_NV_transform_feedback(); -#endif /* GL_NV_transform_feedback */ -#ifdef GL_NV_vertex_array_range - _glewInfo_GL_NV_vertex_array_range(); -#endif /* GL_NV_vertex_array_range */ -#ifdef GL_NV_vertex_array_range2 - _glewInfo_GL_NV_vertex_array_range2(); -#endif /* GL_NV_vertex_array_range2 */ -#ifdef GL_NV_vertex_program - _glewInfo_GL_NV_vertex_program(); -#endif /* GL_NV_vertex_program */ -#ifdef GL_NV_vertex_program1_1 - _glewInfo_GL_NV_vertex_program1_1(); -#endif /* GL_NV_vertex_program1_1 */ -#ifdef GL_NV_vertex_program2 - _glewInfo_GL_NV_vertex_program2(); -#endif /* GL_NV_vertex_program2 */ -#ifdef GL_NV_vertex_program2_option - _glewInfo_GL_NV_vertex_program2_option(); -#endif /* GL_NV_vertex_program2_option */ -#ifdef GL_NV_vertex_program3 - _glewInfo_GL_NV_vertex_program3(); -#endif /* GL_NV_vertex_program3 */ -#ifdef GL_NV_vertex_program4 - _glewInfo_GL_NV_vertex_program4(); -#endif /* GL_NV_vertex_program4 */ -#ifdef GL_OES_byte_coordinates - _glewInfo_GL_OES_byte_coordinates(); -#endif /* GL_OES_byte_coordinates */ -#ifdef GL_OES_compressed_paletted_texture - _glewInfo_GL_OES_compressed_paletted_texture(); -#endif /* GL_OES_compressed_paletted_texture */ -#ifdef GL_OES_read_format - _glewInfo_GL_OES_read_format(); -#endif /* GL_OES_read_format */ -#ifdef GL_OES_single_precision - _glewInfo_GL_OES_single_precision(); -#endif /* GL_OES_single_precision */ -#ifdef GL_OML_interlace - _glewInfo_GL_OML_interlace(); -#endif /* GL_OML_interlace */ -#ifdef GL_OML_resample - _glewInfo_GL_OML_resample(); -#endif /* GL_OML_resample */ -#ifdef GL_OML_subsample - _glewInfo_GL_OML_subsample(); -#endif /* GL_OML_subsample */ -#ifdef GL_PGI_misc_hints - _glewInfo_GL_PGI_misc_hints(); -#endif /* GL_PGI_misc_hints */ -#ifdef GL_PGI_vertex_hints - _glewInfo_GL_PGI_vertex_hints(); -#endif /* GL_PGI_vertex_hints */ -#ifdef GL_REND_screen_coordinates - _glewInfo_GL_REND_screen_coordinates(); -#endif /* GL_REND_screen_coordinates */ -#ifdef GL_S3_s3tc - _glewInfo_GL_S3_s3tc(); -#endif /* GL_S3_s3tc */ -#ifdef GL_SGIS_color_range - _glewInfo_GL_SGIS_color_range(); -#endif /* GL_SGIS_color_range */ -#ifdef GL_SGIS_detail_texture - _glewInfo_GL_SGIS_detail_texture(); -#endif /* GL_SGIS_detail_texture */ -#ifdef GL_SGIS_fog_function - _glewInfo_GL_SGIS_fog_function(); -#endif /* GL_SGIS_fog_function */ -#ifdef GL_SGIS_generate_mipmap - _glewInfo_GL_SGIS_generate_mipmap(); -#endif /* GL_SGIS_generate_mipmap */ -#ifdef GL_SGIS_multisample - _glewInfo_GL_SGIS_multisample(); -#endif /* GL_SGIS_multisample */ -#ifdef GL_SGIS_pixel_texture - _glewInfo_GL_SGIS_pixel_texture(); -#endif /* GL_SGIS_pixel_texture */ -#ifdef GL_SGIS_point_line_texgen - _glewInfo_GL_SGIS_point_line_texgen(); -#endif /* GL_SGIS_point_line_texgen */ -#ifdef GL_SGIS_sharpen_texture - _glewInfo_GL_SGIS_sharpen_texture(); -#endif /* GL_SGIS_sharpen_texture */ -#ifdef GL_SGIS_texture4D - _glewInfo_GL_SGIS_texture4D(); -#endif /* GL_SGIS_texture4D */ -#ifdef GL_SGIS_texture_border_clamp - _glewInfo_GL_SGIS_texture_border_clamp(); -#endif /* GL_SGIS_texture_border_clamp */ -#ifdef GL_SGIS_texture_edge_clamp - _glewInfo_GL_SGIS_texture_edge_clamp(); -#endif /* GL_SGIS_texture_edge_clamp */ -#ifdef GL_SGIS_texture_filter4 - _glewInfo_GL_SGIS_texture_filter4(); -#endif /* GL_SGIS_texture_filter4 */ -#ifdef GL_SGIS_texture_lod - _glewInfo_GL_SGIS_texture_lod(); -#endif /* GL_SGIS_texture_lod */ -#ifdef GL_SGIS_texture_select - _glewInfo_GL_SGIS_texture_select(); -#endif /* GL_SGIS_texture_select */ -#ifdef GL_SGIX_async - _glewInfo_GL_SGIX_async(); -#endif /* GL_SGIX_async */ -#ifdef GL_SGIX_async_histogram - _glewInfo_GL_SGIX_async_histogram(); -#endif /* GL_SGIX_async_histogram */ -#ifdef GL_SGIX_async_pixel - _glewInfo_GL_SGIX_async_pixel(); -#endif /* GL_SGIX_async_pixel */ -#ifdef GL_SGIX_blend_alpha_minmax - _glewInfo_GL_SGIX_blend_alpha_minmax(); -#endif /* GL_SGIX_blend_alpha_minmax */ -#ifdef GL_SGIX_clipmap - _glewInfo_GL_SGIX_clipmap(); -#endif /* GL_SGIX_clipmap */ -#ifdef GL_SGIX_convolution_accuracy - _glewInfo_GL_SGIX_convolution_accuracy(); -#endif /* GL_SGIX_convolution_accuracy */ -#ifdef GL_SGIX_depth_texture - _glewInfo_GL_SGIX_depth_texture(); -#endif /* GL_SGIX_depth_texture */ -#ifdef GL_SGIX_flush_raster - _glewInfo_GL_SGIX_flush_raster(); -#endif /* GL_SGIX_flush_raster */ -#ifdef GL_SGIX_fog_offset - _glewInfo_GL_SGIX_fog_offset(); -#endif /* GL_SGIX_fog_offset */ -#ifdef GL_SGIX_fog_texture - _glewInfo_GL_SGIX_fog_texture(); -#endif /* GL_SGIX_fog_texture */ -#ifdef GL_SGIX_fragment_specular_lighting - _glewInfo_GL_SGIX_fragment_specular_lighting(); -#endif /* GL_SGIX_fragment_specular_lighting */ -#ifdef GL_SGIX_framezoom - _glewInfo_GL_SGIX_framezoom(); -#endif /* GL_SGIX_framezoom */ -#ifdef GL_SGIX_interlace - _glewInfo_GL_SGIX_interlace(); -#endif /* GL_SGIX_interlace */ -#ifdef GL_SGIX_ir_instrument1 - _glewInfo_GL_SGIX_ir_instrument1(); -#endif /* GL_SGIX_ir_instrument1 */ -#ifdef GL_SGIX_list_priority - _glewInfo_GL_SGIX_list_priority(); -#endif /* GL_SGIX_list_priority */ -#ifdef GL_SGIX_pixel_texture - _glewInfo_GL_SGIX_pixel_texture(); -#endif /* GL_SGIX_pixel_texture */ -#ifdef GL_SGIX_pixel_texture_bits - _glewInfo_GL_SGIX_pixel_texture_bits(); -#endif /* GL_SGIX_pixel_texture_bits */ -#ifdef GL_SGIX_reference_plane - _glewInfo_GL_SGIX_reference_plane(); -#endif /* GL_SGIX_reference_plane */ -#ifdef GL_SGIX_resample - _glewInfo_GL_SGIX_resample(); -#endif /* GL_SGIX_resample */ -#ifdef GL_SGIX_shadow - _glewInfo_GL_SGIX_shadow(); -#endif /* GL_SGIX_shadow */ -#ifdef GL_SGIX_shadow_ambient - _glewInfo_GL_SGIX_shadow_ambient(); -#endif /* GL_SGIX_shadow_ambient */ -#ifdef GL_SGIX_sprite - _glewInfo_GL_SGIX_sprite(); -#endif /* GL_SGIX_sprite */ -#ifdef GL_SGIX_tag_sample_buffer - _glewInfo_GL_SGIX_tag_sample_buffer(); -#endif /* GL_SGIX_tag_sample_buffer */ -#ifdef GL_SGIX_texture_add_env - _glewInfo_GL_SGIX_texture_add_env(); -#endif /* GL_SGIX_texture_add_env */ -#ifdef GL_SGIX_texture_coordinate_clamp - _glewInfo_GL_SGIX_texture_coordinate_clamp(); -#endif /* GL_SGIX_texture_coordinate_clamp */ -#ifdef GL_SGIX_texture_lod_bias - _glewInfo_GL_SGIX_texture_lod_bias(); -#endif /* GL_SGIX_texture_lod_bias */ -#ifdef GL_SGIX_texture_multi_buffer - _glewInfo_GL_SGIX_texture_multi_buffer(); -#endif /* GL_SGIX_texture_multi_buffer */ -#ifdef GL_SGIX_texture_range - _glewInfo_GL_SGIX_texture_range(); -#endif /* GL_SGIX_texture_range */ -#ifdef GL_SGIX_texture_scale_bias - _glewInfo_GL_SGIX_texture_scale_bias(); -#endif /* GL_SGIX_texture_scale_bias */ -#ifdef GL_SGIX_vertex_preclip - _glewInfo_GL_SGIX_vertex_preclip(); -#endif /* GL_SGIX_vertex_preclip */ -#ifdef GL_SGIX_vertex_preclip_hint - _glewInfo_GL_SGIX_vertex_preclip_hint(); -#endif /* GL_SGIX_vertex_preclip_hint */ -#ifdef GL_SGIX_ycrcb - _glewInfo_GL_SGIX_ycrcb(); -#endif /* GL_SGIX_ycrcb */ -#ifdef GL_SGI_color_matrix - _glewInfo_GL_SGI_color_matrix(); -#endif /* GL_SGI_color_matrix */ -#ifdef GL_SGI_color_table - _glewInfo_GL_SGI_color_table(); -#endif /* GL_SGI_color_table */ -#ifdef GL_SGI_texture_color_table - _glewInfo_GL_SGI_texture_color_table(); -#endif /* GL_SGI_texture_color_table */ -#ifdef GL_SUNX_constant_data - _glewInfo_GL_SUNX_constant_data(); -#endif /* GL_SUNX_constant_data */ -#ifdef GL_SUN_convolution_border_modes - _glewInfo_GL_SUN_convolution_border_modes(); -#endif /* GL_SUN_convolution_border_modes */ -#ifdef GL_SUN_global_alpha - _glewInfo_GL_SUN_global_alpha(); -#endif /* GL_SUN_global_alpha */ -#ifdef GL_SUN_mesh_array - _glewInfo_GL_SUN_mesh_array(); -#endif /* GL_SUN_mesh_array */ -#ifdef GL_SUN_read_video_pixels - _glewInfo_GL_SUN_read_video_pixels(); -#endif /* GL_SUN_read_video_pixels */ -#ifdef GL_SUN_slice_accum - _glewInfo_GL_SUN_slice_accum(); -#endif /* GL_SUN_slice_accum */ -#ifdef GL_SUN_triangle_list - _glewInfo_GL_SUN_triangle_list(); -#endif /* GL_SUN_triangle_list */ -#ifdef GL_SUN_vertex - _glewInfo_GL_SUN_vertex(); -#endif /* GL_SUN_vertex */ -#ifdef GL_WIN_phong_shading - _glewInfo_GL_WIN_phong_shading(); -#endif /* GL_WIN_phong_shading */ -#ifdef GL_WIN_specular_fog - _glewInfo_GL_WIN_specular_fog(); -#endif /* GL_WIN_specular_fog */ -#ifdef GL_WIN_swap_hint - _glewInfo_GL_WIN_swap_hint(); -#endif /* GL_WIN_swap_hint */ -} - -/* ------------------------------------------------------------------------ */ - -#ifdef _WIN32 - -static void wglewInfo () -{ -#ifdef WGL_3DFX_multisample - _glewInfo_WGL_3DFX_multisample(); -#endif /* WGL_3DFX_multisample */ -#ifdef WGL_3DL_stereo_control - _glewInfo_WGL_3DL_stereo_control(); -#endif /* WGL_3DL_stereo_control */ -#ifdef WGL_ARB_buffer_region - _glewInfo_WGL_ARB_buffer_region(); -#endif /* WGL_ARB_buffer_region */ -#ifdef WGL_ARB_create_context - _glewInfo_WGL_ARB_create_context(); -#endif /* WGL_ARB_create_context */ -#ifdef WGL_ARB_extensions_string - _glewInfo_WGL_ARB_extensions_string(); -#endif /* WGL_ARB_extensions_string */ -#ifdef WGL_ARB_framebuffer_sRGB - _glewInfo_WGL_ARB_framebuffer_sRGB(); -#endif /* WGL_ARB_framebuffer_sRGB */ -#ifdef WGL_ARB_make_current_read - _glewInfo_WGL_ARB_make_current_read(); -#endif /* WGL_ARB_make_current_read */ -#ifdef WGL_ARB_multisample - _glewInfo_WGL_ARB_multisample(); -#endif /* WGL_ARB_multisample */ -#ifdef WGL_ARB_pbuffer - _glewInfo_WGL_ARB_pbuffer(); -#endif /* WGL_ARB_pbuffer */ -#ifdef WGL_ARB_pixel_format - _glewInfo_WGL_ARB_pixel_format(); -#endif /* WGL_ARB_pixel_format */ -#ifdef WGL_ARB_pixel_format_float - _glewInfo_WGL_ARB_pixel_format_float(); -#endif /* WGL_ARB_pixel_format_float */ -#ifdef WGL_ARB_render_texture - _glewInfo_WGL_ARB_render_texture(); -#endif /* WGL_ARB_render_texture */ -#ifdef WGL_ATI_pixel_format_float - _glewInfo_WGL_ATI_pixel_format_float(); -#endif /* WGL_ATI_pixel_format_float */ -#ifdef WGL_ATI_render_texture_rectangle - _glewInfo_WGL_ATI_render_texture_rectangle(); -#endif /* WGL_ATI_render_texture_rectangle */ -#ifdef WGL_EXT_depth_float - _glewInfo_WGL_EXT_depth_float(); -#endif /* WGL_EXT_depth_float */ -#ifdef WGL_EXT_display_color_table - _glewInfo_WGL_EXT_display_color_table(); -#endif /* WGL_EXT_display_color_table */ -#ifdef WGL_EXT_extensions_string - _glewInfo_WGL_EXT_extensions_string(); -#endif /* WGL_EXT_extensions_string */ -#ifdef WGL_EXT_framebuffer_sRGB - _glewInfo_WGL_EXT_framebuffer_sRGB(); -#endif /* WGL_EXT_framebuffer_sRGB */ -#ifdef WGL_EXT_make_current_read - _glewInfo_WGL_EXT_make_current_read(); -#endif /* WGL_EXT_make_current_read */ -#ifdef WGL_EXT_multisample - _glewInfo_WGL_EXT_multisample(); -#endif /* WGL_EXT_multisample */ -#ifdef WGL_EXT_pbuffer - _glewInfo_WGL_EXT_pbuffer(); -#endif /* WGL_EXT_pbuffer */ -#ifdef WGL_EXT_pixel_format - _glewInfo_WGL_EXT_pixel_format(); -#endif /* WGL_EXT_pixel_format */ -#ifdef WGL_EXT_pixel_format_packed_float - _glewInfo_WGL_EXT_pixel_format_packed_float(); -#endif /* WGL_EXT_pixel_format_packed_float */ -#ifdef WGL_EXT_swap_control - _glewInfo_WGL_EXT_swap_control(); -#endif /* WGL_EXT_swap_control */ -#ifdef WGL_I3D_digital_video_control - _glewInfo_WGL_I3D_digital_video_control(); -#endif /* WGL_I3D_digital_video_control */ -#ifdef WGL_I3D_gamma - _glewInfo_WGL_I3D_gamma(); -#endif /* WGL_I3D_gamma */ -#ifdef WGL_I3D_genlock - _glewInfo_WGL_I3D_genlock(); -#endif /* WGL_I3D_genlock */ -#ifdef WGL_I3D_image_buffer - _glewInfo_WGL_I3D_image_buffer(); -#endif /* WGL_I3D_image_buffer */ -#ifdef WGL_I3D_swap_frame_lock - _glewInfo_WGL_I3D_swap_frame_lock(); -#endif /* WGL_I3D_swap_frame_lock */ -#ifdef WGL_I3D_swap_frame_usage - _glewInfo_WGL_I3D_swap_frame_usage(); -#endif /* WGL_I3D_swap_frame_usage */ -#ifdef WGL_NV_float_buffer - _glewInfo_WGL_NV_float_buffer(); -#endif /* WGL_NV_float_buffer */ -#ifdef WGL_NV_gpu_affinity - _glewInfo_WGL_NV_gpu_affinity(); -#endif /* WGL_NV_gpu_affinity */ -#ifdef WGL_NV_present_video - _glewInfo_WGL_NV_present_video(); -#endif /* WGL_NV_present_video */ -#ifdef WGL_NV_render_depth_texture - _glewInfo_WGL_NV_render_depth_texture(); -#endif /* WGL_NV_render_depth_texture */ -#ifdef WGL_NV_render_texture_rectangle - _glewInfo_WGL_NV_render_texture_rectangle(); -#endif /* WGL_NV_render_texture_rectangle */ -#ifdef WGL_NV_swap_group - _glewInfo_WGL_NV_swap_group(); -#endif /* WGL_NV_swap_group */ -#ifdef WGL_NV_vertex_array_range - _glewInfo_WGL_NV_vertex_array_range(); -#endif /* WGL_NV_vertex_array_range */ -#ifdef WGL_NV_video_output - _glewInfo_WGL_NV_video_output(); -#endif /* WGL_NV_video_output */ -#ifdef WGL_OML_sync_control - _glewInfo_WGL_OML_sync_control(); -#endif /* WGL_OML_sync_control */ -} - -#else /* _UNIX */ - -static void glxewInfo () -{ -#ifdef GLX_VERSION_1_2 - _glewInfo_GLX_VERSION_1_2(); -#endif /* GLX_VERSION_1_2 */ -#ifdef GLX_VERSION_1_3 - _glewInfo_GLX_VERSION_1_3(); -#endif /* GLX_VERSION_1_3 */ -#ifdef GLX_VERSION_1_4 - _glewInfo_GLX_VERSION_1_4(); -#endif /* GLX_VERSION_1_4 */ -#ifdef GLX_3DFX_multisample - _glewInfo_GLX_3DFX_multisample(); -#endif /* GLX_3DFX_multisample */ -#ifdef GLX_ARB_create_context - _glewInfo_GLX_ARB_create_context(); -#endif /* GLX_ARB_create_context */ -#ifdef GLX_ARB_fbconfig_float - _glewInfo_GLX_ARB_fbconfig_float(); -#endif /* GLX_ARB_fbconfig_float */ -#ifdef GLX_ARB_framebuffer_sRGB - _glewInfo_GLX_ARB_framebuffer_sRGB(); -#endif /* GLX_ARB_framebuffer_sRGB */ -#ifdef GLX_ARB_get_proc_address - _glewInfo_GLX_ARB_get_proc_address(); -#endif /* GLX_ARB_get_proc_address */ -#ifdef GLX_ARB_multisample - _glewInfo_GLX_ARB_multisample(); -#endif /* GLX_ARB_multisample */ -#ifdef GLX_ATI_pixel_format_float - _glewInfo_GLX_ATI_pixel_format_float(); -#endif /* GLX_ATI_pixel_format_float */ -#ifdef GLX_ATI_render_texture - _glewInfo_GLX_ATI_render_texture(); -#endif /* GLX_ATI_render_texture */ -#ifdef GLX_EXT_fbconfig_packed_float - _glewInfo_GLX_EXT_fbconfig_packed_float(); -#endif /* GLX_EXT_fbconfig_packed_float */ -#ifdef GLX_EXT_framebuffer_sRGB - _glewInfo_GLX_EXT_framebuffer_sRGB(); -#endif /* GLX_EXT_framebuffer_sRGB */ -#ifdef GLX_EXT_import_context - _glewInfo_GLX_EXT_import_context(); -#endif /* GLX_EXT_import_context */ -#ifdef GLX_EXT_scene_marker - _glewInfo_GLX_EXT_scene_marker(); -#endif /* GLX_EXT_scene_marker */ -#ifdef GLX_EXT_texture_from_pixmap - _glewInfo_GLX_EXT_texture_from_pixmap(); -#endif /* GLX_EXT_texture_from_pixmap */ -#ifdef GLX_EXT_visual_info - _glewInfo_GLX_EXT_visual_info(); -#endif /* GLX_EXT_visual_info */ -#ifdef GLX_EXT_visual_rating - _glewInfo_GLX_EXT_visual_rating(); -#endif /* GLX_EXT_visual_rating */ -#ifdef GLX_MESA_agp_offset - _glewInfo_GLX_MESA_agp_offset(); -#endif /* GLX_MESA_agp_offset */ -#ifdef GLX_MESA_copy_sub_buffer - _glewInfo_GLX_MESA_copy_sub_buffer(); -#endif /* GLX_MESA_copy_sub_buffer */ -#ifdef GLX_MESA_pixmap_colormap - _glewInfo_GLX_MESA_pixmap_colormap(); -#endif /* GLX_MESA_pixmap_colormap */ -#ifdef GLX_MESA_release_buffers - _glewInfo_GLX_MESA_release_buffers(); -#endif /* GLX_MESA_release_buffers */ -#ifdef GLX_MESA_set_3dfx_mode - _glewInfo_GLX_MESA_set_3dfx_mode(); -#endif /* GLX_MESA_set_3dfx_mode */ -#ifdef GLX_NV_float_buffer - _glewInfo_GLX_NV_float_buffer(); -#endif /* GLX_NV_float_buffer */ -#ifdef GLX_NV_present_video - _glewInfo_GLX_NV_present_video(); -#endif /* GLX_NV_present_video */ -#ifdef GLX_NV_swap_group - _glewInfo_GLX_NV_swap_group(); -#endif /* GLX_NV_swap_group */ -#ifdef GLX_NV_vertex_array_range - _glewInfo_GLX_NV_vertex_array_range(); -#endif /* GLX_NV_vertex_array_range */ -#ifdef GLX_NV_video_output - _glewInfo_GLX_NV_video_output(); -#endif /* GLX_NV_video_output */ -#ifdef GLX_OML_swap_method - _glewInfo_GLX_OML_swap_method(); -#endif /* GLX_OML_swap_method */ -#if defined(GLX_OML_sync_control) && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -#include - _glewInfo_GLX_OML_sync_control(); -#endif /* GLX_OML_sync_control */ -#ifdef GLX_SGIS_blended_overlay - _glewInfo_GLX_SGIS_blended_overlay(); -#endif /* GLX_SGIS_blended_overlay */ -#ifdef GLX_SGIS_color_range - _glewInfo_GLX_SGIS_color_range(); -#endif /* GLX_SGIS_color_range */ -#ifdef GLX_SGIS_multisample - _glewInfo_GLX_SGIS_multisample(); -#endif /* GLX_SGIS_multisample */ -#ifdef GLX_SGIS_shared_multisample - _glewInfo_GLX_SGIS_shared_multisample(); -#endif /* GLX_SGIS_shared_multisample */ -#ifdef GLX_SGIX_fbconfig - _glewInfo_GLX_SGIX_fbconfig(); -#endif /* GLX_SGIX_fbconfig */ -#ifdef GLX_SGIX_hyperpipe - _glewInfo_GLX_SGIX_hyperpipe(); -#endif /* GLX_SGIX_hyperpipe */ -#ifdef GLX_SGIX_pbuffer - _glewInfo_GLX_SGIX_pbuffer(); -#endif /* GLX_SGIX_pbuffer */ -#ifdef GLX_SGIX_swap_barrier - _glewInfo_GLX_SGIX_swap_barrier(); -#endif /* GLX_SGIX_swap_barrier */ -#ifdef GLX_SGIX_swap_group - _glewInfo_GLX_SGIX_swap_group(); -#endif /* GLX_SGIX_swap_group */ -#ifdef GLX_SGIX_video_resize - _glewInfo_GLX_SGIX_video_resize(); -#endif /* GLX_SGIX_video_resize */ -#ifdef GLX_SGIX_visual_select_group - _glewInfo_GLX_SGIX_visual_select_group(); -#endif /* GLX_SGIX_visual_select_group */ -#ifdef GLX_SGI_cushion - _glewInfo_GLX_SGI_cushion(); -#endif /* GLX_SGI_cushion */ -#ifdef GLX_SGI_make_current_read - _glewInfo_GLX_SGI_make_current_read(); -#endif /* GLX_SGI_make_current_read */ -#ifdef GLX_SGI_swap_control - _glewInfo_GLX_SGI_swap_control(); -#endif /* GLX_SGI_swap_control */ -#ifdef GLX_SGI_video_sync - _glewInfo_GLX_SGI_video_sync(); -#endif /* GLX_SGI_video_sync */ -#ifdef GLX_SUN_get_transparent_index - _glewInfo_GLX_SUN_get_transparent_index(); -#endif /* GLX_SUN_get_transparent_index */ -#ifdef GLX_SUN_video_resize - _glewInfo_GLX_SUN_video_resize(); -#endif /* GLX_SUN_video_resize */ -} - -#endif /* _WIN32 */ - -/* ------------------------------------------------------------------------ */ - -#if defined(_WIN32) || !defined(__APPLE__) || defined(GLEW_APPLE_GLX) -int main (int argc, char** argv) -#else -int main (void) -#endif -{ - GLuint err; - -#if defined(_WIN32) || !defined(__APPLE__) || defined(GLEW_APPLE_GLX) - char* display = NULL; - int visual = -1; - - if (glewParseArgs(argc-1, argv+1, &display, &visual)) - { -#if defined(_WIN32) - fprintf(stderr, "Usage: glewinfo [-pf ]\n"); -#else - fprintf(stderr, "Usage: glewinfo [-display ] [-visual ]\n"); -#endif - return 1; - } -#endif - -#if defined(_WIN32) - if (GL_TRUE == glewCreateContext(&visual)) -#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX) - if (GL_TRUE == glewCreateContext()) -#else - if (GL_TRUE == glewCreateContext(display, &visual)) -#endif - { - fprintf(stderr, "Error: glewCreateContext failed\n"); - glewDestroyContext(); - return 1; - } - glewExperimental = GL_TRUE; -#ifdef GLEW_MX - err = glewContextInit(glewGetContext()); -#ifdef _WIN32 - err = err || wglewContextInit(wglewGetContext()); -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) - err = err || glxewContextInit(glxewGetContext()); -#endif - -#else - err = glewInit(); -#endif - if (GLEW_OK != err) - { - fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err)); - glewDestroyContext(); - return 1; - } -#if defined(_WIN32) - f = fopen("glewinfo.txt", "w"); - if (f == NULL) f = stdout; -#else - f = stdout; -#endif - fprintf(f, "---------------------------\n"); - fprintf(f, " GLEW Extension Info\n"); - fprintf(f, "---------------------------\n\n"); - fprintf(f, "GLEW version %s\n", glewGetString(GLEW_VERSION)); -#if defined(_WIN32) - fprintf(f, "Reporting capabilities of pixelformat %d\n", visual); -#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) - fprintf(f, "Reporting capabilities of display %s, visual 0x%x\n", - display == NULL ? getenv("DISPLAY") : display, visual); -#endif - fprintf(f, "Running on a %s from %s\n", - glGetString(GL_RENDERER), glGetString(GL_VENDOR)); - fprintf(f, "OpenGL version %s is supported\n", glGetString(GL_VERSION)); - glewInfo(); -#if defined(_WIN32) - wglewInfo(); -#else - glxewInfo(); -#endif - if (f != stdout) fclose(f); - glewDestroyContext(); - return 0; -} - -/* ------------------------------------------------------------------------ */ - -#if defined(_WIN32) || !defined(__APPLE__) || defined(GLEW_APPLE_GLX) -GLboolean glewParseArgs (int argc, char** argv, char** display, int* visual) -{ - int p = 0; - while (p < argc) - { -#if defined(_WIN32) - if (!strcmp(argv[p], "-pf") || !strcmp(argv[p], "-pixelformat")) - { - if (++p >= argc) return GL_TRUE; - *display = 0; - *visual = strtol(argv[p++], NULL, 0); - } - else - return GL_TRUE; -#else - if (!strcmp(argv[p], "-display")) - { - if (++p >= argc) return GL_TRUE; - *display = argv[p++]; - } - else if (!strcmp(argv[p], "-visual")) - { - if (++p >= argc) return GL_TRUE; - *visual = (int)strtol(argv[p++], NULL, 0); - } - else - return GL_TRUE; -#endif - } - return GL_FALSE; -} -#endif - -/* ------------------------------------------------------------------------ */ - -#if defined(_WIN32) - -HWND wnd = NULL; -HDC dc = NULL; -HGLRC rc = NULL; - -GLboolean glewCreateContext (int* pixelformat) -{ - WNDCLASS wc; - PIXELFORMATDESCRIPTOR pfd; - /* register window class */ - ZeroMemory(&wc, sizeof(WNDCLASS)); - wc.hInstance = GetModuleHandle(NULL); - wc.lpfnWndProc = DefWindowProc; - wc.lpszClassName = "GLEW"; - if (0 == RegisterClass(&wc)) return GL_TRUE; - /* create window */ - wnd = CreateWindow("GLEW", "GLEW", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - CW_USEDEFAULT, NULL, NULL, GetModuleHandle(NULL), NULL); - if (NULL == wnd) return GL_TRUE; - /* get the device context */ - dc = GetDC(wnd); - if (NULL == dc) return GL_TRUE; - /* find pixel format */ - ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR)); - if (*pixelformat == -1) /* find default */ - { - pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); - pfd.nVersion = 1; - pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; - *pixelformat = ChoosePixelFormat(dc, &pfd); - if (*pixelformat == 0) return GL_TRUE; - } - /* set the pixel format for the dc */ - if (FALSE == SetPixelFormat(dc, *pixelformat, &pfd)) return GL_TRUE; - /* create rendering context */ - rc = wglCreateContext(dc); - if (NULL == rc) return GL_TRUE; - if (FALSE == wglMakeCurrent(dc, rc)) return GL_TRUE; - return GL_FALSE; -} - -void glewDestroyContext () -{ - if (NULL != rc) wglMakeCurrent(NULL, NULL); - if (NULL != rc) wglDeleteContext(wglGetCurrentContext()); - if (NULL != wnd && NULL != dc) ReleaseDC(wnd, dc); - if (NULL != wnd) DestroyWindow(wnd); - UnregisterClass("GLEW", GetModuleHandle(NULL)); -} - -/* ------------------------------------------------------------------------ */ - -#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX) - -#include - -AGLContext ctx, octx; - -GLboolean glewCreateContext () -{ - int attrib[] = { AGL_RGBA, AGL_NONE }; - AGLPixelFormat pf; - /*int major, minor; - SetPortWindowPort(wnd); - aglGetVersion(&major, &minor); - fprintf(stderr, "GL %d.%d\n", major, minor);*/ - pf = aglChoosePixelFormat(NULL, 0, attrib); - if (NULL == pf) return GL_TRUE; - ctx = aglCreateContext(pf, NULL); - if (NULL == ctx || AGL_NO_ERROR != aglGetError()) return GL_TRUE; - aglDestroyPixelFormat(pf); - /*aglSetDrawable(ctx, GetWindowPort(wnd));*/ - octx = aglGetCurrentContext(); - if (NULL == aglSetCurrentContext(ctx)) return GL_TRUE; - return GL_FALSE; -} - -void glewDestroyContext () -{ - aglSetCurrentContext(octx); - if (NULL != ctx) aglDestroyContext(ctx); -} - -/* ------------------------------------------------------------------------ */ - -#else /* __UNIX || (__APPLE__ && GLEW_APPLE_GLX) */ - -Display* dpy = NULL; -XVisualInfo* vi = NULL; -XVisualInfo* vis = NULL; -GLXContext ctx = NULL; -Window wnd = 0; -Colormap cmap = 0; - -GLboolean glewCreateContext (const char* display, int* visual) -{ - int attrib[] = { GLX_RGBA, GLX_DOUBLEBUFFER, None }; - int erb, evb; - XSetWindowAttributes swa; - /* open display */ - dpy = XOpenDisplay(display); - if (NULL == dpy) return GL_TRUE; - /* query for glx */ - if (!glXQueryExtension(dpy, &erb, &evb)) return GL_TRUE; - /* choose visual */ - if (*visual == -1) - { - vi = glXChooseVisual(dpy, DefaultScreen(dpy), attrib); - if (NULL == vi) return GL_TRUE; - *visual = (int)XVisualIDFromVisual(vi->visual); - } - else - { - int n_vis, i; - vis = XGetVisualInfo(dpy, 0, NULL, &n_vis); - for (i=0; iscreen), 0, 0, 1, 1, 1, 0, 0);*/ - cmap = XCreateColormap(dpy, RootWindow(dpy, vi->screen), vi->visual, AllocNone); - swa.border_pixel = 0; - swa.colormap = cmap; - wnd = XCreateWindow(dpy, RootWindow(dpy, vi->screen), - 0, 0, 1, 1, 0, vi->depth, InputOutput, vi->visual, - CWBorderPixel | CWColormap, &swa); - /* make context current */ - if (!glXMakeCurrent(dpy, wnd, ctx)) return GL_TRUE; - return GL_FALSE; -} - -void glewDestroyContext () -{ - if (NULL != dpy && NULL != ctx) glXDestroyContext(dpy, ctx); - if (NULL != dpy && 0 != wnd) XDestroyWindow(dpy, wnd); - if (NULL != dpy && 0 != cmap) XFreeColormap(dpy, cmap); - if (NULL != vis) - XFree(vis); - else if (NULL != vi) - XFree(vi); - if (NULL != dpy) XCloseDisplay(dpy); -} - -#endif /* __UNIX || (__APPLE__ && GLEW_APPLE_GLX) */ diff --git a/oversampling/WDL/lice/glew/src/visualinfo.c b/oversampling/WDL/lice/glew/src/visualinfo.c deleted file mode 100644 index 384313d..0000000 --- a/oversampling/WDL/lice/glew/src/visualinfo.c +++ /dev/null @@ -1,1173 +0,0 @@ -/* -** visualinfo.c -** -** Copyright (C) Nate Robins, 1997 -** Michael Wimmer, 1999 -** Milan Ikits, 2002-2008 -** -** visualinfo is a small utility that displays all available visuals, -** aka. pixelformats, in an OpenGL system along with renderer version -** information. It shows a table of all the visuals that support OpenGL -** along with their capabilities. The format of the table is similar to -** that of glxinfo on Unix systems: -** -** visual ~= pixel format descriptor -** id = visual id (integer from 1 - max visuals) -** tp = type (wn: window, pb: pbuffer, wp: window & pbuffer, bm: bitmap) -** ac = acceleration (ge: generic, fu: full, no: none) -** fm = format (i: integer, f: float, c: color index) -** db = double buffer (y = yes) -** sw = swap method (x: exchange, c: copy, u: undefined) -** st = stereo (y = yes) -** sz = total # bits -** r = # bits of red -** g = # bits of green -** b = # bits of blue -** a = # bits of alpha -** axbf = # aux buffers -** dpth = # bits of depth -** stcl = # bits of stencil -*/ - -#include -#include -#include -#include -#if defined(_WIN32) -#include -#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX) -#include -#else -#include -#endif - -#ifdef GLEW_MX -GLEWContext _glewctx; -# define glewGetContext() (&_glewctx) -# ifdef _WIN32 -WGLEWContext _wglewctx; -# define wglewGetContext() (&_wglewctx) -# elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) -GLXEWContext _glxewctx; -# define glxewGetContext() (&_glxewctx) -# endif -#endif /* GLEW_MX */ - -typedef struct GLContextStruct -{ -#ifdef _WIN32 - HWND wnd; - HDC dc; - HGLRC rc; -#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX) - AGLContext ctx, octx; -#else - Display* dpy; - XVisualInfo* vi; - GLXContext ctx; - Window wnd; - Colormap cmap; -#endif -} GLContext; - -void InitContext (GLContext* ctx); -GLboolean CreateContext (GLContext* ctx); -void DestroyContext (GLContext* ctx); -void VisualInfo (GLContext* ctx); -void PrintExtensions (const char* s); -GLboolean ParseArgs (int argc, char** argv); - -int showall = 0; -int displaystdout = 0; -int verbose = 0; -int drawableonly = 0; - -char* display = NULL; -int visual = -1; - -FILE* file = 0; -GLContext ctx; - -int -main (int argc, char** argv) -{ - GLenum err; - - /* ---------------------------------------------------------------------- */ - /* parse arguments */ - if (GL_TRUE == ParseArgs(argc-1, argv+1)) - { -#if defined(_WIN32) - fprintf(stderr, "Usage: visualinfo [-a] [-s] [-h] [-pf ]\n"); - fprintf(stderr, " -a: show all visuals\n"); - fprintf(stderr, " -s: display to stdout instead of visualinfo.txt\n"); - fprintf(stderr, " -pf : use given pixelformat\n"); - fprintf(stderr, " -h: this screen\n"); -#else - fprintf(stderr, "Usage: visualinfo [-h] [-display ] [-visual ]\n"); - fprintf(stderr, " -h: this screen\n"); - fprintf(stderr, " -display : use given display\n"); - fprintf(stderr, " -visual : use given visual\n"); -#endif - return 1; - } - - /* ---------------------------------------------------------------------- */ - /* create OpenGL rendering context */ - InitContext(&ctx); - if (GL_TRUE == CreateContext(&ctx)) - { - fprintf(stderr, "Error: CreateContext failed\n"); - DestroyContext(&ctx); - return 1; - } - - /* ---------------------------------------------------------------------- */ - /* initialize GLEW */ - glewExperimental = GL_TRUE; -#ifdef GLEW_MX - err = glewContextInit(glewGetContext()); -# ifdef _WIN32 - err = err || wglewContextInit(wglewGetContext()); -# elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX) - err = err || glxewContextInit(glxewGetContext()); -# endif -#else - err = glewInit(); -#endif - if (GLEW_OK != err) - { - fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err)); - DestroyContext(&ctx); - return 1; - } - - /* ---------------------------------------------------------------------- */ - /* open file */ -#if defined(_WIN32) - if (!displaystdout) - file = fopen("visualinfo.txt", "w"); - if (file == NULL) - file = stdout; -#else - file = stdout; -#endif - - /* ---------------------------------------------------------------------- */ - /* output header information */ - /* OpenGL extensions */ - fprintf(file, "OpenGL vendor string: %s\n", glGetString(GL_VENDOR)); - fprintf(file, "OpenGL renderer string: %s\n", glGetString(GL_RENDERER)); - fprintf(file, "OpenGL version string: %s\n", glGetString(GL_VERSION)); - fprintf(file, "OpenGL extensions (GL_): \n"); - PrintExtensions((char*)glGetString(GL_EXTENSIONS)); - /* GLU extensions */ - fprintf(file, "GLU version string: %s\n", gluGetString(GLU_VERSION)); - fprintf(file, "GLU extensions (GLU_): \n"); - PrintExtensions((char*)gluGetString(GLU_EXTENSIONS)); - - /* ---------------------------------------------------------------------- */ - /* extensions string */ -#if defined(_WIN32) - /* WGL extensions */ - if (WGLEW_ARB_extensions_string || WGLEW_EXT_extensions_string) - { - fprintf(file, "WGL extensions (WGL_): \n"); - PrintExtensions(wglGetExtensionsStringARB ? - (char*)wglGetExtensionsStringARB(ctx.dc) : - (char*)wglGetExtensionsStringEXT()); - } -#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX) - -#else - /* GLX extensions */ - fprintf(file, "GLX extensions (GLX_): \n"); - PrintExtensions(glXQueryExtensionsString(glXGetCurrentDisplay(), - DefaultScreen(glXGetCurrentDisplay()))); -#endif - - /* ---------------------------------------------------------------------- */ - /* enumerate all the formats */ - VisualInfo(&ctx); - - /* ---------------------------------------------------------------------- */ - /* release resources */ - DestroyContext(&ctx); - if (file != stdout) - fclose(file); - return 0; -} - -/* do the magic to separate all extensions with comma's, except - for the last one that _may_ terminate in a space. */ -void PrintExtensions (const char* s) -{ - char t[80]; - int i=0; - char* p=0; - - t[79] = '\0'; - while (*s) - { - t[i++] = *s; - if(*s == ' ') - { - if (*(s+1) != '\0') { - t[i-1] = ','; - t[i] = ' '; - p = &t[i++]; - } - else /* zoinks! last one terminated in a space! */ - { - t[i-1] = '\0'; - } - } - if(i > 80 - 5) - { - *p = t[i] = '\0'; - fprintf(file, " %s\n", t); - p++; - i = (int)strlen(p); - strcpy(t, p); - } - s++; - } - t[i] = '\0'; - fprintf(file, " %s.\n", t); -} - -/* ---------------------------------------------------------------------- */ - -#if defined(_WIN32) - -void -VisualInfoARB (GLContext* ctx) -{ - int attrib[32], value[32], n_attrib, n_pbuffer=0, n_float=0; - int i, pf, maxpf; - unsigned int c; - - /* to get pbuffer capable pixel formats */ - attrib[0] = WGL_DRAW_TO_PBUFFER_ARB; - attrib[1] = GL_TRUE; - attrib[2] = 0; - wglChoosePixelFormatARB(ctx->dc, attrib, 0, 1, &pf, &c); - /* query number of pixel formats */ - attrib[0] = WGL_NUMBER_PIXEL_FORMATS_ARB; - wglGetPixelFormatAttribivARB(ctx->dc, 0, 0, 1, attrib, value); - maxpf = value[0]; - for (i=0; i<32; i++) - value[i] = 0; - - attrib[0] = WGL_SUPPORT_OPENGL_ARB; - attrib[1] = WGL_DRAW_TO_WINDOW_ARB; - attrib[2] = WGL_DRAW_TO_BITMAP_ARB; - attrib[3] = WGL_ACCELERATION_ARB; - /* WGL_NO_ACCELERATION_ARB, WGL_GENERIC_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB */ - attrib[4] = WGL_SWAP_METHOD_ARB; - /* WGL_SWAP_EXCHANGE_ARB, WGL_SWAP_COPY_ARB, WGL_SWAP_UNDEFINED_ARB */ - attrib[5] = WGL_DOUBLE_BUFFER_ARB; - attrib[6] = WGL_STEREO_ARB; - attrib[7] = WGL_PIXEL_TYPE_ARB; - /* WGL_TYPE_RGBA_ARB, WGL_TYPE_COLORINDEX_ARB, - WGL_TYPE_RGBA_FLOAT_ATI (WGL_ATI_pixel_format_float) */ - /* Color buffer information */ - attrib[8] = WGL_COLOR_BITS_ARB; - attrib[9] = WGL_RED_BITS_ARB; - attrib[10] = WGL_GREEN_BITS_ARB; - attrib[11] = WGL_BLUE_BITS_ARB; - attrib[12] = WGL_ALPHA_BITS_ARB; - /* Accumulation buffer information */ - attrib[13] = WGL_ACCUM_BITS_ARB; - attrib[14] = WGL_ACCUM_RED_BITS_ARB; - attrib[15] = WGL_ACCUM_GREEN_BITS_ARB; - attrib[16] = WGL_ACCUM_BLUE_BITS_ARB; - attrib[17] = WGL_ACCUM_ALPHA_BITS_ARB; - /* Depth, stencil, and aux buffer information */ - attrib[18] = WGL_DEPTH_BITS_ARB; - attrib[19] = WGL_STENCIL_BITS_ARB; - attrib[20] = WGL_AUX_BUFFERS_ARB; - /* Layer information */ - attrib[21] = WGL_NUMBER_OVERLAYS_ARB; - attrib[22] = WGL_NUMBER_UNDERLAYS_ARB; - attrib[23] = WGL_SWAP_LAYER_BUFFERS_ARB; - attrib[24] = WGL_SAMPLES_ARB; - attrib[25] = WGL_SUPPORT_GDI_ARB; - n_attrib = 26; - if (WGLEW_ARB_pbuffer) - { - attrib[n_attrib] = WGL_DRAW_TO_PBUFFER_ARB; - n_pbuffer = n_attrib; - n_attrib++; - } - if (WGLEW_NV_float_buffer) - { - attrib[n_attrib] = WGL_FLOAT_COMPONENTS_NV; - n_float = n_attrib; - n_attrib++; - } - - if (!verbose) - { - /* print table header */ - fprintf(file, " +-----+-------------------------+-----------------+----------+-----------------+----------+\n"); - fprintf(file, " | | visual | color | ax dp st | accum | layer |\n"); - fprintf(file, " | id | tp ac gd fm db sw st ms | sz r g b a | bf th cl | sz r g b a | ov un sw |\n"); - fprintf(file, " +-----+-------------------------+-----------------+----------+-----------------+----------+\n"); - /* loop through all the pixel formats */ - for(i = 1; i <= maxpf; i++) - { - wglGetPixelFormatAttribivARB(ctx->dc, i, 0, n_attrib, attrib, value); - /* only describe this format if it supports OpenGL */ - if (!value[0]) continue; - /* by default show only fully accelerated window or pbuffer capable visuals */ - if (!showall - && ((value[2] && !value[1]) - || (!WGLEW_ARB_pbuffer || !value[n_pbuffer]) - || (value[3] != WGL_FULL_ACCELERATION_ARB))) continue; - /* print out the information for this visual */ - /* visual id */ - fprintf(file, " |% 4d | ", i); - /* visual type */ - if (value[1]) - { - if (WGLEW_ARB_pbuffer && value[n_pbuffer]) fprintf(file, "wp "); - else fprintf(file, "wn "); - } - else - { - if (value[2]) fprintf(file, "bm "); - else if (WGLEW_ARB_pbuffer && value[n_pbuffer]) fprintf(file, "pb "); - } - /* acceleration */ - fprintf(file, "%s ", value[3] == WGL_FULL_ACCELERATION_ARB ? "fu" : - value[3] == WGL_GENERIC_ACCELERATION_ARB ? "ge" : - value[3] == WGL_NO_ACCELERATION_ARB ? "no" : ". "); - /* gdi support */ - fprintf(file, " %c ", value[25] ? 'y' : '.'); - /* format */ - if (WGLEW_NV_float_buffer && value[n_float]) fprintf(file, " f "); - else if (WGLEW_ATI_pixel_format_float && value[7] == WGL_TYPE_RGBA_FLOAT_ATI) fprintf(file, " f "); - else if (value[7] == WGL_TYPE_RGBA_ARB) fprintf(file, " i "); - else if (value[7] == WGL_TYPE_COLORINDEX_ARB) fprintf(file, " c "); - /* double buffer */ - fprintf(file, " %c ", value[5] ? 'y' : '.'); - /* swap method */ - if (value[4] == WGL_SWAP_EXCHANGE_ARB) fprintf(file, " x "); - else if (value[4] == WGL_SWAP_COPY_ARB) fprintf(file, " c "); - else if (value[4] == WGL_SWAP_UNDEFINED_ARB) fprintf(file, " . "); - else fprintf(file, " . "); - /* stereo */ - fprintf(file, " %c ", value[6] ? 'y' : '.'); - /* multisample */ - if (value[24] > 0) - fprintf(file, "%2d | ", value[24]); - else - fprintf(file, " . | "); - /* color size */ - if (value[8]) fprintf(file, "%3d ", value[8]); - else fprintf(file, " . "); - /* red */ - if (value[9]) fprintf(file, "%2d ", value[9]); - else fprintf(file, " . "); - /* green */ - if (value[10]) fprintf(file, "%2d ", value[10]); - else fprintf(file, " . "); - /* blue */ - if (value[11]) fprintf(file, "%2d ", value[11]); - else fprintf(file, " . "); - /* alpha */ - if (value[12]) fprintf(file, "%2d | ", value[12]); - else fprintf(file, " . | "); - /* aux buffers */ - if (value[20]) fprintf(file, "%2d ", value[20]); - else fprintf(file, " . "); - /* depth */ - if (value[18]) fprintf(file, "%2d ", value[18]); - else fprintf(file, " . "); - /* stencil */ - if (value[19]) fprintf(file, "%2d | ", value[19]); - else fprintf(file, " . | "); - /* accum size */ - if (value[13]) fprintf(file, "%3d ", value[13]); - else fprintf(file, " . "); - /* accum red */ - if (value[14]) fprintf(file, "%2d ", value[14]); - else fprintf(file, " . "); - /* accum green */ - if (value[15]) fprintf(file, "%2d ", value[15]); - else fprintf(file, " . "); - /* accum blue */ - if (value[16]) fprintf(file, "%2d ", value[16]); - else fprintf(file, " . "); - /* accum alpha */ - if (value[17]) fprintf(file, "%2d | ", value[17]); - else fprintf(file, " . | "); - /* overlay */ - if (value[21]) fprintf(file, "%2d ", value[21]); - else fprintf(file, " . "); - /* underlay */ - if (value[22]) fprintf(file, "%2d ", value[22]); - else fprintf(file, " . "); - /* layer swap */ - if (value[23]) fprintf(file, "y "); - else fprintf(file, " . "); - fprintf(file, "|\n"); - } - /* print table footer */ - fprintf(file, " +-----+-------------------------+-----------------+----------+-----------------+----------+\n"); - fprintf(file, " | | visual | color | ax dp st | accum | layer |\n"); - fprintf(file, " | id | tp ac gd fm db sw st ms | sz r g b a | bf th cl | sz r g b a | ov un sw |\n"); - fprintf(file, " +-----+-------------------------+-----------------+----------+-----------------+----------+\n"); - } - else /* verbose */ - { -#if 0 - fprintf(file, "\n"); - /* loop through all the pixel formats */ - for(i = 1; i <= maxpf; i++) - { - DescribePixelFormat(ctx->dc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd); - /* only describe this format if it supports OpenGL */ - if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL) - || (drawableonly && !(pfd.dwFlags & PFD_DRAW_TO_WINDOW))) continue; - fprintf(file, "Visual ID: %2d depth=%d class=%s\n", i, pfd.cDepthBits, - pfd.cColorBits <= 8 ? "PseudoColor" : "TrueColor"); - fprintf(file, " bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n", pfd.cColorBits, pfd.bReserved, pfd.iPixelType == PFD_TYPE_RGBA ? "rgba" : "ci", pfd.dwFlags & PFD_DOUBLEBUFFER, pfd.dwFlags & PFD_STEREO); - fprintf(file, " generic=%d generic accelerated=%d\n", (pfd.dwFlags & PFD_GENERIC_FORMAT) == PFD_GENERIC_FORMAT, (pfd.dwFlags & PFD_GENERIC_ACCELERATED) == PFD_GENERIC_ACCELERATED); - fprintf(file, " rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n", pfd.cRedBits, pfd.cGreenBits, pfd.cBlueBits, pfd.cAlphaBits); - fprintf(file, " auxBuffers=%d depthSize=%d stencilSize=%d\n", pfd.cAuxBuffers, pfd.cDepthBits, pfd.cStencilBits); - fprintf(file, " accum: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n", pfd.cAccumRedBits, pfd.cAccumGreenBits, pfd.cAccumBlueBits, pfd.cAccumAlphaBits); - fprintf(file, " multiSample=%d multisampleBuffers=%d\n", 0, 0); - fprintf(file, " Opaque.\n"); - } -#endif - } -} - -void -VisualInfoGDI (GLContext* ctx) -{ - int i, maxpf; - PIXELFORMATDESCRIPTOR pfd; - - /* calling DescribePixelFormat() with NULL pfd (!!!) return maximum - number of pixel formats */ - maxpf = DescribePixelFormat(ctx->dc, 1, 0, NULL); - - if (!verbose) - { - fprintf(file, "-----------------------------------------------------------------------------\n"); - fprintf(file, " visual x bf lv rg d st ge ge r g b a ax dp st accum buffs ms \n"); - fprintf(file, " id dep tp sp sz l ci b ro ne ac sz sz sz sz bf th cl sz r g b a ns b\n"); - fprintf(file, "-----------------------------------------------------------------------------\n"); - - /* loop through all the pixel formats */ - for(i = 1; i <= maxpf; i++) - { - DescribePixelFormat(ctx->dc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd); - /* only describe this format if it supports OpenGL */ - if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL) - || (drawableonly && (pfd.dwFlags & PFD_DRAW_TO_BITMAP))) continue; - /* other criteria could be tested here for actual pixel format - choosing in an application: - - for (...each pixel format...) { - if (pfd.dwFlags & PFD_SUPPORT_OPENGL && - pfd.dwFlags & PFD_DOUBLEBUFFER && - pfd.cDepthBits >= 24 && - pfd.cColorBits >= 24) - { - goto found; - } - } - ... not found so exit ... - found: - ... found so use it ... - */ - /* print out the information for this pixel format */ - fprintf(file, "0x%02x ", i); - fprintf(file, "%3d ", pfd.cColorBits); - if(pfd.dwFlags & PFD_DRAW_TO_WINDOW) fprintf(file, "wn "); - else if(pfd.dwFlags & PFD_DRAW_TO_BITMAP) fprintf(file, "bm "); - else fprintf(file, "pb "); - /* should find transparent pixel from LAYERPLANEDESCRIPTOR */ - fprintf(file, " . "); - fprintf(file, "%3d ", pfd.cColorBits); - /* bReserved field indicates number of over/underlays */ - if(pfd.bReserved) fprintf(file, " %d ", pfd.bReserved); - else fprintf(file, " . "); - fprintf(file, " %c ", pfd.iPixelType == PFD_TYPE_RGBA ? 'r' : 'c'); - fprintf(file, "%c ", pfd.dwFlags & PFD_DOUBLEBUFFER ? 'y' : '.'); - fprintf(file, " %c ", pfd.dwFlags & PFD_STEREO ? 'y' : '.'); - /* added: */ - fprintf(file, " %c ", pfd.dwFlags & PFD_GENERIC_FORMAT ? 'y' : '.'); - fprintf(file, " %c ", pfd.dwFlags & PFD_GENERIC_ACCELERATED ? 'y' : '.'); - if(pfd.cRedBits && pfd.iPixelType == PFD_TYPE_RGBA) - fprintf(file, "%2d ", pfd.cRedBits); - else fprintf(file, " . "); - if(pfd.cGreenBits && pfd.iPixelType == PFD_TYPE_RGBA) - fprintf(file, "%2d ", pfd.cGreenBits); - else fprintf(file, " . "); - if(pfd.cBlueBits && pfd.iPixelType == PFD_TYPE_RGBA) - fprintf(file, "%2d ", pfd.cBlueBits); - else fprintf(file, " . "); - if(pfd.cAlphaBits && pfd.iPixelType == PFD_TYPE_RGBA) - fprintf(file, "%2d ", pfd.cAlphaBits); - else fprintf(file, " . "); - if(pfd.cAuxBuffers) fprintf(file, "%2d ", pfd.cAuxBuffers); - else fprintf(file, " . "); - if(pfd.cDepthBits) fprintf(file, "%2d ", pfd.cDepthBits); - else fprintf(file, " . "); - if(pfd.cStencilBits) fprintf(file, "%2d ", pfd.cStencilBits); - else fprintf(file, " . "); - if(pfd.cAccumBits) fprintf(file, "%3d ", pfd.cAccumBits); - else fprintf(file, " . "); - if(pfd.cAccumRedBits) fprintf(file, "%2d ", pfd.cAccumRedBits); - else fprintf(file, " . "); - if(pfd.cAccumGreenBits) fprintf(file, "%2d ", pfd.cAccumGreenBits); - else fprintf(file, " . "); - if(pfd.cAccumBlueBits) fprintf(file, "%2d ", pfd.cAccumBlueBits); - else fprintf(file, " . "); - if(pfd.cAccumAlphaBits) fprintf(file, "%2d ", pfd.cAccumAlphaBits); - else fprintf(file, " . "); - /* no multisample in win32 */ - fprintf(file, " . .\n"); - } - /* print table footer */ - fprintf(file, "-----------------------------------------------------------------------------\n"); - fprintf(file, " visual x bf lv rg d st ge ge r g b a ax dp st accum buffs ms \n"); - fprintf(file, " id dep tp sp sz l ci b ro ne ac sz sz sz sz bf th cl sz r g b a ns b\n"); - fprintf(file, "-----------------------------------------------------------------------------\n"); - } - else /* verbose */ - { - fprintf(file, "\n"); - /* loop through all the pixel formats */ - for(i = 1; i <= maxpf; i++) - { - DescribePixelFormat(ctx->dc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd); - /* only describe this format if it supports OpenGL */ - if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL) - || (drawableonly && !(pfd.dwFlags & PFD_DRAW_TO_WINDOW))) continue; - fprintf(file, "Visual ID: %2d depth=%d class=%s\n", i, pfd.cDepthBits, - pfd.cColorBits <= 8 ? "PseudoColor" : "TrueColor"); - fprintf(file, " bufferSize=%d level=%d renderType=%s doubleBuffer=%ld stereo=%ld\n", pfd.cColorBits, pfd.bReserved, pfd.iPixelType == PFD_TYPE_RGBA ? "rgba" : "ci", pfd.dwFlags & PFD_DOUBLEBUFFER, pfd.dwFlags & PFD_STEREO); - fprintf(file, " generic=%d generic accelerated=%d\n", (pfd.dwFlags & PFD_GENERIC_FORMAT) == PFD_GENERIC_FORMAT, (pfd.dwFlags & PFD_GENERIC_ACCELERATED) == PFD_GENERIC_ACCELERATED); - fprintf(file, " rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n", pfd.cRedBits, pfd.cGreenBits, pfd.cBlueBits, pfd.cAlphaBits); - fprintf(file, " auxBuffers=%d depthSize=%d stencilSize=%d\n", pfd.cAuxBuffers, pfd.cDepthBits, pfd.cStencilBits); - fprintf(file, " accum: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n", pfd.cAccumRedBits, pfd.cAccumGreenBits, pfd.cAccumBlueBits, pfd.cAccumAlphaBits); - fprintf(file, " multiSample=%d multisampleBuffers=%d\n", 0, 0); - fprintf(file, " Opaque.\n"); - } - } -} - -void -VisualInfo (GLContext* ctx) -{ - if (WGLEW_ARB_pixel_format) - VisualInfoARB(ctx); - else - VisualInfoGDI(ctx); -} - -/* ---------------------------------------------------------------------- */ - -#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX) - -void -VisualInfo (GLContext* ctx) -{ -/* - int attrib[] = { AGL_RGBA, AGL_NONE }; - AGLPixelFormat pf; - GLint value; - pf = aglChoosePixelFormat(NULL, 0, attrib); - while (pf != NULL) - { - aglDescribePixelFormat(pf, GL_RGBA, &value); - fprintf(stderr, "%d\n", value); - pf = aglNextPixelFormat(pf); - } -*/ -} - -#else /* GLX */ - -void -VisualInfo (GLContext* ctx) -{ - int n_fbc; - GLXFBConfig* fbc; - int value, ret, i; - - fbc = glXGetFBConfigs(ctx->dpy, DefaultScreen(ctx->dpy), &n_fbc); - - if (fbc) - { - if (!verbose) - { - /* print table header */ - fprintf(file, " +-----+-------------------------+-----------------+----------+-------------+-------+------+\n"); - fprintf(file, " | | visual | color | ax dp st | accum | ms | cav |\n"); - fprintf(file, " | id | tp xr cl fm db st lv xp | sz r g b a | bf th cl | r g b a | ns b | eat |\n"); - fprintf(file, " +-----+-------------------------+-----------------+----------+-------------+-------+------+\n"); - /* loop through all the fbcs */ - for (i=0; idpy, fbc[i], GLX_FBCONFIG_ID, &value); - if (ret != Success) - { - fprintf(file, "| ? |"); - } - else - { - fprintf(file, " |% 4d | ", value); - } - /* visual type */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_DRAWABLE_TYPE, &value); - if (ret != Success) - { - fprintf(file, " ? "); - } - else - { - if (value & GLX_WINDOW_BIT) - { - if (value & GLX_PBUFFER_BIT) - { - fprintf(file, "wp "); - } - else - { - fprintf(file, "wn "); - } - } - else - { - if (value & GLX_PBUFFER_BIT) - { - fprintf(file, "pb "); - } - else if (value & GLX_PIXMAP_BIT) - { - fprintf(file, "pm "); - } - else - { - fprintf(file, " ? "); - } - } - } - /* x renderable */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_X_RENDERABLE, &value); - if (ret != Success) - { - fprintf(file, " ? "); - } - else - { - fprintf(file, value ? " y " : " n "); - } - /* class */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_X_VISUAL_TYPE, &value); - if (ret != Success) - { - fprintf(file, " ? "); - } - else - { - if (GLX_TRUE_COLOR == value) - fprintf(file, "tc "); - else if (GLX_DIRECT_COLOR == value) - fprintf(file, "dc "); - else if (GLX_PSEUDO_COLOR == value) - fprintf(file, "pc "); - else if (GLX_STATIC_COLOR == value) - fprintf(file, "sc "); - else if (GLX_GRAY_SCALE == value) - fprintf(file, "gs "); - else if (GLX_STATIC_GRAY == value) - fprintf(file, "sg "); - else if (GLX_X_VISUAL_TYPE == value) - fprintf(file, " . "); - else - fprintf(file, " ? "); - } - /* format */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_RENDER_TYPE, &value); - if (ret != Success) - { - fprintf(file, " ? "); - } - else - { - if (GLXEW_NV_float_buffer) - { - int ret2, value2; - ret2 = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_FLOAT_COMPONENTS_NV, &value2); - if (Success == ret2 && GL_TRUE == value2) - { - fprintf(file, " f "); - } - else if (value & GLX_RGBA_BIT) - fprintf(file, " i "); - else if (value & GLX_COLOR_INDEX_BIT) - fprintf(file, " c "); - else - fprintf(file, " ? "); - } - else - { - if (value & GLX_RGBA_FLOAT_ATI_BIT) - fprintf(file, " f "); - else if (value & GLX_RGBA_BIT) - fprintf(file, " i "); - else if (value & GLX_COLOR_INDEX_BIT) - fprintf(file, " c "); - else - fprintf(file, " ? "); - } - } - /* double buffer */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_DOUBLEBUFFER, &value); - fprintf(file, " %c ", Success != ret ? '?' : (value ? 'y' : '.')); - /* stereo */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_STEREO, &value); - fprintf(file, " %c ", Success != ret ? '?' : (value ? 'y' : '.')); - /* level */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_LEVEL, &value); - if (Success != ret) - { - fprintf(file, " ? "); - } - else - { - fprintf(file, "%2d ", value); - } - /* transparency */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_TRANSPARENT_TYPE, &value); - if (Success != ret) - { - fprintf(file, " ? | "); - } - else - { - if (GLX_TRANSPARENT_RGB == value) - fprintf(file, " r | "); - else if (GLX_TRANSPARENT_INDEX == value) - fprintf(file, " i | "); - else if (GLX_NONE == value) - fprintf(file, " . | "); - else - fprintf(file, " ? | "); - } - /* color size */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_BUFFER_SIZE, &value); - if (Success != ret) - { - fprintf(file, " ? "); - } - else - { - if (value) - fprintf(file, "%3d ", value); - else - fprintf(file, " . "); - } - /* red size */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_RED_SIZE, &value); - if (Success != ret) - { - fprintf(file, " ? "); - } - else - { - if (value) - fprintf(file, "%2d ", value); - else - fprintf(file, " . "); - } - /* green size */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_GREEN_SIZE, &value); - if (Success != ret) - { - fprintf(file, " ? "); - } - else - { - if (value) - fprintf(file, "%2d ", value); - else - fprintf(file, " . "); - } - /* blue size */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_BLUE_SIZE, &value); - if (Success != ret) - { - fprintf(file, " ? "); - } - else - { - if (value) - fprintf(file, "%2d ", value); - else - fprintf(file, " . "); - } - /* alpha size */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_ALPHA_SIZE, &value); - if (Success != ret) - { - fprintf(file, " ? | "); - } - else - { - if (value) - fprintf(file, "%2d | ", value); - else - fprintf(file, " . | "); - } - /* aux buffers */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_AUX_BUFFERS, &value); - if (Success != ret) - { - fprintf(file, " ? "); - } - else - { - if (value) - fprintf(file, "%2d ", value); - else - fprintf(file, " . "); - } - /* depth size */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_DEPTH_SIZE, &value); - if (Success != ret) - { - fprintf(file, " ? "); - } - else - { - if (value) - fprintf(file, "%2d ", value); - else - fprintf(file, " . "); - } - /* stencil size */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_STENCIL_SIZE, &value); - if (Success != ret) - { - fprintf(file, " ? | "); - } - else - { - if (value) - fprintf(file, "%2d | ", value); - else - fprintf(file, " . | "); - } - /* accum red size */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_ACCUM_RED_SIZE, &value); - if (Success != ret) - { - fprintf(file, " ? "); - } - else - { - if (value) - fprintf(file, "%2d ", value); - else - fprintf(file, " . "); - } - /* accum green size */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_ACCUM_GREEN_SIZE, &value); - if (Success != ret) - { - fprintf(file, " ? "); - } - else - { - if (value) - fprintf(file, "%2d ", value); - else - fprintf(file, " . "); - } - /* accum blue size */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_ACCUM_BLUE_SIZE, &value); - if (Success != ret) - { - fprintf(file, " ? "); - } - else - { - if (value) - fprintf(file, "%2d ", value); - else - fprintf(file, " . "); - } - /* accum alpha size */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_ACCUM_ALPHA_SIZE, &value); - if (Success != ret) - { - fprintf(file, " ? | "); - } - else - { - if (value) - fprintf(file, "%2d | ", value); - else - fprintf(file, " . | "); - } - /* multisample */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_SAMPLES, &value); - if (Success != ret) - { - fprintf(file, " ? "); - } - else - { - fprintf(file, "%2d ", value); - } - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_SAMPLE_BUFFERS, &value); - if (Success != ret) - { - fprintf(file, " ? | "); - } - else - { - fprintf(file, "%2d | ", value); - } - /* caveat */ - ret = glXGetFBConfigAttrib(ctx->dpy, fbc[i], GLX_CONFIG_CAVEAT, &value); - if (Success != ret) - { - fprintf(file, "???? |"); - } - else - { - if (GLX_NONE == value) - fprintf(file, "none |\n"); - else if (GLX_SLOW_CONFIG == value) - fprintf(file, "slow |\n"); - else if (GLX_NON_CONFORMANT_CONFIG == value) - fprintf(file, "ncft |\n"); - else - fprintf(file, "???? |\n"); - } - } - /* print table footer */ - fprintf(file, " +-----+-------------------------+-----------------+----------+-------------+-------+------+\n"); - fprintf(file, " | id | tp xr cl fm db st lv xp | sz r g b a | bf th cl | r g b a | ns b | eat |\n"); - fprintf(file, " | | visual | color | ax dp st | accum | ms | cav |\n"); - fprintf(file, " +-----+-------------------------+-----------------+----------+-------------+-------+------+\n"); - } - } -} - -#endif - -/* ------------------------------------------------------------------------ */ - -#if defined(_WIN32) - -void InitContext (GLContext* ctx) -{ - ctx->wnd = NULL; - ctx->dc = NULL; - ctx->rc = NULL; -} - -GLboolean CreateContext (GLContext* ctx) -{ - WNDCLASS wc; - PIXELFORMATDESCRIPTOR pfd; - /* check for input */ - if (NULL == ctx) return GL_TRUE; - /* register window class */ - ZeroMemory(&wc, sizeof(WNDCLASS)); - wc.hInstance = GetModuleHandle(NULL); - wc.lpfnWndProc = DefWindowProc; - wc.lpszClassName = "GLEW"; - if (0 == RegisterClass(&wc)) return GL_TRUE; - /* create window */ - ctx->wnd = CreateWindow("GLEW", "GLEW", 0, CW_USEDEFAULT, CW_USEDEFAULT, - CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, - GetModuleHandle(NULL), NULL); - if (NULL == ctx->wnd) return GL_TRUE; - /* get the device context */ - ctx->dc = GetDC(ctx->wnd); - if (NULL == ctx->dc) return GL_TRUE; - /* find pixel format */ - ZeroMemory(&pfd, sizeof(PIXELFORMATDESCRIPTOR)); - if (visual == -1) /* find default */ - { - pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); - pfd.nVersion = 1; - pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; - visual = ChoosePixelFormat(ctx->dc, &pfd); - if (0 == visual) return GL_TRUE; - } - /* set the pixel format for the dc */ - if (FALSE == SetPixelFormat(ctx->dc, visual, &pfd)) return GL_TRUE; - /* create rendering context */ - ctx->rc = wglCreateContext(ctx->dc); - if (NULL == ctx->rc) return GL_TRUE; - if (FALSE == wglMakeCurrent(ctx->dc, ctx->rc)) return GL_TRUE; - return GL_FALSE; -} - -void DestroyContext (GLContext* ctx) -{ - if (NULL == ctx) return; - if (NULL != ctx->rc) wglMakeCurrent(NULL, NULL); - if (NULL != ctx->rc) wglDeleteContext(wglGetCurrentContext()); - if (NULL != ctx->wnd && NULL != ctx->dc) ReleaseDC(ctx->wnd, ctx->dc); - if (NULL != ctx->wnd) DestroyWindow(ctx->wnd); - UnregisterClass("GLEW", GetModuleHandle(NULL)); -} - -/* ------------------------------------------------------------------------ */ - -#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX) - -void InitContext (GLContext* ctx) -{ - ctx->ctx = NULL; - ctx->octx = NULL; -} - -GLboolean CreateContext (GLContext* ctx) -{ - int attrib[] = { AGL_RGBA, AGL_NONE }; - AGLPixelFormat pf; - /* check input */ - if (NULL == ctx) return GL_TRUE; - /*int major, minor; - SetPortWindowPort(wnd); - aglGetVersion(&major, &minor); - fprintf(stderr, "GL %d.%d\n", major, minor);*/ - pf = aglChoosePixelFormat(NULL, 0, attrib); - if (NULL == pf) return GL_TRUE; - ctx->ctx = aglCreateContext(pf, NULL); - if (NULL == ctx->ctx || AGL_NO_ERROR != aglGetError()) return GL_TRUE; - aglDestroyPixelFormat(pf); - /*aglSetDrawable(ctx, GetWindowPort(wnd));*/ - ctx->octx = aglGetCurrentContext(); - if (NULL == aglSetCurrentContext(ctx->ctx)) return GL_TRUE; - return GL_FALSE; -} - -void DestroyContext (GLContext* ctx) -{ - if (NULL == ctx) return; - aglSetCurrentContext(ctx->octx); - if (NULL != ctx->ctx) aglDestroyContext(ctx->ctx); -} - -/* ------------------------------------------------------------------------ */ - -#else /* __UNIX || (__APPLE__ && GLEW_APPLE_GLX) */ - -void InitContext (GLContext* ctx) -{ - ctx->dpy = NULL; - ctx->vi = NULL; - ctx->ctx = NULL; - ctx->wnd = 0; - ctx->cmap = 0; -} - -GLboolean CreateContext (GLContext* ctx) -{ - int attrib[] = { GLX_RGBA, GLX_DOUBLEBUFFER, None }; - int erb, evb; - XSetWindowAttributes swa; - /* check input */ - if (NULL == ctx) return GL_TRUE; - /* open display */ - ctx->dpy = XOpenDisplay(display); - if (NULL == ctx->dpy) return GL_TRUE; - /* query for glx */ - if (!glXQueryExtension(ctx->dpy, &erb, &evb)) return GL_TRUE; - /* choose visual */ - ctx->vi = glXChooseVisual(ctx->dpy, DefaultScreen(ctx->dpy), attrib); - if (NULL == ctx->vi) return GL_TRUE; - /* create context */ - ctx->ctx = glXCreateContext(ctx->dpy, ctx->vi, None, True); - if (NULL == ctx->ctx) return GL_TRUE; - /* create window */ - /*wnd = XCreateSimpleWindow(dpy, RootWindow(dpy, vi->screen), 0, 0, 1, 1, 1, 0, 0);*/ - ctx->cmap = XCreateColormap(ctx->dpy, RootWindow(ctx->dpy, ctx->vi->screen), - ctx->vi->visual, AllocNone); - swa.border_pixel = 0; - swa.colormap = ctx->cmap; - ctx->wnd = XCreateWindow(ctx->dpy, RootWindow(ctx->dpy, ctx->vi->screen), - 0, 0, 1, 1, 0, ctx->vi->depth, InputOutput, ctx->vi->visual, - CWBorderPixel | CWColormap, &swa); - /* make context current */ - if (!glXMakeCurrent(ctx->dpy, ctx->wnd, ctx->ctx)) return GL_TRUE; - return GL_FALSE; -} - -void DestroyContext (GLContext* ctx) -{ - if (NULL != ctx->dpy && NULL != ctx->ctx) glXDestroyContext(ctx->dpy, ctx->ctx); - if (NULL != ctx->dpy && 0 != ctx->wnd) XDestroyWindow(ctx->dpy, ctx->wnd); - if (NULL != ctx->dpy && 0 != ctx->cmap) XFreeColormap(ctx->dpy, ctx->cmap); - if (NULL != ctx->vi) XFree(ctx->vi); - if (NULL != ctx->dpy) XCloseDisplay(ctx->dpy); -} - -#endif /* __UNIX || (__APPLE__ && GLEW_APPLE_GLX) */ - -GLboolean ParseArgs (int argc, char** argv) -{ - int p = 0; - while (p < argc) - { -#if defined(_WIN32) - if (!strcmp(argv[p], "-pf") || !strcmp(argv[p], "-pixelformat")) - { - if (++p >= argc) return GL_TRUE; - display = NULL; - visual = strtol(argv[p], NULL, 0); - } - else if (!strcmp(argv[p], "-a")) - { - showall = 1; - } - else if (!strcmp(argv[p], "-s")) - { - displaystdout = 1; - } - else if (!strcmp(argv[p], "-h")) - { - return GL_TRUE; - } - else - return GL_TRUE; -#else - if (!strcmp(argv[p], "-display")) - { - if (++p >= argc) return GL_TRUE; - display = argv[p]; - } - else if (!strcmp(argv[p], "-visual")) - { - if (++p >= argc) return GL_TRUE; - visual = (int)strtol(argv[p], NULL, 0); - } - else if (!strcmp(argv[p], "-h")) - { - return GL_TRUE; - } - else - return GL_TRUE; -#endif - p++; - } - return GL_FALSE; -} diff --git a/oversampling/WDL/lice/lice.cpp b/oversampling/WDL/lice/lice.cpp deleted file mode 100644 index 40db3c8..0000000 --- a/oversampling/WDL/lice/lice.cpp +++ /dev/null @@ -1,3058 +0,0 @@ -/* - Cockos WDL - LICE - Lightweight Image Compositing Engine - Copyright (C) 2007 and later, Cockos Incorporated - File: lice.cpp (LICE core processing) - See lice.h for license and other information -*/ - - -#ifndef __LICE_CPP_IMPLEMENTED__ -#define __LICE_CPP_IMPLEMENTED__ - -#ifndef WDL_NO_DEFINE_MINMAX -#define WDL_NO_DEFINE_MINMAX -#endif -#include "lice.h" -#include -#include // only included in case we need to debug with sprintf etc - -#include "lice_combine.h" -#include "lice_extended.h" - -#ifndef _WIN32 -#include "../swell/swell.h" -#endif - -#define IGNORE_SCALING(mode) ((mode)&LICE_BLIT_IGNORE_SCALING) - -#define DO_RECT_SC(mode) \ - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); \ - if (__sc>0) { \ - if (!IGNORE_SCALING(mode)) { \ - __LICE_SC(x); \ - __LICE_SC(y); \ - __LICE_SCU(w); \ - __LICE_SCU(h); \ - } \ - __LICE_SCU(destbm_w); \ - __LICE_SCU(destbm_h); \ - } - - - -_LICE_ImageLoader_rec *LICE_ImageLoader_list; - -LICE_pixel LICE_CombinePixels(LICE_pixel dest, LICE_pixel src, float alpha, int mode) -{ - int r = LICE_GETR(src); - int g = LICE_GETG(src); - int b = LICE_GETB(src); - int a = LICE_GETA(src); - int al = (int)(alpha*256.0f); - -#define __LICE__ACTION(COMBFUNC) COMBFUNC::doPix((LICE_pixel_chan*)&dest,r, g, b, a, al) - __LICE_ACTION_SRCALPHA(mode, al,false); -#undef __LICE__ACTION - - return dest; -} - - -void LICE_CombinePixels2(LICE_pixel *destptr, int r, int g, int b, int a, int ia, int mode) -{ -#define __LICE__ACTION(COMBFUNC) COMBFUNC::doPix((LICE_pixel_chan*)destptr,r, g, b, a, ia) - __LICE_ACTION_SRCALPHA(mode, ia, false); -#undef __LICE__ACTION -} -void LICE_CombinePixels2Clamp(LICE_pixel *destptr, int r, int g, int b, int a, int ia, int mode) -{ -#define __LICE__ACTION(COMBFUNC) COMBFUNC::doPix((LICE_pixel_chan*)destptr,r, g, b, a, ia) - __LICE_ACTION_SRCALPHA(mode, ia, true); -#undef __LICE__ACTION -} - - -LICE_MemBitmap::LICE_MemBitmap(int w, int h, unsigned int linealign) -{ - m_allocsize=0; - m_fb=0; - m_width=0; - m_height=0; - m_linealign = linealign > 1 ? ((linealign & ~(linealign-1))-1) : 0; // force to be contiguous bits - if (m_linealign>16) m_linealign=16; - if (w>0&&h>0) __resize(w,h); -} - -LICE_MemBitmap::~LICE_MemBitmap() { free(m_fb); } - -bool LICE_MemBitmap::__resize(int w, int h) -{ - if (w!=m_width||h!=m_height) - { -#ifdef DEBUG_TIGHT_ALLOC // dont enable for anything you want to be even remotely fast - free(m_fb); - m_fb = (LICE_pixel *)malloc((m_allocsize = ((w+m_linealign)&~m_linealign)*h*sizeof(LICE_pixel)) + LICE_MEMBITMAP_ALIGNAMT); - m_width=m_fb?w:0; - m_height=m_fb?h:0; - return true; -#endif - int sz=(((m_width=w)+m_linealign)&~m_linealign)*(m_height=h)*sizeof(LICE_pixel); - - if (sz<=0||w<1||h<1) { free(m_fb); m_fb=0; m_allocsize=0; } - else if (!m_fb) m_fb=(LICE_pixel*)malloc((m_allocsize=sz) + LICE_MEMBITMAP_ALIGNAMT); - else - { - if (sz>m_allocsize) - { - void *op=m_fb; - if (!(m_fb=(LICE_pixel*)realloc(m_fb,(m_allocsize=sz+sz/4)+LICE_MEMBITMAP_ALIGNAMT))) - { - free(op); - m_fb=(LICE_pixel*)malloc((m_allocsize=sz)+LICE_MEMBITMAP_ALIGNAMT); - } - } - } - if (!m_fb) {m_width=m_height=0; } - - return true; - } - return false; -} - - - -#ifndef _LICE_NO_SYSBITMAPS_ - -LICE_SysBitmap::LICE_SysBitmap(int w, int h) -{ - m_allocw=m_alloch=0; -#ifdef _WIN32 - m_dc = CreateCompatibleDC(NULL); - m_bitmap = 0; - m_oldbitmap = 0; -#else - m_dc=0; -#endif - m_bits=0; - m_width=m_height=0; - m_adv_scaling=0; - m_draw_scaling=0; - - __resize(w,h); -} - - -LICE_SysBitmap::~LICE_SysBitmap() -{ -#ifdef _WIN32 - if (m_oldbitmap && m_dc) SelectObject(m_dc,m_oldbitmap); - if (m_bitmap) DeleteObject(m_bitmap); - if (m_dc) DeleteDC(m_dc); -#else - if (m_dc) - SWELL_DeleteGfxContext(m_dc); -#endif -} - -bool LICE_SysBitmap::__resize(int w, int h) -{ -#ifdef _WIN32 - if (!m_dc) { m_width=m_height=0; m_bits=0; return false; } -#endif - - if (m_width==w && m_height == h) return false; - - m_width=w; - m_height=h; - - if (m_draw_scaling > 0) - { - w = (w * m_draw_scaling) >> 8; - h = (h * m_draw_scaling) >> 8; - } - w = (w+3)&~3; // always keep backing store a multiple of 4px wide - -#ifndef DEBUG_TIGHT_ALLOC - // dont resize down bitmaps - if (w && h && w <= m_allocw && h <= m_alloch && m_bits) - { -#ifndef _WIN32 - if (isFlipped()) - { - m_bits=(LICE_pixel*)SWELL_GetCtxFrameBuffer(m_dc); - m_bits += (m_alloch-h)*m_allocw; - } -#endif - return true; - } -#endif//!DEBUG_TIGHT_ALLOC - - m_allocw=w; - m_alloch=h; - -#ifdef _WIN32 - if (m_oldbitmap) - { - SelectObject(m_dc,m_oldbitmap); - m_oldbitmap=0; - } - if (m_bitmap) DeleteObject(m_bitmap); - m_bitmap=0; - m_bits=0; - - - if (w<1 || h<1) return false; - - BITMAPINFO pbmInfo = {0,}; - pbmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - pbmInfo.bmiHeader.biWidth = w; - pbmInfo.bmiHeader.biHeight = isFlipped()?h:-h; - pbmInfo.bmiHeader.biPlanes = 1; - pbmInfo.bmiHeader.biBitCount = sizeof(LICE_pixel)*8; - pbmInfo.bmiHeader.biCompression = BI_RGB; - m_bitmap = CreateDIBSection( NULL, &pbmInfo, DIB_RGB_COLORS, (void **)&m_bits, NULL, 0); - - if (m_bitmap) m_oldbitmap=SelectObject(m_dc, m_bitmap); - else { m_width=m_height=0; m_bits=0; } -#else - if (m_dc) SWELL_DeleteGfxContext(m_dc); - m_dc=0; - m_bits=0; - - if (w<1 || h<1) return false; - - m_dc=SWELL_CreateMemContext(0,w,h); - if (!m_dc) { m_width=m_height=0; m_bits=0; } - else m_bits=(LICE_pixel*)SWELL_GetCtxFrameBuffer(m_dc); -#endif - - return true; -} - -#endif // _LICE_NO_SYSBITMAPS_ - - - -#ifndef LICE_NO_BLIT_SUPPORT -void LICE_Copy(LICE_IBitmap *dest, LICE_IBitmap *src) // resizes dest -{ - if (src&&dest) - { - dest->resize(src->getWidth(),src->getHeight()); - LICE_Blit(dest,src,0,0,NULL,1.0,LICE_BLIT_MODE_COPY); - } -} -#endif - -template class _LICE_Template_Blit0 // these always templated -{ - public: - static void solidBlitFAST(LICE_pixel *dest, int w, int h, - LICE_pixel color, - int dest_span) - { - while (h--) - { - LICE_pixel *pout=dest; - int n=w; - while (n--) - { - COMBFUNC::doPixFAST(pout,color); - ++pout; - } - dest+=dest_span; - } - } - - - - static void scaleBlitFAST(LICE_pixel_chan *dest, const LICE_pixel_chan *src, int w, int h, - int icurx, int icury, int idx, int idy, unsigned int clipright, unsigned int clipbottom, - int src_span, int dest_span) - { - LICE_pixel* destpx = (LICE_pixel*) dest; - int destpxspan = dest_span*(int)sizeof(LICE_pixel_chan)/(int)sizeof(LICE_pixel); - - while (h--) - { - const unsigned int cury = icury >> 16; - if (cury < clipbottom) - { - int curx=icurx; - const LICE_pixel_chan *inptr=src + cury * src_span; - LICE_pixel* pout = destpx; - int n=w; - while (n--) - { - const unsigned int offs=curx >> 16; - if (offs -#endif -class _LICE_Template_Blit1 // these controlled by LICE_FAVOR_SIZE_EXTREME -{ -#ifdef LICE_FAVOR_SIZE_EXTREME - #define DOPIX(pout,r,g,b,a,ia) combFunc(pout,r,g,b,a,ia); -#else - #define DOPIX(pout,r,g,b,a,ia) COMBFUNC::doPix(pout,r,g,b,a,ia); -#endif - public: - static void solidBlit(LICE_pixel_chan *dest, int w, int h, - int ir, int ig, int ib, int pxa, int ia, - int dest_span -#ifdef LICE_FAVOR_SIZE_EXTREME - , LICE_COMBINEFUNC combFunc -#endif - ) - { - while (h--) - { - LICE_pixel_chan *pout=dest; - int n=w; - while (n--) - { - DOPIX(pout,ir,ig,ib,pxa,ia); - pout += sizeof(LICE_pixel)/sizeof(LICE_pixel_chan); - } - dest+=dest_span; - } - } - static void gradBlit(LICE_pixel_chan *dest, int w, int h, - int ir, int ig, int ib, int ia, - int drdx, int dgdx, int dbdx, int dadx, - int drdy, int dgdy, int dbdy, int dady, - int dest_span -#ifdef LICE_FAVOR_SIZE_EXTREME - , LICE_COMBINEFUNC combFunc -#endif - ) - { - while (h--) - { - int r=ir,g=ig,b=ib,a=ia; - ir+=drdy; ig+=dgdy; ib+=dbdy; ia+=dady; - LICE_pixel_chan *pout=dest; - int n=w; - while (n--) - { - const int aa=a/65536; - DOPIX(pout,r/65536,g/65536,b/65536,aa,aa); - pout += sizeof(LICE_pixel)/sizeof(LICE_pixel_chan); - r+=drdx; g+=dgdx; b+=dbdx; a+=dadx; - } - dest+=dest_span; - } - } - -#undef DOPIX -}; - - -#ifndef LICE_FAVOR_SIZE -template -#endif -class _LICE_Template_Blit2 // these controlled by LICE_FAVOR_SIZE -{ -#ifdef LICE_FAVOR_SIZE - #define DOPIX(pout,r,g,b,a,ia) combFunc(pout,r,g,b,a,ia); -#else - #define DOPIX(pout,r,g,b,a,ia) COMBFUNC::doPix(pout,r,g,b,a,ia); -#endif - - public: - - static void blit(LICE_pixel_chan *dest, const LICE_pixel_chan *src, int w, int h, int src_span, int dest_span, int ia -#ifdef LICE_FAVOR_SIZE - , LICE_COMBINEFUNC combFunc -#endif - ) - { - while (h-->0) - { - int n=w; - const LICE_pixel_chan *pin=src; - LICE_pixel_chan *pout=dest; - while (n--) - { - - DOPIX(pout,pin[LICE_PIXEL_R],pin[LICE_PIXEL_G],pin[LICE_PIXEL_B],pin[LICE_PIXEL_A],ia); - - pin += sizeof(LICE_pixel)/sizeof(LICE_pixel_chan); - pout += sizeof(LICE_pixel)/sizeof(LICE_pixel_chan); - } - dest+=dest_span; - src += src_span; - } - } - - // this is only designed for filtering down an image approx 2:1 to 4:1 or so.. it'll work (poortly) for higher, and for less it's crap too. - // probably need to redo it using linear interpolation of the filter coefficients, but bleh I'm gonna go play some call of duty - static void scaleBlitFilterDown(LICE_pixel_chan *dest, const LICE_pixel_chan *src, int w, int h, - int icurx, int icury, int idx, int idy, int clipright, int clipbottom, - int src_span, int dest_span, int ia, const int *filter, int filt_start, int filtsz -#ifdef LICE_FAVOR_SIZE - , LICE_COMBINEFUNC combFunc -#endif - - ) - { - - while (h--) - { - int cury = icury >> 16; - int curx=icurx; - int n=w; - if (cury >= 0 && cury < clipbottom) - { - const LICE_pixel_chan *inptr=src + (cury+filt_start) * src_span; - LICE_pixel_chan *pout=dest; - while (n--) - { - int offs=curx >> 16; - if (offs>=0 && offs= clipbottom) break; - - if (ypos >= 0) - { - int xpos=offs + filt_start; - const LICE_pixel_chan *pin = rdptr; - int fx=filtsz; - while (fx--) - { - int tsc = *scaletab++; - if (xpos >= 0 && xpos < clipright) - { - r+=pin[LICE_PIXEL_R]*tsc; - g+=pin[LICE_PIXEL_G]*tsc; - b+=pin[LICE_PIXEL_B]*tsc; - a+=pin[LICE_PIXEL_A]*tsc; - sc+=tsc; - } - xpos++; - pin+=sizeof(LICE_pixel)/sizeof(LICE_pixel_chan); - } - } - else scaletab += filtsz; - - ypos++; - rdptr+=src_span; - } - if (sc>0) - { - DOPIX(pout,r/sc,g/sc,b/sc,a/sc,ia); - } - } - - pout += sizeof(LICE_pixel)/sizeof(LICE_pixel_chan); - curx+=idx; - } - } - dest+=dest_span; - icury+=idy; - } - } - static void scaleBlit(LICE_pixel_chan *dest, const LICE_pixel_chan *src, int w, int h, - int icurx, int icury, int idx, int idy, unsigned int clipright, unsigned int clipbottom, - int src_span, int dest_span, int ia, int filtermode -#ifdef LICE_FAVOR_SIZE - , LICE_COMBINEFUNC combFunc -#endif - - ) - { - - if (filtermode == LICE_BLIT_FILTER_BILINEAR) - { - while (h--) - { - const unsigned int cury = icury >> 16; - const int yfrac=icury&65535; - int curx=icurx; - const LICE_pixel_chan *inptr=src + cury * src_span; - LICE_pixel_chan *pout=dest; - int n=w; - if (cury < clipbottom-1) - { - while (n--) - { - const unsigned int offs=curx >> 16; - const LICE_pixel_chan *pin = inptr + offs*sizeof(LICE_pixel); - if (offs> 16; - const LICE_pixel_chan *pin = inptr + offs*sizeof(LICE_pixel); - if (offs> 16; - if (cury < clipbottom) - { - int curx=icurx; - const LICE_pixel_chan *inptr=src + cury * src_span; - LICE_pixel_chan *pout=dest; - int n=w; - while (n--) - { - const unsigned int offs=curx >> 16; - if (offs -#endif -class _LICE_Template_Blit3 // stuff controlled by LICE_FAVOR_SPEED -{ -#ifndef LICE_FAVOR_SPEED - #define DOPIX(pout,r,g,b,a,ia) combFunc(pout,r,g,b,a,ia); -#else - #define DOPIX(pout,r,g,b,a,ia) COMBFUNC::doPix(pout,r,g,b,a,ia); -#endif - - public: - - static void deltaBlit(LICE_pixel_chan *dest, const LICE_pixel_chan *src, int w, int h, - int isrcx, int isrcy, int idsdx, int idtdx, int idsdy, int idtdy, - int idsdxdy, int idtdxdy, - unsigned int src_right, unsigned int src_bottom, - int src_span, int dest_span, int ia, int filtermode -#ifndef LICE_FAVOR_SPEED - , LICE_COMBINEFUNC combFunc -#endif - ) - { - if (filtermode == LICE_BLIT_FILTER_BILINEAR) - { - while (h--) - { - int thisx=isrcx; - int thisy=isrcy; - LICE_pixel_chan *pout=dest; - int n=w; - while (n--) - { - const unsigned int cury = thisy >> 16; - const unsigned int curx = thisx >> 16; - if (cury < src_bottom-1) - { - if (curx < src_right-1) - { - const LICE_pixel_chan *pin = src + cury * src_span + curx*sizeof(LICE_pixel); - int r,g,b,a; - - __LICE_BilinearFilterI(&r,&g,&b,&a,pin,pin+src_span,thisx&65535,thisy&65535); - - DOPIX(pout,r,g,b,a,ia); - } - else if (curx==src_right-1) - { - - const LICE_pixel_chan *pin = src + cury * src_span + curx*sizeof(LICE_pixel); - int r,g,b,a; - - __LICE_LinearFilterI(&r,&g,&b,&a,pin,pin+src_span,thisy&65535); - DOPIX(pout,r,g,b,a,ia); - } - } - else if (cury==src_bottom-1) - { - if (curx> 16; - const unsigned int curx = thisx >> 16; - if (cury < src_bottom && curx < src_right) - { - const LICE_pixel_chan *pin = src + cury * src_span + curx*sizeof(LICE_pixel); - - DOPIX(pout,pin[LICE_PIXEL_R],pin[LICE_PIXEL_G],pin[LICE_PIXEL_B],pin[LICE_PIXEL_A],ia); - } - - pout += sizeof(LICE_pixel)/sizeof(LICE_pixel_chan); - thisx+=idsdx; - thisy+=idtdx; - } - idsdx+=idsdxdy; - idtdx+=idtdxdy; - isrcx+=idsdy; - isrcy+=idtdy; - dest+=dest_span; - } - } - } - -#undef DOPIX -}; - -#ifdef LICE_FAVOR_SPEED -template -#endif -class _LICE_Template_Blit4 // stuff controlled by LICE_FAVOR_SPEED -{ -#ifndef LICE_FAVOR_SPEED - #define DOPIX(pout,r,g,b,a,ia) combFunc(pout,r,g,b,a,ia); -#else - #define DOPIX(pout,r,g,b,a,ia) COMBFUNC::doPix(pout,r,g,b,a,ia); -#endif - - public: - - static void deltaBlitAlpha(LICE_pixel_chan *dest, const LICE_pixel_chan *src, int w, int h, - int isrcx, int isrcy, int idsdx, int idtdx, int idsdy, int idtdy, - int idsdxdy, int idtdxdy, - unsigned int src_right, unsigned int src_bottom, - int src_span, int dest_span, int ia, int idadx, int idady, int idadxdy, int filtermode -#ifndef LICE_FAVOR_SPEED - , LICE_COMBINEFUNC combFunc -#endif - ) - { - if (filtermode == LICE_BLIT_FILTER_BILINEAR) - { - while (h--) - { - int thisx=isrcx; - int thisy=isrcy; - int thisa=ia; - LICE_pixel_chan *pout=dest; - int n=w; - while (n--) - { - const unsigned int cury = thisy >> 16; - const unsigned int curx = thisx >> 16; - if (cury < src_bottom-1) - { - if (curx < src_right-1) - { - const LICE_pixel_chan *pin = src + cury * src_span + curx*sizeof(LICE_pixel); - int r,g,b,a; - - __LICE_BilinearFilterI(&r,&g,&b,&a,pin,pin+src_span,thisx&65535,thisy&65535); - - DOPIX(pout,r,g,b,a,thisa>>8); - } - else if (curx==src_right-1) - { - - const LICE_pixel_chan *pin = src + cury * src_span + curx*sizeof(LICE_pixel); - int r,g,b,a; - - __LICE_LinearFilterI(&r,&g,&b,&a,pin,pin+src_span,thisy&65535); - DOPIX(pout,r,g,b,a,thisa>>8); - } - } - else if (cury==src_bottom-1) - { - if (curx>8); - } - else if (curx==src_right-1) - { - const LICE_pixel_chan *pin = src + cury * src_span + curx*sizeof(LICE_pixel); - DOPIX(pout,pin[LICE_PIXEL_R],pin[LICE_PIXEL_G],pin[LICE_PIXEL_B],pin[LICE_PIXEL_A],thisa>>8); - } - } - - pout += sizeof(LICE_pixel)/sizeof(LICE_pixel_chan); - thisx+=idsdx; - thisy+=idtdx; - thisa+=idadx; - } - idsdx+=idsdxdy; - idtdx+=idtdxdy; - idadx+=idadxdy; - isrcx+=idsdy; - isrcy+=idtdy; - ia += idady; - dest+=dest_span; - } - } - else - { - while (h--) - { - int thisx=isrcx; - int thisy=isrcy; - int thisa=ia; - LICE_pixel_chan *pout=dest; - int n=w; - while (n--) - { - const unsigned int cury = thisy >> 16; - const unsigned int curx = thisx >> 16; - if (cury < src_bottom && curx < src_right) - { - const LICE_pixel_chan *pin = src + cury * src_span + curx*sizeof(LICE_pixel); - - DOPIX(pout,pin[LICE_PIXEL_R],pin[LICE_PIXEL_G],pin[LICE_PIXEL_B],pin[LICE_PIXEL_A],thisa>>8); - } - - pout += sizeof(LICE_pixel)/sizeof(LICE_pixel_chan); - thisx+=idsdx; - thisy+=idtdx; - thisa+=idadx; - } - idsdx+=idsdxdy; - idtdx+=idtdxdy; - idadx+=idadxdy; - isrcx+=idsdy; - isrcy+=idtdy; - ia+=idady; - dest+=dest_span; - } - } - } - -#undef DOPIX -}; - - - -#ifndef LICE_NO_GRADIENT_SUPPORT - -void LICE_GradRect(LICE_IBitmap *dest, int dstx, int dsty, int dstw, int dsth, - float ir, float ig, float ib, float ia, - float drdx, float dgdx, float dbdx, float dadx, - float drdy, float dgdy, float dbdy, float dady, - int mode) -{ - if (!dest) return; - - ir*=255.0; ig*=255.0; ib*=255.0; ia*=256.0; - drdx*=255.0; dgdx*=255.0; dbdx*=255.0; dadx*=256.0; - drdy*=255.0; dgdy*=255.0; dbdy*=255.0; dady*=256.0; - // dont scale alpha - - // clip to output - if (dstx < 0) - { - ir-=dstx*drdx; ig-=dstx*dgdx; ib-=dstx*dbdx; ia-=dstx*dadx; - dstw+=dstx; - dstx=0; - } - if (dsty < 0) - { - ir -= dsty*drdy; ig-=dsty*dgdy; ib -= dsty*dbdy; ia -= dsty*dady; - dsth += dsty; - dsty=0; - } - - int dest_span=dest->getRowSpan()*sizeof(LICE_pixel); - LICE_pixel_chan *pdest = (LICE_pixel_chan *)dest->getBits(); - - const int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - - if (!pdest || !dest_span || dstw < 1 || dsth < 1 || dstx >= destbm_w || dsty >= destbm_h) return; - - if (dstw > destbm_w-dstx) dstw = destbm_w-dstx; - if (dsth > destbm_h-dsty) dsth = destbm_h-dsty; - - if (dest->isFlipped()) - { - pdest += (destbm_h-dsty - 1)*dest_span; - dest_span=-dest_span; - } - else - { - pdest += dsty*dest_span; - } - pdest+=dstx*sizeof(LICE_pixel); -#define TOFIX(a) ((int)((a)*65536.0)) - - int iir=TOFIX(ir), iig=TOFIX(ig), iib=TOFIX(ib), iia=TOFIX(ia), idrdx=TOFIX(drdx),idgdx=TOFIX(dgdx),idbdx=TOFIX(dbdx),idadx=TOFIX(dadx), - idrdy=TOFIX(drdy), idgdy=TOFIX(dgdy), idbdy=TOFIX(dbdy), idady=TOFIX(dady); - - -#ifdef LICE_FAVOR_SIZE_EXTREME - LICE_COMBINEFUNC blitfunc=NULL; - #define __LICE__ACTION(comb) blitfunc=comb::doPix; -#else - - #define __LICE__ACTION(comb) _LICE_Template_Blit1::gradBlit(pdest,dstw,dsth,iir,iig,iib,iia,idrdx,idgdx,idbdx,idadx,idrdy,idgdy,idbdy,idady,dest_span) -#endif - - // todo: could predict whether or not the colors will ever go out of 0.255 range and optimize - - if ((mode & LICE_BLIT_MODE_MASK)==LICE_BLIT_MODE_COPY && iia==65536 && idady==0 && idadx == 0) - { - __LICE__ACTION(_LICE_CombinePixelsClobberClamp); - } - else - { - __LICE_ACTION_NOSRCALPHA(mode,256,true); - } - #undef __LICE__ACTION - -#ifdef LICE_FAVOR_SIZE_EXTREME - if (blitfunc) _LICE_Template_Blit1::gradBlit(pdest,dstw,dsth,iir,iig,iib,iia,idrdx,idgdx,idbdx,idadx,idrdy,idgdy,idbdy,idady,dest_span,blitfunc); -#endif - -#undef TOFIX -} - -#endif - - -#ifndef LICE_NO_BLIT_SUPPORT - -static void LICE_BlitInt(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, const RECT *srcrect, float alpha, int mode, bool allowSc) -{ - if (!dest || !src || !alpha) return; - - int srcbm_w = src->getWidth(), srcbm_h = src->getHeight(); - int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - int __sc2 = (int)src->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc2 > 0) - { - const int __sc = __sc2; - __LICE_SCU(srcbm_w); - __LICE_SCU(srcbm_h); - } - - RECT sr={0,0,srcbm_w, srcbm_h}; - if (srcrect) - { - sr=*srcrect; - if (sr.left < 0) { dstx-=sr.left; sr.left=0; } - if (sr.top < 0) { dsty-=sr.top; sr.top=0; } - if (sr.right > srcbm_w) sr.right=srcbm_w; - if (sr.bottom > srcbm_h) sr.bottom=srcbm_h; - } - - int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (allowSc && __sc != __sc2 && !IGNORE_SCALING(mode)) - { - const int w = sr.right-sr.left, h=sr.bottom-sr.top; - LICE_ScaledBlit(dest,src,dstx,dsty,w,h, sr.left,sr.top,w,h,alpha,mode); - return; - } - if (__sc>0) - { - __LICE_SCU(destbm_w); - __LICE_SCU(destbm_h); - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(dstx); - __LICE_SC(dsty); - } - } - if (__sc2>0 && !IGNORE_SCALING(mode)) - { - __sc=__sc2; - __LICE_SC(sr.left); - __LICE_SC(sr.right); - __LICE_SC(sr.top); - __LICE_SC(sr.bottom); - } - - - // clip to output - if (dstx < 0) { sr.left -= dstx; dstx=0; } - if (dsty < 0) { sr.top -= dsty; dsty=0; } - - if (sr.left < 0 || sr.top < 0) return; // overflow check - if (sr.right <= sr.left || sr.bottom <= sr.top || dstx >= destbm_w || dsty >= destbm_h) return; - - if (sr.right > sr.left + (destbm_w-dstx)) sr.right = sr.left + (destbm_w-dstx); - if (sr.bottom > sr.top + (destbm_h-dsty)) sr.bottom = sr.top + (destbm_h-dsty); - - // ignore blits that are 0 - if (sr.right <= sr.left || sr.bottom <= sr.top) return; - -#ifndef DISABLE_LICE_EXTENSIONS - if (dest->Extended(LICE_EXT_SUPPORTS_ID, (void*) LICE_EXT_BLIT_ACCEL)) - { - LICE_Ext_Blit_acceldata data(src, dstx, dsty, - sr.left, sr.top, - sr.right-sr.left, sr.bottom-sr.top, - alpha, mode); - if (dest->Extended(LICE_EXT_BLIT_ACCEL, &data)) return; - } -#endif - - - int dest_span=dest->getRowSpan()*sizeof(LICE_pixel); - int src_span=src->getRowSpan()*sizeof(LICE_pixel); - const LICE_pixel_chan *psrc = (LICE_pixel_chan *)src->getBits(); - LICE_pixel_chan *pdest = (LICE_pixel_chan *)dest->getBits(); - if (!psrc || !pdest) return; - - if (src->isFlipped()) - { - psrc += (src->getHeight()-sr.top - 1)*src_span; - src_span=-src_span; - } - else psrc += sr.top*src_span; - psrc += sr.left*sizeof(LICE_pixel); - - if (dest->isFlipped()) - { - pdest += (destbm_h-dsty - 1)*dest_span; - dest_span=-dest_span; - } - else pdest += dsty*dest_span; - pdest+=dstx*sizeof(LICE_pixel); - - int i=sr.bottom-sr.top; - int cpsize=sr.right-sr.left; - - if ((mode&LICE_BLIT_MODE_MASK) >= LICE_BLIT_MODE_CHANCOPY && (mode&LICE_BLIT_MODE_MASK) < LICE_BLIT_MODE_CHANCOPY+0x10) - { - while (i-->0) - { - LICE_pixel_chan *o=pdest+((mode>>2)&3); - const LICE_pixel_chan *in=psrc+(mode&3); - int a=cpsize; - while (a--) - { - *o=*in; - o+=sizeof(LICE_pixel); - in+=sizeof(LICE_pixel); - } - pdest+=dest_span; - psrc += src_span; - } - } - // special fast case for copy with no source alpha and alpha=1.0 or 0.5 - else if ((mode&(LICE_BLIT_MODE_MASK|LICE_BLIT_USE_ALPHA))==LICE_BLIT_MODE_COPY && (alpha==1.0||alpha==0.5)) - { - if (alpha==0.5) - { - while (i-->0) - { - int a=cpsize; - const LICE_pixel *rd = (LICE_pixel *)psrc; - LICE_pixel *wr = (LICE_pixel *)pdest; - while (a-->0) - { - *wr = ((*wr>>1)&0x7f7f7f7f)+((*rd++>>1)&0x7f7f7f7f); - wr++; - } - - pdest+=dest_span; - psrc += src_span; - } - } - else - { - while (i-->0) - { - memmove(pdest,psrc,cpsize*sizeof(LICE_pixel)); - pdest+=dest_span; - psrc += src_span; - } - } - } - else - { - int ia=(int)(alpha*256.0); - #ifdef LICE_FAVOR_SIZE - LICE_COMBINEFUNC blitfunc=NULL; - #define __LICE__ACTION(comb) blitfunc=comb::doPix; - #else - #define __LICE__ACTION(comb) _LICE_Template_Blit2::blit(pdest,psrc,cpsize,i,src_span,dest_span,ia) - #endif - - __LICE_ACTION_SRCALPHA(mode,ia,false); - - #undef __LICE__ACTION - - #ifdef LICE_FAVOR_SIZE - if (blitfunc) _LICE_Template_Blit2::blit(pdest,psrc,cpsize,i,src_span,dest_span,ia,blitfunc); - #endif - } -} - -void LICE_Blit(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, const RECT *srcrect, float alpha, int mode) -{ - LICE_BlitInt(dest,src,dstx,dsty,srcrect,alpha,mode,true); -} - -void LICE_Blit(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, int srcx, int srcy, int srcw, int srch, float alpha, int mode) -{ - RECT r={srcx,srcy,srcx+srcw,srcy+srch}; - LICE_BlitInt(dest,src,dstx,dsty,&r,alpha,mode,true); -} - -#endif - -#ifndef LICE_NO_BLUR_SUPPORT - -void LICE_Blur(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, int srcx, int srcy, int srcw, int srch) // src and dest can overlap, however it may look fudgy if they do -{ - if (!dest || !src) return; - - RECT sr={srcx,srcy,srcx+srcw,srcy+srch}; - if (sr.left < 0) sr.left=0; - if (sr.top < 0) sr.top=0; - if (sr.right > src->getWidth()) sr.right=src->getWidth(); - if (sr.bottom > src->getHeight()) sr.bottom = src->getHeight(); - - // clip to output - if (dstx < 0) { sr.left -= dstx; dstx=0; } - if (dsty < 0) { sr.top -= dsty; dsty=0; } - - if (sr.left < 0 || sr.top < 0) return; // overflow check - - const int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - if (sr.right <= sr.left || sr.bottom <= sr.top || dstx >= destbm_w || dsty >= destbm_h) return; - - if (sr.right > sr.left + (destbm_w-dstx)) sr.right = sr.left + (destbm_w-dstx); - if (sr.bottom > sr.top + (destbm_h-dsty)) sr.bottom = sr.top + (destbm_h-dsty); - - // ignore blits that are smaller than 2x2 - if (sr.right <= sr.left+1 || sr.bottom <= sr.top+1) return; - - int dest_span=dest->getRowSpan(); - int src_span=src->getRowSpan(); - const LICE_pixel *psrc = (LICE_pixel *)src->getBits(); - LICE_pixel *pdest = (LICE_pixel *)dest->getBits(); - if (!psrc || !pdest) return; - - if (src->isFlipped()) - { - psrc += (src->getHeight()-sr.top - 1)*src_span; - src_span=-src_span; - } - else psrc += sr.top*src_span; - psrc += sr.left; - - if (dest->isFlipped()) - { - pdest += (destbm_h-dsty - 1)*dest_span; - dest_span=-dest_span; - } - else pdest += dsty*dest_span; - pdest+=dstx; - - LICE_pixel *tmpbuf=NULL; - int w=sr.right-sr.left; - - // buffer to save the last unprocessed lines for the cases where blurring from a bitmap to itself - LICE_pixel turdbuf[2048]; - if (src==dest) - { - if (w <= (int) (sizeof(turdbuf)/sizeof(turdbuf[0])/2)) tmpbuf=turdbuf; - else tmpbuf=(LICE_pixel*)malloc(w*2*sizeof(LICE_pixel)); - } - - int i; - for (i = sr.top; i < sr.bottom; i ++) - { - if (tmpbuf) - memcpy(tmpbuf+((i&1)?w:0),psrc,w*sizeof(LICE_pixel)); - - if (i==sr.top || i==sr.bottom-1) - { - const LICE_pixel *psrc2=psrc+(i==sr.top ? src_span : -src_span); - - LICE_pixel lp; - - pdest[0] = LICE_PIXEL_HALF(lp=psrc[0]) + - LICE_PIXEL_QUARTER(psrc[1]) + - LICE_PIXEL_QUARTER(psrc2[0]); - int x; - for (x = 1; x < w-1; x ++) - { - LICE_pixel tp; - pdest[x] = LICE_PIXEL_HALF(tp=psrc[x]) + - LICE_PIXEL_QUARTER(psrc2[x]) + - LICE_PIXEL_EIGHTH(psrc[x+1]) + - LICE_PIXEL_EIGHTH(lp); - lp=tp; - } - pdest[x] = LICE_PIXEL_HALF(psrc[x]) + - LICE_PIXEL_QUARTER(lp) + - LICE_PIXEL_QUARTER(psrc2[x]); - } - else - { - const LICE_pixel *psrc2=psrc-src_span; - const LICE_pixel *psrc3=psrc+src_span; - if (tmpbuf) - psrc2=tmpbuf + ((i&1) ? 0 : w); - - LICE_pixel lp; - pdest[0] = LICE_PIXEL_HALF(lp=psrc[0]) + - LICE_PIXEL_QUARTER(psrc[1]) + - LICE_PIXEL_EIGHTH(psrc2[0]) + - LICE_PIXEL_EIGHTH(psrc3[0]); - int x; - for (x = 1; x < w-1; x ++) - { - LICE_pixel tp; - pdest[x] = LICE_PIXEL_HALF(tp=psrc[x]) + - LICE_PIXEL_EIGHTH(psrc[x+1]) + - LICE_PIXEL_EIGHTH(lp) + - LICE_PIXEL_EIGHTH(psrc2[x]) + - LICE_PIXEL_EIGHTH(psrc3[x]); - lp=tp; - } - pdest[x] = LICE_PIXEL_HALF(psrc[x]) + - LICE_PIXEL_QUARTER(lp) + - LICE_PIXEL_EIGHTH(psrc2[x]) + - LICE_PIXEL_EIGHTH(psrc3[x]); - } - pdest+=dest_span; - psrc += src_span; - } - if (tmpbuf && tmpbuf != turdbuf) - free(tmpbuf); -} - -#endif - -#ifndef LICE_NO_BLIT_SUPPORT -void LICE_ScaledBlit(LICE_IBitmap *dest, LICE_IBitmap *src, - int dstx, int dsty, int dstw, int dsth, - float srcx, float srcy, float srcw, float srch, - float alpha, int mode) -{ - if (!dest || !src || !dstw || !dsth || !alpha) return; - - int srcbm_w = src->getWidth(), srcbm_h = src->getHeight(); - int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - const float srcx_orig = srcx, srcy_orig = srcy, srcw_orig = srcw, srch_orig = srch; - const int dstx_orig = dstx, dsty_orig = dsty; - if (__sc>0) - { - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(dstx); - __LICE_SC(dsty); - __LICE_SC(dstw); - __LICE_SC(dsth); - } - __LICE_SCU(destbm_w); - __LICE_SCU(destbm_h); - } - __sc = (int)src->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(srcx); - __LICE_SC(srcy); - __LICE_SC(srcw); - __LICE_SC(srch); - } - __LICE_SCU(srcbm_w); - __LICE_SCU(srcbm_h); - } - - // non-scaling optimized omde - if (fabs(srcw-dstw)<0.001 && fabs(srch-dsth)<0.001) - { - // and if not bilinear filtering, or - // the source coordinates are near their integer counterparts - if ((mode&LICE_BLIT_FILTER_MASK)!=LICE_BLIT_FILTER_BILINEAR || - (fabs(srcx-floor(srcx+0.5f))<0.03 && fabs(srcy-floor(srcy+0.5f))<0.03)) - { - RECT sr={(int)(srcx_orig+0.5f),(int)(srcy_orig+0.5f),}; - sr.right=sr.left+(int) (srcw_orig+0.5); - sr.bottom=sr.top+(int) (srch_orig+0.5); - LICE_BlitInt(dest,src,dstx_orig,dsty_orig,&sr,alpha,mode,false); - return; - } - } - -#ifndef DISABLE_LICE_EXTENSIONS - if (dest->Extended(LICE_EXT_SUPPORTS_ID, (void*) LICE_EXT_SCALEDBLIT_ACCEL)) - { - LICE_Ext_ScaledBlit_acceldata data(src, dstx, dsty, dstw, dsth, srcx, srcy, srcw, srch, alpha, mode); - if (dest->Extended(LICE_EXT_SCALEDBLIT_ACCEL, &data)) return; - } -#endif - - if (dstw<0) - { - dstw=-dstw; - dstx-=dstw; - srcx+=srcw; - srcw=-srcw; - } - if (dsth<0) - { - dsth=-dsth; - dsty-=dsth; - srcy+=srch; - srch=-srch; - } - - double xadvance = srcw / dstw; - double yadvance = srch / dsth; - - int clip_r=(int)(srcx+lice_max(srcw,0)+0.999999); // this rounding logic is shit, but we're stuck with it - int clip_b=(int)(srcy+lice_max(srch,0)+0.999999); - if (clip_r>srcbm_w) clip_r=srcbm_w; - if (clip_b>srcbm_h) clip_b=srcbm_h; - - - if (dstx < 0) { srcx -= (float) (dstx*xadvance); dstw+=dstx; dstx=0; } - if (dsty < 0) { srcy -= (float) (dsty*yadvance); dsth+=dsty; dsty=0; } - - if (dstw < 1 || dsth < 1 || dstx >= destbm_w || dsty >= destbm_h) return; - - if (dstw > destbm_w-dstx) dstw=destbm_w-dstx; - if (dsth > destbm_h-dsty) dsth=destbm_h-dsty; - - const double fidx=floor(xadvance*65536.0), fidy=floor(yadvance*65536.0); - - double ficurx=floor(srcx*65536.0), ficury=floor(srcy*65536.0); - - // the clip area calculations need to be done fixed point so the results match runtime - - if (fidx>0) - { - if (ficurx < 0) // increase dstx, decrease dstw - { - int n = (int)((fidx-1-ficurx)/fidx); - dstw-=n; - dstx+=n; - ficurx+=fidx*n; - } - if ((ficurx + fidx*(dstw-1)) >= srcbm_w*65536.0) - { - int neww = (int)(((srcbm_w-1)*65536.0 - ficurx)/fidx); - if (neww < dstw) dstw=neww; - } - } - else if (fidx<0) - { - // todo: optimize source-clipping with reversed X axis - } - - if (fidy > 0) - { - if (ficury < 0) // increase dsty, decrease dsth - { - int n = (int) ((fidy-1-ficury)/fidy); - dsth-=n; - dsty+=n; - ficury+=fidy*n; - } - if ((ficury + fidy*(dsth-1)) >= srcbm_h*65536.0) - { - int newh = (int)(((srcbm_h-1)*65536.0 - ficury)/fidy); - if (newh < dsth) dsth=newh; - } - } - else if (fidy<0) - { - // todo: optimize source-clipping with reversed Y axis (check icury against src->getHeight(), etc) - } - if (dstw<1 || dsth<1) return; - - int dest_span=dest->getRowSpan()*sizeof(LICE_pixel); - int src_span=src->getRowSpan()*sizeof(LICE_pixel); - - const LICE_pixel_chan *psrc = (const LICE_pixel_chan *)src->getBits(); - LICE_pixel_chan *pdest = (LICE_pixel_chan *)dest->getBits(); - if (!psrc || !pdest) return; - - const int srcoffs_x = (int)((ficurx + (fidx<0 ? fidx*dstw : 0))*(1.0/65536.0)); - const int srcoffs_y = (int)((ficury + (fidy<0 ? fidy*dsth : 0))*(1.0/65536.0)); - - if (src->isFlipped()) - { - psrc += (srcbm_h-1-srcoffs_y)*src_span; - src_span=-src_span; - } - else psrc += srcoffs_y * src_span; - psrc += srcoffs_x * sizeof(LICE_pixel); - - if (dest->isFlipped()) - { - pdest += (destbm_h-dsty - 1)*dest_span; - dest_span=-dest_span; - } - else pdest += dsty*dest_span; - pdest+=dstx*sizeof(LICE_pixel); - - clip_r -= srcoffs_x; - clip_b -= srcoffs_y; - - const int icurx = (int) (ficurx - srcoffs_x*65536.0); - const int icury = (int) (ficury - srcoffs_y*65536.0); - const int idx = (int) fidx, idy = (int) fidy; - - if (clip_r<1||clip_b<1) return; - - int ia=(int)(alpha*256.0); - - if ((mode&(LICE_BLIT_FILTER_MASK|LICE_BLIT_MODE_MASK|LICE_BLIT_USE_ALPHA))==LICE_BLIT_MODE_COPY && (ia==128 || ia==256)) - { - if (ia==128) - { - _LICE_Template_Blit0<_LICE_CombinePixelsHalfMixFAST>::scaleBlitFAST(pdest,psrc,dstw,dsth,icurx,icury,idx,idy,clip_r,clip_b,src_span,dest_span); - } - else - { - _LICE_Template_Blit0<_LICE_CombinePixelsClobberFAST>::scaleBlitFAST(pdest,psrc,dstw,dsth,icurx,icury,idx,idy,clip_r,clip_b,src_span,dest_span); - } - } - else - { - if (xadvance>=1.7 && yadvance >=1.7 && (mode&LICE_BLIT_FILTER_MASK)==LICE_BLIT_FILTER_BILINEAR) - { - int msc = lice_max(idx,idy); - const int filtsz=msc>(3<<16) ? 5 : 3; - const int filt_start = - (filtsz/2); - - int filter[25]; // 5x5 max - { - int y; - // char buf[4096]; - // sprintf(buf,"filter, msc=%f: ",msc); - int *p=filter; - for(y=0;y1.0) *p++=65536; - else *p++=(int)(v*65536.0); - } - } - } -// OutputDebugString(buf); - } - - #ifdef LICE_FAVOR_SIZE - LICE_COMBINEFUNC blitfunc=NULL; - #define __LICE__ACTION(comb) blitfunc=comb::doPix; - #else - #define __LICE__ACTION(comb) _LICE_Template_Blit2::scaleBlitFilterDown(pdest,psrc,dstw,dsth,icurx,icury,idx,idy,clip_r,clip_b,src_span,dest_span,ia,filter,filt_start,filtsz) - #endif - __LICE_ACTION_SRCALPHA(mode,ia,false); - #undef __LICE__ACTION - - #ifdef LICE_FAVOR_SIZE - if (blitfunc) _LICE_Template_Blit2::scaleBlitFilterDown(pdest,psrc,dstw,dsth,icurx,icury,idx,idy,clip_r,clip_b,src_span,dest_span,ia,filter,filt_start,filtsz,blitfunc); - #endif - - } - else - { - #ifdef LICE_FAVOR_SIZE - LICE_COMBINEFUNC blitfunc=NULL; - #define __LICE__ACTION(comb) blitfunc=comb::doPix; - #else - #define __LICE__ACTION(comb) _LICE_Template_Blit2::scaleBlit(pdest,psrc,dstw,dsth,icurx,icury,idx,idy,clip_r,clip_b,src_span,dest_span,ia,mode&LICE_BLIT_FILTER_MASK) - #endif - __LICE_ACTION_SRCALPHA(mode,ia,false); - #undef __LICE__ACTION - #ifdef LICE_FAVOR_SIZE - if (blitfunc) _LICE_Template_Blit2::scaleBlit(pdest,psrc,dstw,dsth,icurx,icury,idx,idy,clip_r,clip_b,src_span,dest_span,ia,mode&LICE_BLIT_FILTER_MASK,blitfunc); - #endif - } - } -} - -void LICE_DeltaBlit(LICE_IBitmap *dest, LICE_IBitmap *src, - int dstx, int dsty, int dstw, int dsth, - float srcx, float srcy, float srcw, float srch, - double dsdx, double dtdx, double dsdy, double dtdy, - double dsdxdy, double dtdxdy, - bool cliptosourcerect, float alpha, int mode) -{ - if (!dest || !src || !dstw || !dsth) return; - - int srcbm_w = src->getWidth(), srcbm_h = src->getHeight(); - int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - - int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(dstx); - __LICE_SC(dsty); - __LICE_SC(dstw); - __LICE_SC(dsth); - } - __LICE_SCU(destbm_w); - __LICE_SCU(destbm_h); - - } - const int __scdest = __sc; - __sc = (int)src->Extended(LICE_EXT_GET_SCALING,NULL); - - if (__sc>0) - { - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(srcx); - __LICE_SC(srcy); - __LICE_SC(srcw); - __LICE_SC(srch); - } - __LICE_SCU(srcbm_w); - __LICE_SCU(srcbm_h); - } - - if (__scdest != __sc && !IGNORE_SCALING(mode)) - { - const double adj = (__sc>0 ? __sc : 256.0) / (double) (__scdest>0 ? __scdest : 256.0); - dsdx *= adj; - dtdx *= adj; - dsdy *= adj; - dtdy *= adj; - dsdxdy *= adj; - dtdxdy *= adj; - } - - double src_top=0.0,src_left=0.0,src_right=srcbm_w,src_bottom=srcbm_h; - - if (cliptosourcerect) - { - if (srcx > src_left) src_left=srcx; - if (srcy > src_top) src_top=srcy; - if (srcx+srcw < src_right) src_right=srcx+srcw; - if (srcy+srch < src_bottom) src_bottom=srcy+srch; - } - - if (dstw<0) - { - dstw=-dstw; - dstx-=dstw; - srcx+=srcw; - } - if (dsth<0) - { - dsth=-dsth; - dsty-=dsth; - srcy+=srch; - } - - - if (dstx < 0) - { - srcx -= (float) (dstx*dsdx); - srcy -= (float) (dstx*dtdx); - dstw+=dstx; - dstx=0; - } - if (dsty < 0) - { - srcy -= (float) (dsty*dtdy); - srcx -= (float) (dsty*dsdy); - dsth+=dsty; - dsty=0; - } - - if (dstw < 1 || dsth < 1 || dstx >= destbm_w || dsty >= destbm_h) return; - - if (dstw > destbm_w-dstx) dstw=destbm_w-dstx; - if (dsth > destbm_h-dsty) dsth=destbm_h-dsty; - - - int dest_span=dest->getRowSpan()*sizeof(LICE_pixel); - int src_span=src->getRowSpan()*sizeof(LICE_pixel); - - const LICE_pixel_chan *psrc = (LICE_pixel_chan *)src->getBits(); - LICE_pixel_chan *pdest = (LICE_pixel_chan *)dest->getBits(); - if (!psrc || !pdest) return; - - if (src->isFlipped()) - { - psrc += (srcbm_h-1)*src_span; - src_span=-src_span; - } - - if (dest->isFlipped()) - { - pdest += (destbm_h-dsty - 1)*dest_span; - dest_span=-dest_span; - } - else pdest += dsty*dest_span; - pdest+=dstx*sizeof(LICE_pixel); - - int sl=(int)(src_left); - int sr=(int)(src_right); - int st=(int)(src_top); - int sb=(int)(src_bottom); - - sr -= sl; - sb -= st; - if (sr < 1 || sb < 1) return; - - psrc += src_span * st + sl * sizeof(LICE_pixel); - - int ia=(int)(alpha*256.0); - int isrcx=(int)(srcx*65536.0); - int isrcy=(int)(srcy*65536.0); - int idsdx=(int)(dsdx*65536.0); - int idtdx=(int)(dtdx*65536.0); - int idsdy=(int)(dsdy*65536.0); - int idtdy=(int)(dtdy*65536.0); - int idsdxdy=(int)(dsdxdy*65536.0); - int idtdxdy=(int)(dtdxdy*65536.0); - -#ifndef LICE_FAVOR_SPEED - LICE_COMBINEFUNC blitfunc=NULL; - #define __LICE__ACTION(comb) blitfunc = comb::doPix; -#else - #define __LICE__ACTION(comb) _LICE_Template_Blit3::deltaBlit(pdest,psrc,dstw,dsth,isrcx,isrcy,idsdx,idtdx,idsdy,idtdy,idsdxdy,idtdxdy,sr,sb,src_span,dest_span,ia,mode&LICE_BLIT_FILTER_MASK) -#endif - __LICE_ACTION_SRCALPHA(mode,ia,false); - #undef __LICE__ACTION - -#ifndef LICE_FAVOR_SPEED - if (blitfunc) _LICE_Template_Blit3::deltaBlit(pdest,psrc,dstw,dsth,isrcx,isrcy,idsdx,idtdx,idsdy,idtdy,idsdxdy,idtdxdy,sr,sb,src_span,dest_span,ia,mode&LICE_BLIT_FILTER_MASK,blitfunc); -#endif - -} - -void LICE_DeltaBlitAlpha(LICE_IBitmap *dest, LICE_IBitmap *src, - int dstx, int dsty, int dstw, int dsth, - float srcx, float srcy, float srcw, float srch, - double dsdx, double dtdx, double dsdy, double dtdy, - double dsdxdy, double dtdxdy, - bool cliptosourcerect, float alpha, int mode, double dadx, double dady, double dadxdy) -{ - if (!dest || !src || !dstw || !dsth) return; - - int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - int srcbm_w = src->getWidth(), srcbm_h = src->getHeight(); - int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(dstx); - __LICE_SC(dsty); - __LICE_SC(dstw); - __LICE_SC(dsth); - } - __LICE_SCU(destbm_w); - __LICE_SCU(destbm_h); - - } - const int __scdest = __sc; - __sc = (int)src->Extended(LICE_EXT_GET_SCALING,NULL); - - if (__sc>0) - { - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(srcx); - __LICE_SC(srcy); - __LICE_SC(srcw); - __LICE_SC(srch); - } - __LICE_SCU(srcbm_w); - __LICE_SCU(srcbm_h); - } - - if (lice_max(__scdest,0) != lice_max(__sc,0)) - { - const double adj = (__sc>0 ? __sc : 256.0) / (double) (__scdest>0 ? __scdest : 256.0); - dsdx *= adj; - dtdx *= adj; - dadx *= adj; - dsdy *= adj; - dtdy *= adj; - dady *= adj; - dsdxdy *= adj; - dtdxdy *= adj; - dadxdy *= adj; - } - - const double eps = 0.0001; - if (fabs(dadx*dstw) < eps && fabs(dady*dsth) < eps && fabs(dadxdy*dsth) < eps) - { - LICE_DeltaBlit(dest, src, dstx, dsty, dstw, dsth, srcx, srcy, srcw, srch, dsdx, dtdx, dsdy, dtdy, dsdxdy, dtdxdy, cliptosourcerect, alpha, mode); - return; - } - - double src_top=0.0,src_left=0.0,src_right=srcbm_w,src_bottom=srcbm_h; - - if (cliptosourcerect) - { - if (srcx > src_left) src_left=srcx; - if (srcy > src_top) src_top=srcy; - if (srcx+srcw < src_right) src_right=srcx+srcw; - if (srcy+srch < src_bottom) src_bottom=srcy+srch; - } - - if (dstw<0) - { - dstw=-dstw; - dstx-=dstw; - srcx+=srcw; - } - if (dsth<0) - { - dsth=-dsth; - dsty-=dsth; - srcy+=srch; - } - - - if (dstx < 0) - { - alpha -= (float) (dstx*dadx); - srcx -= (float) (dstx*dsdx); - srcy -= (float) (dstx*dtdx); - dstw+=dstx; - dstx=0; - } - if (dsty < 0) - { - alpha -= (float) (dsty*dady); - srcy -= (float) (dsty*dtdy); - srcx -= (float) (dsty*dsdy); - dsth+=dsty; - dsty=0; - } - - if (dstw < 1 || dsth < 1 || dstx >= destbm_w || dsty >= destbm_h) return; - - if (dstw > destbm_w-dstx) dstw=destbm_w-dstx; - if (dsth > destbm_h-dsty) dsth=destbm_h-dsty; - - - int dest_span=dest->getRowSpan()*sizeof(LICE_pixel); - int src_span=src->getRowSpan()*sizeof(LICE_pixel); - - const LICE_pixel_chan *psrc = (LICE_pixel_chan *)src->getBits(); - LICE_pixel_chan *pdest = (LICE_pixel_chan *)dest->getBits(); - if (!psrc || !pdest) return; - - if (src->isFlipped()) - { - psrc += (srcbm_h-1)*src_span; - src_span=-src_span; - } - - if (dest->isFlipped()) - { - pdest += (destbm_h-dsty - 1)*dest_span; - dest_span=-dest_span; - } - else pdest += dsty*dest_span; - pdest+=dstx*sizeof(LICE_pixel); - - int sl=(int)(src_left); - int sr=(int)(src_right); - int st=(int)(src_top); - int sb=(int)(src_bottom); - - sr -= sl; - sb -= st; - if (sr < 1 || sb < 1) return; - - psrc += src_span * st + sl * sizeof(LICE_pixel); - - int ia=(int)(alpha*65536.0); - int isrcx=(int)(srcx*65536.0); - int isrcy=(int)(srcy*65536.0); - int idsdx=(int)(dsdx*65536.0); - int idtdx=(int)(dtdx*65536.0); - int idsdy=(int)(dsdy*65536.0); - int idtdy=(int)(dtdy*65536.0); - int idsdxdy=(int)(dsdxdy*65536.0); - int idtdxdy=(int)(dtdxdy*65536.0); - - int idadx=(int)(dadx*65536.0); - int idady=(int)(dady*65536.0); - int idadxdy=(int)(dadxdy*65536.0); - -#ifndef LICE_FAVOR_SPEED - LICE_COMBINEFUNC blitfunc=NULL; - #define __LICE__ACTION(comb) blitfunc = comb::doPix; -#else - #define __LICE__ACTION(comb) _LICE_Template_Blit4::deltaBlitAlpha(pdest,psrc,dstw,dsth,isrcx,isrcy,idsdx,idtdx,idsdy,idtdy,idsdxdy,idtdxdy,sr,sb,src_span,dest_span,ia,idadx,idady,idadxdy,mode&LICE_BLIT_FILTER_MASK) -#endif - __LICE_ACTION_NOSRCALPHA(mode,256,true); - #undef __LICE__ACTION - -#ifndef LICE_FAVOR_SPEED - if (blitfunc) _LICE_Template_Blit4::deltaBlitAlpha(pdest,psrc,dstw,dsth,isrcx,isrcy,idsdx,idtdx,idsdy,idtdy,idsdxdy,idtdxdy,sr,sb,src_span,dest_span,ia,idadx,idady,idadxdy,mode&LICE_BLIT_FILTER_MASK,blitfunc); -#endif - -} - - - - -void LICE_RotatedBlit(LICE_IBitmap *dest, LICE_IBitmap *src, - int dstx, int dsty, int dstw, int dsth, - float srcx, float srcy, float srcw, float srch, - float angle, - bool cliptosourcerect, float alpha, int mode, float rotxcent, float rotycent) -{ - if (!dest || !src || !dstw || !dsth) return; - - int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - int srcbm_w = src->getWidth(), srcbm_h = src->getHeight(); - int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(dstx); - __LICE_SC(dsty); - __LICE_SC(dstw); - __LICE_SC(dsth); - } - __LICE_SCU(destbm_w); - __LICE_SCU(destbm_h); - - } - __sc = (int)src->Extended(LICE_EXT_GET_SCALING,NULL); - - if (__sc>0) - { - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(srcx); - __LICE_SC(srcy); - __LICE_SC(srcw); - __LICE_SC(srch); - } - __LICE_SCU(srcbm_w); - __LICE_SCU(srcbm_h); - } - double src_top=0.0,src_left=0.0,src_right=srcbm_w,src_bottom=srcbm_h; - - if (cliptosourcerect) - { - if (srcx > src_left) src_left=srcx; - if (srcy > src_top) src_top=srcy; - if (srcx+srcw < src_right) src_right=srcx+srcw; - if (srcy+srch < src_bottom) src_bottom=srcy+srch; - } - - if (dstw<0) - { - dstw=-dstw; - dstx-=dstw; - srcx+=srcw; - srcw=-srcw; - } - if (dsth<0) - { - dsth=-dsth; - dsty-=dsth; - srcy+=srch; - srch=-srch; - } - - double cosa=cos(angle); - double sina=sin(angle); - - double xsc=srcw / dstw; - double ysc=srch / dsth; - - double dsdx = xsc * cosa; - double dtdy = ysc * cosa; - double dsdy = xsc * sina; - double dtdx = ysc * -sina; - - srcx -= (float) (0.5 * (dstw*dsdx + dsth*dsdy - srcw) - rotxcent); - srcy -= (float) (0.5 * (dsth*dtdy + dstw*dtdx - srch) - rotycent); - - if (dstx < 0) - { - srcx -= (float) (dstx*dsdx); - srcy -= (float) (dstx*dtdx); - dstw+=dstx; - dstx=0; - } - if (dsty < 0) - { - srcy -= (float) (dsty*dtdy); - srcx -= (float) (dsty*dsdy); - dsth+=dsty; - dsty=0; - } - - if (dstw < 1 || dsth < 1 || dstx >= destbm_w || dsty >= destbm_h) return; - - if (dstw > destbm_w-dstx) dstw=destbm_w-dstx; - if (dsth > destbm_h-dsty) dsth=destbm_h-dsty; - - - int dest_span=dest->getRowSpan()*sizeof(LICE_pixel); - int src_span=src->getRowSpan()*sizeof(LICE_pixel); - - const LICE_pixel_chan *psrc = (LICE_pixel_chan *)src->getBits(); - LICE_pixel_chan *pdest = (LICE_pixel_chan *)dest->getBits(); - if (!psrc || !pdest) return; - - if (src->isFlipped()) - { - psrc += (srcbm_h-1)*src_span; - src_span=-src_span; - } - - if (dest->isFlipped()) - { - pdest += (destbm_h-dsty - 1)*dest_span; - dest_span=-dest_span; - } - else pdest += dsty*dest_span; - pdest+=dstx*sizeof(LICE_pixel); - - int sl=(int)(src_left); - int sr=(int)(src_right); - int st=(int)(src_top); - int sb=(int)(src_bottom); - - sr -= sl; - sb -= st; - srcx -= sl; - srcy -= st; - if (sr < 1 || sb < 1) return; - - psrc += src_span * st + sl * sizeof(LICE_pixel); - - int ia=(int)(alpha*256.0); - int isrcx=(int)(srcx*65536.0); - int isrcy=(int)(srcy*65536.0); - int idsdx=(int)(dsdx*65536.0); - int idtdx=(int)(dtdx*65536.0); - int idsdy=(int)(dsdy*65536.0); - int idtdy=(int)(dtdy*65536.0); - -#ifndef LICE_FAVOR_SPEED - LICE_COMBINEFUNC blitfunc=NULL; - #define __LICE__ACTION(comb) blitfunc = comb::doPix; -#else - #define __LICE__ACTION(comb) _LICE_Template_Blit3::deltaBlit(pdest,psrc,dstw,dsth,isrcx,isrcy,idsdx,idtdx,idsdy,idtdy,0,0,sr,sb,src_span,dest_span,ia,mode&LICE_BLIT_FILTER_MASK) -#endif - __LICE_ACTION_SRCALPHA(mode,ia,false); - #undef __LICE__ACTION - -#ifndef LICE_FAVOR_SPEED - if (blitfunc) _LICE_Template_Blit3::deltaBlit(pdest,psrc,dstw,dsth,isrcx,isrcy,idsdx,idtdx,idsdy,idtdy,0,0,sr,sb,src_span,dest_span,ia,mode&LICE_BLIT_FILTER_MASK,blitfunc); -#endif -} - -#endif - - -void LICE_Clear(LICE_IBitmap *dest, LICE_pixel color) -{ - if (!dest) return; - -#ifndef DISABLE_LICE_EXTENSIONS - if (dest->Extended(LICE_EXT_SUPPORTS_ID, (void*) LICE_EXT_CLEAR_ACCEL)) - { - if (dest->Extended(LICE_EXT_CLEAR_ACCEL, &color)) return; - } -#endif - - LICE_pixel *p=dest->getBits(); - int h=dest->getHeight(); - int w=dest->getWidth(); - const int sp=dest->getRowSpan(); - - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - __LICE_SCU(w); - __LICE_SCU(h); - } - - if (!p || w<1 || h<1 || !sp) return; - - while (h-->0) - { - int n=w; - while (n--) *p++ = color; - p+=sp-w; - } -} - - - - -void LICE_MultiplyAddRect(LICE_IBitmap *dest, int x, int y, int w, int h, - float rsc, float gsc, float bsc, float asc, - float radd, float gadd, float badd, float aadd) -{ - if (!dest) return; - - int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - DO_RECT_SC(0) - - if (x<0) { w+=x; x=0; } - if (y<0) { h+=y; y=0; } - - LICE_pixel *p=dest->getBits(); - const int sp=dest->getRowSpan(); - if (!p || !sp || w<1 || h < 1 || x >= destbm_w || y >= destbm_h) return; - - if (w>destbm_w-x) w=destbm_w-x; - if (h>destbm_h-y) h=destbm_h-y; - - if (dest->isFlipped()) - { - p+=(destbm_h - y - h)*sp; - } - else - { - p+=sp*y; - } - - p += x; - - int ir=(int)(rsc*256.0); - int ig=(int)(gsc*256.0); - int ib=(int)(bsc*256.0); - int ia=(int)(asc*256.0); - int ir2=(int)(radd*256.0); - int ig2=(int)(gadd*256.0); - int ib2=(int)(badd*256.0); - int ia2=(int)(aadd*256.0); - - while (h-->0) - { - int n=w; - while (n--) - { - LICE_pixel_chan *ptr=(LICE_pixel_chan *)p++; - _LICE_MakePixelClamp(ptr,(ptr[LICE_PIXEL_R]*ir+ir2)>>8, - (ptr[LICE_PIXEL_G]*ig+ig2)>>8, - (ptr[LICE_PIXEL_B]*ib+ib2)>>8, - (ptr[LICE_PIXEL_A]*ia+ia2)>>8); - } - p+=sp-w; - } -} - -void LICE_ProcessRect(LICE_IBitmap *dest, int x, int y, int w, int h, void (*procFunc)(LICE_pixel *p, void *parm), void *parm) -{ - if (!dest||!procFunc) return; - - int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - DO_RECT_SC(0) - - if (x<0) { w+=x; x=0; } - if (y<0) { h+=y; y=0; } - - LICE_pixel *p=dest->getBits(); - const int sp=dest->getRowSpan(); - - if (!p || !sp || w<1 || h < 1 || x >= destbm_w || y >= destbm_h) return; - - if (w>destbm_w-x) w=destbm_w-x; - if (h>destbm_h-y) h=destbm_h-y; - - if (dest->isFlipped()) - { - p+=(destbm_h - y - h)*sp; - } - else - { - p+=sp*y; - } - - p += x; - - while (h--) - { - LICE_pixel *pout=p; - int n=w; - while (n-->0) procFunc(pout++,parm); - p+=sp; - } - - -} - -void LICE_FillRect(LICE_IBitmap *dest, int x, int y, int w, int h, LICE_pixel color, float alpha, int mode) -{ - if (!dest) return; - - int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - DO_RECT_SC(mode) - -#ifndef DISABLE_LICE_EXTENSIONS - if (dest->Extended(LICE_EXT_SUPPORTS_ID, (void*) LICE_EXT_FILLRECT_ACCEL)) - { - LICE_Ext_FillRect_acceldata data(x, y, w, h, color, alpha, mode); - if (dest->Extended(LICE_EXT_FILLRECT_ACCEL, &data)) return; - } -#endif - - if (mode & LICE_BLIT_USE_ALPHA) alpha *= LICE_GETA(color)/255.0f; - - LICE_pixel *p=dest->getBits(); - const int sp=dest->getRowSpan(); - - if (x<0) { w+=x; x=0; } - if (y<0) { h+=y; y=0; } - if (!alpha || !p || !sp || w<1 || h < 1 || x >= destbm_w || y >= destbm_h) return; - - if (w>destbm_w-x) w=destbm_w-x; - if (h>destbm_h-y) h=destbm_h-y; - - if (dest->isFlipped()) - { - p+=(destbm_h - y - h)*sp; - } - else - { - p+=sp*y; - } - - p += x; - - const int ia=(int)(alpha*256.0); - // copy, alpha=1, alpha=0.5, 0.25, 0.75 optimizations - if ((mode&LICE_BLIT_MODE_MASK)==LICE_BLIT_MODE_COPY) - { - if (ia==256) - { - _LICE_Template_Blit0<_LICE_CombinePixelsClobberFAST>::solidBlitFAST(p,w,h,color,sp); - return; - } - if (ia==128) - { - // we use _LICE_CombinePixelsHalfMix2 because we pre-halve color here - _LICE_Template_Blit0<_LICE_CombinePixelsHalfMix2FAST>::solidBlitFAST(p,w,h,(color>>1)&0x7f7f7f7f,sp); - return; - } - if (ia==64) - { - _LICE_Template_Blit0<_LICE_CombinePixelsQuarterMix2FAST>::solidBlitFAST(p,w,h,(color>>2)&0x3f3f3f3f,sp); - return; - } - if (ia==192) - { - _LICE_Template_Blit0<_LICE_CombinePixelsThreeQuarterMix2FAST>::solidBlitFAST(p,w,h, - ((color>>1)&0x7f7f7f7f)+((color>>2)&0x3f3f3f3f),sp); - return; - } - } - -#ifdef LICE_FAVOR_SIZE_EXTREME - LICE_COMBINEFUNC blitfunc=NULL; - #define __LICE__ACTION(comb) blitfunc=comb::doPix; -#else - #define __LICE__ACTION(comb) _LICE_Template_Blit1::solidBlit((LICE_pixel_chan*)p,w,h,LICE_GETR(color),LICE_GETG(color),LICE_GETB(color),LICE_GETA(color),ia,sp*sizeof(LICE_pixel)) -#endif - - // we use __LICE_ACTION_NOSRCALPHA even though __LICE_ACTION_CONSTANTALPHA - // is valid, sinc we optimized the 1.0f/0.5f cases above - __LICE_ACTION_NOSRCALPHA(mode,ia,false); - #undef __LICE__ACTION - -#ifdef LICE_FAVOR_SIZE_EXTREME - if (blitfunc) _LICE_Template_Blit1::solidBlit((LICE_pixel_chan*)p,w,h,LICE_GETR(color),LICE_GETG(color),LICE_GETB(color),LICE_GETA(color),ia,sp*sizeof(LICE_pixel),blitfunc); -#endif -} - -void LICE_ClearRect(LICE_IBitmap *dest, int x, int y, int w, int h, LICE_pixel mask, LICE_pixel orbits) -{ - if (!dest) return; - LICE_pixel *p=dest->getBits(); - - int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - DO_RECT_SC(0) - - if (x<0) { w+=x; x=0; } - if (y<0) { h+=y; y=0; } - - const int sp=dest->getRowSpan(); - if (!p || !sp || w<1 || h < 1 || x >= destbm_w || y >= destbm_h) return; - - if (w>destbm_w-x) w=destbm_w-x; - if (h>destbm_h-y) h=destbm_h-y; - - if (dest->isFlipped()) - { - p+=(destbm_h - y - h)*sp; - } - else p+=sp*y; - - p += x; - while (h-->0) - { - int n=w; - while (n--) - { - *p = (*p&mask)|orbits; - p++; - } - p+=sp-w; - } -} - - -LICE_pixel LICE_GetPixel(LICE_IBitmap *bm, int x, int y) -{ - if (!bm) return 0; - - int w = bm->getWidth(), h = bm->getHeight(); - const int __sc = (int)bm->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - __LICE_SCU(w); - __LICE_SCU(h); - __LICE_SC(x); - __LICE_SC(y); - } -#ifndef DISABLE_LICE_EXTENSIONS - if (bm->Extended(LICE_EXT_SUPPORTS_ID, (void*) LICE_EXT_GETPIXEL_ACCEL)) - { - LICE_Ext_GetPixel_acceldata data(x, y); - if (bm->Extended(LICE_EXT_GETPIXEL_ACCEL, &data)) return data.px; - } -#endif - - const LICE_pixel *px; - - if (!(px=bm->getBits()) || x < 0 || y < 0 || x >= w || y>= h) return 0; - if (bm->isFlipped()) return px[(h-1-y) * bm->getRowSpan() + x]; - return px[y * bm->getRowSpan() + x]; -} - -void LICE_PutPixel(LICE_IBitmap *bm, int x, int y, LICE_pixel color, float alpha, int mode) -{ - if (!bm) return; - - const int __sc = (int)bm->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - if (!IGNORE_SCALING(mode)) - { - LICE_FillRect(bm,x,y,1,1,color,alpha,mode); - return; - } - - } - - int w = bm->getWidth(), h = bm->getHeight(); - if (__sc>0) - { - __LICE_SCU(w); - __LICE_SCU(h); - } -#ifndef DISABLE_LICE_EXTENSIONS - if (bm->Extended(LICE_EXT_SUPPORTS_ID, (void*) LICE_EXT_PUTPIXEL_ACCEL)) - { - LICE_Ext_PutPixel_acceldata data(x, y, color, alpha, mode); - if (bm->Extended(LICE_EXT_PUTPIXEL_ACCEL, &data)) return; - } -#endif - - LICE_pixel *px; - if (!(px=bm->getBits()) || x < 0 || y < 0 || x >= w || y >= h) return; - - if (bm->isFlipped()) px+=x+(h-1-y)*bm->getRowSpan(); - else px+=x+y*bm->getRowSpan(); - - int ia = (int)(alpha * 256.0f); - if ((mode&LICE_BLIT_MODE_MASK)==LICE_BLIT_MODE_COPY) - { - if (ia==256) - { - *px = color; - return; - } - if (ia==128) - { - *px = ((*px>>1)&0x7f7f7f7f) + ((color>>1)&0x7f7f7f7f); - return; - } - if (ia==64) - { - *px = ((*px>>1)&0x7f7f7f7f) + ((*px>>2)&0x3f3f3f3f) + ((color>>2)&0x3f3f3f3f); - return; - } - if (ia==192) - { - *px = ((*px>>2)&0x3f3f3f3f) + ((color>>1)&0x7f7f7f7f) + ((color>>2)&0x3f3f3f3f); - return; - } - } -#define __LICE__ACTION(comb) comb::doPix((LICE_pixel_chan *)px, LICE_GETR(color),LICE_GETG(color),LICE_GETB(color),LICE_GETA(color), ia) - __LICE_ACTION_NOSRCALPHA(mode,ia,false); -#undef __LICE__ACTION -} - - -#ifndef LICE_NO_BLIT_SUPPORT - -template class LICE_TransformBlit_class -{ - public: - static void blit(LICE_IBitmap *dest, LICE_IBitmap *src, - int dstx, int dsty, int dstw, int dsth, - const T *srcpoints, int div_w, int div_h, // srcpoints coords should be div_w*div_h*2 long, and be in source image coordinates - float alpha, int mode) -{ - if (!dest || !src || dstw<1 || dsth<1 || div_w<2 || div_h<2) return; - - int cypos=dsty; - double ypos=dsty; - double dxpos=dstw/(float)(div_w-1); - double dypos=dsth/(float)(div_h-1); - int y; - const T *curpoints=srcpoints; - for (y = 0; y < div_h-1; y ++) - { - int nypos=(int)((ypos+=dypos) + 0.5); - int x; - double xpos=dstx; - int cxpos=dstx; - - if (nypos != cypos) - { - double iy=1.0/(double)(nypos-cypos); - for (x = 0; x < div_w-1; x ++) - { - int nxpos=(int) ((xpos+=dxpos) + 0.5); - if (nxpos != cxpos) - { - int offs=x*2; - double sx=curpoints[offs]; - double sy=curpoints[offs+1]; - double sw=curpoints[offs+2]-sx; - double sh=curpoints[offs+3]-sy; - - offs+=div_w*2; - double sxdiff=curpoints[offs]-sx; - double sydiff=curpoints[offs+1]-sy; - double sw3=curpoints[offs+2]-curpoints[offs]; - double sh3=curpoints[offs+3]-curpoints[offs+1]; - - double ix=1.0/(double)(nxpos-cxpos); - double dsdx=sw*ix; - double dtdx=sh*ix; - double dsdx2=sw3*ix; - double dtdx2=sh3*ix; - double dsdy=sxdiff*iy; - double dtdy=sydiff*iy; - double dsdxdy = (dsdx2-dsdx)*iy; - double dtdxdy = (dtdx2-dtdx)*iy; - - LICE_DeltaBlit(dest,src,cxpos,cypos,nxpos-cxpos,nypos-cypos, - (float)sx,(float)sy,(float)sw,(float)sh, - dsdx,dtdx,dsdy,dtdy,dsdxdy,dtdxdy,false,alpha,mode); - } - - cxpos=nxpos; - } - } - curpoints+=div_w*2; - cypos=nypos; - } -} -}; - -template class LICE_TransformBlitAlpha_class -{ - public: - static void blit(LICE_IBitmap *dest, LICE_IBitmap *src, - int dstx, int dsty, int dstw, int dsth, - const T *srcpoints, int div_w, int div_h, // srcpoints coords should be div_w*div_h*2 long, and be in source image coordinates - int mode) -{ - if (!dest || !src || dstw<1 || dsth<1 || div_w<2 || div_h<2) return; - - int cypos=dsty; - double ypos=dsty; - double dxpos=dstw/(float)(div_w-1); - double dypos=dsth/(float)(div_h-1); - int y; - const T *curpoints=srcpoints; - for (y = 0; y < div_h-1; y ++) - { - int nypos=(int)((ypos+=dypos)+0.5); - int x; - double xpos=dstx; - int cxpos=dstx; - - if (nypos != cypos) - { - double iy=1.0/(double)(nypos-cypos); - for (x = 0; x < div_w-1; x ++) - { - int nxpos=(int) ((xpos+=dxpos)+0.5); - if (nxpos != cxpos) - { - int offs=x*3; - double sx=curpoints[offs]; - double sy=curpoints[offs+1]; - double sa=curpoints[offs+2]; - double sw=curpoints[offs+3]-sx; - double sh=curpoints[offs+4]-sy; - double sa2 = curpoints[offs+5]-sa; - - offs+=div_w*3; - double sxdiff=curpoints[offs]-sx; - double sydiff=curpoints[offs+1]-sy; - double sadiff=curpoints[offs+2]-sa; - double sw3=curpoints[offs+3]-curpoints[offs]; - double sh3=curpoints[offs+4]-curpoints[offs+1]; - double sa3=curpoints[offs+5]-curpoints[offs+2]; - - double ix=1.0/(double)(nxpos-cxpos); - double dsdx=sw*ix; - double dtdx=sh*ix; - double dadx=sa2*ix; - double dsdx2=sw3*ix; - double dtdx2=sh3*ix; - double dadx2=sa3*ix; - double dsdy=sxdiff*iy; - double dtdy=sydiff*iy; - double dady=sadiff*iy; - double dsdxdy = (dsdx2-dsdx)*iy; - double dtdxdy = (dtdx2-dtdx)*iy; - double dadxdy = (dadx2-dadx)*iy; - - LICE_DeltaBlitAlpha(dest,src,cxpos,cypos,nxpos-cxpos,nypos-cypos, - (float)sx,(float)sy,(float)sw,(float)sh, - dsdx,dtdx,dsdy,dtdy,dsdxdy,dtdxdy,false,sa,mode,dadx,dady,dadxdy); - } - - cxpos=nxpos; - } - } - curpoints+=div_w*3; - cypos=nypos; - } -} -}; - -void LICE_TransformBlit(LICE_IBitmap *dest, LICE_IBitmap *src, - int dstx, int dsty, int dstw, int dsth, - const float *srcpoints, int div_w, int div_h, // srcpoints coords should be div_w*div_h*2 long, and be in source image coordinates - float alpha, int mode) -{ - LICE_TransformBlit_class::blit(dest,src,dstx,dsty,dstw,dsth,srcpoints,div_w,div_h,alpha,mode); -} -void LICE_TransformBlit2(LICE_IBitmap *dest, LICE_IBitmap *src, - int dstx, int dsty, int dstw, int dsth, - const double *srcpoints, int div_w, int div_h, // srcpoints coords should be div_w*div_h*2 long, and be in source image coordinates - float alpha, int mode) -{ - LICE_TransformBlit_class::blit(dest,src,dstx,dsty,dstw,dsth,srcpoints,div_w,div_h,alpha,mode); -} - - -void LICE_TransformBlit2Alpha(LICE_IBitmap *dest, LICE_IBitmap *src, - int dstx, int dsty, int dstw, int dsth, - const double *srcpoints, int div_w, int div_h, // srcpoints coords should be div_w*div_h*3 long, and be in source image coordinates+alpha - int mode) -{ - LICE_TransformBlitAlpha_class::blit(dest,src,dstx,dsty,dstw,dsth,srcpoints,div_w,div_h,mode); -} -#endif - -#ifndef LICE_NO_MISC_SUPPORT - -void LICE_SetAlphaFromColorMask(LICE_IBitmap *dest, LICE_pixel color) -{ - if (!dest) return; - LICE_pixel *p=dest->getBits(); - int h=dest->getHeight(); - int w=dest->getWidth(); - int sp=dest->getRowSpan(); - if (!p || w<1 || h<1 || sp<1) return; - - while (h-->0) - { - int n=w; - while (n--) - { - if ((*p&LICE_RGBA(255,255,255,0)) == color) *p&=LICE_RGBA(255,255,255,0); - else *p|=LICE_RGBA(0,0,0,255); - p++; - } - p+=sp-w; - } -} - - -void LICE_SimpleFill(LICE_IBitmap *dest, int x, int y, LICE_pixel newcolor, - LICE_pixel comparemask, - LICE_pixel keepmask) -{ - if (!dest) return; - int dw=dest->getWidth(); - int dh=dest->getHeight(); - int rowsize=dest->getRowSpan(); - if (x<0||x>=dw||y<0||y>=dh) return; - LICE_pixel *ptr=dest->getBits(); - if (!ptr) return; - ptr += rowsize*y; - - LICE_pixel compval=ptr[x]&comparemask; - int ay; - for (ay=y;ay=0) - { - if ((ptr[ax]&comparemask)!=compval) break; - ptr[ax]=(ptr[ax]&keepmask)|newcolor; - } - - ptr+=rowsize; - } - ptr =dest->getBits()+rowsize*y; - - ay=y; - while (--ay>=0) - { - ptr-=rowsize; - if ((ptr[x]&comparemask)!=compval) break; - ptr[x]=(ptr[x]&keepmask)|newcolor; - - int ax; - for(ax=x+1;ax=0) - { - if ((ptr[ax]&comparemask)!=compval) break; - ptr[ax]=(ptr[ax]&keepmask)|newcolor; - } - } -} - -// VS6 instantiates this wrong as a template function, needs to be a template class -template class GlyphDrawImpl -{ -public: - static void DrawGlyph(const LICE_pixel_chan* srcalpha, LICE_pixel* destpx, int src_w, int src_h, LICE_pixel color, int span, int src_span, int aa) - { - const int r = LICE_GETR(color), g = LICE_GETG(color), b = LICE_GETB(color), a = LICE_GETA(color); - - int xi, yi; - for (yi = 0; yi < src_h; ++yi, srcalpha += src_span, destpx += span) { - const LICE_pixel_chan* tsrc = srcalpha; - LICE_pixel* tdest = destpx; - for (xi = 0; xi < src_w; ++xi, ++tsrc, ++tdest) { - const LICE_pixel_chan v = *tsrc; - if (v) { // glyphs should be expected to have a lot of "holes" - COMBFUNC::doPix((LICE_pixel_chan*) tdest, r, g, b, a, v*aa/256); - } - } - } - } - static void DrawGlyphScale(const LICE_pixel_chan* srcalpha, LICE_pixel* destpx, int src_w, int src_h, LICE_pixel color, int span, int src_span, int aa, int scale) - { - const int r = LICE_GETR(color), g = LICE_GETG(color), b = LICE_GETB(color), a = LICE_GETA(color); - - int xi, yi; - int ysum = 0; - for (yi = 0; yi < src_h; ++yi, srcalpha += src_span) { - ysum += scale; - while (ysum > 255) - { - const LICE_pixel_chan* tsrc = srcalpha; - LICE_pixel* tdest = destpx; - ysum -= 256; - destpx += span; - int sum = 0; - for (xi = 0; xi < src_w; ++xi, ++tsrc) { - const LICE_pixel_chan v = *tsrc; - sum += scale; - if (v) { // glyphs should be expected to have a lot of "holes" - while (sum>255) - { - COMBFUNC::doPix((LICE_pixel_chan*) tdest, r, g, b, a, v*aa/256); - tdest++; - sum -= 256; - } - } - else - { - tdest += sum/256; - sum &= 255; - } - } - } - } - } - static void DrawGlyphMono(const unsigned char * srcalpha, LICE_pixel* destpx, int src_w, int src_h, LICE_pixel color, int span, int src_span, int aa) - { - const int r = LICE_GETR(color), g = LICE_GETG(color), b = LICE_GETB(color), a = LICE_GETA(color); - - int xi, yi; - for (yi = 0; yi < src_h; ++yi, srcalpha += src_span, destpx += span) { - const unsigned char *tsrc = srcalpha; - LICE_pixel* tdest = destpx; - unsigned char cv=0; - for (xi = 0; xi < src_w; ++xi, ++tdest) { - if (!(xi&7)) cv = *tsrc++; - const LICE_pixel_chan v = (cv&128)?255:0; - cv<<=1; - if (v) { // glyphs should be expected to have a lot of "holes" - COMBFUNC::doPix((LICE_pixel_chan*) tdest, r, g, b, a, v*aa/256); - } - } - } - } - static void DrawGlyphMonoScale(const unsigned char * srcalpha, LICE_pixel* destpx, int src_w, int src_h, LICE_pixel color, int span, int src_span, int aa, int scale) - { - const int r = LICE_GETR(color), g = LICE_GETG(color), b = LICE_GETB(color), a = LICE_GETA(color); - - int xi, yi; - int ysum=0; - for (yi = 0; yi < src_h; ++yi, srcalpha += src_span) { - ysum += scale; - while (ysum > 255) - { - const unsigned char *tsrc = srcalpha; - LICE_pixel* tdest = destpx; - unsigned char cv=0; - int sum=0; - ysum -= 256; - destpx++; - for (xi = 0; xi < src_w; ++xi) { - if (!(xi&7)) cv = *tsrc++; - const LICE_pixel_chan v = (cv&128)?255:0; - cv<<=1; - sum += scale; - if (v) { // glyphs should be expected to have a lot of "holes" - while (sum > 255) - { - COMBFUNC::doPix((LICE_pixel_chan*) tdest, r, g, b, a, v*aa/256); - tdest++; - sum -= 256; - } - } - else - { - tdest += sum/256; - sum &= 255; - } - } - } - } - } -}; - -void LICE_DrawGlyphEx(LICE_IBitmap* dest, int x, int y, LICE_pixel color, const LICE_pixel_chan* alphas, int glyph_w, int glyph_span, int glyph_h, float alpha, int mode) -{ - if (!dest) return; - -#ifndef DISABLE_LICE_EXTENSIONS - if (dest->Extended(LICE_EXT_SUPPORTS_ID, (void*) LICE_EXT_DRAWGLYPH_ACCEL) && glyph_w == glyph_span) - { - LICE_Ext_DrawGlyph_acceldata data(x, y, color, alphas, glyph_w, glyph_h, alpha, mode); - if (dest->Extended(LICE_EXT_DRAWGLYPH_ACCEL, &data)) return; - } -#endif - - int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0 && IGNORE_SCALING(mode)) - { - __LICE_SCU(destbm_w); - __LICE_SCU(destbm_h); - } - - if (glyph_span < 0) alphas += -glyph_span * (glyph_h-1); - - const int ia= (int)(alpha*256.0f); - - int src_x = 0, src_y = 0, src_w = glyph_w, src_h = glyph_h; - if (x <= -src_w || y <= -src_h) return; - - if (x < 0) { - src_x -= x; - if (src_x < 0) return; // overflow - src_w += x; - x = 0; - } - if (y < 0) { - src_y -= y; - if (src_y < 0) return; // overflow - src_h += y; - y = 0; - } - - if (src_w < 0 || src_h < 0 || x >= destbm_w || y >= destbm_h) return; - - if (src_h > destbm_h-y) src_h = destbm_h-y; - if (src_w > destbm_w-x) src_w = destbm_w-x; - - if (src_w < 1 || src_h < 1) return; - - if (__sc>0 && !IGNORE_SCALING(mode)) - { - __LICE_SCU(destbm_w); - __LICE_SCU(destbm_h); - __LICE_SC(x); - __LICE_SC(y); - } - - LICE_pixel* destpx = dest->getBits(); - int span = dest->getRowSpan(); - if (dest->isFlipped()) { - destpx += (destbm_h-y-1)*span+x; - span = -span; - } - else { - destpx += y*dest->getRowSpan()+x; - } - - const LICE_pixel_chan* srcalpha = alphas+src_y*glyph_span+src_x; - - if (__sc>0 && !IGNORE_SCALING(mode)) - { -#define __LICE__ACTION(COMBFUNC) GlyphDrawImpl::DrawGlyphScale(srcalpha,destpx, src_w, src_h, color,span,glyph_span,ia,__sc) - __LICE_ACTION_NOSRCALPHA(mode, ia, false); -#undef __LICE__ACTION - } - else - { -#define __LICE__ACTION(COMBFUNC) GlyphDrawImpl::DrawGlyph(srcalpha,destpx, src_w, src_h, color,span,glyph_span,ia) - __LICE_ACTION_NOSRCALPHA(mode, ia, false); -#undef __LICE__ACTION - } -} - -void LICE_DrawGlyph(LICE_IBitmap* dest, int x, int y, LICE_pixel color, const LICE_pixel_chan* alphas, int glyph_w, int glyph_h, float alpha, int mode) -{ - LICE_DrawGlyphEx(dest,x,y,color,alphas,glyph_w,glyph_w,glyph_h,alpha,mode); -} - - -void LICE_DrawMonoGlyph(LICE_IBitmap* dest, int x, int y, LICE_pixel color, const unsigned char *alphabits, int glyph_w, int glyph_span, int glyph_h, float alpha, int mode) -{ - if (!dest) return; - - int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0 && IGNORE_SCALING(mode)) - { - __LICE_SCU(destbm_w); - __LICE_SCU(destbm_h); - } - - if (glyph_span < 0) alphabits += -glyph_span * (glyph_h-1); - - const int ia= (int)(alpha*256.0f); - - int src_x = 0, src_y = 0, src_w = glyph_w, src_h = glyph_h; - if (x <= -src_w || y <= -src_h) return; - - if (x < 0) { - src_x -= x; - src_w += x; - x = 0; - } - if (y < 0) { - src_y -= y; - src_h += y; - y = 0; - } - - if (src_w < 0 || src_h < 0 || x >= destbm_w || y >= destbm_h) return; - - if (src_h > destbm_h-y) src_h = destbm_h-y; - if (src_w > destbm_w-x) src_w = destbm_w-x; - - if (src_w < 1 || src_h < 1) return; - - if (__sc>0 && !IGNORE_SCALING(mode)) - { - __LICE_SCU(destbm_w); - __LICE_SCU(destbm_h); - __LICE_SC(x); - __LICE_SC(y); - } - - LICE_pixel* destpx = dest->getBits(); - int span = dest->getRowSpan(); - if (dest->isFlipped()) { - destpx += (destbm_h-y-1)*span+x; - span = -span; - } - else { - destpx += y*dest->getRowSpan()+x; - } - - const unsigned char * srcalpha = alphabits+src_y*glyph_span+src_x; - if (__sc>0 && !IGNORE_SCALING(mode)) - { -#define __LICE__ACTION(COMBFUNC) GlyphDrawImpl::DrawGlyphMonoScale(srcalpha,destpx, src_w, src_h, color,span,glyph_span,ia,__sc) - __LICE_ACTION_NOSRCALPHA(mode, ia, false); -#undef __LICE__ACTION - } - else - { -#define __LICE__ACTION(COMBFUNC) GlyphDrawImpl::DrawGlyphMono(srcalpha,destpx, src_w, src_h, color,span,glyph_span,ia) - __LICE_ACTION_NOSRCALPHA(mode, ia, false); -#undef __LICE__ACTION - } -} - -void LICE_HalveBlitAA(LICE_IBitmap *dest, LICE_IBitmap *src) -{ - if (!dest||!src) return; - int w = dest->getWidth(); - if (w > src->getWidth()/2) w=src->getWidth()/2; - int h = dest->getHeight(); - if (h > src->getHeight()/2) h=src->getHeight()/2; - int src_span = src->getRowSpan(); - int dest_span = dest->getRowSpan(); - const LICE_pixel *srcptr = src->getBits(); - LICE_pixel *destptr = dest->getBits(); - - while (h--) - { - const LICE_pixel *sp = srcptr; - const LICE_pixel *sp2 = srcptr+src_span; - LICE_pixel *dp = destptr; - int x=w/2; - - // this is begging for SSE intrinsics, but we never use this function so leave it as-is :) - - // perhaps we should use more precision rather than chopping each src pixel to 6 bits, but oh well - while (x--) // unroll 2px at a time, about 5% faster on core2 and ICC - { - int r1=((sp[0]>>2)&0x3f3f3f3f); - int r2=((sp[2]>>2)&0x3f3f3f3f); - r1 += ((sp[1]>>2)&0x3f3f3f3f); - r2 += ((sp[3]>>2)&0x3f3f3f3f); - dp[0] = r1 + - ((sp2[0]>>2)&0x3f3f3f3f) + - ((sp2[1]>>2)&0x3f3f3f3f); - dp[1] = r2 + - ((sp2[2]>>2)&0x3f3f3f3f) + - ((sp2[3]>>2)&0x3f3f3f3f); - sp+=4; - sp2+=4; - dp+=2; - } - if (w&1) - { - *dp = - ((sp[0]>>2)&0x3f3f3f3f) + - ((sp[1]>>2)&0x3f3f3f3f) + - ((sp2[0]>>2)&0x3f3f3f3f) + - ((sp2[1]>>2)&0x3f3f3f3f); - } - srcptr+=src_span*2; - destptr+=dest_span; - } -} - -#endif // LICE_NO_MISC_SUPPORT - -int LICE_BitmapCmp(LICE_IBitmap* a, LICE_IBitmap* b, int *coordsOut) -{ - return LICE_BitmapCmpEx(a,b,LICE_RGBA(255,255,255,255),coordsOut); -} - -int LICE_BitmapCmpEx(LICE_IBitmap* a, LICE_IBitmap* b, LICE_pixel mask, int *coordsOut) -{ - if (!a || !b) { - if (!a && b) return -1; - if (a && !b) return 1; - return 0; - } - - int aw = a->getWidth(), bw = b->getWidth(); - if (aw != bw) return bw-aw; - int ah = a->getHeight(), bh = b->getHeight(); - if (ah != bh) return bh-ah; - - //coordsOut - const LICE_pixel *px1 = a->getBits(); - const LICE_pixel *px2 = b->getBits(); - int span1 = a->getRowSpan(); - int span2 = b->getRowSpan(); - if (a->isFlipped()) - { - px1+=span1*(ah-1); - span1=-span1; - } - if (b->isFlipped()) - { - px2+=span2*(ah-1); - span2=-span2; - } - - int y; - if (!coordsOut) - { - if (mask == (LICE_pixel)LICE_RGBA(255,255,255,255)) - for (y=0; y < ah; y ++) - { - const int dv = memcmp(px1,px2,aw*sizeof(LICE_pixel)); - if (dv) return dv; - px1+=span1; - px2+=span2; - } - else - for (y=0; y < ah; y ++) - { - const LICE_pixel *ptr1 = px1, *ptr2 = px2; - int x=aw; - while (x--) - if ((*ptr1++ ^ *ptr2++) & mask) return true; - px1+=span1; - px2+=span2; - } - } - else - { - int x; - - // find first row that differs - for (y=0; y < ah; y ++) - { - // check left side - for (x=0;x=ah) - { - memset(coordsOut,0,4*sizeof(int)); - return 0; // no differences - } - - int miny=y; - int minx=x; - // scan right edge of top differing row - for (x=aw-1;x>minx && !((px1[x]^px2[x])&mask);x--); - int maxx=x; - - // find last row that differs - px1+=span1 * (ah-1-y); - px2+=span2 * (ah-1-y); - for (y = ah-1; y > miny; y --) - { - // check left side - for (x=0;x miny) - { - // scan right edge of bottom row that differs - for (x=aw-1;x>maxx && !((px1[x]^px2[x])&mask);x--); - maxx=x; - } - - - // find min/max x that differ - px1+=span1 * (miny+1-y); - px2+=span2 * (miny+1-y); - for (y=miny+1;y0 || maxxmaxx && !((px1[x]^px2[x])&mask);x--); - maxx=x; - - px1+=span1; - px2+=span2; - } - - coordsOut[0]=minx; - coordsOut[1]=miny; - coordsOut[2]=maxx-minx+1; - coordsOut[3]=maxy-miny+1; - - return 1; - } - - return 0; -} - -unsigned short _LICE_RGB2HSV_invtab[256]={ // 65536/idx - 1 - 0, 0xffff, 0x7fff, 0x5554, 0x3fff, 0x3332, 0x2aa9, 0x2491, - 0x1fff, 0x1c70, 0x1998, 0x1744, 0x1554, 0x13b0, 0x1248, 0x1110, - 0x0fff, 0x0f0e, 0x0e37, 0x0d78, 0x0ccb, 0x0c2f, 0x0ba1, 0x0b20, - 0x0aa9, 0x0a3c, 0x09d7, 0x097a, 0x0923, 0x08d2, 0x0887, 0x0841, - 0x07ff, 0x07c0, 0x0786, 0x074f, 0x071b, 0x06ea, 0x06bb, 0x068f, - 0x0665, 0x063d, 0x0617, 0x05f3, 0x05d0, 0x05af, 0x058f, 0x0571, - 0x0554, 0x0538, 0x051d, 0x0504, 0x04eb, 0x04d3, 0x04bc, 0x04a6, - 0x0491, 0x047c, 0x0468, 0x0455, 0x0443, 0x0431, 0x0420, 0x040f, - 0x03ff, 0x03ef, 0x03df, 0x03d1, 0x03c2, 0x03b4, 0x03a7, 0x039a, - 0x038d, 0x0380, 0x0374, 0x0368, 0x035d, 0x0352, 0x0347, 0x033c, - 0x0332, 0x0328, 0x031e, 0x0314, 0x030b, 0x0302, 0x02f9, 0x02f0, - 0x02e7, 0x02df, 0x02d7, 0x02cf, 0x02c7, 0x02bf, 0x02b8, 0x02b0, - 0x02a9, 0x02a2, 0x029b, 0x0294, 0x028e, 0x0287, 0x0281, 0x027b, - 0x0275, 0x026f, 0x0269, 0x0263, 0x025d, 0x0258, 0x0252, 0x024d, - 0x0248, 0x0242, 0x023d, 0x0238, 0x0233, 0x022f, 0x022a, 0x0225, - 0x0221, 0x021c, 0x0218, 0x0213, 0x020f, 0x020b, 0x0207, 0x0203, - 0x01ff, 0x01fb, 0x01f7, 0x01f3, 0x01ef, 0x01eb, 0x01e8, 0x01e4, - 0x01e0, 0x01dd, 0x01d9, 0x01d6, 0x01d3, 0x01cf, 0x01cc, 0x01c9, - 0x01c6, 0x01c2, 0x01bf, 0x01bc, 0x01b9, 0x01b6, 0x01b3, 0x01b1, - 0x01ae, 0x01ab, 0x01a8, 0x01a5, 0x01a3, 0x01a0, 0x019d, 0x019b, - 0x0198, 0x0196, 0x0193, 0x0191, 0x018e, 0x018c, 0x0189, 0x0187, - 0x0185, 0x0182, 0x0180, 0x017e, 0x017c, 0x0179, 0x0177, 0x0175, - 0x0173, 0x0171, 0x016f, 0x016d, 0x016b, 0x0169, 0x0167, 0x0165, - 0x0163, 0x0161, 0x015f, 0x015d, 0x015b, 0x0159, 0x0157, 0x0156, - 0x0154, 0x0152, 0x0150, 0x014f, 0x014d, 0x014b, 0x0149, 0x0148, - 0x0146, 0x0145, 0x0143, 0x0141, 0x0140, 0x013e, 0x013d, 0x013b, - 0x013a, 0x0138, 0x0137, 0x0135, 0x0134, 0x0132, 0x0131, 0x012f, - 0x012e, 0x012d, 0x012b, 0x012a, 0x0128, 0x0127, 0x0126, 0x0124, - 0x0123, 0x0122, 0x0120, 0x011f, 0x011e, 0x011d, 0x011b, 0x011a, - 0x0119, 0x0118, 0x0117, 0x0115, 0x0114, 0x0113, 0x0112, 0x0111, - 0x0110, 0x010e, 0x010d, 0x010c, 0x010b, 0x010a, 0x0109, 0x0108, - 0x0107, 0x0106, 0x0105, 0x0104, 0x0103, 0x0102, 0x0101, 0x0100, -}; - - -#endif//__LICE_CPP_IMPLEMENTED__ diff --git a/oversampling/WDL/lice/lice.h b/oversampling/WDL/lice/lice.h deleted file mode 100644 index 8e4c927..0000000 --- a/oversampling/WDL/lice/lice.h +++ /dev/null @@ -1,639 +0,0 @@ -#ifndef _LICE_H -#define _LICE_H - -/* - Cockos WDL - LICE - Lightweight Image Compositing Engine - - Copyright (C) 2007 and later, Cockos Incorporated - Portions Copyright (C) 2007 "schwa" - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - -*/ - -#ifdef _WIN32 -#include -#else -#include "../swell/swell-types.h" // use SWELL on other systems -#endif - - -// one of these can be defined in your project if you choose: -//#define LICE_FAVOR_SPEED // optimizes some stuff that doesnt seem to benefit much (like LICE_DeltaBlit/LICE_RotatedBlit/LICE_TransformBlit) -// (nothing) default probably good overall -//#define LICE_FAVOR_SIZE // reduces code size of normal/scaled blit functions -//#define LICE_FAVOR_SIZE_EXTREME // same as LICE_FAVOR_SIZE w/ smaller gains with bigger perf penalties (solid fills etc) - -#ifdef LICE_FAVOR_SPEED - #ifdef LICE_FAVOR_SIZE_EXTREME - #undef LICE_FAVOR_SIZE_EXTREME - #endif - #ifdef LICE_FAVOR_SIZE - #undef LICE_FAVOR_SIZE - #endif -#endif -#if defined(LICE_FAVOR_SIZE_EXTREME) && !defined(LICE_FAVOR_SIZE) -#define LICE_FAVOR_SIZE -#endif - - -typedef unsigned int LICE_pixel; -typedef unsigned char LICE_pixel_chan; - -#define LICE_RGBA(r,g,b,a) (((b)&0xff)|(((g)&0xff)<<8)|(((r)&0xff)<<16)|(((a)&0xff)<<24)) -#define LICE_GETB(v) ((v)&0xff) -#define LICE_GETG(v) (((v)>>8)&0xff) -#define LICE_GETR(v) (((v)>>16)&0xff) -#define LICE_GETA(v) (((v)>>24)&0xff) - -#if defined(__APPLE__) && defined(__ppc__) -#define LICE_PIXEL_A 0 -#define LICE_PIXEL_R 1 -#define LICE_PIXEL_G 2 -#define LICE_PIXEL_B 3 -#else -#define LICE_PIXEL_B 0 -#define LICE_PIXEL_G 1 -#define LICE_PIXEL_R 2 -#define LICE_PIXEL_A 3 -#endif - - -static inline LICE_pixel LICE_RGBA_FROMNATIVE(LICE_pixel col, int alpha=0) -{ - return LICE_RGBA(GetRValue(col),GetGValue(col),GetBValue(col),alpha); -} - -// bitmap interface, and some built-in types (memory bitmap and system bitmap) - -class LICE_IBitmap -{ -public: - virtual ~LICE_IBitmap() { } - - virtual LICE_pixel *getBits()=0; - virtual int getWidth()=0; - virtual int getHeight()=0; - virtual int getRowSpan()=0; // includes any off-bitmap data - virtual bool isFlipped() { return false; } - virtual bool resize(int w, int h)=0; - - virtual HDC getDC() { return 0; } // only sysbitmaps have to implement this - - - virtual INT_PTR Extended(int id, void* data) { return 0; } -}; - -#define LICE_EXT_SET_SCALING 0x2000 // data = int *, scaling is .8 fixed point. returns true if supported. affects LICE_*() draw operations -#define LICE_EXT_GET_SCALING 0x2001 // data ignored, returns .8 fixed point, returns 0 if unscaled -#define LICE_EXT_SET_ADVISORY_SCALING 0x2002 // data = int *, scaling is .8 fixed point. returns true if supported. does not affect draw operations -#define LICE_EXT_GET_ADVISORY_SCALING 0x2003 // data ignored, returns .8 fixed point. returns 0 if unscaled -#define LICE_EXT_GET_ANY_SCALING 0x2004 // data ignored, returns .8 fixed point, 0 if unscaled - -#define LICE_MEMBITMAP_ALIGNAMT 63 - -class LICE_MemBitmap : public LICE_IBitmap -{ -public: - LICE_MemBitmap(int w=0, int h=0, unsigned int linealign=4); - virtual ~LICE_MemBitmap(); - - - // LICE_IBitmap interface - virtual LICE_pixel *getBits() - { - const UINT_PTR extra=LICE_MEMBITMAP_ALIGNAMT; - return (LICE_pixel *) (((UINT_PTR)m_fb + extra)&~extra); - } - virtual int getWidth() { return m_width; } - virtual int getHeight() { return m_height; } - virtual int getRowSpan() { return (m_width+m_linealign)&~m_linealign; } - virtual bool resize(int w, int h) { return __resize(w,h); } // returns TRUE if a resize occurred - - // todo: LICE_EXT_SET_SCALING ? - -private: - bool __resize(int w, int h); - LICE_pixel *m_fb; - int m_width, m_height; - int m_allocsize; - unsigned int m_linealign; -}; - -class LICE_SysBitmap : public LICE_IBitmap -{ -public: - LICE_SysBitmap(int w=0, int h=0); - virtual ~LICE_SysBitmap(); - - // LICE_IBitmap interface - virtual LICE_pixel *getBits() { return m_bits; } - virtual int getWidth() { return m_width; } - virtual int getHeight() { return m_height; } - virtual int getRowSpan() { return m_allocw; }; - virtual bool resize(int w, int h) { return __resize(w,h); } // returns TRUE if a resize occurred - - virtual INT_PTR Extended(int id, void* data) - { - switch (id) - { - case LICE_EXT_SET_ADVISORY_SCALING: - { - int sc = data && *(int*)data != 256 ? *(int *)data : 0; - if (sc < 0) sc = 0; - m_adv_scaling = sc; - } - return 1; - case LICE_EXT_SET_SCALING: - { - int sc = data && *(int*)data != 256 ? *(int *)data : 0; - if (sc < 0) sc = 0; - if (m_draw_scaling != sc) - { - const int tmp=m_width; - m_draw_scaling = sc; - m_width=0; - resize(tmp,m_height); - } - } - return 1; - case LICE_EXT_GET_SCALING: - return m_draw_scaling; - case LICE_EXT_GET_ADVISORY_SCALING: - return m_adv_scaling; - case LICE_EXT_GET_ANY_SCALING: - if (m_draw_scaling > 0) - { - if (m_adv_scaling > 0) - return (m_adv_scaling * m_draw_scaling) >> 8; - return m_draw_scaling; - } - return m_adv_scaling; - } - return 0; - } - - // sysbitmap specific calls - virtual HDC getDC() { return m_dc; } - - -private: - bool __resize(int w, int h); - int m_width, m_height; - - HDC m_dc; - LICE_pixel *m_bits; - int m_allocw, m_alloch; -#ifdef _WIN32 - HBITMAP m_bitmap; - HGDIOBJ m_oldbitmap; -#endif - int m_draw_scaling, m_adv_scaling; -}; - -class LICE_WrapperBitmap : public LICE_IBitmap -{ - public: - LICE_WrapperBitmap(LICE_pixel *buf, int w, int h, int span, bool flipped) - { - m_buf=buf; - m_w=w; - m_h=h; - m_span=span; - m_flipped=flipped; - } - virtual ~LICE_WrapperBitmap() {} - - virtual bool resize(int w, int h) { return false; } - virtual LICE_pixel *getBits() { return m_buf; } - virtual int getWidth() { return m_w; } - virtual int getHeight() { return m_h; } - virtual int getRowSpan() { return m_span; } - - virtual HDC getDC() { return NULL; } - virtual bool isFlipped() { return m_flipped; } - - - LICE_pixel *m_buf; - int m_w,m_h,m_span; - bool m_flipped; -}; - - -class LICE_SubBitmap : public LICE_IBitmap // note: you should only keep these around as long as they are needed, and don't resize the parent while this is allocated -{ - public: - LICE_SubBitmap(LICE_IBitmap *parent, int x, int y, int w, int h) - { - m_parent=parent; - if(x<0)x=0; - if(y<0)y=0; - m_x=x;m_y=y; - __resize(w,h); - } - virtual ~LICE_SubBitmap() { } - - virtual bool resize(int w, int h) { return __resize(w,h); } - - bool __resize(int w, int h) - { - m_w=0;m_h=0; - if (m_parent && m_x >= 0 && m_y >= 0 && m_x < m_parent->getWidth() && m_y < m_parent->getHeight()) - { - if (w > m_parent->getWidth()-m_x) w=m_parent->getWidth()-m_x; - if (h > m_parent->getHeight()-m_y) h=m_parent->getHeight()-m_y; - - m_w=w; - m_h=h; - } - - return true; - } - - virtual bool isFlipped() { return m_parent && m_parent->isFlipped(); } - - virtual LICE_pixel *getBits() - { - if (!m_parent) return 0; - - int xc = m_x, yc = m_y, h = m_h; - const int scale = (int)m_parent->Extended(LICE_EXT_GET_SCALING,NULL); - if (scale > 0) - { - xc = (xc*scale)>>8; - yc = (yc*scale)>>8; - h = (h*scale)>>8; - } - - LICE_pixel* parentptr=m_parent->getBits(); - if (m_parent->isFlipped()) parentptr += (m_parent->getHeight() - (yc+h))*m_parent->getRowSpan()+xc; - else parentptr += yc*m_parent->getRowSpan()+xc; - - return parentptr; - } - - enum { - LICE_GET_SUBBITMAP_VERSION = 0x51b7000, - LICE_SUBBITMAP_VERSION = 0x1000 // if we change any of this struct, then we *must* increment this version. - }; - - virtual INT_PTR Extended(int id, void* data) - { - if (id == LICE_GET_SUBBITMAP_VERSION) return LICE_SUBBITMAP_VERSION; - - if (!m_parent) return 0; - return m_parent->Extended(id, data); - } - - virtual int getWidth() { return m_w; } - virtual int getHeight() { return m_h; } - virtual int getRowSpan() { return m_parent ? m_parent->getRowSpan() : 0; } - - virtual HDC getDC() { return NULL; } - - int m_w,m_h,m_x,m_y; - LICE_IBitmap *m_parent; -}; - - -// flags that most blit functions can take - -#define LICE_BLIT_MODE_MASK 0xff -#define LICE_BLIT_MODE_COPY 0 -#define LICE_BLIT_MODE_ADD 1 -#define LICE_BLIT_MODE_DODGE 2 -#define LICE_BLIT_MODE_MUL 3 -#define LICE_BLIT_MODE_OVERLAY 4 -#define LICE_BLIT_MODE_HSVADJ 5 - -#define LICE_BLIT_MODE_CHANCOPY 0xf0 // in this mode, only available for LICE_Blit(), the low nibble is 2 bits of source channel (low 2), 2 bits of dest channel (high 2) - -#define LICE_BLIT_FILTER_MASK 0xff00 -#define LICE_BLIT_FILTER_NONE 0 -#define LICE_BLIT_FILTER_BILINEAR 0x100 // currently pretty slow! ack -#define LICE_BLIT_IGNORE_SCALING 0x20000 - - -#define LICE_BLIT_USE_ALPHA 0x10000 // use source's alpha channel - -#ifndef lice_max -#define lice_max(x,y) ((x)<(y)?(y):(x)) -#define lice_min(x,y) ((x)<(y)?(x):(y)) -#endif - -#ifdef _MSC_VER - #include - #define lice_isfinite(x) _finite(x) -#else - #define lice_isfinite(x) isfinite(x) -#endif - -// Reaper exports most LICE functions, so the function declarations below -// will collide with reaper_plugin.h -#ifndef LICE_PROVIDED_BY_APP - - -// bitmap loaders - -// dispatch to a linked loader implementation based on file extension -LICE_IBitmap* LICE_LoadImage(const char* filename, LICE_IBitmap* bmp=NULL, bool tryIgnoreExtension=false); -char *LICE_GetImageExtensionList(bool wantAllSup=true, bool wantAllFiles=true); // returns doublenull terminated GetOpenFileName() style list -- free() when done. -bool LICE_ImageIsSupported(const char *filename); // must be a filename that ends in .jpg, etc. if you want to check the extension, pass .ext - - -// pass a bmp if you wish to load it into that bitmap. note that if it fails bmp will not be deleted. -LICE_IBitmap *LICE_LoadPNG(const char *filename, LICE_IBitmap *bmp=NULL); // returns a bitmap (bmp if nonzero) on success -LICE_IBitmap *LICE_LoadPNGFromMemory(const void *data_in, int buflen, LICE_IBitmap *bmp=NULL); -LICE_IBitmap *LICE_LoadPNGFromResource(HINSTANCE hInst, const char *resid, LICE_IBitmap *bmp=NULL); // returns a bitmap (bmp if nonzero) on success -#ifndef _WIN32 -LICE_IBitmap *LICE_LoadPNGFromNamedResource(const char *name, LICE_IBitmap *bmp=NULL); // returns a bitmap (bmp if nonzero) on success -#endif - -LICE_IBitmap *LICE_LoadBMP(const char *filename, LICE_IBitmap *bmp=NULL); // returns a bitmap (bmp if nonzero) on success -LICE_IBitmap *LICE_LoadBMPFromResource(HINSTANCE hInst, const char *resid, LICE_IBitmap *bmp=NULL); // returns a bitmap (bmp if nonzero) on success - -LICE_IBitmap *LICE_LoadIcon(const char *filename, int reqiconsz=16, LICE_IBitmap *bmp=NULL); // returns a bitmap (bmp if nonzero) on success -LICE_IBitmap *LICE_LoadIconFromResource(HINSTANCE hInst, const char *resid, int reqiconsz=16, LICE_IBitmap *bmp=NULL); // returns a bitmap (bmp if nonzero) on success - -LICE_IBitmap *LICE_LoadJPG(const char *filename, LICE_IBitmap *bmp=NULL); -LICE_IBitmap *LICE_LoadJPGFromMemory(const void *data_in, int buflen, LICE_IBitmap *bmp = NULL); -LICE_IBitmap* LICE_LoadJPGFromResource(HINSTANCE hInst, const char *resid, LICE_IBitmap* bmp = 0); - -LICE_IBitmap *LICE_LoadGIF(const char *filename, LICE_IBitmap *bmp=NULL, int *nframes=NULL); // if nframes set, will be set to number of images (stacked vertically), otherwise first frame used - -LICE_IBitmap *LICE_LoadPCX(const char *filename, LICE_IBitmap *bmp=NULL); // returns a bitmap (bmp if nonzero) on success - -// bitmap saving -bool LICE_WritePNG(const char *filename, LICE_IBitmap *bmp, bool wantalpha=true); -bool LICE_WriteJPG(const char *filename, LICE_IBitmap *bmp, int quality=95, bool force_baseline=true); -bool LICE_WriteGIF(const char *filename, LICE_IBitmap *bmp, int transparent_alpha=0, bool dither=true); // if alphaExtended(LICE_EXT_GET_SCALING,NULL); \ - if (rsc>0) \ - StretchBlt(hdc,_x,_y,_w,_h,(src)->getDC(),(_sx*rsc)/256,(_sy*rsc)/256,(_w*rsc)>>8,(_h*rsc)>>8,_mode); \ - else BitBlt(hdc,_x,_y,_w,_h,(src)->getDC(),_sx,_sy,_mode); \ -} while (0) -#else -#define LICE_Scale_BitBlt(hdc, x,y,w,h, src, sx,sy, mode) BitBlt(hdc,x,y,w,h,(src)->getDC(),sx,sy,mode) -#endif - -#endif diff --git a/oversampling/WDL/lice/lice_arc.cpp b/oversampling/WDL/lice/lice_arc.cpp deleted file mode 100644 index 6f0e467..0000000 --- a/oversampling/WDL/lice/lice_arc.cpp +++ /dev/null @@ -1,731 +0,0 @@ -#ifndef WDL_NO_DEFINE_MINMAX -#define WDL_NO_DEFINE_MINMAX -#endif -#include "lice.h" -#include "lice_combine.h" -#include - -#define _PI 3.141592653589793238f - -#define IGNORE_SCALING(mode) ((mode)&LICE_BLIT_IGNORE_SCALING) -template inline void _SWAP(T& a, T& b) { T tmp = a; a = b; b = tmp; } - -#define A(x) ((LICE_pixel_chan)((x)*255.0+0.5)) -#define AF(x) (255) - -#define DEF_ALPHAS(dim) \ - static const LICE_pixel_chan alphas_unfill[] = { __ALPHAS__(A) }; \ - static const LICE_pixel_chan alphas_fill[] = { __ALPHAS__(AF) }; \ - const LICE_pixel_chan * const alphas = fill ? alphas_fill : alphas_unfill; \ - ((void)sizeof(char[1 - 2*(sizeof(alphas_unfill) != dim*dim)])); \ - ((void)sizeof(char[1 - 2*(sizeof(alphas_fill) != dim*dim)])); - -static bool CachedCircle(LICE_IBitmap* dest, float cx, float cy, float r, LICE_pixel color, float alpha, int mode, bool aa, bool fill) -{ - // fast draw for some small circles - if (r == 1.5f) - { - if (aa) - { -#define __ALPHAS__(B) \ - A(0.31), A(1.00), A(1.00), A(0.31), \ - A(1.00), B(0.06), B(0.06), A(1.00), \ - A(1.00), B(0.06), B(0.06), A(1.00), \ - A(0.31), A(1.00), A(1.00), A(0.31), - - DEF_ALPHAS(4) -#undef __ALPHAS__ - LICE_DrawGlyph(dest, cx-r, cy-r, color, alphas, 4, 4, alpha, mode); - } - else - { -#define __ALPHAS__(B) \ - A(0.00), A(1.00), A(1.00), A(0.00), \ - A(1.00), B(0.00), B(0.00), A(1.00), \ - A(1.00), B(0.00), B(0.00), A(1.00), \ - A(0.00), A(1.00), A(1.00), A(0.00), - - DEF_ALPHAS(4) -#undef __ALPHAS__ - LICE_DrawGlyph(dest, cx-r, cy-r, color, alphas, 4, 4, alpha, mode); - } - return true; - } - else if (r == 2.0f) - { - if (aa) - { -#define __ALPHAS__(B) \ - A(0.06), A(0.75), A(1.00), A(0.75), A(0.06), \ - A(0.75), A(0.82), B(0.31), A(0.82), A(0.75), \ - A(1.00), B(0.31), B(0.00), B(0.31), A(1.00), \ - A(0.75), A(0.82), B(0.31), A(0.82), A(0.75), \ - A(0.06), A(0.75), A(1.00), A(0.75), A(0.06) - - DEF_ALPHAS(5) -#undef __ALPHAS__ - LICE_DrawGlyph(dest, cx-r, cy-r, color, alphas, 5, 5, alpha, mode); - } - else - { -#define __ALPHAS__(B) \ - A(0.00), A(0.00), A(1.00), A(0.00), A(0.00), \ - A(0.00), A(1.00), B(0.00), A(1.00), A(0.00), \ - A(1.00), B(0.00), B(0.00), B(0.00), A(1.00), \ - A(0.00), A(1.00), B(0.00), A(1.00), A(0.00), \ - A(0.00), A(0.00), A(1.00), A(0.00), A(0.00) - - DEF_ALPHAS(5) -#undef __ALPHAS__ - LICE_DrawGlyph(dest, cx-r, cy-r, color, alphas, 5, 5, alpha, mode); - } - return true; - } - else if (r == 2.5f) { - if (aa) { -#define __ALPHAS__(B) \ - A(0.06), A(0.75), A(1.00), A(1.00), A(0.75), A(0.06), \ - A(0.75), A(0.82), B(0.31), B(0.31), A(0.82), A(0.75), \ - A(1.00), B(0.31), B(0.00), B(0.00), B(0.31), A(1.00), \ - A(1.00), B(0.31), B(0.00), B(0.00), B(0.31), A(1.00), \ - A(0.75), A(0.82), B(0.31), B(0.31), A(0.82), A(0.75), \ - A(0.06), A(0.75), A(1.00), A(1.00), A(0.75), A(0.06) - - DEF_ALPHAS(6) -#undef __ALPHAS__ - LICE_DrawGlyph(dest, cx-r, cy-r, color, alphas, 6, 6, alpha, mode); - } - else { -#define __ALPHAS__(B) \ - A(0.00), A(0.00), A(1.00), A(1.00), A(0.00), A(0.00), \ - A(0.00), A(1.00), B(0.00), B(0.00), A(1.00), A(0.00), \ - A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), \ - A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), \ - A(0.00), A(1.00), B(0.00), B(0.00), A(1.00), A(0.00), \ - A(0.00), A(0.00), A(1.00), A(1.00), A(0.00), A(0.00) - - DEF_ALPHAS(6) -#undef __ALPHAS__ - LICE_DrawGlyph(dest, cx-r, cy-r, color, alphas, 6, 6, alpha, mode); - } - return true; - } - else if (r == 3.0f) { - if (aa) { -#define __ALPHAS__(B) \ - A(0.00), A(0.56), A(1.00), A(1.00), A(1.00), A(0.56), A(0.00), \ - A(0.56), A(1.00), B(0.38), B(0.25), B(0.38), A(1.00), A(0.56), \ - A(1.00), B(0.44), B(0.00), B(0.00), B(0.00), B(0.44), A(1.00), \ - A(1.00), B(0.19), B(0.00), B(0.00), B(0.00), B(0.19), A(1.00), \ - A(1.00), B(0.44), B(0.00), B(0.00), B(0.00), B(0.44), A(1.00), \ - A(0.56), A(1.00), B(0.38), B(0.25), B(0.38), A(1.00), A(0.56), \ - A(0.00), A(0.56), A(1.00), A(1.00), A(1.00), A(0.56), A(0.00) - - DEF_ALPHAS(7) -#undef __ALPHAS__ - LICE_DrawGlyph(dest, cx-r, cy-r, color, alphas, 7, 7, alpha, mode); - } - else { -#define __ALPHAS__(B) \ - A(0.00), A(0.00), A(1.00), A(1.00), A(1.00), A(0.00), A(0.00), \ - A(0.00), A(1.00), B(0.00), B(0.00), B(0.00), A(1.00), A(0.00), \ - A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), \ - A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), \ - A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), \ - A(0.00), A(1.00), B(0.00), B(0.00), B(0.00), A(1.00), A(0.00), \ - A(0.00), A(0.00), A(1.00), A(1.00), A(1.00), A(0.00), A(0.00) - - DEF_ALPHAS(7) -#undef __ALPHAS__ - LICE_DrawGlyph(dest, cx-r, cy-r, color, alphas, 7, 7, alpha, mode); - } - return true; - } - else if (r == 3.5f) { - if (aa) { -#define __ALPHAS__(B) \ - A(0.00), A(0.31), A(0.87), A(1.00), A(1.00), A(0.87), A(0.31), A(0.00), \ - A(0.31), A(1.00), A(0.69), B(0.25), B(0.25), A(0.69), A(1.00), A(0.31), \ - A(0.87), A(0.69), B(0.00), B(0.00), B(0.00), B(0.00), A(0.69), A(0.87), \ - A(1.00), B(0.25), B(0.00), B(0.00), B(0.00), B(0.00), B(0.25), A(1.00), \ - A(1.00), B(0.25), B(0.00), B(0.00), B(0.00), B(0.00), B(0.25), A(1.00), \ - A(0.87), A(0.69), B(0.00), B(0.00), B(0.00), B(0.00), A(0.69), A(0.87), \ - A(0.31), A(1.00), A(0.69), B(0.25), B(0.25), A(0.69), A(1.00), A(0.31), \ - A(0.00), A(0.31), A(0.87), A(1.00), A(1.00), A(0.87), A(0.31), A(0.00) - - DEF_ALPHAS(8) -#undef __ALPHAS__ - LICE_DrawGlyph(dest, cx-r, cy-r, color, alphas, 8, 8, alpha, mode); - } - else { -#define __ALPHAS__(B) \ - A(0.00), A(0.00), A(1.00), A(1.00), A(1.00), A(1.00), A(0.00), A(0.00), \ - A(0.00), A(1.00), A(1.00), B(0.00), B(0.00), A(1.00), A(1.00), A(0.00), \ - A(1.00), A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), A(1.00), \ - A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), \ - A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), \ - A(1.00), A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), A(1.00), \ - A(0.00), A(1.00), A(1.00), B(0.00), B(0.00), A(1.00), A(1.00), A(0.00), \ - A(0.00), A(0.00), A(1.00), A(1.00), A(1.00), A(1.00), A(0.00), A(0.00) - - DEF_ALPHAS(8) -#undef __ALPHAS__ - LICE_DrawGlyph(dest, cx-r, cy-r, color, alphas, 8, 8, alpha, mode); - } - return true; - } - else if (r == 4.0f) { - if (aa) { -#define __ALPHAS__(B) \ - A(0.00), A(0.12), A(0.69), A(1.00), A(1.00), A(1.00), A(0.69), A(0.12), A(0.00), \ - A(0.12), A(0.94), A(0.82), B(0.31), B(0.25), B(0.31), A(0.82), A(0.94), A(0.12), \ - A(0.69), A(0.82), B(0.06), B(0.00), B(0.00), B(0.00), B(0.06), A(0.82), A(0.69), \ - A(1.00), B(0.31), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.31), A(1.00), \ - A(1.00), B(0.19), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.19), A(1.00), \ - A(1.00), B(0.31), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.31), A(1.00), \ - A(0.69), A(0.82), B(0.06), B(0.00), B(0.00), B(0.00), B(0.06), A(0.82), A(0.69), \ - A(0.12), A(0.94), A(0.82), B(0.31), B(0.25), B(0.31), A(0.82), A(0.94), A(0.12), \ - A(0.00), A(0.12), A(0.69), A(1.00), A(1.00), A(1.00), A(0.69), A(0.12), A(0.00) - - DEF_ALPHAS(9) -#undef __ALPHAS__ - LICE_DrawGlyph(dest, cx-r, cy-r, color, alphas, 9, 9, alpha, mode); - } - else { -#define __ALPHAS__(B) \ - A(0.00), A(0.00), A(1.00), A(1.00), A(1.00), A(1.00), A(1.00), A(0.00), A(0.00), \ - A(0.00), A(1.00), A(1.00), B(0.00), B(0.00), B(0.00), A(1.00), A(1.00), A(0.00), \ - A(1.00), A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), A(1.00), \ - A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), \ - A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), \ - A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), \ - A(1.00), A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), A(1.00), \ - A(0.00), A(1.00), A(1.00), B(0.00), B(0.00), B(0.00), A(1.00), A(1.00), A(0.00), \ - A(0.00), A(0.00), A(1.00), A(1.00), A(1.00), A(1.00), A(1.00), A(0.00), A(0.00) - - DEF_ALPHAS(9) -#undef __ALPHAS__ - LICE_DrawGlyph(dest, cx-r, cy-r, color, alphas, 9, 9, alpha, mode); - } - return true; - } - else if (r == 5.0f) - { - if (aa) { -#define __ALPHAS__(B) \ - A(0.00), A(0.00), A(0.00), A(0.58), A(0.90), A(1.00), A(0.90), A(0.58), A(0.00), A(0.00), A(0.00), \ - A(0.00), A(0.00), A(1.00), B(0.42), B(0.10), B(0.00), B(0.10), B(0.42), A(1.00), A(0.00), A(0.00), \ - A(0.00), A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), A(0.00), \ - A(0.58), B(0.42), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.42), A(0.58), \ - A(0.90), B(0.10), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.10), A(0.90), \ - A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), \ - A(0.90), B(0.10), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.10), A(0.90), \ - A(0.58), B(0.42), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.42), A(0.58), \ - A(0.00), A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), A(0.00), \ - A(0.00), A(0.00), A(1.00), B(0.42), B(0.10), B(0.00), B(0.10), B(0.42), A(1.00), A(0.00), A(0.00), \ - A(0.00), A(0.00), A(0.00), A(0.58), A(0.90), A(1.00), A(0.90), A(0.58), A(0.00), A(0.00), A(0.00) - - DEF_ALPHAS(11) -#undef __ALPHAS__ - LICE_DrawGlyph(dest, cx-r, cy-r, color, alphas, 11, 11, alpha, mode); - return true; - } - } - else if (r == 6.0f) - { - if (aa) { -#define __ALPHAS__(B) \ - A(0.00), A(0.00), A(0.00), A(0.20), A(0.66), A(0.92), A(1.00), A(0.92), A(0.66), A(0.20), A(0.00), A(0.00), A(0.00), \ - A(0.00), A(0.00), A(0.47), A(0.81), B(0.35), B(0.09), B(0.00), B(0.09), B(0.35), A(0.81), A(0.47), A(0.00), A(0.00), \ - A(0.00), A(0.47), B(0.53), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.53), A(0.47), A(0.00), \ - A(0.20), A(0.81), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(0.81), A(0.20), \ - A(0.66), B(0.35), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.35), A(0.66), \ - A(0.92), B(0.09), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.09), A(0.92), \ - A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), \ - A(0.92), B(0.09), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.09), A(0.92), \ - A(0.66), B(0.35), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.35), A(0.66), \ - A(0.20), A(0.81), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(0.81), A(0.20), \ - A(0.00), A(0.47), B(0.53), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.53), A(0.47), A(0.00), \ - A(0.00), A(0.00), A(0.47), A(0.81), B(0.35), B(0.09), B(0.00), B(0.09), B(0.35), A(0.81), A(0.47), A(0.00), A(0.00), \ - A(0.00), A(0.00), A(0.00), A(0.20), A(0.66), A(0.92), A(1.00), A(0.92), A(0.66), A(0.20), A(0.00), A(0.00), A(0.00), - - DEF_ALPHAS(13) -#undef __ALPHAS__ - LICE_DrawGlyph(dest, cx-r, cy-r, color, alphas, 13, 13, alpha, mode); - return true; - } - } - else if (r == 7.0f) - { - if (aa) { -#define __ALPHAS__(B) \ - A(0.00), A(0.00), A(0.00), A(0.00), A(0.33), A(0.71), A(0.93), A(1.00), A(0.93), A(0.71), A(0.33), A(0.00), A(0.00), A(0.00), A(0.00), \ - A(0.00), A(0.00), A(0.00), A(0.75), A(0.68), B(0.29), B(0.07), B(0.00), B(0.07), B(0.29), A(0.68), A(0.75), A(0.00), A(0.00), A(0.00), \ - A(0.00), A(0.00), A(0.90), B(0.26), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.34), A(0.90), A(0.00), A(0.00), \ - A(0.00), A(0.75), B(0.34), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.26), A(0.75), A(0.00), \ - A(0.33), A(0.68), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(0.68), A(0.33), \ - A(0.71), B(0.29), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.29), A(0.71), \ - A(0.93), B(0.07), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.07), A(0.93), \ - A(1.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(1.00), \ - A(0.93), B(0.07), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.07), A(0.93), \ - A(0.71), B(0.29), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.29), A(0.71), \ - A(0.33), A(0.68), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), A(0.68), A(0.33), \ - A(0.00), A(0.75), B(0.34), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.26), A(0.75), A(0.00), \ - A(0.00), A(0.00), A(0.90), B(0.26), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.00), B(0.34), A(0.90), A(0.00), A(0.00), \ - A(0.00), A(0.00), A(0.00), A(0.75), A(0.68), B(0.29), B(0.07), B(0.00), B(0.07), B(0.29), A(0.68), A(0.75), A(0.00), A(0.00), A(0.00), \ - A(0.00), A(0.00), A(0.00), A(0.00), A(0.33), A(0.71), A(0.93), A(1.00), A(0.93), A(0.71), A(0.33), A(0.00), A(0.00), A(0.00), A(0.00), - - DEF_ALPHAS(15) -#undef __ALPHAS__ - LICE_DrawGlyph(dest, cx-r, cy-r, color, alphas, 15, 15, alpha, mode); - return true; - } - } - - return false; -} - - -template class _LICE_CircleDrawer -{ -public: - - static void DrawClippedPt(LICE_IBitmap* dest, int x, int y, const int *clip, - int r, int g, int b, int a, int alpha, bool doclip) - { - if (doclip && (x < clip[0] || x >= clip[2] || y < clip[1] || y >= clip[3])) return; - LICE_pixel* px = dest->getBits()+y*dest->getRowSpan()+x; - COMBFUNC::doPix((LICE_pixel_chan*)px, r, g, b, a, alpha); - } - - static void DrawClippedHorzLine(LICE_IBitmap* dest, int y, int xlo, int xhi, const int *clip, - int r, int g, int b, int a, int alpha, bool doclip) - { - if (doclip) - { - if (y < clip[1] || y >= clip[3]) return; - xlo = lice_max(xlo, clip[0]); - xhi = lice_min(xhi, clip[2]-1); - } - LICE_pixel* px = dest->getBits()+y*dest->getRowSpan()+xlo; - while (xlo <= xhi) - { - COMBFUNC::doPix((LICE_pixel_chan*)px, r, g, b, a, alpha); - ++px; - ++xlo; - } - } - - static void DrawClippedVertLine(LICE_IBitmap* dest, int x, int ylo, int yhi, const int *clip, - int r, int g, int b, int a, int alpha, bool doclip) - { - if (doclip) - { - if (x < clip[0] || x >= clip[2]) return; - ylo = lice_max(ylo, clip[1]); - yhi = lice_min(yhi, clip[3]-1); - } - int span=dest->getRowSpan(); - LICE_pixel* px = dest->getBits()+ylo*span+x; - while (ylo <= yhi) - { - COMBFUNC::doPix((LICE_pixel_chan*)px, r, g, b, a, alpha); - px += span; - ++ylo; - } - } - - static void DrawClippedCircleAA(LICE_IBitmap* dest, float cx, float cy, float rad, - const int *clip, LICE_pixel color, int ai, bool filled, bool doclip) - { - int r = LICE_GETR(color), g = LICE_GETG(color), b = LICE_GETB(color), a = LICE_GETA(color); - - const int cx0=(int)floor(cx+0.5f); - const int cy0=(int)floor(cy+0.5f); - - int y=(int)rad; - double w=rad-floor(rad); - int wa=(int)((double)ai*w); - - DrawClippedPt(dest, cx0, cy0-y-1, clip, r, g, b, a, wa, doclip); - DrawClippedPt(dest, cx0, cy0+y+1, clip, r, g, b, a, wa, doclip); - DrawClippedPt(dest, cx0-y-1, cy0, clip, r, g, b, a, wa, doclip); - DrawClippedPt(dest, cx0+y+1, cy0, clip, r, g, b, a, wa, doclip); - - if (filled) - { - DrawClippedVertLine(dest, cx0, cy0-y, cy0-1, clip, r, g, b, a, ai, doclip); - DrawClippedVertLine(dest, cx0, cy0+1, cy0+y, clip, r, g, b, a, ai, doclip); - DrawClippedHorzLine(dest, cy0, cx0-y, cx0+y, clip, r, g, b, a, ai, doclip); - } - else - { - int iwa=ai-wa; - DrawClippedPt(dest, cx0, cy0-y, clip, r, g, b, a, iwa, doclip); - DrawClippedPt(dest, cx0+y, cy0, clip, r, g, b, a, iwa, doclip); - DrawClippedPt(dest, cx0, cy0+y, clip, r, g, b, a, iwa, doclip); - DrawClippedPt(dest, cx0-y, cy0, clip, r, g, b, a, iwa, doclip); - } - - double r2=rad*rad; - double yf=sqrt(r2-1.0); - int yl=(int)(yf+0.5); - - int x=1; - while (x <= yl) - { - y=(int)yf; - w=yf-floor(yf); - wa=(int)((double)ai*w); - - DrawClippedPt(dest, cx0-x, cy0-y-1, clip, r, g, b, a, wa, doclip); - DrawClippedPt(dest, cx0-x, cy0+y+1, clip, r, g, b, a, wa, doclip); - DrawClippedPt(dest, cx0+x, cy0-y-1, clip, r, g, b, a, wa, doclip); - DrawClippedPt(dest, cx0+x, cy0+y+1, clip, r, g, b, a, wa, doclip); - if (x != yl) - { - DrawClippedPt(dest, cx0-y-1, cy0-x, clip, r, g, b, a, wa, doclip); - DrawClippedPt(dest, cx0+y+1, cy0-x, clip, r, g, b, a, wa, doclip); - DrawClippedPt(dest, cx0-y-1, cy0+x, clip, r, g, b, a, wa, doclip); - DrawClippedPt(dest, cx0+y+1, cy0+x, clip, r, g, b, a, wa, doclip); - } - - if (filled) - { - DrawClippedVertLine(dest, cx0-x, cy0-y, cy0-x-1, clip, r, g, b, a, ai, doclip); - DrawClippedVertLine(dest, cx0-x, cy0+x+1, cy0+y, clip, r, g, b, a, ai, doclip); - DrawClippedHorzLine(dest, cy0-x, cx0-y, cx0-x, clip, r, g, b, a, ai, doclip); - DrawClippedHorzLine(dest, cy0-x, cx0+x, cx0+y, clip, r, g, b, a, ai, doclip); - DrawClippedHorzLine(dest, cy0+x, cx0-y, cx0-x, clip, r, g, b, a, ai, doclip); - DrawClippedHorzLine(dest, cy0+x, cx0+x, cx0+y, clip, r, g, b, a, ai, doclip); - DrawClippedVertLine(dest, cx0+x, cy0-y, cy0-x-1, clip, r, g, b, a, ai, doclip); - DrawClippedVertLine(dest, cx0+x, cy0+x+1, cy0+y, clip, r, g, b, a, ai, doclip); - } - else - { - int iwa=ai-wa; - DrawClippedPt(dest, cx0-y, cy0-x, clip, r, g, b, a, iwa, doclip); - DrawClippedPt(dest, cx0+y, cy0-x, clip, r, g, b, a, iwa, doclip); - DrawClippedPt(dest, cx0-x, cy0+y, clip, r, g, b, a, iwa, doclip); - DrawClippedPt(dest, cx0+x, cy0+y, clip, r, g, b, a, iwa, doclip); - if (x != yl) - { - DrawClippedPt(dest, cx0-x, cy0-y, clip, r, g, b, a, iwa, doclip); - DrawClippedPt(dest, cx0+x, cy0-y, clip, r, g, b, a, iwa, doclip); - DrawClippedPt(dest, cx0-y, cy0+x, clip, r, g, b, a, iwa, doclip); - DrawClippedPt(dest, cx0+y, cy0+x, clip, r, g, b, a, iwa, doclip); - } - } - - ++x; - yf=sqrt(r2-(double)(x*x)); - yl=(int)(yf+0.5); - } - } - - static void DrawClippedCircle(LICE_IBitmap* dest, float cx, float cy, float rad, - const int *clip, LICE_pixel color, int ai, bool filled, bool doclip) - { - const int r = LICE_GETR(color), g = LICE_GETG(color), b = LICE_GETB(color), a = LICE_GETA(color); - - const int cx0=(int)floor(cx+0.5f); - const int cy0=(int)floor(cy+0.5f); - const int r0=(int)(rad+0.5f); - - if (filled) - { - DrawClippedVertLine(dest, cx0, cy0-r0, cy0-1, clip, r, g, b, a, ai, doclip); - DrawClippedVertLine(dest, cx0, cy0+1, cy0+r0, clip, r, g, b, a, ai, doclip); - DrawClippedHorzLine(dest, cy0, cx0-r0, cx0+r0, clip, r, g, b, a, ai, doclip); - } - else - { - DrawClippedPt(dest, cx0, cy0-r0, clip, r, g, b, a, ai, doclip); - DrawClippedPt(dest, cx0+r0, cy0, clip, r, g, b, a, ai, doclip); - DrawClippedPt(dest, cx0, cy0+r0, clip, r, g, b, a, ai, doclip); - DrawClippedPt(dest, cx0-r0, cy0, clip, r, g, b, a, ai, doclip); - } - - int x=0; - int y=r0; - int e=-r0; - while (++x < y) - { - if (e < 0) - { - e += 2*x+1; - } - else - { - --y; - e += 2*(x-y)+1; - } - - if (filled) - { - DrawClippedVertLine(dest, cx0-x, cy0-y, cy0-x-1, clip, r, g, b, a, ai, doclip); - DrawClippedVertLine(dest, cx0-x, cy0+x+1, cy0+y, clip, r, g, b, a, ai, doclip); - DrawClippedHorzLine(dest, cy0-x, cx0-y, cx0-x, clip, r, g, b, a, ai, doclip); - DrawClippedHorzLine(dest, cy0-x, cx0+x, cx0+y, clip, r, g, b, a, ai, doclip); - DrawClippedHorzLine(dest, cy0+x, cx0-y, cx0-x, clip, r, g, b, a, ai, doclip); - DrawClippedHorzLine(dest, cy0+x, cx0+x, cx0+y, clip, r, g, b, a, ai, doclip); - DrawClippedVertLine(dest, cx0+x, cy0-y, cy0-x-1, clip, r, g, b, a, ai, doclip); - DrawClippedVertLine(dest, cx0+ x, cy0+x+1, cy0+y, clip, r, g, b, a, ai, doclip); - } - else - { - DrawClippedPt(dest, cx0-x, cy0-y, clip, r, g, b, a, ai, doclip); - DrawClippedPt(dest, cx0-x, cy0+y, clip, r, g, b, a, ai, doclip); - DrawClippedPt(dest, cx0+x, cy0-y, clip, r, g, b, a, ai, doclip); - DrawClippedPt(dest, cx0+x, cy0+y, clip, r, g, b, a, ai, doclip); - if (x != y) - { - DrawClippedPt(dest, cx0-y, cy0-x, clip, r, g, b, a, ai, doclip); - DrawClippedPt(dest, cx0-y, cy0+x, clip, r, g, b, a, ai, doclip); - DrawClippedPt(dest, cx0+y, cy0-x, clip, r, g, b, a, ai, doclip); - DrawClippedPt(dest, cx0+y, cy0+x, clip, r, g, b, a, ai, doclip); - } - } - } - } - -}; - - -static void __DrawCircleClipped(LICE_IBitmap* dest, float cx, float cy, float rad, - LICE_pixel color, int ia, bool aa, bool filled, int mode, const int *clip, bool doclip) -{ - // todo: more clipped/filled versions (to optimize constants out?) - if (aa) - { - #define __LICE__ACTION(COMBFUNC) _LICE_CircleDrawer::DrawClippedCircleAA(dest, cx, cy, rad, clip, color, ia, filled, doclip) - __LICE_ACTION_NOSRCALPHA(mode, ia,false) - #undef __LICE__ACTION - } - else - { - #define __LICE__ACTION(COMBFUNC) _LICE_CircleDrawer::DrawClippedCircle(dest, cx, cy, rad, clip, color, ia, filled, doclip) - __LICE_ACTION_CONSTANTALPHA(mode,ia,false) - #undef __LICE__ACTION - } -} - - -static void __DrawArc(int w, int h, LICE_IBitmap* dest, float cx, float cy, float rad, double anglo, double anghi, - LICE_pixel color, int ialpha, bool aa, int mode) -{ - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - __LICE_SCU(w); - __LICE_SCU(h); - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(cx); - __LICE_SC(cy); - __LICE_SC(rad); - } - } - // -2PI <= anglo <= anghi <= 2PI - anglo += 2.0*_PI; - anghi += 2.0*_PI; - - // 0 <= anglo <= anghi <= 4PI - - double next_ang = anglo - fmod(anglo,0.5*_PI); - - int ly = (int)floor(cy - rad*cos(anglo) + 0.5); - int lx = (int)floor(cx + rad*sin(anglo) + 0.5); - - while (anglo < anghi) - { - next_ang += 0.5*_PI; - if (next_ang > anghi) next_ang = anghi; - - int yhi = (int) floor(cy-rad*cos(next_ang)+0.5); - int xhi = (int) floor(cx+rad*sin(next_ang)+0.5); - int ylo = ly; - int xlo = lx; - - ly = yhi; - lx = xhi; - - if (yhi < ylo) { int tmp = ylo; ylo = yhi; yhi=tmp; } - if (xhi < xlo) { int tmp = xlo; xlo = xhi; xhi=tmp; } - - anglo = next_ang; - - if (xhi != cx) xhi++; - if (yhi != cy) yhi++; - - const int clip[4]={lice_max(xlo,0),lice_max(0, ylo),lice_min(w,xhi+1),lice_min(h, yhi+1)}; - - __DrawCircleClipped(dest,cx,cy,rad,color,ialpha,aa,false,mode,clip,true); - } -} - -void LICE_Arc(LICE_IBitmap* dest, float cx, float cy, float r, float minAngle, float maxAngle, - LICE_pixel color, float alpha, int mode, bool aa) -{ - if (!dest) return; - - if (dest->isFlipped()) { cy=dest->getHeight()-1-cy; minAngle=_PI-minAngle; maxAngle=_PI-maxAngle; } - - if (maxAngle < minAngle) - { - float tmp=maxAngle; - maxAngle=minAngle; - minAngle=tmp; - } - - if (maxAngle - minAngle >= 2.0f*_PI) - { - LICE_Circle(dest,cx,cy,r,color,alpha,mode,aa); - return; - } - - if (maxAngle >= 2.0f*_PI) - { - float tmp = fmod(maxAngle,2.0f*_PI); - minAngle -= maxAngle - tmp; // reduce by factors of 2PI - maxAngle = tmp; - } - else if (minAngle <= -2.0f*_PI) - { - float tmp = fmod(minAngle,2.0f*_PI); - maxAngle -= minAngle - tmp; // toward zero by factors of 2pi - minAngle = tmp; - } - - // -2PI <= minAngle <= maxAngle <= 2PI - - int ia = (int) (alpha*256.0f); - if (!ia) return; - - __DrawArc(dest->getWidth(),dest->getHeight(),dest,cx,cy,r,minAngle,maxAngle,color,ia,aa,mode); -} - - - - -void LICE_Circle(LICE_IBitmap* dest, float cx, float cy, float r, LICE_pixel color, float alpha, int mode, bool aa) -{ - if (!dest) return; - - int w = dest->getWidth(), h = dest->getHeight(); - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - __LICE_SCU(w); - __LICE_SCU(h); - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(cx); - __LICE_SC(cy); - __LICE_SC(r); - } - } - - const int clip[4] = { 0, 0, w, h }; - if (w < 1 || h <1 || r<0 || - (int)cx+(int)r < -2 || (int)cy + (int)r < - 2 || - (int)cx-(int)r > w + 2 || (int)cy - (int)r > h + 2 - ) return; - - int ia = (int) (alpha*256.0f); - if (!ia) return; - - if (CachedCircle(dest, cx, cy, r, color, alpha, mode|LICE_BLIT_IGNORE_SCALING, aa, false)) return; - - if (dest->isFlipped()) cy=h-1-cy; - - const bool doclip = !(cx-r-2 >= 0 && cy-r-2 >= 0 && cx+r+2 < w && cy+r+2 < h); - - __DrawCircleClipped(dest,cx,cy,r,color,ia,aa,false,mode,clip,doclip); -} - -void LICE_FillCircle(LICE_IBitmap* dest, float cx, float cy, float r, LICE_pixel color, float alpha, int mode, bool aa) -{ - if (!dest) return; - - int w = dest->getWidth(), h = dest->getHeight(); - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - __LICE_SCU(w); - __LICE_SCU(h); - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(cx); - __LICE_SC(cy); - __LICE_SC(r); - } - } - - if (w < 1 || h < 1 || r < 0.0 || - (int)cx+(int)r < -2 || (int)cy + (int)r < - 2 || - (int)cx-(int)r > w + 2 || (int)cy - (int)r > h + 2 - ) return; - - const int ia = (int) (alpha*256.0f); - if (!ia) return; - - if (CachedCircle(dest, cx, cy, r, color, alpha, mode|LICE_BLIT_IGNORE_SCALING, aa, true)) return; - - if (dest->isFlipped()) cy=h-1-cy; - - const int clip[4] = { 0, 0, w, h }; - - const bool doclip = !(cx-r-2 >= 0 && cy-r-2 >= 0 && cx+r+2 < w && cy+r+2 < h); - __DrawCircleClipped(dest,cx,cy,r,color,ia,aa,true,mode,clip,doclip); -} - - -void LICE_RoundRect(LICE_IBitmap *drawbm, float xpos, float ypos, float w, float h, int cornerradius, - LICE_pixel col, float alpha, int mode, bool aa) -{ - xpos = floor(xpos+0.5); - ypos = floor(ypos+0.5); - w = floor(w+0.5); - h = floor(h+0.5); - if (cornerradius>0) - { - float cr=cornerradius; - if (cr > w*0.5) cr=w*0.5; - if (cr > h*0.5) cr=h*0.5; - cr=floor(cr); - - if (cr>=2) - { - double adj = 0.0; - const int __sc = IGNORE_SCALING(mode) ? 0 : drawbm ? (int)drawbm->Extended(LICE_EXT_GET_SCALING,NULL) : 0; - if (__sc>0) - { - adj = 1.0 - 256.0/__sc; - - LICE_FLine(drawbm,xpos+cr+adj,ypos+adj,xpos+w-cr,ypos+adj,col,alpha,mode,true); - LICE_FLine(drawbm,xpos+cr-1+adj,ypos+h-adj,xpos+w-cr-adj,ypos+h-adj,col,alpha,mode,true); - LICE_FLine(drawbm,xpos+w-adj,ypos+cr+adj,xpos+w-adj,ypos+h-cr-adj,col,alpha,mode,true); - LICE_FLine(drawbm,xpos+adj,ypos+cr-1+adj,xpos+adj,ypos+h-cr-adj,col,alpha,mode,true); -// aa=true; - } - else - { - LICE_Line(drawbm,xpos+cr,ypos,xpos+w-cr,ypos,col,alpha,mode,aa); - LICE_Line(drawbm,xpos+cr-1,ypos+h,xpos+w-cr,ypos+h,col,alpha,mode,aa); - LICE_Line(drawbm,xpos+w,ypos+cr,xpos+w,ypos+h-cr,col,alpha,mode,aa); - LICE_Line(drawbm,xpos,ypos+cr-1,xpos,ypos+h-cr,col,alpha,mode,aa); - } - - LICE_Arc(drawbm,xpos+cr+adj,ypos+cr+adj,cr,-_PI*0.5f,0,col,alpha,mode,aa); - LICE_Arc(drawbm,xpos+w-cr-adj,ypos+cr+adj,cr,0,_PI*0.5f,col,alpha,mode,aa); - LICE_Arc(drawbm,xpos+w-cr-adj,ypos+h-cr-adj,cr,_PI*0.5f,_PI,col,alpha,mode,aa); - LICE_Arc(drawbm,xpos+cr+adj,ypos+h-cr-adj,cr,_PI,_PI*1.5f,col,alpha,mode,aa); - - return; - } - } - - LICE_DrawRect(drawbm, (int)xpos, (int)ypos, (int)w, (int)h, col, alpha, mode); -} - diff --git a/oversampling/WDL/lice/lice_bezier.h b/oversampling/WDL/lice/lice_bezier.h deleted file mode 100644 index f446642..0000000 --- a/oversampling/WDL/lice/lice_bezier.h +++ /dev/null @@ -1,306 +0,0 @@ -#ifndef _LICE_BEZIER_ -#define _LICE_BEZIER_ - -#include "lice.h" -#include - -// Returns quadratic bezier x, y for a given t in [0,1]. -template -void LICE_Bezier(T ctrl_x1, T ctrl_x2, T ctrl_x3, - T ctrl_y1, T ctrl_y2, T ctrl_y3, double t, T* pX, T* pY) -{ - double it = 1.0 - t; - double a = it * it; - double b = 2.0 * it * t; - double c = t * t; - *pX = (T) (a * (double) ctrl_x1 + b * (double) ctrl_x2 + c * (double) ctrl_x3); - *pY = (T) (a * (double) ctrl_y1 + b * (double) ctrl_y2 + c * (double) ctrl_y3); -} - -template -void LICE_CBezier_GetCoeffs(T ctrl_x1, T ctrl_x2, T ctrl_x3, T ctrl_x4, - T ctrl_y1, T ctrl_y2, T ctrl_y3, T ctrl_y4, - double* pAX, double* pBX, double* pCX, - double* pAY, double* pBY, double* pCY) -{ - double cx = *pCX = 3.0 * (double) (ctrl_x2 - ctrl_x1); - double bx = *pBX = 3.0 * (double) (ctrl_x3 - ctrl_x2) - cx; - *pAX = (double) (ctrl_x4 - ctrl_x1) - cx - bx; - double cy = *pCY = 3.0 * (double) (ctrl_y2 - ctrl_y1); - double by = *pBY = 3.0 * (double) (ctrl_y3 - ctrl_y2) - cy; - *pAY = (double) (ctrl_y4 - ctrl_y1) - cy - by; -} - -// Returns cubic bezier x, y for a given t in [0,1]. -template -void LICE_CBezier(T ctrl_x1, T ctrl_x2, T ctrl_x3, T ctrl_x4, - T ctrl_y1, T ctrl_y2, T ctrl_y3, T ctrl_y4, double t, T* pX, T* pY) -{ - double ax, bx, cx, ay, by, cy; - LICE_CBezier_GetCoeffs(ctrl_x1, ctrl_x2, ctrl_x3, ctrl_x4, - ctrl_y1, ctrl_y2, ctrl_y3, ctrl_y4, - &ax, &bx, &cx, &ay, &by, &cy); - - double t2 = t * t; - double t3 = t * t2; - *pX = (T) (ax * t3 + bx * t2 + cx * t) + ctrl_x1; - *pY = (T) (ay * t3 + by * t2 + cy * t) + ctrl_y1; -} - -// Returns quadratic bezier y for a given x in [x1, x3] (for rasterizing). -// ctrl_x1 < ctrl_x3 required. -template -T LICE_Bezier_GetY(T ctrl_x1, T ctrl_x2, T ctrl_x3, T ctrl_y1, T ctrl_y2, T ctrl_y3, T x, double* pt=0) -{ - if (x <= ctrl_x1) - { - if (pt) *pt = 0.0; - return ctrl_y1; - } - if (x >= ctrl_x3) - { - if (pt) *pt = 1.0; - return ctrl_y3; - } - - double t, a = (double) ctrl_x1 - (double) (2 * ctrl_x2) + (double) ctrl_x3; - if (a == 0.0) - { - t=(ctrl_x1 == ctrl_x3) ? 0.0 : (x-ctrl_x1)/(ctrl_x3-ctrl_x1); - } - else - { - t = (double) (ctrl_x2 - ctrl_x1); - t = (-t + sqrt(t * t - a * (ctrl_x1 - x))) / a; - } - const double it = 1.0 - t; - - if (pt) *pt = t; - return (T) (it * it * (double) ctrl_y1 + t * (2.0*it*(double)ctrl_y2 + t * (double) ctrl_y3)); -} - -// Special case for x = y = [0,1] -template -void LICE_Bezier_Norm(T ctrl_x2, T ctrl_y2, double t, T* pX, T* pY) -{ - double b = 2.0 * (1.0 - t) * t; - double c = t * t; - *pX = (T) (b * (double) ctrl_x2 + c); - *pY = (T) (b * (double) ctrl_y2 + c); -} - -// special case for x = y = [0,1]. -template -T LICE_Bezier_GetY_Norm(T ctrl_x2, T ctrl_y2, T x) -{ - if (x < (T) 0.0) { - return (T) 0.0; - } - if (x >= (T) 1.0) { - return (T) 1.0; - } - if (ctrl_x2 == (T) 0.5) { // linear - return x; - } - - -/* - // this causes ICC 11.0 to produce bad results on OSX/386 - double b = (double) (2 * ctrl_x2); - double a = 1.0 - b; - double c = (double) -x; - double t = (-b + sqrt(b * b - 4.0 * a * c)) / (2.0 * a); - - b = 2.0 * (1.0 - t) * t; - c = t * t; - return (T) (b * (double) ctrl_y2 + c); - - // the simplified math below works properly -*/ - - - const double t = (-ctrl_x2 + sqrt(ctrl_x2 * (ctrl_x2 - 2.0*x) + x)) / (1.0-2.0*ctrl_x2); - - return (T) (((2.0 * (1.0-t)) * ctrl_y2 + t)*t); -} - -// Finds the cardinal bezier control points surrounding x2. -// Cubic bezier over (x1,x1b,x2a,x2), (y1,y1b,y2a,y2) or -// quadratic bezier over (x1,x1b,mid(x1b,x2a)), (y1,y1b,mid(y1b,y2a)) -// will smoothly interpolate between (x1,y1) and (x2,y2) while preserving all existing values. -// The lower alpha is, the more tame the bezier curve will be (0.25 = subtle). -template -void LICE_Bezier_FindCardinalCtlPts(double alpha, T x1, T x2, T x3, T y1, T y2, T y3, - T* ctrl_x2a, T* ctrl_x2b, T* ctrl_y2a, T* ctrl_y2b) -{ - double dxa = alpha * (double) (x2 - x1); - double dxb = alpha * (double) (x3 - x2); - if (ctrl_x2a) *ctrl_x2a = x2 - (T) dxa; - if (ctrl_x2b) *ctrl_x2b = x2 + (T) dxb; - - if (x1 == x3) - { - if (ctrl_y2a) *ctrl_y2a = y2; - if (ctrl_y2b) *ctrl_y2b = y2; - } - else - { - double m = (double) (y3 - y1) / (double) (x3 - x1); - if (ctrl_y2a) *ctrl_y2a = y2 - (T) (m * dxa); - if (ctrl_y2b) *ctrl_y2b = y2 + (T) (m * dxb); - } -} - -// Basic quadratic nurbs. Given a set of n (x,y) pairs, -// populate pDest with the unit-spaced nurbs curve. -// pDest must be passed in with size (int) (*(pX+n-1) - *pX). -// pX must be monotonically increasing and no duplicates. -template -inline void LICE_QNurbs(T* pDest, int pDest_sz, int *pX, T* pY, int n, bool hit_each_point=false) -{ - int x1 = *pX++, x2 = *pX++; - T y1 = *pY++, y2 = *pY++; - double xm1, xm2 = 0.5 * (x1 + x2); - double ym1, ym2 = 0.5 * (y1 + y2); - - double yi = y1, m = (y2 - y1) / (double) (x2 - x1); - int xi = x1, iend = (int)floor(xm2+0.5); // this (and below) was previously ceil(), but can't see any reason why it should matter (this should be more correct, I'd imagine) - for (; xi < iend; xi++, yi += m) - { - if (--pDest_sz<0) return; - *pDest++ = (T) yi; - } - - for (int i = 2; i < n; ++i) - { - x1 = x2; - x2 = *pX++; - y1 = y2; - y2 = *pY++; - - xm1 = xm2; - xm2 = 0.5 * (x1 + x2); - ym1 = ym2; - ym2 = 0.5 * (y1 + y2); - - iend = (int)floor(xm2+0.5); - if (ym1 == ym2 && y1 == ym1) - { - for (; xi < iend; xi++) - { - if (--pDest_sz<0) return; - *pDest++ = (T) y1; - } - } - else - { - double y1u = y1; - if (hit_each_point) - { - // y1 = LICE_Bezier_GetY(0,0.5,1.0, ym1,y1u,ym2,0.5), this is the inverse - y1u = 2.0 * y1 - 0.5 * (ym1 + ym2); - } - for (; xi < iend; xi++) - { - if (--pDest_sz<0) return; - *pDest++ = (T) LICE_Bezier_GetY(xm1, (double)x1, xm2, ym1, (double)y1u, ym2, (double)xi); - } - } - } - - m = (y2 - y1) / (double) (x2 - x1); - yi = ym2; - for (; xi < x2; xi++, yi += m) - { - if (--pDest_sz<0) return; - *pDest++ = (T) yi; - } -} - -#define CBEZ_ITERS 8 - -#define EVAL_CBEZ(tx,a,b,c,d,t) \ -{ \ - double _t2=t*t; \ - tx=(a*t*_t2+b*_t2+c*t+d); \ -} - -#define EVAL_CBEZXY(tx, ty, ax, bx, cx, dx, ay, by, cy, dy, t) \ -{ \ - double _t2=t*t; \ - double _t3=t*_t2; \ - tx=ax*_t3+bx*_t2+cx*t+dx; \ - ty=ay*_t3+by*_t2+cy*t+dy; \ -} - -template -T LICE_CBezier_GetY(T ctrl_x1, T ctrl_x2, T ctrl_x3, T ctrl_x4, - T ctrl_y1, T ctrl_y2, T ctrl_y3, T ctrl_y4, T x, - T* pNextX = 0, T* pdYdX = 0, double* ptLo = 0, double* ptHi = 0) -{ - if (x < ctrl_x1) - { - if (pNextX) *pNextX = ctrl_x1; - if (pdYdX) *pdYdX = (T) 0.0; - return ctrl_y1; - } - if (x >= ctrl_x4) - { - if (pNextX) *pNextX = ctrl_x4; - if (pdYdX) *pdYdX = (T) 0.0; - return ctrl_y4; - } - - double ax, bx, cx, ay, by, cy; - LICE_CBezier_GetCoeffs(ctrl_x1, ctrl_x2, ctrl_x3, ctrl_x4, - ctrl_y1, ctrl_y2, ctrl_y3, ctrl_y4, - &ax, &bx, &cx, &ay, &by, &cy); - - double tx, t, tLo = 0.0, tHi = 1.0; - double xLo=0.0, xHi=0.0, yLo, yHi; - int i; - for (i = 0; i < CBEZ_ITERS; ++i) - { - t = 0.5 * (tLo + tHi); - EVAL_CBEZ(tx, ax, bx, cx, (double) ctrl_x1, t); - if (tx < (double) x) - { - tLo = t; - xLo = tx; - } - else if (tx > (double) x) - { - tHi = t; - xHi = tx; - } - else - { - tLo = t; - xLo = tx; - tHi = t + 1.0/pow(2.0,CBEZ_ITERS); - if (tHi > 1.0) tHi = 1.0; // floating point error - EVAL_CBEZ(xHi, ax, bx, cx, (double) ctrl_x1, tHi); - break; - } - } - - if (tLo == 0.0) EVAL_CBEZ(xLo, ax, bx, cx, (double) ctrl_x1, 0.0); - if (tHi == 1.0) EVAL_CBEZ(xHi, ax, bx, cx, (double) ctrl_x1, 1.0); - - EVAL_CBEZ(yLo, ay, by, cy, (double) ctrl_y1, tLo); - EVAL_CBEZ(yHi, ay, by, cy, (double) ctrl_y1, tHi); - - double dYdX = (xLo == xHi ? 0.0 : (yHi - yLo) / (xHi - xLo)); - double y = yLo + ((double) x - xLo) * dYdX; - - if (pNextX) *pNextX = (T) xHi; - if (pdYdX) *pdYdX = (T) dYdX; - - if (ptLo) *ptLo = tLo; - if (ptHi) *ptHi = tHi; - - return (T) y; -} - -#endif - diff --git a/oversampling/WDL/lice/lice_bmp.cpp b/oversampling/WDL/lice/lice_bmp.cpp deleted file mode 100644 index 3f2842d..0000000 --- a/oversampling/WDL/lice/lice_bmp.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - Cockos WDL - LICE - Lightweight Image Compositing Engine - Copyright (C) 2007 and later, Cockos Incorporated - File: lice_bmp.cpp (BMP loading for LICE) - See lice.h for license and other information -*/ - -#ifndef WDL_NO_DEFINE_MINMAX -#define WDL_NO_DEFINE_MINMAX -#endif -#include "lice.h" -#include "../wdltypes.h" -#ifndef _WIN32 -#include "../swell/swell.h" -#endif - -static LICE_IBitmap *hbmToBit(HBITMAP hbm, LICE_IBitmap *bmp) -{ - BITMAP bm; - GetObject(hbm, sizeof(BITMAP), (LPSTR)&bm); - - LICE_SysBitmap sysbitmap(bm.bmWidth,bm.bmHeight); - -#ifdef _WIN32 - HDC hdc=CreateCompatibleDC(NULL); - HGDIOBJ oldBM=SelectObject(hdc,hbm); - - BitBlt(sysbitmap.getDC(),0,0,bm.bmWidth,bm.bmHeight,hdc,0,0,SRCCOPY); - GdiFlush(); - - if (!bmp) bmp=new WDL_NEW LICE_MemBitmap(bm.bmWidth,bm.bmHeight); - LICE_Copy(bmp,&sysbitmap); - - SelectObject(hdc,oldBM); - DeleteDC(hdc); - #else - LICE_Clear(&sysbitmap,0); - RECT r={0,0,bm.bmWidth,bm.bmHeight}; - DrawImageInRect(sysbitmap.getDC(),hbm,&r); - if (!bmp) bmp=new WDL_NEW LICE_MemBitmap(bm.bmWidth,bm.bmHeight); - LICE_Copy(bmp,&sysbitmap); - #endif - - if (bmp) LICE_FillRect(bmp,0,0,bmp->getWidth(),bmp->getHeight(),LICE_RGBA(0,0,0,255),1.0f,LICE_BLIT_MODE_ADD); - - return bmp; -} - - -LICE_IBitmap *LICE_LoadBMP(const char *filename, LICE_IBitmap *bmp) // returns a bitmap (bmp if nonzero) on success -{ - HBITMAP bm=NULL; -#ifdef _WIN32 -#ifndef WDL_NO_SUPPORT_UTF8 - #ifdef WDL_SUPPORT_WIN9X - if (GetVersion()<0x80000000) - #endif - { - WCHAR wf[2048]; - if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,filename,-1,wf,2048)) - bm = (HBITMAP) LoadImageW(NULL,wf,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE); - } -#endif - - if (!bm) bm=(HBITMAP) LoadImage(NULL,filename,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE); -#else - bm=(HBITMAP) LoadNamedImage(filename,false); -#endif - if (!bm) return 0; - - LICE_IBitmap *ret=hbmToBit(bm,bmp); - - DeleteObject(bm); - return ret; -} - -#ifdef _WIN32 -LICE_IBitmap *LICE_LoadBMPFromResource(HINSTANCE hInst, const char *resid, LICE_IBitmap *bmp) // returns a bitmap (bmp if nonzero) on success -{ - HBITMAP bm=(HBITMAP) LoadImage(hInst,resid,IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION); - if (!bm) return 0; - - LICE_IBitmap *ret=hbmToBit(bm,bmp); - - DeleteObject(bm); - return ret; -} -#endif - - - -class LICE_BMPLoader -{ -public: - _LICE_ImageLoader_rec rec; - LICE_BMPLoader() - { - rec.loadfunc = loadfunc; - rec.get_extlist = get_extlist; - rec._next = LICE_ImageLoader_list; - LICE_ImageLoader_list = &rec; - } - - static LICE_IBitmap *loadfunc(const char *filename, bool checkFileName, LICE_IBitmap *bmpbase) - { - if (checkFileName) - { - const char *p=filename; - while (*p)p++; - while (p>filename && *p != '\\' && *p != '/' && *p != '.') p--; - if (stricmp(p,".bmp")) return 0; - } - return LICE_LoadBMP(filename,bmpbase); - } - static const char *get_extlist() - { - return "BMP files (*.BMP)\0*.BMP\0"; - } - -}; - -LICE_BMPLoader LICE_bmpldr; diff --git a/oversampling/WDL/lice/lice_colorspace.cpp b/oversampling/WDL/lice/lice_colorspace.cpp deleted file mode 100644 index f8acb0d..0000000 --- a/oversampling/WDL/lice/lice_colorspace.cpp +++ /dev/null @@ -1,151 +0,0 @@ -#ifndef WDL_NO_DEFINE_MINMAX -#define WDL_NO_DEFINE_MINMAX -#endif -#include "lice.h" -#include - -#define LICE_COMBINE_IMPLEMENT_HSV -#include "lice_combine.h" - - -LICE_pixel LICE_AlterColorHSV_int(LICE_pixel color, int dH, int dS, int dV) // H is rolled over [0,384), S and V are clamped [0,255) -{ - int h, s, v; - LICE_RGB2HSV(LICE_GETR(color), LICE_GETG(color), LICE_GETB(color), &h, &s, &v); - - h += dH; - s += dS; - v += dV; - - if (h < 0) h += 384; - else if (h >= 384) h -= 384; - - if (s & ~255) - { - if (s<0) s = 0; - else s = 255; - } - - if (v&~255) - { - if (v < 0) v = 0.; - else v = 255; - } - - return LICE_HSV2Pix(h, s, v, LICE_GETA(color)); -} - -LICE_pixel LICE_AlterColorHSV(LICE_pixel color, float dH, float dS, float dV) // H is rolled over, S and V are clamped, all [0,1) -{ - int dHi = (int)(dH*384.0f); - int dSi = (int)(dS*255.0f); - int dVi = (int)(dV*255.0f); - return LICE_AlterColorHSV_int(color, dHi, dSi, dVi); -} - -void LICE_AlterBitmapHSV(LICE_IBitmap* src, float dH, float dS, float dV) // H is rolled over, S and V are clamped -{ - if (src) LICE_AlterRectHSV(src,0,0,src->getWidth(),src->getHeight(),dH,dS,dV); -} - -void LICE_AlterRectHSV(LICE_IBitmap* src, int xpos, int ypos, int w, int h, float dH, float dS, float dV, int mode) // H is rolled over, S and V are clamped -{ - if (!src) return; - - int destbm_w = src->getWidth(), destbm_h = src->getHeight(); - const int __sc = (int)src->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - __LICE_SCU(destbm_w); - __LICE_SCU(destbm_h); - if (!(mode & LICE_BLIT_IGNORE_SCALING)) - { - __LICE_SC(w); - __LICE_SC(h); - __LICE_SC(xpos); - __LICE_SC(ypos); - } - } - - if (xpos < 0) { - w += xpos; - xpos = 0; - } - if (ypos < 0) { - h += ypos; - ypos = 0; - } - - const int span = src->getRowSpan(); - if (span < 1 || w < 1 || h < 1 || xpos >= destbm_w || ypos >= destbm_h) return; - - if (w > destbm_w - xpos) w = destbm_w - xpos; - if (h > destbm_h - ypos) h = destbm_h - ypos; - - LICE_pixel* px = src->getBits()+ypos*span+xpos; - - int dHi = (int)(dH*384.0f); - int dSi = (int)(dS*255.0f); - int dVi = (int)(dV*255.0f); - if (dHi > 383) dHi=383; - else if (dHi < -383) dHi=-383; - - - if (!dHi && !dSi && !dVi) return; // no mod - - if (w*h > 8192) - { - // generate a table of HSV translations with clip/clamp - unsigned char stab[256], vtab[256]; - short htab[384]; - int x; - for(x=0;x<256;x++) - { - int a=x+dSi; - if(a<0)a=0; else if (a>255)a=255; - stab[x]=a; - - a=x+dVi; - if(a<0)a=0; else if (a>255)a=255; - vtab[x]=a; - - a=x+dHi; - if(a<0)a+=384; else if (a>=384)a-=384; - htab[x]=a; - } - for(;x<384;x++) - { - int a=x+dHi; - if(a<0)a+=384; else if (a>=384)a-=384; - htab[x]=a; - } - - while (h-->0) - { - LICE_pixel* tpx = px; - px+=span; - int xi=w; - while (xi-->0) - { - LICE_pixel color = *tpx; - int hh,s,v; - LICE_RGB2HSV(LICE_GETR(color), LICE_GETG(color), LICE_GETB(color), &hh, &s, &v); - *tpx++ = LICE_HSV2Pix(htab[hh],stab[s],vtab[v],LICE_GETA(color)); - } - } - } - else - { - while (h-->0) - { - LICE_pixel* tpx = px; - px+=span; - int xi=w; - while (xi-->0) - { - *tpx = LICE_AlterColorHSV_int(*tpx, dHi, dSi, dVi); - tpx++; - } - } - } -} diff --git a/oversampling/WDL/lice/lice_combine.h b/oversampling/WDL/lice/lice_combine.h deleted file mode 100644 index 6b355e8..0000000 --- a/oversampling/WDL/lice/lice_combine.h +++ /dev/null @@ -1,846 +0,0 @@ -#ifndef _LICE_COMBINE_H_ -#define _LICE_COMBINE_H_ - -#include "../wdltypes.h" - -#if defined(_MSC_VER) -#pragma warning(disable:4244) // float-to-int -#endif - -#define __LICE_BOUND(x,lo,hi) ((x)<(lo)?(lo):((x)>(hi)?(hi):(x))) - - -#define LICE_PIXEL_HALF(x) (((x)>>1)&0x7F7F7F7F) -#define LICE_PIXEL_QUARTER(x) (((x)>>2)&0x3F3F3F3F) -#define LICE_PIXEL_EIGHTH(x) (((x)>>3)&0x1F1F1F1F) - - -static inline void __LICE_BilinearFilterI(int *r, int *g, int *b, int *a, const LICE_pixel_chan *pin, const LICE_pixel_chan *pinnext, unsigned int xfrac, unsigned int yfrac) -{ - const unsigned int f4=(xfrac*yfrac)>>16; - const unsigned int f3=yfrac-f4; // (1.0-xfrac)*yfrac; - const unsigned int f2=xfrac-f4; // xfrac*(1.0-yfrac); - const unsigned int f1=65536-yfrac-xfrac+f4; // (1.0-xfrac)*(1.0-yfrac); - #define DOCHAN(output, inchan) \ - (output)=(pin[(inchan)]*f1 + pin[4+(inchan)]*f2 + pinnext[(inchan)]*f3 + pinnext[4+(inchan)]*f4)>>16; - DOCHAN(*r,LICE_PIXEL_R) - DOCHAN(*g,LICE_PIXEL_G) - DOCHAN(*b,LICE_PIXEL_B) - DOCHAN(*a,LICE_PIXEL_A) - #undef DOCHAN -} - -static inline void __LICE_BilinearFilterIPixOut(LICE_pixel_chan *out, const LICE_pixel_chan *pin, const LICE_pixel_chan *pinnext, unsigned int xfrac, unsigned int yfrac) -{ - const unsigned int f4=(xfrac*yfrac)>>16; - const unsigned int f3=yfrac-f4; // (1.0-xfrac)*yfrac; - const unsigned int f2=xfrac-f4; // xfrac*(1.0-yfrac); - const unsigned int f1=65536-yfrac-xfrac+f4; // (1.0-xfrac)*(1.0-yfrac); - #define DOCHAN(inchan) \ - (out[inchan])=(pin[(inchan)]*f1 + pin[4+(inchan)]*f2 + pinnext[(inchan)]*f3 + pinnext[4+(inchan)]*f4)>>16; - DOCHAN(LICE_PIXEL_R) - DOCHAN(LICE_PIXEL_G) - DOCHAN(LICE_PIXEL_B) - DOCHAN(LICE_PIXEL_A) - #undef DOCHAN -} - - -static inline void __LICE_BilinearFilterI_2(int *r, int *g, int *b, int *a, const LICE_pixel_chan *pin, const LICE_pixel_chan *pinnext, int npoffs, unsigned int xfrac, unsigned int yfrac) -{ - const unsigned int f4=(xfrac*yfrac)>>16; - const unsigned int f3=yfrac-f4; // (1.0-xfrac)*yfrac; - const unsigned int f2=xfrac-f4; // xfrac*(1.0-yfrac); - const unsigned int f1=65536-yfrac-xfrac+f4; // (1.0-xfrac)*(1.0-yfrac); - *r=(pin[LICE_PIXEL_R]*f1 + pin[npoffs+LICE_PIXEL_R]*f2 + pinnext[LICE_PIXEL_R]*f3 + pinnext[npoffs+LICE_PIXEL_R]*f4)>>16; - *g=(pin[LICE_PIXEL_G]*f1 + pin[npoffs+LICE_PIXEL_G]*f2 + pinnext[LICE_PIXEL_G]*f3 + pinnext[npoffs+LICE_PIXEL_G]*f4)>>16; - *b=(pin[LICE_PIXEL_B]*f1 + pin[npoffs+LICE_PIXEL_B]*f2 + pinnext[LICE_PIXEL_B]*f3 + pinnext[npoffs+LICE_PIXEL_B]*f4)>>16; - *a=(pin[LICE_PIXEL_A]*f1 + pin[npoffs+LICE_PIXEL_A]*f2 + pinnext[LICE_PIXEL_A]*f3 + pinnext[npoffs+LICE_PIXEL_A]*f4)>>16; -} - - -static inline void __LICE_LinearFilterI(int *r, int *g, int *b, int *a, const LICE_pixel_chan *pin, const LICE_pixel_chan *pinnext, unsigned int frac) -{ - const unsigned int f=65536-frac; - *r=(pin[LICE_PIXEL_R]*f + pinnext[LICE_PIXEL_R]*frac)>>16; - *g=(pin[LICE_PIXEL_G]*f + pinnext[LICE_PIXEL_G]*frac)>>16; - *b=(pin[LICE_PIXEL_B]*f + pinnext[LICE_PIXEL_B]*frac)>>16; - *a=(pin[LICE_PIXEL_A]*f + pinnext[LICE_PIXEL_A]*frac)>>16; -} -static inline void __LICE_LinearFilterIPixOut(LICE_pixel_chan *out, const LICE_pixel_chan *pin, const LICE_pixel_chan *pinnext, unsigned int frac) -{ - const unsigned int f=65536-frac; - out[LICE_PIXEL_R]=(pin[LICE_PIXEL_R]*f + pinnext[LICE_PIXEL_R]*frac)>>16; - out[LICE_PIXEL_G]=(pin[LICE_PIXEL_G]*f + pinnext[LICE_PIXEL_G]*frac)>>16; - out[LICE_PIXEL_B]=(pin[LICE_PIXEL_B]*f + pinnext[LICE_PIXEL_B]*frac)>>16; - out[LICE_PIXEL_A]=(pin[LICE_PIXEL_A]*f + pinnext[LICE_PIXEL_A]*frac)>>16; -} - -static void inline _LICE_MakePixelClamp(LICE_pixel_chan *out, int r, int g, int b, int a) -{ -#define LICE_PIX_MAKECHAN(a,b) out[a] = (b&~0xff) ? (b<0?0:255) : b; - LICE_PIX_MAKECHAN(LICE_PIXEL_B,b) - LICE_PIX_MAKECHAN(LICE_PIXEL_G,g) - LICE_PIX_MAKECHAN(LICE_PIXEL_R,r) - LICE_PIX_MAKECHAN(LICE_PIXEL_A,a) -#undef LICE_PIX_MAKECHAN -} - -static void inline _LICE_MakePixelNoClamp(LICE_pixel_chan *out, LICE_pixel_chan r, LICE_pixel_chan g, LICE_pixel_chan b, LICE_pixel_chan a) -{ -#define LICE_PIX_MAKECHAN(a,b) out[a] = b; - LICE_PIX_MAKECHAN(LICE_PIXEL_B,b) - LICE_PIX_MAKECHAN(LICE_PIXEL_G,g) - LICE_PIX_MAKECHAN(LICE_PIXEL_R,r) - LICE_PIX_MAKECHAN(LICE_PIXEL_A,a) -#undef LICE_PIX_MAKECHAN -} - - - -#define HSV_P v*(256-s)/256 -#define HSV_Q(hval) v*(16384-(hval)*s)/16384 -#define HSV_T(hval) v*(16384-(64-(hval))*s)/16384 -#define HSV_X v -extern unsigned short _LICE_RGB2HSV_invtab[256]; // 65536/idx - 1 - -#ifdef LICE_COMBINE_IMPLEMENT_HSV - LICE_pixel LICE_HSV2Pix(int h, int s, int v, int alpha) - #define __LICE_HSV2Pix LICE_HSV2Pix -#else - static inline LICE_pixel __LICE_HSV2Pix(int h, int s, int v, int alpha) -#endif -{ - if (h<192) - { - if (h<64) return LICE_RGBA(HSV_X,HSV_T(h),HSV_P,alpha); - if (h<128) return LICE_RGBA(HSV_Q(h-64),HSV_X,HSV_P,alpha); - return LICE_RGBA(HSV_P,HSV_X,HSV_T(h-128),alpha); - } - if (h < 256) return LICE_RGBA(HSV_P,HSV_Q(h-192),HSV_X,alpha); - if (h < 320) return LICE_RGBA(HSV_T(h-256),HSV_P,HSV_X,alpha); - return LICE_RGBA(HSV_X,HSV_P,HSV_Q(h-320),alpha); -} - -#ifdef LICE_COMBINE_IMPLEMENT_HSV -void LICE_HSV2RGB(int h, int s, int v, int* r, int* g, int* b) -#define __LICE_HSV2RGB LICE_HSV2RGB -#else -static inline void __LICE_HSV2RGB(int h, int s, int v, int* r, int* g, int* b) -#endif -{ - if (h<192) - { - if (h<64) - { - *r = HSV_X; *g = HSV_T(h); *b = HSV_P; - } - else if (h<128) - { - *r = HSV_Q(h-64); *g = HSV_X; *b = HSV_P; - } - else - { - *r = HSV_P; *g = HSV_X; *b = HSV_T(h-128); - } - } - else - { - if (h < 256) - { - *r = HSV_P; *g = HSV_Q(h-192); *b = HSV_X; - } - else if (h < 320) - { - *r = HSV_T(h-256); *g = HSV_P; *b = HSV_X; - } - else - { - *r = HSV_X; *g = HSV_P; *b = HSV_Q(h-320); - } - } -} - - -#define LICE_RGB2HSV_USE_TABLE -// h = [0,384), s and v = [0,256) - -#ifdef LICE_COMBINE_IMPLEMENT_HSV - void LICE_RGB2HSV(int r, int g, int b, int* h, int* s, int* v) - #define __LICE_RGB2HSV LICE_RGB2HSV -#else - static inline void __LICE_RGB2HSV(int r, int g, int b, int* h, int* s, int* v) -#endif -{ - - // this makes it just 3 conditional branches per call - int df,d,maxrgb; - int degoffs; - if (g > r) - { - if (g>b) // green max - { - maxrgb=g; - degoffs=128; - df = maxrgb - lice_min(b,r); - d=b-r; - } - else // blue max - { - maxrgb=b; - degoffs=256; - df = maxrgb - lice_min(g,r); - d=r-g; - } - } - else // r >= g - { - if (r > b) // red max - { - maxrgb=r; - - if (g>1, - (dest[LICE_PIXEL_G]+g)>>1, - (dest[LICE_PIXEL_B]+b)>>1, - (dest[LICE_PIXEL_A]+a)>>1); - } -}; - -class _LICE_CombinePixelsHalfMixFAST -{ -public: - static inline void doPixFAST(LICE_pixel *dest, LICE_pixel src) // src is full range - { - *dest = ((*dest>>1) &0x7f7f7f7f) + ((src>>1)&0x7f7f7f7f); - } -}; - -class _LICE_CombinePixelsHalfMixClamp -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - _LICE_MakePixelClamp(dest, - (dest[LICE_PIXEL_R]+r)>>1, - (dest[LICE_PIXEL_G]+g)>>1, - (dest[LICE_PIXEL_B]+b)>>1, - (dest[LICE_PIXEL_A]+a)>>1); - } - -}; - - -class _LICE_CombinePixelsHalfMix2FAST -{ -public: - static inline void doPixFAST(LICE_pixel *dest, LICE_pixel src) // src is pre-halfed and masked - { - *dest = ((*dest>>1) &0x7f7f7f7f) + src; - } -}; - -class _LICE_CombinePixelsQuarterMix2FAST -{ -public: - static inline void doPixFAST(LICE_pixel *dest, LICE_pixel src) // src is pre-quartered and masked - { - LICE_pixel tmp = *dest; - *dest = ((tmp>>1) &0x7f7f7f7f) + ((tmp>>2) &0x3f3f3f3f) + src; - } -}; - -class _LICE_CombinePixelsThreeEighthMix2FAST -{ -public: - static inline void doPixFAST(LICE_pixel *dest, LICE_pixel src) // src is pre-three-eighthed and masked - { - LICE_pixel tmp = *dest; - *dest = ((tmp>>1) &0x7f7f7f7f) + ((tmp>>3) &0x1f1f1f1f) + src; - } -}; - -class _LICE_CombinePixelsThreeQuarterMix2FAST -{ -public: - static inline void doPixFAST(LICE_pixel *dest, LICE_pixel src) // src is pre-three-quartered and masked - { - *dest = ((*dest>>2) &0x3f3f3f3f) + src; - } -}; - -class _LICE_CombinePixelsCopyNoClamp -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - const int sc=(256-alpha); - - // don't check alpha=0 here, since the caller should (since alpha is usually used for static alphas) - _LICE_MakePixelNoClamp(dest, - r + ((dest[LICE_PIXEL_R]-r)*sc)/256, - g + ((dest[LICE_PIXEL_G]-g)*sc)/256, - b + ((dest[LICE_PIXEL_B]-b)*sc)/256, - a + ((dest[LICE_PIXEL_A]-a)*sc)/256); - } -}; - -class _LICE_CombinePixelsCopyClamp -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - const int sc=(256-alpha); - - // don't check alpha=0 here, since the caller should (since alpha is usually used for static alphas) - _LICE_MakePixelClamp(dest, - r + ((dest[LICE_PIXEL_R]-r)*sc)/256, - g + ((dest[LICE_PIXEL_G]-g)*sc)/256, - b + ((dest[LICE_PIXEL_B]-b)*sc)/256, - a + ((dest[LICE_PIXEL_A]-a)*sc)/256); - } -}; - -class _LICE_CombinePixelsCopySourceAlphaNoClamp -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - if (a) - { - const int sc2=(alpha*(a+1))/256; - const int sc = 256 - sc2; - - _LICE_MakePixelNoClamp(dest, - r + ((dest[LICE_PIXEL_R]-r)*sc)/256, - g + ((dest[LICE_PIXEL_G]-g)*sc)/256, - b + ((dest[LICE_PIXEL_B]-b)*sc)/256, - lice_min(255,sc2 + dest[LICE_PIXEL_A])); - } - } -}; - -class _LICE_CombinePixelsCopySourceAlphaClamp -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - if (a) - { - const int sc2=(alpha*(a+1))/256; - const int sc = 256 - sc2; - - _LICE_MakePixelClamp(dest, - r + ((dest[LICE_PIXEL_R]-r)*sc)/256, - g + ((dest[LICE_PIXEL_G]-g)*sc)/256, - b + ((dest[LICE_PIXEL_B]-b)*sc)/256, - sc2 + dest[LICE_PIXEL_A]); - } - } -}; -class _LICE_CombinePixelsCopySourceAlphaIgnoreAlphaParmNoClamp -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - if (a) - { - if (a==255) - { - _LICE_MakePixelNoClamp(dest,r,g,b,a); - } - else - { - const int sc=(255-a); - - _LICE_MakePixelNoClamp(dest, - r + ((dest[LICE_PIXEL_R]-r)*sc)/256, - g + ((dest[LICE_PIXEL_G]-g)*sc)/256, - b + ((dest[LICE_PIXEL_B]-b)*sc)/256, - lice_min(255,a + dest[LICE_PIXEL_A])); - } - } - } -}; -class _LICE_CombinePixelsCopySourceAlphaIgnoreAlphaParmClamp -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - if (a) - { - if (a==255) - { - _LICE_MakePixelClamp(dest,r,g,b,a); - } - else - { - const int sc=(255-a); - - _LICE_MakePixelClamp(dest, - r + ((dest[LICE_PIXEL_R]-r)*sc)/256, - g + ((dest[LICE_PIXEL_G]-g)*sc)/256, - b + ((dest[LICE_PIXEL_B]-b)*sc)/256, - a + dest[LICE_PIXEL_A]); - } - } - } -}; - -#ifndef LICE_DISABLE_BLEND_ADD - -class _LICE_CombinePixelsAdd -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - // don't check alpha=0 here, since the caller should (since alpha is usually used for static alphas) - - _LICE_MakePixelClamp(dest, - dest[LICE_PIXEL_R]+(r*alpha)/256, - dest[LICE_PIXEL_G]+(g*alpha)/256, - dest[LICE_PIXEL_B]+(b*alpha)/256, - dest[LICE_PIXEL_A]+(a*alpha)/256); - - } -}; -class _LICE_CombinePixelsAddSourceAlpha -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - if (a) - { - alpha=(alpha*(a+1))/256; - _LICE_MakePixelClamp(dest, - dest[LICE_PIXEL_R]+(r*alpha)/256, - dest[LICE_PIXEL_G]+(g*alpha)/256, - dest[LICE_PIXEL_B]+(b*alpha)/256, - dest[LICE_PIXEL_A]+(a*alpha)/256); - } - } -}; - -#else // !LICE_DISABLE_BLEND_ADD -#define _LICE_CombinePixelsAddSourceAlpha _LICE_CombinePixelsCopySourceAlphaClamp -#define _LICE_CombinePixelsAdd _LICE_CombinePixelsCopyClamp -#endif - -#ifndef LICE_DISABLE_BLEND_DODGE - -class _LICE_CombinePixelsColorDodge -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - const int src_r = 256-r*alpha/256; - const int src_g = 256-g*alpha/256; - const int src_b = 256-b*alpha/256; - const int src_a = 256-a*alpha/256; - - _LICE_MakePixelClamp(dest, - src_r > 1 ? 256*dest[LICE_PIXEL_R] / src_r : 256*dest[LICE_PIXEL_R], - src_g > 1 ? 256*dest[LICE_PIXEL_G] / src_g : 256*dest[LICE_PIXEL_G], - src_b > 1 ? 256*dest[LICE_PIXEL_B] / src_b : 256*dest[LICE_PIXEL_B], - src_a > 1 ? 256*dest[LICE_PIXEL_A] / src_a : 256*dest[LICE_PIXEL_A]); - } -}; - -class _LICE_CombinePixelsColorDodgeSourceAlpha -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - const int ualpha=(alpha*(a+1))/256; - - const int src_r = 256-r*ualpha/256; - const int src_g = 256-g*ualpha/256; - const int src_b = 256-b*ualpha/256; - const int src_a = 256-a*ualpha/256; - - _LICE_MakePixelClamp(dest, - src_r > 1 ? 256*dest[LICE_PIXEL_R] / src_r : 256*dest[LICE_PIXEL_R], - src_g > 1 ? 256*dest[LICE_PIXEL_G] / src_g : 256*dest[LICE_PIXEL_G], - src_b > 1 ? 256*dest[LICE_PIXEL_B] / src_b : 256*dest[LICE_PIXEL_B], - src_a > 1 ? 256*dest[LICE_PIXEL_A] / src_a : 256*dest[LICE_PIXEL_A]); - } -}; - -#else // !LICE_DISABLE_BLEND_DODGE -#define _LICE_CombinePixelsColorDodgeSourceAlpha _LICE_CombinePixelsCopySourceAlphaClamp -#define _LICE_CombinePixelsColorDodge _LICE_CombinePixelsCopyClamp -#endif - - -#ifndef LICE_DISABLE_BLEND_MUL - -class _LICE_CombinePixelsMulNoClamp -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - // we could check alpha=0 here, but the caller should (since alpha is usually used for static alphas) - - const int da=(256-alpha)*256; - _LICE_MakePixelNoClamp(dest, - (dest[LICE_PIXEL_R]*(da + (r*alpha)))>>16, - (dest[LICE_PIXEL_G]*(da + (g*alpha)))>>16, - (dest[LICE_PIXEL_B]*(da + (b*alpha)))>>16, - (dest[LICE_PIXEL_A]*(da + (a*alpha)))>>16); - - } -}; -class _LICE_CombinePixelsMulClamp -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - // we could check alpha=0 here, but the caller should (since alpha is usually used for static alphas) - - const int da=(256-alpha)*256; - _LICE_MakePixelClamp(dest, - (dest[LICE_PIXEL_R]*(da + (r*alpha)))>>16, - (dest[LICE_PIXEL_G]*(da + (g*alpha)))>>16, - (dest[LICE_PIXEL_B]*(da + (b*alpha)))>>16, - (dest[LICE_PIXEL_A]*(da + (a*alpha)))>>16); - - } -}; -class _LICE_CombinePixelsMulSourceAlphaNoClamp -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - if (a) - { - const int ualpha=(alpha*(a+1))/256; - const int da=(256-ualpha)*256; - _LICE_MakePixelNoClamp(dest, - (dest[LICE_PIXEL_R]*(da + (r*ualpha)))>>16, - (dest[LICE_PIXEL_G]*(da + (g*ualpha)))>>16, - (dest[LICE_PIXEL_B]*(da + (b*ualpha)))>>16, - (dest[LICE_PIXEL_A]*(da + (a*ualpha)))>>16); - - } - } -}; -class _LICE_CombinePixelsMulSourceAlphaClamp -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - if (a) - { - const int ualpha=(alpha*(a+1))/256; - const int da=(256-ualpha)*256; - _LICE_MakePixelClamp(dest, - (dest[LICE_PIXEL_R]*(da + (r*ualpha)))>>16, - (dest[LICE_PIXEL_G]*(da + (g*ualpha)))>>16, - (dest[LICE_PIXEL_B]*(da + (b*ualpha)))>>16, - (dest[LICE_PIXEL_A]*(da + (a*ualpha)))>>16); - - } - } -}; - -#else // !LICE_DISABLE_BLEND_MUL -#define _LICE_CombinePixelsMulSourceAlphaNoClamp _LICE_CombinePixelsCopySourceAlphaNoClamp -#define _LICE_CombinePixelsMulSourceAlphaClamp _LICE_CombinePixelsCopySourceAlphaClamp -#define _LICE_CombinePixelsMulNoClamp _LICE_CombinePixelsCopyNoClamp -#define _LICE_CombinePixelsMulClamp _LICE_CombinePixelsCopyClamp -#endif - -//#define LICE_DISABLE_BLEND_OVERLAY -#ifndef LICE_DISABLE_BLEND_OVERLAY - -class _LICE_CombinePixelsOverlay -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - // we could check alpha=0 here, but the caller should (since alpha is usually used for static alphas) - - int destr = dest[LICE_PIXEL_R], destg = dest[LICE_PIXEL_G], destb = dest[LICE_PIXEL_B], desta = dest[LICE_PIXEL_A]; - -#if 0 - int srcr = r*alpha, srcg = g*alpha, srcb = b*alpha, srca = a*alpha; - int da=(256-alpha)*256; - int mr = (destr*(da+srcr))/65536; - int mg = (destg*(da+srcg))/65536; - int mb = (destb*(da+srcb))/65536; - int ma = (desta*(da+srca))/65536; - int sr = 256-(65536-srcr)*(256-destr)/65536; - int sg = 256-(65536-srcg)*(256-destg)/65536; - int sb = 256-(65536-srcb)*(256-destb)/65536; - int sa = 256-(65536-srca)*(256-desta)/65536; - - destr = (destr*sr+(256-destr)*mr)/256; - destg = (destg*sg+(256-destg)*mg)/256; - destb = (destb*sb+(256-destb)*mb)/256; - desta = (desta*sa+(256-desta)*ma)/256; -#else - // can produce slightly diff (+-1) results from above due to rounding - const int da=(256-alpha)*128; - const int srcr = r*alpha+da, srcg = g*alpha+da, srcb = b*alpha+da, srca = a*alpha + da; - destr = ( destr*( (destr*(32768-srcr))/256 + srcr ) ) >> 15; - destg = ( destg*( (destg*(32768-srcg))/256 + srcg ) ) >> 15; - destb = ( destb*( (destb*(32768-srcb))/256 + srcb ) ) >> 15; - desta = ( desta*( (desta*(32768-srca))/256 + srca ) ) >> 15; - -#endif - - _LICE_MakePixelClamp(dest, destr, destg, destb, desta); - } -}; - -class _LICE_CombinePixelsOverlaySourceAlpha -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - _LICE_CombinePixelsOverlay::doPix(dest, r, g, b, a, (alpha*(a+1))/256); - } -}; - -#else // !LICE_DISABLE_BLEND_OVERLAY -#define _LICE_CombinePixelsOverlaySourceAlpha _LICE_CombinePixelsCopySourceAlphaClamp -#define _LICE_CombinePixelsOverlay _LICE_CombinePixelsCopyClamp -#endif - - -//#define LICE_DISABLE_BLEND_HSVADJ -#ifndef LICE_DISABLE_BLEND_HSVADJ - -class _LICE_CombinePixelsHSVAdjust -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - int h,s,v; - __LICE_RGB2HSV(dest[LICE_PIXEL_R],dest[LICE_PIXEL_G],dest[LICE_PIXEL_B],&h,&s,&v); - h+=(((r+r/2) - 192) * alpha)/256; - if (h<0)h+=384; - else if (h>=384) h-=384; - s+=((g-128)*alpha)/128; - if (s&~0xff) - { - if (s<0)s=0; - else s=255; - } - v+=((b-128)*alpha)/128; - if (v&~0xff) - { - if (v<0)v=0; - else v=255; - } - - *(LICE_pixel *)dest = __LICE_HSV2Pix(h,s,v,a); - } -}; - -class _LICE_CombinePixelsHSVAdjustSourceAlpha -{ -public: - static inline void doPix(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha) - { - _LICE_CombinePixelsHSVAdjust::doPix(dest, r, g, b, a, (alpha*(a+1))/256); - } -}; - -#else // !LICE_DISABLE_BLEND_HSVADJ -#define _LICE_CombinePixelsHSVAdjustSourceAlpha _LICE_CombinePixelsCopySourceAlphaClamp -#define _LICE_CombinePixelsHSVAdjust _LICE_CombinePixelsCopyClamp -#endif - -// note: the "clamp" parameter would generally be false, unless you're working with -// input colors that need to be clamped (i.e. if you have a r value of >255 or <0, etc. -// if your input is LICE_pixel only then use false, and it will clamp as needed depending -// on the blend mode.. - -//#define __LICE__ACTION(comb) templateclass::function(parameters) -//__LICE_ACTION_SRCALPHA(mode,alpha,clamp); -//#undef __LICE__ACTION - - -// use this for paths that support LICE_BLIT_USE_ALPHA (source-alpha combining), but -// otherwise have constant alpha -#define __LICE_ACTION_SRCALPHA(mode,ia,clamp) \ - if ((ia)!=0) switch ((mode)&(LICE_BLIT_MODE_MASK|LICE_BLIT_USE_ALPHA)) { \ - case LICE_BLIT_MODE_COPY: if ((ia)>0) { \ - if (clamp) { \ - if ((ia)==256) { __LICE__ACTION(_LICE_CombinePixelsClobberClamp); } \ - else { __LICE__ACTION(_LICE_CombinePixelsCopyClamp); } \ - } else { \ - if ((ia)==256) { __LICE__ACTION(_LICE_CombinePixelsClobberNoClamp); } \ - else { __LICE__ACTION(_LICE_CombinePixelsCopyNoClamp); } \ - } \ - } \ - break; \ - case LICE_BLIT_MODE_ADD: __LICE__ACTION(_LICE_CombinePixelsAdd); break; \ - case LICE_BLIT_MODE_DODGE: __LICE__ACTION(_LICE_CombinePixelsColorDodge); break; \ - case LICE_BLIT_MODE_MUL: \ - if (clamp) { __LICE__ACTION(_LICE_CombinePixelsMulClamp); } \ - else { __LICE__ACTION(_LICE_CombinePixelsMulNoClamp); } \ - break; \ - case LICE_BLIT_MODE_OVERLAY: __LICE__ACTION(_LICE_CombinePixelsOverlay); break; \ - case LICE_BLIT_MODE_HSVADJ: __LICE__ACTION(_LICE_CombinePixelsHSVAdjust); break; \ - case LICE_BLIT_MODE_COPY|LICE_BLIT_USE_ALPHA: \ - if (clamp) { \ - if ((ia)==256) { __LICE__ACTION(_LICE_CombinePixelsCopySourceAlphaIgnoreAlphaParmClamp);} \ - else { __LICE__ACTION(_LICE_CombinePixelsCopySourceAlphaClamp); } \ - } else { \ - if ((ia)==256) { __LICE__ACTION(_LICE_CombinePixelsCopySourceAlphaIgnoreAlphaParmNoClamp); } \ - else { __LICE__ACTION(_LICE_CombinePixelsCopySourceAlphaNoClamp); } \ - } \ - break; \ - case LICE_BLIT_MODE_ADD|LICE_BLIT_USE_ALPHA: \ - __LICE__ACTION(_LICE_CombinePixelsAddSourceAlpha); \ - break; \ - case LICE_BLIT_MODE_DODGE|LICE_BLIT_USE_ALPHA: \ - __LICE__ACTION(_LICE_CombinePixelsColorDodgeSourceAlpha); \ - break; \ - case LICE_BLIT_MODE_MUL|LICE_BLIT_USE_ALPHA: \ - if (clamp) { __LICE__ACTION(_LICE_CombinePixelsMulSourceAlphaClamp); } \ - else { __LICE__ACTION(_LICE_CombinePixelsMulSourceAlphaNoClamp); } \ - break; \ - case LICE_BLIT_MODE_OVERLAY|LICE_BLIT_USE_ALPHA: \ - __LICE__ACTION(_LICE_CombinePixelsOverlaySourceAlpha); \ - break; \ - case LICE_BLIT_MODE_HSVADJ|LICE_BLIT_USE_ALPHA: \ - __LICE__ACTION(_LICE_CombinePixelsHSVAdjustSourceAlpha); \ - break; \ - } - - -// use this for paths that can have per pixel alpha, but calculate it themselves -#define __LICE_ACTION_NOSRCALPHA(mode, ia,clamp) \ - if ((ia)!=0) switch ((mode)&LICE_BLIT_MODE_MASK) { \ - case LICE_BLIT_MODE_COPY: if ((ia)>0) { if (clamp) { __LICE__ACTION(_LICE_CombinePixelsCopyClamp); } else { __LICE__ACTION(_LICE_CombinePixelsCopyNoClamp); } } break; \ - case LICE_BLIT_MODE_ADD: __LICE__ACTION(_LICE_CombinePixelsAdd); break; \ - case LICE_BLIT_MODE_DODGE: __LICE__ACTION(_LICE_CombinePixelsColorDodge); break; \ - case LICE_BLIT_MODE_MUL: if (clamp) { __LICE__ACTION(_LICE_CombinePixelsMulClamp); } else { __LICE__ACTION(_LICE_CombinePixelsMulNoClamp); } break; \ - case LICE_BLIT_MODE_OVERLAY: __LICE__ACTION(_LICE_CombinePixelsOverlay); break; \ - case LICE_BLIT_MODE_HSVADJ: __LICE__ACTION(_LICE_CombinePixelsHSVAdjust); break; \ - } - -// For drawing where there is constant alpha and no per-pixel alpha. -#define __LICE_ACTION_CONSTANTALPHA(mode,ia,clamp) \ - if ((ia)!=0) switch ((mode)&LICE_BLIT_MODE_MASK) { \ - case LICE_BLIT_MODE_COPY: \ - if ((ia)==256) { if (clamp) { __LICE__ACTION(_LICE_CombinePixelsClobberClamp); } else { __LICE__ACTION(_LICE_CombinePixelsClobberNoClamp); } } \ - else if ((ia)==128) { if (clamp) { __LICE__ACTION(_LICE_CombinePixelsHalfMixClamp); } else { __LICE__ACTION(_LICE_CombinePixelsHalfMixNoClamp); } } \ - else if ((ia)>0) { if (clamp) { __LICE__ACTION(_LICE_CombinePixelsCopyClamp); } else { __LICE__ACTION(_LICE_CombinePixelsCopyNoClamp); } } \ - break; \ - case LICE_BLIT_MODE_ADD: __LICE__ACTION(_LICE_CombinePixelsAdd); break; \ - case LICE_BLIT_MODE_DODGE: __LICE__ACTION(_LICE_CombinePixelsColorDodge); break; \ - case LICE_BLIT_MODE_MUL: if (clamp) { __LICE__ACTION(_LICE_CombinePixelsMulClamp); } else { __LICE__ACTION(_LICE_CombinePixelsMulNoClamp); } break; \ - case LICE_BLIT_MODE_OVERLAY: __LICE__ACTION(_LICE_CombinePixelsOverlay); break; \ - case LICE_BLIT_MODE_HSVADJ: __LICE__ACTION(_LICE_CombinePixelsHSVAdjust); break; \ - } - -typedef void (*LICE_COMBINEFUNC)(LICE_pixel_chan *dest, int r, int g, int b, int a, int alpha); - -static void WDL_STATICFUNC_UNUSED __LICE_SC_INTERNAL(int &x, int __sc) { - const WDL_INT64 t = (((WDL_INT64) x*(__sc))/256); - x = (int) wdl_clamp(t, -WDL_INT64_CONST(0x80000000), WDL_INT64_CONST(0x7fffffff)); -} -static void __LICE_SCU_INTERNAL(int &x, int __sc) { - const WDL_UINT64 t = (((WDL_UINT64) x*(__sc))>>8); - x = (unsigned int) wdl_min(t, WDL_UINT64_CONST(0xffffffff)); -} - -#if defined(_WIN32) || (defined(__APPLE__) && !defined(__LP64__)) -static void WDL_STATICFUNC_UNUSED __LICE_SC_INTERNAL(LONG &x, int __sc) { - const WDL_INT64 t = (((WDL_INT64) x*(__sc))/256); - x = (LONG) wdl_clamp(t, -WDL_INT64_CONST(0x80000000), WDL_INT64_CONST(0x7fffffff)); -} -#endif - -static void WDL_STATICFUNC_UNUSED __LICE_SC_INTERNAL(float &x, int __sc) { x = (float) (((double)x * __sc) / 256.0); } -static void WDL_STATICFUNC_UNUSED __LICE_SC_INTERNAL(double &x, int __sc) { x = (x * __sc) / 256.0; } - -#define __LICE_SC(x) __LICE_SC_INTERNAL(x,__sc) -#define __LICE_SCU(x) __LICE_SCU_INTERNAL(x,__sc) - -#endif // _LICE_COMBINE_H_ diff --git a/oversampling/WDL/lice/lice_extended.h b/oversampling/WDL/lice/lice_extended.h deleted file mode 100644 index a453a77..0000000 --- a/oversampling/WDL/lice/lice_extended.h +++ /dev/null @@ -1,164 +0,0 @@ -#ifndef _LICE_EXTENDED_ -#define _LICE_EXTENDED_ - -#include "lice.h" - -#define DISABLE_LICE_EXTENSIONS - -// stuff to pass to LICE_IBitmap::Extended - -enum // IDs -{ - LICE_EXT_SUPPORTS_ID, // data = ID, returns 1 if that extension ID is supported - LICE_EXT_CLEAR_ACCEL, - LICE_EXT_LINE_ACCEL, - LICE_EXT_FILLRECT_ACCEL, - LICE_EXT_DRAWCBEZIER_ACCEL, - LICE_EXT_DRAWGLYPH_ACCEL, - LICE_EXT_BLIT_ACCEL, - LICE_EXT_SCALEDBLIT_ACCEL, - LICE_EXT_GETFBOTEX_ACCEL, // if the bitmap is implemented as an openGL framebuffer object, get its texture backing store - LICE_EXT_DASHEDLINE_ACCEL, - LICE_EXT_GETPIXEL_ACCEL, - LICE_EXT_PUTPIXEL_ACCEL, - LICE_EXT_SETCLIP, // data == 0 to clear clip - LICE_EXT_WINDOW_BLIT, - LICE_EXT_FORGET, // optimizations can sometimes happen if a bitmap can be told it doesn't need to retain data after it's accessed - LICE_EXT_DRAWTRIANGLE_ACCEL, -}; - -struct LICE_Ext_Line_acceldata -{ - float x1, y1, x2, y2; - LICE_pixel color; - float alpha; - int mode; - bool aa; - - LICE_Ext_Line_acceldata(float _x1, float _y1, float _x2, float _y2, LICE_pixel _color, float _alpha, int _mode, bool _aa) - : x1(_x1), y1(_y1), x2(_x2), y2(_y2), color(_color), alpha(_alpha), mode(_mode), aa(_aa) {} -}; - -struct LICE_Ext_FillRect_acceldata -{ - int x, y, w, h; - LICE_pixel color; - float alpha; - int mode; - - LICE_Ext_FillRect_acceldata(int _x, int _y, int _w, int _h, LICE_pixel _color, float _alpha, int _mode) - : x(_x), y(_y), w(_w), h(_h), color(_color), alpha(_alpha), mode(_mode) {} -}; - -struct LICE_Ext_DrawCBezier_acceldata -{ - float xstart, ystart, xctl1, yctl1, xctl2, yctl2, xend, yend; - LICE_pixel color; - float alpha; - int mode; - bool aa; - - LICE_Ext_DrawCBezier_acceldata(float _xstart, float _ystart, float _xctl1, float _yctl1, float _xctl2, float _yctl2, float _xend, float _yend, - LICE_pixel _color, float _alpha, int _mode, bool _aa) - : xstart(_xstart), ystart(_ystart), xctl1(_xctl1), yctl1(_yctl1), xctl2(_xctl2), yctl2(_yctl2), xend(_xend), yend(_yend), - color(_color), alpha(_alpha), mode(_mode), aa(_aa) {} -}; - -struct LICE_Ext_DrawGlyph_acceldata -{ - int x; - int y; - LICE_pixel color; - const LICE_pixel_chan* alphas; - int glyph_w, glyph_h; - float alpha; - int mode; - - LICE_Ext_DrawGlyph_acceldata(int _x, int _y, LICE_pixel _color, LICE_pixel_chan* _alphas, int _glyph_w, int _glyph_h, float _alpha, int _mode) - : x(_x), y(_y), color(_color), alphas(_alphas), glyph_w(_glyph_w), glyph_h(_glyph_h), alpha(_alpha), mode(_mode) {} -}; - -struct LICE_Ext_Blit_acceldata -{ - LICE_IBitmap* src; - int dstx, dsty, srcx, srcy, srcw, srch; - float alpha; - int mode; - - LICE_Ext_Blit_acceldata(LICE_IBitmap* _src, int _dstx, int _dsty, int _srcx, int _srcy, int _srcw, int _srch, float _alpha, int _mode) - : src(_src), dstx(_dstx), dsty(_dsty), srcx(_srcx), srcy(_srcy), srcw(_srcw), srch(_srch), alpha(_alpha), mode(_mode) {} -}; - -struct LICE_Ext_ScaledBlit_acceldata -{ - LICE_IBitmap* src; - int dstx, dsty, dstw, dsth; - float srcx, srcy, srcw, srch; - float alpha; - int mode; - - LICE_Ext_ScaledBlit_acceldata(LICE_IBitmap* _src, int _dstx, int _dsty, int _dstw, int _dsth, float _srcx, float _srcy, float _srcw, float _srch, float _alpha, int _mode) - : src(_src), dstx(_dstx), dsty(_dsty), dstw(_dstw), dsth(_dsth), srcx(_srcx), srcy(_srcy), srcw(_srcw), srch(_srch), alpha(_alpha), mode(_mode) {} -}; - -struct LICE_Ext_DashedLine_acceldata -{ - float x1, y1, x2, y2; - int pxon, pxoff; - LICE_pixel color; - float alpha; - int mode; - bool aa; - - LICE_Ext_DashedLine_acceldata(float _x1, float _y1, float _x2, float _y2, int _pxon, int _pxoff, LICE_pixel _color, float _alpha, int _mode, bool _aa) - : x1(_x1), y1(_y1), x2(_x2), y2(_y2), pxon(_pxon), pxoff(_pxoff), color(_color), alpha(_alpha), mode(_mode), aa(_aa) {} -}; - -struct LICE_Ext_GetPixel_acceldata -{ - int x, y; - LICE_pixel px; // return - - LICE_Ext_GetPixel_acceldata(int _x, int _y) - : x(_x), y(_y), px(0) {} -}; - -struct LICE_Ext_PutPixel_acceldata -{ - int x, y; - LICE_pixel color; - float alpha; - int mode; - - LICE_Ext_PutPixel_acceldata(int _x, int _y, LICE_pixel _color, float _alpha, int _mode) - : x(_x), y(_y), color(_color), alpha(_alpha), mode(_mode) {} -}; - -struct LICE_Ext_SetClip_data -{ - int x, y, w, h; - - LICE_Ext_SetClip_data(int _x, int _y, int _w, int _h) - : x(_x), y(_y), w(_w), h(_h) {} -}; - -class pl_Mat; - -struct LICE_Ext_DrawTriangle_acceldata -{ - pl_Mat *mat; // will need to include plush.h to access this - double VertexShades[3][3]; // for solid element - float scrx[3], scry[3], scrz[3]; // scrz = 1/Zdist - double mapping_coords[2][3][2]; // [texture or texture2][vertex][uv] -}; - -struct LICE_Ext_WindowBlit_data -{ - HWND hwnd; - int destx, desty, srcx, srcy, w, h; - - LICE_Ext_WindowBlit_data(HWND _hwnd, int _destx, int _desty, int _srcx, int _srcy, int _w, int _h) - : hwnd(_hwnd), destx(_destx), desty(_desty), srcx(_srcx), srcy(_srcy), w(_w), h(_h) {} -}; - -#endif diff --git a/oversampling/WDL/lice/lice_gif.cpp b/oversampling/WDL/lice/lice_gif.cpp deleted file mode 100644 index b6989e7..0000000 --- a/oversampling/WDL/lice/lice_gif.cpp +++ /dev/null @@ -1,462 +0,0 @@ -/* - Cockos WDL - LICE - Lightweight Image Compositing Engine - Copyright (C) 2007 and later, Cockos Incorporated - File: lice_gif.cpp (GIF loading for LICE) - See lice.h for license and other information -*/ - -#include "lice.h" -#include "../heapbuf.h" -#include "../fileread.h" -#include - -extern "C" { - -#include "../giflib/gif_lib.h" -int _GifError; -}; - -static void applyGifFrameToBitmap(LICE_IBitmap *bmp, GifFileType *fp, int transparent_pix, bool clear) -{ - const int width=fp->Image.Width,height=fp->Image.Height; - - LICE_pixel cmap[256]; - GifPixelType _linebuf[2048]; - GifPixelType *linebuf=width > 2048 ? (GifPixelType*)malloc(width*sizeof(GifPixelType)) : _linebuf; - int y; - - if (bmp) - { - y=0; - if (fp->Image.ColorMap && fp->Image.ColorMap->Colors) for (;y<256 && y < fp->Image.ColorMap->ColorCount;y++) - { - GifColorType *ct=fp->Image.ColorMap->Colors+y; - cmap[y]=LICE_RGBA(ct->Red,ct->Green,ct->Blue,255); - } - - if (fp->SColorMap && fp->SColorMap->Colors) for (;y<256 && y < fp->SColorMap->ColorCount;y++) - { - GifColorType *ct=fp->SColorMap->Colors+y; - cmap[y]=LICE_RGBA(ct->Red,ct->Green,ct->Blue,255); - } - for (;y<256;y++) cmap[y]=0; - - if (clear) - { - LICE_pixel col = 0; - - if (fp->SColorMap && fp->SColorMap->Colors && fp->SBackGroundColor >= 0 && fp->SBackGroundColor < fp->SColorMap->ColorCount) - { - GifColorType *ct=fp->SColorMap->Colors+fp->SBackGroundColor; - col = LICE_RGBA(ct->Red,ct->Green,ct->Blue,0); - } - else if (fp->SBackGroundColor>=0 && fp->SBackGroundColor<256) - { - col = cmap[fp->SBackGroundColor] & LICE_RGBA(255,255,255,0); - } - LICE_Clear(bmp,col); - } - } - - const int bmp_h = bmp ? bmp->getHeight() : 0; - const int bmp_w = bmp ? bmp->getWidth() : 0; - LICE_pixel *bmp_ptr = bmp ? bmp->getBits() : NULL; - int bmp_span = bmp ? bmp->getRowSpan() : 0; - if (bmp && bmp->isFlipped() ) - { - bmp_ptr += (bmp_h-1)*bmp_span; - bmp_span = -bmp_span; - } - const int xpos = fp->Image.Left; - - int skip=0; - int use_width = width; - if (xpos < 0) skip = -xpos; - - if (use_width > bmp_w - xpos) use_width = bmp_w - xpos; - - int ystate = 0, ypass=0; - for (y=0; y < height; y ++) - { - if (DGifGetLine(fp,linebuf,width)==GIF_ERROR) break; - - int ypos; - if (fp->Image.Interlace) - { - if (ypass == 0) - { - ypos = ystate++ * 8; - if (ypos >= height) { ypass++; ystate=0; } - } - if (ypass == 1) - { - ypos = ystate++ * 8 + 4; - if (ypos >= height) { ypass++; ystate=0; } - } - if (ypass == 2) - { - ypos = ystate++ * 4 + 2; - if (ypos >= height) { ypass++; ystate=0; } - } - if (ypass==3) ypos = ystate++ * 2 + 1; - } - else - { - ypos = ystate++; - } - - ypos += fp->Image.Top; - if (ypos < 0 || ypos >= bmp_h) continue; - - LICE_pixel *p = bmp_ptr + ypos*bmp_span + xpos; - int x; - for (x = skip; x < use_width; x ++) - { - const int a = (int) linebuf[x]; - if (a != transparent_pix) p[x]=cmap[a]; - } - } - if (linebuf != _linebuf) free(linebuf); -} - -static int readfunc_fh(GifFileType *fh, GifByteType *buf, int sz) -{ - return ((WDL_FileRead*)fh->UserData)->Read(buf,sz); -} - - -LICE_IBitmap *LICE_LoadGIF(const char *filename, LICE_IBitmap *bmp, int *nframes) -{ - WDL_FileRead fpp(filename,0,65536); - - if (nframes) *nframes=0; - - if (!fpp.IsOpen()) return 0; - - GifFileType *fp=DGifOpen(&fpp, readfunc_fh); - if (!fp) return 0; - - int transparent_pix = -1; - - bool had_image = false; - bool had_delay = false; - bool need_new_frame = false; - - const bool own_bmp = !bmp; - GifRecordType RecordType; - GifByteType *Extension; - int ExtCode; - LICE_WrapperBitmap workbm(NULL,0,0,0,false); - WDL_HeapBuf workbuf(128*1024); - - - do - { - if (DGifGetRecordType(fp, &RecordType) == GIF_ERROR) break; - - switch (RecordType) - { - case IMAGE_DESC_RECORD_TYPE: - if (DGifGetImageDesc(fp) == GIF_ERROR) - { - RecordType = TERMINATE_RECORD_TYPE; - break; - } - - if (!bmp) bmp=new WDL_NEW LICE_MemBitmap; - - if (!had_image || (nframes && need_new_frame)) - { - if (had_image) - { - // implies nframes - const int ht = (*nframes+1) * (int)fp->SHeight; - workbm.m_h = ht; - workbm.m_w = (int)fp->SWidth; - workbm.m_span = (workbm.m_w+3)&~3; - workbm.m_buf = (LICE_pixel *) workbuf.ResizeOK(ht * sizeof(LICE_pixel) * workbm.m_span); - if (!workbm.m_buf) - { - RecordType = TERMINATE_RECORD_TYPE; - break; - } - } - else - { - if (bmp) bmp->resize(fp->SWidth,fp->SHeight); - - if (!bmp || bmp->getWidth() != (int)fp->SWidth || bmp->getHeight() != (int)fp->SHeight) - { - RecordType = TERMINATE_RECORD_TYPE; - break; - } - } - - if (nframes) - { - if (*nframes > 0) - { - if (*nframes == 1) - LICE_Blit(&workbm,bmp,0,0,0,0,bmp->getWidth(),bmp->getHeight(),1.0,LICE_BLIT_MODE_COPY); - - LICE_Blit(&workbm,&workbm,0,workbm.getHeight()-(int)fp->SHeight,0, - workbm.getHeight()-(int)fp->SHeight*2, workbm.getWidth(), (int)fp->SHeight,1.0f,LICE_BLIT_MODE_COPY); - } - - *nframes += 1; - } - } - - if (nframes) - { - LICE_SubBitmap tmp(&workbm, 0,workbm.getHeight() - (int) fp->SHeight, workbm.getWidth(), (int)fp->SHeight); - applyGifFrameToBitmap(&tmp,fp,transparent_pix,!had_image); - } - else - applyGifFrameToBitmap(bmp,fp,transparent_pix,!had_image); - - had_image = true; - - need_new_frame = false; - transparent_pix = -1; - - if (had_delay) - { - if (!nframes) - { - RecordType = TERMINATE_RECORD_TYPE; // finish up if first frame is finished - } - else - { - need_new_frame = true; - } - had_delay = false; - } - break; - case EXTENSION_RECORD_TYPE: - if (DGifGetExtension(fp, &ExtCode, &Extension) == GIF_ERROR) - { - RecordType = TERMINATE_RECORD_TYPE; - } - else - { - while (Extension != NULL) - { - if (ExtCode == 0xF9 && *Extension >= 4) - { - transparent_pix = -1; - if (Extension[1]&1) - { - transparent_pix = Extension[4]; - } - if (Extension[2] || Extension[3]) had_delay=true; - } - - if (DGifGetExtensionNext(fp, &Extension) == GIF_ERROR) - { - RecordType = TERMINATE_RECORD_TYPE; - break; - } - } - } - break; - case TERMINATE_RECORD_TYPE: - break; - default: /* Should be traps by DGifGetRecordType. */ - break; - } - } - while (RecordType != TERMINATE_RECORD_TYPE); - - DGifCloseFile(fp); - - if (had_image) - { - if (workbm.getWidth()) LICE_Copy(bmp,&workbm); - return bmp; - } - - if (own_bmp) delete bmp; - return NULL; -} - - - -class LICE_GIFLoader -{ -public: - _LICE_ImageLoader_rec rec; - LICE_GIFLoader() - { - rec.loadfunc = loadfunc; - rec.get_extlist = get_extlist; - rec._next = LICE_ImageLoader_list; - LICE_ImageLoader_list = &rec; - } - - static LICE_IBitmap *loadfunc(const char *filename, bool checkFileName, LICE_IBitmap *bmpbase) - { - if (checkFileName) - { - const char *p=filename; - while (*p)p++; - while (p>filename && *p != '\\' && *p != '/' && *p != '.') p--; - if (stricmp(p,".gif")) return 0; - } - return LICE_LoadGIF(filename,bmpbase,NULL); - } - static const char *get_extlist() - { - return "GIF files (*.GIF)\0*.GIF\0"; - } - -}; - -LICE_GIFLoader LICE_gifldr; - - - - - -struct lice_gif_read_ctx -{ - WDL_FileRead *fh; - GifFileType *gif; - int msecpos; - int state; - WDL_FILEREAD_POSTYPE ipos; -}; - - -void *LICE_GIF_LoadEx(const char *filename) -{ - WDL_FileRead *fpp = new WDL_FileRead(filename,0,32768); - - if (!fpp->IsOpen()) - { - delete fpp; - return 0; - } - - GifFileType *gif=DGifOpen(fpp, readfunc_fh); - if (!gif) - { - delete fpp; - return 0; - } - - lice_gif_read_ctx *ret = (lice_gif_read_ctx*)calloc(sizeof(lice_gif_read_ctx), 1); - if (!ret) - { - DGifCloseFile(gif); - delete fpp; - return NULL; - } - ret->fh = fpp; - ret->gif = gif; - ret->msecpos = 0; - ret->state = 0; - ret->ipos = fpp->GetPosition(); - - return ret; -} - - -void LICE_GIF_Close(void *handle) -{ - lice_gif_read_ctx *h = (lice_gif_read_ctx*)handle; - if (h) - { - DGifCloseFile(h->gif); - delete h->fh; - free(h); - } -} -void LICE_GIF_Rewind(void *handle) -{ - lice_gif_read_ctx *h = (lice_gif_read_ctx*)handle; - if (h) - { - h->state = 0; - h->msecpos = 0; - h->fh->SetPosition(h->ipos); - // todo: flush giflib too - } -} -unsigned int LICE_GIF_GetFilePos(void *handle) -{ - // only used for accounting at the moment, so meh - lice_gif_read_ctx *h = (lice_gif_read_ctx*)handle; - if (h && h->fh) - { - return (unsigned int) h->fh->GetPosition(); - } - - return 0; -} - -int LICE_GIF_UpdateFrame(void *handle, LICE_IBitmap *bm) -{ - lice_gif_read_ctx *h = (lice_gif_read_ctx*)handle; - if (!h||h->state<0) return -2; - GifFileType *fp = h->gif; - - if (bm) - { - bm->resize(fp->SWidth, fp->SHeight); - if (bm->getWidth() != (int)fp->SWidth || bm->getHeight() != (int)fp->SHeight) return -3; - } - - int has_delay = 0; - int transparent_pix = -1; - GifRecordType RecordType; - GifByteType *Extension; - int ExtCode; - do - { - if (DGifGetRecordType(fp, &RecordType) == GIF_ERROR) return h->state = -5; - switch (RecordType) - { - case IMAGE_DESC_RECORD_TYPE: - if (DGifGetImageDesc(fp) == GIF_ERROR) return h->state = -4; - - applyGifFrameToBitmap(bm,fp,transparent_pix,!h->state); - h->state += 1; - h->msecpos += has_delay*10; - return has_delay*10; - - case EXTENSION_RECORD_TYPE: - if (DGifGetExtension(fp, &ExtCode, &Extension) == GIF_ERROR) - { - return h->state = -9; - } - else - { - while (Extension != NULL) - { - if (ExtCode == 0xF9 && *Extension >= 4) - { - transparent_pix = -1; - if (Extension[1]&1) - { - transparent_pix = Extension[4]; - } - has_delay = ((int)Extension[3] << 8) + Extension[2]; - if (has_delay == 1) has_delay = 10; // https://www.biphelps.com/blog/The-Fastest-GIF-Does-Not-Exist - } - - if (DGifGetExtensionNext(fp, &Extension) == GIF_ERROR) return h->state = -8; - } - } - break; - case TERMINATE_RECORD_TYPE: - break; - default: /* Should be traps by DGifGetRecordType. */ - break; - } - } - while (RecordType != TERMINATE_RECORD_TYPE); - - return h->state = -10; -} - diff --git a/oversampling/WDL/lice/lice_gif_write.cpp b/oversampling/WDL/lice/lice_gif_write.cpp deleted file mode 100644 index be01beb..0000000 --- a/oversampling/WDL/lice/lice_gif_write.cpp +++ /dev/null @@ -1,491 +0,0 @@ -/* - Cockos WDL - LICE - Lightweight Image Compositing Engine - Copyright (C) 2007 and later, Cockos Incorporated - File: lice_gif.cpp (GIF loading for LICE) - See lice.h for license and other information -*/ - -#include "lice.h" - -#include - -#include "../wdltypes.h" -#include "../filewrite.h" - -extern "C" { - -#include "../giflib/gif_lib.h" -//int _GifError; -}; - - -struct liceGifWriteRec -{ - GifFileType *f; - WDL_FileWrite *fh; - ColorMapObject *cmap; - GifPixelType *linebuf; - LICE_IBitmap *prevframe; // used when multiframe, transalpha<0 - void *last_octree; - LICE_pixel last_palette[256]; - unsigned char from15to8bit[32][32][32];//r,g,b - - int transalpha; - int w,h; - bool append; - bool dither; - bool has_had_frame; - bool has_global_cmap; - - bool has_from15to8bit; // set when last_octree has been generated into from15to8bit -}; - -static inline GifPixelType QuantPixel(LICE_pixel p, liceGifWriteRec *wr) -{ - return wr->from15to8bit[LICE_GETR(p)>>3][LICE_GETG(p)>>3][LICE_GETB(p)>>3]; -} - -static int generate_palette_from_octree(void *ww, void *octree, int numcolors) -{ - liceGifWriteRec *wr = (liceGifWriteRec *)ww; - if (!octree||!ww||numcolors>256) return 0; - - ColorMapObject *cmap = wr->cmap; - - int palette_sz=0; - - // store palette - { - LICE_pixel* palette=wr->last_palette; - - palette_sz = LICE_ExtractOctreePalette(octree, palette); - - int i; - for (i = 0; i < palette_sz; ++i) - { - cmap->Colors[i].Red = LICE_GETR(palette[i]); - cmap->Colors[i].Green = LICE_GETG(palette[i]); - cmap->Colors[i].Blue = LICE_GETB(palette[i]); - } - for (i = palette_sz; i < numcolors; ++i) - { - cmap->Colors[i].Red = cmap->Colors[i].Green = cmap->Colors[i].Blue = 0; - } - } - - wr->has_from15to8bit = false; - wr->has_global_cmap=true; - - return palette_sz; -} - -static void generate15to8(void *ww, void *octree) -{ - liceGifWriteRec *wr = (liceGifWriteRec *)ww; - if (!octree||!ww) return; - - // map palette to 16 bit - unsigned char r,g,b; - for(r=0;r<32;r++) - { - unsigned char cr = r<<3; - for (g=0;g<32;g++) - { - unsigned char cg = g<<3; - for (b=0;b<32;b++) - { - unsigned char cb = b<<3; - LICE_pixel col = LICE_RGBA(cr,cg,cb,0); - wr->from15to8bit[r][g][b] = LICE_FindInOctree(octree, col); - } - } - } - wr->has_from15to8bit=true; -} - -int LICE_SetGIFColorMapFromOctree(void *ww, void *octree, int numcolors) -{ - const int rv = generate_palette_from_octree(ww,octree,numcolors); - generate15to8(ww,octree); - return rv; -} - -unsigned int LICE_WriteGIFGetSize(void *handle) -{ - if (handle) - { - liceGifWriteRec *wr = (liceGifWriteRec*)handle; - if (wr->fh) return (unsigned int) ((WDL_FileWrite *)wr->fh)->GetPosition(); - } - return 0; -} - -bool LICE_WriteGIFFrame(void *handle, LICE_IBitmap *frame, int xpos, int ypos, bool perImageColorMap, int frame_delay, int nreps) -{ - liceGifWriteRec *wr = (liceGifWriteRec*)handle; - if (!wr) return false; - - bool isFirst=false; - if (!wr->has_had_frame) - { - wr->has_had_frame=true; - isFirst=true; - - if (!perImageColorMap && !wr->has_global_cmap) - { - const int ccnt = 256 - (wr->transalpha?1:0); - void* octree = wr->last_octree; - if (!octree) wr->last_octree = octree = LICE_CreateOctree(ccnt); - else LICE_ResetOctree(octree,ccnt); - - if (octree) - { - LICE_BuildOctree(octree, frame); - // sets has_global_cmap - int pcnt = generate_palette_from_octree(wr, octree, ccnt); - - if (pcnt < 256 && wr->transalpha) pcnt++; - int nb = 1; - while (nb < 8 && (1<cmap->ColorCount = 1<cmap->BitsPerPixel=nb; - } - } - - if (!wr->append) EGifPutScreenDesc(wr->f,wr->w,wr->h,8,0,wr->has_global_cmap ? wr->cmap : 0); - - } - - int usew=frame->getWidth(), useh=frame->getHeight(); - if (xpos+usew > wr->w) usew = wr->w-xpos; - if (ypos+useh > wr->h) useh = wr->h-ypos; - if (usew<1||useh<1) return false; - - int pixcnt=usew*useh; - - const int trans_chan_mask = wr->transalpha&0xff; // -1 means 0xff by default, user can change this accordingly - const LICE_pixel trans_mask = LICE_RGBA(trans_chan_mask,trans_chan_mask,trans_chan_mask,0); - const bool advanced_trans_stats = !!(wr->transalpha&0x100); - - if (perImageColorMap && !wr->has_global_cmap) - { - const int ccnt = 256 - (wr->transalpha?1:0); - void* octree = wr->last_octree; - if (!octree) wr->last_octree = octree = LICE_CreateOctree(ccnt); - else LICE_ResetOctree(octree,ccnt); - if (octree) - { - if ((!isFirst || frame_delay) && wr->transalpha<0 && wr->prevframe) - { - LICE_SubBitmap tmpprev(wr->prevframe, xpos, ypos, usew, useh); - int pc=LICE_BuildOctreeForDiff(octree,frame,&tmpprev,trans_mask); - if (!advanced_trans_stats) pixcnt = pc; - } - else if (wr->transalpha>0) - pixcnt=LICE_BuildOctreeForAlpha(octree, frame,wr->transalpha&0xff); - else - LICE_BuildOctree(octree, frame); - - // sets has_global_cmap (clear below) - int pcnt = generate_palette_from_octree(wr, octree, ccnt); - - wr->has_global_cmap=false; - if (pcnt < 256 && wr->transalpha) pcnt++; - int nb = 1; - while (nb < 8 && (1<cmap->ColorCount = 1<cmap->BitsPerPixel=nb; - } - } - - if (!wr->has_from15to8bit && pixcnt > 40000 && wr->last_octree) - { - generate15to8(wr,wr->last_octree); - } - - const unsigned char transparent_pix = wr->cmap->ColorCount-1; - unsigned char gce[4] = { 0, }; - if (wr->transalpha) - { - gce[0] |= 1; - gce[3] = transparent_pix; - } - - int a = frame_delay/10; - if(a<2&&frame_delay)a=2; // https://www.biphelps.com/blog/The-Fastest-GIF-Does-Not-Exist - else if (a>60000) a=60000; - gce[1]=(a)&255; - gce[2]=(a)>>8; - - if (isFirst && frame_delay && nreps!=1 && !wr->append) - { - int nr = nreps > 1 && nreps <= 65536 ? nreps-1 : 0; - unsigned char ext[]={0xB, 'N','E','T','S','C','A','P','E','2','.','0',3,1,(unsigned char) (nr&0xff), (unsigned char) ((nr>>8)&0xff)}; - EGifPutExtension(wr->f,0xFF, sizeof(ext),ext); - } - - if (gce[0]||gce[1]||gce[2]) - EGifPutExtension(wr->f, 0xF9, sizeof(gce), gce); - - - EGifPutImageDesc(wr->f, xpos, ypos, usew,useh, 0, wr->has_global_cmap ? NULL : wr->cmap); - - GifPixelType *linebuf = wr->linebuf; - int y; - - void *use_octree = wr->has_from15to8bit ? NULL : wr->last_octree; - - if ((!isFirst || frame_delay) && wr->transalpha<0) - { - bool ignFr=false; - if (!wr->prevframe) - { - ignFr=true; - wr->prevframe = new WDL_NEW LICE_MemBitmap(wr->w,wr->h); - LICE_Clear(wr->prevframe,0); - } - - LICE_SubBitmap tmp(wr->prevframe,xpos,ypos,usew,useh); - - LICE_pixel last_pixel_rgb=0; - GifPixelType last_pixel_idx=transparent_pix; - - int pix_stats[256]; - if (advanced_trans_stats) memset(pix_stats,0,sizeof(pix_stats)); - pix_stats[transparent_pix] = -8; - - for(y=0;yisFlipped()) rdy = frame->getHeight()-1-y; - if (tmp.isFlipped()) rdy2 = tmp.getHeight()-1-y; - const LICE_pixel *in = frame->getBits() + rdy*frame->getRowSpan(); - const LICE_pixel *in2 = tmp.getBits() + rdy2*tmp.getRowSpan(); - int x; - - if (advanced_trans_stats) - { - if (use_octree) for(x=0;xlast_palette[np]&trans_mask) || pix_stats[transparent_pix] > pix_stats[np]) - last_pixel_idx = transparent_pix; - else - last_pixel_idx = np; - } - } - linebuf[x] = last_pixel_idx; - pix_stats[last_pixel_idx]++; - last_pixel_rgb = p; - } - else for(x=0;xlast_palette[np]&trans_mask) || pix_stats[transparent_pix] > pix_stats[np]) - last_pixel_idx = transparent_pix; - else - last_pixel_idx = np; - } - } - linebuf[x] = last_pixel_idx; - pix_stats[last_pixel_idx]++; - last_pixel_rgb = p; - } - } - else - { - // optimize solids by reusing the same value if previous rgb was the same, also avoid switching between - // from color to transparent if the color hasn't changed - if (use_octree) for(x=0;xf, linebuf, usew); - } - - LICE_Blit(&tmp,frame,0,0,0,0,usew,useh,1.0f,LICE_BLIT_MODE_COPY); - - } - else if (wr->transalpha>0) - { - const unsigned int al = wr->transalpha&0xff; - for(y=0;yisFlipped()) rdy = frame->getHeight()-1-y; - const LICE_pixel *in = frame->getBits() + rdy*frame->getRowSpan(); - int x; - if (use_octree) for(x=0;xf, linebuf, usew); - } - } - else for(y=0;yisFlipped()) rdy = frame->getHeight()-1-y; - const LICE_pixel *in = frame->getBits() + rdy*frame->getRowSpan(); - int x; - if (use_octree) for(x=0;xf, linebuf, usew); - } - - return true; -} - -static int writefunc_fh(GifFileType *fh, const GifByteType *buf, int sz) -{ - return ((WDL_FileWrite *)fh->UserData)->Write(buf,sz); -} - -void *LICE_WriteGIFBeginNoFrame(const char *filename, int w, int h, int transparent_alpha, bool dither, bool is_append) -{ - WDL_FileWrite *fp = new WDL_FileWrite(filename,1,65536,16,16,is_append); - if (!fp->IsOpen()) - { - delete fp; - return NULL; - } - - - EGifSetGifVersion("89a"); - - - GifFileType *f = EGifOpen(fp,writefunc_fh); - if (!f) - { - delete fp; - return NULL; - } - - liceGifWriteRec *wr = (liceGifWriteRec*)calloc(sizeof(liceGifWriteRec),1); - wr->f = f; - wr->fh = fp; - wr->append = is_append; - wr->dither = dither; - wr->w=w; - wr->h=h; - wr->cmap = (ColorMapObject*)calloc(sizeof(ColorMapObject)+256*sizeof(GifColorType),1); - wr->cmap->Colors = (GifColorType*)(wr->cmap+1); - wr->cmap->ColorCount=256; - wr->cmap->BitsPerPixel=8; - wr->has_had_frame=false; - wr->has_global_cmap=false; - wr->has_from15to8bit=false; - wr->last_octree=NULL; - - wr->linebuf = (GifPixelType*)malloc(wr->w*sizeof(GifPixelType)); - wr->transalpha = transparent_alpha; - - return wr; -} -void *LICE_WriteGIFBegin(const char *filename, LICE_IBitmap *firstframe, int transparent_alpha, int frame_delay, bool dither, int nreps) -{ - if (!firstframe) return NULL; - - void *wr=LICE_WriteGIFBeginNoFrame(filename,firstframe->getWidth(),firstframe->getHeight(),transparent_alpha,dither); - if (wr) LICE_WriteGIFFrame(wr,firstframe,0,0,true,frame_delay,nreps); - - return wr; -} - - - -bool LICE_WriteGIFEnd(void *handle) -{ - liceGifWriteRec *wr = (liceGifWriteRec*)handle; - if (!wr) return false; - - int ret = EGifCloseFile(wr->f); - - free(wr->linebuf); - free(wr->cmap); - if (wr->last_octree) LICE_DestroyOctree(wr->last_octree); - - delete wr->prevframe; - delete wr->fh; - - free(wr); - - return ret!=GIF_ERROR; -} - - -bool LICE_WriteGIF(const char *filename, LICE_IBitmap *bmp, int transparent_alpha, bool dither) -{ - // todo: alpha? - if (!bmp) return false; - - int has_transparent = 0; - if (transparent_alpha>0) - { - int y=bmp->getHeight(); - LICE_pixel *p = bmp->getBits(); - int w = bmp->getWidth(); - while (y--&&!has_transparent) - { - int x=w; - while(x--) - { - if (LICE_GETA(*p) < (unsigned int)transparent_alpha) - { - has_transparent=1; - break; - } - p++; - } - p+=bmp->getRowSpan()-w; - } - } - - - void *wr=LICE_WriteGIFBeginNoFrame(filename,bmp->getWidth(),bmp->getHeight(),has_transparent?transparent_alpha:0,dither); - if (!wr) return false; - - LICE_WriteGIFFrame(wr,bmp,0,0,false,0); - - return LICE_WriteGIFEnd(wr); -} diff --git a/oversampling/WDL/lice/lice_gl_ctx.cpp b/oversampling/WDL/lice/lice_gl_ctx.cpp deleted file mode 100644 index 314ff03..0000000 --- a/oversampling/WDL/lice/lice_gl_ctx.cpp +++ /dev/null @@ -1,264 +0,0 @@ -#include "lice_gl_ctx.h" - -#define MAX_CACHED_GLYPHS 4096 - -// create one hidden window per process to hold the openGL state, -// its GL render context stays current for the life of the process, -// we serve all framebuffers from the same render context - -class LICE_GL_ctx -{ -public: - - LICE_GL_ctx(); - ~LICE_GL_ctx(); - - bool IsValid(); - HWND GetWindow() { return m_hwnd; } - void Close(); - - GLUnurbsObj* GetNurbsObj(int linetol=8); // linetol = maximum number of straight-line pixels - - int GetTexFromGlyph(const unsigned char* glyph, int glyph_w, int glyph_h); - void ClearTex(); - - struct GlyphCache - { - unsigned int tex; - unsigned char* glyph; // lives on the heap - int glyph_w, glyph_h; - }; - -private: - - bool Init(); - - bool m_init_tried; - HINSTANCE m_gldll; - HWND m_hwnd; - HGLRC m_glrc; - - GLUnurbsObj* m_nurbs; // keep this here for easy reuse - - GlyphCache m_glyphCache[MAX_CACHED_GLYPHS]; - int m_nCachedGlyphs; -}; - -LICE_GL_ctx::LICE_GL_ctx() -{ - m_init_tried = false; - m_gldll = 0; - m_hwnd = 0; - m_glrc = 0; - m_nurbs = 0; - memset(m_glyphCache, 0, MAX_CACHED_GLYPHS*sizeof(GlyphCache)); - m_nCachedGlyphs = 0; -} - -LICE_GL_ctx::~LICE_GL_ctx() -{ - Close(); -} - -bool LICE_GL_ctx::Init() -{ - m_init_tried = true; - - m_gldll = LoadLibrary("opengl32.dll"); - if (!m_gldll) - { - Close(); - return false; - } - - // create a minimal GL render context to serve FBOs out of - WNDCLASS wc; - memset(&wc, 0, sizeof(WNDCLASS)); - wc.hInstance = GetModuleHandle(0); - wc.lpfnWndProc = DefWindowProc; - wc.lpszClassName = "LICE_GL_ctx"; - RegisterClass(&wc); - m_hwnd = CreateWindow("LICE_GL_ctx", "LICE_GL_ctx", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, GetModuleHandle(0), 0); - HDC dc = GetDC(m_hwnd); - if (!dc) - { - Close(); - return false; - } - - PIXELFORMATDESCRIPTOR pfd; - memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR)); - pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR); - pfd.nVersion = 1; - pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL; - pfd.iPixelType = PFD_TYPE_RGBA; - pfd.cColorBits = 24; - pfd.cAlphaBits = 8; - int pxfmt = ChoosePixelFormat(dc, &pfd); - if (!SetPixelFormat(dc, pxfmt, &pfd)) - { - Close(); - return false; - } - - m_glrc = wglCreateContext(dc); - if (!wglMakeCurrent(dc, m_glrc)) // render context should stay current throughout - { - Close(); - return false; - } - - char *rendstr = (char*) glGetString(GL_RENDERER); - if (!rendstr || strstr(rendstr, "GDI")) - { - Close(); - return false; - } - - // check now for all the extension functions we will ever need - if (glewInit() != GLEW_OK || - !glewIsSupported("GL_EXT_framebuffer_object") || - !glewIsSupported("GL_ARB_texture_rectangle")) - { - Close(); - return false; - } - - // any one-time initialization goes here - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - ReleaseDC(m_hwnd, dc); - - return true; -} - -bool LICE_GL_ctx::IsValid() -{ - if (m_gldll && m_glrc) return true; - if (!m_init_tried) return Init(); - return false; -} - -void LICE_GL_ctx::Close() -{ - ClearTex(); - if (m_nurbs) - { - gluDeleteNurbsRenderer(m_nurbs); - m_nurbs = 0; - } - if (m_glrc) - { - wglMakeCurrent(0, 0); - wglDeleteContext(m_glrc); - m_glrc = 0; - } - if (m_hwnd) - { - DestroyWindow(m_hwnd); - m_hwnd = 0; - } - if (m_gldll) - { - FreeLibrary(m_gldll); - m_gldll = 0; - } -} - -GLUnurbsObj* LICE_GL_ctx::GetNurbsObj(int linetol) -{ - if (!IsValid()) return 0; - if (!m_nurbs) m_nurbs = gluNewNurbsRenderer(); - if (m_nurbs) gluNurbsProperty(m_nurbs, GLU_SAMPLING_TOLERANCE, (float)linetol); - return m_nurbs; -} - -void LICE_GL_ctx::ClearTex() -{ - int i; - for (i = 0; i < m_nCachedGlyphs; ++i) - { - glDeleteTextures(1, &m_glyphCache[i].tex); - free(m_glyphCache[i].glyph); - memset(&m_glyphCache[i], 0, sizeof(GlyphCache)); - } - m_nCachedGlyphs = 0; -} - -static int _glyphcmp(const void* p1, const void* p2) -{ - LICE_GL_ctx::GlyphCache* gc1 = (LICE_GL_ctx::GlyphCache*) p1; - LICE_GL_ctx::GlyphCache* gc2 = (LICE_GL_ctx::GlyphCache*) p2; - - if (gc1->glyph_w < gc2->glyph_w) return -1; - if (gc1->glyph_w > gc2->glyph_w) return 1; - if (gc1->glyph_h < gc2->glyph_h) return -1; - if (gc1->glyph_h > gc2->glyph_h) return 1; - return memcmp(gc1->glyph, gc2->glyph, gc1->glyph_w*gc1->glyph_h); -} - -int LICE_GL_ctx::GetTexFromGlyph(const unsigned char* glyph, int glyph_w, int glyph_h) -{ - if (!IsValid()) return false; - - GlyphCache gc; - gc.tex = 0; - gc.glyph = (unsigned char *)glyph; - gc.glyph_w = glyph_w; - gc.glyph_h = glyph_h; - - GlyphCache* p = (GlyphCache*) bsearch(&gc, m_glyphCache, m_nCachedGlyphs, sizeof(GlyphCache), _glyphcmp); - if (p) return p->tex; - - glGenTextures(1, &gc.tex); - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, gc.tex); - glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_ALPHA8, glyph_w, glyph_h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, glyph); - - if (m_nCachedGlyphs >= MAX_CACHED_GLYPHS) ClearTex(); // quick & dirty - - gc.glyph = (unsigned char*) malloc(glyph_w*glyph_h); - memcpy(gc.glyph, glyph, glyph_w*glyph_h); - m_glyphCache[m_nCachedGlyphs++] = gc; // copy - qsort(m_glyphCache, m_nCachedGlyphs, sizeof(GlyphCache), _glyphcmp); - - return gc.tex; -} - -//////// - -static LICE_GL_ctx s_glctx; // one static opengl context object per process - - -bool LICE_GL_IsValid() -{ - return s_glctx.IsValid(); -} - -HWND LICE_GL_GetWindow() -{ - if (s_glctx.IsValid()) return s_glctx.GetWindow(); - return 0; -} - -void LICE_GL_CloseCtx() -{ - s_glctx.Close(); -} - -GLUnurbsObj* LICE_GL_GetNurbsObj(int linetol) // linetol = maximum number of straight-line pixels -{ - return s_glctx.GetNurbsObj(linetol); -} - -GLuint LICE_GL_GetTexFromGlyph(const unsigned char* glyph, int glyph_w, int glyph_h) -{ - return s_glctx.GetTexFromGlyph(glyph, glyph_w, glyph_h); -} - -void LICE_GL_ClearTex() -{ - s_glctx.ClearTex(); -} - diff --git a/oversampling/WDL/lice/lice_gl_ctx.h b/oversampling/WDL/lice/lice_gl_ctx.h deleted file mode 100644 index 2915a06..0000000 --- a/oversampling/WDL/lice/lice_gl_ctx.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _GL_CTX_ -#define _GL_CTX_ - -#include "lice.h" - -#define GLEW_STATIC -#include "glew/include/gl/glew.h" -#include "glew/include/gl/wglew.h" -#include "glew/include/gl/wglext.h" - -// GL context functions -// opening and managing GL context is handled behind the scenes - - -bool LICE_GL_IsValid(); // GL context is initialized (will be lazy initialized on first call) and valid - -HWND LICE_GL_GetWindow(); // Get the window that owns the GL context (one per process) - -void LICE_GL_CloseCtx(); // Something failed, turn off GL context forever so we don't keep failing - -GLUnurbsObj* LICE_GL_GetNurbsObj(int linetol=8); // linetol = maximum number of straight-line pixels - -// facility for associating a glyph with a texture -GLuint LICE_GL_GetTexFromGlyph(const unsigned char* glyph, int glyph_w, int glyph_h); -void LICE_GL_ClearTex(); - -#endif diff --git a/oversampling/WDL/lice/lice_glbitmap.cpp b/oversampling/WDL/lice/lice_glbitmap.cpp deleted file mode 100644 index 140ab96..0000000 --- a/oversampling/WDL/lice/lice_glbitmap.cpp +++ /dev/null @@ -1,708 +0,0 @@ -#include "lice_glbitmap.h" -#include "lice_gl_ctx.h" - -#include "../plush2/plush.h" - -LICE_GLBitmap::LICE_GLBitmap() -{ - m_bmp = 0; - m_fbo = 0; - m_tex = 0; - m_bufloc = EMPTY; -} - -// This is separate from the constructor for initialization order reasons -void LICE_GLBitmap::Init(LICE_IBitmap* bmp, int w, int h) -{ - m_bmp = bmp; - if (w > 0 && h > 0) CreateFBO(w, h); -} - -bool LICE_GLBitmap::CreateFBO(int w, int h) -{ - if (LICE_GL_IsValid()) - { - if (m_fbo) ReleaseFBO(); - glGenFramebuffersEXT(1, &m_fbo); // create a new empty FBO - if (m_fbo) - { - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); // bind this FBO so it is the rendering target - glEnable(GL_TEXTURE_RECTANGLE_ARB); // enable texturing - glGenTextures(1, &m_tex); // create a new texture to be the backing store - if (m_tex) - { - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_tex); // bind this texture so it is the texturing target - glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // we won't be scaling it for this purpose - glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); // size the texture - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, m_tex, 0); // attach the texture as the backing store for the FBO - } - glDisable(GL_TEXTURE_RECTANGLE_ARB); // done texturing - } - - return BindFBO(); // this tests the FBO for validity - } - return false; -} - -LICE_GL_SysBitmap::LICE_GL_SysBitmap(int w, int h) -: m_sysbmp(w, h) -{ - Init(&m_sysbmp, w, h); -} - -LICE_GL_MemBitmap::LICE_GL_MemBitmap(int w, int h) -: m_membmp(w, h) -{ - Init(&m_membmp, w, h); -} - -HDC LICE_GL_SysBitmap::getDC() -{ - // no known way to get a DC directly from an offscreen openGL render context, sadly - FramebufferFromGPU(); - OutputDebugString("GL to screen"); - return m_sysbmp.getDC(); -} - - -LICE_GL_SubBitmap::LICE_GL_SubBitmap(LICE_IBitmap *parent, int x, int y, int w, int h) -{ - m_parent = parent; - m_x = x; - m_y = y; - m_w = w; - m_h = h; -} - -LICE_pixel* LICE_GL_SubBitmap::getBits() -{ - if (!m_parent) return 0; - return m_parent->getBits()+m_y*m_parent->getRowSpan()+m_x; -} - -bool LICE_GL_SubBitmap::resize(int w, int h) -{ - if (w == m_w && h == m_h) return false; - m_w = w; - m_h = h; - return true; -} - -INT_PTR LICE_GL_SubBitmap::Extended(int id, void* data) -{ - if (!m_parent) return 0; - - if (id == LICE_EXT_SUPPORTS_ID) return m_parent->Extended(id, data); - - LICE_Ext_SetClip_data clipdata(m_x, m_y, m_w, m_h); - if (!m_parent->Extended(LICE_EXT_SETCLIP, &clipdata)) return 0; - INT_PTR ret = m_parent->Extended(id, data); - m_parent->Extended(LICE_EXT_SETCLIP, 0); - - return ret; -} - -bool LICE_GLBitmap::SetClip_ext(LICE_Ext_SetClip_data* p) -{ - if (!FramebufferToGPU()) return false; - - if (p) - { - GLdouble c0[4] = { 1.0, 0.0, 0.0, -p->x }; - GLdouble c1[4] = { -1.0, 0.0, 0.0, p->x+p->w }; - GLdouble c2[4] = { 0.0, 1.0, 0.0, -p->y}; - GLdouble c3[4] = { 0.0, -1.0, 0.0, p->y+p->h }; - glClipPlane(GL_CLIP_PLANE0, c0); - glClipPlane(GL_CLIP_PLANE1, c1); - glClipPlane(GL_CLIP_PLANE2, c2); - glClipPlane(GL_CLIP_PLANE3, c3); - glEnable(GL_CLIP_PLANE0); - glEnable(GL_CLIP_PLANE1); - glEnable(GL_CLIP_PLANE2); - glEnable(GL_CLIP_PLANE3); - } - else - { - glDisable(GL_CLIP_PLANE0); - glDisable(GL_CLIP_PLANE1); - glDisable(GL_CLIP_PLANE2); - glDisable(GL_CLIP_PLANE3); - } - - return true; -} - -LICE_GLBitmap::~LICE_GLBitmap() -{ - ReleaseFBO(); -} - -int LICE_GLBitmap::getWidth() -{ - return m_bmp->getWidth(); -} - -int LICE_GLBitmap::getHeight() -{ - return m_bmp->getHeight(); -} - -int LICE_GLBitmap::getRowSpan() -{ - return m_bmp->getRowSpan(); -} - -LICE_pixel* LICE_GLBitmap::getBits() -{ - FramebufferFromGPU(); - return m_bmp->getBits(); -} - -bool LICE_GLBitmap::resize(int w, int h) -{ - int oldw = getWidth(); - int oldh = getHeight(); - if (w == oldw && h == oldh) return false; - - if (oldw == 0 && oldh == 0 && w > 0 && h > 0) - { - m_bmp->resize(w, h); - CreateFBO(w, h); - return true; - } - - if (!m_fbo || !m_tex) return m_bmp->resize(w, h); - - OutputDebugString("GL resizing"); - - // the framebuffer/GPU transfer overhead is per-call, so it's important to be able - // to move the entire bitmap back and forth in one call, which means keeping m_sysbmp width == rowspan - - int oldloc = m_bufloc; - - FramebufferFromGPU(); // copy out the GPU data (this binds the FBO so it is the rendering target) - - glEnable(GL_TEXTURE_RECTANGLE_ARB); // enable texturing - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_tex); // bind this texture so it is the texturing target - glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // we won't be scaling it for this purpose - glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); // size the texture - glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, m_tex, 0); // attach the texture as the backing store for the FBO - glDisable(GL_TEXTURE_RECTANGLE_ARB); // done texturing - - if (!BindFBO()) return m_bmp->resize(w, h); // this tests the FBO for validity - - static LICE_MemBitmap tmpbmp; - tmpbmp.resize(w, h); - LICE_Blit(&tmpbmp, m_bmp, 0, 0, 0, 0, oldw, oldh, 1.0f, LICE_BLIT_MODE_COPY); - m_bmp->resize(0, 0); // force it to resize down - LICE_Copy(m_bmp, &tmpbmp); - - if (oldloc == EMPTY) m_bufloc = EMPTY; // else bufloc remains INMEM - - return true; -} - -bool LICE_GLBitmap::BindFBO() -{ - bool valid = false; - if (m_fbo) - { - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fbo); // bind this FBO so it is the rendering target - valid = (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT); - if (valid) - { - int w = getWidth(); - int h = getHeight(); - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluOrtho2D(0.0, w, 0.0, h); - } - else - { - ReleaseFBO(); - LICE_GL_CloseCtx(); // if we fail once we're done with GL - } - } - return valid; -} - -void LICE_GLBitmap::ReleaseFBO() -{ - if (m_fbo) - { - glDeleteFramebuffersEXT(1, &m_fbo); - m_fbo = 0; - } - if (m_tex) - { - glDeleteTextures(1, &m_tex); - m_tex = 0; - } -} - -bool LICE_GLBitmap::FramebufferToGPU() -{ - if (BindFBO()) - { - if (m_bufloc == INMEM) - { - OutputDebugString("GL to GPU"); - glDisable(GL_BLEND); - glRasterPos2i(0, 0); - glDrawPixels(getWidth(), getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, m_bmp->getBits()); - } - m_bufloc = INGPU; - } - return (m_bufloc == INGPU); -} - -void LICE_GLBitmap::FramebufferFromGPU() -{ - if (m_bufloc == INGPU && BindFBO()) - { - OutputDebugString("GL to mem"); - glFinish(); - glReadPixels(0, 0, getWidth(), getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, m_bmp->getBits()); - } - m_bufloc = INMEM; -} - -INT_PTR LICE_GLBitmap::Extended(int id, void* data) -{ - if (id == LICE_EXT_SUPPORTS_ID) - { - int extid = (int) data; - if (extid == LICE_EXT_LINE_ACCEL) return 1; - if (extid == LICE_EXT_FILLRECT_ACCEL) return 1; - if (extid == LICE_EXT_DRAWCBEZIER_ACCEL) return 1; - if (extid == LICE_EXT_DRAWGLYPH_ACCEL) return 1; - if (extid == LICE_EXT_BLIT_ACCEL) return 1; - if (extid == LICE_EXT_SCALEDBLIT_ACCEL) return 1; - if (extid == LICE_EXT_GETFBOTEX_ACCEL) return 1; - if (extid == LICE_EXT_CLEAR_ACCEL) return 1; - if (extid == LICE_EXT_DASHEDLINE_ACCEL) return 1; - if (extid == LICE_EXT_GETPIXEL_ACCEL) return 1; - if (extid == LICE_EXT_PUTPIXEL_ACCEL) return 1; - if (extid == LICE_EXT_SETCLIP) return 1; - if (extid == LICE_EXT_WINDOW_BLIT) return 1; - if (extid == LICE_EXT_FORGET) return 1; - if (extid == LICE_EXT_DRAWTRIANGLE_ACCEL) return 1; - return 0; - } - - if (id == LICE_EXT_CLEAR_ACCEL) return Clear_accel((LICE_pixel*)data); - if (id == LICE_EXT_LINE_ACCEL) return Line_accel((LICE_Ext_Line_acceldata*)data); - if (id == LICE_EXT_FILLRECT_ACCEL) return FillRect_accel((LICE_Ext_FillRect_acceldata*) data); - if (id == LICE_EXT_DRAWCBEZIER_ACCEL) return DrawCBezier_accel((LICE_Ext_DrawCBezier_acceldata*)data); - if (id == LICE_EXT_DRAWGLYPH_ACCEL) return DrawGlyph_accel((LICE_Ext_DrawGlyph_acceldata*)data); - if (id == LICE_EXT_BLIT_ACCEL) return Blit_accel((LICE_Ext_Blit_acceldata*)data); - if (id == LICE_EXT_SCALEDBLIT_ACCEL) return ScaledBlit_accel((LICE_Ext_ScaledBlit_acceldata*)data); - if (id == LICE_EXT_DASHEDLINE_ACCEL) return DashedLine_accel((LICE_Ext_DashedLine_acceldata*)data); - if (id == LICE_EXT_GETPIXEL_ACCEL) return GetPixel_accel((LICE_Ext_GetPixel_acceldata*)data); - if (id == LICE_EXT_PUTPIXEL_ACCEL) return PutPixel_accel((LICE_Ext_PutPixel_acceldata*)data); - if (id == LICE_EXT_SETCLIP) return SetClip_ext((LICE_Ext_SetClip_data*)data); - if (id == LICE_EXT_DRAWTRIANGLE_ACCEL) return DrawTriangle_accel((LICE_Ext_DrawTriangle_acceldata*)data); - if (id == LICE_EXT_WINDOW_BLIT) return WindowBlit((LICE_Ext_WindowBlit_data*)data); - - if (id == LICE_EXT_FORGET) - { - m_bufloc = EMPTY; - return 1; - } - - if (id == LICE_EXT_GETFBOTEX_ACCEL) - { - if (FramebufferToGPU()) return m_tex; - return 0; - } - - return 0; -} - -static void SetGLAliasing(bool aa) -{ - if (aa) - { - glEnable(GL_LINE_SMOOTH); - } - else - { - glDisable(GL_LINE_SMOOTH); - } -} - -static void SetGLColor(LICE_pixel color, float alpha, int licemode) -{ - int a = 255; - if (licemode&LICE_BLIT_USE_ALPHA) a = LICE_GETA(color); - a = (float)a*alpha; - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - glColor4ub(LICE_GETB(color), LICE_GETG(color), LICE_GETR(color), a); - //glColor4ub(LICE_GETR(color), LICE_GETG(color), LICE_GETB(color), a); -} - -bool LICE_GLBitmap::Clear_accel(LICE_pixel* color) -{ - if (!color) return false; - LICE_pixel col = *color; - - if (!FramebufferToGPU()) return false; - - float r = (float)LICE_GETR(col)/255.0f; - float g = (float)LICE_GETG(col)/255.0f; - float b = (float)LICE_GETB(col)/255.0f; - float a = (float)LICE_GETA(col)/255.0f; - glClearColor(b, g, r, a); - //glClearColor(r, g, b, a); - glClear(GL_COLOR_BUFFER_BIT); - - return true; -} - -bool LICE_GLBitmap::Line_accel(LICE_Ext_Line_acceldata* p) -{ - if (!p) return false; - if (!FramebufferToGPU()) return false; - - SetGLColor(p->color, p->alpha, p->mode); - SetGLAliasing(p->aa); - - glBegin(GL_LINES); - - glVertex2f(p->x1, p->y1); - glVertex2f(p->x2, p->y2); - - glEnd(); - - return true; -} - -bool LICE_GLBitmap::DashedLine_accel(LICE_Ext_DashedLine_acceldata* p) -{ - if (!p) return false; - if (!FramebufferToGPU()) return false; - - SetGLColor(p->color, p->alpha, p->mode); - SetGLAliasing(p->aa); - - glEnable(GL_LINE_STIPPLE); - int n = (p->pxon+p->pxoff)/2; // todo properly when pxon != pxoff - glLineStipple(n, 0xAAAA); - - glBegin(GL_LINES); - - glVertex2f(p->x1, p->y1); - glVertex2f(p->x2, p->y2); - - glEnd(); - - glLineStipple(1, 65535); - glDisable(GL_LINE_STIPPLE); - - return true; -} - - -bool LICE_GLBitmap::FillRect_accel(LICE_Ext_FillRect_acceldata* p) -{ - if (!p) return false; - if (!FramebufferToGPU()) return false; - - SetGLColor(p->color, p->alpha, p->mode); - - glBegin(GL_POLYGON); - - glVertex2i(p->x, p->y); - glVertex2i(p->x+p->w, p->y); - glVertex2i(p->x+p->w, p->y+p->h); - glVertex2i(p->x, p->y+p->h); - - glEnd(); - - return true; -} - -bool LICE_GLBitmap::DrawCBezier_accel(LICE_Ext_DrawCBezier_acceldata* p) -{ - if (!p) return false; - if (!FramebufferToGPU()) return false; - - GLUnurbsObj* nurbs = LICE_GL_GetNurbsObj(); - if (!nurbs) return false; - -p->color = LICE_RGBA(255,255,255,255); // temp for easy ID of GL rendering - - SetGLColor(p->color, p->alpha, p->mode); - SetGLAliasing(p->aa); - - float ctlpts[] = - { - p->xstart, p->ystart, 0.0f, - p->xctl1, p->yctl1, 0.0f, - p->xctl2, p->yctl2, 0.0f, - p->xend, p->yend, 0.0f - }; - float knots[] = { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f }; - - gluBeginCurve(nurbs); - gluNurbsCurve(nurbs, 8, knots, 3, ctlpts, 4, GL_MAP1_VERTEX_3); - gluEndCurve(nurbs); - - return true; -} - -bool LICE_GLBitmap::DrawGlyph_accel(LICE_Ext_DrawGlyph_acceldata* p) -{ - if (!p) return false; - if (!FramebufferToGPU()) return false; - - glEnable(GL_TEXTURE_RECTANGLE_ARB); - - int texID = LICE_GL_GetTexFromGlyph(p->alphas, p->glyph_w, p->glyph_h); - if (!texID) return false; - - SetGLColor(p->color, p->alpha, p->mode); - - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texID); - glBegin(GL_POLYGON); - - glTexCoord2i(0, 0); - glVertex2i(p->x, p->y); - glTexCoord2i(p->glyph_w, 0); - glVertex2i(p->x+p->glyph_w, p->y); - glTexCoord2i(p->glyph_w, p->glyph_h); - glVertex2i(p->x+p->glyph_w, p->y+p->glyph_h); - glTexCoord2i(0, p->glyph_h); - glVertex2i(p->x, p->y+p->glyph_h); - - glEnd(); - - glDisable(GL_TEXTURE_RECTANGLE_ARB); - - return true; -} - -bool LICE_GLBitmap::Blit_accel(LICE_Ext_Blit_acceldata* p) -{ - if (!p || !p->src) return false; - if (!FramebufferToGPU()) return false; - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - GLuint src_tex = p->src->Extended(LICE_EXT_GETFBOTEX_ACCEL, 0); // this binds the src's FBO - if (src_tex) - { - if (!BindFBO()) return false; // re-bind dest FBO - - glEnable(GL_TEXTURE_RECTANGLE_ARB); - - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, src_tex); - glBegin(GL_POLYGON); - - glTexCoord2i(p->srcx, p->srcy); - glVertex2i(p->dstx, p->dsty); - glTexCoord2i(p->srcx+p->srcw, p->srcy); - glVertex2i(p->dstx+p->srcw, p->dsty); - glTexCoord2i(p->srcx+p->srcw, p->srcy+p->srch); - glVertex2i(p->dstx+p->srcw, p->dsty+p->srch); - glTexCoord2i(p->srcx, p->srcy+p->srch); - glVertex2i(p->dstx, p->dsty+p->srch); - - glEnd(); - - glDisable(GL_TEXTURE_RECTANGLE_ARB); - - return true; - } - - int srcspan = p->src->getRowSpan(); - if (p->srcx == 0 && p->srcy == 0 && p->srcw == srcspan) - { - glRasterPos2i(p->dstx, p->dsty); - glDrawPixels(p->srcw, p->srch, GL_RGBA, GL_UNSIGNED_BYTE, p->src->getBits()); - return true; - } - - LICE_pixel* srcrow = p->src->getBits()+p->srcy*srcspan+p->srcx; - int y; - for (y = 0; y < p->srch; ++y, srcrow += srcspan) - { - glRasterPos2i(p->dstx, p->dsty+y); - glDrawPixels(p->srcw, 1, GL_RGBA, GL_UNSIGNED_BYTE, srcrow); - } - return true; -} - -bool LICE_GLBitmap::ScaledBlit_accel(LICE_Ext_ScaledBlit_acceldata* p) -{ - if (!p || !p->src) return false; - if (!FramebufferToGPU()) return false; - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - glEnable(GL_TEXTURE_RECTANGLE_ARB); - - GLuint src_tex = p->src->Extended(LICE_EXT_GETFBOTEX_ACCEL, 0); // this binds the src's FBO - bool src_has_tex = (src_tex > 0); - if (src_has_tex) - { - if (!BindFBO()) return false; // re-bind dest FBO - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, src_tex); - } - else - { - // create texture from src bits - glGenTextures(1, &src_tex); - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, src_tex); - - int srcspan = p->src->getRowSpan(); - if (p->srcx == 0 && p->srcy == 0 && srcspan == p->srcw) - { - glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, p->srcw, p->srch, 0, GL_RGBA, GL_UNSIGNED_BYTE, p->src->getBits()); - } - else - { - glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, p->srcw, p->srch, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); // size the texture - LICE_pixel* srcrow = p->src->getBits()+(int)p->srcy*srcspan+(int)p->srcx; - int y; - for (y = 0; y < p->srch; ++y, srcrow += srcspan) - { - glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 0, y, p->srcw, 1, GL_RGBA, GL_UNSIGNED_BYTE, srcrow); - } - } - } - - if (!src_tex) return false; - - glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // filter - glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - - glBegin(GL_POLYGON); - - glTexCoord2i(p->srcx, p->srcy); - glVertex2i(p->dstx, p->dsty); - glTexCoord2i(p->srcx+p->srcw, p->srcy); - glVertex2i(p->dstx+p->dstw, p->dsty); - glTexCoord2i(p->srcx+p->srcw, p->srcy+p->srch); - glVertex2i(p->dstx+p->dstw, p->dsty+p->dsth); - glTexCoord2i(p->srcx, p->srcy+p->srch); - glVertex2i(p->dstx, p->dsty+p->dsth); - - glEnd(); - - if (!src_has_tex) glDeleteTextures(1, &src_tex); - - glDisable(GL_TEXTURE_RECTANGLE_ARB); - - return true; -} - -bool LICE_GLBitmap::GetPixel_accel(LICE_Ext_GetPixel_acceldata* p) -{ - if (!p) return false; - if (!FramebufferToGPU()) return false; - - p->px = 0; - glReadPixels(p->x, p->y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &p->px); - - return true; -} - -bool LICE_GLBitmap::PutPixel_accel(LICE_Ext_PutPixel_acceldata* p) -{ - if (!p) return false; - if (!FramebufferToGPU()) return false; - - SetGLColor(p->color, p->alpha, p->mode); - - glBegin(GL_POINTS); - glVertex2i(p->x, p->y); - glEnd(); - - return true; -} - -bool LICE_GLBitmap::DrawTriangle_accel(LICE_Ext_DrawTriangle_acceldata *p) -{ - if (!p) return false; - if (!FramebufferToGPU()) return false; - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - // todo: finish implementing zbuffering, (multi)texture mapping, alpha, etc - glColor4f(p->VertexShades[0][0], - p->VertexShades[0][1], - p->VertexShades[0][2], - p->mat->SolidOpacity); - - glBegin(GL_TRIANGLES); - - int x; - for(x=0;x<3;x++) - { - glVertex2i(p->scrx[x], p->scry[x]); - } - - glEnd(); - - return true; -} - -bool LICE_GLBitmap::WindowBlit(LICE_Ext_WindowBlit_data* p) -{ - if (!p) return false; - if (!FramebufferToGPU()) return false; - - HWND hwnd = p->hwnd; - if (hwnd != LICE_GL_GetWindow()) return 0; - - glFinish(); - - //HDC dc = GetDC(hwnd); - //HGLRC rc = wglCreateContext(dc); - //wglMakeCurrent(dc, rc); - - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - -/* - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluOrtho2D(0.0, w, 0.0, h); -*/ - glEnable(GL_TEXTURE_RECTANGLE_ARB); - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_tex); - - glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - - // the src image is upside down - // todo positioning - glBegin(GL_POLYGON); - glTexCoord2i(0, p->h); - glVertex2i(0, 0); - glTexCoord2i(p->w, p->h); - glVertex2i(p->w, 0); - glTexCoord2i(p->w, 0); - glVertex2i(p->w-1, p->h); - glTexCoord2i(0, 0); - glVertex2i(0, p->h); - glEnd(); - glDisable(GL_TEXTURE_RECTANGLE_ARB); - -//wglMakeCurrent(0, 0); -//wglDeleteContext(rc); - -// ReleaseDC(hwnd, dc); - - return true; -} diff --git a/oversampling/WDL/lice/lice_glbitmap.h b/oversampling/WDL/lice/lice_glbitmap.h deleted file mode 100644 index 46ec7b8..0000000 --- a/oversampling/WDL/lice/lice_glbitmap.h +++ /dev/null @@ -1,110 +0,0 @@ -#include "lice.h" -#include "lice_extended.h" - -// interface class for LICE_GL_SysBitmap and LICE_GL_MemBitmap -class LICE_GLBitmap : public LICE_IBitmap -{ -public: - - LICE_GLBitmap(); - ~LICE_GLBitmap(); - - LICE_pixel* getBits(); - - int getWidth(); - int getHeight(); - int getRowSpan(); - - bool resize(int w, int h); - - virtual HDC getDC() = 0; // re-virtualize this to prevent instantiating LICE_GLBitmap directly - - INT_PTR Extended(int id, void* data); - -private: - - bool Clear_accel(LICE_pixel* color); - bool Line_accel(LICE_Ext_Line_acceldata* p); - bool FillRect_accel(LICE_Ext_FillRect_acceldata* p); - bool DrawCBezier_accel(LICE_Ext_DrawCBezier_acceldata* p); - bool DrawGlyph_accel(LICE_Ext_DrawGlyph_acceldata* p); - bool Blit_accel(LICE_Ext_Blit_acceldata* p); - bool ScaledBlit_accel(LICE_Ext_ScaledBlit_acceldata* p); - bool DashedLine_accel(LICE_Ext_DashedLine_acceldata* p); - bool GetPixel_accel(LICE_Ext_GetPixel_acceldata* p); - bool PutPixel_accel(LICE_Ext_PutPixel_acceldata* p); - bool SetClip_ext(LICE_Ext_SetClip_data* p); - bool DrawTriangle_accel(LICE_Ext_DrawTriangle_acceldata *p); - // etc - - bool WindowBlit(LICE_Ext_WindowBlit_data* p); - - bool CreateFBO(int w, int h); - bool BindFBO(); // bind this FBO so it is the current rendering target, and test for validity - void ReleaseFBO(); - - unsigned int m_fbo; // framebuffer object: rendering target for drawing on this glbitmap - unsigned int m_tex; // texture object: backing store for this framebuffer object - - enum { EMPTY, INGPU, INMEM }; - int m_bufloc; // where is the current framebuffer? - LICE_IBitmap* m_bmp; - -protected: - - void Init(LICE_IBitmap* bmp, int w, int h); - bool FramebufferToGPU(); - void FramebufferFromGPU(); -}; - -class LICE_GL_SysBitmap : public LICE_GLBitmap -{ -public: - - LICE_GL_SysBitmap(int w=0, int h=0); - - HDC getDC(); - -private: - - LICE_SysBitmap m_sysbmp; -}; - - -class LICE_GL_MemBitmap : public LICE_GLBitmap -{ -public: - - LICE_GL_MemBitmap(int w=0, int h=0); - - HDC getDC() { return 0; } - -private: - - LICE_MemBitmap m_membmp; -}; - - -class LICE_GL_SubBitmap : public LICE_IBitmap -{ -public: - - LICE_GL_SubBitmap(LICE_IBitmap *parent, int x, int y, int w, int h); - - LICE_pixel* getBits(); - - int getWidth() { return m_w; } - int getHeight() { return m_h; } - int getRowSpan() { return (m_parent ? m_parent->getRowSpan() : 0); } - - bool resize(int w, int h); - - HDC getDC() { return (m_parent ? m_parent->getDC() : 0); } - - INT_PTR Extended(int id, void* data); - -private: - - LICE_IBitmap* m_parent; - int m_x, m_y, m_w, m_h; -}; diff --git a/oversampling/WDL/lice/lice_ico.cpp b/oversampling/WDL/lice/lice_ico.cpp deleted file mode 100644 index c3be7af..0000000 --- a/oversampling/WDL/lice/lice_ico.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/* - Cockos WDL - LICE - Lightweight Image Compositing Engine - Copyright (C) 2007 and later, Cockos Incorporated - File: lice_ico.cpp (ICO icon file loading for LICE) - See lice.h for license and other information - - This file contains some code from Microsoft's MSDN ICO loading sample - see: http://msdn2.microsoft.com/en-us/library/ms997538.aspx -*/ - -#include "lice.h" -#include "../wdltypes.h" -#ifndef _WIN32 -#include "../swell/swell.h" -#endif - -static LICE_IBitmap *icoToBitmap(HICON icon, LICE_IBitmap *bmpOut) -{ - int icon_w = 16, icon_h=16; - -#ifdef _WIN32 - ICONINFO ii={0,}; - if (GetIconInfo(icon,&ii)) - { - bool blah=false; - if (ii.hbmColor) - { - BITMAP bm={0,}; - if (GetObject(ii.hbmColor,sizeof(bm),&bm) && bm.bmWidth && bm.bmHeight) - { - icon_w=bm.bmWidth; - icon_h=bm.bmHeight; - blah=true; - } - DeleteObject(ii.hbmColor); - } - if (ii.hbmMask) - { - BITMAP bm={0,}; - if (!blah && GetObject(ii.hbmMask,sizeof(bm),&bm) && bm.bmWidth && bm.bmHeight) - { - icon_w=bm.bmWidth; - icon_h=bm.bmHeight; - } - DeleteObject(ii.hbmMask); - } - } -#else - BITMAP bm={0,}; - if (GetObject(icon,sizeof(bm),&bm) && bm.bmWidth && bm.bmHeight) // SWELL's GetObject() works on icons - { - icon_w=bm.bmWidth; - icon_h=bm.bmHeight; - } - -#endif - - LICE_SysBitmap tempbm(icon_w*2,icon_h); - LICE_FillRect(&tempbm,0,0,icon_w,icon_h,LICE_RGBA(0,0,0,255),1.0f,LICE_BLIT_MODE_COPY); -#ifdef _WIN32 - DrawIconEx(tempbm.getDC(),0,0,icon,icon_w,icon_h,0,NULL,DI_NORMAL); -#else - { - RECT r={0,0,icon_w,icon_h}; - DrawImageInRect(tempbm.getDC(),icon,&r); - } -#endif - - LICE_FillRect(&tempbm,icon_w,0,icon_w,icon_h,LICE_RGBA(255,255,255,255),1.0f,LICE_BLIT_MODE_COPY); -#ifdef _WIN32 - DrawIconEx(tempbm.getDC(),icon_w,0,icon,icon_w,icon_h,0,NULL,DI_NORMAL); -#else - { - RECT r={icon_w,0,icon_w+icon_w,icon_h}; - DrawImageInRect(tempbm.getDC(),icon,&r); - } -#endif - - if (!bmpOut) bmpOut = new WDL_NEW LICE_MemBitmap(icon_w,icon_h); - else bmpOut->resize(icon_w,icon_h); - - int y; // since we have the image drawn on white and on black, we can calculate the alpha channel... - if (bmpOut) for(y=0;y=255) alpha=255; - else if (alpha>0) - { - r1 = (r1*255)/alpha; // LICE stores its alpha channel non-premultiplied, so we need to scale these up. - g1 = (g1*255)/alpha; - b1 = (b1*255)/alpha; - if (r1>255)r1=255; - if (g1>255)g1=255; - if (b1>255)b1=255; - } - else alpha=0; - LICE_PutPixel(bmpOut,x,y,LICE_RGBA(r1,g1,b1,alpha),1.0f,LICE_BLIT_MODE_COPY); - } - } - - return bmpOut; -} - -LICE_IBitmap *LICE_LoadIcon(const char *filename, int reqiconsz, LICE_IBitmap *bmp) // returns a bitmap (bmp if nonzero) on success -{ - if (reqiconsz<1) reqiconsz=16; - HICON icon = NULL; -#ifdef _WIN32 - -#ifndef WDL_NO_SUPPORT_UTF8 - #ifdef WDL_SUPPORT_WIN9X - if (GetVersion()<0x80000000) - #endif - { - WCHAR wf[2048]; - if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,filename,-1,wf,2048)) - icon = (HICON)LoadImageW(NULL,wf,IMAGE_ICON,reqiconsz,reqiconsz,LR_LOADFROMFILE); - } -#endif - - if (!icon) icon = (HICON)LoadImage(NULL,filename,IMAGE_ICON,reqiconsz,reqiconsz,LR_LOADFROMFILE); - -#else - icon = (HICON)LoadNamedImage(filename,false); -#endif - if (!icon) return 0; - - LICE_IBitmap *ret=icoToBitmap(icon,bmp); - DestroyIcon(icon); - return ret; -} - -LICE_IBitmap *LICE_LoadIconFromResource(HINSTANCE hInst, const char *resid, int reqiconsz, LICE_IBitmap *bmp) // returns a bitmap (bmp if nonzero) on success -{ -#ifdef _WIN32 - if (reqiconsz<1) reqiconsz=16; - HICON icon = (HICON)LoadImage(hInst,resid,IMAGE_ICON,reqiconsz,reqiconsz,0); - if (!icon) return 0; - - LICE_IBitmap *ret=icoToBitmap(icon,bmp); - DestroyIcon(icon); - return ret; -#else - return 0; -#endif -} - - - - -class LICE_ICOLoader -{ -public: - _LICE_ImageLoader_rec rec; - LICE_ICOLoader() - { - rec.loadfunc = loadfunc; - rec.get_extlist = get_extlist; - rec._next = LICE_ImageLoader_list; - LICE_ImageLoader_list = &rec; - } - - static LICE_IBitmap *loadfunc(const char *filename, bool checkFileName, LICE_IBitmap *bmpbase) - { - if (checkFileName) - { - const char *p=filename; - while (*p)p++; - while (p>filename && *p != '\\' && *p != '/' && *p != '.') p--; - if (stricmp(p,".ico")) return 0; - } - return LICE_LoadIcon(filename,16,bmpbase); - } - static const char *get_extlist() - { - return "ICO files (*.ICO)\0*.ICO\0"; - } - -}; - -LICE_ICOLoader LICE_icoldr; diff --git a/oversampling/WDL/lice/lice_image.cpp b/oversampling/WDL/lice/lice_image.cpp deleted file mode 100644 index 93bd063..0000000 --- a/oversampling/WDL/lice/lice_image.cpp +++ /dev/null @@ -1,147 +0,0 @@ -#include "lice.h" - - - -LICE_IBitmap* LICE_LoadImage(const char* filename, LICE_IBitmap* bmp, bool tryIgnoreExtension) -{ - _LICE_ImageLoader_rec *hdr = LICE_ImageLoader_list; - while (hdr) - { - LICE_IBitmap *ret = hdr->loadfunc(filename,true,bmp); - if (ret) return ret; - hdr=hdr->_next; - } - if (tryIgnoreExtension) - { - hdr = LICE_ImageLoader_list; - while (hdr) - { - LICE_IBitmap *ret = hdr->loadfunc(filename,false,bmp); - if (ret) return ret; - hdr=hdr->_next; - } - } - - return 0; -} - - -static bool grow_buf(char **buf, int *bufsz, int *wrpos, const char *rd, int len) -{ - if (*wrpos + len > *bufsz) - { - char *nbuf=(char*)realloc(*buf,*bufsz = *wrpos+len+4096); - if (!nbuf) return true; // ugh - *buf = nbuf; - } - memcpy(*buf+*wrpos,rd,len); - *wrpos+=len; - return false; -} - -char *LICE_GetImageExtensionList(bool wantAllSup, bool wantAllFiles) -{ - _LICE_ImageLoader_rec *hdr = LICE_ImageLoader_list; - int bufsz=4096; - int wrpos=0; - char *buf=(char *)malloc(bufsz); - buf[0]=buf[1]=buf[2]=0; - - if (wantAllSup) - { - static const char af[]="All supported images"; - if (grow_buf(&buf,&bufsz,&wrpos,af,sizeof(af))) { free(buf); return NULL; } // fail - - int cnt=0; - while (hdr) - { - const char *rd = hdr->get_extlist(); - if (rd && *rd) - { - bool st=false; - const char *p=rd; - while (*p) - { - if (st) - { - if (cnt++) - if (grow_buf(&buf,&bufsz,&wrpos,";",1)) { free(buf); return NULL; } // fail - if (grow_buf(&buf,&bufsz,&wrpos,p,(int)strlen(p)+1)) { free(buf); return NULL; } // fail - wrpos--; - } - while (*p) p++; - p++; - st=!st; - } - } - hdr=hdr->_next; - } - - if (!cnt) - { - wrpos=0; // reset if nothing meaningful added - buf[0]=buf[1]=buf[2]=0; - } - else wrpos++; - - hdr = LICE_ImageLoader_list; - } - - while (hdr) - { - const char *rd = hdr->get_extlist(); - if (rd && *rd) - { - int len = 0; - while (rd[len] || rd[len+1]) len++; // doublenull terminated list - - if (len) - { - if (grow_buf(&buf, &bufsz, &wrpos, rd, len+2)) return buf; // fail - wrpos--; // remove doublenull on next round - } - } - hdr=hdr->_next; - } - if (wantAllFiles) - { - static const char af[]="All files (*.*)\0*.*\0"; - if (grow_buf(&buf,&bufsz,&wrpos,af,sizeof(af))) return buf; // fail - wrpos--; - } - - return buf; -} - -bool LICE_ImageIsSupported(const char *filename) -{ - const char *extension = filename; - while (*extension)extension++; - while (extension>=filename && *extension != '/' && *extension != '.' && *extension != '\\') extension--; - if (extensionget_extlist(); - if (el) - { - while (*el) el++; // skip desc - ++el; - - // scan rest of buffer - while (*el) - { - if (!strnicmp(el,extension,extlen)) - { - if (el[extlen] == 0|| el[extlen] == ';') return true; - } - el++; - } - } - hdr=hdr->_next; - } - return false; -} diff --git a/oversampling/WDL/lice/lice_import.h b/oversampling/WDL/lice/lice_import.h deleted file mode 100644 index 17876a1..0000000 --- a/oversampling/WDL/lice/lice_import.h +++ /dev/null @@ -1,84 +0,0 @@ -#define LICE_TEXT_NO_DECLARE_CACHEDFONT - -#ifdef LICE_IMPORT_INTERFACE_ONLY -#define LICE_FUNC_DEF_DECL extern -#else -#define LICE_FUNC_DEF_DECL -#endif - -#include "lice_text.h" -LICE_FUNC_DEF_DECL LICE_IBitmap *(*__LICE_CreateBitmap)(int, int, int); -LICE_FUNC_DEF_DECL void (*__LICE_PutPixel)(LICE_IBitmap* dest, int x, int y, LICE_pixel color, float alpha, int mode); -LICE_FUNC_DEF_DECL void (*__LICE_Line)(LICE_IBitmap *dest, int x1, int y1, int x2, int y2, LICE_pixel color, float alpha, int mode, bool aa); -LICE_FUNC_DEF_DECL void (*__LICE_FLine)(LICE_IBitmap *dest, float x1, float y1, float x2, float y2, LICE_pixel color, float alpha, int mode, bool aa); -LICE_FUNC_DEF_DECL void (*__LICE_DashedLine)(LICE_IBitmap *dest, int x1, int y1, int x2, int y2, int on, int off, LICE_pixel color, float alpha, int mode, bool aa); -LICE_FUNC_DEF_DECL void (*__LICE_FillRect)(LICE_IBitmap *dest, int x, int y, int w, int h, LICE_pixel color, float alpha , int mode); -LICE_FUNC_DEF_DECL void (*__LICE_DrawRect)(LICE_IBitmap *dest, int x, int y, int w, int h, LICE_pixel color, float alpha , int mode); -LICE_FUNC_DEF_DECL void (*__LICE_BorderedRect)(LICE_IBitmap *dest, int x, int y, int w, int h, LICE_pixel bgcolor, LICE_pixel fgcolor, float alpha, int mode); -LICE_FUNC_DEF_DECL void (*__LICE_Circle)(LICE_IBitmap* dest, float cx, float cy, float r, LICE_pixel color, float alpha, int mode, bool aa); -LICE_FUNC_DEF_DECL void (*__LICE_FillCircle)(LICE_IBitmap* dest, float cx, float cy, float r, LICE_pixel color, float alpha, int mode, bool aa); -LICE_FUNC_DEF_DECL void (*__LICE_Clear)(LICE_IBitmap *dest, LICE_pixel color); -LICE_FUNC_DEF_DECL void (*__LICE_Blit)(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, int srcx, int srcy, int srcw, int srch, float alpha, int mode); -LICE_FUNC_DEF_DECL void (*__LICE_RotatedBlit)(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, int dstw, int dsth, float srcx, float srcy, float srcw, float srch, float angle, bool cliptosourcerect, float alpha, int mode, float rotxcent, float rotycent); -LICE_FUNC_DEF_DECL void (*__LICE_DrawGlyph)(LICE_IBitmap* dest, int x, int y, LICE_pixel color, LICE_pixel_chan* glyph, int glyph_w, int glyph_h, float alpha, int mode); -LICE_FUNC_DEF_DECL void (*__LICE_FillTriangle)(LICE_IBitmap *dest, int x1, int y1, int x2, int y2, int x3, int y3, LICE_pixel color, float alpha, int mode); -LICE_FUNC_DEF_DECL void (*__LICE_Arc)(LICE_IBitmap* dest, float cx, float cy, float r, float alo, float ahi, LICE_pixel color, float alpha, int mode, bool aa); -LICE_FUNC_DEF_DECL void (*__LICE_FillTrapezoid)(LICE_IBitmap* dest, int x1a, int x1b, int y1, int x2a, int x2b, int y2, LICE_pixel color, float alpha, int mode); -LICE_FUNC_DEF_DECL void (*__LICE_FillConvexPolygon)(LICE_IBitmap* dest, int* x, int* y, int npoints, LICE_pixel color, float alpha, int mode); -LICE_FUNC_DEF_DECL void (*__LICE_Copy)(LICE_IBitmap* dest, LICE_IBitmap* src); -LICE_FUNC_DEF_DECL void (*__LICE_DrawText)(LICE_IBitmap *bm, int x, int y, const char *string, LICE_pixel color, float alpha, int mode); -LICE_FUNC_DEF_DECL void (*__LICE_MeasureText)(const char *string, int *w, int *h); -LICE_FUNC_DEF_DECL void (*__LICE_ScaledBlit)(LICE_IBitmap *dest, LICE_IBitmap *src, int dstx, int dsty, int dstw, int dsth, float srcx, float srcy, float srcw, float srch, float alpha, int mode); - -LICE_FUNC_DEF_DECL void * (*LICE_CreateFont)(); -#define LICE_PutPixel __LICE_PutPixel -#define LICE_Line __LICE_Line -#define LICE_FLine __LICE_FLine -#define LICE_DashedLine __LICE_DashedLine -#define LICE_FillRect __LICE_FillRect -#define LICE_DrawRect __LICE_DrawRect -#define LICE_Circle __LICE_Circle -#define LICE_Clear __LICE_Clear -#define LICE_Blit __LICE_Blit -#define LICE_RotatedBlit __LICE_RotatedBlit -#define LICE_DrawGlyph __LICE_DrawGlyph -#define LICE_FillCircle __LICE_FillCircle -#define LICE_BorderedRect __LICE_BorderedRect -#define LICE_FillTriangle __LICE_FillTriangle -#define LICE_Arc __LICE_Arc -#define LICE_FillTrapezoid __LICE_FillTrapezoid -#define LICE_FillConvexPolygon __LICE_FillConvexPolygon -#define LICE_Copy __LICE_Copy -#define LICE_DrawText __LICE_DrawText -#define LICE_MeasureText __LICE_MeasureText -#define LICE_ScaledBlit __LICE_ScaledBlit -#define LICE_CreateMemBitmap(w,h) (__LICE_CreateBitmap ? __LICE_CreateBitmap(0,w,h) : 0) -#define LICE_CreateSysBitmap(w,h) (__LICE_CreateBitmap ? __LICE_CreateBitmap(1,w,h) : 0) -#define LICE_CreateTextCache() ((LICE_IFont*)(LICE_CreateFont?LICE_CreateFont():0)) -#undef LICE_FUNC_DEF_DECL - -#define IMPORT_LICE_FUNCS(IMPORT_FUNC) \ - IMPORT_FUNC(__LICE_CreateBitmap,"LICE_CreateBitmap") \ - IMPORT_FUNC(__LICE_PutPixel,"LICE_PutPixel") \ - IMPORT_FUNC(__LICE_Line,"LICE_LineInt") \ - IMPORT_FUNC(__LICE_FLine,"LICE_Line") \ - IMPORT_FUNC(__LICE_DashedLine, "LICE_DashedLine") \ - IMPORT_FUNC(__LICE_Circle,"LICE_Circle") \ - IMPORT_FUNC(__LICE_FillCircle,"LICE_FillCircle") \ - IMPORT_FUNC(__LICE_FillRect,"LICE_FillRect") \ - IMPORT_FUNC(__LICE_DrawRect,"LICE_DrawRect") \ - IMPORT_FUNC(__LICE_BorderedRect,"LICE_BorderedRect") \ - IMPORT_FUNC(__LICE_Clear,"LICE_Clear") \ - IMPORT_FUNC(__LICE_Blit,"LICE_Blit") \ - IMPORT_FUNC(__LICE_RotatedBlit,"LICE_RotatedBlit") \ - IMPORT_FUNC(__LICE_DrawGlyph,"LICE_DrawGlyph") \ - IMPORT_FUNC(LICE_CreateFont,"LICE_CreateFont") \ - IMPORT_FUNC(LICE_FillTriangle,"LICE_FillTriangle") \ - IMPORT_FUNC(LICE_Arc,"LICE_Arc") \ - IMPORT_FUNC(LICE_FillTrapezoid,"LICE_FillTrapezoid") \ - IMPORT_FUNC(LICE_FillConvexPolygon,"LICE_FillConvexPolygon") \ - IMPORT_FUNC(LICE_Copy,"LICE_Copy") \ - IMPORT_FUNC(__LICE_ScaledBlit,"LICE_ScaledBlit") \ - IMPORT_FUNC(__LICE_MeasureText,"LICE_MeasureText") \ - IMPORT_FUNC(__LICE_DrawText,"LICE_DrawText") - diff --git a/oversampling/WDL/lice/lice_jpg.cpp b/oversampling/WDL/lice/lice_jpg.cpp deleted file mode 100644 index eebff49..0000000 --- a/oversampling/WDL/lice/lice_jpg.cpp +++ /dev/null @@ -1,404 +0,0 @@ -/* - Cockos WDL - LICE - Lightweight Image Compositing Engine - Copyright (C) 2007 and later, Cockos Incorporated - File: lice_jpg.cpp (JPG loading for LICE) - See lice.h for license and other information -*/ - -#include -#include "lice.h" -#include -#include "../wdltypes.h" - -extern "C" { -#include "../jpeglib/jpeglib.h" -}; - -struct my_error_mgr { - struct jpeg_error_mgr pub; /* "public" fields */ - jmp_buf setjmp_buffer; /* for return to caller */ -}; -static void LICEJPEG_Error(j_common_ptr cinfo) -{ - longjmp(((my_error_mgr*)cinfo->err)->setjmp_buffer,1); -} -static void LICEJPEG_EmitMsg(j_common_ptr cinfo, int msg_level) { } -static void LICEJPEG_FmtMsg(j_common_ptr cinfo, char *) { } -static void LICEJPEG_OutMsg(j_common_ptr cinfo) { } -static void LICEJPEG_reset_error_mgr(j_common_ptr cinfo) -{ - cinfo->err->num_warnings = 0; - cinfo->err->msg_code = 0; -} - -#ifdef _WIN32 -static void LICEJPEG_init_source(j_decompress_ptr cinfo) {} -static unsigned char EOI_data[2] = { 0xFF, 0xD9 }; -static boolean LICEJPEG_fill_input_buffer(j_decompress_ptr cinfo) -{ - cinfo->src->next_input_byte = EOI_data; - cinfo->src->bytes_in_buffer = 2; - return TRUE; -} -static void LICEJPEG_skip_input_data(j_decompress_ptr cinfo, long num_bytes) -{ - if (num_bytes > 0) - { - if (num_bytes > (long) cinfo->src->bytes_in_buffer) - { - num_bytes = (long) cinfo->src->bytes_in_buffer; - } - cinfo->src->next_input_byte += (size_t) num_bytes; - cinfo->src->bytes_in_buffer -= (size_t) num_bytes; - } -} -static void LICEJPEG_term_source(j_decompress_ptr cinfo) {} -#endif - - -LICE_IBitmap *LICE_LoadJPGFromResource(HINSTANCE hInst, const char *resid, LICE_IBitmap *bmp) -{ -#ifdef _WIN32 - HRSRC hResource = FindResource(hInst, resid, "JPG"); - if(!hResource) return NULL; - - DWORD imageSize = SizeofResource(hInst, hResource); - if(imageSize < 8) return NULL; - - HGLOBAL res = LoadResource(hInst, hResource); - const void* pResourceData = LockResource(res); - if(!pResourceData) return NULL; - - unsigned char *data = (unsigned char *)pResourceData; - - struct jpeg_decompress_struct cinfo; - struct my_error_mgr jerr={0,}; - JSAMPARRAY buffer; - int row_stride; - - jerr.pub.error_exit = LICEJPEG_Error; - jerr.pub.emit_message = LICEJPEG_EmitMsg; - jerr.pub.output_message = LICEJPEG_OutMsg; - jerr.pub.format_message = LICEJPEG_FmtMsg; - jerr.pub.reset_error_mgr = LICEJPEG_reset_error_mgr; - - cinfo.err = &jerr.pub; - - if (setjmp(jerr.setjmp_buffer)) - { - jpeg_destroy_decompress(&cinfo); - return 0; - } - jpeg_create_decompress(&cinfo); - - cinfo.src = (struct jpeg_source_mgr *) (*cinfo.mem->alloc_small) ((j_common_ptr) &cinfo, JPOOL_PERMANENT, sizeof (struct jpeg_source_mgr)); - - cinfo.src->init_source = LICEJPEG_init_source; - cinfo.src->fill_input_buffer = LICEJPEG_fill_input_buffer; - cinfo.src->skip_input_data = LICEJPEG_skip_input_data; - cinfo.src->resync_to_restart = jpeg_resync_to_restart; - cinfo.src->term_source = LICEJPEG_term_source; - - cinfo.src->next_input_byte = data; - cinfo.src->bytes_in_buffer = imageSize; - - jpeg_read_header(&cinfo, TRUE); - jpeg_start_decompress(&cinfo); - - row_stride = cinfo.output_width * cinfo.output_components; - - buffer = (*cinfo.mem->alloc_sarray) ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); - - LICE_IBitmap *delbmp = NULL; - if (bmp) bmp->resize(cinfo.output_width,cinfo.output_height); - else delbmp = bmp = new WDL_NEW LICE_MemBitmap(cinfo.output_width,cinfo.output_height); - - if (!bmp || bmp->getWidth() != (int)cinfo.output_width || bmp->getHeight() != (int)cinfo.output_height) - { - jpeg_finish_decompress(&cinfo); - jpeg_destroy_decompress(&cinfo); - delete delbmp; - return 0; - } - - LICE_pixel *bmpptr = bmp->getBits(); - int dbmpptr=bmp->getRowSpan(); - if (bmp->isFlipped()) - { - bmpptr += dbmpptr*(bmp->getHeight()-1); - dbmpptr=-dbmpptr; - } - - while (cinfo.output_scanline < cinfo.output_height) - { - /* jpeg_read_scanlines expects an array of pointers to scanlines. - * Here the array is only one element long, but you could ask for - * more than one scanline at a time if that's more convenient. - */ - jpeg_read_scanlines(&cinfo, buffer, 1); - /* Assume put_scanline_someplace wants a pointer and sample count. */ -// put_scanline_someplace(buffer[0], row_stride); - if (cinfo.output_components==3) - { - int x; - for (x = 0; x < (int)cinfo.output_width; x++) - { - bmpptr[x]=LICE_RGBA(buffer[0][x*3],buffer[0][x*3+1],buffer[0][x*3+2],255); - } - } - else if (cinfo.output_components==1) - { - int x; - for (x = 0; x < (int)cinfo.output_width; x++) - { - int v=buffer[0][x]; - bmpptr[x]=LICE_RGBA(v,v,v,255); - } - } - else - { - memset(bmpptr,0,4*cinfo.output_width); - } - bmpptr+=dbmpptr; - } - - jpeg_finish_decompress(&cinfo); - jpeg_destroy_decompress(&cinfo); // we created cinfo.src with some special alloc so I think it gets collected - - return bmp; - -#else - return 0; -#endif -} - - -LICE_IBitmap *LICE_LoadJPG(const char *filename, LICE_IBitmap *bmp) -{ - struct jpeg_decompress_struct cinfo; - struct my_error_mgr jerr={{0},}; - JSAMPARRAY buffer; - int row_stride; - - FILE *fp=NULL; -#if defined(_WIN32) && !defined(WDL_NO_SUPPORT_UTF8) - #ifdef WDL_SUPPORT_WIN9X - if (GetVersion()<0x80000000) - #endif - { - WCHAR wf[2048]; - if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,filename,-1,wf,2048)) - fp = _wfopen(wf,L"rb"); - } -#endif - if (!fp) fp = WDL_fopenA(filename,"rb"); - - if (!fp) return 0; - - jerr.pub.error_exit = LICEJPEG_Error; - jerr.pub.emit_message = LICEJPEG_EmitMsg; - jerr.pub.output_message = LICEJPEG_OutMsg; - jerr.pub.format_message = LICEJPEG_FmtMsg; - jerr.pub.reset_error_mgr = LICEJPEG_reset_error_mgr; - - cinfo.err = &jerr.pub; - - if (setjmp(jerr.setjmp_buffer)) - { - jpeg_destroy_decompress(&cinfo); - fclose(fp); - return 0; - } - jpeg_create_decompress(&cinfo); - - jpeg_stdio_src(&cinfo, fp); - jpeg_read_header(&cinfo, TRUE); - jpeg_start_decompress(&cinfo); - - row_stride = cinfo.output_width * cinfo.output_components; - - buffer = (*cinfo.mem->alloc_sarray) - ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); - - - LICE_IBitmap *delbmp = NULL; - if (bmp) bmp->resize(cinfo.output_width,cinfo.output_height); - else delbmp = bmp = new WDL_NEW LICE_MemBitmap(cinfo.output_width,cinfo.output_height); - - if (!bmp || bmp->getWidth() != (int)cinfo.output_width || bmp->getHeight() != (int)cinfo.output_height) - { - jpeg_finish_decompress(&cinfo); - jpeg_destroy_decompress(&cinfo); - fclose(fp); - delete delbmp; - return 0; - } - - LICE_pixel *bmpptr = bmp->getBits(); - int dbmpptr=bmp->getRowSpan(); - if (bmp->isFlipped()) - { - bmpptr += dbmpptr*(bmp->getHeight()-1); - dbmpptr=-dbmpptr; - } - - while (cinfo.output_scanline < cinfo.output_height) { - /* jpeg_read_scanlines expects an array of pointers to scanlines. - * Here the array is only one element long, but you could ask for - * more than one scanline at a time if that's more convenient. - */ - jpeg_read_scanlines(&cinfo, buffer, 1); - /* Assume put_scanline_someplace wants a pointer and sample count. */ -// put_scanline_someplace(buffer[0], row_stride); - if (cinfo.output_components==3) - { - int x; - for (x = 0; x < (int)cinfo.output_width; x++) - { - bmpptr[x]=LICE_RGBA(buffer[0][x*3],buffer[0][x*3+1],buffer[0][x*3+2],255); - } - } - else if (cinfo.output_components==1) - { - int x; - for (x = 0; x < (int)cinfo.output_width; x++) - { - int v=buffer[0][x]; - bmpptr[x]=LICE_RGBA(v,v,v,255); - } - } - else - memset(bmpptr,0,4*cinfo.output_width); - bmpptr+=dbmpptr; - } - - jpeg_finish_decompress(&cinfo); - jpeg_destroy_decompress(&cinfo); - fclose(fp); - - return bmp; -} - -LICE_IBitmap *LICE_LoadJPGFromMemory(const void *data_in, int buflen, LICE_IBitmap *bmp) -{ - if (buflen < 8) return NULL; - - unsigned char *data = (unsigned char *)(void *)data_in; - - struct jpeg_decompress_struct cinfo; - struct my_error_mgr jerr={{0},}; - JSAMPARRAY buffer; - int row_stride; - - jerr.pub.error_exit = LICEJPEG_Error; - jerr.pub.emit_message = LICEJPEG_EmitMsg; - jerr.pub.output_message = LICEJPEG_OutMsg; - jerr.pub.format_message = LICEJPEG_FmtMsg; - jerr.pub.reset_error_mgr = LICEJPEG_reset_error_mgr; - - cinfo.err = &jerr.pub; - - if (setjmp(jerr.setjmp_buffer)) - { - jpeg_destroy_decompress(&cinfo); - return 0; - } - jpeg_create_decompress(&cinfo); - - jpeg_mem_src(&cinfo, data, buflen); - jpeg_read_header(&cinfo, TRUE); - jpeg_start_decompress(&cinfo); - - row_stride = cinfo.output_width * cinfo.output_components; - - buffer = (*cinfo.mem->alloc_sarray) - ((j_common_ptr) &cinfo, JPOOL_IMAGE, row_stride, 1); - - - LICE_IBitmap *delbmp = NULL; - if (bmp) bmp->resize(cinfo.output_width,cinfo.output_height); - else delbmp = bmp = new WDL_NEW LICE_MemBitmap(cinfo.output_width,cinfo.output_height); - - if (!bmp || bmp->getWidth() != (int)cinfo.output_width || bmp->getHeight() != (int)cinfo.output_height) - { - jpeg_finish_decompress(&cinfo); - jpeg_destroy_decompress(&cinfo); - delete delbmp; - return 0; - } - - LICE_pixel *bmpptr = bmp->getBits(); - int dbmpptr=bmp->getRowSpan(); - if (bmp->isFlipped()) - { - bmpptr += dbmpptr*(bmp->getHeight()-1); - dbmpptr=-dbmpptr; - } - - while (cinfo.output_scanline < cinfo.output_height) { - /* jpeg_read_scanlines expects an array of pointers to scanlines. - * Here the array is only one element long, but you could ask for - * more than one scanline at a time if that's more convenient. - */ - jpeg_read_scanlines(&cinfo, buffer, 1); - /* Assume put_scanline_someplace wants a pointer and sample count. */ -// put_scanline_someplace(buffer[0], row_stride); - if (cinfo.output_components==3) - { - int x; - for (x = 0; x < (int)cinfo.output_width; x++) - { - bmpptr[x]=LICE_RGBA(buffer[0][x*3],buffer[0][x*3+1],buffer[0][x*3+2],255); - } - } - else if (cinfo.output_components==1) - { - int x; - for (x = 0; x < (int)cinfo.output_width; x++) - { - int v=buffer[0][x]; - bmpptr[x]=LICE_RGBA(v,v,v,255); - } - } - else - memset(bmpptr,0,4*cinfo.output_width); - bmpptr+=dbmpptr; - } - - jpeg_finish_decompress(&cinfo); - jpeg_destroy_decompress(&cinfo); - - return bmp; -} - -class LICE_JPGLoader -{ -public: - _LICE_ImageLoader_rec rec; - LICE_JPGLoader() - { - rec.loadfunc = loadfunc; - rec.get_extlist = get_extlist; - rec._next = LICE_ImageLoader_list; - LICE_ImageLoader_list = &rec; - } - - static LICE_IBitmap *loadfunc(const char *filename, bool checkFileName, LICE_IBitmap *bmpbase) - { - if (checkFileName) - { - const char *p=filename; - while (*p)p++; - while (p>filename && *p != '\\' && *p != '/' && *p != '.') p--; - if (stricmp(p,".jpg")&&stricmp(p,".jpeg")&&stricmp(p,".jfif")) return 0; - } - return LICE_LoadJPG(filename,bmpbase); - } - static const char *get_extlist() - { - return "JPEG files (*.JPG;*.JPEG;*.JFIF)\0*.JPG;*.JPEG;*.JFIF\0"; - } - -}; - -LICE_JPGLoader LICE_jgpldr; diff --git a/oversampling/WDL/lice/lice_jpg_write.cpp b/oversampling/WDL/lice/lice_jpg_write.cpp deleted file mode 100644 index 0f8621e..0000000 --- a/oversampling/WDL/lice/lice_jpg_write.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - Cockos WDL - LICE - Lightweight Image Compositing Engine - Copyright (C) 2007 and later, Cockos Incorporated - File: lice_jpg_write.cpp (JPG writing for LICE) - See lice.h for license and other information -*/ - -#include -#include "lice.h" -#include - -extern "C" { -#include "../jpeglib/jpeglib.h" -}; - -struct my_error_mgr { - struct jpeg_error_mgr pub; /* "public" fields */ - jmp_buf setjmp_buffer; /* for return to caller */ -}; -static void LICEJPEG_Error(j_common_ptr cinfo) -{ - longjmp(((my_error_mgr*)cinfo->err)->setjmp_buffer,1); -} -static void LICEJPEG_EmitMsg(j_common_ptr cinfo, int msg_level) { } -static void LICEJPEG_FmtMsg(j_common_ptr cinfo, char *) { } -static void LICEJPEG_OutMsg(j_common_ptr cinfo) { } -static void LICEJPEG_reset_error_mgr(j_common_ptr cinfo) -{ - cinfo->err->num_warnings = 0; - cinfo->err->msg_code = 0; -} - -bool LICE_WriteJPG(const char *filename, LICE_IBitmap *bmp, int quality, bool force_baseline) -{ - if (!bmp || !filename) return false; - - FILE *fp=NULL; -#if defined(_WIN32) && !defined(WDL_NO_SUPPORT_UTF8) - #ifdef WDL_SUPPORT_WIN9X - if (GetVersion()<0x80000000) - #endif - { - WCHAR wf[2048]; - if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,filename,-1,wf,2048)) - fp = _wfopen(wf,L"wb"); - } -#endif - if (!fp) fp = fopen(filename,"wb"); - - if (!fp) return false; - - struct jpeg_compress_struct cinfo; - struct my_error_mgr jerr={0,}; - jerr.pub.error_exit = LICEJPEG_Error; - jerr.pub.emit_message = LICEJPEG_EmitMsg; - jerr.pub.output_message = LICEJPEG_OutMsg; - jerr.pub.format_message = LICEJPEG_FmtMsg; - jerr.pub.reset_error_mgr = LICEJPEG_reset_error_mgr; - - cinfo.err = &jerr.pub; - unsigned char *buf = NULL; - - if (setjmp(jerr.setjmp_buffer)) - { - jpeg_destroy_compress(&cinfo); - if (fp) fclose(fp); - free(buf); - return false; - } - jpeg_create_compress(&cinfo); - - jpeg_stdio_dest(&cinfo, fp); - - cinfo.image_width = bmp->getWidth(); /* image width and height, in pixels */ - cinfo.image_height = bmp->getHeight(); - cinfo.input_components = 3; /* # of color components per pixel */ - cinfo.in_color_space = JCS_RGB; /* colorspace of input image */ - - jpeg_set_defaults(&cinfo); - jpeg_set_quality(&cinfo, quality, !!force_baseline); - jpeg_start_compress(&cinfo, TRUE); - - buf = (unsigned char *)malloc(cinfo.image_width * 3); - LICE_pixel_chan *rd = (LICE_pixel_chan *)bmp->getBits(); - int rowspan = bmp->getRowSpan()*4; - if (bmp->isFlipped()) - { - rd += rowspan*(bmp->getHeight()-1); - rowspan=-rowspan; - } - while (cinfo.next_scanline < cinfo.image_height) - { - unsigned char *outp=buf; - LICE_pixel_chan *rdp = rd; - int x=cinfo.image_width; - while(x--) - { - outp[0] = rdp[LICE_PIXEL_R]; - outp[1] = rdp[LICE_PIXEL_G]; - outp[2] = rdp[LICE_PIXEL_B]; - outp+=3; - rdp+=4; - } - jpeg_write_scanlines(&cinfo, &buf, 1); - - rd+=rowspan; - } - free(buf); - buf=0; - - jpeg_finish_compress(&cinfo); - - if (fp) fclose(fp); - fp=0; - - jpeg_destroy_compress(&cinfo); - - return true; -} diff --git a/oversampling/WDL/lice/lice_lcf.cpp b/oversampling/WDL/lice/lice_lcf.cpp deleted file mode 100644 index d35f8ab..0000000 --- a/oversampling/WDL/lice/lice_lcf.cpp +++ /dev/null @@ -1,673 +0,0 @@ -#include -#include - -#include "lice_lcf.h" - -#include "../filewrite.h" -#include "../fileread.h" - - -#define LCF_VERSION 0x11CEb001 - -LICECaptureCompressor::LICECaptureCompressor(const char *outfn, int w, int h, int interval, int bsize_w, int bsize_h) -{ - m_inframes = m_outframes=0; - m_file = new WDL_FileWrite(outfn,1,512*1024); - if (!m_file->IsOpen()) { delete m_file; m_file=0; } - - memset(&m_compstream,0,sizeof(m_compstream)); - if (m_file) - { - if (deflateInit(&m_compstream,9)!=Z_OK) - { - delete m_file; - m_file=0; - } - } - - m_inbytes=0; - m_outsize=0; - m_w=w; - m_h=h; - m_interval=interval; - m_bsize_w=bsize_w; - m_bsize_h=bsize_h; - m_state=0; - m_which=0; - m_outchunkpos=0; - m_numcols = (m_w+bsize_w-1) / (bsize_w>0?bsize_w:1); - if (m_numcols<1) m_numcols=1; - m_numrows = (m_h+bsize_h-1)/ (bsize_h>0?bsize_h:1); - - m_current_block_srcsize=0; -} - -void LICECaptureCompressor::OnFrame(LICE_IBitmap *fr, int delta_t_ms) -{ - if (fr) - { - if (fr->getWidth()!=m_w || fr->getHeight()!=m_h) return; - - frameRec *rec = m_framelists[m_which].Get(m_state); - if (!rec) - { - rec = new frameRec(m_w*m_h); - m_framelists[m_which].Add(rec); - } - rec->delta_t_ms=delta_t_ms; - BitmapToFrameRec(fr,rec); - m_state++; - m_inframes++; - } - - - bool isLastBlock = m_state >= m_interval || !fr; - - if (m_framelists[!m_which].GetSize()) - { - int compressTo; - if (isLastBlock) compressTo = m_numcols*m_numrows; - else compressTo = (m_state * m_numcols*m_numrows) / m_interval; - - frameRec **list = m_framelists[!m_which].GetList(); - int list_size = m_framelists[!m_which].GetSize(); - - // compress some data - int chunkpos = m_outchunkpos; - while (chunkpos < compressTo) - { - int xpos = (chunkpos%m_numcols) * m_bsize_w; - int ypos = (chunkpos/m_numcols) * m_bsize_h; - - int wid = m_w-xpos; - int hei = m_h-ypos; - if (wid > m_bsize_w) wid=m_bsize_w; - if (hei > m_bsize_h) hei=m_bsize_h; - - int i; - int rdoffs = xpos + ypos*m_w; - int rdspan = m_w; - - int repeat_cnt=0; - - for(i=0;idata + rdoffs; - if (i&&repeat_cnt<255) - { - unsigned short *rd1=rd; - unsigned short *rd2=list[i-1]->data+rdoffs; - int a=hei; - while(a--) - { - if (memcmp(rd1,rd2,wid*sizeof(short))) break; - rd1+=rdspan; - rd2+=rdspan; - } - if (a<0) - { - repeat_cnt++; - continue; - } - } - - if (i || repeat_cnt) - { - unsigned char c = (unsigned char)repeat_cnt; - DeflateBlock(&c,1,false); - repeat_cnt=0; - } - int a=hei; - while (a--) - { - DeflateBlock(rd,wid*sizeof(short),false); - rd+=rdspan; - } - } - if (repeat_cnt) - { - unsigned char c = (unsigned char)repeat_cnt; - DeflateBlock(&c,1,false); - } - - chunkpos++; - } - m_outchunkpos=chunkpos; - } - - if (isLastBlock) - { - if (m_framelists[!m_which].GetSize()) - { - m_outframes += m_framelists[!m_which].GetSize(); - - DeflateBlock(NULL,0,true); - - deflateReset(&m_compstream); - - m_hdrqueue.Clear(); - AddHdrInt(LCF_VERSION); - AddHdrInt(16); - AddHdrInt(m_w); - AddHdrInt(m_h); - AddHdrInt(m_bsize_w); - AddHdrInt(m_bsize_h); - int nf = m_framelists[!m_which].GetSize(); - AddHdrInt(nf); - int sz = m_current_block.Available(); - AddHdrInt(sz); - - int uncomp_sz = m_current_block_srcsize; - AddHdrInt(uncomp_sz); - - { - int x; - for(x=0;xdelta_t_ms); - } - } - - - m_file->Write(m_hdrqueue.Get(),m_hdrqueue.Available()); - m_outsize += m_hdrqueue.Available(); - m_file->Write(m_current_block.Get(),sz); - m_outsize += sz; - - m_current_block.Clear(); - m_current_block_srcsize=0; - } - - - int old_state=m_state; - m_state=0; - m_outchunkpos=0; - m_which=!m_which; - - - if (old_state>0 && !fr) - { - while (m_framelists[!m_which].GetSize() > old_state) - m_framelists[!m_which].Delete(m_framelists[!m_which].GetSize()-1,true); - - OnFrame(NULL,0); - } - - if (!fr) - { - m_framelists[0].Empty(true); - m_framelists[1].Empty(true); - } - } -} - -void LICECaptureCompressor::BitmapToFrameRec(LICE_IBitmap *fr, frameRec *dest) -{ - unsigned short *outptr = dest->data; - const LICE_pixel *p = fr->getBits(); - int span = fr->getRowSpan(); - if (fr->isFlipped()) - { - p+=(fr->getHeight()-1)*span; - span=-span; - } - int h = fr->getHeight(),w=fr->getWidth(); - while (h--) - { - int x=w; - const LICE_pixel *sp = p; - while (x--) - { - LICE_pixel pix = *sp++; - *outptr++ = (((int)LICE_GETR(pix)&0xF8)>>3) | (((int)LICE_GETG(pix)&0xFC)<<3) | (((int)LICE_GETB(pix)&0xF8)<<8); - } - p += span; - } -} - -void LICECaptureCompressor::DeflateBlock(void *data, int data_size, bool flush) -{ - m_current_block_srcsize += data_size; - m_inbytes += data_size; - int bytesout=0; - - m_compstream.next_in = (unsigned char *)data; - m_compstream.avail_in = data_size; - - for (;;) - { - int add_sz = data_size+32768; - m_compstream.next_out = (unsigned char *)m_current_block.Add(NULL,add_sz); - m_compstream.avail_out = add_sz; - - int e = deflate(&m_compstream,flush?Z_FULL_FLUSH:Z_NO_FLUSH); - - m_current_block.Add(NULL,-(int)m_compstream.avail_out); - - bytesout+=add_sz-m_compstream.avail_out; - - - if (e != Z_OK) - { - break; - } - - if (!m_compstream.avail_in && (!flush || add_sz==(int)m_compstream.avail_out)) break; - } - m_outsize += bytesout; - -} - - - -LICECaptureCompressor::~LICECaptureCompressor() -{ - // process any pending frames - if (m_file) - { - OnFrame(NULL,0); - deflateEnd(&m_compstream); - } - - delete m_file; - m_framelists[0].Empty(true); - m_framelists[1].Empty(true); -} - - - - - - - - - - - - - - -////////////////////////////////////////// -///////DECOMPRESS -////////////////////////////////////////// - - -LICECaptureDecompressor::LICECaptureDecompressor(const char *fn, bool want_seekable) : m_workbm(0,0,1) -{ - m_bytes_read=0; - m_file_length_ms=0; - m_rd_which=0; - m_frameidx=0; - memset(&m_compstream,0,sizeof(m_compstream)); - memset(&m_curhdr,0,sizeof(m_curhdr)); - m_file = new WDL_FileRead(fn,2,1024*1024); - if (m_file->IsOpen()) - { - if (inflateInit(&m_compstream)!=Z_OK) - { - delete m_file; - m_file=0; - } - if (m_file) - { - m_file_frame_info.Clear(); - m_file_length_ms=0; - if (want_seekable) - { - unsigned int lastpos = 0; - int first_frame_delay = 0; - while (ReadHdr(0)) - { - m_file_frame_info.Add(&lastpos,1); - unsigned int mst = m_file_length_ms; - if (m_frame_deltas[0].GetSize()) - { - if (lastpos > 0) - mst += m_frame_deltas[0].Get()[0]-first_frame_delay; // TOC is by time of first frames, ignore first delay when seeking - else - first_frame_delay = m_frame_deltas[0].Get()[0]; - } - m_file_frame_info.Add(&mst,1); - - int x; - for(x=0;xSetPosition(lastpos = (unsigned int)(m_file->GetPosition() + m_curhdr[0].cdata_left)); - } - } - - Seek(0); - } - } - - if (m_curhdr[m_rd_which].bpp!=16) - { - delete m_file; - m_file=0; - } - -} - -LICECaptureDecompressor::~LICECaptureDecompressor() -{ - inflateEnd(&m_compstream); - delete m_file; -} - -bool LICECaptureDecompressor::NextFrame() // TRUE if out of frames -{ - if (++m_frameidx >= m_frame_deltas[m_rd_which].GetSize()) - { - m_rd_which=!m_rd_which; - - DecompressBlock(m_rd_which,1.0); - if (!ReadHdr(!m_rd_which)) - memset(&m_curhdr[!m_rd_which],0,sizeof(m_curhdr[!m_rd_which])); - m_frameidx=0; - if (!m_curhdr[m_rd_which].bpp) return false; - DecodeSlices(); - } - else - DecompressBlock(!m_rd_which,m_frameidx/(double)m_frame_deltas[m_rd_which].GetSize()); - return false; -} - -int LICECaptureDecompressor::Seek(unsigned int offset_ms) -{ - - memset(m_curhdr,0,sizeof(m_curhdr)); - if (!m_file) return -1; - - int rval=0; - - unsigned int seekpos=0; - m_frameidx=0; - if (offset_ms>0&&m_file_frame_info.GetSize()) - { - int x; - for(x=0;x0) rval=-1; - offset_ms=0; - } - - m_rd_which=0; - m_file->SetPosition(seekpos); - if (!ReadHdr(m_rd_which)||!DecompressBlock(m_rd_which,1.0)) - { - rval=-1; - memset(&m_curhdr,0,sizeof(m_curhdr)); - } - else - { - if (offset_ms>0 && rval==0) - { - int x; - for (x = 1; x < m_frame_deltas[m_rd_which].GetSize(); x++) - { - if (offset_ms < m_frame_deltas[m_rd_which].Get()[x]) - { - rval = offset_ms; - break; - } - offset_ms -= m_frame_deltas[m_rd_which].Get()[x]; - } - m_frameidx=x-1; - } - if (!ReadHdr(!m_rd_which)) - memset(&m_curhdr[!m_rd_which],0,sizeof(m_curhdr[!m_rd_which])); - - DecodeSlices(); - } - - return rval; -} - - -bool LICECaptureDecompressor::ReadHdr(int whdr) // todo: eventually make this read/decompress the next header as it goes -{ - m_tmp.Clear(); - int hdr_sz = (4*9); - if (m_file->Read(m_tmp.Add(NULL,hdr_sz),hdr_sz)!=hdr_sz) return false; - m_bytes_read+=hdr_sz; - int ver=0; - m_tmp.GetTFromLE(&ver); - if (ver !=LCF_VERSION) return false; - m_tmp.GetTFromLE(&m_curhdr[whdr].bpp); - m_tmp.GetTFromLE(&m_curhdr[whdr].w); - m_tmp.GetTFromLE(&m_curhdr[whdr].h); - m_tmp.GetTFromLE(&m_curhdr[whdr].bsize_w); - m_tmp.GetTFromLE(&m_curhdr[whdr].bsize_h); - int nf=0; - m_tmp.GetTFromLE(&nf); - int csize=0; - m_tmp.GetTFromLE(&csize); - - int dsize=0; - m_tmp.GetTFromLE(&dsize); - - if (nf<1 || nf > 1024) return false; - - m_frame_deltas[whdr].Resize(nf); - - if (m_frame_deltas[whdr].GetSize()!=nf) return false; - - if (m_file->Read(m_frame_deltas[whdr].Get(),nf*4)!=nf*4) return false; - m_bytes_read+=nf*4; - int x; - for(x=0;xpercent) break; - } - m_compstream.next_in = buf; - m_compstream.avail_in = m_curhdr[whdr].cdata_left; - if (m_compstream.avail_in > (int)sizeof(buf)) m_compstream.avail_in=(int)sizeof(buf); - - m_compstream.avail_in = m_file->Read(buf,m_compstream.avail_in); - m_bytes_read+=m_compstream.avail_in; - m_curhdr[whdr].cdata_left -= m_compstream.avail_in; - - int e = inflate(&m_compstream,0); - if (e != Z_OK&&e!=Z_STREAM_END) - { -// printf("inflate error: %d (%d/%d)\n",e,m_compstream.avail_in, m_curhdr[whdr].cdata_left); - return !m_compstream.avail_out; - } - if (!m_compstream.avail_out && !m_compstream.avail_in) break; - } - m_compstream.next_in = NULL; - } - - return true; -} - -int LICECaptureDecompressor::GetTimeToNextFrame() -{ - int nf = m_frame_deltas[m_rd_which].GetSize(); - int fidx = m_frameidx; - - if (fidx<0&& nf) return m_frame_deltas[m_rd_which].Get()[0]; - - if (fidx+1 < nf) return m_frame_deltas[m_rd_which].Get()[fidx+1]; - - if (m_curhdr[!m_rd_which].bpp && m_frame_deltas[!m_rd_which].GetSize()) - return m_frame_deltas[!m_rd_which].Get()[0]; - - return 100; -} - -void LICECaptureDecompressor::DecodeSlices() -{ - int nf = m_frame_deltas[m_rd_which].GetSize(); - unsigned char *sp = (unsigned char *)m_decompdata[m_rd_which].Get(); - int sp_left = m_decompdata[m_rd_which].GetSize(); - hdrType *hdr = m_curhdr+m_rd_which; - int ns_x = (hdr->w + hdr->bsize_w-1)/hdr->bsize_w; - int ns_y = (hdr->h + hdr->bsize_h-1)/hdr->bsize_h; - - int ns_frame = ns_x*ns_y; - void **slicelist = m_slices.Resize(nf * ns_frame); - - // format of sp is: - // nf slices - // each slice is : - // initial value - // repeat cnt - // frame - // repeat cnt - // .. - - int ypos, - toth=hdr->h, - totw=hdr->w; - - int bytespersample = (hdr->bpp+7)/8; - - for (ypos = 0; ypos < toth; ypos+=hdr->bsize_h) - { - int hei = toth-ypos; - if (hei>hdr->bsize_h) hei=hdr->bsize_h; - int xpos; - for (xpos=0; xposbsize_w) - { - int wid = totw-xpos; - if (wid>hdr->bsize_w) wid=hdr->bsize_w; - - int sz1=wid*hei*bytespersample; - - int slicewritepos = 0,i = 0; - void *lvalid = NULL; - while (i0) - { - if (lvalid) - { - unsigned char c = *sp++; - sp_left--; - while (c-->0 && i++ < nf) - { - // repeat last slice - slicelist[slicewritepos] = lvalid; - slicewritepos += ns_frame; - } - } - if (i=0 && fidx < nf && m_slices.GetSize() && hdr->bsize_w && hdr->bsize_h) - { - int ns_x = (hdr->w + hdr->bsize_w-1)/hdr->bsize_w; - int ns_y = (hdr->h + hdr->bsize_h-1)/hdr->bsize_h; - - int ns_frame = ns_x*ns_y; - - if (m_slices.GetSize() != ns_frame*nf) - return NULL; // invalid slices - - if (hdr->bpp == 16) - { - m_workbm.resize(hdr->w,hdr->h); - //unsigned short * - // format of m_decompdata is: - // nf frames of slice1, nf frames of slice2, etc - - LICE_pixel *pout = m_workbm.getBits(); - int span = m_workbm.getRowSpan(); - - int ypos, - toth=hdr->h, - totw=hdr->w; - void **sliceptr = m_slices.Get() + ns_frame * fidx; - - for (ypos = 0; ypos < toth; ypos+=hdr->bsize_h) - { - int hei = toth-ypos; - if (hei>hdr->bsize_h) hei=hdr->bsize_h; - int xpos; - for (xpos=0; xposbsize_w) - { - int wid = totw-xpos; - if (wid>hdr->bsize_w) wid=hdr->bsize_w; - - unsigned short *rdptr = (unsigned short *)*sliceptr; - - sliceptr++; - - LICE_pixel *dest = pout + xpos + ypos*span; - int y; - for (y=0;y>3)&0xFC,(px>>8)&0xF8,255); - } - dest+=span; - } - } - } - - - return &m_workbm; - } - } - return NULL; -} \ No newline at end of file diff --git a/oversampling/WDL/lice/lice_lcf.h b/oversampling/WDL/lice/lice_lcf.h deleted file mode 100644 index 6d16570..0000000 --- a/oversampling/WDL/lice/lice_lcf.h +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef _LICE_LCF_H_ -#define _LICE_LCF_H_ - -#include "../zlib/zlib.h" -#include "lice.h" - -#include "../ptrlist.h" -#include "../queue.h" -class WDL_FileWrite; -class WDL_FileRead; - -class LICECaptureCompressor -{ -public: - LICECaptureCompressor(const char *outfn, int w, int h, int interval=20, int bsize_w=128, int bsize_h=16); - - ~LICECaptureCompressor(); - - bool IsOpen() { return !!m_file; } - void OnFrame(LICE_IBitmap *fr, int delta_t_ms); - - WDL_INT64 GetOutSize() { return m_outsize; } - WDL_INT64 GetInSize() { return m_inbytes; } - -private: - WDL_FileWrite *m_file; - WDL_INT64 m_outsize,m_inbytes; - int m_inframes, m_outframes; - - int m_w,m_h,m_interval,m_bsize_w,m_bsize_h; - - - struct frameRec - { - frameRec(int sz) { data=(unsigned short *)malloc(sz*sizeof(short)); delta_t_ms=0; } - ~frameRec() { free(data); } - unsigned short *data; // shorts - int delta_t_ms; // time (ms) since last frame - }; - WDL_PtrList m_framelists[2]; - WDL_Queue m_current_block; - WDL_Queue m_hdrqueue; - - int m_state, m_which,m_outchunkpos,m_numrows,m_numcols; - int m_current_block_srcsize; - - z_stream m_compstream; - - void BitmapToFrameRec(LICE_IBitmap *fr, frameRec *dest); - void DeflateBlock(void *data, int data_size, bool flush); - void AddHdrInt(int a) { m_hdrqueue.AddToLE(&a); } - - -}; - - -class LICECaptureDecompressor -{ -public: - LICECaptureDecompressor(const char *fn, bool want_seekable=false); - ~LICECaptureDecompressor(); - - - bool IsOpen() { return !!m_file; } - - // only supported if want_seekable=true - int GetLength() { return m_file_length_ms; } // length in ms - int Seek(unsigned int offset_ms); // return -1 on fail (out of range), or >0 to tell you how far into the frame you seeked (0=exact hit) - - bool NextFrame(); // TRUE if out of frames - LICE_IBitmap *GetCurrentFrame(); // can return NULL if error - int GetTimeToNextFrame(); // delta in ms - - int GetWidth(){ return m_curhdr[m_rd_which].w; } - int GetHeight(){ return m_curhdr[m_rd_which].h; } - - int m_bytes_read; // increases for statistics, caller can clear - -private: - LICE_MemBitmap m_workbm; - - struct hdrType - { - int bpp; - int w, h; - int bsize_w, bsize_h; - int cdata_left; - } m_curhdr[2]; - - int m_rd_which; - int m_frameidx; - - bool ReadHdr(int whdr); - bool DecompressBlock(int whdr, double percent=1.0); - - z_stream m_compstream; - WDL_Queue m_tmp; - - WDL_FileRead *m_file; - - unsigned int m_file_length_ms; - WDL_TypedQueue m_file_frame_info; //pairs of offset_bytes, offset_ms - - WDL_TypedBuf m_frame_deltas[2]; - WDL_HeapBuf m_decompdata[2]; - WDL_TypedBuf m_slices; // indexed by [frame][slice] - - void DecodeSlices(); -}; - -#endif diff --git a/oversampling/WDL/lice/lice_line.cpp b/oversampling/WDL/lice/lice_line.cpp deleted file mode 100644 index 9677426..0000000 --- a/oversampling/WDL/lice/lice_line.cpp +++ /dev/null @@ -1,2035 +0,0 @@ -#ifndef WDL_NO_DEFINE_MINMAX -#define WDL_NO_DEFINE_MINMAX -#endif -#include "lice.h" -#include "lice_combine.h" -#include "lice_extended.h" -#include -#include -//#include - -#define IGNORE_SCALING(mode) ((mode)&LICE_BLIT_IGNORE_SCALING) - -template inline void SWAP(T& a, T& b) { T tmp = a; a = b; b = tmp; } - -enum { eOK = 0, eXLo = 1, eXHi = 2, eYLo = 4, eYHi = 8 }; - -static int OffscreenTest(int x, int y, int nX, int nY) -{ - int e = eOK; - if (x < 0) e |= eXLo; - else if (x >= nX) e |= eXHi; - if (y < 0) e |= eYLo; - else if (y >= nY) e |= eYHi; - return e; -} - -// Cohen-Sutherland. Returns false if the line is entirely offscreen. -static bool ClipLine(int* pX1, int* pY1, int* pX2, int* pY2, int nX, int nY) -{ - int x1 = *pX1, y1 = *pY1, x2 = *pX2, y2 = *pY2; - int e1 = OffscreenTest(x1, y1, nX, nY); - int e2 = OffscreenTest(x2, y2, nX, nY); - int timeout = 32; - bool accept = false, done = false; - do - { - if (!(e1 | e2)) { - accept = done = true; - } - else - if (e1 & e2) { - done = true; // Line is entirely offscreen. - } - else { - int x, y; - int eOut = e1 ? e1 : e2; - if (eOut & eYHi) { - x = x1 + (int) ((double) (x2 - x1) * (double) (nY - 1 - y1) / (double) (y2 - y1)); - y = nY - 1; - } - else - if (eOut & eYLo) { - x = x1 + (int) ((double) (x2 - x1) * (double) -y1 / (double) (y2 - y1)); - y = 0; - } - else - if (eOut & eXHi) { - y = y1 + (int) ((double) (y2 - y1) * (double) (nX - 1 - x1) / (double) (x2 - x1)); - x = nX - 1; - } - else { - y = y1 + (int) ((double) (y2 - y1) * (double) -x1 / (double) (x2 - x1)); - x = 0; - } - - if (eOut == e1) { - x1 = x; - y1 = y; - e1 = OffscreenTest(x1, y1, nX, nY); - } - else { - x2 = x; - y2 = y; - e2 = OffscreenTest(x2, y2, nX, nY); - } - } - } - while (!done && timeout--); - - *pX1 = x1; - *pY1 = y1; - *pX2 = x2; - *pY2 = y2; - return accept; -} - -template static int OffscreenFTest(T x, T y, T w, T h) -{ - int e = eOK; - if (x < 0.0f) e |= eXLo; - else if (x >= w) e |= eXHi; - if (y < 0.0f) e |= eYLo; - else if (y >= h) e |= eYHi; - return e; -} - -template static bool ClipFLine(T * x1, T * y1, T * x2, T *y2, int w, int h) -{ - T tx1 = *x1, ty1 = *y1, tx2 = *x2, ty2 = *y2; - T tw = (T)(w-1), th = (T)(h-1); - if (!lice_isfinite(tx1) || !lice_isfinite(tx2) || - !lice_isfinite(ty1) || !lice_isfinite(ty2)) return false; - - int e1 = OffscreenFTest(tx1, ty1, tw, th); - int e2 = OffscreenFTest(tx2, ty2, tw, th); - - int timeout = 32; - bool accept = false, done = false; - do - { - if (!(e1|e2)) - { - accept = done = true; - } - else - if (e1&e2) - { - done = true; // Line is entirely offscreen. - } - else - { - T x, y; - int eOut = (e1 ? e1 : e2); - if (eOut&eYHi) - { - x = tx1+(tx2-tx1)*(th-ty1)/(ty2-ty1); - y = th-1.0f; - } - else if (eOut&eYLo) - { - x = tx1+(tx2-tx1)*ty1/(ty1-ty2); - y = 0.0f; - } - else if (eOut&eXHi) - { - y = ty1+(ty2-ty1)*(tw-tx1)/(tx2-tx1); - x = tw-1.0f; - } - else - { - y = ty1+(ty2-ty1)*tx1/(tx1-tx2); - x = 0.0f; - } - - if (eOut == e1) - { - tx1 = x; - ty1 = y; - e1 = OffscreenFTest(tx1, ty1, tw, th); - } - else - { - tx2 = x; - ty2 = y; - e2 = OffscreenFTest(tx2, ty2, tw, th); - } - } - } - while (!done && timeout--); - - *x1 = tx1; - *y1 = ty1; - *x2 = tx2; - *y2 = ty2; - return accept; -} - - -inline static void LICE_DiagLineFAST(LICE_pixel *px, int span, int n, int xstep, int ystep, LICE_pixel color, bool aa) -{ - int step = xstep+ystep; - if (aa) - { - LICE_pixel color75 = ((color>>1)&0x7f7f7f7f)+((color>>2)&0x3f3f3f3f); - LICE_pixel color25 = (color>>2)&0x3f3f3f3f; - while (n--) - { - _LICE_CombinePixelsThreeQuarterMix2FAST::doPixFAST(px, color75); - _LICE_CombinePixelsQuarterMix2FAST::doPixFAST(px+xstep, color25); - _LICE_CombinePixelsQuarterMix2FAST::doPixFAST(px+ystep, color25); - px += step; - } - _LICE_CombinePixelsThreeQuarterMix2FAST::doPixFAST(px, color75); - } - else - { - ++n; - while (n--) - { - *px = color; - px += step; - } - } -} - -inline static void LICE_DottedVertLineFAST(LICE_IBitmap* dest, int x, int y1, int y2, LICE_pixel color) -{ - int span = dest->getRowSpan(); - LICE_pixel* px = dest->getBits()+y1*span+x; - - int n = (y2-y1+1)/2; - while (n--) - { - *px = color; - px += 2*span; - } -} - -// this is the white-color table, doing this properly requires correcting the destination color specifically -#define DO_AA_GAMMA_CORRECT 0 -#if DO_AA_GAMMA_CORRECT -static unsigned char AA_GAMMA_CORRECT[256] = -{ - // 1.8 gamma - 0,11,17,21,25,28,31,34,37,39,42,44,46,48,50,52,54,56,58,60,61,63,65,67,68,70,71,73,74,76,77,79,80,81,83,84,85,87,88,89,91,92,93,94,96,97,98,99,100,101,103,104,105,106,107,108,109,110,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,132,133,134,135,136,137,138,139,140,141,142,142,143,144,145,146,147,148,149,149,150,151,152,153,154,154,155,156,157,158,159,159,160,161,162,163,163,164,165,166,166,167,168,169,170,170,171,172,173,173,174,175,176,176,177,178,179,179,180,181,182,182,183,184,184,185,186,187,187,188,189,189,190,191,191,192,193,194,194,195,196,196,197,198,198,199,200,200,201,202,202,203,204,204,205,206,206,207,208,208,209,210,210,211,212,212,213,214,214,215,215,216,217,217,218,219,219,220,220,221,222,222,223,224,224,225,225,226,227,227,228,228,229,230,230,231,231,232,233,233,234,234,235,236,236,237,237,238,239,239,240,240,241,241,242,243,243,244,244,245,245,246,247,247,248,248,249,249,250,251,251,252,252,253,253,254,255 - - // 2.0 gamma - //0,15,22,27,31,35,39,42,45,47,50,52,55,57,59,61,63,65,67,69,71,73,74,76,78,79,81,82,84,85,87,88,90,91,93,94,95,97,98,99,100,102,103,104,105,107,108,109,110,111,112,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,141,142,143,144,145,146,147,148,148,149,150,151,152,153,153,154,155,156,157,158,158,159,160,161,162,162,163,164,165,165,166,167,168,168,169,170,171,171,172,173,174,174,175,176,177,177,178,179,179,180,181,182,182,183,184,184,185,186,186,187,188,188,189,190,190,191,192,192,193,194,194,195,196,196,197,198,198,199,200,200,201,201,202,203,203,204,205,205,206,206,207,208,208,209,210,210,211,211,212,213,213,214,214,215,216,216,217,217,218,218,219,220,220,221,221,222,222,223,224,224,225,225,226,226,227,228,228,229,229,230,230,231,231,232,233,233,234,234,235,235,236,236,237,237,238,238,239,240,240,241,241,242,242,243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251,251,252,252,253,253,254,255 - - // 2.2 gamma - //0,20,28,33,38,42,46,49,52,55,58,61,63,65,68,70,72,74,76,78,80,81,83,85,87,88,90,91,93,94,96,97,99,100,102,103,104,106,107,108,109,111,112,113,114,115,117,118,119,120,121,122,123,124,125,126,128,129,130,131,132,133,134,135,136,136,137,138,139,140,141,142,143,144,145,146,147,147,148,149,150,151,152,153,153,154,155,156,157,158,158,159,160,161,162,162,163,164,165,165,166,167,168,168,169,170,171,171,172,173,174,174,175,176,176,177,178,178,179,180,181,181,182,183,183,184,185,185,186,187,187,188,189,189,190,190,191,192,192,193,194,194,195,196,196,197,197,198,199,199,200,200,201,202,202,203,203,204,205,205,206,206,207,208,208,209,209,210,210,211,212,212,213,213,214,214,215,216,216,217,217,218,218,219,219,220,220,221,222,222,223,223,224,224,225,225,226,226,227,227,228,228,229,229,230,230,231,231,232,232,233,233,234,234,235,235,236,236,237,237,238,238,239,239,240,240,241,241,242,242,243,243,244,244,245,245,246,246,247,247,248,248,249,249,249,250,250,251,251,252,252,253,253,254,254,255 - - // 2.6 gamma - //0,30,39,46,51,56,60,63,67,70,73,76,78,81,83,85,87,89,91,93,95,97,99,101,102,104,105,107,109,110,111,113,114,116,117,118,120,121,122,123,125,126,127,128,129,130,131,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,148,149,150,151,152,153,154,155,155,156,157,158,159,160,160,161,162,163,164,164,165,166,167,167,168,169,170,170,171,172,173,173,174,175,175,176,177,177,178,179,179,180,181,181,182,183,183,184,185,185,186,187,187,188,188,189,190,190,191,192,192,193,193,194,195,195,196,196,197,197,198,199,199,200,200,201,201,202,203,203,204,204,205,205,206,206,207,207,208,208,209,210,210,211,211,212,212,213,213,214,214,215,215,216,216,217,217,218,218,219,219,220,220,221,221,222,222,223,223,223,224,224,225,225,226,226,227,227,228,228,229,229,230,230,230,231,231,232,232,233,233,234,234,234,235,235,236,236,237,237,237,238,238,239,239,240,240,240,241,241,242,242,243,243,243,244,244,245,245,245,246,246,247,247,247,248,248,249,249,249,250,250,251,251,251,252,252,253,253,253,254,254,255 -}; -#endif - -static void GetAAPxWeight(int err, int alpha, int* wt, int* iwt) -{ - int i = err>>8; - int w = 255-i; - -#if DO_AA_GAMMA_CORRECT - w = AA_GAMMA_CORRECT[w]; - i = AA_GAMMA_CORRECT[i]; -#endif - - w = (alpha*w) >> 8; - i = (alpha*i) >> 8; - *wt = w; - *iwt = i; -} - -static void GetAAPxWeightFAST(int err, int* wt, int* iwt) -{ - int i = err>>8; - int w = 255-i; - -#if DO_AA_GAMMA_CORRECT - w = AA_GAMMA_CORRECT[w]; - i = AA_GAMMA_CORRECT[i]; -#endif - - *wt = w; - *iwt = i; -} -template class __LICE_LineClassSimple -{ -public: - static void LICE_VertLineFAST(LICE_pixel *px, int span, int len, LICE_pixel color) - { - while (len--) - { - COMBFUNC::doPixFAST(px, color); - px+=span; - } - } - - static void LICE_HorizLineFAST(LICE_pixel *px, int n, LICE_pixel color) - { - while (n--) - { - COMBFUNC::doPixFAST(px, color); - px++; - } - } - static void LICE_VertLine(LICE_pixel *px, int span, int len, int color, int aw) - { - int r = LICE_GETR(color), g = LICE_GETG(color), b = LICE_GETB(color), a = LICE_GETA(color); - while (len--) - { - COMBFUNC::doPix((LICE_pixel_chan*) px, r, g, b, a, aw); - px+=span; - } - } - - static void LICE_HorizLine(LICE_pixel *px, int n, LICE_pixel color, int aw) - { - int r = LICE_GETR(color), g = LICE_GETG(color), b = LICE_GETB(color), a = LICE_GETA(color); - - while (n--) - { - COMBFUNC::doPix((LICE_pixel_chan*) px, r, g, b, a, aw); - px++; - } - } - static void LICE_DiagLine(LICE_pixel *px, int span, int n, int xstep, int ystep, LICE_pixel color, int aw) - { - int r = LICE_GETR(color), g = LICE_GETG(color), b = LICE_GETB(color), a = LICE_GETA(color); - int step = xstep+ystep; - - for (int i = 0; i <= n; ++i, px += step) - { - COMBFUNC::doPix((LICE_pixel_chan*) px, r, g, b, a, aw); - } - } - static void LICE_DiagLineAA(LICE_pixel *px, int span, int n, int xstep, int ystep, LICE_pixel color, int aw) - { - int r = LICE_GETR(color), g = LICE_GETG(color), b = LICE_GETB(color), a = LICE_GETA(color); - int step = xstep+ystep; - -#if DO_AA_GAMMA_CORRECT - int iw = aw*AA_GAMMA_CORRECT[256*3/4]/256; - int dw = aw*AA_GAMMA_CORRECT[256/4]/256; -#else - int iw = aw*3/4; - int dw = aw/4; -#endif - for (int i = 0; i < n; ++i, px += step) - { - COMBFUNC::doPix((LICE_pixel_chan*) px, r, g, b, a, iw); - COMBFUNC::doPix((LICE_pixel_chan*) (px+xstep), r, g, b, a, dw); - COMBFUNC::doPix((LICE_pixel_chan*) (px+ystep), r, g, b, a, dw); - } - COMBFUNC::doPix((LICE_pixel_chan*) px, r, g, b, a, iw); - } -}; - - -#ifndef LICE_FAVOR_SIZE -template -#endif -class __LICE_LineClass -{ -public: - -#ifdef LICE_FAVOR_SIZE - #define DOPIX(pout,r,g,b,a,ia) combFunc(pout,r,g,b,a,ia); -#else - #define DOPIX(pout,r,g,b,a,ia) COMBFUNC::doPix(pout,r,g,b,a,ia); -#endif - - static void DashedLine(LICE_IBitmap* dest, int x1, int y1, int x2, int y2, int pxon, int pxoff, LICE_pixel color, int aw -#ifdef LICE_FAVOR_SIZE - , LICE_COMBINEFUNC combFunc -#endif - ) - { - int span = dest->getRowSpan(); - LICE_pixel* px = dest->getBits()+y1*span+x1; - int r = LICE_GETR(color), g = LICE_GETG(color), b = LICE_GETB(color), a = LICE_GETA(color); - - if (x1 == x2) - { - int i, y; - for (y = y1; y < y2-pxon; y += pxon+pxoff) - { - for (i = 0; i < pxon; ++i, px += span) DOPIX((LICE_pixel_chan*) px, r, g, b, a, aw) - px += pxoff*span; - } - for (i = 0; i < lice_min(pxon, y2-y); ++i, px += span) DOPIX((LICE_pixel_chan*) px, r, g, b, a, aw) - } - else if (y1 == y2) - { - int i, x; - for (x = x1; x < x2-pxon; x += pxon+pxoff) - { - for (i = 0; i < pxon; ++i, ++px) DOPIX((LICE_pixel_chan*) px, r, g, b, a, aw) - px += pxoff; - } - for (i = 0; i < lice_min(pxon, x2-x); ++i, ++px) DOPIX((LICE_pixel_chan*) px, r, g, b, a, aw) - } - } - - - - - static void LICE_LineImpl(LICE_pixel *px, LICE_pixel *px2, int derr, int astep, int da, int bstep, LICE_pixel color, int aw, bool aa -#ifdef LICE_FAVOR_SIZE - , LICE_COMBINEFUNC combFunc -#endif - ) - { - int r = LICE_GETR(color), g = LICE_GETG(color), b = LICE_GETB(color), a = LICE_GETA(color); - - int err = 0; - int i; - int n = (da+1)/2; - - if (aa) - { - DOPIX((LICE_pixel_chan*) px, r, g, b, a, aw) - DOPIX((LICE_pixel_chan*) px2, r, g, b, a, aw) - px += astep; - px2 -= astep; - err = derr; - - if (aw == 256) - { - for (i = 1; i < n; ++i) - { - int wt, iwt; - GetAAPxWeightFAST(err, &wt, &iwt); - DOPIX((LICE_pixel_chan*)px, r, g, b, a, wt) - DOPIX((LICE_pixel_chan*)(px+bstep), r, g, b, a, iwt) - DOPIX((LICE_pixel_chan*)px2, r, g, b, a, wt) - DOPIX((LICE_pixel_chan*)(px2-bstep), r, g, b, a, iwt) - - err += derr; - if (err >= 65536) - { - px += bstep; - px2 -= bstep; - err -= 65536; - } - px += astep; - px2 -= astep; - } - } - else // alpha<256 - { - for (i = 1; i < n; ++i) - { - int wt, iwt; - GetAAPxWeight(err, aw, &wt, &iwt); - DOPIX((LICE_pixel_chan*)px, r, g, b, a, wt) - DOPIX((LICE_pixel_chan*)(px+bstep), r, g, b, a, iwt) - DOPIX((LICE_pixel_chan*)px2, r, g, b, a, wt) - DOPIX((LICE_pixel_chan*)(px2-bstep), r, g, b, a, iwt) - - err += derr; - if (err >= 65536) - { - px += bstep; - px2 -= bstep; - err -= 65536; - } - px += astep; - px2 -= astep; - } - } - if (!(da%2)) - { - int wt, iwt; - if (aw == 256) GetAAPxWeightFAST(err, &wt, &iwt); - else GetAAPxWeight(err, aw, &wt, &iwt); - DOPIX((LICE_pixel_chan*)px, r, g, b, a, wt) - DOPIX((LICE_pixel_chan*)(px+bstep), r, g, b, a, iwt) - } - } - else // not aa - { - for (i = 0; i < n; ++i) - { - DOPIX((LICE_pixel_chan*)px, r, g, b, a, aw) - DOPIX((LICE_pixel_chan*)px2, r, g, b, a, aw) - err += derr; - if (err >= 65536/2) - { - px += bstep; - px2 -= bstep; - err -= 65536; - } - - px += astep; - px2 -= astep; - } - if (!(da%2)) - { - DOPIX((LICE_pixel_chan*)px, r, g, b, a, aw) - } - } - } - - static void LICE_FLineImpl(LICE_pixel *px, int n , int err, int derr, int astep, int bstep, LICE_pixel color, int aw -#ifdef LICE_FAVOR_SIZE - , LICE_COMBINEFUNC combFunc -#endif - - ) // only does AA - { - int r = LICE_GETR(color), g = LICE_GETG(color), b = LICE_GETB(color), a = LICE_GETA(color); - - - int wt, iwt; - int i; - - if (aw == 256) - { - for (i = 0; i <= n; ++i) - { - GetAAPxWeightFAST(err, &wt, &iwt); - DOPIX((LICE_pixel_chan*)px, r, g, b, a, wt) - DOPIX((LICE_pixel_chan*)(px+bstep), r, g, b, a, iwt) - - err += derr; - if (err >= 65536) - { - px += bstep; - err -= 65536; - } - px += astep; - } - } - else // alpha != 256 - { - for (i = 0; i <= n; ++i) - { - GetAAPxWeight(err, aw, &wt, &iwt); - DOPIX((LICE_pixel_chan*)px, r, g, b, a, wt) - DOPIX((LICE_pixel_chan*)(px+bstep), r, g, b, a, iwt) - - err += derr; - if (err >= 65536) - { - px += bstep; - err -= 65536; - } - px += astep; - } - } - } - - static void LICE_FLineImplFill(LICE_pixel *px, int n , int err, int derr, int astep, int bstep, LICE_pixel color, int aw, - int fill_sz, int b_pos, unsigned int b_max -#ifdef LICE_FAVOR_SIZE - , LICE_COMBINEFUNC combFunc -#endif - ) - { - // fill_sz always >= 2 - int r = LICE_GETR(color), g = LICE_GETG(color), b = LICE_GETB(color), a = LICE_GETA(color); - - int wt, iwt; - int i; - - const int dbpos = bstep < 0 ? -1 : 1; - - const int b_adj = -(fill_sz/2); - b_pos += b_adj*dbpos; - px += b_adj*bstep; - - fill_sz--; // fill size of 2 has one extra pixel in the middle, 2 AA pixels - - if (aw == 256) - { - for (i = 0; i <= n; ++i) - { - GetAAPxWeightFAST(err, &wt, &iwt); - LICE_pixel *wr = px; - unsigned int bp = b_pos; - if (bp= 65536) - { - px += bstep; - b_pos += dbpos; - err -= 65536; - } - px += astep; - } - } - else // alpha != 256 - { - for (i = 0; i <= n; ++i) - { - GetAAPxWeight(err, aw, &wt, &iwt); - LICE_pixel *wr = px; - unsigned int bp = b_pos; - if (bp= 65536) - { - px += bstep; - b_pos += dbpos; - err -= 65536; - } - px += astep; - } - } - } - -#undef DOPIX -}; - - -void LICE_Line(LICE_IBitmap *dest, int x1, int y1, int x2, int y2, LICE_pixel color, float alpha, int mode, bool aa) -{ - if (!dest) return; - - int w = dest->getWidth(); - int h = dest->getHeight(); - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - __LICE_SCU(w); - __LICE_SCU(h); - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(x1); - __LICE_SC(y1); - __LICE_SC(x2); - __LICE_SC(y2); - } - } - -#ifndef DISABLE_LICE_EXTENSIONS - if (dest->Extended(LICE_EXT_SUPPORTS_ID, (void*) LICE_EXT_LINE_ACCEL)) - { - LICE_Ext_Line_acceldata data(x1, y1, x2, y2, color, alpha, mode, aa); - if (dest->Extended(LICE_EXT_LINE_ACCEL, &data)) return; - } -#endif - - if (dest->isFlipped()) - { - y1 = h-1-y1; - y2 = h-1-y2; - } - - if (ClipLine(&x1, &y1, &x2, &y2, w, h)) - { - int xdiff = x2-x1; - if (y1 == y2) // horizontal line optimizations - { - if (x1 > x2) SWAP(x1, x2); - int span = dest->getRowSpan(); - LICE_pixel* px = dest->getBits()+y1*span+x1; - int n=x2-x1+1; - - if ((mode&LICE_BLIT_MODE_MASK) == LICE_BLIT_MODE_COPY && alpha == 1.0f) - { - __LICE_LineClassSimple<_LICE_CombinePixelsClobberFAST>::LICE_HorizLineFAST(px, n, color); - } - else if ((mode&LICE_BLIT_MODE_MASK) == LICE_BLIT_MODE_COPY && alpha == 0.5f) - { - color = (color>>1)&0x7f7f7f7f; - __LICE_LineClassSimple<_LICE_CombinePixelsHalfMix2FAST>::LICE_HorizLineFAST(px, n, color); - } - else if ((mode&LICE_BLIT_MODE_MASK) == LICE_BLIT_MODE_COPY && alpha == 0.25f) - { - color = (color>>2)&0x3f3f3f3f; - __LICE_LineClassSimple<_LICE_CombinePixelsQuarterMix2FAST>::LICE_HorizLineFAST(px, n, color); - } - else if ((mode&LICE_BLIT_MODE_MASK) == LICE_BLIT_MODE_COPY && alpha == 0.75f) - { - color = ((color>>1)&0x7f7f7f7f)+((color>>2)&0x3f3f3f3f); - __LICE_LineClassSimple<_LICE_CombinePixelsThreeQuarterMix2FAST>::LICE_HorizLineFAST(px, n, color); - } - else - { - int aw = (int)(256.0f*alpha); -#define __LICE__ACTION(COMBFUNC) __LICE_LineClassSimple::LICE_HorizLine(px, n, color, aw) - __LICE_ACTION_CONSTANTALPHA(mode, aw, false); -#undef __LICE__ACTION - } - } - else if (!xdiff) // vertical line optimizations - { - if (y1 > y2) SWAP(y1, y2); - int len=y2+1-y1; - int span = dest->getRowSpan(); - LICE_pixel* px = dest->getBits()+y1*span+x1; - int aw = (int)(256.0f*alpha); - if ((mode&LICE_BLIT_MODE_MASK) == LICE_BLIT_MODE_COPY && alpha == 1.0f) - { - __LICE_LineClassSimple<_LICE_CombinePixelsClobberFAST>::LICE_VertLineFAST(px, span, len, color); - } - else if ((mode&LICE_BLIT_MODE_MASK) == LICE_BLIT_MODE_COPY && alpha == 0.5f) - { - color = (color>>1)&0x7f7f7f7f; - __LICE_LineClassSimple<_LICE_CombinePixelsHalfMix2FAST>::LICE_VertLineFAST(px, span, len, color); - } - else if ((mode&LICE_BLIT_MODE_MASK) == LICE_BLIT_MODE_COPY && alpha == 0.25f) - { - color = (color>>2)&0x3f3f3f3f; - __LICE_LineClassSimple<_LICE_CombinePixelsQuarterMix2FAST>::LICE_VertLineFAST(px, span, len, color); - } - else if ((mode&LICE_BLIT_MODE_MASK) == LICE_BLIT_MODE_COPY && alpha == 0.75f) - { - color = ((color>>1)&0x7f7f7f7f)+((color>>2)&0x3f3f3f3f); - __LICE_LineClassSimple<_LICE_CombinePixelsThreeQuarterMix2FAST>::LICE_VertLineFAST(px, span, len, color); - } - else - { -#define __LICE__ACTION(COMBFUNC) __LICE_LineClassSimple::LICE_VertLine(px, span, len, color,aw) - __LICE_ACTION_CONSTANTALPHA(mode, aw, false); -#undef __LICE__ACTION - } - } - else if ((xdiff=abs(xdiff)) == abs(y2-y1)) // diagonal line optimizations - { - int span = dest->getRowSpan(); - LICE_pixel* px = dest->getBits()+y1*span+x1; - int aw = (int)(256.0f*alpha); - int xstep = (x2 > x1 ? 1 : -1); - int ystep = (y2 > y1 ? span : -span); - if ((mode&LICE_BLIT_MODE_MASK) == LICE_BLIT_MODE_COPY && alpha == 1.0f) - { - LICE_DiagLineFAST(px,span, xdiff, xstep, ystep, color, aa); - } - else - { - if (aa) - { -#define __LICE__ACTION(COMBFUNC) __LICE_LineClassSimple::LICE_DiagLineAA(px,span, xdiff, xstep, ystep, color, aw) - __LICE_ACTION_NOSRCALPHA(mode, aw, false); -#undef __LICE__ACTION - } - else - { -#define __LICE__ACTION(COMBFUNC) __LICE_LineClassSimple::LICE_DiagLine(px,span, xdiff, xstep, ystep, color, aw) - __LICE_ACTION_CONSTANTALPHA(mode, aw, false); -#undef __LICE__ACTION - } - } - } - else - { - - // common set-up for normal line draws - - int span = dest->getRowSpan(); - int aw = (int)(256.0f*alpha); - LICE_pixel* px = dest->getBits()+y1*span+x1; - LICE_pixel* px2 = dest->getBits()+y2*span+x2; - - int da, db; - int astep, bstep; - int dx = x2-x1; - int dy = y2-y1; - - if (abs(dx) > abs(dy)) - { - da = dx; - db = dy; - astep = 1; - bstep = span; - } - else - { - da = dy; - db = dx; - astep = span; - bstep = 1; - } - - if (da < 0) - { - da = -da; - db = -db; - SWAP(px, px2); - } - if (db < 0) - { - db = -db; - bstep = -bstep; - } - - double dbda = (double)db/(double)da; - - int derr = (int)(dbda*65536.0); - -#ifdef LICE_FAVOR_SIZE - - LICE_COMBINEFUNC blitfunc=NULL; - #define __LICE__ACTION(comb) blitfunc=comb::doPix; - -#else - #define __LICE__ACTION(COMBFUNC) __LICE_LineClass::LICE_LineImpl(px,px2, derr, astep, da, bstep, color, aw, aa) -#endif - if (aa) - { - __LICE_ACTION_NOSRCALPHA(mode, aw, false); - } - else - { - __LICE_ACTION_CONSTANTALPHA(mode, aw, false); - } - - #undef __LICE__ACTION - -#ifdef LICE_FAVOR_SIZE - if (blitfunc) __LICE_LineClass::LICE_LineImpl(px,px2, derr, astep, da, bstep, color, aw, aa, blitfunc); -#endif - } - } -} - -void LICE_FLine(LICE_IBitmap* dest, float x1, float y1, float x2, float y2, LICE_pixel color, float alpha, int mode, bool aa) -{ - if (!dest) return; - if (!aa) - { - LICE_Line(dest,(int)x1,(int)y1,(int)x2,(int)y2,color,alpha,mode,false); - return; - } - - int w = dest->getWidth(); - int h = dest->getHeight(); - if (dest->isFlipped()) - { - y1 = (float)(h-1)-y1; - y2 = (float)(h-1)-y2; - } - - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - __LICE_SCU(w); - __LICE_SCU(h); - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(x1); - __LICE_SC(x2); - __LICE_SC(y1); - __LICE_SC(y2); - } - } - - if (ClipFLine(&x1, &y1, &x2, &y2, w, h)) - { - if (x1 != x2 || y1 != y2) - { - int span = dest->getRowSpan(); - int aw = (int)(256.0f*alpha); - - float a1, a2, b1, b2, da, db; - int astep, bstep; - float dx = x2-x1; - float dy = y2-y1; - - if (fabs(dx) > fabs(dy)) - { - a1 = x1; - a2 = x2; - b1 = y1; - b2 = y2; - da = dx; - db = dy; - astep = 1; - bstep = span; - } - else - { - a1 = y1; - a2 = y2; - b1 = x1; - b2 = x2; - da = dy; - db = dx; - astep = span; - bstep = 1; - } - - if (da < 0.0f) - { - da = -da; - db = -db; - SWAP(a1, a2); - SWAP(b1, b2); - } - if (db < 0.0f) - { - bstep = -bstep; - } - - int n = (int)(floor(a2)-ceil(a1)); - float dbda = db/da; - - float ta = ceil(a1); - float tb = b1+(ta-a1)*dbda; - float bf = tb-floor(tb); - int err = (int)(bf*65536.0f); - if (bstep < 0) err = 65535-err; - int derr = (int)(fabs(dbda)*65536.0f); - - LICE_pixel* px = dest->getBits()+(int)ta*astep+(int)tb*abs(bstep); - - if (bstep < 0) px -= bstep; - -#ifdef LICE_FAVOR_SIZE - - LICE_COMBINEFUNC blitfunc=NULL; - #define __LICE__ACTION(comb) blitfunc=comb::doPix; - -#else - - #define __LICE__ACTION(COMBFUNC) __LICE_LineClass::LICE_FLineImpl(px,n,err,derr,astep,bstep, color, aw) -#endif - - __LICE_ACTION_NOSRCALPHA(mode, aw, false); - -#ifdef LICE_FAVOR_SIZE - if (blitfunc) __LICE_LineClass::LICE_FLineImpl(px,n,err,derr,astep,bstep, color, aw, blitfunc); -#endif - - #undef __LICE__ACTION - } - } -} - -void LICE_DashedLine(LICE_IBitmap* dest, int x1, int y1, int x2, int y2, int pxon, int pxoff, LICE_pixel color, float alpha, int mode, bool aa) -{ - if (!dest) return; - - int w = dest->getWidth(); - int h = dest->getHeight(); - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - __LICE_SCU(w); - __LICE_SCU(h); - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(x1); - __LICE_SC(y1); - __LICE_SC(x2); - __LICE_SC(y2); - __LICE_SCU(pxon); - __LICE_SCU(pxoff); - } - } - -#ifndef DISABLE_LICE_EXTENSIONS - if (dest->Extended(LICE_EXT_SUPPORTS_ID, (void*) LICE_EXT_DASHEDLINE_ACCEL)) - { - LICE_Ext_DashedLine_acceldata data(x1, y1, x2, y2, pxon, pxoff, color, alpha, mode, aa); - if (dest->Extended(LICE_EXT_DASHEDLINE_ACCEL, &data)) return; - } -#endif - - if (ClipLine(&x1, &y1, &x2, &y2, w, h)) - { - if (y1 > y2) SWAP(y1, y2); - if (pxon == 1 && pxoff == 1 && x1 == x2 && (mode&LICE_BLIT_MODE_MASK) == LICE_BLIT_MODE_COPY && alpha == 1.0f) - { - LICE_DottedVertLineFAST(dest, x1, y1, y2, color); - } - else - { - int aw = (int)(256.0f*alpha); - if (x1 > x2) SWAP(x1, x2); - -#ifdef LICE_FAVOR_SIZE - - LICE_COMBINEFUNC blitfunc=NULL; - #define __LICE__ACTION(comb) blitfunc=comb::doPix; - -#else - - #define __LICE__ACTION(COMBFUNC) __LICE_LineClass::DashedLine(dest, x1, y1, x2, y2, pxon, pxoff, color, aw); -#endif - - __LICE_ACTION_CONSTANTALPHA(mode, aw, false); - -#ifdef LICE_FAVOR_SIZE - if (blitfunc) __LICE_LineClass::DashedLine(dest, x1, y1, x2, y2, pxon, pxoff, color, aw, blitfunc); -#endif - -#undef __LICE__ACTION - } - } -} - -bool LICE_ClipLine(int* pX1, int* pY1, int* pX2, int* pY2, int xLo, int yLo, int xHi, int yHi) -{ - int x1 = *pX1-xLo; - int y1 = *pY1-yLo; - int x2 = *pX2-xLo; - int y2 = *pY2-yLo; - bool onscreen = ClipLine(&x1, &y1, &x2, &y2, xHi-xLo, yHi-yLo); - *pX1 = x1+xLo; - *pY1 = y1+yLo; - *pX2 = x2+xLo; - *pY2 = y2+yLo; - return onscreen; -} - -bool LICE_ClipFLine(float* px1, float* py1, float* px2, float* py2, float xlo, float ylo, float xhi, float yhi) -{ - float x1 = *px1-xlo; - float y1 = *py1-ylo; - float x2 = *px2-xlo; - float y2 = *py2-ylo; - bool onscreen = ClipFLine(&x1, &y1, &x2, &y2, xhi-xlo, yhi-ylo); - *px1 = x1+xlo; - *py1 = y1+ylo; - *px2 = x2+xlo; - *py2 = y2+ylo; - return onscreen; -} - - -#include "lice_bezier.h" - -static void DoBezierFillSegment(LICE_IBitmap* dest, int x1, int y1, int x2, int y2, int yfill, LICE_pixel color, float alpha, int mode) -{ - if (x2 < x1) return; - if (x2 == x1) - { - if (y1 > y2) SWAP(y1,y2); - int ylo = lice_min(y1,yfill); - int yhi = lice_max(y2,yfill+1); - LICE_FillRect(dest, x1, ylo, 1, yhi-ylo+1, color, alpha, mode); - return; - } - - if ((y1 < yfill) == (y2 < yfill)) - { - if (y1 < yfill) ++yfill; - int x[4] = { x1, x1, x2, x2 }; - int y[4] = { y1, yfill, y2, yfill }; - LICE_FillConvexPolygon(dest, x, y, 4, color, alpha, mode); - } - else - { - int x = x1+(int)((double)(yfill-y1)*(double)(x2-x1)/(double)(y2-y1)); - int yf = yfill; - if (y1 < yfill) ++yf; - LICE_FillTriangle(dest, x1, y1, x1, yf, x, yf, color, alpha, mode); - yf = yfill; - if (y2 < yfill) ++yf; - LICE_FillTriangle(dest, x, yf, x2, yf, x2, y2, color, alpha, mode); - } -} - -static void DoBezierFillSegmentX(LICE_IBitmap* dest, int x1, int y1, int x2, int y2, int xfill, LICE_pixel color, float alpha, int mode) -{ - if (y2 < y1) return; - if (y2 == y1) - { - if (x1 > x2) SWAP(x1,x2); - int xlo = lice_min(x1,xfill); - int xhi = lice_max(x2,xfill+1); - LICE_FillRect(dest, xlo, y1, xhi-xlo+1, 1, color, alpha, mode); - return; - } - - if ((x1 < xfill) == (x2 < xfill)) - { - if (x1 < xfill) ++xfill; - int x[4] = { x1, xfill, x2, xfill }; - int y[4] = { y1, y1, y2+1, y2+1 }; - LICE_FillConvexPolygon(dest, x, y, 4, color, alpha, mode); - } - else - { - int y = y1+(int)((double)(xfill-x1)*(double)(y2-y1)/(double)(x2-x1)); - int xf = xfill; - if (x1 < xfill) ++xf; - LICE_FillTriangle(dest, x1, y1, xf, y1, xf, y, color, alpha, mode); - xf = xfill; - if (x2 < xfill) ++xf; - LICE_FillTriangle(dest, xf, y, xf, y2, x2, y2, color, alpha, mode); - } -} - - -// quadratic bezier ... NOT TESTED YET -// attempt to draw segments no longer than tol px -void LICE_DrawQBezier(LICE_IBitmap* dest, double xstart, double ystart, double xctl, double yctl, double xend, double yend, - LICE_pixel color, float alpha, int mode, bool aa, double tol) -{ - if (!dest) return; - - int w = dest->getWidth(); - - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc) - { - __LICE_SCU(w); - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(xstart); - __LICE_SC(ystart); - __LICE_SC(xctl); - __LICE_SC(yctl); - __LICE_SC(xend); - __LICE_SC(yend); - } - mode|=LICE_BLIT_IGNORE_SCALING; - } - - - - - if (xstart > xend) - { - SWAP(xstart, xend); - SWAP(ystart, yend); - } - - double len = sqrt((xctl-xstart)*(xctl-xstart)+(yctl-ystart)*(yctl-ystart)); - len += sqrt((xend-xctl)*(xend-xctl)+(yend-yctl)*(yend-yctl)); - - double xlo = xstart; - double xhi = xend; - double ylo = ystart; - double yhi = yend; - double tlo = 0.0; - double thi = 1.0; - - if (xlo < 0.0f) - { - xlo = 0.0f; - ylo = LICE_Bezier_GetY(xstart, xctl, xend, ystart, yctl, yend, xlo, &tlo); - } - if (xhi >= (float)w) - { - xhi = (float)(w-1); - yhi = LICE_Bezier_GetY(xstart, xctl, xend, ystart, yctl, yend, xhi, &thi); - } - if (xlo > xhi) return; - - len *= (thi-tlo); - if (tol <= 0.0f) tol = 1.0f; - int nsteps = (int)(len/tol); - if (nsteps <= 0) nsteps = 1; - - double dt = (thi-tlo)/(double)nsteps; - double t = tlo+dt; - - double lastx = xlo; - double lasty = ylo; - double x, y; - int i; - for (i = 1; i < nsteps; ++i) - { - LICE_Bezier(xstart, xctl, xend, ystart, yctl, yend, t, &x, &y); - LICE_FLine(dest, lastx, lasty, x, y, color, alpha, mode, aa); - lastx = x; - lasty = y; - t += dt; - } - LICE_FLine(dest, lastx, lasty, xhi, yhi, color, alpha, mode, aa); - -} - -int LICE_CBezPrep(int dest_w, double xstart, double ystart, double xctl1, double yctl1, - double xctl2, double yctl2, double xend, double yend, double tol, bool xbasis, - double* ax, double* bx, double* cx, double* dx, double* ay, double* by, double* cy, double* dy, - double* xlo, double* xhi, double* ylo, double* yhi, double* tlo, double* thi) -{ - const int w = dest_w; - - if ((xbasis && xstart > xend) || (!xbasis && ystart > yend)) - { - SWAP(xstart, xend); - SWAP(xctl1, xctl2); - SWAP(ystart, yend); - SWAP(yctl1, yctl2); - } - - double len = sqrt((xctl1-xstart)*(xctl1-xstart)+(yctl1-ystart)*(yctl1-ystart)); - len += sqrt((xctl2-xctl1)*(xctl2-xctl1)+(yctl2-yctl1)*(yctl2-yctl1)); - len += sqrt((xend-xctl2)*(xend-xctl2)+(yend-yctl2)*(yend-yctl2)); - - LICE_CBezier_GetCoeffs(xstart, xctl1, xctl2, xend, ystart, yctl1, yctl2, yend, ax, bx, cx, ay, by, cy); - *dx = xstart; - *dy = ystart; - - *xlo = xstart; - *xhi = xend; - *ylo = ystart; - *yhi = yend; - *tlo = 0.0; - *thi = 1.0; - - if (*xlo < 0.0f) - { - *xlo = 0.0f; - *ylo = LICE_CBezier_GetY(xstart, xctl1, xctl2, xend, ystart, yctl1, yctl2, yend, *xlo, (double*)NULL, (double*)NULL, (double*)NULL, tlo); - } - if (*xhi > w) - { - *xhi = w; - *yhi = LICE_CBezier_GetY(xstart, xctl1, xctl2, xend, ystart, yctl1, yctl2, yend, *xhi, (double*)NULL, (double*)(double*)NULL, thi, (double*)NULL); - } - if ((xbasis && *xlo > *xhi) || (!xbasis && *ylo > *yhi)) - { - return 0; - } - - len *= (*thi-*tlo); - if (tol <= 0.0f) tol = 1.0f; - int nsteps = (int)(len/tol); - if (nsteps <= 0) nsteps = 1; - return nsteps; -} - -#define __LICE_SC_BEZ \ - __LICE_SC(destbm_w); \ - if (!IGNORE_SCALING(mode)) { \ - __LICE_SC(xstart); \ - __LICE_SC(ystart); \ - __LICE_SC(xctl1); \ - __LICE_SC(yctl1); \ - __LICE_SC(xctl2); \ - __LICE_SC(yctl2); \ - __LICE_SC(xend); \ - __LICE_SC(yend); \ - } - - -void LICE_DrawCBezier(LICE_IBitmap* dest, double xstart, double ystart, double xctl1, double yctl1, - double xctl2, double yctl2, double xend, double yend, LICE_pixel color, float alpha, int mode, bool aa, double tol) -{ - if (!dest) return; - int destbm_w = dest->getWidth(); - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc) - { - __LICE_SC_BEZ - mode|=LICE_BLIT_IGNORE_SCALING; - } - -#ifndef DISABLE_LICE_EXTENSIONS - if (dest->Extended(LICE_EXT_SUPPORTS_ID, (void*) LICE_EXT_DRAWCBEZIER_ACCEL)) - { - LICE_Ext_DrawCBezier_acceldata data(xstart, ystart, xctl1, yctl1, xctl2, yctl2, xend, yend, color, alpha, mode, aa); - if (dest->Extended(LICE_EXT_DRAWCBEZIER_ACCEL, &data)) return; - } -#endif - - double ax, bx, cx, dx, ay, by, cy, dy; - double xlo, xhi, ylo, yhi; - double tlo, thi; - int nsteps = LICE_CBezPrep(destbm_w, xstart, ystart, xctl1, yctl1, xctl2, yctl2, xend, yend, tol, true, - &ax, &bx, &cx, &dx, &ay, &by, &cy, &dy, &xlo, &xhi, &ylo, &yhi, &tlo, &thi); - if (!nsteps) return; - - double dt = (thi-tlo)/(double)nsteps; - double t = tlo+dt; - - double lastx = xlo; - double lasty = ylo; - double x, y; - int i; - for (i = 1; i < nsteps-1; ++i) - { - EVAL_CBEZXY(x, y, ax, bx, cx, dx, ay, by, cy, dy, t); - LICE_FLine(dest, lastx, lasty, x, y, color, alpha, mode, aa); - lastx = x; - lasty = y; - t += dt; - } - LICE_FLine(dest, lastx, lasty, xhi, yhi, color, alpha, mode, aa); -} - -void LICE_DrawThickCBezier(LICE_IBitmap* dest, double xstart, double ystart, double xctl1, double yctl1, - double xctl2, double yctl2, double xend, double yend, LICE_pixel color, float alpha, int mode, int wid, double tol) -{ - if (!dest) return; - int destbm_w = dest->getWidth(); - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc) - { - __LICE_SC_BEZ - mode|=LICE_BLIT_IGNORE_SCALING; - } - - double ax, bx, cx, dx, ay, by, cy, dy; - double xlo, xhi, ylo, yhi; - double tlo, thi; - int nsteps = LICE_CBezPrep(destbm_w, xstart, ystart, xctl1, yctl1, xctl2, yctl2, xend, yend, tol, true, - &ax, &bx, &cx, &dx, &ay, &by, &cy, &dy, &xlo, &xhi, &ylo, &yhi, &tlo, &thi); - if (!nsteps) return; - - double dt = (thi-tlo)/(double)nsteps; - double t = tlo+dt; - - double lastx = xlo; - double lasty = ylo; - double x, y; - bool last_xmaj=false; - int i; - for (i = 1; i < nsteps; ++i) - { - if (i == nsteps-1) - { - x = xhi; - y = yhi; - } - else - { - EVAL_CBEZXY(x, y, ax, bx, cx, dx, ay, by, cy, dy, t); - } - LICE_ThickFLine(dest, lastx, lasty, x, y, color, alpha, mode, wid); - - bool xmaj = fabs(x-lastx) > fabs(y-lasty); - if (i>1 && xmaj != last_xmaj) - { - //int color = LICE_RGBA(255,0,0,0); - if (wid>2) - { - // tested this with w=3, w=4, w=8 and all looked pretty decent - double r = wid*.5 - 1; - if (r<0) r=0; - LICE_FillCircle(dest,floor(lastx+0.5),floor(lasty+0.5),.5+r*.707,color,alpha,mode,true); - } - else - { - const int ix = (int)floor(lastx+0.5), iy = (int)floor(lasty); - const double da = lasty - iy; - LICE_PutPixel(dest,ix,iy,color,alpha * (1.0-da),mode); - LICE_PutPixel(dest,ix,iy+1,color,alpha*da,mode); - } - } - - last_xmaj = xmaj; - lastx = x; - lasty = y; - t += dt; - } -} - -void LICE_FillCBezier(LICE_IBitmap* dest, double xstart, double ystart, double xctl1, double yctl1, - double xctl2, double yctl2, double xend, double yend, int yfill, LICE_pixel color, float alpha, int mode, double tol) -{ - if (!dest) return; - int destbm_w = dest->getWidth(); - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc) - { - __LICE_SC_BEZ - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(yfill); - mode|=LICE_BLIT_IGNORE_SCALING; - } - } - - - double ax, bx, cx, dx, ay, by, cy, dy; - double xlo, xhi, ylo, yhi; - double tlo, thi; - int nsteps = LICE_CBezPrep(destbm_w, xstart, ystart, xctl1, yctl1, xctl2, yctl2, xend, yend, tol, true, - &ax, &bx, &cx, &dx, &ay, &by, &cy, &dy, &xlo, &xhi, &ylo, &yhi, &tlo, &thi); - if (!nsteps) return; - - double dt = (thi-tlo)/(double)nsteps; - double t = tlo+dt; - - int lastfillx = (int)xlo; - int lastfilly = (int)(ylo+0.5f); - double x, y; - int i; - for (i = 1; i < nsteps-1; ++i) - { - EVAL_CBEZXY(x, y, ax, bx, cx, dx, ay, by, cy, dy, t); - if ((int)x >= lastfillx) - { - int xi = (int)x; - int yi = (int)(y+0.5f); - DoBezierFillSegment(dest, lastfillx, lastfilly, xi, yi, yfill, color, alpha, mode); - lastfillx = xi+1; - lastfilly = yi; - } - t += dt; - } - if ((int)(xhi-1.0f) >= lastfillx) - { - DoBezierFillSegment(dest, lastfillx, lastfilly, (int)(xhi-1.0f),(int)(yhi+0.5f), yfill, color, alpha, mode); - } -} - -void LICE_FillCBezierX(LICE_IBitmap* dest, double xstart, double ystart, double xctl1, double yctl1, - double xctl2, double yctl2, double xend, double yend, int xfill, LICE_pixel color, float alpha, int mode, double tol) -{ - if (!dest) return; - - int destbm_w = dest->getWidth(); - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc) - { - __LICE_SC_BEZ - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(xfill); - mode|=LICE_BLIT_IGNORE_SCALING; - } - } - - double ax, bx, cx, dx, ay, by, cy, dy; - double xlo, xhi, ylo, yhi; - double tlo, thi; - int nsteps = LICE_CBezPrep(destbm_w, xstart, ystart, xctl1, yctl1, xctl2, yctl2, xend, yend, tol, false, - &ax, &bx, &cx, &dx, &ay, &by, &cy, &dy, &xlo, &xhi, &ylo, &yhi, &tlo, &thi); - if (!nsteps) return; - - double dt = (thi-tlo)/(double)nsteps; - double t = tlo+dt; - - int lastfillx = (int)(xlo+0.5f); - int lastfilly = (int)ylo; - double x, y; - int i; - for (i = 1; i < nsteps-1; ++i) - { - EVAL_CBEZXY(x, y, ax, bx, cx, dx, ay, by, cy, dy, t); - if ((int)y >= lastfilly) - { - int xi = (int)(x+0.5f); - int yi = (int)y; - DoBezierFillSegmentX(dest, lastfillx, lastfilly, xi, yi, xfill, color, alpha, mode); - lastfillx = xi; - lastfilly = yi+1; - } - t += dt; - } - if ((int)(yhi-1.0f) >= lastfilly) - { - DoBezierFillSegmentX(dest, lastfillx, lastfilly, (int)(xhi+0.5),(int)(yhi-1.0f), xfill, color, alpha, mode); - } -} - - -void LICE_DrawRect(LICE_IBitmap *dest, int x, int y, int w, int h, LICE_pixel color, float alpha, int mode) -{ - const int __sc = IGNORE_SCALING(mode) ? 0 : (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - double x1 = x, y1 = y, x2 = x+w, y2 = y+h; - const double amt = 1.0 - 256.0/__sc; - x1 += amt; - y1 += amt; - x2 -= amt; - y2 -= amt; - LICE_FLine(dest, x1, y1, x2, y1, color, alpha, mode, true); - LICE_FLine(dest, x2, y1, x2, y2, color, alpha, mode, true); - LICE_FLine(dest, x2, y2, x1, y2, color, alpha, mode, true); - LICE_FLine(dest, x1, y2, x1, y1, color, alpha, mode, true); - } - else - { - LICE_Line(dest, x, y, x+w, y, color, alpha, mode, false); - LICE_Line(dest, x+w, y, x+w, y+h, color, alpha, mode, false); - LICE_Line(dest, x+w, y+h, x, y+h, color, alpha, mode, false); - LICE_Line(dest, x, y+h, x, y, color, alpha, mode, false); - } -} - -void LICE_BorderedRect(LICE_IBitmap *dest, int x, int y, int w, int h, LICE_pixel bgcolor, LICE_pixel fgcolor, float alpha, int mode) -{ - LICE_FillRect(dest, x+1, y+1, w-1, h-1, bgcolor, alpha, mode); - LICE_DrawRect(dest, x, y, w, h, fgcolor, alpha, mode); -} - - -#ifndef LICE_FAVOR_SIZE_EXTREME -template -#endif -class _LICE_Fill -{ - -#ifdef LICE_FAVOR_SIZE_EXTREME - #define DOPIX(pout,r,g,b,a,ia) combFunc(pout,r,g,b,a,ia); -#else - #define DOPIX(pout,r,g,b,a,ia) COMBFUNC::doPix(pout,r,g,b,a,ia); -#endif - -public: - - // da, db are [0..65536] - static void FillClippedTrapezoid(int wid, int span, LICE_pixel *px, int y, int xa, int xb, int da, int db, int a, int b, int astep, int bstep, int cr, int cg, int cb, int ca, int aw -#ifdef LICE_FAVOR_SIZE_EXTREME - , LICE_COMBINEFUNC combFunc -#endif - ) - { - if (!da && !db) - { - while (y-->0) - { - LICE_pixel* xpx = px; - int x=xb; - while (x--) - { - DOPIX((LICE_pixel_chan*)xpx, cr, cg, cb, ca, aw) - ++xpx; - } - px += span; - } - return; - } - - - while (y-->0) - { - int x1=lice_max(xa,0); - int x2=lice_min(xb,wid); - LICE_pixel* xpx = px + x1; - int cnt=x2-x1; - while (cnt-->0) - { - DOPIX((LICE_pixel_chan*)xpx, cr, cg, cb, ca, aw) - ++xpx; - } - - a += da; - b += db; - if (a >= 65536) - { - int na = a>>16; - a &= 65535; - if (astep<0)na=-na; - xa += na; - } - if (b >= 65536) - { - int nb = b>>16; - b &= 65535; - if (bstep<0)nb=-nb; - xb += nb; - } - px += span; - } - } -}; - - -template class _LICE_FillFast -{ -public: - - // da, db are [0..65536] - static void FillClippedTrapezoidFAST(int wid, int span, LICE_pixel *px, int y, int xa, int xb, int da, int db, int a, int b, int astep, int bstep, LICE_pixel color) - { - if (!da && !db) - { - while (y-->0) - { - LICE_pixel* xpx = px; - int x=xb; - while (x--) - { - COMBFUNC::doPixFAST(xpx, color); - ++xpx; - } - px += span; - } - return; - } - - - while (y-->0) - { - int x1=lice_max(xa,0); - int x2=lice_min(xb,wid); - LICE_pixel* xpx = px + x1; - int cnt=x2-x1; - while (cnt-->0) - { - COMBFUNC::doPixFAST(xpx, color); - ++xpx; - } - - a += da; - b += db; - if (a >= 65536) - { - int na = a>>16; - a &= 65535; - if (astep<0)na=-na; - xa += na; - } - if (b >= 65536) - { - int nb = b>>16; - b &= 65535; - if (bstep<0)nb=-nb; - xb += nb; - } - px += span; - } - } -}; - -static double FindXOnSegment(int x1, int y1, int x2, int y2, int ty) -{ - if (y1 > y2) - { - SWAP(x1, x2); - SWAP(y1, y2); - } - if (ty <= y1) return x1; - if (ty >= y2) return x2; - const double dxdy = (x2-x1)/(double)(y2-y1); - return x1+(ty-y1)*dxdy; -} - -void LICE_FillTrapezoidF(LICE_IBitmap* dest, double fx1a, double fx1b, int y1, double fx2a, double fx2b, int y2, LICE_pixel color, float alpha, int mode) -{ - if (!dest) return; - if (y1 > y2) - { - SWAP(y1, y2); - SWAP(fx1a, fx2a); - SWAP(fx1b, fx2b); - } - if (fx1a > fx1b) SWAP(fx1a, fx1b); - if (fx2a > fx2b) SWAP(fx2a, fx2b); - - int w = dest->getWidth(); - int h = dest->getHeight(); - - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - __LICE_SCU(w); - __LICE_SCU(h); - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(fx1a); - __LICE_SC(fx1b); - __LICE_SC(fx2a); - __LICE_SC(fx2b); - __LICE_SC(y1); - __LICE_SC(y2); - } - } - - if (fx1b < 0 && fx2b < 0) return; - if (fx1a >= w && fx2a >= w) return; - - if (fx1a <= 0 && fx2a <= 0) fx1a = fx2a = 0; - if (fx1b >= w-1 && fx2b >= w-1) fx1b = fx2b = w-1; - - if (y2 < 0 || y1 >= h) return; - - int aw = (int)(alpha*256.0f); - - double idy = y2==y1 ? 0.0 : (65536.0/(y2-y1)); - - const double maxv=(double)(1<<29); - double tmp = (fx2a-fx1a)*idy; - if (tmp > maxv) tmp=maxv; - else if (tmp < -maxv) tmp=-maxv; - int dxady = (int)floor(tmp+0.5); - - tmp = ((fx2b-fx1b)*idy); - if (tmp > maxv) tmp=maxv; - else if (tmp < -maxv) tmp=-maxv; - int dxbdy = (int)floor(tmp+0.5); - - int astep = 1; - int bstep = 1; - if (dxady < 0) - { - dxady = -dxady; - astep = -1; - } - if (dxbdy < 0) - { - dxbdy = -dxbdy; - bstep = -1; - } - - int x1a = (int)floor(fx1a); - int x1b = (int)floor(fx1b); - int a = (int) floor((fx1a-x1a)*65536.0*astep+0.5); - int b = (int) floor((fx1b-x1b)*65536.0*bstep+0.5); - - if (y1<0) - { - a -= dxady*y1; - b -= dxbdy*y1; - y1=0; - } - if (a< 0 || a >= 65536) - { - int na = a>>16; - a &= 65535; - if (astep<0)na=-na; - x1a += na; - } - if (b < 0 || b >= 65536) - { - int nb = b>>16; - b &= 65535; - if (bstep<0)nb=-nb; - x1b += nb; - } - const int extra = __sc> 0 && !IGNORE_SCALING(mode) ? (__sc/256 - 1) : 0; - if (y2 > h-1-extra) y2 = h-1-extra; - - int wid = w; - int span = dest->getRowSpan(); - LICE_pixel* px = dest->getBits()+y1*span; - int y = y2-y1 + 1 + extra; - - x1b++; // from now on draw [x1a,x1b) - - if (!dxady && !dxbdy) - { - if (x1a<0)x1a=0; - x1b = lice_min(x1b,wid)-x1a; - px+=x1a; - if (x1b<1) return; - } - - if ((mode&LICE_BLIT_MODE_MASK) == LICE_BLIT_MODE_COPY && aw==256) - { - _LICE_FillFast<_LICE_CombinePixelsClobberFAST>::FillClippedTrapezoidFAST(wid,span,px,y, x1a, x1b, dxady, dxbdy, a,b, astep,bstep, color); - } - else if ((mode&LICE_BLIT_MODE_MASK) == LICE_BLIT_MODE_COPY && aw==128) - { - color = (color>>1)&0x7f7f7f7f; - _LICE_FillFast<_LICE_CombinePixelsHalfMix2FAST>::FillClippedTrapezoidFAST(wid,span,px,y, x1a, x1b, dxady, dxbdy, a,b, astep,bstep, color); - } - else if ((mode&LICE_BLIT_MODE_MASK) == LICE_BLIT_MODE_COPY && aw==64) - { - color = (color>>2)&0x3f3f3f3f; - _LICE_FillFast<_LICE_CombinePixelsQuarterMix2FAST>::FillClippedTrapezoidFAST(wid,span,px,y, x1a, x1b, dxady, dxbdy, a,b, astep,bstep, color); - } - else if ((mode&LICE_BLIT_MODE_MASK) == LICE_BLIT_MODE_COPY && aw==192) - { - color = ((color>>1)&0x7f7f7f7f)+((color>>2)&0x3f3f3f3f); - _LICE_FillFast<_LICE_CombinePixelsThreeQuarterMix2FAST>::FillClippedTrapezoidFAST(wid,span,px,y, x1a, x1b, dxady, dxbdy,a,b, astep,bstep, color); - } - else - { - int cr = LICE_GETR(color), cg = LICE_GETG(color), cb = LICE_GETB(color), ca = LICE_GETA(color); -#ifdef LICE_FAVOR_SIZE_EXTREME - - LICE_COMBINEFUNC blitfunc=NULL; -#define __LICE__ACTION(comb) blitfunc=comb::doPix; -#else -#define __LICE__ACTION(COMBFUNC) _LICE_Fill::FillClippedTrapezoid(wid,span,px,y, x1a, x1b, dxady, dxbdy, a,b, astep,bstep, cr,cg,cb,ca, aw); -#endif - - __LICE_ACTION_CONSTANTALPHA(mode, aw, false); - -#ifdef LICE_FAVOR_SIZE_EXTREME - if (blitfunc) _LICE_Fill::FillClippedTrapezoid(wid,span,px,y, x1a, x1b, dxady, dxbdy, a,b, astep,bstep, cr,cg,cb,ca, aw, blitfunc); -#endif - -#undef __LICE__ACTION - } -} - -void LICE_FillTrapezoid(LICE_IBitmap* dest, int x1a, int x1b, int y1, int x2a, int x2b, int y2, LICE_pixel color, float alpha, int mode) -{ - LICE_FillTrapezoidF(dest,x1a,x1b,y1,x2a,x2b,y2,color,alpha,mode); -} - -static int _ysort(const void* a, const void* b) -{ - int* xya = (int*)a; - int* xyb = (int*)b; - if (xya[1] < xyb[1]) return -1; - if (xya[1] > xyb[1]) return 1; - if (xya[0] < xyb[0]) return -1; - if (xya[0] > xyb[0]) return 1; - return 0; -} - -#define _X(i) xy[2*(i)] -#define _Y(i) xy[2*(i)+1] - -static int FindNextEdgeVertex(int* xy, int a, int n, int dir) -{ - bool init = false; - double dxdy_best = 0.0f; - int i, ilo = a; - - for (i = a+1; i < n; ++i) - { - if (_Y(i) == _Y(a)) continue; - const double dxdy = (_X(i)-_X(a))/(double)(_Y(i)-_Y(a)); - if (!init || dxdy == dxdy_best || (dir < 0 && dxdy < dxdy_best) || (dir > 0 && dxdy > dxdy_best)) - { - init = true; - ilo = i; - dxdy_best = dxdy; - } - } - return ilo; -} - -void LICE_FillConvexPolygon(LICE_IBitmap* dest, const int* x, const int* y, int npoints, LICE_pixel color, float alpha, int mode) -{ - if (!dest) return; - if (npoints < 3) return; - - int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - - int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc) - { - __LICE_SCU(destbm_w); - __LICE_SCU(destbm_h); - if (IGNORE_SCALING(mode)) __sc = 0; // input is already scaled, ignore - mode |= LICE_BLIT_IGNORE_SCALING; - } - - int* xy = 0; - int xyt[1024]; // use stack space if small - bool usestack = npoints <= (int) (sizeof(xyt)/sizeof(int)/2); - if (usestack) xy = xyt; - else xy = (int*)malloc(npoints*sizeof(int)*2); - - int i; - { - int min_x=destbm_w,max_x=0; - for (i = 0; i < npoints; ++i) - { - int tx = x[i], ty=y[i]; - if (__sc) - { - __LICE_SC(tx); - __LICE_SC(ty); - } - if (tx < min_x) min_x=tx; - if (tx > max_x) max_x=tx; - _X(i) = tx; - if (dest->isFlipped()) ty = destbm_h-ty-1; - _Y(i) = ty; - } - qsort(xy, npoints, 2*sizeof(int), _ysort); // sorts by y, at same y sorts by x - - - int ty=_Y(0); - if (ty == _Y(npoints-1)) - { - // special case 1px high polygon - if (ty >= 0 && ty < dest->getHeight() && min_x <= max_x) - { - LICE_FillTrapezoid(dest,min_x,max_x,ty,min_x,max_x,ty,color,alpha,mode); - } - if (!usestack) free(xy); - - return; - } - } - - int a1, b1; // index of previous vertex L and R - int a2, b2; // index of next vertex L and R - int y1; // top and bottom of current trapezoid - - a1 = b1 = 0; - y1 = _Y(0); - - for (i = 1; i < npoints && _Y(i) == y1; ++i) - { - if (_X(i) == _X(0)) a1 = i; - b1 = i; - } - - a2 = FindNextEdgeVertex(xy, a1, npoints, -1); - b2 = FindNextEdgeVertex(xy, b1, npoints, 1); - - while (a1 != a2 || b1 != b2) - { - int y_a2 = _Y(a2); - int y_b2 = _Y(b2); - - int y2 = lice_min(y_a2, y_b2); - double x1a = FindXOnSegment(_X(a1), _Y(a1), _X(a2), y_a2, y1); - double x1b = FindXOnSegment(_X(b1), _Y(b1), _X(b2), y_b2, y1); - double x2a = FindXOnSegment(_X(a1), _Y(a1), _X(a2), y_a2, y2); - double x2b = FindXOnSegment(_X(b1), _Y(b1), _X(b2), y_b2, y2); - - LICE_FillTrapezoidF(dest, x1a, x1b, y1, x2a, x2b, y2, color, alpha, mode); - - bool dir = y1<=y2; // should always be true - - y1 = y2; - if (y_a2 == y1) - { - a1 = a2; - a2 = FindNextEdgeVertex(xy, a2, npoints, -1); - } - if (y_b2 == y1) - { - b1 = b2; - b2 = FindNextEdgeVertex(xy, b2, npoints, 1); - } - - if (dir) y1++; - else y1--; - } - - if (!usestack) free(xy); -} - -#undef _X -#undef _Y - - -void LICE_FillTriangle(LICE_IBitmap *dest, int x1, int y1, int x2, int y2, int x3, int y3, LICE_pixel color, float alpha, int mode) -{ - if (!dest) return; - - int x[3] = { x1, x2, x3 }; - int y[3] = { y1, y2, y3 }; - LICE_FillConvexPolygon(dest, x, y, 3, color, alpha, mode); -} - -void LICE_ThickFLine(LICE_IBitmap* dest, double x1, double y1, double x2, double y2, LICE_pixel color, float alpha, int mode, int wid) // always AA. wid is not affected by scaling (1 is always normal line, 2 is always 2 physical pixels, etc) -{ - if (!dest || wid<1) return; - if (wid==1) - { - LICE_Line(dest,(float)x1,(float)y1,(float)x2,float(y2),color,alpha,mode,true); - return; - } - - int w = dest->getWidth(); - int h = dest->getHeight(); - if (dest->isFlipped()) - { - y1 = (h-1)-y1; - y2 = (h-1)-y2; - } - - const int __sc = (int)dest->Extended(LICE_EXT_GET_SCALING,NULL); - if (__sc>0) - { - __LICE_SCU(w); - __LICE_SCU(h); - if (!IGNORE_SCALING(mode)) - { - __LICE_SC(x1); - __LICE_SC(x2); - __LICE_SC(y1); - __LICE_SC(y2); - } - } - - bool steep = fabs(y2-y1) >= fabs(x2-x1); - - if (ClipFLine(&x1, &y1, &x2, &y2, w, h)) - { - if (x1 != x2 || y1 != y2) - { - int span = dest->getRowSpan(); - int aw = (int)(256.0f*alpha); - - double a1, a2, b1, b2, da, db; - int astep, bstep; - double dx = x2-x1; - double dy = y2-y1; - - int b_max; - if (!steep) - { - a1 = x1; - a2 = x2; - b1 = y1; - b2 = y2; - da = dx; - db = dy; - astep = 1; - bstep = span; - b_max = h; - } - else - { - a1 = y1; - a2 = y2; - b1 = x1; - b2 = x2; - da = dy; - db = dx; - astep = span; - bstep = 1; - b_max = w; - } - - if (da < 0.0) - { - da = -da; - db = -db; - SWAP(a1, a2); - SWAP(b1, b2); - } - if (db < 0.0) - { - bstep = -bstep; - } - - int n = (int)(floor(a2)-ceil(a1)); - double dbda = db/da; - - double ta = ceil(a1); - double tb = b1+(ta-a1)*dbda; - double bf = tb-floor(tb); - int err = (int)(bf*65536.0); - if (bstep < 0) err = 65535-err; - int derr = (int)(fabs(dbda)*65536.0); - - int b_pos = (int) tb; - LICE_pixel *px = dest->getBits() + (int)ta*astep+b_pos*abs(bstep); - - if (bstep < 0) { px -= bstep; b_pos++; } - -#ifdef LICE_FAVOR_SIZE - - LICE_COMBINEFUNC blitfunc=NULL; - #define __LICE__ACTION(comb) blitfunc=comb::doPix; - -#else - #define __LICE__ACTION(COMBFUNC) \ - __LICE_LineClass::LICE_FLineImplFill(px,n,err,derr,astep,bstep, color, aw, wid, b_pos, b_max) -#endif - - __LICE_ACTION_NOSRCALPHA(mode, aw, false); - -#ifdef LICE_FAVOR_SIZE - if (blitfunc) - { - __LICE_LineClass::LICE_FLineImplFill(px,n,err,derr,astep,bstep, color, aw, wid, b_pos, b_max, blitfunc); - } -#endif - - #undef __LICE__ACTION - } - } -} diff --git a/oversampling/WDL/lice/lice_lvg.cpp b/oversampling/WDL/lice/lice_lvg.cpp deleted file mode 100644 index d68bb06..0000000 --- a/oversampling/WDL/lice/lice_lvg.cpp +++ /dev/null @@ -1,625 +0,0 @@ -#ifndef WDL_NO_DEFINE_MINMAX -#define WDL_NO_DEFINE_MINMAX -#endif -#include "lice.h" -#include -#include -#include "../projectcontext.h" -#include "../lineparse.h" -#include "../ptrlist.h" -#include "../assocarray.h" - -#define PI 3.1415926535897932384626433832795 - -static inline int chartohex(char c) -{ - if (c >= '0' && c<='9') return c-'0'; - else if (c>='A' && c<='F') return 10 + c - 'A'; - else if (c>='a' && c<='f') return 10 + c - 'a'; - return -1; -} -static int __boolval(const char *p, int defval) -{ - if (!stricmp(p,"yes") || - !stricmp(p,"true") || - !stricmp(p,"on") || - atoi(p)>0) return 1; - if (!stricmp(p,"no") || - !stricmp(p,"false") || - !stricmp(p,"off") || - !stricmp(p,"0")) return 0; - return defval; -} - -static LICE_pixel __colorval(const char *p, LICE_pixel def) -{ - const size_t lp = strlen(p); - if (lp == 3) - { - int r = chartohex(p[0]); - int g = chartohex(p[1]); - int b = chartohex(p[2]); - if (r>=0&&g>=0&&b>=0) - def = LICE_RGBA(r+(r<<4),g+(g<<4),b+(b<<4),255); - } - else if (lp == 6||lp==8) - { - int r = chartohex(p[0]), r2 = chartohex(p[1]); - int g = chartohex(p[2]), g2 = chartohex(p[3]); - int b = chartohex(p[4]), b2 = chartohex(p[5]); - int a = 0xf, a2=0xf; - if (lp==8) { a=chartohex(p[6]); a2=chartohex(p[7]); } - if (r>=0&&g>=0&&b>=0&&r2>=0&&g2>=0&&b2>=0&&a>=0&&a2>=0) - def = LICE_RGBA((r<<4)+r2,(g<<4)+g2,(b<<4)+b2,(a<<4)+a2); - } - return def; -} - -class lvgRenderState -{ -public: - lvgRenderState() - { - m_color=LICE_RGBA(255,255,255,255); - m_alpha=1.0f; - m_blend = LICE_BLIT_MODE_COPY; - m_aa = false; - } - ~lvgRenderState() { } - - LICE_pixel m_color; - float m_alpha; - int m_blend; - bool m_aa; - - WDL_TypedBuf m_aa_stack; - WDL_TypedBuf m_alpha_stack; - WDL_TypedBuf m_color_stack; - WDL_TypedBuf m_blend_stack; - -///////// - - void parsealpha(const char *p) - { - int idx=0; - if (*p == '-') idx++; - if (p[idx] == '.' || (p[idx] >= '0' && p[idx] <= '9')) - m_alpha = (float)atof(p); - } - - void parseaa(const char *p) - { - int a = __boolval(p,-1); - if (a>=0) m_aa = !!a; - } - - void parseblend(const char *p) - { - if (!stricmp(p,"copy")) m_blend = LICE_BLIT_MODE_COPY; - else if (!stricmp(p,"add")) m_blend = LICE_BLIT_MODE_ADD; - else if (!stricmp(p,"dodge")) m_blend = LICE_BLIT_MODE_DODGE; - else if (!stricmp(p,"mul")||!stricmp(p,"multiply")) m_blend = LICE_BLIT_MODE_MUL; - else if (!stricmp(p,"overlay")) m_blend = LICE_BLIT_MODE_MUL; - else if (!stricmp(p,"hsvadj")) m_blend = LICE_BLIT_MODE_HSVADJ; - } - - void parsecolor(const char *p) - { - m_color = __colorval(p,m_color); - } - -#define DEF_PUSHPOP(name,defpopval) \ - void push##name() { int sz=m_##name##_stack.GetSize(); m_##name##_stack.Resize(sz+1,false)[sz] = m_##name; } \ - void pop##name() { int sz = m_##name##_stack.GetSize()-1; m_##name = sz>=0 ? m_##name##_stack.Get()[sz] : defpopval; m_##name##_stack.Resize(sz,false); } - DEF_PUSHPOP(color,LICE_RGBA(0,0,0,255)) - DEF_PUSHPOP(alpha,1.0f) - DEF_PUSHPOP(aa,false) - DEF_PUSHPOP(blend,LICE_BLIT_MODE_COPY) -#undef DEF_PUSHPOP - - bool processAttributeLine(LineParser *lp) - { - int i,numtok=lp->getnumtokens(); - switch (lp->gettoken_enum(0,"color\0" - "alpha\0" - "aa\0" - "blend\0" - "\0")) - { -#define PROCTYPE(v,name) \ - case v: for (i=1;igettoken_str(i); \ - if (!stricmp(p,"push")) push##name(); \ - else if (!stricmp(p,"pop")) pop##name(); \ - else parse##name(p); \ - } \ - return true; - - PROCTYPE(0,color) - PROCTYPE(1,alpha) - PROCTYPE(2,aa) - PROCTYPE(3,blend) -#undef PROCTYPE - - } - return false; - } - - -}; - -class lvgImageCtx -{ -public: - lvgImageCtx(lvgImageCtx *par) : m_images(true,deleteThis) - { - m_in_render=false; - m_par=par; - m_cachedImage=0; - m_base_w=0; - m_base_h=0; - } - ~lvgImageCtx() - { - delete m_cachedImage; - m_lines.Empty(true,free); - } - - WDL_PtrList m_lines; - LICE_IBitmap *m_cachedImage; - - lvgImageCtx *m_par; - WDL_StringKeyedArray m_images; - - int m_base_w,m_base_h; - bool m_in_render; - - void render(lvgRenderState *rstate, int wantw, int wanth); - -private: - static void deleteThis(lvgImageCtx *t) { delete t; } - - double parsecoord(const char *p, double scale, bool round) - { - if (!*p) return 0; - if (p[0] == 'a' && p[1]) return atoi(p+1); - if (p[0] == 'w') - { - scale = m_cachedImage ? m_cachedImage->getWidth() : 0.0; - p++; - } - else if (p[0] == 'h') - { - scale = m_cachedImage ? m_cachedImage->getHeight() : 0.0; - p++; - } - return atof(p) * scale + (round ? 0.5 : 0.0); - } - void processLvgLine(LineParser *lp, lvgRenderState *state, LICE_IBitmap *bm, double xscale, double yscale); - -}; - -#define DECL_OPT(type, cfunc) \ - static type getoption_##type(LineParser *lp, int startidx, const char *name, type def) { \ - const size_t namelen = strlen(name); \ - for(;startidxgetnumtokens();startidx++) { \ - const char *p=lp->gettoken_str(startidx); \ - if (!strnicmp(name,p,namelen) && p[namelen]=='=') return cfunc(p+namelen+1,def); \ - } \ - return def; \ - } - -static int __intval(const char *p, int def) { return atoi(p); } -static double __dblval(const char *p, double def) { return atof(p); } - -DECL_OPT(bool,!!__boolval) -DECL_OPT(int,__intval) -DECL_OPT(double,__dblval) -DECL_OPT(LICE_pixel,__colorval) - -#undef DECL_OPT - -void lvgImageCtx::processLvgLine(LineParser *lp, lvgRenderState *state, LICE_IBitmap *bm, double xscale, double yscale) -{ - if (state->processAttributeLine(lp)) return; - - int numtok = lp->getnumtokens(); - const char *tok = lp->gettoken_str(0); - if (!stricmp(tok,"line")) - { - int i; - float lx,ly; - for (i = 1; i < numtok-1; i+= 2) - { - const char *p=lp->gettoken_str(i); - if (strstr(p,"=")) break; - float x=(float)parsecoord(p,xscale,false); - p=lp->gettoken_str(i+1); - if (strstr(p,"=")) break; - float y=(float)parsecoord(p,yscale,false); - - if (i!=1) LICE_FLine(bm,lx,ly,x,y,state->m_color,state->m_alpha,state->m_blend,state->m_aa); - - lx=x; - ly=y; - } - } - else if (!stricmp(tok,"circle")) - { - if (numtok>=4) - { - float x=(float)parsecoord(lp->gettoken_str(1),xscale,false); - float y=(float)parsecoord(lp->gettoken_str(2),yscale,false); - float r=(float)(atof(lp->gettoken_str(3))*lice_min(xscale,yscale)); - if (getoption_bool(lp,1,"fill",false)) - { - LICE_FillCircle(bm,x,y,r,state->m_color,state->m_alpha,state->m_blend,state->m_aa); - } - else - LICE_Circle(bm,x,y,r,state->m_color,state->m_alpha,state->m_blend,state->m_aa); - } - } - else if (!stricmp(tok,"arc")) - { - if (numtok>=6) - { - float x=(float)parsecoord(lp->gettoken_str(1),xscale,false); - float y=(float)parsecoord(lp->gettoken_str(2),yscale,false); - float r=(float)(atof(lp->gettoken_str(3))*lice_min(xscale,yscale)); - float a1=(float)(atof(lp->gettoken_str(4))*PI/180.0); - float a2=(float)(atof(lp->gettoken_str(5))*PI/180.0); - LICE_Arc(bm,x,y,r,a1,a2,state->m_color,state->m_alpha,state->m_blend,state->m_aa); - } - } - else if (!stricmp(tok,"fill")) - { - if (numtok>=3) // fill x y [cmask=xxxxxx kmask=xxxxxxx] - { - LICE_pixel cmask = getoption_LICE_pixel(lp,1,"cmask",LICE_RGBA(255,255,255,0)); - LICE_pixel kmask = getoption_LICE_pixel(lp,1,"kmask",LICE_RGBA(0,0,0,0)); - int x = (int)parsecoord(lp->gettoken_str(1),xscale,true); - int y = (int)parsecoord(lp->gettoken_str(2),yscale,true); - - LICE_SimpleFill(bm,x,y,state->m_color,cmask,kmask); - } - } - else if (!stricmp(tok,"rect")) - { - if (numtok>=5) // rect x y w h [dcdx=xxxxxxxx dcdy=xxxxxxxxx dcdxscale=1.0 dcdyscale=1.0] - { - LICE_pixel dcdx = getoption_LICE_pixel(lp,1,"dcdx",LICE_RGBA(0x80,0x80,0x80,0x80)); - LICE_pixel dcdy = getoption_LICE_pixel(lp,1,"dcdy",LICE_RGBA(0x80,0x80,0x80,0x80)); - double dcdxsc = getoption_double(lp,1,"dcdxscale",1.0); - double dcdysc = getoption_double(lp,1,"dcdyscale",1.0); - - // todo: any options? - int x = (int)parsecoord(lp->gettoken_str(1),xscale,true); - int y = (int)parsecoord(lp->gettoken_str(2),yscale,true); - int w = (int)parsecoord(lp->gettoken_str(3),xscale,true); - int h = (int)parsecoord(lp->gettoken_str(4),yscale,true); - if (w>0 && h>0) - { - if (dcdx!=LICE_RGBA(0x80,0x80,0x80,0x80) || - dcdy!=LICE_RGBA(0x80,0x80,0x80,0x80)) - { - LICE_pixel sc = state->m_color; - dcdxsc /= w*128.0; - dcdysc /= h*128.0; - LICE_GradRect(bm,x,y,w,h, - (float)(LICE_GETR(sc)/255.0), - (float)(LICE_GETG(sc)/255.0), - (float)(LICE_GETB(sc)/255.0), - (float)(LICE_GETA(sc)/255.0*state->m_alpha), - (float)(((int)LICE_GETR(dcdx)-0x80)*dcdxsc), - (float)(((int)LICE_GETG(dcdx)-0x80)*dcdxsc), - (float)(((int)LICE_GETB(dcdx)-0x80)*dcdxsc), - (float)(((int)LICE_GETA(dcdx)-0x80)*dcdxsc), - (float)(((int)LICE_GETR(dcdy)-0x80)*dcdysc), - (float)(((int)LICE_GETG(dcdy)-0x80)*dcdysc), - (float)(((int)LICE_GETB(dcdy)-0x80)*dcdysc), - (float)(((int)LICE_GETA(dcdy)-0x80)*dcdysc), - state->m_blend); - } - else - LICE_FillRect(bm,x,y,w,h,state->m_color,state->m_alpha,state->m_blend); - } - } - } - else if (!stricmp(tok,"rerender")) - { - if (numtok>=2) - { - int forcew=getoption_int(lp,1,"w",0),forceh=getoption_int(lp,1,"h",0); - bool useState=getoption_bool(lp,1,"usestate",false); - - lvgImageCtx *scan = this; - while (scan) - { - lvgImageCtx *p = scan->m_images.Get(lp->gettoken_str(1)); - if (p) - { - if (!p->m_in_render) - { - p->m_in_render=true; - p->render(useState ? state : NULL,forcew,forceh); - p->m_in_render=false; - } - break; - } - scan=scan->m_par; - } - } - } - else if (!stricmp(tok,"blit")) - { - if (numtok>=3) // blit image x y [options] - { - LICE_IBitmap *src=NULL; - lvgImageCtx *scan = this; - const char *rd = lp->gettoken_str(1); - - while (!strnicmp(rd,"parent:",7)) { scan = scan ? scan->m_par : NULL; rd += 7; } - - if (!stricmp(rd,"parent")) - { - if (scan) scan=scan->m_par; - if (scan) src=scan->m_cachedImage; - } - else if (!stricmp(rd,"self")) - { - if (scan) src=scan->m_cachedImage; - } - else while (scan&&!src) - { - lvgImageCtx *p = scan->m_images.Get(rd); - if (p) - { - if (!p->m_cachedImage && !p->m_in_render) - { - p->m_in_render=true; - p->render(NULL,0,0); - p->m_in_render=false; - } - src = p->m_cachedImage; - break; - } - scan=scan->m_par; - } - if (src) - { - int x = (int)parsecoord(lp->gettoken_str(2),xscale,true); - int y = (int)parsecoord(lp->gettoken_str(3),yscale,true); - - // these will be options filter= srcalpha= w= h= scale= - bool filter=getoption_bool(lp,1,"filter",true); - bool usesrcalpha = getoption_bool(lp,1,"srcalpha",true); - int w = getoption_int(lp,1,"w",src->getWidth()); - int h = getoption_int(lp,1,"h",src->getHeight()); - double sc = getoption_double(lp,1,"scale",1.0f); - if (fabs(sc-1.0)>0.0000000001) - { - w = (int)(w*sc+0.5); - h = (int)(h*sc+0.5); - } -// double ang = getoption_double(lp,1,"rotate",0.0) * PI / 180.0; - float sx=(float)getoption_double(lp,1,"srcx",0.0); - float sy=(float)getoption_double(lp,1,"srcy",0.0); - float sw=(float)getoption_double(lp,1,"srcw",src->getWidth()); - float sh=(float)getoption_double(lp,1,"srch",src->getHeight()); -// if (fabs(ang)>0.0001) LICE_RotatedBlit(bm,src,x,y,w,h,sx,sy,sw,sh,ang,true,state->m_alpha,state->m_blend,0,0); - //else - LICE_ScaledBlit(bm,src,x,y,w,h,sx,sy,sw,sh, - state->m_alpha,state->m_blend|(filter ? LICE_BLIT_FILTER_BILINEAR : 0)|(usesrcalpha ? LICE_BLIT_USE_ALPHA : 0)); - } - } - } -} - -void lvgImageCtx::render(lvgRenderState *rstate, int wantw, int wanth) -{ - if (wantw<1) wantw = m_base_w; - if (wanth<1) wanth = m_base_h; - - if (wantw<1||wanth<1) - { - if (m_cachedImage) m_cachedImage->resize(0,0); - return; - } - - if (!m_cachedImage) m_cachedImage = new LICE_MemBitmap(wantw,wanth); - else m_cachedImage->resize(wantw,wanth); - - LICE_Clear(m_cachedImage,LICE_RGBA(0,0,0,0)); - - lvgRenderState rs; - if (rstate) rs = *rstate; - - double xscale = wantw / lice_max(m_base_w,1); - double yscale = wanth / lice_max(m_base_h,1); - int x; - bool comment_state=false; - LineParser lp(comment_state); - for (x=0;x0) - processLvgLine(&lp,&rs,m_cachedImage,xscale,yscale); - } -} - -void *LICE_GetSubLVG(void *lvg, const char *subname) -{ - if (!lvg||!subname||!*subname) return NULL; - lvgImageCtx *t = (lvgImageCtx *)lvg; - return t->m_images.Get(subname); -} - -LICE_IBitmap *LICE_RenderLVG(void *lvg, int reqw, int reqh, LICE_IBitmap *bmOut) -{ - lvgImageCtx *t = (lvgImageCtx *)lvg; - if (!t || !t->m_lines.GetSize() || t->m_in_render) return NULL; - - if (bmOut) - { - delete t->m_cachedImage; - t->m_cachedImage = bmOut; - } - else if (!t->m_cachedImage) t->m_cachedImage = new LICE_MemBitmap; - - t->m_in_render=true; - t->render(NULL,reqw,reqh); - t->m_in_render=false; - - LICE_IBitmap *ret = t->m_cachedImage; - - t->m_cachedImage=NULL; - - return ret; -} - -void LICE_DestroyLVG(void *lvg) -{ - lvgImageCtx *t = (lvgImageCtx *)lvg; - if (t && !t->m_par) delete t; -} - -class lvgRdContext : public ProjectStateContext -{ -public: - lvgRdContext(FILE *fp) { m_fp=fp; } - virtual ~lvgRdContext() { } - - virtual void AddLine(const char *fmt, ...) {}; - virtual int GetLine(char *buf, int buflen) // returns -1 on eof - { - if (!m_fp) return -1; - for (;;) - { - buf[0]=0; - fgets(buf,buflen,m_fp); - if (!buf[0]) return -1; - - char *p=buf; - while (*p) p++; - while (p>buf && (p[-1] == '\r' || p[-1]=='\n')) p--; - *p=0; - if (*buf) return 0; - } - } - - virtual WDL_INT64 GetOutputSize() { return 0; } - virtual int GetTempFlag() { return 0; } - virtual void SetTempFlag(int flag) {} - - FILE *m_fp; -}; - -void *LICE_LoadLVGFromContext(ProjectStateContext *ctx, const char *nameInfo, int defw, int defh) -{ - if (!ctx) return NULL; - - bool err=false; - int ignoreBlockCnt=0; - - lvgImageCtx *retimg = new lvgImageCtx(NULL); - lvgImageCtx *curimg = NULL; - - if (nameInfo) - { - curimg = retimg; - curimg->m_base_w = defw; - curimg->m_base_h = defh; - } - - while (!err) - { - char line[4096]; - line[0]=0; - if (ctx->GetLine(line,sizeof(line))) break; - - char *p=line; - while (*p == ' ' || *p == '\t') p++; - if (!*p) continue; - - if (ignoreBlockCnt>0) - { - if (*p == '<') ignoreBlockCnt++; - else if (*p == '>') ignoreBlockCnt--; - } - else - { - if (*p == '<') - { - bool comment_state=false; - LineParser lp(comment_state); - if (!lp.parse(p)&&lp.getnumtokens()>=2 && !strcmp(lp.gettoken_str(0),"m_images.Insert(lp.gettoken_str(1),img); - curimg = img; - } - curimg->m_base_w = lp.gettoken_int(2); - curimg->m_base_h = lp.gettoken_int(3); - } - else ignoreBlockCnt++; - } - else if (curimg) - { - if (*p == '>') - { - curimg = curimg->m_par; - if (!curimg) break; // success! - } - else - { - curimg->m_lines.Add(strdup(p)); - } - } - - if (!curimg) err=true; // 24-bit RGB) - -struct ONode -{ - WDL_INT64 colorcount; // number of color instances at or below this node - WDL_INT64 sumrgb[3]; - int childflag; // 0=leaf, >0=index of single child, <0=branch - int leafidx; // populated at the end - ONode* next; // for OTree::branches - ONode* children[8]; -}; - -struct OTree -{ - int maxcolors; - int leafcount; - ONode* trunk; - ONode* branches[OCTREE_DEPTH]; // linked lists of branches for each level of the tree - ONode* spares; - LICE_pixel* palette; // populated at the end - bool palette_valid; -}; - - - -int LICE_BuildPalette(LICE_IBitmap* bmp, LICE_pixel* palette, int maxcolors) -{ - void* tree = LICE_CreateOctree(maxcolors); - LICE_BuildOctree(tree, bmp); - int sz = LICE_ExtractOctreePalette(tree, palette); - LICE_DestroyOctree(tree); - return sz; -} - - -static void AddColorToTree(OTree*, const LICE_pixel_chan *rgb); -static int FindColorInTree(OTree*, const LICE_pixel_chan *rgb); -static int PruneTree(OTree*); -static void DeleteNode(OTree*, ONode*, ONode **delete_to); -static int CollectLeaves(OTree*); -static int CollectNodeLeaves(ONode* node, LICE_pixel* palette, int colorcount); - - -void* LICE_CreateOctree(int maxcolors) -{ - OTree* tree = new OTree; - memset(tree, 0, sizeof(OTree)); - tree->maxcolors = maxcolors; - tree->trunk = new ONode; - memset(tree->trunk, 0, sizeof(ONode)); - tree->spares = NULL; - return tree; -} - - -void LICE_ResetOctree(void *octree, int maxc) -{ - OTree* tree = (OTree*)octree; - if (!tree) return; - - if (maxc > tree->maxcolors) - { - free(tree->palette); - tree->palette=0; - } - - DeleteNode(tree, tree->trunk, &tree->spares); - tree->leafcount = 0; - tree->maxcolors = maxc; - tree->palette_valid=false; - memset(tree->branches,0,sizeof(tree->branches)); - - tree->trunk=tree->spares; - if (tree->trunk) tree->spares = tree->trunk->next; - else tree->trunk = new ONode; - - memset(tree->trunk, 0, sizeof(ONode)); -} - -void LICE_DestroyOctree(void* octree) -{ - OTree* tree = (OTree*)octree; - if (!tree) return; - - DeleteNode(tree, tree->trunk, NULL); - - ONode *p = tree->spares; - while (p) - { - ONode *del = p; - p = p->next; - - delete del; - } - free(tree->palette); - delete tree; -} - - -int LICE_BuildOctree(void* octree, LICE_IBitmap* bmp) -{ - OTree* tree = (OTree*)octree; - if (!tree || !bmp) return 0; - - tree->palette_valid = false; - - int y; - const int h=bmp->getHeight(); - const int w=bmp->getWidth(); - const int rowspan = bmp->getRowSpan(); - const LICE_pixel *bits = bmp->getBits(); - for (y = 0; y < h; ++y) - { - const LICE_pixel *px = bits+y*rowspan; - int x=w; - while (x--) - { - AddColorToTree(tree, (const LICE_pixel_chan*)px); - if (tree->leafcount > tree->maxcolors) PruneTree(tree); - px++; - } - } - - return tree->leafcount; -} - -int LICE_BuildOctreeForAlpha(void* octree, LICE_IBitmap* bmp, unsigned int minalpha) -{ - OTree* tree = (OTree*)octree; - if (!tree || !bmp) return 0; - - tree->palette_valid = false; - - int y; - const int h=bmp->getHeight(); - const int w=bmp->getWidth(); - const int rowspan = bmp->getRowSpan(); - const LICE_pixel *bits = bmp->getBits(); - int pxcnt=0; - for (y = 0; y < h; ++y) - { - const LICE_pixel *px = bits+y*rowspan; - int x=w; - while (x--) - { - if (px[LICE_PIXEL_A] >= minalpha) - { - AddColorToTree(tree, (const LICE_pixel_chan*)px); - if (tree->leafcount > tree->maxcolors) PruneTree(tree); - pxcnt++; - } - px++; - } - } - - return pxcnt; -} - - -int LICE_BuildOctreeForDiff(void* octree, LICE_IBitmap* bmp, LICE_IBitmap* refbmp, LICE_pixel mask) -{ - OTree* tree = (OTree*)octree; - if (!tree || !bmp || !refbmp) return 0; - - tree->palette_valid=false; - - int y; - const int h=lice_min(bmp->getHeight(),refbmp->getHeight()); - const int w=lice_min(bmp->getWidth(),refbmp->getWidth()); - - int rowspan = bmp->getRowSpan(); - int rowspan2 = refbmp->getRowSpan(); - const LICE_pixel *bits = bmp->getBits(); - const LICE_pixel *bits2 = refbmp->getBits(); - - if (bmp->isFlipped()) - { - bits += rowspan * (bmp->getHeight()-1); - rowspan = -rowspan; - } - - if (refbmp->isFlipped()) - { - bits2 += rowspan2 * (refbmp->getHeight()-1); - rowspan2 = -rowspan2; - } - - int pxcnt=0; - for (y = 0; y < h; ++y) - { - const LICE_pixel * px = bits+y*rowspan; - const LICE_pixel * px2 = bits2+y*rowspan2; - int x=w; - while (x--) - { - if ((*px ^ *px2) & mask) - { - AddColorToTree(tree, (const LICE_pixel_chan *)px); - if (tree->leafcount > tree->maxcolors) PruneTree(tree); - pxcnt++; - } - px++; - px2++; - } - } - - return pxcnt; -} - - -int LICE_FindInOctree(void* octree, LICE_pixel color) -{ - OTree* tree = (OTree*)octree; - if (!tree) return 0; - - if (!tree->palette_valid) CollectLeaves(tree); - - return FindColorInTree(tree, (const LICE_pixel_chan *)&color); -} - - -int LICE_ExtractOctreePalette(void* octree, LICE_pixel* palette) -{ - OTree* tree = (OTree*)octree; - if (!tree || !palette) return 0; - - if (!tree->palette_valid) CollectLeaves(tree); - - if (tree->palette) memcpy(palette, tree->palette, tree->maxcolors*sizeof(LICE_pixel)); - - return tree->leafcount; -} - - - -void LICE_TestPalette(LICE_IBitmap* bmp, LICE_pixel* palette, int numcolors) -{ - int x, y; - for (y = 0; y < bmp->getHeight(); ++y) - { - LICE_pixel* px = bmp->getBits()+y*bmp->getRowSpan(); - for (x = 0; x < bmp->getWidth(); ++x) - { - const LICE_pixel col = px[x]; - const int rgb[3] = { (int)LICE_GETR(col), (int)LICE_GETG(col), (int)LICE_GETB(col) }; - - int minerr = 0x7FFFFFFF; - int bestcol=-1; - int i; - for (i = 0; i < numcolors; ++i) - { - const LICE_pixel palcol = palette[i]; - const int rerr[3] = { rgb[0]-(int)LICE_GETR(palcol), rgb[1]-(int)LICE_GETG(palcol), rgb[2]-(int)LICE_GETB(palcol) }; - const int err = rerr[0]*rerr[0]+rerr[1]*rerr[1]+rerr[2]*rerr[2]; - if (err < minerr) - { - bestcol=i; - minerr=err; - } - } - px[x] = palette[bestcol]; - } - } -} - - -void AddColorToTree(OTree* tree, const LICE_pixel_chan *rgb) -{ - ONode* p = tree->trunk; - p->colorcount++; - - int i; - const unsigned char r = rgb[LICE_PIXEL_R]; - const unsigned char g = rgb[LICE_PIXEL_G]; - const unsigned char b = rgb[LICE_PIXEL_B]; - for (i = OCTREE_DEPTH-1; i >= 0; --i) - { - const int j = i+8-OCTREE_DEPTH; - const unsigned char idx = (((r>>(j-2))&4))|(((g>>(j-1))&2))|((b>>j)&1); - - ONode* np = p->children[idx]; - bool isleaf = false; - - if (np) - { - isleaf = !np->childflag; - } - else // add node - { - if (!p->childflag) // first time down this path - { - p->childflag=idx+1; - } - else if (p->childflag > 0) // creating a new branch - { - p->childflag = -1; - p->next = tree->branches[i]; - tree->branches[i] = p; - } - // else multiple branch, which we don't care about - - np=tree->spares; - if (np) tree->spares = np->next; - else np = new ONode; - - p->children[idx] = np; - memset(np, 0, sizeof(ONode)); - } - - np->sumrgb[0] += r; - np->sumrgb[1] += g; - np->sumrgb[2] += b; - np->colorcount++; - - if (isleaf) return; - - p=np; // continue downward - } - - // p is a new leaf at the bottom - tree->leafcount++; -} - -int FindColorInTree(OTree* tree, const LICE_pixel_chan *rgb) -{ - ONode* p = tree->trunk; - - int i; - const unsigned char r=rgb[LICE_PIXEL_R]; - const unsigned char g=rgb[LICE_PIXEL_G]; - const unsigned char b=rgb[LICE_PIXEL_B]; - for (i = OCTREE_DEPTH-1; i >= 0; --i) - { - if (!p->childflag) break; - - const int j = i+8-OCTREE_DEPTH; - const unsigned char idx = (((r>>(j-2))&4))|(((g>>(j-1))&2))|((b>>j)&1); - - ONode* np = p->children[idx]; - if (!np) break; - - p = np; - } - - return p->leafidx; -} - - -int PruneTree(OTree* tree) -{ - ONode* branch=0; - int i; - for (i = 0; i < OCTREE_DEPTH; ++i) // prune at the furthest level from the trunk - { - branch = tree->branches[i]; - if (branch) - { - tree->branches[i] = branch->next; - branch->next=0; - break; - } - } - - if (branch) - { - for (i = 0; i < 8; ++i) - { - if (branch->children[i]) - { - DeleteNode(tree, branch->children[i],&tree->spares); - branch->children[i]=0; - } - } - branch->childflag=0; // now it's a leaf - tree->leafcount++; - } - - return tree->leafcount; -} - -int CollectLeaves(OTree* tree) -{ - if (!tree->palette) tree->palette = (LICE_pixel*)malloc(tree->maxcolors*sizeof(LICE_pixel)); - - if (!tree->palette) return 0; - - int sz = CollectNodeLeaves(tree->trunk, tree->palette, 0); - memset(tree->palette+sz, 0, (tree->maxcolors-sz)*sizeof(LICE_pixel)); - tree->palette_valid = true; - - return sz; -} - -int CollectNodeLeaves(ONode* p, LICE_pixel* palette, int colorcount) -{ - if (!p->childflag) - { - p->leafidx = colorcount; - int r = (int)((double)p->sumrgb[0]/(double)p->colorcount); - int g = (int)((double)p->sumrgb[1]/(double)p->colorcount); - int b = (int)((double)p->sumrgb[2]/(double)p->colorcount); - palette[colorcount++] = LICE_RGBA(r, g, b, 255); - } - else - { - if (p->childflag > 0) - { - colorcount = CollectNodeLeaves(p->children[p->childflag-1], palette, colorcount); - } - else - { - int i; - for (i = 0; i < 8; ++i) - { - if (p->children[i]) - { - colorcount = CollectNodeLeaves(p->children[i], palette, colorcount); - } - } - } - // this is a branch or passthrough node, record the index - // of any downtree leaf here so that we can return it for - // color lookups that want to diverge off this node - p->leafidx = colorcount-1; - } - - // colorcount should == leafcount - return colorcount; -} - - -void DeleteNode(OTree* tree, ONode* p, ONode **delete_to) -{ - if (!p->childflag) - { - tree->leafcount--; - } - else if (p->childflag > 0) - { - DeleteNode(tree, p->children[p->childflag-1],delete_to); - } - else - { - int i; - for (i = 0; i < 8; ++i) - { - if (p->children[i]) - { - DeleteNode(tree, p->children[i],delete_to); - } - } - } - - if (delete_to) - { - p->next = *delete_to; - *delete_to = p; - } - else - { - delete p; - } -} - diff --git a/oversampling/WDL/lice/lice_pcx.cpp b/oversampling/WDL/lice/lice_pcx.cpp deleted file mode 100644 index 6b9b1fc..0000000 --- a/oversampling/WDL/lice/lice_pcx.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - Cockos WDL - LICE - Lightweight Image Compositing Engine - Copyright (C) 2007 and later, Cockos Incorporated - File: lice_pcx.cpp (PCX loading for LICE) - See lice.h for license and other information -*/ - -#include "lice.h" -#include "../wdltypes.h" - -#include - -// note: you'd never really want to use PCX files, but in case you do... - -LICE_IBitmap *LICE_LoadPCX(const char *filename, LICE_IBitmap *_bmp) -{ - FILE *fp = WDL_fopenA(filename,"rb"); - if(!fp) return 0; - - fgetc(fp); - if (fgetc(fp) != 5) { fclose(fp); return NULL; } - if (fgetc(fp) != 1) { fclose(fp); return NULL; } - if (fgetc(fp) != 8) { fclose(fp); return NULL; } - - int sx = fgetc(fp); sx += fgetc(fp)<<8; - int sy = fgetc(fp); sy += fgetc(fp)<<8; - int ex = fgetc(fp); ex += fgetc(fp)<<8; - int ey = fgetc(fp); ey += fgetc(fp)<<8; - - - unsigned char pal[768]; - fseek(fp,-769,SEEK_END); - if (fgetc(fp) != 12) { fclose(fp); return NULL; } - if (fread(pal,1,768,fp) != 768 || feof(fp)) - { - fclose(fp); - return NULL; - } - - - LICE_IBitmap *usebmp = NULL; - if (_bmp) (usebmp=_bmp)->resize(ex-sx+1,ey-sy+1); - else usebmp = new WDL_NEW LICE_MemBitmap(ex-sx+1,ey-sy+1); - if (!usebmp || usebmp->getWidth() != (ex-sx+1) || usebmp->getHeight() != (ey-sy+1)) - { - if (usebmp != _bmp) delete usebmp; - fclose(fp); - return NULL; - } - - fseek(fp,128,SEEK_SET); - - LICE_Clear(usebmp,0); - int y = usebmp->getHeight(); - int w = usebmp->getWidth(); - int rowspan = usebmp->getRowSpan(); - LICE_pixel *pout = usebmp->getBits(); - if (usebmp->isFlipped()) - { - pout += rowspan*(y-1); - rowspan=-rowspan; - } - while (y--) - { - int xpos = 0; - while (xpos < w) - { - int c = fgetc(fp); - if (c&~255) break; - if ((c & 192) == 192) - { - int oc = (fgetc(fp))&255; - LICE_pixel t=LICE_RGBA(pal[oc*3],pal[oc*3+1],pal[oc*3+2],255); - - c&=63; - while (c-- && xposfilename && *p != '\\' && *p != '/' && *p != '.') p--; - if (stricmp(p,".pcx")) return 0; - } - return LICE_LoadPCX(filename,bmpbase); - } - static const char *get_extlist() - { - return "PCX files (*.PCX)\0*.PCX\0"; - } - -}; - -LICE_PCXLoader LICE_pcxldr; diff --git a/oversampling/WDL/lice/lice_png.cpp b/oversampling/WDL/lice/lice_png.cpp deleted file mode 100644 index d2f5656..0000000 --- a/oversampling/WDL/lice/lice_png.cpp +++ /dev/null @@ -1,375 +0,0 @@ -/* - Cockos WDL - LICE - Lightweight Image Compositing Engine - Copyright (C) 2007 and later, Cockos Incorporated - File: lice_png.cpp (PNG loading for LICE) - See lice.h for license and other information -*/ - -#include "lice.h" - -#include "../wdltypes.h" - -#include -#include "../libpng/png.h" - -#ifdef __APPLE__ -#include // for loading images from embedded resource -#endif - - -LICE_IBitmap *LICE_LoadPNG(const char *filename, LICE_IBitmap *bmp) -{ - FILE *fp = NULL; -#if defined(_WIN32) && !defined(WDL_NO_SUPPORT_UTF8) - #ifdef WDL_SUPPORT_WIN9X - if (GetVersion()<0x80000000) - #endif - { - WCHAR wf[2048]; - if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,filename,-1,wf,2048)) - fp = _wfopen(wf,L"rb"); - } -#endif - - if (!fp) fp = WDL_fopenA(filename,"rb"); - if (!fp) return 0; - - png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if(!png_ptr) - { - fclose(fp); - return 0; - } - - png_infop info_ptr = png_create_info_struct(png_ptr); - if(!info_ptr) - { - png_destroy_read_struct(&png_ptr, NULL, NULL); - fclose(fp); - return 0; - } - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - fclose(fp); - return 0; - } - - png_init_io(png_ptr, fp); - - png_read_info(png_ptr, info_ptr); - - unsigned int width, height; - int bit_depth, color_type, interlace_type, compression_type, filter_method; - png_get_IHDR(png_ptr, info_ptr, &width, &height, - &bit_depth, &color_type, &interlace_type, - &compression_type, &filter_method); - - //convert whatever it is to RGBA - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); - - if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_expand_gray_1_2_4_to_8(png_ptr); - - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - { - png_set_tRNS_to_alpha(png_ptr); - color_type |= PNG_COLOR_MASK_ALPHA; - } - - if (bit_depth == 16) - png_set_strip_16(png_ptr); - - if (bit_depth < 8) - png_set_packing(png_ptr); - - if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - - if (color_type & PNG_COLOR_MASK_ALPHA) - png_set_swap_alpha(png_ptr); - else - png_set_filler(png_ptr, 0xff, PNG_FILLER_BEFORE); - - LICE_IBitmap *delbmp = NULL; - - if (bmp) bmp->resize(width,height); - else delbmp = bmp = new WDL_NEW LICE_MemBitmap(width,height); - - if (!bmp || bmp->getWidth() != (int)width || bmp->getHeight() != (int)height) - { - delete delbmp; - png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); - fclose(fp); - return 0; - } - - unsigned char **row_pointers=(unsigned char **)malloc(height*sizeof(unsigned char *));; - LICE_pixel *srcptr = bmp->getBits(); - int dsrcptr=bmp->getRowSpan(); - if (bmp->isFlipped()) - { - srcptr += dsrcptr*(bmp->getHeight()-1); - dsrcptr=-dsrcptr; - } - unsigned int i; - for(i=0;i0) - { - unsigned char a = bp[0]; - unsigned char r = bp[1]; - unsigned char g = bp[2]; - unsigned char b = bp[3]; - ((LICE_pixel*)bp)[0] = LICE_RGBA(r,g,b,a); - bp+=4; - } - } - #endif - free(row_pointers); - - return bmp; -} - -typedef struct -{ - unsigned char *data; - int len; -} pngReadStruct; - -static void staticPngReadFunc(png_structp png_ptr, png_bytep data, png_size_t length) -{ - pngReadStruct *readStruct = (pngReadStruct *)png_get_io_ptr(png_ptr); - memset(data, 0, length); - - int l = (int)length; - if (l > readStruct->len) l = readStruct->len; - memcpy(data, readStruct->data, l); - readStruct->data += l; - readStruct->len -= l; -} - -#ifndef _WIN32 -LICE_IBitmap *LICE_LoadPNGFromNamedResource(const char *name, LICE_IBitmap *bmp) // returns a bitmap (bmp if nonzero) on success -{ - char buf[2048]; - buf[0]=0; - if (strlen(name)>400) return NULL; // max name for this is 400 chars - -#ifdef __APPLE__ - CFBundleRef bund = CFBundleGetMainBundle(); - if (bund) - { - CFURLRef url=CFBundleCopyBundleURL(bund); - if (url) - { - CFURLGetFileSystemRepresentation(url,true,(UInt8*)buf,sizeof(buf)-512); - CFRelease(url); - } - } - if (!buf[0]) return 0; - strcat(buf,"/Contents/Resources/"); -#else - int sz = readlink("/proc/self/exe", buf, sizeof(buf)-512); - if (sz < 1) - { - static char tmp; - // this will likely not work if the program was launched with a relative path - // and the cwd has changed, but give it a try anyway - Dl_info inf={0,}; - if (dladdr(&tmp,&inf) && inf.dli_fname) - sz = (int) strlen(inf.dli_fname); - else - sz = 0; - } - - if ((unsigned int)sz >= sizeof(buf)-512) sz = sizeof(buf)-512-1; - buf[sz]=0; - char *p = buf; - while (*p) p++; - while (p > buf && *p != '/') p--; - *p=0; - strcat(buf,"/Resources/"); -#endif // !__APPLE__ - - strcat(buf,name); - return LICE_LoadPNG(buf,bmp); -} -#endif - -LICE_IBitmap *LICE_LoadPNGFromMemory(const void *data_in, int buflen, LICE_IBitmap *bmp) -{ - if (buflen<8) return NULL; - unsigned char *data = (unsigned char *)(void*)data_in; - if(png_sig_cmp(data, 0, 8)) return NULL; - - pngReadStruct readStruct = {data, buflen}; - - png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if(!png_ptr) - { - return 0; - } - - png_infop 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))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return 0; - } - - png_set_read_fn(png_ptr, &readStruct, staticPngReadFunc); - - png_read_info(png_ptr, info_ptr); - - unsigned int width, height; - int bit_depth, color_type, interlace_type, compression_type, filter_method; - png_get_IHDR(png_ptr, info_ptr, &width, &height, - &bit_depth, &color_type, &interlace_type, - &compression_type, &filter_method); - - //convert whatever it is to RGBA - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); - - if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_expand_gray_1_2_4_to_8(png_ptr); - - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) - { - png_set_tRNS_to_alpha(png_ptr); - color_type |= PNG_COLOR_MASK_ALPHA; - } - - if (bit_depth == 16) - png_set_strip_16(png_ptr); - - if (bit_depth < 8) - png_set_packing(png_ptr); - - if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - - if (color_type & PNG_COLOR_MASK_ALPHA) - png_set_swap_alpha(png_ptr); - else - png_set_filler(png_ptr, 0xff, PNG_FILLER_BEFORE); - - LICE_IBitmap *delbmp = NULL; - - if (bmp) bmp->resize(width,height); - else delbmp = bmp = new WDL_NEW LICE_MemBitmap(width,height); - if (!bmp || bmp->getWidth() != (int)width || bmp->getHeight() != (int)height) - { - delete delbmp; - png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); - return 0; - } - - unsigned char **row_pointers=(unsigned char **)malloc(height*sizeof(unsigned char *));; - LICE_pixel *srcptr = bmp->getBits(); - int dsrcptr=bmp->getRowSpan(); - unsigned int i; - for(i=0;i0) - { - unsigned char a = bp[0]; - unsigned char r = bp[1]; - unsigned char g = bp[2]; - unsigned char b = bp[3]; - ((LICE_pixel*)bp)[0] = LICE_RGBA(r,g,b,a); - bp+=4; - } - } - #endif - free(row_pointers); - return bmp; -} -LICE_IBitmap *LICE_LoadPNGFromResource(HINSTANCE hInst, const char *resid, LICE_IBitmap *bmp) -{ -#ifdef _WIN32 - HRSRC hResource = FindResource(hInst, resid, "PNG"); - if(!hResource) return NULL; - - DWORD imageSize = SizeofResource(hInst, hResource); - if(imageSize < 8) return NULL; - - HGLOBAL res = LoadResource(hInst, hResource); - const void* pResourceData = LockResource(res); - if(!pResourceData) return NULL; - - LICE_IBitmap * ret = LICE_LoadPNGFromMemory(pResourceData,imageSize,bmp); - - // todo : cleanup res?? - - return ret; -#else - return 0; -#endif -} - - -class LICE_PNGLoader -{ -public: - _LICE_ImageLoader_rec rec; - LICE_PNGLoader() - { - rec.loadfunc = loadfunc; - rec.get_extlist = get_extlist; - rec._next = LICE_ImageLoader_list; - LICE_ImageLoader_list = &rec; - } - - static LICE_IBitmap *loadfunc(const char *filename, bool checkFileName, LICE_IBitmap *bmpbase) - { - if (checkFileName) - { - const char *p=filename; - while (*p)p++; - while (p>filename && *p != '\\' && *p != '/' && *p != '.') p--; - if (stricmp(p,".png")) return 0; - } - return LICE_LoadPNG(filename,bmpbase); - } - static const char *get_extlist() - { - return "PNG files (*.PNG)\0*.PNG\0"; - } - -}; - -LICE_PNGLoader LICE_pngldr; diff --git a/oversampling/WDL/lice/lice_png_write.cpp b/oversampling/WDL/lice/lice_png_write.cpp deleted file mode 100644 index 29f6719..0000000 --- a/oversampling/WDL/lice/lice_png_write.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - Cockos WDL - LICE - Lightweight Image Compositing Engine - Copyright (C) 2007 and later, Cockos Incorporated - File: lice_png_write.cpp (PNG saving for LICE) - See lice.h for license and other information -*/ - -#include "lice.h" - - -#include -#include "../libpng/png.h" - - -bool LICE_WritePNG(const char *filename, LICE_IBitmap *bmp, bool wantalpha /*=true*/) -{ - if (!bmp || !filename) return false; - /* - ** Joshua Teitelbaum 1/1/2008 - ** Gifted to cockos for toe nail clippings. - ** - ** JF> tweaked some - */ - png_structp png_ptr=NULL; - png_infop info_ptr=NULL; - unsigned char *rowbuf=NULL; - - FILE *fp=NULL; -#if defined(_WIN32) && !defined(WDL_NO_SUPPORT_UTF8) - #ifdef WDL_SUPPORT_WIN9X - if (GetVersion()<0x80000000) - #endif - { - WCHAR wf[2048]; - if (MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,filename,-1,wf,2048)) - fp = _wfopen(wf,L"wb"); - } -#endif - if (!fp) fp = fopen(filename,"wb"); - - if (fp == NULL) return false; - - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,NULL, NULL, NULL); - - if (png_ptr == NULL) { - fclose(fp); - return false; - } - - info_ptr = png_create_info_struct(png_ptr); - if (info_ptr == NULL) { - fclose(fp); - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - return false; - } - - if (setjmp(png_jmpbuf(png_ptr))) { - /* If we get here, we had a problem reading the file */ - if (fp) fclose(fp); - fp=0; - free(rowbuf); - rowbuf=0; - png_destroy_write_struct(&png_ptr, &info_ptr); - return false; - } - - - png_init_io(png_ptr, fp); - int width=bmp->getWidth(); - int height = bmp->getHeight(); - -#define BITDEPTH 8 - png_set_IHDR(png_ptr, info_ptr, width, height, BITDEPTH, wantalpha ? PNG_COLOR_TYPE_RGB_ALPHA : PNG_COLOR_TYPE_RGB, - PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - - png_write_info(png_ptr, info_ptr); - - png_set_bgr(png_ptr); - - // kill alpha channel bytes if not wanted - if (!wantalpha) png_set_filler(png_ptr, 0, PNG_FILLER_AFTER); - - LICE_pixel *ptr=(LICE_pixel *)bmp->getBits(); - int rowspan=bmp->getRowSpan(); - if (bmp->isFlipped()) - { - ptr+=rowspan*(bmp->getHeight()-1); - rowspan=-rowspan; - } - - - if (LICE_PIXEL_B != 0 || LICE_PIXEL_G != 1 || LICE_PIXEL_R != 2 || LICE_PIXEL_A != 3) - { - rowbuf=(unsigned char *)malloc(width*4); - int k; - for (k = 0; k < height; k++) - { - int x; - unsigned char *bout = rowbuf; - LICE_pixel_chan *bin = (LICE_pixel_chan *) ptr; - for(x=0;x - -void LICE_TexGen_Marble(LICE_IBitmap *dest, const RECT *rect, float rv, float gv, float bv, float intensity) -{ - int span=dest->getRowSpan(); - int w = dest->getWidth(); - int h = dest->getHeight(); - int x = 0; - int y = 0; - if(rect) - { - x = rect->left; - y = rect->top; - w = rect->right - rect->left; - h = rect->bottom - rect->top; - } - - if (x<0) { w+=x; x=0; } - if (y<0) { h+=y; y=0; } - - const int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - if (w<1 || h < 1 || x >= destbm_w || y >= destbm_h) return; - - if (w>destbm_w-x) w=destbm_w-x; - if (h>destbm_h-y) h=destbm_h-y; - - - LICE_pixel *startp = dest->getBits(); - if (dest->isFlipped()) - { - startp += x + (dest->getHeight()-1-y)*span; - span=-span; - } - else startp += x + y*span; - - //simple 16bit marble noise generator - -#define ROL(x,y) ((x<<(y))|(((unsigned short)x)>>(16-(y)))) -#define ROR(x,y) ((((unsigned short)x)>>(y))|(x<<(16-(y)))) - - intensity/=1024.0f; - int maxc = 0; - { - LICE_pixel *p = startp; - short n1 = 0, n2 = 0; - for(int i=0;i0) - { - c = p[j-span]; - if(j==0) - c2 = p[(w-1)-span]; - else - c2 = p[(j-1)-span]; - } - - int pix = (((c + c2)/2) + val); - if(pix>maxc) maxc = pix; - p[j] = pix; - } - p+=span; - } - } - - //normalize values and apply gamma - { - LICE_pixel *p = startp; - float sc=255.0f/maxc; - - for(int i=0;igetRowSpan(); - int w = dest->getWidth(); - int h = dest->getHeight(); - int dx = 0; - int dy = 0; - if(rect) - { - dx = rect->left; - dy = rect->top; - w = rect->right - rect->left; - h = rect->bottom - rect->top; - } - - if (dx<0) { w+=dx; dx=0; } - if (dy<0) { h+=dy; dy=0; } - const int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - if (w<1 || h < 1 || dx >= destbm_w || dy >= destbm_h) return; - - if (w>destbm_w-dx) w=destbm_w-dx; - if (h>destbm_h-dy) h=destbm_h-dy; - - LICE_pixel *startp = dest->getBits(); - if (dest->isFlipped()) - { - startp += dx + (dest->getHeight()-1-dy)*span; - span=-span; - } - else startp += dx + dy*span; - - { - LICE_pixel *p = startp; - for(int i=0;i=1) - { - switch(mode) - { - case NOISE_MODE_NORMAL: val += noise(x/size, y/size)*size; break; - case NOISE_MODE_WOOD: val += (float)cos( x/size + noise(x/size,y/size) )*size/2; break; - } - size /= 2; - } - float col = (float)fabs(val/smooth)*255; - if(col>255) col=255; - - p[j] = LICE_RGBA((int)(col*rv),(int)(col*gv),(int)(col*bv),255); - } - p+=span; - } - } -} - -static float turbulence(int x, int y, float size, float isize) -{ - float value = 0.0; - const float initialSize = isize; - while(size >= 1) - { - value += noise(x * isize, y * isize) * size; - size *= 0.5f; - isize *= 2.0f; - } - return(128.0f * value * initialSize); -} - -void LICE_TexGen_CircNoise(LICE_IBitmap *dest, const RECT *rect, float rv, float gv, float bv, float nrings, float power, int size) -{ - initNoise(); - - int span=dest->getRowSpan(); - int w = dest->getWidth(); - int h = dest->getHeight(); - int x = 0; - int y = 0; - if(rect) - { - x = rect->left; - y = rect->top; - w = rect->right - rect->left; - h = rect->bottom - rect->top; - } - - if (x<0) { w+=x; x=0; } - if (y<0) { h+=y; y=0; } - const int destbm_w = dest->getWidth(), destbm_h = dest->getHeight(); - if (w<1 || h < 1 || x >= destbm_w || y >= destbm_h) return; - - if (w>destbm_w-x) w=destbm_w-x; - if (h>destbm_h-y) h=destbm_h-y; - - LICE_pixel *startp = dest->getBits(); - if (dest->isFlipped()) - { - startp += x + (dest->getHeight()-1-y)*span; - span=-span; - } - else startp += x + y*span; - - float xyPeriod = nrings; - float turbPower = power; - const float iturbSize = 1.0f/(float)size; - const float turbSize = (float)size; - - { - LICE_pixel *p = startp; - for(int i=0;i' */ - 0x60, /* 01100000 */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x30, /* 00110000 */ - 0x60, /* 01100000 */ - 0x00, /* 00000000 */ - - /* 63 0x3f '?' */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0x0c, /* 00001100 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* 64 0x40 '@' */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xde, /* 11011110 */ - 0xde, /* 11011110 */ - 0xde, /* 11011110 */ - 0xc0, /* 11000000 */ - 0x78, /* 01111000 */ - 0x00, /* 00000000 */ - - /* 65 0x41 'A' */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* 66 0x42 'B' */ - 0xfc, /* 11111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x7c, /* 01111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0xfc, /* 11111100 */ - 0x00, /* 00000000 */ - - /* 67 0x43 'C' */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* 68 0x44 'D' */ - 0xf8, /* 11111000 */ - 0x6c, /* 01101100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x6c, /* 01101100 */ - 0xf8, /* 11111000 */ - 0x00, /* 00000000 */ - - /* 69 0x45 'E' */ - 0xfe, /* 11111110 */ - 0x62, /* 01100010 */ - 0x68, /* 01101000 */ - 0x78, /* 01111000 */ - 0x68, /* 01101000 */ - 0x62, /* 01100010 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* 70 0x46 'F' */ - 0xfe, /* 11111110 */ - 0x62, /* 01100010 */ - 0x68, /* 01101000 */ - 0x78, /* 01111000 */ - 0x68, /* 01101000 */ - 0x60, /* 01100000 */ - 0xf0, /* 11110000 */ - 0x00, /* 00000000 */ - - /* 71 0x47 'G' */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0xc0, /* 11000000 */ - 0xc0, /* 11000000 */ - 0xce, /* 11001110 */ - 0x66, /* 01100110 */ - 0x3a, /* 00111010 */ - 0x00, /* 00000000 */ - - /* 72 0x48 'H' */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* 73 0x49 'I' */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* 74 0x4a 'J' */ - 0x1e, /* 00011110 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x78, /* 01111000 */ - 0x00, /* 00000000 */ - - /* 75 0x4b 'K' */ - 0xe6, /* 11100110 */ - 0x66, /* 01100110 */ - 0x6c, /* 01101100 */ - 0x78, /* 01111000 */ - 0x6c, /* 01101100 */ - 0x66, /* 01100110 */ - 0xe6, /* 11100110 */ - 0x00, /* 00000000 */ - - /* 76 0x4c 'L' */ - 0xf0, /* 11110000 */ - 0x60, /* 01100000 */ - 0x60, /* 01100000 */ - 0x60, /* 01100000 */ - 0x62, /* 01100010 */ - 0x66, /* 01100110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* 77 0x4d 'M' */ - 0xc6, /* 11000110 */ - 0xee, /* 11101110 */ - 0xfe, /* 11111110 */ - 0xfe, /* 11111110 */ - 0xd6, /* 11010110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* 78 0x4e 'N' */ - 0xc6, /* 11000110 */ - 0xe6, /* 11100110 */ - 0xf6, /* 11110110 */ - 0xde, /* 11011110 */ - 0xce, /* 11001110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* 79 0x4f 'O' */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* 80 0x50 'P' */ - 0xfc, /* 11111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x7c, /* 01111100 */ - 0x60, /* 01100000 */ - 0x60, /* 01100000 */ - 0xf0, /* 11110000 */ - 0x00, /* 00000000 */ - - /* 81 0x51 'Q' */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xce, /* 11001110 */ - 0x7c, /* 01111100 */ - 0x0e, /* 00001110 */ - - /* 82 0x52 'R' */ - 0xfc, /* 11111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x7c, /* 01111100 */ - 0x6c, /* 01101100 */ - 0x66, /* 01100110 */ - 0xe6, /* 11100110 */ - 0x00, /* 00000000 */ - - /* 83 0x53 'S' */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* 84 0x54 'T' */ - 0x7e, /* 01111110 */ - 0x7e, /* 01111110 */ - 0x5a, /* 01011010 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* 85 0x55 'U' */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* 86 0x56 'V' */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x00, /* 00000000 */ - - /* 87 0x57 'W' */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xd6, /* 11010110 */ - 0xd6, /* 11010110 */ - 0xfe, /* 11111110 */ - 0x6c, /* 01101100 */ - 0x00, /* 00000000 */ - - /* 88 0x58 'X' */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* 89 0x59 'Y' */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* 90 0x5a 'Z' */ - 0xfe, /* 11111110 */ - 0xc6, /* 11000110 */ - 0x8c, /* 10001100 */ - 0x18, /* 00011000 */ - 0x32, /* 00110010 */ - 0x66, /* 01100110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ - - /* 91 0x5b '[' */ - 0x3c, /* 00111100 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* 92 0x5c '\' */ - 0xc0, /* 11000000 */ - 0x60, /* 01100000 */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x06, /* 00000110 */ - 0x02, /* 00000010 */ - 0x00, /* 00000000 */ - - /* 93 0x5d ']' */ - 0x3c, /* 00111100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x0c, /* 00001100 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* 94 0x5e '^' */ - 0x10, /* 00010000 */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* 95 0x5f '_' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xff, /* 11111111 */ - - /* 96 0x60 '`' */ - 0x30, /* 00110000 */ - 0x18, /* 00011000 */ - 0x0c, /* 00001100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - /* 97 0x61 'a' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x78, /* 01111000 */ - 0x0c, /* 00001100 */ - 0x7c, /* 01111100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* 98 0x62 'b' */ - 0xe0, /* 11100000 */ - 0x60, /* 01100000 */ - 0x7c, /* 01111100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0xdc, /* 11011100 */ - 0x00, /* 00000000 */ - - /* 99 0x63 'c' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc0, /* 11000000 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* 100 0x64 'd' */ - 0x1c, /* 00011100 */ - 0x0c, /* 00001100 */ - 0x7c, /* 01111100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* 101 0x65 'e' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0xc0, /* 11000000 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* 102 0x66 'f' */ - 0x3c, /* 00111100 */ - 0x66, /* 01100110 */ - 0x60, /* 01100000 */ - 0xf8, /* 11111000 */ - 0x60, /* 01100000 */ - 0x60, /* 01100000 */ - 0xf0, /* 11110000 */ - 0x00, /* 00000000 */ - - /* 103 0x67 'g' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x76, /* 01110110 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x7c, /* 01111100 */ - 0x0c, /* 00001100 */ - 0xf8, /* 11111000 */ - - /* 104 0x68 'h' */ - 0xe0, /* 11100000 */ - 0x60, /* 01100000 */ - 0x6c, /* 01101100 */ - 0x76, /* 01110110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0xe6, /* 11100110 */ - 0x00, /* 00000000 */ - - /* 105 0x69 'i' */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - 0x38, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* 106 0x6a 'j' */ - 0x06, /* 00000110 */ - 0x00, /* 00000000 */ - 0x06, /* 00000110 */ - 0x06, /* 00000110 */ - 0x06, /* 00000110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x3c, /* 00111100 */ - - /* 107 0x6b 'k' */ - 0xe0, /* 11100000 */ - 0x60, /* 01100000 */ - 0x66, /* 01100110 */ - 0x6c, /* 01101100 */ - 0x78, /* 01111000 */ - 0x6c, /* 01101100 */ - 0xe6, /* 11100110 */ - 0x00, /* 00000000 */ - - /* 108 0x6c 'l' */ - 0x38, /* 00111000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x3c, /* 00111100 */ - 0x00, /* 00000000 */ - - /* 109 0x6d 'm' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xec, /* 11101100 */ - 0xfe, /* 11111110 */ - 0xd6, /* 11010110 */ - 0xd6, /* 11010110 */ - 0xd6, /* 11010110 */ - 0x00, /* 00000000 */ - - /* 110 0x6e 'n' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xdc, /* 11011100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x00, /* 00000000 */ - - /* 111 0x6f 'o' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7c, /* 01111100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7c, /* 01111100 */ - 0x00, /* 00000000 */ - - /* 112 0x70 'p' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xdc, /* 11011100 */ - 0x66, /* 01100110 */ - 0x66, /* 01100110 */ - 0x7c, /* 01111100 */ - 0x60, /* 01100000 */ - 0xf0, /* 11110000 */ - - /* 113 0x71 'q' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x76, /* 01110110 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x7c, /* 01111100 */ - 0x0c, /* 00001100 */ - 0x1e, /* 00011110 */ - - /* 114 0x72 'r' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xdc, /* 11011100 */ - 0x76, /* 01110110 */ - 0x60, /* 01100000 */ - 0x60, /* 01100000 */ - 0xf0, /* 11110000 */ - 0x00, /* 00000000 */ - - /* 115 0x73 's' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0xc0, /* 11000000 */ - 0x7c, /* 01111100 */ - 0x06, /* 00000110 */ - 0xfc, /* 11111100 */ - 0x00, /* 00000000 */ - - /* 116 0x74 't' */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0xfc, /* 11111100 */ - 0x30, /* 00110000 */ - 0x30, /* 00110000 */ - 0x36, /* 00110110 */ - 0x1c, /* 00011100 */ - 0x00, /* 00000000 */ - - /* 117 0x75 'u' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0xcc, /* 11001100 */ - 0x76, /* 01110110 */ - 0x00, /* 00000000 */ - - /* 118 0x76 'v' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x00, /* 00000000 */ - - /* 119 0x77 'w' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0xd6, /* 11010110 */ - 0xd6, /* 11010110 */ - 0xfe, /* 11111110 */ - 0x6c, /* 01101100 */ - 0x00, /* 00000000 */ - - /* 120 0x78 'x' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0x6c, /* 01101100 */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0x00, /* 00000000 */ - - /* 121 0x79 'y' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0x7e, /* 01111110 */ - 0x06, /* 00000110 */ - 0xfc, /* 11111100 */ - - /* 122 0x7a 'z' */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x7e, /* 01111110 */ - 0x4c, /* 01001100 */ - 0x18, /* 00011000 */ - 0x32, /* 00110010 */ - 0x7e, /* 01111110 */ - 0x00, /* 00000000 */ - - /* 123 0x7b '{' */ - 0x0e, /* 00001110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x70, /* 01110000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x0e, /* 00001110 */ - 0x00, /* 00000000 */ - - /* 124 0x7c '|' */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x00, /* 00000000 */ - - /* 125 0x7d '}' */ - 0x70, /* 01110000 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x0e, /* 00001110 */ - 0x18, /* 00011000 */ - 0x18, /* 00011000 */ - 0x70, /* 01110000 */ - 0x00, /* 00000000 */ - - /* 126 0x7e '~' */ - 0x76, /* 01110110 */ - 0xdc, /* 11011100 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - 0x00, /* 00000000 */ - - - /* 127 0x7f '' */ - 0x00, /* 00000000 */ - 0x10, /* 00010000 */ - 0x38, /* 00111000 */ - 0x6c, /* 01101100 */ - 0xc6, /* 11000110 */ - 0xc6, /* 11000110 */ - 0xfe, /* 11111110 */ - 0x00, /* 00000000 */ -}; - - -void LICE_DrawChar(LICE_IBitmap *bm, int x, int y, char c, - LICE_pixel color, float alpha, int mode) -{ - LICE_pixel *fb; - if (c<1 || !bm || !(fb=bm->getBits()))return; - unsigned char *font = LICE_deffont + ((c-1)*LICE_FONT_HEIGHT); - int len = LICE_FONT_HEIGHT; - int smask=128; - int xlen=8; - - if (y < 0) - { - font -= y; - len += y; - y = 0; - } - if (x<0) - { - smask >>= -x; - xlen+=x; - x=0; - } - - const int bm_w = bm->getWidth(), bm_h = bm->getHeight(); - if (xlen < 1 || len < 1 || x >= bm_w || y >= bm_h) return; - - if (xlen > bm_w - x) xlen = bm_w - x; - if (len > bm_h - y) len = bm_h - y; - - int rs=bm->getRowSpan(); - if (bm->isFlipped()) - { - fb += x+((bm->getHeight()-1-y)*rs); - rs=-rs; - } - else - fb += x+(y*rs); - - int red=LICE_GETR(color), green=LICE_GETG(color), blue=LICE_GETB(color), alp=LICE_GETA(color), ialpha=(int) (alpha * 256.0f); - - while (len-->0) - { - LICE_pixel *outmem = fb; - fb+=rs; - unsigned char ch = *font++; - int a=smask; - int xleft = xlen; - while (a && xleft--) - { - if (ch & a) - { - #define __LICE__ACTION(comb) comb::doPix((LICE_pixel_chan *)outmem, red,green,blue,alp,ialpha) - __LICE_ACTION_NOSRCALPHA(mode,ialpha, false); - #undef __LICE__ACTION - } - outmem++; - a >>= 1; - } - } -} - -void LICE_DrawText(LICE_IBitmap *bm, int x, int y, const char *string, - LICE_pixel color, float alpha, int mode) -{ - if (!bm) return; - int w=bm->getWidth(); - int h=bm->getHeight(); - int xx = x; - while (*string) - { - switch (*string) - { - case '\n': y += LICE_FONT_HEIGHT; xx = x; break; - case ' ': xx += 8; break; - case '\r': break; - case '\t': xx += 8*5; break; - default: - if (xx>=-8 && xx= -LICE_FONT_HEIGHT && y < h) - LICE_DrawChar(bm,xx,y,*string, color,alpha,mode); - xx += 8; - break; - } - string++; - } -} - -void LICE_MeasureText(const char *string, int *w, int *h) -{ - if (w) *w=0; - if (h) *h=0; - int x=0,y=LICE_FONT_HEIGHT; - while (*string) - { - switch (*string) - { - case '\n': y += LICE_FONT_HEIGHT; x = 0; break; - case '\r': break; - case '\t': - x += 8*4; - WDL_FALLTHROUGH; - default: - x += 8; - if (w && x > *w) *w=x; - if (h && y > *h) *h=y; - break; - } - string++; - } -} - diff --git a/oversampling/WDL/lice/lice_text.h b/oversampling/WDL/lice/lice_text.h deleted file mode 100644 index bda2dca..0000000 --- a/oversampling/WDL/lice/lice_text.h +++ /dev/null @@ -1,274 +0,0 @@ -#ifndef _LICE_TEXT_H_ -#define _LICE_TEXT_H_ - -#include "lice.h" - -#ifndef _WIN32 -#include "../swell/swell.h" -#endif -#include "../heapbuf.h" - -#define LICE_FONT_FLAG_VERTICAL 1 // rotate text to vertical (do not set the windows font to vertical though) -#define LICE_FONT_FLAG_VERTICAL_BOTTOMUP 2 - -#define LICE_FONT_FLAG_PRECALCALL 4 -//#define LICE_FONT_FLAG_ALLOW_NATIVE 8 -#define LICE_FONT_FLAG_FORCE_NATIVE 1024 - -#define LICE_FONT_FLAG_FX_BLUR 16 -#define LICE_FONT_FLAG_FX_INVERT 32 -#define LICE_FONT_FLAG_FX_MONO 64 // faster but no AA/etc - -#define LICE_FONT_FLAG_FX_SHADOW 128 // these imply MONO -#define LICE_FONT_FLAG_FX_OUTLINE 256 - -#define LICE_FONT_FLAG_OWNS_HFONT 512 - -// could do a mask for these flags -#define LICE_FONT_FLAGS_HAS_FX(flag) \ - (flag&(LICE_FONT_FLAG_VERTICAL|LICE_FONT_FLAG_VERTICAL_BOTTOMUP| \ - LICE_FONT_FLAG_FX_BLUR|LICE_FONT_FLAG_FX_INVERT|LICE_FONT_FLAG_FX_MONO| \ - LICE_FONT_FLAG_FX_SHADOW|LICE_FONT_FLAG_FX_OUTLINE)) - -#define LICE_DT_NEEDALPHA 0x80000000 // include in DrawText() if the output alpha channel is important -#define LICE_DT_USEFGALPHA 0x40000000 // uses alpha channel in fg color - -class LICE_IFont -{ - public: - virtual ~LICE_IFont() {} - - virtual void SetFromHFont(HFONT font, int flags=0)=0; // hfont must REMAIN valid, unless LICE_FONT_FLAG_PRECALCALL or LICE_FONT_FLAG_OWNS_HFONT set (OWNS means LICE_IFont will clean up hfont on font change or exit) - - virtual LICE_pixel SetTextColor(LICE_pixel color)=0; - virtual LICE_pixel SetBkColor(LICE_pixel color)=0; - virtual LICE_pixel SetEffectColor(LICE_pixel color)=0; - virtual int SetBkMode(int bkmode)=0; - virtual void SetCombineMode(int combine, float alpha=1.0f)=0; - - virtual int DrawText(LICE_IBitmap *bm, const char *str, int strcnt, RECT *rect, UINT dtFlags)=0; - - virtual LICE_pixel GetTextColor()=0; - virtual HFONT GetHFont()=0; - virtual int GetLineHeight()=0; - virtual void SetLineSpacingAdjust(int amt)=0; -}; - - -#ifndef LICE_TEXT_NO_DECLARE_CACHEDFONT - -class LICE_CachedFont : public LICE_IFont -{ - public: - LICE_CachedFont(); - virtual ~LICE_CachedFont(); - - virtual void SetFromHFont(HFONT font, int flags=0); - - virtual LICE_pixel SetTextColor(LICE_pixel color) { LICE_pixel ret=m_fg; m_fg=color; return ret; } - virtual LICE_pixel SetBkColor(LICE_pixel color) { LICE_pixel ret=m_bg; m_bg=color; return ret; } - virtual LICE_pixel SetEffectColor(LICE_pixel color) { LICE_pixel ret=m_effectcol; m_effectcol=color; return ret; } - virtual int SetBkMode(int bkmode) { int bk = m_bgmode; m_bgmode=bkmode; return bk; } - virtual void SetCombineMode(int combine, float alpha=1.0f) { m_comb=combine; m_alpha=alpha; } - - virtual int DrawText(LICE_IBitmap *bm, const char *str, int strcnt, RECT *rect, UINT dtFlags) - { - return DrawTextImpl(bm,str,strcnt,rect,dtFlags); - } - - virtual LICE_pixel GetTextColor() { return m_fg; } - virtual HFONT GetHFont() { return m_font; } - virtual int GetLineHeight() { return m_line_height; } - - virtual void SetLineSpacingAdjust(int amt) { m_lsadj=amt; } - - protected: - - virtual bool DrawGlyph(LICE_IBitmap *bm, unsigned short c, int xpos, int ypos, const RECT *clipR); - int DrawTextImpl(LICE_IBitmap *bm, const char *str, int strcnt, RECT *rect, UINT dtFlags); // cause swell defines DrawText to SWELL_DrawText etc - - bool RenderGlyph(unsigned short idx); - - const char *NextWordBreak(const char *str, int strcnt, int w); - - LICE_pixel m_fg,m_bg,m_effectcol; - int m_bgmode; - int m_comb; - float m_alpha; - int m_flags; - - int m_line_height,m_lsadj; - struct charEnt - { - int base_offset; // offset in m_cachestore+1, so 1=offset0, 0=unset, -1=failed to render - int width, height; - int advance; - int charid; // used by m_extracharlist - int left_extra; - }; - charEnt *findChar(unsigned short c); - - charEnt m_lowchars[128]; // first 128 chars cached here - WDL_TypedBuf m_extracharlist; - WDL_TypedBuf m_cachestore; - - static int _charSortFunc(const void *a, const void *b); - - HFONT m_font; - -}; - -#endif // !LICE_TEXT_NO_DECLARE_CACHEDFONT - -#ifndef LICE_TEXT_NO_MULTIDPI -class __LICE_dpiAwareFont : public LICE_IFont -{ - struct rec { - LICE_IFont *cache; - int sz; - }; - WDL_TypedBuf m_list; // used entries are at end of list, most recently used last. sz=0 for unused - - int (*m_getflags)(int); - int m_flags; - LICE_pixel m_fg, m_bg, m_effectcol; - int m_bgmode, m_comb; - float m_alpha; - int m_lsadj; - -public: - LOGFONT m_lf; - - - // LICE_IFont interface - virtual void SetFromHFont(HFONT font, int flags=0) { } - - virtual LICE_pixel SetTextColor(LICE_pixel color) { LICE_pixel ret=m_fg; m_fg=color; return ret; } - virtual LICE_pixel SetBkColor(LICE_pixel color) { LICE_pixel ret=m_bg; m_bg=color; return ret; } - virtual LICE_pixel SetEffectColor(LICE_pixel color) { LICE_pixel ret=m_effectcol; m_effectcol=color; return ret; } - virtual int SetBkMode(int bkmode) { int bk = m_bgmode; m_bgmode=bkmode; return bk; } - virtual void SetCombineMode(int combine, float alpha=1.0f) { m_comb=combine; m_alpha=alpha; } - - virtual int DrawText(LICE_IBitmap *bm, const char *str, int strcnt, RECT *rect, UINT dtFlags) - { - LICE_IFont *f = get(bm); - if (!f) return 0; - if (!(dtFlags & DT_CALCRECT)) - { - f->SetTextColor(m_fg); - f->SetBkColor(m_bg); - f->SetEffectColor(m_effectcol); - f->SetBkMode(m_bgmode); - f->SetCombineMode(m_comb,m_alpha); - f->SetLineSpacingAdjust(m_lsadj); - } - return f->DrawText(bm,str,strcnt,rect,dtFlags); - } - - virtual LICE_pixel GetTextColor() { return m_fg; } - virtual HFONT GetHFont() { return NULL; } - virtual int GetLineHeight() { return GetLineHeightDPI(NULL); } - - virtual void SetLineSpacingAdjust(int amt) { m_lsadj=amt; } - - __LICE_dpiAwareFont(int maxsz) - { - memset(&m_lf,0,sizeof(m_lf)); - m_getflags = NULL; - m_flags=0; - m_fg=m_bg=m_effectcol=0; - m_bgmode=TRANSPARENT; - m_comb=0; - m_alpha=1.0; - m_lsadj=0; - - rec *l = m_list.ResizeOK(maxsz); - if (l) memset(l,0,sizeof(*l)*maxsz); - } - ~__LICE_dpiAwareFont() - { - for (int x = 0; x < m_list.GetSize(); x ++) delete m_list.Get()[x].cache; - } - void SetFromLogFont(LOGFONT *lf, int (*get_flags)(int)) - { - m_lf = *lf; - m_getflags = get_flags; - m_flags = get_flags ? get_flags(0) : 0; - clear(); - } - - void clear() - { - int x = m_list.GetSize()-1; - rec *t = m_list.Get(); - while (x>=0 && t[x].sz) t[x--].sz=0; - } - - LICE_IFont *get_for_sc(int fsc) - { - int use_flag = m_getflags ? m_getflags(0) & ~LICE_FONT_FLAG_PRECALCALL : 0; - if (m_flags != use_flag) - { - m_flags = use_flag; - clear(); - } - - int ht = m_lf.lfHeight, ht2 = m_lf.lfWidth; - if (fsc && fsc != 256) - { - ht = (ht * fsc) / 256; - ht2 = (ht2 * fsc) / 256; - use_flag |= LICE_FONT_FLAG_FORCE_NATIVE; - } - - int x = m_list.GetSize()-1; - rec *t = m_list.Get(); - while (x>=0 && t[x].sz != ht && t[x].sz) x--; - if (x<0) t[x=0].sz = 0; // if list full, use oldest item - - // move to end of list - if (x != m_list.GetSize()-1) - { - rec tmp = t[x]; - m_list.Delete(x); - m_list.Add(tmp); - } - - t = m_list.Get() + m_list.GetSize() - 1; - if (!t->cache) t->cache = __CreateFont(); - if (!t->sz && t->cache) - { - t->sz = ht; - LOGFONT lf = m_lf; - lf.lfHeight = ht; - lf.lfWidth = ht2; - #ifdef _WIN32 - if (!(m_flags & LICE_FONT_FLAG_FORCE_NATIVE) && abs(lf.lfHeight) <= 14) lf.lfQuality = NONANTIALIASED_QUALITY; - #endif - t->cache->SetFromHFont(CreateFontIndirect(&lf), LICE_FONT_FLAG_OWNS_HFONT | use_flag); - } - - return t->cache; - } - LICE_IFont *get(LICE_IBitmap *bm) - { - return get_for_sc(bm ? (int)bm->Extended(LICE_EXT_GET_ANY_SCALING,NULL) : 0); - } - - - int GetLineHeightDPI(LICE_IBitmap *bm) - { - LICE_IFont *f = get(bm); - return f ? f->GetLineHeight() : 10; - } - virtual LICE_IFont *__CreateFont()=0; -}; - -template class LICE_dpiAwareFont : public __LICE_dpiAwareFont { - public: - LICE_dpiAwareFont(int max) : __LICE_dpiAwareFont(max) { } - virtual LICE_IFont *__CreateFont() { return new BASEFONT; } -}; -#endif//LICE_TEXT_NO_MULTIDPI - -#endif//_LICE_TEXT_H_ diff --git a/oversampling/WDL/lice/lice_textnew.cpp b/oversampling/WDL/lice/lice_textnew.cpp deleted file mode 100644 index 2547cb9..0000000 --- a/oversampling/WDL/lice/lice_textnew.cpp +++ /dev/null @@ -1,1356 +0,0 @@ -#ifndef WDL_NO_DEFINE_MINMAX -#define WDL_NO_DEFINE_MINMAX -#endif -#include "lice_text.h" -#include - -#include "lice_combine.h" -#include "lice_extended.h" - -#define IGNORE_SCALING(mode) ((mode)&LICE_BLIT_IGNORE_SCALING) - -#if defined(_WIN32) && defined(WDL_SUPPORT_WIN9X) -static char __1ifNT2if98=0; // 2 for iswin98 -#endif - -// for very large fonts, fallback to native and avoid making a huge glyph cache, which would be terrible for performance -#define USE_NATIVE_RENDERING_FOR_FONTS_HIGHER_THAN 256 - - -// if other methods fail, at this point just flat out refuse to render glyphs (since they would use a ridiculous amount of memory) -#ifndef ABSOLUTELY_NO_GLYPHS_HIGHER_THAN -#define ABSOLUTELY_NO_GLYPHS_HIGHER_THAN 1024 -#endif - - -static int utf8makechar(char *ptrout, unsigned short charIn) -{ - unsigned char *pout = (unsigned char *)ptrout; - if (charIn < 128) { *pout = (unsigned char)charIn; return 1; } - if (charIn < 2048) { pout[0] = 0xC0 + (charIn>>6); pout[1] = 0x80 + (charIn&0x3f); return 2; } - pout[0] = 0xE0 + (charIn>>12); - pout[1] = 0x80 + ((charIn>>6)&0x3f); - pout[2] = 0x80 + (charIn&0x3f); - return 3; -} - -static int utf8char(const char *ptr, unsigned short *charOut) // returns char length -{ - const unsigned char *p = (const unsigned char *)ptr; - unsigned char tc = *p; - - if (tc < 128) - { - if (charOut) *charOut = (unsigned short) tc; - return 1; - } - else if (tc < 0xC2) // invalid chars (subsequent in sequence, or overlong which we disable for) - { - } - else if (tc < 0xE0) // 2 char seq - { - if (p[1] >= 0x80 && p[1] <= 0xC0) - { - if (charOut) *charOut = ((tc&0x1f)<<6) | (p[1]&0x3f); - return 2; - } - } - else if (tc < 0xF0) // 3 char seq - { - if (p[1] >= 0x80 && p[1] <= 0xC0 && p[2] >= 0x80 && p[2] <= 0xC0) - { - if (charOut) *charOut = ((tc&0xf)<<12) | ((p[1]&0x3f)<<6) | ((p[2]&0x3f)); - return 3; - } - } - else if (tc < 0xF5) // 4 char seq - { - if (p[1] >= 0x80 && p[1] <= 0xC0 && p[2] >= 0x80 && p[2] <= 0xC0 && p[3] >= 0x80 && p[3] <= 0xC0) - { - if (charOut) *charOut = (unsigned short)' '; // dont support 4 byte sequences yet(ever?) - return 4; - } - } - if (charOut) *charOut = (unsigned short) tc; - return 1; -} - - - -//not threadsafe ---- -static LICE_SysBitmap *s_tempbitmap; // keep a sysbitmap around for rendering fonts -static LICE_SysBitmap *s_nativerender_tempbitmap; -static int s_tempbitmap_refcnt; - - -int LICE_CachedFont::_charSortFunc(const void *a, const void *b) -{ - charEnt *aa = (charEnt *)a; - charEnt *bb = (charEnt *)b; - return aa->charid - bb->charid; -} - -LICE_CachedFont::LICE_CachedFont() : m_cachestore(65536) -{ - s_tempbitmap_refcnt++; - m_fg=0; - m_effectcol=m_bg=LICE_RGBA(255,255,255,255); - m_comb=0; - m_alpha=1.0f; - m_bgmode = TRANSPARENT; - m_flags=0; - m_line_height=0; - m_lsadj=0; - m_font=0; - memset(m_lowchars,0,sizeof(m_lowchars)); -} - -LICE_CachedFont::~LICE_CachedFont() -{ - if ((m_flags&LICE_FONT_FLAG_OWNS_HFONT) && m_font) { - DeleteObject(m_font); - } - if (!--s_tempbitmap_refcnt) - { - delete s_tempbitmap; - s_tempbitmap=0; - delete s_nativerender_tempbitmap; - s_nativerender_tempbitmap=0; - } -} - -void LICE_CachedFont::SetFromHFont(HFONT font, int flags) -{ - if ((m_flags&LICE_FONT_FLAG_OWNS_HFONT) && m_font && m_font != font) - { - DeleteObject(m_font); - } - - m_flags=flags; - m_font=font; - if (font) - { - if (!s_tempbitmap) s_tempbitmap=new LICE_SysBitmap; - - if (s_tempbitmap->getWidth() < 256 || s_tempbitmap->getHeight() < 256) - { - s_tempbitmap->resize(256,256); - ::SetTextColor(s_tempbitmap->getDC(),RGB(255,255,255)); - ::SetBkMode(s_tempbitmap->getDC(),OPAQUE); - ::SetBkColor(s_tempbitmap->getDC(),RGB(0,0,0)); - } - - TEXTMETRIC tm; - HGDIOBJ oldFont = 0; - if (font) oldFont = SelectObject(s_tempbitmap->getDC(),font); - GetTextMetrics(s_tempbitmap->getDC(),&tm); - if (oldFont) SelectObject(s_tempbitmap->getDC(),oldFont); - - m_line_height = tm.tmHeight; - } - - memset(m_lowchars,0,sizeof(m_lowchars)); - m_extracharlist.Resize(0,false); - m_cachestore.Resize(0); - if (flags&LICE_FONT_FLAG_PRECALCALL) - { - int x; - for(x=0;x<128;x++) - RenderGlyph(x); - } -} - -bool LICE_CachedFont::RenderGlyph(unsigned short idx) // return TRUE if ok -{ - if (m_line_height >= ABSOLUTELY_NO_GLYPHS_HIGHER_THAN) return false; - - bool needSort=false; - charEnt *ent; - if (idx>=128) - { -#if defined(_WIN32) && defined(WDL_SUPPORT_WIN9X) - if (!__1ifNT2if98) __1ifNT2if98 = GetVersion()<0x80000000 ? 1 : 2; - - if (__1ifNT2if98==2) return false; -#endif - ent=findChar(idx); - if (!ent) - { - if (m_flags & LICE_FONT_FLAG_PRECALCALL) return false; - - int oldsz=m_extracharlist.GetSize(); - ent = m_extracharlist.Resize(oldsz+1) + oldsz; - memset(ent,0,sizeof(*ent)); - ent->charid = idx; - - needSort=true; - } - } - else ent = m_lowchars+idx; - - const int bmsz=lice_max(m_line_height,1) * 2 + 8; - - if (!s_tempbitmap) s_tempbitmap=new LICE_SysBitmap; - - if (s_tempbitmap->getWidth() < bmsz || s_tempbitmap->getHeight() < bmsz) - { - s_tempbitmap->resize(bmsz,bmsz); - ::SetTextColor(s_tempbitmap->getDC(),RGB(255,255,255)); - ::SetBkMode(s_tempbitmap->getDC(),OPAQUE); - ::SetBkColor(s_tempbitmap->getDC(),RGB(0,0,0)); - } - - HGDIOBJ oldFont=0; - if (m_font) oldFont = SelectObject(s_tempbitmap->getDC(),m_font); - RECT r={0,0,0,0,}; - int advance; - // overrender sides and check to see if it was updated - const int right_extra_pad = 2+wdl_max(m_line_height/8,0); - const int left_extra_pad = 2+wdl_max(m_line_height/16,0); - -#ifdef _WIN32 -#if defined(WDL_SUPPORT_WIN9X) - if (__1ifNT2if98==1) -#endif - { - WCHAR tmpstr[2]={(WCHAR)idx,0}; - ::DrawTextW(s_tempbitmap->getDC(),tmpstr,1,&r,DT_CALCRECT|DT_SINGLELINE|DT_NOPREFIX); - advance=r.right; - r.right += right_extra_pad+left_extra_pad; - LICE_FillRect(s_tempbitmap,0,0,r.right,r.bottom,0,1.0f,LICE_BLIT_MODE_COPY); - r.left+=left_extra_pad; - ::DrawTextW(s_tempbitmap->getDC(),tmpstr,1,&r,DT_SINGLELINE|DT_LEFT|DT_TOP|DT_NOPREFIX|DT_NOCLIP); - } - #if defined(WDL_SUPPORT_WIN9X) - else - #endif -#endif - -#if !defined(_WIN32) || defined(WDL_SUPPORT_WIN9X) - { - - char tmpstr[6]={(char)idx,0}; -#ifndef _WIN32 - if (idx>=128) utf8makechar(tmpstr,idx); -#endif - ::DrawText(s_tempbitmap->getDC(),tmpstr,-1,&r,DT_CALCRECT|DT_SINGLELINE|DT_NOPREFIX); - advance=r.right; - r.right += right_extra_pad+left_extra_pad; - LICE_FillRect(s_tempbitmap,0,0,r.right,r.bottom,0,1.0f,LICE_BLIT_MODE_COPY); - r.left += left_extra_pad; - ::DrawText(s_tempbitmap->getDC(),tmpstr,-1,&r,DT_SINGLELINE|DT_LEFT|DT_TOP|DT_NOPREFIX|DT_NOCLIP); - } -#endif - - if (advance > s_tempbitmap->getWidth()) advance=s_tempbitmap->getWidth(); - if (r.right > s_tempbitmap->getWidth()) r.right=s_tempbitmap->getWidth(); - if (r.bottom > s_tempbitmap->getHeight()) r.bottom=s_tempbitmap->getHeight(); - - if (oldFont) SelectObject(s_tempbitmap->getDC(),oldFont); - - if (advance < 1 || r.bottom < 1) - { - ent->base_offset=-1; - ent->left_extra=ent->advance=ent->width=ent->height=0; - } - else - { - ent->advance=advance; - int flags=m_flags; - if (flags&LICE_FONT_FLAG_FX_BLUR) - { - LICE_Blur(s_tempbitmap,s_tempbitmap,0,0,0,0,r.right,r.bottom); - } - LICE_pixel *srcbuf = s_tempbitmap->getBits(); - int span=s_tempbitmap->getRowSpan(); - - ent->base_offset=m_cachestore.GetSize()+1; - int newsz = ent->base_offset-1+r.right*r.bottom; - unsigned char *destbuf = m_cachestore.Resize(newsz) + ent->base_offset-1; - if (m_cachestore.GetSize() != newsz) - { - ent->base_offset=-1; - ent->advance=ent->width=ent->height=0; - } - else - { - if (s_tempbitmap->isFlipped()) - { - srcbuf += (s_tempbitmap->getHeight()-1)*span; - span=-span; - } - int x,y; - int min_x=left_extra_pad; - int max_x=advance + min_x; - - for(y=0;y 0) - { - const int neww = max_x-min_x; - const unsigned char *rdptr=destbuf + min_x; - // trim down destbuf - for (y=0;ybase_offset-1+r.right*r.bottom; - destbuf = m_cachestore.Resize(newsz,false) + ent->base_offset-1; - } - - if (flags&LICE_FONT_FLAG_VERTICAL) - { - int a=r.bottom; r.bottom=r.right; r.right=a; - - unsigned char *tmpbuf = (unsigned char *)s_tempbitmap->getBits(); - memcpy(tmpbuf,destbuf,r.right*r.bottom); - - int dptr=r.bottom; - int dtmpbuf=1; - if (!(flags&LICE_FONT_FLAG_VERTICAL_BOTTOMUP)) - { - tmpbuf += (r.right-1)*dptr; - dptr=-dptr; - } - else - { - tmpbuf+=r.bottom-1; - dtmpbuf=-1; - } - - for(y=0;y130 ? 255:0; - destbuf++; - } - - destbuf -= r.right*r.bottom; - } - if (flags&(LICE_FONT_FLAG_FX_SHADOW|LICE_FONT_FLAG_FX_OUTLINE)) - { - for(y=0;y130 ? 255:0; - destbuf++; - } - - destbuf -= r.right*r.bottom; - if (flags&LICE_FONT_FLAG_FX_SHADOW) - { - for(y=0;y0) - { - if (destbuf[-1]==255) *destbuf=128; - else if (y>0 && destbuf[-r.right-1]==255) *destbuf=128; - } - if (y>0 && destbuf[-r.right]==255) *destbuf=128; - } - destbuf++; - } - } - else - { - for(y=0;y0 && destbuf[-r.right]==255) *destbuf=128; - else if (y0) - { - if (destbuf[-1]==255) *destbuf=128; - // else if (y>0 && destbuf[-r.right-1]==255) *destbuf=128; - // else if (y0 && destbuf[-r.right+1]==255) *destbuf=128; - // else if (yleft_extra=left_extra_pad-min_x; - ent->width = r.right; - ent->height = r.bottom; - } - } - if (needSort&&m_extracharlist.GetSize()>1) qsort(m_extracharlist.Get(),m_extracharlist.GetSize(),sizeof(charEnt),_charSortFunc); - - return true; -} - -template class GlyphRenderer -{ -public: - static void Normal(unsigned char *gsrc, LICE_pixel *pout, - int src_span, int dest_span, int width, int height, - int red, int green, int blue, int pxa, int a256) - { - int y; - if (a256==256) - { - for(y=0;y256)a=256; - T::doPix((unsigned char *)(pout+x),red,green,blue,pxa,a); - } - } - gsrc += src_span; - pout += dest_span; - } - } - } - static void Mono(unsigned char *gsrc, LICE_pixel *pout, - int src_span, int dest_span, int width, int height, - int red, int green, int blue, int pxa, int alpha) - { - int y; - for(y=0;yleft_extra; - else - ypos += ch->left_extra; - } - else - { - xpos -= ch->left_extra; - } - - if (xpos >= clipR->right || - ypos >= clipR->bottom || - xpos+ch->width <= clipR->left || - ypos+ch->height <= clipR->top) return true; // would have drawn but out of bounds - - unsigned char *gsrc = m_cachestore.Get() + ch->base_offset-1; - int src_span = ch->width; - int width = ch->width; - int height = ch->height; - -#ifndef DISABLE_LICE_EXTENSIONS - if (bm->Extended(LICE_EXT_SUPPORTS_ID, (void*) LICE_EXT_DRAWGLYPH_ACCEL)) - { - LICE_Ext_DrawGlyph_acceldata data(xpos, ypos, m_fg, gsrc, width, height, m_alpha, m_comb); - if (bm->Extended(LICE_EXT_DRAWGLYPH_ACCEL, &data)) return true; - } -#endif - - if (xpos < clipR->left) - { - width += (xpos-clipR->left); - gsrc += clipR->left-xpos; - xpos=clipR->left; - } - if (ypos < clipR->top) - { - gsrc += src_span*(clipR->top-ypos); - height += (ypos-clipR->top); - ypos=clipR->top; - } - int dest_span = bm->getRowSpan(); - LICE_pixel *pout = bm->getBits(); - - if (bm->isFlipped()) - { - int bm_h = bm->getHeight(); - const int __sc = bm ? (int)bm->Extended(LICE_EXT_GET_SCALING,NULL) : 0; - if (__sc>0) - { - __LICE_SCU(bm_h); - } - - pout += (bm_h-1)*dest_span; - dest_span=-dest_span; - } - - pout += xpos + ypos * dest_span; - - if (width >= clipR->right-xpos) width = clipR->right-xpos; - if (height >= clipR->bottom-ypos) height = clipR->bottom-ypos; - - if (width < 1 || height < 1) return false; // this could be an assert, it is guaranteed by the xpos/ypos checks at the top of this function - - int mode=m_comb&~LICE_BLIT_USE_ALPHA; - float alpha=m_alpha; - - if (m_bgmode==OPAQUE) - LICE_FillRect(bm,xpos,ypos,width,height,m_bg,alpha,mode|LICE_BLIT_IGNORE_SCALING); - - int red=LICE_GETR(m_fg); - int green=LICE_GETG(m_fg); - int blue=LICE_GETB(m_fg); - int pxa=LICE_GETA(m_fg); - - if (m_flags&LICE_FONT_FLAG_FX_MONO) - { - if (alpha==1.0 && (mode&LICE_BLIT_MODE_MASK)==LICE_BLIT_MODE_COPY) // fast simple - { - LICE_pixel col=m_fg; - int y; - for(y=0;y256)avalint=256; - - #define __LICE__ACTION(comb) GlyphRenderer::Mono(gsrc,pout,src_span,dest_span,width,height,red,green,blue,pxa,avalint) - __LICE_ACTION_NOSRCALPHA(mode,avalint, false); - #undef __LICE__ACTION - } - } - else if (m_flags&(LICE_FONT_FLAG_FX_SHADOW|LICE_FONT_FLAG_FX_OUTLINE)) - { - LICE_pixel col=m_fg; - LICE_pixel bkcol=m_effectcol; - - if (alpha==1.0 && (mode&LICE_BLIT_MODE_MASK)==LICE_BLIT_MODE_COPY) - { - int y; - for(y=0;y256)avalint=256; - int r2=LICE_GETR(bkcol); - int g2=LICE_GETG(bkcol); - int b2=LICE_GETB(bkcol); - int pxa2=LICE_GETA(bkcol); - #define __LICE__ACTION(comb) GlyphRenderer::Effect(gsrc,pout,src_span,dest_span,width,height,red,green,blue,pxa,avalint,r2,g2,b2,pxa2) - __LICE_ACTION_NOSRCALPHA(mode,avalint, false); - #undef __LICE__ACTION - } - } - else - { - int avalint = (int) (alpha*256.0); - #define __LICE__ACTION(comb) GlyphRenderer::Normal(gsrc,pout,src_span,dest_span,width,height,red,green,blue,pxa,avalint) - __LICE_ACTION_NOSRCALPHA(mode,avalint, false); - #undef __LICE__ACTION - } - - return true; // drew glyph at all (for updating max extents) -} - - -#ifndef LICE_TEXT_NONATIVE -static int LICE_Text_IsWine() -{ - static int isWine=-1; -#ifdef _WIN32 - if (isWine<0) - { - HKEY hk; - if (RegOpenKey(HKEY_LOCAL_MACHINE,"Software\\Wine",&hk)==ERROR_SUCCESS) - { - isWine=1; - RegCloseKey(hk); - } - else isWine=0; - } -#endif - return isWine>0; -} -#endif - -#ifdef _WIN32 -static BOOL LICE_Text_HasUTF8(const char *_str) -{ - const unsigned char *str = (const unsigned char *)_str; - if (!str) return FALSE; - while (*str) - { - unsigned char c = *str; - if (c >= 0xC2) // fuck overlongs - { - if (c <= 0xDF && str[1] >=0x80 && str[1] <= 0xBF) return TRUE; - else if (c <= 0xEF && str[1] >=0x80 && str[1] <= 0xBF && str[2] >=0x80 && str[2] <= 0xBF) return TRUE; - else if (c <= 0xF4 && str[1] >=0x80 && str[1] <= 0xBF && str[2] >=0x80 && str[2] <= 0xBF) return TRUE; - } - str++; - } - return FALSE; -} -#endif - - -#define __LICE_SC_DRAWTEXT_RESTORE_RECT \ - if (__sc > 0 && rect) { \ - rect->left = (rect->left * 256) / __sc; \ - rect->top = (rect->top * 256) / __sc; \ - rect->right = (rect->right * 256) / __sc; \ - rect->bottom = (rect->bottom * 256) / __sc; \ - } - - -static const char *adv_str(const char *str, int *strcnt, unsigned short *c) -{ - int charlen=utf8char(str, c); - if (strcnt && *strcnt > 0) *strcnt=wdl_max(*strcnt-charlen, 0); - return str+charlen; -} - -const char *LICE_CachedFont::NextWordBreak(const char *str, int strcnt, int w) -{ - // returns the first character of the next line - const char *next_break=NULL; - while (*str && strcnt) - { - unsigned short c; - str=adv_str(str, &strcnt, &c); - if (c == '\n') return str; - if (c != '\r') - { - charEnt *ent=findChar(c); - if (ent && ent->base_offset > 0 && ent->base_offset < m_cachestore.GetSize()) - { - w -= ent->advance; - if (w < 0) return next_break ? next_break : str; - } - } - if (c == ' ' || c == '\t' || c == '\r') next_break=str; - } - return str; -} - - -int LICE_CachedFont::DrawTextImpl(LICE_IBitmap *bm, const char *str, int strcnt, - RECT *rect, UINT dtFlags) -{ - WDL_ASSERT((dtFlags & DT_SINGLELINE) || !(dtFlags & (DT_BOTTOM|DT_VCENTER))); // if DT_BOTTOM or DT_VCENTER used, must have DT_SINGLELINE - if (!bm && !(dtFlags&DT_CALCRECT)) return 0; - - const int __sc = bm ? (int)bm->Extended(LICE_EXT_GET_SCALING,NULL) : 0; - int bm_w = bm ? bm->getWidth() : 0; - int bm_h = bm ? bm->getHeight() : 0; - - if (__sc>0 && rect) - { - if (!IGNORE_SCALING(m_comb)) - { - __LICE_SC(rect->left); - __LICE_SC(rect->top); - __LICE_SC(rect->right); - __LICE_SC(rect->bottom); - } - __LICE_SC(bm_w); - __LICE_SC(bm_h); - } - - bool forceWantAlpha=false; - - if (dtFlags & LICE_DT_NEEDALPHA) - { - forceWantAlpha=true; - dtFlags &= ~LICE_DT_NEEDALPHA; - } - - if (dtFlags&DT_SINGLELINE) dtFlags &= ~DT_WORDBREAK; - -#ifndef _WIN32 - const int lsadj = m_lsadj+3; -#else - const int lsadj = m_lsadj; -#endif - - // if using line-spacing adjustments (m_lsadj), don't allow native rendering - // todo: split rendering up into invidual lines and DrawText calls -#ifndef LICE_TEXT_NONATIVE - - int ret=0; - if (!bm || !bm->Extended('YUVx',NULL)) if (((m_flags&LICE_FONT_FLAG_FORCE_NATIVE) && m_font && !forceWantAlpha &&!LICE_Text_IsWine() && -#ifndef _WIN32 - // swell does not support DT_WORDBREAK at the moment - !(dtFlags & DT_WORDBREAK) && -#endif - !(dtFlags & LICE_DT_USEFGALPHA) && - !(m_flags&LICE_FONT_FLAG_PRECALCALL) && !LICE_FONT_FLAGS_HAS_FX(m_flags) && - (!lsadj || (dtFlags&DT_SINGLELINE))) || - (m_line_height >= USE_NATIVE_RENDERING_FOR_FONTS_HIGHER_THAN) ) - { - -#ifdef _WIN32 - WCHAR wtmpbuf[1024]; - WCHAR *wtmp=NULL; - #ifdef WDL_SUPPORT_WIN9X - static int win9x; - if (!win9x) win9x = GetVersion() < 0x80000000 ? -1 : 1; //>0 if win9x - if (win9x<0 && LICE_Text_HasUTF8(str)) - #else - if (LICE_Text_HasUTF8(str)) - #endif - { - int req = MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,str,strcnt,NULL,0); - if (req < 1000) - { - int cnt=0; - if ((cnt=MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,str,strcnt,wtmpbuf,1024))) - { - wtmp=wtmpbuf; - wtmp[cnt]=0; - } - } - else - { - wtmp = (WCHAR *)malloc((req + 32)*sizeof(WCHAR)); - int cnt=-1; - if (wtmp && !(cnt=MultiByteToWideChar(CP_UTF8,MB_ERR_INVALID_CHARS,str,strcnt,wtmp,req+1))) - free(wtmp); - else if (cnt>0) wtmp[cnt]=0; - } - } -#endif - - HDC hdc = (bm ? bm->getDC() : 0); - HGDIOBJ oldfont = 0; - RECT dt_rect={0,}; - - bool isTmp=false; - RECT tmp_rect={0,}; - -#ifdef _WIN32 - HRGN rgn=NULL; -#endif - RECT nr_subbitmap_clip = {0,}; - bool nr_subbitmap_clip_use=false; - if (!hdc && bm) - { - LICE_IBitmap *bmt = bm; - while (bmt->Extended(LICE_SubBitmap::LICE_GET_SUBBITMAP_VERSION,NULL) == (INT_PTR)LICE_SubBitmap::LICE_SUBBITMAP_VERSION) - { - LICE_SubBitmap *sb = (LICE_SubBitmap *)bmt; - int sub_x = sb->m_x, sub_y = sb->m_y; - if (__sc>0) - { - __LICE_SC(sub_x); - __LICE_SC(sub_y); - } - nr_subbitmap_clip.left += sub_x; - nr_subbitmap_clip.top += sub_y; - bmt = sb->m_parent; - if (!bmt) break; // ran out of parents - - hdc=bmt->getDC(); - if (hdc) - { - int sub_w = ((LICE_SubBitmap*)bm)->m_w, sub_h = ((LICE_SubBitmap*)bm)->m_h; - if (__sc>0) - { - __LICE_SC(sub_w); - __LICE_SC(sub_h); - } - nr_subbitmap_clip.right = nr_subbitmap_clip.left + sub_w; - nr_subbitmap_clip.bottom = nr_subbitmap_clip.top + sub_h; - nr_subbitmap_clip_use=!(dtFlags & DT_CALCRECT); - bm = bmt; - break; - } - } - } - - if (!hdc) - { - // use temp buffer -- we could optionally enable this if non-1 alpha was desired, though this only works for BLIT_MODE_COPY anyway (since it will end up compositing the whole rectangle, ugh) - isTmp=true; - - if (!s_nativerender_tempbitmap) - s_nativerender_tempbitmap = new LICE_SysBitmap; - - if (s_nativerender_tempbitmap->getWidth() < 4 || s_nativerender_tempbitmap->getHeight() < 4) s_nativerender_tempbitmap->resize(4,4); - - hdc = s_nativerender_tempbitmap->getDC(); - if (!hdc) goto finish_up_native_render; - - oldfont = SelectObject(hdc, m_font); - - RECT text_size = {0,0}; - ret = -#ifdef _WIN32 - wtmp ? ::DrawTextW(hdc,wtmp,-1,&text_size,(dtFlags&~(DT_CENTER|DT_VCENTER|DT_TOP|DT_BOTTOM|DT_LEFT|DT_RIGHT))|DT_CALCRECT|DT_NOPREFIX) : -#endif - ::DrawText(hdc,str,strcnt,&text_size,(dtFlags&~(DT_CENTER|DT_VCENTER|DT_TOP|DT_BOTTOM|DT_LEFT|DT_RIGHT))|DT_CALCRECT|DT_NOPREFIX); - if (dtFlags & DT_CALCRECT) - { - rect->right = rect->left + text_size.right - text_size.left; - rect->bottom = rect->top + text_size.bottom - text_size.top; - goto finish_up_native_render; - } - if (!bm) goto finish_up_native_render; - - if (dtFlags & DT_RIGHT) tmp_rect.left = rect->right - text_size.right; - else if (dtFlags & DT_CENTER) tmp_rect.left = (rect->right+rect->left- text_size.right)/2; - else tmp_rect.left = rect->left; - tmp_rect.right = tmp_rect.left + text_size.right; - - if (dtFlags & DT_BOTTOM) tmp_rect.top = rect->bottom - text_size.bottom; - else if (dtFlags & DT_VCENTER) tmp_rect.top = (rect->bottom+rect->top- text_size.bottom)/2; - else tmp_rect.top = rect->top; - tmp_rect.bottom = tmp_rect.top + text_size.bottom; - - // tmp_rect is the desired rect of drawing, now clip to bitmap (adjusting dt_rect.top/left if starting offscreen) - if (tmp_rect.right > bm_w) tmp_rect.right=bm_w; - if (tmp_rect.bottom > bm_h) tmp_rect.bottom=bm_h; - - int lclip = 0, tclip = 0; - // clip tmp_rect to rect if not DT_NOCLIP - if (!(dtFlags&DT_NOCLIP)) - { - if (tmp_rect.right > rect->right) tmp_rect.right=rect->right; - if (tmp_rect.bottom > rect->bottom) tmp_rect.bottom=rect->bottom; - if (rect->left > 0) lclip = rect->left; - if (rect->top > 0) tclip = rect->top; - } - - if (tmp_rect.left < lclip) - { - dt_rect.left = tmp_rect.left - lclip; - tmp_rect.left = lclip; - } - if (tmp_rect.top < tclip) - { - dt_rect.top = tmp_rect.top - tclip; - tmp_rect.top = tclip; - } - - if (tmp_rect.bottom <= tmp_rect.top || tmp_rect.right <= tmp_rect.left) goto finish_up_native_render; - - dtFlags &= ~(DT_BOTTOM|DT_RIGHT|DT_CENTER|DT_VCENTER); - - int left_overrender = 2+(m_line_height>=16 ? m_line_height/16 : 0); - if (left_overrender>tmp_rect.left) left_overrender=tmp_rect.left; - tmp_rect.left -= left_overrender; - - if (tmp_rect.right-tmp_rect.left > s_nativerender_tempbitmap->getWidth() || - tmp_rect.bottom-tmp_rect.top > s_nativerender_tempbitmap->getHeight()) - { - SelectObject(hdc,oldfont); - s_nativerender_tempbitmap->resize(tmp_rect.right-tmp_rect.left, tmp_rect.bottom-tmp_rect.top); - hdc = s_nativerender_tempbitmap->getDC(); - oldfont = SelectObject(hdc, m_font); - } - - LICE_Blit(s_nativerender_tempbitmap, bm, 0, 0, &tmp_rect, 1.0f, LICE_BLIT_MODE_COPY); - - dt_rect.left += left_overrender; - dt_rect.right=tmp_rect.right; - dt_rect.bottom=tmp_rect.bottom; - } - else - { - oldfont = SelectObject(hdc, m_font); - dt_rect = *rect; - } - - ::SetTextColor(hdc,RGB(LICE_GETR(m_fg),LICE_GETG(m_fg),LICE_GETB(m_fg))); - ::SetBkMode(hdc,m_bgmode); - if (m_bgmode==OPAQUE) ::SetBkColor(hdc,RGB(LICE_GETR(m_bg),LICE_GETG(m_bg),LICE_GETB(m_bg))); - - if (nr_subbitmap_clip_use) - { -#ifdef _WIN32 - rgn=CreateRectRgn(0,0,0,0); - if (!GetClipRgn(hdc,rgn)) - { - DeleteObject(rgn); - rgn=NULL; - } - IntersectClipRect(hdc,nr_subbitmap_clip.left,nr_subbitmap_clip.top,nr_subbitmap_clip.right,nr_subbitmap_clip.bottom); -#else - SWELL_PushClipRegion(hdc); - SWELL_SetClipRegion(hdc,&nr_subbitmap_clip); -#endif - dt_rect.left += nr_subbitmap_clip.left; - dt_rect.top += nr_subbitmap_clip.top; - dt_rect.right += nr_subbitmap_clip.left; - dt_rect.bottom += nr_subbitmap_clip.top; - } - - ret = -#ifdef _WIN32 - wtmp ? ::DrawTextW(hdc,wtmp,-1,&dt_rect,dtFlags|DT_NOPREFIX) : -#endif - ::DrawText(hdc,str,strcnt,&dt_rect,dtFlags|DT_NOPREFIX); - - if (nr_subbitmap_clip_use) - { -#ifdef _WIN32 - SelectClipRgn(hdc,rgn); // if rgn is NULL, clears region - if (rgn) DeleteObject(rgn); -#else - SWELL_PopClipRegion(hdc); -#endif - } - - if (isTmp) - LICE_Blit(bm, s_nativerender_tempbitmap, tmp_rect.left, tmp_rect.top, - 0,0, tmp_rect.right-tmp_rect.left, tmp_rect.bottom-tmp_rect.top, - m_alpha, // this is a slight improvement over the non-tempbuffer version, but might not be necessary... - LICE_BLIT_MODE_COPY); - else if (dtFlags & DT_CALCRECT) *rect = dt_rect; - -finish_up_native_render: - if (hdc) SelectObject(hdc, oldfont); -#ifdef _WIN32 - if (wtmp!=wtmpbuf) free(wtmp); -#endif - - __LICE_SC_DRAWTEXT_RESTORE_RECT - if (__sc>0) ret = (ret * 256) / __sc; - - return ret; - } -#endif - - // ensure all glyphs rendered - const char *tstr=str; - int tcnt=strcnt; - while (*tstr && tcnt) - { - unsigned short c; - tstr=adv_str(tstr, &tcnt, &c); - - if (c == '\r') continue; - if (c == '\n') - { - if (dtFlags & DT_SINGLELINE) c=' '; - else continue; - } - - charEnt *ent=findChar(c); - if (!ent) - { - const int os=m_extracharlist.GetSize(); - RenderGlyph(c); - if (m_extracharlist.GetSize() != os) ent=findChar(c); - } - if (ent && ent->base_offset == 0) RenderGlyph(c); - } - - if (dtFlags & DT_CALCRECT) - { - int xpos=0; - int ypos=0; - int max_xpos=0; - int max_ypos=0; - const char *next_break=NULL; - while (*str && strcnt) - { - unsigned short c; - str=adv_str(str, &strcnt, &c); - - if (c == '\r') continue; - if (c == '\n') - { - if (dtFlags & DT_SINGLELINE) - { - c=' '; // different from win32 native behavior, which skips the character - } - else - { - if (m_flags&LICE_FONT_FLAG_VERTICAL) - { - xpos+=m_line_height+lsadj; - ypos=0; - } - else - { - ypos+=m_line_height+lsadj; - xpos=0; - } - if (dtFlags&DT_WORDBREAK) next_break=NULL; - continue; - } - } - - charEnt *ent = findChar(c); - if (ent && ent->base_offset > 0 && ent->base_offset < m_cachestore.GetSize()) - { - if (m_flags&LICE_FONT_FLAG_VERTICAL) - { - const int yext = ypos + ent->height - ent->left_extra; - ypos += ent->advance; - if (xpos+ent->width>max_xpos) max_xpos=xpos+ent->width; - if (ypos>max_ypos) max_ypos=ypos; - if (yext>max_ypos) max_ypos=yext; - } - else - { - const int xext = xpos + ent->width - ent->left_extra; - xpos += ent->advance; - if (ypos+ent->height>max_ypos) max_ypos=ypos+ent->height; - if (xpos>max_xpos) max_xpos=xpos; - if (xext>max_xpos) max_xpos=xext; - } - - if (dtFlags&DT_WORDBREAK) - { - if (m_flags&LICE_FONT_FLAG_VERTICAL) - { - if (str == next_break) - { - xpos += m_line_height+lsadj; - ypos=0; - next_break=NULL; - } - if (!next_break) - { - next_break=NextWordBreak(str, strcnt, rect->bottom-rect->top-ypos); - } - } - else - { - if (str == next_break) - { - ypos += m_line_height+lsadj; - xpos=0; - next_break=NULL; - } - if (!next_break) - { - next_break=NextWordBreak(str, strcnt, rect->right-rect->left-xpos); - } - } - } - } - } - - rect->right = rect->left+max_xpos; - rect->bottom = rect->top+max_ypos; - - - int retval = (m_flags&LICE_FONT_FLAG_VERTICAL) ? max_xpos : max_ypos; - __LICE_SC_DRAWTEXT_RESTORE_RECT - if (__sc>0) return (retval * 256) / __sc; - return retval; - } - float alphaSave = m_alpha; - - if (dtFlags & LICE_DT_USEFGALPHA) - { - m_alpha *= LICE_GETA(m_fg)/255.0; - } - - if (m_alpha==0.0) - { - m_alpha=alphaSave; - __LICE_SC_DRAWTEXT_RESTORE_RECT - return 0; - } - - - RECT use_rect=*rect; - int xpos=use_rect.left; - int ypos=use_rect.top; - - bool isVertRev = false; - if ((m_flags&(LICE_FONT_FLAG_VERTICAL|LICE_FONT_FLAG_VERTICAL_BOTTOMUP)) == (LICE_FONT_FLAG_VERTICAL|LICE_FONT_FLAG_VERTICAL_BOTTOMUP)) - isVertRev=true; - - if (dtFlags & (DT_CENTER|DT_VCENTER|DT_RIGHT|DT_BOTTOM)) - { - RECT tr={0,}; - DrawTextImpl(bm,str,strcnt,&tr,DT_CALCRECT|(dtFlags & DT_SINGLELINE)|(forceWantAlpha?LICE_DT_NEEDALPHA:0)); - if (__sc > 0) - { - __LICE_SC(tr.right); - __LICE_SC(tr.bottom); - } - if (dtFlags & DT_CENTER) - { - xpos += (use_rect.right-use_rect.left-tr.right)/2; - } - else if (dtFlags & DT_RIGHT) - { - xpos = use_rect.right - tr.right; - } - - if (dtFlags & DT_VCENTER) - { - ypos += (use_rect.bottom-use_rect.top-tr.bottom)/2; - } - else if (dtFlags & DT_BOTTOM) - { - ypos = use_rect.bottom - tr.bottom; - } - if (isVertRev) - ypos += tr.bottom; - } - else if (isVertRev) - { - RECT tr={0,}; - DrawTextImpl(bm,str,strcnt,&tr,DT_CALCRECT|(dtFlags & DT_SINGLELINE)|(forceWantAlpha?LICE_DT_NEEDALPHA:0)); - if (__sc > 0) __LICE_SC(tr.bottom); - ypos += tr.bottom; - } - - - int start_y=ypos; - int start_x=xpos; - int max_ypos=ypos; - int max_xpos=xpos; - - if (!(dtFlags & DT_NOCLIP)) - { - if (use_rect.left<0)use_rect.left=0; - if (use_rect.top<0) use_rect.top=0; - if (use_rect.right > bm_w) use_rect.right = bm_w; - if (use_rect.bottom > bm_h) use_rect.bottom = bm_h; - if (use_rect.right <= use_rect.left || use_rect.bottom <= use_rect.top) - { - m_alpha=alphaSave; - __LICE_SC_DRAWTEXT_RESTORE_RECT - return 0; - } - } - else - { - use_rect.left=use_rect.top=0; - use_rect.right = bm_w; - use_rect.bottom = bm_h; - } - - - // todo: handle DT_END_ELLIPSIS etc - // thought: calculate length of "...", then when pos+length+widthofnextchar >= right, switch - // might need to precalc size to make sure it's needed, though - - const char *next_break=NULL; - while (*str && strcnt) - { - unsigned short c; - str=adv_str(str, &strcnt, &c); - - if (c == '\r') continue; - if (c == '\n') - { - if (dtFlags & DT_SINGLELINE) - { - c=' '; // different from win32 native behavior, which skips the character - } - else - { - if (m_flags&LICE_FONT_FLAG_VERTICAL) - { - xpos+=m_line_height+lsadj; - ypos=start_y; - } - else - { - ypos+=m_line_height+lsadj; - xpos=start_x; - } - if (dtFlags&DT_WORDBREAK) next_break=NULL; - continue; - } - } - - charEnt *ent = findChar(c); - if (ent && ent->base_offset > 0 && ent->base_offset < m_cachestore.GetSize()) - { - if (isVertRev) ypos -= ent->height; - - bool drawn = DrawGlyph(bm,c,xpos,ypos,&use_rect); - - if (m_flags&LICE_FONT_FLAG_VERTICAL) - { - if (!isVertRev) - { - ypos += ent->advance; - } - else ypos += ent->height - ent->advance; - if (drawn && xpos+ent->width > max_xpos) max_xpos=xpos; - } - else - { - xpos += ent->advance; - if (drawn && ypos+ent->height>max_ypos) max_ypos=ypos+ent->height; - } - - if (dtFlags&DT_WORDBREAK) - { - if (m_flags&LICE_FONT_FLAG_VERTICAL) - { - if (str == next_break) - { - xpos += m_line_height+lsadj; - ypos=start_y; - next_break=NULL; - } - if (!next_break) - { - next_break=NextWordBreak(str, strcnt, use_rect.bottom-ypos); - } - } - else - { - if (str == next_break) - { - ypos += m_line_height+lsadj; - xpos=start_x; - next_break=NULL; - } - if (!next_break) - { - next_break=NextWordBreak(str, strcnt, use_rect.right-xpos); - } - } - } - } - } - - m_alpha=alphaSave; - int retv = (m_flags&LICE_FONT_FLAG_VERTICAL) ? max_xpos - start_x : max_ypos - start_y; - __LICE_SC_DRAWTEXT_RESTORE_RECT - if (__sc>0) return (retv*256)/__sc; - return retv; -} diff --git a/oversampling/WDL/lice/test/.gitignore b/oversampling/WDL/lice/test/.gitignore deleted file mode 100644 index 4787a18..0000000 --- a/oversampling/WDL/lice/test/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -Win32/Debug/ -Win32/Release/ -x64/Debug/ -x64/Release/ - diff --git a/oversampling/WDL/lice/test/Makefile b/oversampling/WDL/lice/test/Makefile deleted file mode 100644 index 2f8c313..0000000 --- a/oversampling/WDL/lice/test/Makefile +++ /dev/null @@ -1,68 +0,0 @@ -CFLAGS=-O2 -g -Wall -LFLAGS= -CC=gcc -CXX=g++ -WDL_PATH=../.. - -CFLAGS += -D_FILE_OFFSET_BITS=64 - -ifdef NOSWELL -CFLAGS += -D_LICE_NO_SYSBITMAPS_ -SWELL_OBJS = -else - CFLAGS += -DSWELL_LICE_GDI - - ifdef GDK2 - CFLAGS += -DSWELL_TARGET_GDK=2 $(shell pkg-config --cflags gdk-2.0) - LFLAGS += $(shell pkg-config --libs gdk-2.0) -lX11 -lXi - else - CFLAGS += -DSWELL_TARGET_GDK=3 $(shell pkg-config --cflags gdk-3.0) - LFLAGS += $(shell pkg-config --libs gdk-3.0) -lX11 -lXi - endif - ifndef NOFREETYPE - CFLAGS += -DSWELL_FREETYPE $(shell pkg-config --cflags freetype2) - LFLAGS += $(shell pkg-config --libs freetype2) - endif - - SWELL_OBJS = swell-wnd-generic.o swell-gdi-lice.o swell.o swell-misc-generic.o \ - swell-dlg-generic.o swell-menu-generic.o swell-kb-generic.o \ - swell-gdi-generic.o swell-ini.o swell-generic-gdk.o \ - swell-appstub-generic.o swell-miscdlg-generic.o - - LFLAGS += -ldl - - vpath %.cpp $(WDL_PATH)/swell -endif - -CXXFLAGS=$(CFLAGS) - -vpath %.c $(WDL_PATH)/zlib $(WDL_PATH)/libpng $(WDL_PATH)/jpeglib $(WDL_PATH)/giflib -vpath %.cpp $(WDL_PATH)/lice $(WDL_PATH)/plush2 - -ZLIB_OBJS = compress.o adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o ioapi.o zip.o unzip.o - -PNGLIB_OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o pngtrans.o - -JPEGLIB_OBJS = jcomapi.o jdapimin.o jdapistd.o jdatadst.o jdatasrc.o jdcoefct.o jdcolor.o jddctmgr.o jdhuff.o jdinput.o jdmainct.o jdmarker.o \ - jdmaster.o jdmerge.o jdphuff.o jdpostct.o jdsample.o jerror.o jfdctflt.o jfdctfst.o jfdctint.o jidctflt.o jidctfst.o jidctint.o \ - jidctred.o jmemmgr.o jmemnobs.o jquant1.o jquant2.o jutils.o - -GIFLIB_OBJS = dgif_lib.o egif_lib.o gifalloc.o gif_hash.o - -LICEOBJS = lice.o lice_gif.o lice_gif_write.o lice_image.o lice_jpg.o lice_png.o lice_pcx.o lice_palette.o lice_line.o lice_arc.o lice_text.o lice_textnew.o lice_texgen.o lice_colorspace.o - -PLUSH_OBJS = pl_cam.o pl_make.o pl_math.o pl_obj.o pl_putface.o pl_read_3ds.o pl_read_cob.o pl_read_jaw.o pl_spline.o - -.phony: clean default - -default: test - -test: $(LICEOBJS) $(JPEGLIB_OBJS) $(PNGLIB_OBJS) $(ZLIB_OBJS) $(GIFLIB_OBJS) $(SWELL_OBJS) $(PLUSH_OBJS) main.o fly.o - $(CXX) $(CFLAGS) -o $@ $^ $(LFLAGS) - - -imgs2gif: $(LICEOBJS) $(JPEGLIB_OBJS) $(PNGLIB_OBJS) $(ZLIB_OBJS) $(GIFLIB_OBJS) $(SWELL_OBJS) imgs2gif.o - $(CXX) $(CFLAGS) -o $@ $^ $(LFLAGS) - -clean: - -rm $(LICEOBJS) $(JPEGLIB_OBJS) $(PNGLIB_OBJS) $(ZLIB_OBJS) $(GIFLIB_OBJS) imgs2gif.o imgs2gif $(SWELL_OBJS) $(PLUSH_OBJS) test main.o fly.o diff --git a/oversampling/WDL/lice/test/main.cpp b/oversampling/WDL/lice/test/main.cpp deleted file mode 100644 index 781abbe..0000000 --- a/oversampling/WDL/lice/test/main.cpp +++ /dev/null @@ -1,1137 +0,0 @@ -/* - Cockos WDL - LICE - Lightweight Image Compositing Engine - Copyright (C) 2007 and later, Cockos Incorporated - File: main.cpp (example use of LICE) - See lice.h for license and other information -*/ - -#ifndef WDL_NO_DEFINE_MINMAX -#define WDL_NO_DEFINE_MINMAX -#endif -#include "../lice.h" -#include "../../plush2/plush.h" -#include "../../MersenneTwister.h" -#include -#include - -#ifndef _WIN32 -#include -#include "../../swell/swell.h" -#endif - -static double gettm() -{ -#ifndef _WIN32 - struct timeval tm={0,}; - gettimeofday(&tm,NULL); - return (double)tm.tv_sec + (double)tm.tv_usec/1000000; -#else - LARGE_INTEGER freq; - QueryPerformanceFrequency(&freq); - - LARGE_INTEGER now; - QueryPerformanceCounter(&now); - return (double)now.QuadPart / (double)freq.QuadPart; -#endif -} - -char g_status[1024]; - - -#include "../lice_text.h" - -#include "../lice_glbitmap.h" -//#define GLEW_STATIC -//#include "../glew/include/gl/glew.h" -//#include "../glew/include/gl/wglew.h" - -//uncomment this to enable the ffmpeg video output in test 1 -//#define FFMPEG_TEST - -//#define TIMING -#include "../../timing.c" - -#ifdef FFMPEG_TEST -//ffmpeg encoding test -#include "../../ffmpeg.h" -#pragma comment(lib, "../../../sdks/ffmpeg/lib/avcodec.lib") -#pragma comment(lib, "../../../sdks/ffmpeg/lib/avformat.lib") -#pragma comment(lib, "../../../sdks/ffmpeg/lib/avutil.lib") -#pragma comment(lib, "../../../sdks/ffmpeg/lib/swscale.lib") -static WDL_VideoEncode *m_encoder; -static WDL_VideoDecode *m_decoder; -#endif - -#include "resource.h" - -#define NUM_EFFECTS 25 - -const char *effect_names[NUM_EFFECTS] = -{ - "Rotated + Scaled blit", - "Simple alpha blit", - "Rotated blit", - "Scaled blit", - "GradRect", - "Marble generator", - "Wood generator", - "Noise generator", - "Circular noise generator", - "GradRect + text + rotated blit", - "PutPixel", - "Line", - "DrawText", - "Icon loading", - "Circles, Arc", - "Rotated + Multiply add blit", - "Transform blit", - "Plush 3D", - "3D Fly (use mouse)", - "SVG loading (C:\\test.svg)", - "GL acceleration (disabled)", - "Bezier curves", - "Convex polygon fill", - "Palette generator (C:\\test.png)", - "Triangle test", -}; - -HINSTANCE g_hInstance; -LICE_IBitmap *jpg; -LICE_IBitmap *bmp; -LICE_IBitmap *icon; -LICE_IBitmap *framebuffer; -static int m_effect = 11; -static int m_doeff = 0; - -static LICE_IBitmap* tmpbmp = 0; - -static DWORD m_start_time, m_frame_cnt; -bool m_cap; - - -static void DoPaint(HWND hwndDlg, HDC dc) -{ - RECT r; - GetClientRect(hwndDlg, &r); - -#ifdef _WIN32 - r.top+=40; - if (r.top >= r.bottom) r.top=r.bottom-1; -#endif - - if (framebuffer->resize(r.right-r.left,r.bottom-r.top)) - { - m_doeff=1; - // memset(framebuffer->getBits(),0,framebuffer->getWidth()*framebuffer->getHeight()*4); - } - - int x=rand()%(r.right+300)-150; - int y=rand()%(r.bottom+300)-150; - - static int frame_cnt; - static int s_preveff = -1; - if (m_effect != s_preveff) - { - frame_cnt=0; - s_preveff = m_effect; - LICE_Clear(framebuffer, 0); - } - - static MTRand s_rng; - double t2=gettm(); - - switch(m_effect) - { - case 23: - { - const int palnumcols=256; - - static int init=0; - static LICE_IBitmap* srcbmp=0; - static LICE_IBitmap* palbmp=0; - static LICE_pixel palette[palnumcols] = { 0 }; - - if (!init) - { - init=-1; - srcbmp = LICE_LoadPNG("C:\\test.png"); - if (srcbmp) - { - int n = LICE_BuildPalette(srcbmp, palette, palnumcols); - palbmp = new LICE_MemBitmap; - LICE_Copy(palbmp, srcbmp); - void LICE_TestPalette(LICE_IBitmap*, LICE_pixel*, int); - LICE_TestPalette(palbmp, palette, n); - init=1; - } - } - - if (init > 0) - { - static int lastw=0; - static int lasth=0; - if (lastw != framebuffer->getWidth() || lasth != framebuffer->getHeight()) - { - lastw = framebuffer->getWidth(); - lasth = framebuffer->getHeight(); - int y = framebuffer->getHeight()*3/4; - LICE_ScaledBlit(framebuffer, srcbmp, 0, 0, lastw/2, y, 0, 0, srcbmp->getWidth(), srcbmp->getHeight(), 1.0f, LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR); - LICE_ScaledBlit(framebuffer, palbmp, lastw/2, 0, lastw/2, y, 0, 0, palbmp->getWidth(), palbmp->getHeight(), 1.0f, LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR); - - int dy = (lasth-y)/4; - int dx = lastw/(palnumcols/4); - int i, j, k=0; - for (i = 0; i < 4; ++i) - { - for (j = 0; j < palnumcols/4; ++j) - { - LICE_FillRect(framebuffer, j*dx, y+i*dy, dx, dy, palette[k++], 1.0f, LICE_BLIT_MODE_COPY); - } - } - } - } - } - break; - case 24: - { - LICE_MemBitmap bm(128,128); - LICE_Clear(framebuffer,0); - LICE_Clear(&bm,0); - - static POINT sp; - POINT p; - if (!sp.x&&!sp.y) GetCursorPos(&sp); - GetCursorPos(&p); - p.x-=sp.x; - p.y-=sp.y; - int th=p.y+16; - bool flip = th < 0; - if (flip) th=-th; - int tw=p.x+16; - int cx=(tw+1)/2; - int x=1,y=1; - LICE_pixel lc=LICE_RGBA(255,0,255,255); - LICE_Line(&bm,x,y,x+tw,y,lc,1.0f,LICE_BLIT_MODE_COPY); - LICE_Line(&bm,x,y+th,x+tw,y+th,lc,1.0f,LICE_BLIT_MODE_COPY); - LICE_Line(&bm,x+tw,y,x+tw,y+th,lc,1.0f,LICE_BLIT_MODE_COPY); - LICE_Line(&bm,x,y,x,y+th,lc,1.0f,LICE_BLIT_MODE_COPY); - - LICE_FillTriangle(&bm,x+tw,y+(flip?th:0)/*+th/4*/,x+cx,y+(flip?0:th),x,y+(flip?th:0),LICE_RGBA(255,255,255,255),0.75f,LICE_BLIT_MODE_COPY); - - int sc=16; - LICE_ScaledBlit(framebuffer,&bm,0,0,bm.getWidth()*sc,bm.getHeight()*sc,0,0,bm.getWidth(),bm.getHeight(),1.0,LICE_BLIT_MODE_COPY); - for (y=0;ygetWidth(); - int h = framebuffer->getHeight(); - - static bool init = false; - if (!init) - { - init = true; - for (i = 0; i < 16; ++i) - { - x[i] = s_rng.randInt(w-1); - y[i] = s_rng.randInt(h-1); - } - } - - for (i = 0; i < 16; ++i) - { - x[i] += s_rng.randNorm(0.0, 1.0)+0.5; - y[i] += s_rng.randNorm(0.0, 1.0)+0.5; - if (x[i] < 0) x[i] = 0; - else if (x[i] >= w) x[i] = w-1; - if (y[i] < 0) y[i] = 0; - else if (y[i] >= h) y[i] = h-1; - } - - LICE_Clear(framebuffer, 0); - LICE_FillConvexPolygon(framebuffer, x, y, 16, LICE_RGBA(96,96,96,255), 0.5f, LICE_BLIT_MODE_ADD); - - for (i = 0; i < 16; ++i) - { - LICE_Line(framebuffer, x[i]-1, y[i], x[i]+1, y[i], LICE_RGBA(255,0,0,255), 1.0f, LICE_BLIT_MODE_COPY); - LICE_Line(framebuffer, x[i], y[i]-1, x[i], y[i]+1, LICE_RGBA(255,0,0,255), 1.0f, LICE_BLIT_MODE_COPY); - } - } - break; - - case 21: - { - int w = framebuffer->getWidth(); - int h = framebuffer->getHeight(); - - int x0, y0, x1, y1, x2, y2, x3, y3; - - bool aa = true; - float maxsegmentpx = 0.0f; - - x0 = w*(double)rand()/RAND_MAX; - y0 = h*(double)rand()/RAND_MAX; - x1 = w*(double)rand()/RAND_MAX; - y1 = h*(double)rand()/RAND_MAX; - x2 = w*(double)rand()/RAND_MAX; - y2 = h*(double)rand()/RAND_MAX; - LICE_DrawQBezier(framebuffer, x0, y0, x1, y1, x2, y2, LICE_RGBA(255,0,0,255), 1.0f, LICE_BLIT_MODE_COPY, aa, maxsegmentpx); - - x0 = w*(double)rand()/RAND_MAX; - y0 = h*(double)rand()/RAND_MAX; - x1 = w*(double)rand()/RAND_MAX; - y1 = h*(double)rand()/RAND_MAX; - x2 = w*(double)rand()/RAND_MAX; - y2 = h*(double)rand()/RAND_MAX; - x3 = w*(double)rand()/RAND_MAX; - y3 = h*(double)rand()/RAND_MAX; - LICE_DrawCBezier(framebuffer, x0, y0, x1, y1, x2, y2, x3, y3, LICE_RGBA(0,255,0,255), 1.0f, LICE_BLIT_MODE_COPY, aa, maxsegmentpx); - } - break; - -#ifndef DISABLE_LICE_EXTENSIONS - case 20: // GL acceleration - { - int w = framebuffer->getWidth(); - int h = framebuffer->getHeight(); - - int x, y, tw, th; - - static LICE_IBitmap* glbmp = 0; - if (!glbmp) - { - glbmp = new LICE_GL_SysBitmap(0, 0); - glbmp->resize(w, h); - - glbmp = new LICE_GL_SubBitmap(glbmp, 20, 80, 50, 20); - - framebuffer = glbmp; - } - - if (!tmpbmp) - { - tmpbmp = new LICE_GL_MemBitmap(0, 0); - tmpbmp->resize(20, 20); - //tmpbmp = new LICE_MemBitmap(20, 20); - } - - LICE_Clear(tmpbmp, LICE_RGBA(255,0,0,255)); - LICE_Line(tmpbmp, 0, 0, 20, 20, LICE_RGBA(255,255,255,255), 1.0f, LICE_BLIT_MODE_COPY, true); - - static int _n = 0; - - //if (_n < 3) - { - //LICE_Clear(glbmp, LICE_RGBA(0,0,0,0)); - - x = w*rand()/RAND_MAX; - y = h*rand()/RAND_MAX; - LICE_Blit(glbmp, tmpbmp, x, y, 0, 0, 20, 20, 1.0f, LICE_BLIT_MODE_COPY); // blit one GL bitmap to another - - x = w*rand()/RAND_MAX; - y = h*rand()/RAND_MAX; - LICE_ScaledBlit(glbmp, tmpbmp, x, y, 40, 40, 0, 0, 20, 20, 1.0f, LICE_BLIT_MODE_COPY); // blit one GL bitmap to another - - x = w*rand()/RAND_MAX; - y = h*rand()/RAND_MAX; - tw = (w-x)*rand()/RAND_MAX; - th = (h-y)*rand()/RAND_MAX; - int color = (_n%2 ? LICE_RGBA(63,63,63,255) : LICE_RGBA(0,0,0,255)); - LICE_FillRect(glbmp, x, y, tw, th, color, 1.0f, LICE_BLIT_MODE_COPY); - - x = w*rand()/RAND_MAX; - y = h*rand()/RAND_MAX; - tw = (w-x)*rand()/RAND_MAX; - th = (h-y)*rand()/RAND_MAX; - LICE_Line(glbmp, x, y, x+tw, y+th, LICE_RGBA(255,0,0,255), 1.0f, LICE_BLIT_MODE_COPY, true); - - int x0 = w*rand()/RAND_MAX; - int y0 = h*rand()/RAND_MAX; - int x1 = w*rand()/RAND_MAX; - int y1 = h*rand()/RAND_MAX; - int x2 = w*rand()/RAND_MAX; - int y2 = h*rand()/RAND_MAX; - int x3 = w*rand()/RAND_MAX; - int y3 = h*rand()/RAND_MAX; - LICE_DrawCBezier(glbmp, x0, y0, x1, y1, x2, y2, x3, y3, LICE_RGBA(0,255,0,255), 1.0f, LICE_BLIT_MODE_COPY, true); - - #define A(x) ((LICE_pixel_chan)((x)*255.0+0.5)) - - LICE_pixel_chan alphas[81] = - { - A(0.00), A(0.12), A(0.69), A(1.00), A(1.00), A(1.00), A(0.69), A(0.12), A(0.00), - A(0.12), A(0.94), A(0.82), A(0.31), A(0.25), A(0.31), A(0.82), A(0.94), A(0.12), - A(0.69), A(0.82), A(0.06), A(0.00), A(0.00), A(0.00), A(0.06), A(0.82), A(0.69), - A(1.00), A(0.31), A(0.00), A(0.00), A(0.00), A(0.00), A(0.00), A(0.31), A(1.00), - A(1.00), A(0.19), A(0.00), A(0.00), A(0.00), A(0.00), A(0.00), A(0.19), A(1.00), - A(1.00), A(0.31), A(0.00), A(0.00), A(0.00), A(0.00), A(0.00), A(0.31), A(1.00), - A(0.69), A(0.82), A(0.06), A(0.00), A(0.00), A(0.00), A(0.06), A(0.82), A(0.69), - A(0.12), A(0.94), A(0.82), A(0.31), A(0.25), A(0.31), A(0.82), A(0.94), A(0.12), - A(0.00), A(0.12), A(0.69), A(1.00), A(1.00), A(1.00), A(0.69), A(0.12), A(0.00) - }; - int gw = 9; - int gh = 9; - - x = w*rand()/RAND_MAX; - y = h*rand()/RAND_MAX; - LICE_DrawGlyph(glbmp, x, y, LICE_RGBA(255,255,0,255), alphas, gw, gh, 1.0f, LICE_BLIT_MODE_COPY); - - static LICE_CachedFont* font = 0; - if (!font) - { - font = new LICE_CachedFont; - LOGFONT lf={ 12, 0, 0, 0, FW_LIGHT, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial"}; - HFONT hf = CreateFontIndirect(&lf); - font->SetFromHFont(hf, 0); - font->SetTextColor(LICE_RGBA(255,255,0,255)); - } - - x = w*rand()/RAND_MAX; - y = h*rand()/RAND_MAX; - RECT r = { x, y, x+40, y+10 }; - font->DrawText(glbmp, "foo bar", -1, &r, 0); - - } - ++_n; - } - break; -#endif - - case 18: - { - void doFlyEffect(LICE_IBitmap *fb,HWND); - doFlyEffect(framebuffer,m_cap ? hwndDlg : NULL); - } - break; - - case 17: - { - static pl_Obj *obj=NULL,*obj2=NULL; - static LICE_IBitmap *framebuffer2; - if (!framebuffer2) framebuffer2=new LICE_MemBitmap; - LICE_Copy(framebuffer2,framebuffer); - if (!obj) - { - pl_Mat *mat = new pl_Mat; - pl_Mat *mat2 = new pl_Mat; - - mat2->Smoothing=false; - mat2->Ambient[0]=mat2->Ambient[1]=mat2->Ambient[2]=0.0; - mat2->Diffuse[0]=mat2->Diffuse[1]=0.6; - mat2->Diffuse[2]=1.0; - - mat->Ambient[0]=mat->Ambient[1]=mat->Ambient[2]=0.0; - mat->Diffuse[0]=mat->Diffuse[1]=1.9; - mat->Diffuse[2]=0.4; - - mat->PerspectiveCorrect=16; - mat->SolidCombineMode=LICE_BLIT_MODE_COPY; - mat->SolidOpacity=1.0; - mat->Smoothing=true; - mat->Lightable=true; - //mat->FadeDist = 300.0; - - mat2->Texture=bmp; - mat2->TexOpacity=0.5; - mat2->TexCombineMode=LICE_BLIT_MODE_MUL|LICE_BLIT_FILTER_BILINEAR; - mat2->SolidOpacity=0.4; - mat2->BackfaceCull=false; - mat2->BackfaceIllumination=1.0; - mat2->Texture2=framebuffer2; - mat2->Tex2MapIdx=-1; - mat2->Tex2Opacity=0.75; - - mat->Texture=bmp; - LICE_TexGen_Marble(mat->Texture = new LICE_MemBitmap(r.right,r.bottom),NULL,0.3,0.4,0.0,1.0f); - - mat->TexOpacity=0.5; - mat->TexScaling[0]=mat->TexScaling[1]=3.0; - mat->TexCombineMode=LICE_BLIT_MODE_MUL|LICE_BLIT_FILTER_BILINEAR; - - LICE_TexGen_Noise(mat->Texture2 = new LICE_MemBitmap(r.right,r.bottom),NULL,0.3,0.4,0.0,1.0f); - // mat->Texture2=icon; - mat->Tex2MapIdx=-1; - mat->Tex2CombineMode=LICE_BLIT_MODE_ADD|LICE_BLIT_FILTER_BILINEAR; - mat->Tex2Opacity=0.8; - mat->Tex2Scaling[0]=2.0; - mat->Tex2Scaling[1]=-2.0; - - mat->BackfaceCull=true; - mat->BackfaceIllumination=0.0; - - obj=plMakeTorus(100.0,80.0,40,40,mat); - - int x; - if (0)for(x=1;x<3;x++) - { - pl_Obj *no = obj->Clone(); - no->Translate(0,40.0,-x*35.0); - obj->Children.Add(no); - no->Xa += 50.35*x; - no->Ya -= 30.13*x; - } - obj2=plMakeSphere(58,20,20,mat2); - obj2->Zp -= 30.0; - obj->Zp += 30.0; - - /*pl_Obj *o = plRead3DSObj("c:\\temp\\suzanne.3ds",mat); - if (o) - { - o->Scale(30.0); - o->Translate(150.0,0,0); - obj->Children.Add(o); - } - */ - } - obj2->Xa+=0.3; - obj2->Ya+=-0.1; - obj->Ya+=0.1; - obj->Xa+=0.1; - obj->Za+=0.1; - obj->GenMatrix=true; - - if (1) LICE_Clear(framebuffer,0); - else { - double a=GetTickCount()/1000.0; - - double scale=(1.1+sin(a)*0.3); - - LICE_RotatedBlit(framebuffer,framebuffer,0,0,r.right,r.bottom,0+sin(a*0.3)*16.0,0+sin(a*0.21)*16.0,r.right,r.bottom,cos(a*0.5)*0.13,false,254/255.0,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR); - } - static pl_Cam cam; - LICE_SubBitmap tmpbm(framebuffer,10,10,framebuffer->getWidth()-20,framebuffer->getHeight()-20); - //cam.CenterX = (tmpbm.getWidth()/2+80); - //cam.CenterY = (tmpbm.getHeight()/2+80); - cam.AspectRatio = 1.0;//cam.frameBuffer->getWidth()* 3.0/4.0 / (double)cam.frameBuffer->getHeight(); - cam.X = cam.Y = 0.0; - cam.Z = -200.0; - cam.WantZBuffer=true; - cam.SetTarget(0,0,0); - - - - static pl_Light light; - light.Set(PL_LIGHT_POINT,500.0,0,-900.0,1.3f,0.5f,0.5f,1000.0); - static pl_Light light2; - light2.Set(PL_LIGHT_POINT,-500.0,0,-700.0,0.0f,1.0f,0.5f,1000.0); - cam.ClipBack=220.0; - - cam.Begin(&tmpbm); - cam.RenderLight(&light); - cam.RenderLight(&light2); - cam.RenderObject(obj); - cam.SortToCurrent(); - cam.RenderObject(obj2); - cam.End(); - - char buf[512]; - sprintf(buf,"tri: %d->%d->%d, pix=%.0f", - cam.RenderTrisIn, - cam.RenderTrisCulled, - cam.RenderTrisOut,cam.RenderPixelsOut); - LICE_DrawText(framebuffer,0,10,buf,LICE_RGBA(255,255,255,255),1.0f,0); - - } - break; - case 15: - case 0: - { - double a=.51;//GetTickCount()/1000.0; - - double scale=(1.1+sin(a)*0.3); - - if (0) // weirdness - { - LICE_RotatedBlit(framebuffer,framebuffer,0,0,r.right,r.bottom,0+sin(a*0.3)*16.0,0+sin(a*0.21)*16.0,r.right,r.bottom,cos(a*0.5)*0.13,false,254/255.0,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR); - } - else // artifact-free mode - { - LICE_MemBitmap framebuffer_back; - - LICE_Copy(&framebuffer_back,framebuffer); - LICE_RotatedBlit(framebuffer,&framebuffer_back,0,0,r.right,r.bottom,0+sin(a*0.3)*16.0,0+sin(a*0.21)*16.0,r.right,r.bottom,cos(a*0.5)*0.13,false,1.0,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR); - timingEnter(0); - LICE_ScaledBlit(framebuffer,&framebuffer_back,0,0,r.right,r.bottom,-200,-200,3000,3000,0.1,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR); - timingLeave(0); - timingEnter(1); - LICE_ScaledBlit(framebuffer,&framebuffer_back,0,0,r.right,r.bottom,0,0,r.right/2,r.bottom/2,0.1,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR); - timingLeave(1); - } - //LICE_Clear(framebuffer,0); - if (bmp) LICE_RotatedBlit(framebuffer,bmp,r.right*scale,r.bottom*scale,r.right*(1.0-scale*2.0),r.bottom*(1.0-scale*2.0),0,0,bmp->getWidth(),bmp->getHeight(),cos(a*0.3)*13.0,false,0.3,LICE_BLIT_MODE_ADD|LICE_BLIT_USE_ALPHA|LICE_BLIT_FILTER_BILINEAR); - - if (m_effect==15) - { - LICE_MultiplyAddRect(framebuffer,0,0,framebuffer->getWidth(),framebuffer->getHeight(),0.9,0.9,-0.3,1, - 3,2,200,0); - } - - -#ifdef FFMPEG_TEST - -#if 0 - //ffmpeg encoding test - if(!m_encoder) m_encoder = new WDL_VideoEncode("flv", framebuffer->getWidth(),framebuffer->getHeight(), 25, 1256, NULL, 44100, 1, 128); - if(m_encoder->isInited()) - { - //set the alpha bit to 0xff - //LICE_FillRect(framebuffer, 0, 0, framebuffer->getWidth(), framebuffer->getHeight(), LICE_RGBA(0,0,0,255), 1.0f, LICE_BLIT_MODE_ADD); - m_encoder->encodeVideo(framebuffer->getBits()); - - static short audiodata[2000]={0,}; - static int initaudio=0; - if(!initaudio) - { - float t = 0; - for(int j=0;j<2000;j++) - { - audiodata[j] = (int)(sin(t) * 10000); - t += 2 * M_PI * 440.0 / 44100; - } - initaudio = 1; - } - m_encoder->encodeAudio(audiodata, 44100/25); - - static WDL_HeapBuf h; - h.Resize(256*1024); - unsigned char *p = (unsigned char *)h.Get(); - int s = m_encoder->getBytes(p, 256*1024); - if(s) - { - FILE *fh = fopen("c:\\temp\\out.flv", "ab"); - fwrite(p, s, 1, fh); - fclose(fh); - } - } -#else - //ffmpeg decoding test - if(!m_decoder) m_decoder = new WDL_VideoDecode("c:\\test.avi"); - if(m_decoder->isInited()) - { - static LICE_IBitmap *m_tmpframe; - static double t = 0; - if(!m_tmpframe) - { - m_tmpframe = new LICE_MemBitmap(framebuffer->getWidth(), framebuffer->getHeight()); - } - m_decoder->GetVideoFrameAtTime(m_tmpframe, t, NULL, &t, true); - t+=0.0001; - LICE_Blit(framebuffer, m_tmpframe, 0, 0, 0, 0, m_tmpframe->getWidth(), m_tmpframe->getHeight(), 1.0f, 0); - } -#endif - -#endif - - - } - break; - case 1: - if (rand()%6==0) - LICE_Blit(framebuffer,bmp,x,y,NULL,-1.4,LICE_BLIT_MODE_ADD|LICE_BLIT_USE_ALPHA); - else - LICE_Blit(framebuffer,bmp,x,y,NULL,0.6,LICE_BLIT_MODE_COPY|LICE_BLIT_USE_ALPHA); - break; - case 2: - { - LICE_Clear(framebuffer,0); - double a=GetTickCount()/1000.0; - - double scale=(1.1+sin(a)*0.3); - if (bmp) LICE_RotatedBlit(framebuffer,bmp,r.right*scale,r.bottom*scale,r.right*(1.0-scale*2.0),r.bottom*(1.0-scale*2.0),0,0,bmp->getWidth(),bmp->getHeight(),cos(a*0.3)*13.0,false,1.0,LICE_BLIT_MODE_ADD|LICE_BLIT_USE_ALPHA|LICE_BLIT_FILTER_BILINEAR,0.0,-bmp->getHeight()/2); - } - break; - case 3: - { - LICE_Clear(framebuffer,LICE_RGBA(128,128,128,128)); - static double a; - a+=0.003; - int xsize=sin(a*1.1)*r.right*10.5; - int ysize=sin(a*1.7)*r.bottom*10.5; - int xp = sin(a*0.3+1515851)*r.right*0.5; - int yp = sin(a*0.3+15853)*r.bottom*0.5; - - if (bmp) - { -// if (rand()%3==0) - // LICE_ScaledBlit(framebuffer,bmp,r.right/2-xsize/2,r.bottom/2-ysize/2,xsize,ysize,0.0,0.0,bmp->getWidth(),bmp->getHeight(),-0.7,LICE_BLIT_USE_ALPHA|LICE_BLIT_MODE_ADD|LICE_BLIT_FILTER_BILINEAR); - /// else - LICE_ScaledBlit(framebuffer,bmp,xp + r.right/2-xsize/2,yp + r.bottom/2-ysize/2,xsize,ysize,-300,-300,600+bmp->getWidth(),600+bmp->getHeight(),1,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR); - } - } - break; - case 4: - case 9: - - { - static double a; - a+=0.003; - - LICE_GradRect(framebuffer,0,0,framebuffer->getWidth(),framebuffer->getHeight(), - 0.5*sin(a*14.0),0.5*cos(a*2.0+1.3),0.5*sin(a*4.0),1.0, - (cos(a*37.0))/framebuffer->getWidth()*0.5,(sin(a*17.0))/framebuffer->getWidth()*0.5,(cos(a*7.0))/framebuffer->getWidth()*0.5,0, - (sin(a*12.0))/framebuffer->getHeight()*0.5,(cos(a*4.0))/framebuffer->getHeight()*0.5,(cos(a*3.0))/framebuffer->getHeight()*0.5,0, - LICE_BLIT_MODE_COPY); - - - if (m_effect==9) - { - /* LOGFONT lf={ - 140,0,0,0,FW_NORMAL,FALSE,FALSE,FALSE,DEFAULT_CHARSET, - OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH, - "Times New Roman" - }; - HFONT font=CreateFontIndirect(&lf); - - */ - - - LICE_SysBitmap bm(60,60); - LICE_Clear(&bm,LICE_RGBA(0,0,0,0)); - SetTextColor(bm.getDC(),RGB(255,255,255)); - SetBkMode(bm.getDC(),TRANSPARENT); - // HGDIOBJ of=SelectObject(bm.getDC(),font); - RECT r={0,0,bm.getWidth(),bm.getHeight()}; - DrawText(bm.getDC(),"LICE",-1,&r,DT_LEFT|DT_TOP|DT_SINGLELINE); - // SelectObject(bm.getDC(),of); - // DeleteObject(font); - - LICE_Blit(&bm,&bm,0,0,NULL,1.0,LICE_BLIT_MODE_CHANCOPY|LICE_PIXEL_R|(LICE_PIXEL_A<<2)); - - int bmw=bm.getWidth(); - int bmh=bm.getHeight(); - LICE_FillRect(framebuffer,framebuffer->getWidth()/2,framebuffer->getHeight()/2,bmh,bmw,0,0.5,LICE_BLIT_MODE_COPY); - LICE_RotatedBlit(framebuffer,&bm, - framebuffer->getWidth()/2,framebuffer->getHeight()/2, - bmh,bmw,0,0,bmw,bmh, - 3.14159*0.5,false,.4,LICE_BLIT_MODE_COPY|LICE_BLIT_USE_ALPHA|LICE_BLIT_FILTER_BILINEAR,-bm.getWidth()/4,-bm.getHeight()/4); - } - - break; - } - case 5: - if(m_doeff) - { - LICE_TexGen_Marble(framebuffer, NULL, 1, 1, 1, 1); - } - break; - case 6: - if(m_doeff) - { - LICE_TexGen_Noise(framebuffer, NULL, 0.9, 0.3, 0.6, 6.0f, NOISE_MODE_WOOD, 2); - } - break; - case 7: - if(m_doeff) - { - LICE_TexGen_Noise(framebuffer, NULL, 1,1,1, 8.0f, NOISE_MODE_NORMAL, 8); - } - break; - case 8: - if(m_doeff) - { - LICE_TexGen_CircNoise(framebuffer, NULL, 0.5f,0.5f,0.5f, 12.0f, 0.1f, 32); - } - break; - case 10: - { - int x; - static double a; - double sc=sin(a)*0.24; - a+=0.03; - for (x = 0; x < 10000; x ++) - LICE_PutPixel(framebuffer,rand()%framebuffer->getWidth(),rand()%framebuffer->getHeight(),LICE_RGBA(255,255,255,255),sc,LICE_BLIT_MODE_ADD); - } - break; - case 11: - //line test - { - - LICE_pixel goodCol=LICE_RGBA(192,0,192,64); - LICE_Clear(framebuffer,goodCol); - int subx=30,suby=30,subw=framebuffer->getWidth()-60,subh=framebuffer->getHeight()-60; - LICE_SubBitmap bm(framebuffer,subx,suby,subw,subh); - LICE_Clear(&bm,LICE_RGBA(80,80,80,255)); - - int n; - int w = framebuffer->getWidth(), h = framebuffer->getHeight(); - for(n=0;n<1000;n++) - { - LICE_FLine(&bm, rand()%(w*3/2)-w/4, rand()%(h*3/2)-h/4, rand()%(w*3/2)-w/4, rand()%(h*3/2)-h/4, LICE_RGBA(rand()%255,rand()%255,rand()%255,255)); - } - int y; - if (0) for(y=0;y=subx+subw||y>=suby+subh) - { - if (LICE_GetPixel(framebuffer,x,y)!=goodCol) - { - LICE_Clear(framebuffer,LICE_RGBA(255,255,255,255)); - y=h; - break; - } - } - } - } - - // LICE_Line(framebuffer, rand()%(w*3/2)-w/4, rand()%(h*3/2)-h/4, rand()%(w*3/2)-w/4, rand()%(h*3/2)-h/4, LICE_RGBA(rand()%255,rand()%255,rand()%255,255)); - } - break; - case 12: - //lice draw text test - { - static double a; - a+=0.001; - LICE_DrawText(framebuffer,0.5*(1+sin(a))*(framebuffer->getWidth()-30),0.5*(1+sin(a*7.0+1.3))*(framebuffer->getHeight()-16),"LICE RULEZ",LICE_RGBA(255,0,0,0),sin(a*0.7),LICE_BLIT_MODE_ADD); - } - break; - case 13: - //icon loading test - { - LICE_Clear(framebuffer, LICE_RGBA(255,255,255,255)); - LICE_Blit(framebuffer,icon,0,0,NULL,1.0f,LICE_BLIT_MODE_COPY|LICE_BLIT_USE_ALPHA); - } - break; - case 14: - // circles/arcs - { - int w = framebuffer->getWidth(), h = framebuffer->getHeight(); - const double _PI = acos(-1.0); - static int m_init, m_x, m_y; - if (!m_init) { - m_init = true; - m_x = w/2; m_y = h/2; - } - int r = rand()%w; - float alpha = 1.0f; //(float) r / (float) w; - float aLo = 2*_PI*rand()/RAND_MAX; - float aHi = 2*_PI*rand()/RAND_MAX; - - //LICE_Clear(framebuffer, LICE_RGBA(0,0,0,0)); - LICE_Arc(framebuffer, m_x, m_y, r, aLo, aHi, LICE_RGBA(rand()%255,rand()%255,rand()%255,255),alpha); - //LICE_Circle(framebuffer, m_x, m_y, r, LICE_RGBA(rand()%255,rand()%255,rand()%255,255)); - } - break; - case 16: - { - int sw=framebuffer->getWidth(); - int sh=framebuffer->getHeight(); - - LICE_MemBitmap framebuffer_back; - { - static double a; - a+=0.003; - - static int turd; - if ((turd++&511) < 12) - LICE_GradRect(framebuffer,sw/4,sh/4,sw/2,sh/2, - 0.5*sin(a*14.0),0.5*cos(a*2.0+1.3),0.5*sin(a*4.0),0.1, - (cos(a*37.0))/framebuffer->getWidth()*0.5,(sin(a*17.0))/framebuffer->getWidth()*0.5,(cos(a*7.0))/framebuffer->getWidth()*0.5,0, - (sin(a*12.0))/framebuffer->getHeight()*0.5,(cos(a*4.0))/framebuffer->getHeight()*0.5,(cos(a*3.0))/framebuffer->getHeight()*0.5,0, - LICE_BLIT_MODE_ADD); - } - //LICE_TexGen_Marble(framebuffer, NULL, 1, 1, 1, 1); - LICE_Copy(&framebuffer_back,framebuffer); - - - const int divw=10; - const int divh=5; - float pts[2*divw*divh]; - static float angs[2*divw*divh]; - static float dangs[2*divw*divh]; - static int turd; - if (!turd) - { - turd++; - int a; - for (a = 0; a < 2*divw*divh; a ++) - { - dangs[a]=((rand()%1000)-500)*0.0001; - angs[a]=((rand()%1000)-500)*0.1; - } - } - int x,y; - for (y=0;ygetWidth(), - framebuffer->getHeight(),pts,divw,divh,0.8,LICE_BLIT_MODE_COPY|LICE_BLIT_FILTER_BILINEAR); - } - - break; - case 19: - //SVG loading - break; - } - - if(jpg) - { - LICE_ScaledBlit(framebuffer,jpg,0,0,framebuffer->getWidth(),framebuffer->getHeight(),0,0,jpg->getWidth(),jpg->getHeight(),0.5,LICE_BLIT_MODE_COPY); - } - t2 = gettm()-t2; - - m_frame_cnt++; - - double sec=(GetTickCount()-m_start_time)*0.001; - //if (sec>0.0001) - if (g_status[0]) - { - LICE_DrawText(framebuffer,1,1,g_status,LICE_RGBA(0,0,0,0),1,LICE_BLIT_MODE_COPY); - LICE_DrawText(framebuffer,0,0,g_status,LICE_RGBA(255,255,255,0),1,LICE_BLIT_MODE_COPY); - } - - m_doeff = 0; - - double t1=gettm(); - - BitBlt(dc,r.left,r.top,framebuffer->getWidth(),framebuffer->getHeight(),framebuffer->getDC(),0,0,SRCCOPY); - // bmp->blitToDC(dc, NULL, 0, 0); - t1 = gettm()-t1; - - static double ac,stt,ac2; - - if (!frame_cnt++) - { - ac=ac2=0; - stt=gettm(); - } - ac+=t1; - ac2+=t2; - sprintf(g_status,"blit = %f/%f, %f/%f %dx%d @ %ffps\n",t1,t2,ac/frame_cnt,ac2/frame_cnt,framebuffer->getWidth(),framebuffer->getHeight(),frame_cnt/(gettm()-stt)); - -#if 0 - if (GetAsyncKeyState(VK_SHIFT)&0x8000) - if (GetAsyncKeyState(VK_MENU)&0x8000) - if (GetAsyncKeyState(VK_CONTROL)&0x8000) - { - LICE_WritePNG("/tmp/blah.png",framebuffer,false); - LICE_WriteJPG("/tmp/blah.jpg",framebuffer); - } -#endif -} - - -// this is only used on OS X since it's way faster there -LRESULT WINAPI testRenderDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - if (uMsg==WM_PAINT) - { - PAINTSTRUCT ps; - - HDC dc = BeginPaint(hwndDlg, &ps); - DoPaint(hwndDlg,dc); - EndPaint(hwndDlg, &ps); - return 0; - } - if (uMsg == WM_LBUTTONDOWN) - { - m_cap=true; - SetCapture(hwndDlg); - ShowCursor(FALSE); - } - else if (uMsg == WM_LBUTTONUP||uMsg==WM_CAPTURECHANGED) - { - m_cap=false; - ShowCursor(TRUE); - if (uMsg==WM_LBUTTONUP)ReleaseCapture(); - } - - return DefWindowProc(hwndDlg,uMsg,wParam,lParam); -} - -WDL_DLGRET WINAPI dlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - if (uMsg == WM_LBUTTONDOWN) - { - m_cap=true; - SetCapture(hwndDlg); - ShowCursor(FALSE); - } - else if (uMsg == WM_LBUTTONUP||uMsg==WM_CAPTURECHANGED) - { - m_cap=false; - ShowCursor(TRUE); - if (uMsg==WM_LBUTTONUP)ReleaseCapture(); - } - - switch(uMsg) - { - case WM_INITDIALOG: - - framebuffer = new LICE_SysBitmap(0,0); - - //jpg=LICE_LoadJPG("C:/turds.jpg"); - -#ifdef _WIN32 - bmp = LICE_LoadPNGFromResource(g_hInstance, MAKEINTRESOURCE(IDC_PNG1)); - icon = LICE_LoadIconFromResource(g_hInstance, MAKEINTRESOURCE(IDI_MAIN), 0); -#else - bmp = LICE_LoadPNGFromNamedResource("image.png"); - - - // uncomment if you want to try GL blits: - // SWELL_SetViewGL(GetDlgItem(hwndDlg,IDC_RECT),true); - SendMessage(hwndDlg,WM_SIZE,0,0); -#endif - - SetTimer(hwndDlg,1,1,NULL); - { - int x; - for (x = 0; x < NUM_EFFECTS; x ++) - { - char buf[512]; - wsprintf(buf,"Effect %d - %s",x+1,effect_names[x]); - SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_ADDSTRING,0,(LPARAM)buf); - } - SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_SETCURSEL,m_effect,0); - - m_start_time=GetTickCount(); - m_frame_cnt=0; - } - return 0; - case WM_DESTROY: - - - delete icon; - delete bmp; - delete framebuffer; - return 0; - -#ifdef _WIN32 - case WM_TIMER: - InvalidateRect(hwndDlg,NULL,FALSE); - return 0; - case WM_PAINT: - { - PAINTSTRUCT ps; - - HDC dc = BeginPaint(hwndDlg, &ps); - - DoPaint(hwndDlg,dc); - EndPaint(hwndDlg,&ps); - } - break; -#else - case WM_SIZE: - { - RECT r; - GetClientRect(hwndDlg,&r); - r.top+=40; - SetWindowPos(GetDlgItem(hwndDlg,IDC_RECT),NULL,r.left,r.top,r.right-r.left,r.bottom-r.top,SWP_NOZORDER|SWP_NOACTIVATE); - } - return 0; - case WM_TIMER: -#if 1 - InvalidateRect(GetDlgItem(hwndDlg,IDC_RECT),NULL,FALSE); -#else - { - HWND h = GetDlgItem(hwndDlg,IDC_RECT); - HDC dc = GetWindowDC(h); - DoPaint(hwndDlg,dc); - ReleaseDC(h,dc); - SWELL_FlushWindow(h); - } -#endif - return 0; -#endif - case WM_COMMAND: - switch(LOWORD(wParam)) - { - case IDC_COMBO1: - m_effect = SendDlgItemMessage(hwndDlg,IDC_COMBO1,CB_GETCURSEL,0,0); - m_doeff=1; - m_start_time=GetTickCount(); - m_frame_cnt=0; - break; - case IDCANCEL: -#ifndef __APPLE__ - EndDialog(hwndDlg, 0); -#else - DestroyWindow(hwndDlg); // on mac we run modeless -#endif - break; - } - break; - } - return 0; -} - -#ifdef _WIN32 -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdParam, int nShowCmd) -{ - - timingInit(); - g_hInstance=hInstance; - DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, dlgProc); - - timingPrint(); - - return 0; -} -#else - -static HWND ccontrolCreator(HWND parent, const char *cname, int idx, const char *classname, int style, int x, int y, int w, int h) -{ - if (!stricmp(classname,"TestRenderingClass")) - { - HWND hw=CreateDialog(NULL,0,parent,(DLGPROC)testRenderDialogProc); - SetWindowLong(hw,GWL_ID,idx); - SetWindowPos(hw,HWND_TOP,x,y,w,h,SWP_NOZORDER|SWP_NOACTIVATE); - ShowWindow(hw,SW_SHOWNA); - return hw; - } - return 0; -} - -#include "../../swell/swell-dlggen.h" - -// define our dialog box resource! - -SWELL_DEFINE_DIALOG_RESOURCE_BEGIN(IDD_DIALOG1,SWELL_DLG_WS_RESIZABLE|SWELL_DLG_WS_FLIPPED,"LICE Test",400,300,1.8) -BEGIN -CONTROL "",IDC_RECT,"TestRenderingClass",0,7,23,384,239 // we arae creating a custom control here because it will be opaque and therefor a LOT faster drawing -COMBOBOX IDC_COMBO1,7,7,181,170,CBS_DROPDOWNLIST | WS_VSCROLL | -WS_TABSTOP - -END -SWELL_DEFINE_DIALOG_RESOURCE_END(IDD_DIALOG1) - -#if !defined(__APPLE__) -int main(int argc, char **argv) -{ - SWELL_initargs(&argc,&argv); - SWELL_Internal_PostMessage_Init(); - SWELL_ExtendedAPI("APPNAME",(void*)"LICE test"); - SWELL_RegisterCustomControlCreator(ccontrolCreator); - //SWELL_ExtendedAPI("INIFILE",(void*)"path/to/ini/file.ini"); - //SWELL_ExtendedAPI("FONTPANGRAM",(void*)"LICE test thingy lbah akbzfshauoh01384u1023"); - DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, dlgProc); - - return 0; -} - -INT_PTR SWELLAppMain(int msg, INT_PTR parm1, INT_PTR parm2) -{ - return 0; -} -#endif -#endif diff --git a/oversampling/WDL/lineparse.h b/oversampling/WDL/lineparse.h deleted file mode 100644 index 07f4a4e..0000000 --- a/oversampling/WDL/lineparse.h +++ /dev/null @@ -1,350 +0,0 @@ -/* - WDL - lineparse.h - Copyright (C) 2005-2014 Cockos Incorporated - Copyright (C) 1999-2004 Nullsoft, Inc. - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - -*/ - -/* - - This file provides a simple line parsing class. This class was derived from that of NSIS, - http://nsis.sf.net, but it is no longer compatible (escaped-encodings and multiline C-style comments - are ignored). - - In particular, it allows for multiple space delimited tokens - on a line, with a choice of three quotes (`bla`, 'bla', or "bla") to contain any - items that may have spaces. - -*/ - -#ifndef WDL_LINEPARSE_H_ -#define WDL_LINEPARSE_H_ - -#include "heapbuf.h" - -#ifndef WDL_LINEPARSER_HAS_LINEPARSERINT -#define WDL_LINEPARSER_HAS_LINEPARSERINT -#endif - -#ifndef WDL_LINEPARSE_IMPL_ONLY -class LineParserInt // version which does not have any temporary space for buffers (requires use of parseDestroyBuffer) -{ - public: - int getnumtokens() const { return m_nt-m_eat; } - - #ifdef WDL_LINEPARSE_INTF_ONLY - // parse functions return <0 on error (-1=mem, -2=unterminated quotes), ignore_commentchars = true means don't treat #; as comments - int parseDestroyBuffer(char *line, bool ignore_commentchars = true, bool backtickquote = true, bool allowunterminatedquotes = false); - - double gettoken_float(int token) const; - int gettoken_int(int token) const; - unsigned int gettoken_uint(int token) const; // deprecated - const char *gettoken_str(int token) const; - char gettoken_quotingchar(int token) const; - int gettoken_enum(int token, const char *strlist) const; // null separated list - void insert_token_raw(int token, const char *p); // first character of p is quoting character! - #endif - - void eattoken() { if (m_eat= m_nt) return ""; - return m_tokens[token]; - } - - char WDL_LINEPARSE_PREFIX gettoken_quotingchar(int token) const - { - token+=m_eat; - if ((unsigned int)token >= m_nt) return 0; - - const char *tok = m_tokens[token]; - if (tok != m_tokenbasebuffer) switch (tok[-1]) - { - case '"': return '"'; - case '`': return '`'; - case '\'': return '\''; - } - return 0; - } - - int WDL_LINEPARSE_PREFIX gettoken_enum(int token, const char *strlist) const // null separated list - { - int x=0; - const char *tt=gettoken_str(token); - if (*tt) while (*strlist) - { - if (!stricmp(tt,strlist)) return x; - while (*strlist) strlist++; - strlist++; - x++; - } - return -1; - } - - void WDL_LINEPARSE_PREFIX insert_token_raw(int token, const char *p) // first character of p is quoting character! - { - if (WDL_NOT_NORMALLY((unsigned int)token > m_nt)) return; - if (WDL_NOT_NORMALLY(!adding_token_alloc())) return; - if ((unsigned int)token < m_nt) - memmove(m_tokens + token + 1, m_tokens + token, (m_nt-token) * sizeof(const char *)); - m_tokens[token] = p+1; - m_nt++; - } - -#ifndef WDL_LINEPARSE_IMPL_ONLY - private: -#endif - - - #undef WDL_LINEPARSE_PREFIX - #undef WDL_LINEPARSE_DEFPARM -#endif // ! WDL_LINEPARSE_INTF_ONLY - -#ifndef WDL_LINEPARSE_IMPL_ONLY - protected: - - bool adding_token_alloc() - { - if (m_nt < (int) (sizeof(m_toklist_small)/sizeof(m_toklist_small[0]))) - return true; - - m_tokens = m_toklist_big.ResizeOK(m_nt+1,false); - if (!m_tokens) - { - m_nt=0; - return false; - } - if (m_nt == (int) (sizeof(m_toklist_small)/sizeof(m_toklist_small[0]))) - memcpy(m_tokens,m_toklist_small,m_nt*sizeof(const char *)); - - return true; - } - - WDL_TypedBuf m_toklist_big; - - unsigned int m_nt, m_eat; - - const char *m_tokenbasebuffer; // points to (mangled) caller's buffer - const char **m_tokens; // points to m_toklist_small or m_toklist_big - - const char *m_toklist_small[64]; -}; -#endif//!WDL_LINEPARSE_IMPL_ONLY - - - - - - -// derived - -#ifndef WDL_LINEPARSE_IMPL_ONLY -class LineParser : public LineParserInt -{ - public: - int parse(const char *line) { return parse_ex(line,false); } // <0 on error, old style (;# starting tokens means comment to EOL) - - #ifdef WDL_LINEPARSE_INTF_ONLY - // parse functions return <0 on error (-1=mem, -2=unterminated quotes), ignore_commentchars = true means don't treat #; as comments - int parse_ex(const char *line, bool ignore_commentchars = true, bool backtickquote = true, bool allowunterminatedquotes = false); - void set_one_token(const char *ptr); - char *__get_tmpbuf(const char *line); - #endif - - - LineParser(bool ignoredLegacyValue=false) { } - -#endif // !WDL_LINEPARSE_IMPL_ONLY - - - -#ifndef WDL_LINEPARSE_INTF_ONLY - #ifdef WDL_LINEPARSE_IMPL_ONLY - #define WDL_LINEPARSE_PREFIX LineParser:: - #define WDL_LINEPARSE_DEFPARM(x) - #else - #define WDL_LINEPARSE_PREFIX - #define WDL_LINEPARSE_DEFPARM(x) =(x) - #endif - - int WDL_LINEPARSE_PREFIX parse_ex(const char *line, bool ignore_commentchars WDL_LINEPARSE_DEFPARM(true), bool backtickquote WDL_LINEPARSE_DEFPARM(true), bool allowunterminatedquotes WDL_LINEPARSE_DEFPARM(false)) - { - return parseDestroyBuffer(__get_tmpbuf(line), ignore_commentchars, backtickquote, allowunterminatedquotes); - } - - void WDL_LINEPARSE_PREFIX set_one_token(const char *line) - { - m_tokens=m_toklist_small; - m_tokens[0] = m_tokenbasebuffer = __get_tmpbuf(line); - m_eat=0; - m_nt=m_tokenbasebuffer?1:0; - } - - char * WDL_LINEPARSE_PREFIX __get_tmpbuf(const char *line) - { - int linelen = (int)strlen(line); - - char *usebuf=m_tmpbuf; - if (linelen >= (int)sizeof(m_tmpbuf)) - { - usebuf = (char *)m_tmpbuf_big.ResizeOK(linelen+1,false); - if (!usebuf) - { - m_nt=0; - return NULL; - } - } - memcpy(usebuf,line,linelen+1); - return usebuf; - } - - #undef WDL_LINEPARSE_PREFIX - #undef WDL_LINEPARSE_DEFPARM -#endif // ! WDL_LINEPARSE_INTF_ONLY - -#ifndef WDL_LINEPARSE_IMPL_ONLY - private: - - WDL_HeapBuf m_tmpbuf_big; - char m_tmpbuf[2048]; -}; -#endif//!WDL_LINEPARSE_IMPL_ONLY - - - - - - - -#endif//WDL_LINEPARSE_H_ - diff --git a/oversampling/WDL/localize/build_sample_langpack.cpp b/oversampling/WDL/localize/build_sample_langpack.cpp deleted file mode 100644 index 34ea259..0000000 --- a/oversampling/WDL/localize/build_sample_langpack.cpp +++ /dev/null @@ -1,691 +0,0 @@ -/* - * to generate a template language pack, use: - * build_sample_langpack --template *.rc *.cpp etc > file.langpack - * - */ -#include -#include -#include -#include -#ifndef _WIN32 -#define stricmp strcasecmp -#endif - -#include "../wdltypes.h" -#include "../assocarray.h" -#include "../ptrlist.h" -#include "../wdlstring.h" -#include "../fnv64.h" - -static bool isblank(char c) -{ - return c==' ' || c== '\t' || c=='\r' || c=='\n'; -} -static bool isblankorz(char c) -{ - return !c || isblank(c); -} - -WDL_StringKeyedArray section_descs; - -WDL_StringKeyedArray< WDL_PtrList * > translations; -WDL_StringKeyedArray< WDL_StringKeyedArray * > translations_indexed; - -void gotString(const char *str, int len, const char *secname, bool isRC, const char *fn, int line) -{ - WDL_PtrList *sec=translations.Get(secname); - if (!sec) - { - sec=new WDL_PtrList; - translations.Insert(secname,sec); - } - WDL_StringKeyedArray *sec2 = translations_indexed.Get(secname); - if (!sec2) - { - sec2 = new WDL_StringKeyedArray(true); - translations_indexed.Insert(secname,sec2); - } - if (len > (int)strlen(str)) - { - fprintf(stderr,"gotString got len>strlen(str) on %s:%d\n",fn,line); - exit(1); - } - - WDL_FastString buf; - if (!isRC) - { - int st = 0; - for (int x = 0; x < len; x ++) - { - if (!st) - { - if (str[x] == '\\' && str[x+1]) - { - buf.Append(str+x,2); - x++; - } - else if (str[x] == '\"') st=1; - else buf.Append(str+x,1); - } - else if (str[x] == '\"') st=0; - else if (!isblank(str[x])) - { - fprintf(stderr,"gotString has junk between concatenated strings on %s:%d\n",fn,line); - exit(1); - } - } - } - else - { - buf.Set(str,len); - } - if (sec2->Get(buf.Get())) return; //already in list - - sec2->Insert(buf.Get(),true); - sec->Add(strdup(buf.Get())); -} -const char *g_last_file; -int g_last_linecnt; -int length_of_quoted_string(char *p, bool convertRCquotesToSlash) -{ - int l=0; - while (p[l]) - { - if (convertRCquotesToSlash && p[l] == '\"' && p[l+1] == '\"') p[l]='\\'; - - if (p[l] == '\"') - { - if (convertRCquotesToSlash) return l; - - // scan over whitespace to see if another string begins, concat them - int l2 = l+1; - while (isblank(p[l2])) l2++; - if (p[l2] != '\"') return l; - l = l2; - } - if (p[l] == '\\') - { - l++; - } - if (!p[l] || p[l] == '\r' || p[l] == '\n') break; - l++; - } - fprintf(stderr,"ERROR: mismatched quotes in file %s:%d, check input!\n",g_last_file,g_last_linecnt); - exit(1); - return -1; -} - -static int uint64cmpfunc(WDL_UINT64 *a, WDL_UINT64 *b) -{ - if (*a < *b) return -1; - if (*a > *b) return 1; - return 0; -} -#define HACK_WILDCARD_ENTRY 2 -static int isLocalizeCall(const char *p) -{ - int rv = 0; - if (!strncmp(p,"__LOCALIZE",10)) { p+=10; rv = 1; } - else if (!strncmp(p,"ADD_WILDCARD_ENTRY",18)) { p+=18; rv = HACK_WILDCARD_ENTRY; } - else return 0; - - if (*p == '_') while (*p == '_' || (*p >= 'A' && *p <= 'Z')||(*p>='0' && *p <='9')) p++; - while (isblank(*p)) p++; - return *p == '(' ? rv : 0; -} - -WDL_UINT64 outputLine(const char *strv, int casemode) -{ - WDL_UINT64 h = WDL_FNV64_IV; - const char *p=strv; - while (*p) - { - char c = *p++; - if (c == '\\') - { - if (*p == '\\'||*p == '"' || *p == '\'') h=WDL_FNV64(h,(unsigned char *)p,1); - else if (*p == 'n') h=WDL_FNV64(h,(unsigned char *)"\n",1); - else if (*p == 'r') h=WDL_FNV64(h,(unsigned char *)"\r",1); - else if (*p == 't') h=WDL_FNV64(h,(unsigned char *)"\t",1); - else if (*p == '0') h=WDL_FNV64(h,(unsigned char *)"",1); - else if (*p == 'x' && p[1] == 'e' && p[2] == '9') - { - h=WDL_FNV64(h,(unsigned char *)"\xe9",1); - p+=2; - } - else - { - fprintf(stderr,"ERROR: unknown escape seq in '%s' at '%s'\n",strv,p); - exit(1); - } - p++; - } - else h=WDL_FNV64(h,(unsigned char *)&c,1); - } - h=WDL_FNV64(h,(unsigned char *)"",1); - - printf("%08X%08X=",(int)(h>>32),(int)(h&0xffffffff)); - int lc = 0; - while (*strv) - { - int c = *strv++; - if (lc == '%' || lc == '\\') { /* hacky*/ } - else if (c == '\\' && strv[0] == 'x' && strv[1] == 'e' && strv[2] == '9') - { - strv+=3; - c = 0xe9; - } - else if (casemode == 2) - { - switch (tolower(c)) - { - case 'o': c='0'; break; - case 'i': c='1'; break; - case 'e': c='3'; break; - case 'a': c='4'; break; - case 's': c='5'; break; - } - } - else if (casemode==-1) c=tolower(c); - else if (casemode==1) c=toupper(c); - else if (casemode==4) - { - switch (c) - { - case 'E': c=0xc494; break; - case 'A': c=0xc381; break; - case 'I': c=0xc38f; break; - case 'N': c=0xc391; break; - case 'O': c=0xc395; break; - case 'U': c=0xc39a; break; - case 'B': c=0xc39f; break; - case 'C': c=0xc486; break; - case 'G': c=0xc4a0; break; - case 'e': c=0xc497; break; - case 'a': c=0xc3a4; break; - case 'i': c=0xc4ad; break; - case 'n': c=0xc584; break; - case 'o': c=0xc58d; break; - case 'u': c=0xc5af; break; - case 'b': c=0xc39e; break; - case 'c': c=0xc48d; break; - case 'g': c=0xc49f; break; - } - if (c >= 256) - { - printf("%c",(c>>8)); - c&=0xff; - } - } - printf("%c",c); - if (lc == '%' && (c == '.' || c=='l' || (c>='0' && c<='9'))) - { - // ignore .xyz and l between format spec (hacky) - } - else if (lc == '%' && c == '%') lc = 0; - else if (lc == '\\' && c == '\\') lc = 0; - else lc = c; - } - printf("\n"); - return h; -} - - -WDL_StringKeyedArray g_resdefs; -const char *getResourceDefinesFromHeader(const char *fn) -{ - g_resdefs.DeleteAll(); - - FILE *fp=fopen(fn,"rb"); - if (!fp) return "error opening header"; - for (;;) - { - char buf[8192]; - g_last_linecnt++; - if (!fgets(buf,sizeof(buf),fp)) break; - char *p = buf; - while (*p) p++; - while (p>buf && (p[-1] == '\r'|| p[-1] == '\n' || p[-1] == ' ')) p--; - *p=0; - - if (!strncmp(buf,"#define",7)) - { - p=buf; - while (*p && *p != ' '&& *p != '\t') p++; - while (*p == ' ' || *p == '\t') p++; - char *n1 = p; - while (*p && *p != ' '&& *p != '\t') p++; - if (*p) *p++=0; - while (*p == ' ' || *p == '\t') p++; - int a = atoi(p); - if (a && *n1) - { - g_resdefs.Insert(n1,a); - } - } - } - - fclose(fp); - return NULL; -} - -void processRCfile(FILE *fp, const char *dirprefix, const char *filename) -{ - char sname[512]; - sname[0]=0; - int depth=0; - for (;;) - { - char buf[8192]; - g_last_linecnt++; - if (!fgets(buf,sizeof(buf),fp)) break; - char *p = buf; - while (*p) p++; - while (p>buf && (p[-1] == '\r'|| p[-1] == '\n' || p[-1] == ' ')) p--; - *p=0; - - p=buf; - if (sname[0]) while (*p == ' ' || *p == '\t') p++; - char *first_tok = p; - if (!strncmp(first_tok,"CLASS",5) && isblank(first_tok[5]) && first_tok[6]=='\"') continue; - - while (*p && *p != '\t' && *p != ' ') p++; - if (*p) *p++=0; - while (*p == '\t' || *p == ' ') p++; - char *second_tok = p; - - if ((!strncmp(second_tok,"DIALOG",6) && isblankorz(second_tok[6])) || - (!strncmp(second_tok,"DIALOGEX",8) && isblankorz(second_tok[8]))|| - (!strncmp(second_tok,"MENU",4) && isblankorz(second_tok[4]))) - { - if (sname[0]) - { - fprintf(stderr,"got %s inside a block\n",second_tok); - exit(1); - } - int sec = g_resdefs.Get(first_tok); - if (!sec) - { - fprintf(stderr, "unknown dialog %s\n",first_tok); - exit(1); - } - sprintf(sname,"%s%s%s_%d",dirprefix?dirprefix:"",dirprefix?"_":"",second_tok[0] == 'M' ? "MENU" : "DLG",sec); - section_descs.Insert(sname,strdup(first_tok)); - } - else if (sname[0] && *second_tok && *first_tok) - { - if (*second_tok == '"') - { - int l = length_of_quoted_string(second_tok+1,true); - if (l>0) - { - gotString(second_tok+1,l,sname, true, filename, g_last_linecnt); - - // OSX menu support: store a 2nd string w/o \tshortcuts, strip '&' too - // note: relies on length_of_quoted_string() pre-conversion above - if (depth && strstr(sname, "MENU_")) - { - int j=0; - char* m=second_tok+1; - for(;;) - { - if (!*m || (*m == '\\' && *(m+1)=='t') || (*m=='\"' && *(m-1)!='\\')) { buf[j]=0; break; } - if (*m != '&') buf[j++] = *m; - m++; - } - if (j!=l) gotString(buf,j,sname,true, filename, g_last_linecnt); - } - } - } - } - else if (!strcmp(first_tok,"BEGIN")) - { - depth++; - } - else if (!strcmp(first_tok,"END")) - { - depth--; - if (depth<0) - { - fprintf(stderr,"extra END\n"); - exit(1); - } - if (!depth) sname[0]=0; - } - - } - if (depth!=0) - { - fprintf(stderr,"missing some ENDs at end of rc file\n"); - exit(1); - } -} - -void processCPPfile(FILE *fp, const char *filename) -{ - char clocsec[512]; - clocsec[0]=0; - WDL_FastString fs; - for (;;) - { - char buf[8192]; - if (!fgets(buf,sizeof(buf),fp)) break; - fs.Append(buf); - } - - char *p = (char*)fs.Get(); - char *comment_state = NULL; - g_last_linecnt++; - while (*p) - { - if (!strncmp(p,"//",2)) - { - comment_state = p; - p+=2; - } - else if (*p == '\n') - { - g_last_linecnt++; - comment_state = NULL; - p++; - } - else if (!comment_state) - { - int hm; - if (*p == '\\') { p++; if (*p) p++; } - else if (*p == '\'') { p++; if (*p == '"') p++; } - else if (*p == '"') - { - int l = length_of_quoted_string(p+1,false); - if (clocsec[0]) - { - gotString(p+1,l,clocsec,false, filename, g_last_linecnt); - } - p += l+2; - } - else if ((p==(char*)fs.Get() || (!isalnum(p[-1]) && p[-1] != '_')) && (hm=isLocalizeCall(p))) - { - while (*p != '(') p++; - p++; - while (isblank(*p)) p++; - if (*p++ != '"') - { - fprintf(stderr,"Error: missing \" on %s:%d\n",filename,g_last_linecnt); - exit(1); - } - int l = length_of_quoted_string(p,false); - char *sp = p; - p+=l+1; - while (isblank(*p)) p++; - if (*p++ != ',') - { - fprintf(stderr,"Error: missing , on %s:%d\n",filename,g_last_linecnt); - exit(1); - } - while (isblank(*p)) p++; - if (*p++ != '"') - { - fprintf(stderr,"Error: missing second \" on %s:%d\n",filename,g_last_linecnt); - exit(1); - } - int l2 = length_of_quoted_string(p,false); - - if (hm == HACK_WILDCARD_ENTRY) - { - gotString(p,l2,"render_wildcard",false, filename, g_last_linecnt); - p += l2; - } - else - { - char sec[512]; - memcpy(sec,p,l2); - sec[l2]=0; - p+=l2; - gotString(sp,l,sec,false, filename, g_last_linecnt); - } - p++; - } - else - p++; - } - else if (p > comment_state && p < comment_state + 4) - { - if (!strncmp(p,"!WANT_LOCALIZE_STRINGS_BEGIN:",29)) - { - p += 29; - if (clocsec[0]) - { - fprintf(stderr,"Error: !WANT_LOCALIZE_STRINGS_BEGIN: before WANT_LOCALIZE_STRINGS_END on %s:%d\n",filename,g_last_linecnt); - exit(1); - } - int a = 0; - while (*p && !isblank(*p) && a < sizeof(clocsec)) clocsec[a++] = *p++; - if (a >= sizeof(clocsec)) - { - fprintf(stderr,"Error: !WANT_LOCALIZE_STRINGS_BEGIN: too long on %s:%d\n",filename,g_last_linecnt); - exit(1); - } - clocsec[a]=0; - } - else - { - if (!strncmp(p,"!WANT_LOCALIZE_STRINGS_END",26)) - { - if (!clocsec[0]) - { - fprintf(stderr,"Error: mismatched !WANT_LOCALIZE_STRINGS_END on %s:%d\n",filename,g_last_linecnt); - exit(1); - } - clocsec[0]=0; - } - p++; - } - } - else p++; - } - if (clocsec[0]) - { - fprintf(stderr,"Error: missing !WANT_LOCALIZE_STRINGS_END at eof %s:%d\n",filename,g_last_linecnt); - exit(1); - } -} - - - -int main(int argc, char **argv) -{ - int x; - int casemode=0; - for (x=1;x3 && !stricmp(argv[x]+alen-3,".rc")) - { - WDL_String s(argv[x]); - WDL_String dpre; - char *p=s.Get(); - while (*p) p++; - while (p>=s.Get() && *p != '\\' && *p != '/') p--; - *++p=0; - if (p>s.Get()) - { - p-=2; - while (p>=s.Get() && *p != '\\' && *p != '/') p--; - dpre.Set(++p); // get dir name portion - if (dpre.GetLength()) dpre.Get()[dpre.GetLength()-1]=0; - } - if (!strcmp(dpre.Get(),"jesusonic")) dpre.Set("jsfx"); - - s.Append("resource.h"); - const char *err=getResourceDefinesFromHeader(s.Get()); - if (err) - { - fprintf(stderr,"Error reading %s: %s\n",s.Get(),err); - exit(1); - } - processRCfile(fp,dpre.Get()[0]?dpre.Get():NULL, argv[x]); - } - else - { - processCPPfile(fp,argv[x]); - } - - fclose(fp); - } - if (casemode==4) printf("\xef\xbb\xbf"); - printf("#NAME:%s\n", - casemode==-1 ? "English (lower case, demo)" : - casemode==1 ? "English (upper case, demo)" : - casemode==2 ? "English (leet-speak, demo)" : - casemode==4 ? "UTF-8 English test (demo)" : - casemode==3 ? "Template (edit-me)" : - "English (sample language pack)"); - if (casemode==3) - { - printf("; NOTE: this is the best starting point for making a new langpack.\n" - "; As you translate a string, remove the ; from the beginning of the\n" - "; line. If the line begins with ;^, then it is an optional string,\n" - "; and you should only modify that line if the definition in [common]\n" - "; is not accurate for that context.\n" - "; You can enlarge windows using 5CA1E00000000000=scale, for example:\n" - "; [DLG_218] ; IDD_LOCKSETTINGS\n" - "; 5CA1E00000000000=1.2\n" - "; This makes the above dialog 1.2x wider than default.\n\n"); - } - - WDL_StringKeyedArray common_found; - { - if (!translations_indexed.GetSize()) - { - fprintf(stderr,"no sections!\n"); - exit(1); - } - else if (translations_indexed.GetSize() > 4096) - { - fprintf(stderr,"too many translation sections, check input or adjust code here\n"); - exit(1); - } - fprintf(stderr,"%d sections\n",translations_indexed.GetSize()); - - int pos[4096]={0,}; - printf("[common]\n"); - WDL_FastString matchlist; - WDL_AssocArray ids(uint64cmpfunc); - int minpos = 0; - for (;;) - { - int matchcnt=0; - matchlist.Set(""); - const char *str=NULL; - for(x=minpos;x *l = translations_indexed.Enumerate(x,&secname); - int sz=l->GetSize(); - if (!str) - { - if (x>minpos) - { - memset(pos,0,sizeof(pos)); // start over - minpos=x; - } - while (!str && pos[x]Enumerate(pos[x]++,&str); - if (!*str || common_found.Get(str)) str=NULL; // skip if we've already analyzed this string - } - if (str) matchlist.Set(secname); - } - else - { - while (pos[x] < sz) - { - const char *tv=NULL; - l->Enumerate(pos[x],&tv); - int c = strcmp(tv,str); - if (c>0) break; - pos[x]++; - if (!c) - { - matchlist.Append(", "); - matchlist.Append(secname); - matchcnt++; - break; - } - } - } - } - if (matchcnt>0) - { - common_found.Insert(str,true); - //printf("; used by: %s\n",matchlist.Get()); - if (casemode==3) printf(";"); - WDL_UINT64 a = outputLine(str,casemode); - if (ids.Get(a)) - { - fprintf(stderr,"duplicate hash for strings in common section, hope this is OK.. 64 bit hash fail!\n"); - exit(1); - } -// printf("\n"); - ids.Insert(a,true); - } - if (minpos == x-1) break; - } - printf("\n"); - } - - for(x=0;x *p = translations.Enumerate(x,&nm); - if (x) printf("\n"); - char *secinfo = section_descs.Get(nm); - printf("[%s]%s%s\n",nm,secinfo?" ; ":"", secinfo?secinfo:""); - int a; - int y; - WDL_AssocArray ids(uint64cmpfunc); - for (a=0;a<2;a++) - { - for (y=0;yGetSize();y++) - { - char *strv=p->Get(y); - if (!*strv) continue; - if ((common_found.Get(strv)?1:0) != a) continue; - - if (a) printf(";^"); - else if (casemode==3) printf(";"); - - WDL_UINT64 a = outputLine(strv,casemode); - if (ids.Get(a)) - { - fprintf(stderr,"duplicate hash for strings in section, hope this is OK.. 64 bit hash fail!\n"); - exit(1); - } - ids.Insert(a,true); - } - } - } - return 0; -} diff --git a/oversampling/WDL/localize/langpack_edit/.gitignore b/oversampling/WDL/localize/langpack_edit/.gitignore deleted file mode 100644 index a44db36..0000000 --- a/oversampling/WDL/localize/langpack_edit/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -Win32/Debug/ -Win32/Release/ -x64/Debug/ -x64/Release/ -*.sdf -*.opensdf -*.v12.suo diff --git a/oversampling/WDL/localize/langpack_edit/Base.lproj/MainMenu.xib b/oversampling/WDL/localize/langpack_edit/Base.lproj/MainMenu.xib deleted file mode 100644 index 5e4de97..0000000 --- a/oversampling/WDL/localize/langpack_edit/Base.lproj/MainMenu.xib +++ /dev/null @@ -1,654 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Default - - - - - - - Left to Right - - - - - - - Right to Left - - - - - - - - - - - Default - - - - - - - Left to Right - - - - - - - Right to Left - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/oversampling/WDL/localize/langpack_edit/LangPackEdit-Info.plist b/oversampling/WDL/localize/langpack_edit/LangPackEdit-Info.plist deleted file mode 100644 index 79c2644..0000000 --- a/oversampling/WDL/localize/langpack_edit/LangPackEdit-Info.plist +++ /dev/null @@ -1,36 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIconFile - LangPackEdit - CFBundleIdentifier - nobody.wdl.langpackedit - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - APPL - CFBundleShortVersionString - 0.5 - CFBundleSignature - ???? - CFBundleVersion - 1 - LSApplicationCategoryType - public.app-category.developer-tools - LSMinimumSystemVersion - ${MACOSX_DEPLOYMENT_TARGET} - NSHumanReadableCopyright - Copyright © 2022 Cockos Inc - NSMainNibFile - MainMenu - NSPrincipalClass - SWELLApplication - - diff --git a/oversampling/WDL/localize/langpack_edit/LangPackEdit-Prefix.pch b/oversampling/WDL/localize/langpack_edit/LangPackEdit-Prefix.pch deleted file mode 100644 index 4187f19..0000000 --- a/oversampling/WDL/localize/langpack_edit/LangPackEdit-Prefix.pch +++ /dev/null @@ -1,9 +0,0 @@ -// -// Prefix header -// -// The contents of this file are implicitly included at the beginning of every source file. -// - -#ifdef __OBJC__ - #import -#endif diff --git a/oversampling/WDL/localize/langpack_edit/LangPackEdit.icns b/oversampling/WDL/localize/langpack_edit/LangPackEdit.icns deleted file mode 100644 index 6eeef52..0000000 Binary files a/oversampling/WDL/localize/langpack_edit/LangPackEdit.icns and /dev/null differ diff --git a/oversampling/WDL/localize/langpack_edit/LangPackEdit.sln b/oversampling/WDL/localize/langpack_edit/LangPackEdit.sln deleted file mode 100644 index ca3a7c1..0000000 --- a/oversampling/WDL/localize/langpack_edit/LangPackEdit.sln +++ /dev/null @@ -1,28 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 2013 for Windows Desktop -VisualStudioVersion = 12.0.21005.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LangPackEdit", "LangPackEdit.vcxproj", "{DC8CCBA9-5214-48ED-96AE-C18B212FBE10}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DC8CCBA9-5214-48ED-96AE-C18B212FBE10}.Debug|Win32.ActiveCfg = Debug|Win32 - {DC8CCBA9-5214-48ED-96AE-C18B212FBE10}.Debug|Win32.Build.0 = Debug|Win32 - {DC8CCBA9-5214-48ED-96AE-C18B212FBE10}.Debug|x64.ActiveCfg = Debug|x64 - {DC8CCBA9-5214-48ED-96AE-C18B212FBE10}.Debug|x64.Build.0 = Debug|x64 - {DC8CCBA9-5214-48ED-96AE-C18B212FBE10}.Release|Win32.ActiveCfg = Release|Win32 - {DC8CCBA9-5214-48ED-96AE-C18B212FBE10}.Release|Win32.Build.0 = Release|Win32 - {DC8CCBA9-5214-48ED-96AE-C18B212FBE10}.Release|x64.ActiveCfg = Release|x64 - {DC8CCBA9-5214-48ED-96AE-C18B212FBE10}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/oversampling/WDL/localize/langpack_edit/LangPackEdit.vcxproj b/oversampling/WDL/localize/langpack_edit/LangPackEdit.vcxproj deleted file mode 100644 index d5061fc..0000000 --- a/oversampling/WDL/localize/langpack_edit/LangPackEdit.vcxproj +++ /dev/null @@ -1,172 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {DC8CCBA9-5214-48ED-96AE-C18B212FBE10} - Win32Proj - LangPackEdit - - - - Application - true - v120 - MultiByte - - - Application - true - v120 - MultiByte - - - Application - false - v120 - true - MultiByte - - - Application - false - v120 - true - MultiByte - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)$(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\ - - - - Level3 - Disabled - WIN32;BUILD_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - false - - - Windows - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;winmm.lib;wsock32.lib;%(AdditionalDependencies) - - - - - Level3 - Disabled - WIN32;BUILD_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - false - - - Windows - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;winmm.lib;wsock32.lib;%(AdditionalDependencies) - - - - - Level3 - NotUsing - MaxSpeed - true - true - WIN32;BUILD_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - MultiThreaded - - - Windows - true - true - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;winmm.lib;wsock32.lib;%(AdditionalDependencies) - - - - - Level3 - NotUsing - MaxSpeed - true - true - WIN32;BUILD_WINDOWS;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_WARNINGS;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - MultiThreaded - - - Windows - true - true - true - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;winmm.lib;wsock32.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - - - diff --git a/oversampling/WDL/localize/langpack_edit/LangPackEdit.vcxproj.filters b/oversampling/WDL/localize/langpack_edit/LangPackEdit.vcxproj.filters deleted file mode 100644 index 95a0a99..0000000 --- a/oversampling/WDL/localize/langpack_edit/LangPackEdit.vcxproj.filters +++ /dev/null @@ -1,50 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {26d63633-dc60-4f96-afe7-14e5aa4ad154} - - - - - - - - Header Files - - - - - Source Files\WDL - - - Source Files\WDL - - - Source Files - - - Source Files\WDL - - - Source Files\WDL - - - - - Resource Files - - - diff --git a/oversampling/WDL/localize/langpack_edit/LangPackEdit.xcodeproj/project.pbxproj b/oversampling/WDL/localize/langpack_edit/LangPackEdit.xcodeproj/project.pbxproj deleted file mode 100644 index c9efd20..0000000 --- a/oversampling/WDL/localize/langpack_edit/LangPackEdit.xcodeproj/project.pbxproj +++ /dev/null @@ -1,417 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 338536692957A46300048720 /* langpack_edit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 338536682957A46300048720 /* langpack_edit.cpp */; }; - 3385366B2957A4D300048720 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 3385366A2957A4D300048720 /* main.m */; }; - 338536702957A62F00048720 /* LangPackEdit.icns in Resources */ = {isa = PBXBuildFile; fileRef = 3385366E2957A62F00048720 /* LangPackEdit.icns */; }; - 338536732957A6EB00048720 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 338536712957A6EB00048720 /* MainMenu.xib */; }; - 3385932D185B555500FDFFEA /* wndsize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3385932C185B555500FDFFEA /* wndsize.cpp */; }; - 33AA3116185A7E8D001D767E /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33AA3115185A7E8D001D767E /* Cocoa.framework */; }; - 33AA3126185A7E8D001D767E /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 33AA3124185A7E8D001D767E /* Credits.rtf */; }; - 33B8832B2958A0C300A9EBFF /* filebrowse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33B8832A2958A0C300A9EBFF /* filebrowse.cpp */; }; - 33B8832E2958A3BD00A9EBFF /* localize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33B8832D2958A3BD00A9EBFF /* localize.cpp */; }; - 33F96581185A7F79004C7070 /* swell-appstub.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33F96576185A7F79004C7070 /* swell-appstub.mm */; }; - 33F96582185A7F79004C7070 /* swell-dlg.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33F96577185A7F79004C7070 /* swell-dlg.mm */; }; - 33F96583185A7F79004C7070 /* swell-gdi.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33F96578185A7F79004C7070 /* swell-gdi.mm */; }; - 33F96584185A7F79004C7070 /* swell-ini.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33F96579185A7F79004C7070 /* swell-ini.cpp */; }; - 33F96585185A7F79004C7070 /* swell-kb.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33F9657A185A7F79004C7070 /* swell-kb.mm */; }; - 33F96586185A7F79004C7070 /* swell-menu.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33F9657B185A7F79004C7070 /* swell-menu.mm */; }; - 33F96587185A7F79004C7070 /* swell-misc.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33F9657C185A7F79004C7070 /* swell-misc.mm */; }; - 33F96588185A7F79004C7070 /* swell-miscdlg.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33F9657D185A7F79004C7070 /* swell-miscdlg.mm */; }; - 33F96589185A7F79004C7070 /* swell-wnd.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33F9657E185A7F79004C7070 /* swell-wnd.mm */; }; - 33F9658A185A7F79004C7070 /* swell.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33F9657F185A7F79004C7070 /* swell.cpp */; }; - 33F9658B185A7F79004C7070 /* swellappmain.mm in Sources */ = {isa = PBXBuildFile; fileRef = 33F96580185A7F79004C7070 /* swellappmain.mm */; }; - 33F9658D185A8228004C7070 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33F9658C185A8228004C7070 /* Carbon.framework */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 338536682957A46300048720 /* langpack_edit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = langpack_edit.cpp; sourceTree = SOURCE_ROOT; }; - 3385366A2957A4D300048720 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; }; - 3385366C2957A62F00048720 /* LangPackEdit-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "LangPackEdit-Info.plist"; sourceTree = SOURCE_ROOT; }; - 3385366D2957A62F00048720 /* LangPackEdit-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "LangPackEdit-Prefix.pch"; sourceTree = SOURCE_ROOT; }; - 3385366E2957A62F00048720 /* LangPackEdit.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = LangPackEdit.icns; sourceTree = SOURCE_ROOT; }; - 338536722957A6EB00048720 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = SOURCE_ROOT; }; - 3385932C185B555500FDFFEA /* wndsize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = wndsize.cpp; path = ../../wingui/wndsize.cpp; sourceTree = ""; }; - 33AA3112185A7E8D001D767E /* LangPackEdit.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LangPackEdit.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 33AA3115185A7E8D001D767E /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; - 33AA3118185A7E8D001D767E /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; - 33AA3119185A7E8D001D767E /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; - 33AA311A185A7E8D001D767E /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 33AA311F185A7E8D001D767E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; - 33AA3125185A7E8D001D767E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; name = en; path = en.lproj/Credits.rtf; sourceTree = ""; }; - 33B8832A2958A0C300A9EBFF /* filebrowse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ../../filebrowse.cpp; sourceTree = ""; }; - 33B8832C2958A3BD00A9EBFF /* localize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = localize.h; path = localize/localize.h; sourceTree = ""; }; - 33B8832D2958A3BD00A9EBFF /* localize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = localize.cpp; path = ../localize.cpp; sourceTree = ""; }; - 33F96576185A7F79004C7070 /* swell-appstub.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "swell-appstub.mm"; path = "../../swell/swell-appstub.mm"; sourceTree = ""; }; - 33F96577185A7F79004C7070 /* swell-dlg.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "swell-dlg.mm"; path = "../../swell/swell-dlg.mm"; sourceTree = ""; }; - 33F96578185A7F79004C7070 /* swell-gdi.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "swell-gdi.mm"; path = "../../swell/swell-gdi.mm"; sourceTree = ""; }; - 33F96579185A7F79004C7070 /* swell-ini.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "swell-ini.cpp"; path = "../../swell/swell-ini.cpp"; sourceTree = ""; }; - 33F9657A185A7F79004C7070 /* swell-kb.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "swell-kb.mm"; path = "../../swell/swell-kb.mm"; sourceTree = ""; }; - 33F9657B185A7F79004C7070 /* swell-menu.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "swell-menu.mm"; path = "../../swell/swell-menu.mm"; sourceTree = ""; }; - 33F9657C185A7F79004C7070 /* swell-misc.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "swell-misc.mm"; path = "../../swell/swell-misc.mm"; sourceTree = ""; }; - 33F9657D185A7F79004C7070 /* swell-miscdlg.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "swell-miscdlg.mm"; path = "../../swell/swell-miscdlg.mm"; sourceTree = ""; }; - 33F9657E185A7F79004C7070 /* swell-wnd.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "swell-wnd.mm"; path = "../../swell/swell-wnd.mm"; sourceTree = ""; }; - 33F9657F185A7F79004C7070 /* swell.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = swell.cpp; path = ../../swell/swell.cpp; sourceTree = ""; }; - 33F96580185A7F79004C7070 /* swellappmain.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = swellappmain.mm; path = ../../swell/swellappmain.mm; sourceTree = ""; }; - 33F9658C185A8228004C7070 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 33AA310F185A7E8D001D767E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 33F9658D185A8228004C7070 /* Carbon.framework in Frameworks */, - 33AA3116185A7E8D001D767E /* Cocoa.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 33AA3109185A7E8D001D767E = { - isa = PBXGroup; - children = ( - 338536712957A6EB00048720 /* MainMenu.xib */, - 338536682957A46300048720 /* langpack_edit.cpp */, - 3385366C2957A62F00048720 /* LangPackEdit-Info.plist */, - 3385366D2957A62F00048720 /* LangPackEdit-Prefix.pch */, - 3385366E2957A62F00048720 /* LangPackEdit.icns */, - 3385366A2957A4D300048720 /* main.m */, - 33AA3149185A7EEC001D767E /* WDL */, - 33AA311E185A7E8D001D767E /* InfoPlist.strings */, - 33AA3124185A7E8D001D767E /* Credits.rtf */, - 33AA3114185A7E8D001D767E /* Frameworks */, - 33AA3113185A7E8D001D767E /* Products */, - ); - sourceTree = ""; - }; - 33AA3113185A7E8D001D767E /* Products */ = { - isa = PBXGroup; - children = ( - 33AA3112185A7E8D001D767E /* LangPackEdit.app */, - ); - name = Products; - sourceTree = ""; - }; - 33AA3114185A7E8D001D767E /* Frameworks */ = { - isa = PBXGroup; - children = ( - 33F9658C185A8228004C7070 /* Carbon.framework */, - 33AA3115185A7E8D001D767E /* Cocoa.framework */, - 33AA3117185A7E8D001D767E /* Other Frameworks */, - ); - name = Frameworks; - sourceTree = ""; - }; - 33AA3117185A7E8D001D767E /* Other Frameworks */ = { - isa = PBXGroup; - children = ( - 33AA3118185A7E8D001D767E /* AppKit.framework */, - 33AA3119185A7E8D001D767E /* CoreData.framework */, - 33AA311A185A7E8D001D767E /* Foundation.framework */, - ); - name = "Other Frameworks"; - sourceTree = ""; - }; - 33AA3149185A7EEC001D767E /* WDL */ = { - isa = PBXGroup; - children = ( - 33B8832A2958A0C300A9EBFF /* filebrowse.cpp */, - 33B8832D2958A3BD00A9EBFF /* localize.cpp */, - 33B8832C2958A3BD00A9EBFF /* localize.h */, - 3385932C185B555500FDFFEA /* wndsize.cpp */, - 33AA314A185A7EF4001D767E /* swell */, - ); - name = WDL; - path = .; - sourceTree = ""; - }; - 33AA314A185A7EF4001D767E /* swell */ = { - isa = PBXGroup; - children = ( - 33F96576185A7F79004C7070 /* swell-appstub.mm */, - 33F96577185A7F79004C7070 /* swell-dlg.mm */, - 33F96578185A7F79004C7070 /* swell-gdi.mm */, - 33F96579185A7F79004C7070 /* swell-ini.cpp */, - 33F9657A185A7F79004C7070 /* swell-kb.mm */, - 33F9657B185A7F79004C7070 /* swell-menu.mm */, - 33F9657C185A7F79004C7070 /* swell-misc.mm */, - 33F9657D185A7F79004C7070 /* swell-miscdlg.mm */, - 33F9657E185A7F79004C7070 /* swell-wnd.mm */, - 33F9657F185A7F79004C7070 /* swell.cpp */, - 33F96580185A7F79004C7070 /* swellappmain.mm */, - ); - name = swell; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 33AA3111185A7E8D001D767E /* LangPackEdit */ = { - isa = PBXNativeTarget; - buildConfigurationList = 33AA3143185A7E8D001D767E /* Build configuration list for PBXNativeTarget "LangPackEdit" */; - buildPhases = ( - 3304E16F1FC2253B00290319 /* ShellScript */, - 33AA310E185A7E8D001D767E /* Sources */, - 33AA310F185A7E8D001D767E /* Frameworks */, - 33AA3110185A7E8D001D767E /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = LangPackEdit; - productName = langpack_edit; - productReference = 33AA3112185A7E8D001D767E /* LangPackEdit.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 33AA310A185A7E8D001D767E /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0500; - ORGANIZATIONNAME = cockos; - }; - buildConfigurationList = 33AA310D185A7E8D001D767E /* Build configuration list for PBXProject "LangPackEdit" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - English, - en, - Base, - ); - mainGroup = 33AA3109185A7E8D001D767E; - productRefGroup = 33AA3113185A7E8D001D767E /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 33AA3111185A7E8D001D767E /* LangPackEdit */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 33AA3110185A7E8D001D767E /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 338536732957A6EB00048720 /* MainMenu.xib in Resources */, - 33AA3126185A7E8D001D767E /* Credits.rtf in Resources */, - 338536702957A62F00048720 /* LangPackEdit.icns in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXShellScriptBuildPhase section */ - 3304E16F1FC2253B00290319 /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/usr/bin/perl ../../swell/swell_resgen.pl res.rc\n"; - showEnvVarsInLog = 0; - }; -/* End PBXShellScriptBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 33AA310E185A7E8D001D767E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 33B8832E2958A3BD00A9EBFF /* localize.cpp in Sources */, - 33F96581185A7F79004C7070 /* swell-appstub.mm in Sources */, - 33F9658B185A7F79004C7070 /* swellappmain.mm in Sources */, - 33F9658A185A7F79004C7070 /* swell.cpp in Sources */, - 33F96584185A7F79004C7070 /* swell-ini.cpp in Sources */, - 3385932D185B555500FDFFEA /* wndsize.cpp in Sources */, - 33F96589185A7F79004C7070 /* swell-wnd.mm in Sources */, - 33F96582185A7F79004C7070 /* swell-dlg.mm in Sources */, - 33F96585185A7F79004C7070 /* swell-kb.mm in Sources */, - 33F96586185A7F79004C7070 /* swell-menu.mm in Sources */, - 33F96583185A7F79004C7070 /* swell-gdi.mm in Sources */, - 338536692957A46300048720 /* langpack_edit.cpp in Sources */, - 33B8832B2958A0C300A9EBFF /* filebrowse.cpp in Sources */, - 33F96587185A7F79004C7070 /* swell-misc.mm in Sources */, - 3385366B2957A4D300048720 /* main.m in Sources */, - 33F96588185A7F79004C7070 /* swell-miscdlg.mm in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - 338536712957A6EB00048720 /* MainMenu.xib */ = { - isa = PBXVariantGroup; - children = ( - 338536722957A6EB00048720 /* Base */, - ); - name = MainMenu.xib; - sourceTree = ""; - }; - 33AA311E185A7E8D001D767E /* InfoPlist.strings */ = { - isa = PBXVariantGroup; - children = ( - 33AA311F185A7E8D001D767E /* en */, - ); - name = InfoPlist.strings; - sourceTree = ""; - }; - 33AA3124185A7E8D001D767E /* Credits.rtf */ = { - isa = PBXVariantGroup; - children = ( - 33AA3125185A7E8D001D767E /* en */, - ); - name = Credits.rtf; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 33AA3141185A7E8D001D767E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++98"; - CLANG_CXX_LIBRARY = "libstdc++"; - CLANG_ENABLE_OBJC_ARC = NO; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_STRICT_ALIASING = NO; - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.5; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - }; - name = Debug; - }; - 33AA3142185A7E8D001D767E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD)"; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++98"; - CLANG_CXX_LIBRARY = "libstdc++"; - CLANG_ENABLE_OBJC_ARC = NO; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_STRICT_ALIASING = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.5; - SDKROOT = macosx; - }; - name = Release; - }; - 33AA3144185A7E8D001D767E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_CXX_LIBRARY = "libc++"; - COMBINE_HIDPI_IMAGES = YES; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "LangPackEdit-Prefix.pch"; - GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; - INFOPLIST_FILE = "LangPackEdit-Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.9; - PRODUCT_BUNDLE_IDENTIFIER = nobody.wdl.langpackedit; - PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = app; - }; - name = Debug; - }; - 33AA3145185A7E8D001D767E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_CXX_LIBRARY = "libc++"; - COMBINE_HIDPI_IMAGES = YES; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "LangPackEdit-Prefix.pch"; - GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; - INFOPLIST_FILE = "LangPackEdit-Info.plist"; - MACOSX_DEPLOYMENT_TARGET = 10.9; - PRODUCT_BUNDLE_IDENTIFIER = nobody.wdl.langpackedit; - PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = app; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 33AA310D185A7E8D001D767E /* Build configuration list for PBXProject "LangPackEdit" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 33AA3141185A7E8D001D767E /* Debug */, - 33AA3142185A7E8D001D767E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 33AA3143185A7E8D001D767E /* Build configuration list for PBXNativeTarget "LangPackEdit" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 33AA3144185A7E8D001D767E /* Debug */, - 33AA3145185A7E8D001D767E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 33AA310A185A7E8D001D767E /* Project object */; -} diff --git a/oversampling/WDL/localize/langpack_edit/Makefile b/oversampling/WDL/localize/langpack_edit/Makefile deleted file mode 100644 index a2558f4..0000000 --- a/oversampling/WDL/localize/langpack_edit/Makefile +++ /dev/null @@ -1,110 +0,0 @@ -APPNAME=langpack_edit - -WDL_PATH = ../.. -vpath swell%.cpp $(WDL_PATH)/swell -vpath lice%.cpp $(WDL_PATH)/lice -vpath %.c $(WDL_PATH) -vpath %.cpp $(WDL_PATH) $(WDL_PATH)/wingui $(WDL_PATH)/localize - -###### Objects and resources (probably too many) -SWELL_OBJS = swell.o swell-ini.o swell-miscdlg-generic.o swell-wnd-generic.o \ - swell-menu-generic.o swell-kb-generic.o swell-dlg-generic.o \ - swell-gdi-generic.o swell-misc-generic.o swell-gdi-lice.o \ - swell-generic-gdk.o swell-appstub-generic.o swell-modstub-generic.o - -LICE_OBJS = lice_image.o lice_arc.o lice_line.o lice_text.o \ - lice_textnew.o lice.o lice_colorspace.o - -OTHER_OBJS = wndsize.o localize.o filebrowse.o - -RESFILES = res.rc_mac_dlg res.rc_mac_menu - -OBJS += langpack_edit.o $(SWELL_OBJS) $(OTHER_OBJS) - - -###### Compiler/Linker flags -CFLAGS += -pipe -fvisibility=hidden -fno-math-errno -fPIC -DPIC -Wall -Wshadow -Wtype-limits \ - -Wno-unused-function -Wno-multichar -Wno-unused-result - -CFLAGS += -D_FILE_OFFSET_BITS=64 - -ARCH := $(shell uname -m) -PKG_CONFIG = pkg-config - -ifndef ALLOW_WARNINGS - CFLAGS += -Werror -endif -ifndef DEPRECATED_WARNINGS - CFLAGS += -Wno-deprecated-declarations -endif - -ifeq ($(ARCH),arm64) - CFLAGS += -fsigned-char -else - ifneq ($(filter arm%,$(ARCH)),) - CFLAGS += -fsigned-char -mfpu=vfp -march=armv6t2 -marm - endif - ifeq ($(ARCH),aarch64) - CFLAGS += -fsigned-char - endif -endif - - -ifndef RELEASE - CFLAGS += -O0 -g -D_DEBUG -DWDL_CHECK_FOR_NON_UTF8_FOPEN -else - CFLAGS += -O2 -DNDEBUG -endif - -LINKEXTRA = -lpthread -ldl - -ifndef NOGDK - ifdef GDK2 - CFLAGS += -DSWELL_TARGET_GDK=2 $(shell $(PKG_CONFIG) --cflags gdk-2.0) - LINKEXTRA += $(shell $(PKG_CONFIG) --libs gdk-2.0) - LINKEXTRA += -lX11 -lXi - else - ifdef SWELL_SUPPORT_GTK - CFLAGS += -DSWELL_TARGET_GDK=3 $(shell $(PKG_CONFIG) --cflags gtk+-3.0) -DSWELL_SUPPORT_GTK - else - CFLAGS += -DSWELL_TARGET_GDK=3 $(shell $(PKG_CONFIG) --cflags gdk-3.0) - endif - LINKEXTRA += -lX11 -lXi -lGL - ifdef SWELL_SUPPORT_GTK - LINKEXTRA += $(shell $(PKG_CONFIG) --libs gtk+-3.0) - else - LINKEXTRA += $(shell $(PKG_CONFIG) --libs gdk-3.0) - endif - endif - CFLAGS += -DSWELL_LICE_GDI - OBJS += $(LICE_OBJS) - - ifndef NOFREETYPE - CFLAGS += -DSWELL_FREETYPE $(shell $(PKG_CONFIG) --cflags freetype2) - LINKEXTRA += $(shell $(PKG_CONFIG) --libs freetype2) - ifndef NOFONTCONFIG - CFLAGS += -DSWELL_FONTCONFIG - LINKEXTRA += -lfontconfig - endif - endif -endif - - -CXXFLAGS = $(CFLAGS) - - -default: $(APPNAME) - -.PHONY: clean run - -$(RESFILES): res.rc - $(WDL_PATH)/swell/swell_resgen.pl $^ - -$(APPNAME): $(RESFILES) $(OBJS) - $(CXX) -o $@ $(CFLAGS) $(OBJS) $(LINKEXTRA) - -run: $(APPNAME) - ./$^ - -clean: - -rm $(OBJS) $(APPNAME) $(RESFILES) diff --git a/oversampling/WDL/localize/langpack_edit/Resources/main.png b/oversampling/WDL/localize/langpack_edit/Resources/main.png deleted file mode 100644 index a0d791c..0000000 Binary files a/oversampling/WDL/localize/langpack_edit/Resources/main.png and /dev/null differ diff --git a/oversampling/WDL/localize/langpack_edit/en.lproj/Credits.rtf b/oversampling/WDL/localize/langpack_edit/en.lproj/Credits.rtf deleted file mode 100644 index 33bd334..0000000 --- a/oversampling/WDL/localize/langpack_edit/en.lproj/Credits.rtf +++ /dev/null @@ -1,7 +0,0 @@ -{\rtf1\ansi\ansicpg1252\cocoartf1265 -{\fonttbl\f0\fswiss\fcharset0 Helvetica;} -{\colortbl;\red255\green255\blue255;} -\vieww9600\viewh8400\viewkind0 -\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720 - -\f0\b\fs24 \cf0 This is it, word.} \ No newline at end of file diff --git a/oversampling/WDL/localize/langpack_edit/en.lproj/InfoPlist.strings b/oversampling/WDL/localize/langpack_edit/en.lproj/InfoPlist.strings deleted file mode 100644 index 477b28f..0000000 --- a/oversampling/WDL/localize/langpack_edit/en.lproj/InfoPlist.strings +++ /dev/null @@ -1,2 +0,0 @@ -/* Localized versions of Info.plist keys */ - diff --git a/oversampling/WDL/localize/langpack_edit/icon1.ico b/oversampling/WDL/localize/langpack_edit/icon1.ico deleted file mode 100644 index 09660b3..0000000 Binary files a/oversampling/WDL/localize/langpack_edit/icon1.ico and /dev/null differ diff --git a/oversampling/WDL/localize/langpack_edit/langpack_edit.cpp b/oversampling/WDL/localize/langpack_edit/langpack_edit.cpp deleted file mode 100644 index 5fe284b..0000000 --- a/oversampling/WDL/localize/langpack_edit/langpack_edit.cpp +++ /dev/null @@ -1,1106 +0,0 @@ -/* - LangPackEdit - Copyright (C) 2022 Cockos Inc - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef _WIN32 -#include -#include -#endif - -#include "../../swell/swell.h" - -#include "../../win32_utf8.h" -#include "../../wingui/wndsize.h" -#include "../../filebrowse.h" -#include "../../wdlstring.h" - -#include "../../assocarray.h" - -#include "../../localize/localize.h" -#include "../../lineparse.h" -#include "../../has_strings.h" - -#include "resource.h" - -#if !defined(_WIN32) && !defined(__APPLE__) -bool g_quit; -#endif - -HINSTANCE g_hInstance; -WDL_FastString g_ini_file; - -enum { - COL_STATE=0, - COL_ID, - COL_ROW_IDX, - COL_TEMPLATE, - COL_LOCALIZED, - COL_COMMON_LOCALIZED, - COL_MAX, -}; - - -struct pack_rec { - char *template_str, *pack_str; - - char *key_desc; // key name + comments - - int common_idx; - - static void freeptrs(pack_rec r) - { - free(r.key_desc); - free(r.template_str); - free(r.pack_str); - } -}; - -struct editor_instance { - editor_instance() : m_recs(false, pack_rec::freeptrs), m_hwnd(NULL), m_dirty(false) { } - ~editor_instance() { } - - WDL_FastString m_pack_fn; - - WDL_StringKeyedArray2 m_recs; - WDL_TypedBuf m_display_order; - - HWND m_hwnd; - bool m_dirty; - - WDL_WndSizer m_resize; - - void load_file(const char *filename, bool is_template); - void save_file(const char *filename); - - void cull_recs(); - void refresh_list(bool refilter=true); - - const char *get_rec_value(const pack_rec *r, const char *k, int w) const - { - __LOCALIZE_LCACHE("(empty)","langpackedit",empt); - switch (w) - { - case COL_STATE: - { - if (!r->template_str) - { - if (strstr(k,":5CA1E00000000000")) return ""; - __LOCALIZE_LCACHE("not-in-template","langpackedit",nit); - return nit; - } - if (r->pack_str) return ""; - if (r->common_idx>=0) - { - const char *k2; - pack_rec *r2 = m_recs.EnumeratePtr(r->common_idx,&k2); - if (WDL_NORMALLY(r2 && k2)) - { - WDL_ASSERT(!strcmp(strstr(k2,":"),strstr(k,":"))); - __LOCALIZE_LCACHE("localized-in-common","langpackedit",lic); - __LOCALIZE_LCACHE("common-not-localized","langpackedit",cnl); - if (r2->pack_str) return lic; - return cnl; - } - } - return "not-localized"; - } - case COL_ID: return r->key_desc ? r->key_desc : k; - case COL_TEMPLATE: return r->template_str; - case COL_LOCALIZED: return r->pack_str == NULL ? "" : r->pack_str[0] ? r->pack_str : empt; - case COL_COMMON_LOCALIZED: - if (r->common_idx>=0) - { - const char *k2; - pack_rec *r2 = m_recs.EnumeratePtr(r->common_idx,&k2); - if (WDL_NORMALLY(r2 && k2)) - { - WDL_ASSERT(!strcmp(strstr(k2,":"),strstr(k,":"))); - return r2->pack_str == NULL ? "" : r2->pack_str[0] ? r2->pack_str : empt; - } - } - break; - - } - return NULL; - } - - const char *get_row_value(int row, int w) const - { - if (row < 0 || row >= m_display_order.GetSize()) return ""; - const char *k; - pack_rec *r = m_recs.EnumeratePtr(m_display_order.Get()[row],&k); - if (!r || !k) return ""; - const char *rv = get_rec_value(r,k,w); - return rv ? rv : ""; - } - - bool edit_row(int rec_idx, int other_action=IDC_LOCALIZED_STRING); - bool on_key(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - void item_context_menu(); - - void set_dirty() - { - if (!m_dirty) - { - m_dirty=true; - set_caption(); - } - } - void set_caption() - { - if (m_hwnd) - { - char tmp[512]; - snprintf(tmp,sizeof(tmp),"%s%sLangPackEdit%s", - m_pack_fn.get_filepart(),m_pack_fn.GetLength() ? " - ": "",m_dirty ? __LOCALIZE(" (unsaved)","langpackedit") :""); - SetWindowText(m_hwnd,tmp); - } - } - bool prompt_exit() - { - if (m_dirty) - { - int a = MessageBox(m_hwnd,__LOCALIZE("LangPack is not saved, save before exiting?","langpackedit"), - __LOCALIZE("Unsaved","langpackedit"),MB_YESNOCANCEL); - if (a == IDCANCEL) return false; - if (a == IDNO) m_dirty = false; - else SendMessage(m_hwnd,WM_COMMAND,IDC_PACK_SAVE,0); - } - return !m_dirty; - } -}; - -static void del_array(WDL_AssocArray *d) { delete d; } - -static void format_section_id(char *buf, size_t bufsz, const char *section, WDL_UINT64 id) -{ - snprintf(buf,bufsz,"%s:%08X%08X",section, (int)(id>>32),(int)(id&0xffffffff)); -} - -static const char *parse_section_id(const char *k, char *buf, int bufsz) // returns ID or NULL -{ - if (buf) lstrcpyn_safe(buf, k, bufsz); - - char *base = buf ? buf : (char*)k, *p = base; - while (*p) p++; - while (p > base && *p != ':') p--; - if (WDL_NOT_NORMALLY(p==base)) return NULL; - if (buf) *p=0; - return p+1; -} - -void editor_instance::save_file(const char *filename) -{ - FILE *fp = fopen(filename,"wb"); - if (!fp) - { - MessageBox(m_hwnd,__LOCALIZE("Error opening file for writing","langpackedit"), - __LOCALIZE("Error","langpackedit"),MB_OK); - return; - } - char buf[32768]; - buf[0]=0; - if (WDL_NORMALLY(m_hwnd)) - GetDlgItemText(m_hwnd,IDC_COMMENTS,buf,sizeof(buf)); - WDL_remove_trailing_whitespace(buf); - fprintf(fp,"%s\r\n",buf); - - char last_sec[1024]; - last_sec[0]=0; - - for (int x = 0; x < m_recs.GetSize(); x ++) - { - const char *k; - const pack_rec *rec = m_recs.EnumeratePtr(x,&k); - if (!rec->pack_str) continue; - - char sec[256]; - const char *id = parse_section_id(k,sec,sizeof(sec)); - if (WDL_NORMALLY(id)) - { - if (stricmp(last_sec,sec)) - { - lstrcpyn_safe(last_sec,sec,sizeof(last_sec)); - const char *trail = ""; - if (rec->key_desc) - { - trail = strstr(rec->key_desc," "); - trail = trail ? (trail+1) : ""; - } - fprintf(fp,"\r\n[%s]%s\r\n",sec,trail); - } - fprintf(fp,"%s=%s\r\n",id,rec->pack_str); - } - } - fclose(fp); -} - -void editor_instance::load_file(const char *filename, bool is_template) -{ - for (int x = 0; x < m_recs.GetSize(); x ++) - { - pack_rec *r = m_recs.EnumeratePtr(x); - if (is_template) - { - free(r->template_str); - r->template_str = NULL; - } - else - { - free(r->pack_str); - r->pack_str = NULL; - } - } - - WDL_StringKeyedArray extra(false, WDL_StringKeyedArray::freecharptr); - if (*filename) - { - WDL_StringKeyedArray< WDL_AssocArray * > r(false,del_array); - WDL_LoadLanguagePackInternal(filename,&r,NULL, is_template, true, &extra); - - for (int si = 0; si < r.GetSize(); si ++) - { - const char *sec_name; - WDL_AssocArray *sec = r.Enumerate(si,&sec_name); - for (int i = 0; i < sec->GetSize(); i ++) - { - WDL_UINT64 id; - const char *value = sec->Enumerate(i,&id); - if (WDL_NOT_NORMALLY(!value)) break; - - char rec_buf[256], key_desc[256]; - format_section_id(rec_buf,sizeof(rec_buf),sec_name, id); - - { - const char *p = extra.Get(sec_name); - if (p) - snprintf(key_desc,sizeof(key_desc),"%.100s %s",rec_buf,p); - else - key_desc[0]=0; - } - - pack_rec *rec = m_recs.GetPtr(rec_buf); - if (!rec) - { - pack_rec newr = { 0 }; - if (is_template) newr.template_str = strdup(value); - else newr.pack_str = strdup(value); - - if (key_desc[0]) newr.key_desc = strdup(key_desc); - m_recs.Insert(rec_buf,newr); - } - else - { - if (is_template || key_desc[0]) - { - free(rec->key_desc); - rec->key_desc = key_desc[0] ? strdup(key_desc) : NULL; - } - if (is_template) - { - free(rec->template_str); - rec->template_str = strdup(value); - } - else - { - free(rec->pack_str); - rec->pack_str = strdup(value); - } - } - } - } - } - cull_recs(); - refresh_list(); - - if (m_hwnd) - { - SetDlgItemText(m_hwnd,is_template ? IDC_TEMPLATE : IDC_PACK, *filename ? filename : __LOCALIZE("(none)","langpackedit")); - - if (!is_template) - { - WDL_FastString fs; - for (int x=0; ; x++) - { - char tmp[512]; - snprintf(tmp,sizeof(tmp),"_initial_comment_%d",x); - const char *p = extra.Get(tmp); - if (!p) break; - if (fs.GetLength()) fs.Append("\r\n"); - fs.Append(p); - } - if (fs.GetLength()) - WDL_remove_trailing_whitespace((char *)fs.Get()); - SetDlgItemText(m_hwnd,IDC_COMMENTS,fs.Get()); - } - } -} - -void editor_instance::cull_recs() -{ - for (int x = 0; x < m_recs.GetSize(); x ++) - { - pack_rec *r = m_recs.EnumeratePtr(x); - if (!r->template_str && !r->pack_str) - m_recs.DeleteByIndex(x--); - } -} - -void editor_instance::refresh_list(bool refilter) -{ - int *p, cnt; - if (refilter) - { - p = m_display_order.Resize(m_recs.GetSize()); - cnt = 0; - } - else - { - p = m_display_order.Get(); - cnt = m_display_order.GetSize(); - } - - if (m_recs.GetSize() && WDL_NORMALLY(p)) - { - LineParser lp; - if (refilter && m_hwnd) - { - char filter[512]; - GetDlgItemText(m_hwnd,IDC_FILTER,filter,sizeof(filter)); - WDL_makeSearchFilter(filter, &lp); - } - const bool do_filt = lp.getnumtokens()>0; - for (int x = 0; x < m_recs.GetSize(); x ++) - { - const char *k = NULL; - pack_rec *r = m_recs.EnumeratePtr(x,&k); - if (WDL_NOT_NORMALLY(!r)) break; - - if (strnicmp(k,"common:",7)) - { - const char *sid = parse_section_id(k,NULL,0); - if (WDL_NORMALLY(sid)) - { - char tmp[256]; - snprintf(tmp,sizeof(tmp),"common:%s",sid); - r->common_idx = m_recs.GetIdx(tmp); - } - } - else - r->common_idx = -1; - - if (refilter) - { - const char *strs[COL_MAX]; - int nc = 0; - if (do_filt) - { - for (int c =0; c < COL_MAX; c ++) - { - const char *v = get_rec_value(r,k,c); - if (v) strs[nc++] = v; - } - } - - if (!do_filt || WDL_hasStringsEx2(strs,nc,&lp,NULL)) - p[cnt++] = x; - } - } - } - - m_display_order.Resize(cnt,false); - if (m_hwnd) - { - HWND list = GetDlgItem(m_hwnd,IDC_LIST); - ListView_SetItemCount(list,cnt); - ListView_RedrawItems(list,0,cnt); - } -} - -WDL_DLGRET editorProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch (uMsg) - { - case WM_INITDIALOG: - SetWindowLongPtr(hwndDlg,GWLP_USERDATA,lParam); - { - void **p = (void **)lParam; - editor_instance *edit = (editor_instance *)p[0]; - int item = (int) (INT_PTR) p[1]; - const char *k; - pack_rec *rec = edit->m_recs.EnumeratePtr(item,&k); - if (WDL_NORMALLY(rec)) - { - char tmp[512]; - snprintf(tmp,sizeof(tmp),__LOCALIZE_VERFMT("Localize: %s","langpackedit"),k); - SetWindowText(hwndDlg,tmp); - - if (rec->template_str) - SetDlgItemText(hwndDlg,IDC_TEMPLATE_STRING,rec->template_str); - - const char *common_str = NULL; - if (rec->common_idx>=0) - { - const char *k2; - pack_rec *r2 = edit->m_recs.EnumeratePtr(rec->common_idx,&k2); - if (WDL_NORMALLY(r2 && k2)) - { - WDL_ASSERT(!strcmp(strstr(k2,":"),strstr(k,":"))); - SetDlgItemText(hwndDlg,IDC_COMMON_STRING,r2->pack_str ? r2->pack_str : __LOCALIZE("(not yet localized)","langpackedit")); - common_str = r2->pack_str; - } - } - else if (!strnicmp(k,"common:",7)) - { - ShowWindow(GetDlgItem(hwndDlg,IDC_COMMON_LABEL),SW_HIDE); - ShowWindow(GetDlgItem(hwndDlg,IDC_COMMON_STRING),SW_HIDE); - } - else - SetDlgItemText(hwndDlg,IDC_COMMON_STRING,__LOCALIZE("(not in [common])","langpackedit")); - - if (rec->pack_str || rec->template_str) - SetDlgItemText(hwndDlg,IDC_LOCALIZED_STRING,rec->pack_str ? rec->pack_str : - common_str ? common_str : rec->template_str); - } - } - return 0; - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDC_REMOVE_LOCALIZATION: - case IDC_COPY_TEMPLATE: - case IDOK: - { - void **p = (void **)GetWindowLongPtr(hwndDlg,GWLP_USERDATA); - editor_instance *edit = (editor_instance *)p[0]; - int item = (int) (INT_PTR) p[1]; - const char *k; - pack_rec *rec = edit->m_recs.EnumeratePtr(item,&k); - if (WDL_NORMALLY(rec)) - { - if (LOWORD(wParam) == IDOK) - { - char buf[32768]; - GetDlgItemText(hwndDlg,IDC_LOCALIZED_STRING,buf,sizeof(buf)); - free(rec->pack_str); - rec->pack_str = strdup(buf); - } - else - { - free(rec->pack_str); - rec->pack_str = LOWORD(wParam) == IDC_COPY_TEMPLATE && rec->template_str ? - strdup(rec->template_str) : NULL; - } - } - } - EndDialog(hwndDlg,1); - break; - case IDCANCEL: - EndDialog(hwndDlg,0); - break; - } - break; - } - return 0; -} - -bool editor_instance::edit_row(int row, int other_action) -{ - if (row < 0 || row >= m_display_order.GetSize()) return false; - int rec_idx = m_display_order.Get()[row]; - - WDL_ASSERT(rec_idx>=0 && rec_idx < m_recs.GetSize()); - - if (other_action && other_action != IDC_LOCALIZED_STRING) - { - const char *k; - pack_rec *r = m_recs.EnumeratePtr(rec_idx,&k); - if (WDL_NORMALLY(r)) - { - switch (other_action) - { - case IDC_COMMON_STRING: - if (r->common_idx>=0 && r->common_idx < m_recs.GetSize()) - rec_idx = r->common_idx; - break; - case IDC_REMOVE_NONLOCALIZATION: - if (r->pack_str) - { - if (!r->template_str) return false; - if (strcmp(r->template_str,r->pack_str)) return false; - } - // fall through - case IDC_REMOVE_LOCALIZATION: - case IDC_COPY_TEMPLATE: - if (other_action == IDC_COPY_TEMPLATE && r->pack_str) return false; // do not modify already-localized strings - - free(r->pack_str); - r->pack_str = other_action == IDC_COPY_TEMPLATE && r->template_str ? strdup(r->template_str) : NULL; - return true; - case ID_SCALING_ADD: - { - char sec[256]; - if (WDL_NORMALLY(parse_section_id(k,sec,sizeof(sec)))) - { - lstrcatn(sec,":5CA1E00000000000",sizeof(sec)); - if (!m_recs.GetPtr(sec)) - { - pack_rec newr = { 0 }; - m_recs.Insert(sec,newr); - int idx = m_recs.GetIdx(sec); - if (WDL_NORMALLY(idx>=0)) - { - // added a rec, adjust indices and stick us at the end - for (int x = 0; x < m_display_order.GetSize(); x ++) - { - if (m_display_order.Get()[x] >= idx) - m_display_order.Get()[x]++; - } - m_display_order.Add(idx); - return true; - } - - } - } - } - return false; - } - } - } - - void *p[2] = { this, (void *)(INT_PTR) rec_idx }; - if (DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_RENAME), m_hwnd, editorProc, (LPARAM)p)) - { - refresh_list(false); - set_dirty(); - return true; - } - return false; -} - - -bool editor_instance::on_key(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - if (!m_hwnd || (hwnd != m_hwnd && !IsChild(m_hwnd,hwnd))) - return false; - -#ifndef __APPLE__ - if (msg == WM_KEYDOWN && (wParam=='S' || wParam == 'O' || wParam == 'T')) - { - bool shift = !!(GetAsyncKeyState(VK_SHIFT)&0x8000); - bool ctrl = !!(GetAsyncKeyState(VK_CONTROL)&0x8000); - if (!shift && ctrl) - { - bool alt = !!(GetAsyncKeyState(VK_MENU)&0x8000); - int cmd = 0; - if (wParam == 'S' && ctrl) cmd = alt ? IDC_PACK_SAVE_AS : IDC_PACK_SAVE; - else if (wParam == 'O') cmd = IDC_PACK_LOAD; - else if (wParam == 'T') cmd = IDC_TEMPLATE_LOAD; - - if (cmd) - { - SendMessage(m_hwnd,WM_COMMAND,cmd,0); - return 1; - } - } - } -#endif - - HWND hlist = GetDlgItem(m_hwnd,IDC_LIST); - if (hwnd == hlist || IsChild(hlist,hwnd)) - { - if (msg == WM_KEYDOWN) switch (wParam) - { - case VK_RETURN: - SendMessage(m_hwnd,WM_COMMAND,IDC_LOCALIZED_STRING,0); - return true; - break; -#ifdef _WIN32 - case VK_APPS: - item_context_menu(); - return true; -#endif - case VK_BACK: - case VK_DELETE: - SendMessage(m_hwnd,WM_COMMAND,IDC_REMOVE_LOCALIZATION,0); - return true; - } - } - return false; -} - -void editor_instance::item_context_menu() -{ - HMENU menu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_CONTEXTMENU)); - POINT p; - GetCursorPos(&p); - TrackPopupMenu(GetSubMenu(menu,0),0,p.x,p.y,0,m_hwnd,NULL); - DestroyMenu(menu); -} - -const char *COL_DESCS[COL_MAX] = { - // !WANT_LOCALIZE_STRINGS_BEGIN:langpackedit - "State", - "ID", - "Row", - "Template", - "Localized", - "Common Localized", - // !WANT_LOCALIZE_STRINGS_END -}; - -int COL_SIZES[COL_MAX] = { - 120, - 120, - 30, - 240, - 240, - 240, -}; - -editor_instance g_editor; -WDL_DLGRET mainProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - enum { - TIMER_FILTER=1 - }; - switch (uMsg) - { - case WM_INITDIALOG: - g_editor.m_hwnd = hwndDlg; -#ifdef _WIN32 - { - HICON icon=LoadIcon(g_hInstance,MAKEINTRESOURCE(IDI_ICON1)); - SetClassLongPtr(hwndDlg,GCLP_HICON,(LPARAM)icon); - } -#endif - - g_editor.m_resize.init(hwndDlg); - g_editor.m_resize.init_item(IDC_FILTER,0,0,1,0); - g_editor.m_resize.init_item(IDC_TEMPLATE,0,0,1,0); - g_editor.m_resize.init_item(IDC_PACK,0,0,1,0); - g_editor.m_resize.init_item(IDC_COMMENTS,0,0,1,0); - g_editor.m_resize.init_item(IDC_LIST,0,0,1,1); - - { - HWND hlist = GetDlgItem(hwndDlg, IDC_LIST); - - int s=LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES; -#ifdef _WIN32 - s|=LVS_EX_DOUBLEBUFFER; -#endif - ListView_SetExtendedListViewStyleEx(hlist, s,s ); - -#ifdef _WIN32 - WDL_UTF8_HookListView(hlist); - SendMessage(hlist,LVM_SETUNICODEFORMAT,1,0); -#endif - for (int x = 0; x < COL_MAX; x ++) - { - LVCOLUMN lvc = { LVCF_TEXT|LVCF_WIDTH, 0, COL_SIZES[x], (char*)__localizeFunc(COL_DESCS[x],"langpackedit",LOCALIZE_FLAG_NOCACHE) }; - ListView_InsertColumn(hlist, x, &lvc); - } - } - - { - char buf[2048]; - GetPrivateProfileString("LangPackEdit","template","",buf,sizeof(buf),g_ini_file.Get()); - g_editor.load_file(buf,true); - - GetPrivateProfileString("LangPackEdit","lastpack","",buf,sizeof(buf),g_ini_file.Get()); - g_editor.load_file(buf,false); - g_editor.m_pack_fn.Set(buf); - g_editor.set_caption(); - } - return 1; - case WM_DESTROY: - g_editor.m_hwnd = NULL; -#ifdef __APPLE__ - SWELL_PostQuitMessage(0); -#elif defined(_WIN32) - PostQuitMessage(0); -#else - g_quit = true; -#endif - break; - case WM_SIZE: - if (wParam != SIZE_MINIMIZED) - g_editor.m_resize.onResize(); - break; - case WM_TIMER: - switch (wParam) - { - case TIMER_FILTER: - KillTimer(hwndDlg,TIMER_FILTER); - g_editor.refresh_list(); - break; - } - break; - case WM_CLOSE: - if (g_editor.prompt_exit()) - DestroyWindow(hwndDlg); - break; - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case ID_QUIT: - if (g_editor.prompt_exit()) - DestroyWindow(hwndDlg); - break; - case IDC_FILTER: - if (HIWORD(wParam) == EN_CHANGE) - { - SetTimer(hwndDlg,TIMER_FILTER,100,NULL); - } - break; - case IDC_PACK_SAVE_AS: - case IDC_PACK_SAVE: - - if (!g_editor.m_pack_fn.GetLength() || LOWORD(wParam) == IDC_PACK_SAVE_AS) - { - char newfn[2048]; - if (!WDL_ChooseFileForSave(hwndDlg, __LOCALIZE("Save LangPack as...","langpackedit"), - NULL, - g_editor.m_pack_fn.Get(), - "All files (*.*)\0*.*\0", - "", - false, - newfn,sizeof(newfn)) || !newfn[0]) return 0; - - g_editor.m_pack_fn.Set(newfn); - WritePrivateProfileString("LangPackEdit","lastpack",newfn,g_ini_file.Get()); - SetDlgItemText(hwndDlg,IDC_PACK,newfn); - } - - g_editor.save_file(g_editor.m_pack_fn.Get()); - g_editor.m_dirty=false; - g_editor.set_caption(); - break; - - case IDC_PACK_LOAD: - case IDC_TEMPLATE_LOAD: - { - char buf[2048]; - const bool is_template = LOWORD(wParam) == IDC_TEMPLATE_LOAD; - const char *inikey = is_template ? "template" : "lastpack"; - GetPrivateProfileString("LangPackEdit",inikey,"",buf,sizeof(buf),g_ini_file.Get()); - char *f = WDL_ChooseFileForOpen(hwndDlg, - is_template ? __LOCALIZE("Choose LangPack Template","langpackedit") : - __LOCALIZE("Load LangPack","langpackedit"), - NULL, - buf, - "All files (*.*)\0*.*\0" - , - "", - false, false); - if (f) - { - WritePrivateProfileString("LangPackEdit",inikey,f,g_ini_file.Get()); - g_editor.load_file(f,is_template); - if (!is_template) g_editor.m_pack_fn.Set(f); - free(f); - if (!is_template) - { - g_editor.m_dirty=false; - g_editor.set_caption(); - } - } - } - break; - case IDC_LOCALIZED_STRING: - case IDC_COMMON_STRING: - case ID_SCALING_ADD: - case IDC_COPY_TEMPLATE: - case IDC_REMOVE_LOCALIZATION: - case IDC_REMOVE_NONLOCALIZATION: - { - HWND list = GetDlgItem(hwndDlg,IDC_LIST); - int cnt = 0; - const int n = ListView_GetItemCount(list); - for (int x = 0; x < n; x ++) - { - if (ListView_GetItemState(list,x,LVIS_SELECTED) & LVIS_SELECTED) - { - if (g_editor.edit_row(x,(int)wParam)) cnt++; - if (wParam == ID_SCALING_ADD) - ListView_SetItemState(list,x,0,LVIS_SELECTED); - } - } - if (cnt && wParam != IDC_LOCALIZED_STRING) - { - g_editor.refresh_list(false); - g_editor.set_dirty(); - } - if (wParam == ID_SCALING_ADD) - { - const int nn = ListView_GetItemCount(list); - if (n < nn) - { - ListView_EnsureVisible(list,n,false); - for (int i = n; i < nn; i ++) - ListView_SetItemState(list,i,LVIS_SELECTED,LVIS_SELECTED); - } - } - } - break; - } - break; - case WM_INITMENUPOPUP: - if (wParam) - { - HMENU menu = (HMENU) wParam; - static const unsigned short tab[]={ - IDC_LOCALIZED_STRING, - IDC_COMMON_STRING, - ID_SCALING_ADD, - IDC_COPY_TEMPLATE, - IDC_REMOVE_LOCALIZATION, - IDC_REMOVE_NONLOCALIZATION, - }; - bool en = ListView_GetSelectedCount(GetDlgItem(hwndDlg,IDC_LIST))>0; - for (size_t x = 0; x < sizeof(tab)/sizeof(tab[0]); x ++) - EnableMenuItem(menu,tab[x],MF_BYCOMMAND|(en ? 0 : MF_GRAYED)); - } - break; - case WM_NOTIFY: - { - NMLISTVIEW* lv = (NMLISTVIEW*)lParam; - if (lv->hdr.idFrom == IDC_LIST) switch (lv->hdr.code) - { - case NM_DBLCLK: - g_editor.edit_row(lv->iItem); - return 0; - case NM_RCLICK: - if (ListView_GetSelectedCount(lv->hdr.hwndFrom)>0) - { - g_editor.item_context_menu(); - } - return 0; - case LVN_GETDISPINFO: -#ifdef _WIN32 - case LVN_GETDISPINFOW: -#endif - { - NMLVDISPINFO *lpdi = (NMLVDISPINFO*) lParam; - if (lpdi->item.mask & LVIF_TEXT) - { - if (lpdi->item.iSubItem == COL_ROW_IDX) - snprintf(lpdi->item.pszText,lpdi->item.cchTextMax,"%d",lpdi->item.iItem+1); - else - lpdi->item.pszText = (char*) g_editor.get_row_value(lpdi->item.iItem, lpdi->item.iSubItem); -#ifdef _WIN32 - if (lv->hdr.code == LVN_GETDISPINFOW) - WDL_UTF8_ListViewConvertDispInfoToW(lpdi); -#endif - } - } - } - } - break; - } - return 0; -} - -INT_PTR SWELLAppMain(int msg, INT_PTR parm1, INT_PTR parm2) -{ - switch (msg) - { - case SWELLAPP_ONLOAD: - { - } - break; - case SWELLAPP_LOADED: - { - char buf[2048]; - GetModuleFileName(NULL,buf,sizeof(buf)); - WDL_remove_filepart(buf); - lstrcatn(buf,WDL_DIRCHAR_STR "LangPackEdit.ini",sizeof(buf)); - g_ini_file.Set(buf); - - WDL_remove_filepart(buf); - lstrcatn(buf,WDL_DIRCHAR_STR "LangPackEdit.LangPack",sizeof(buf)); - -#ifdef _DEBUG - extern bool g_debug_langpack_has_loaded; - g_debug_langpack_has_loaded=true; -#endif - WDL_LoadLanguagePack(buf,NULL); - - HWND h=CreateDialog(NULL,MAKEINTRESOURCE(IDD_DIALOG1),NULL,mainProc); - ShowWindow(h,SW_SHOW); - -#ifndef _WIN32 - { - HMENU menu = LoadMenu(NULL,MAKEINTRESOURCE(IDR_MENU1)); -#ifdef __APPLE__ - { - HMENU sm=GetSubMenu(menu,0); - DeleteMenu(sm,ID_QUIT,MF_BYCOMMAND); // remove QUIT from our file menu, since it is in the system menu on OSX - - // remove any trailing separators - int a= GetMenuItemCount(sm); - while (a > 0 && GetMenuItemID(sm,a-1)==0) DeleteMenu(sm,--a,MF_BYPOSITION); - } - - extern HMENU SWELL_app_stocksysmenu; - if (SWELL_app_stocksysmenu) // insert the stock system menu - { - HMENU nm=SWELL_DuplicateMenu(SWELL_app_stocksysmenu); - if (nm) - { - MENUITEMINFO mi={sizeof(mi),MIIM_STATE|MIIM_SUBMENU|MIIM_TYPE,MFT_STRING,0,0,nm,NULL,NULL,0,(char*)"LangPackEdit"}; - InsertMenuItem(menu,0,TRUE,&mi); - } - } - SetMenuItemModifier(menu,IDC_TEMPLATE_LOAD,MF_BYCOMMAND,'T',FCONTROL); - SetMenuItemModifier(menu,IDC_PACK_LOAD,MF_BYCOMMAND,'O',FCONTROL); - SetMenuItemModifier(menu,IDC_PACK_SAVE,MF_BYCOMMAND,'S',FCONTROL); - SetMenuItemModifier(menu,IDC_PACK_SAVE_AS,MF_BYCOMMAND,'S',FCONTROL|FALT); -#endif - - SetMenu(h,menu); - } -#endif - - } - break; - case SWELLAPP_DESTROY: - if (g_editor.m_hwnd) DestroyWindow(g_editor.m_hwnd); - break; - case SWELLAPP_SHOULDDESTROY: - return g_editor.prompt_exit() ? 0 : 1; - case SWELLAPP_ONCOMMAND: - if (g_editor.m_hwnd) - SendMessage(g_editor.m_hwnd,WM_COMMAND,parm1,0); - return 0; - case SWELLAPP_PROCESSMESSAGE: - if (parm1) - { - const MSG *m = (MSG *)parm1; - if (m->message == WM_KEYDOWN && m->hwnd) - { -#ifndef __APPLE__ - if (m->wParam == 'Q' && - (GetAsyncKeyState(VK_CONTROL)&0x8000) && - !(GetAsyncKeyState(VK_SHIFT)&0x8000) && - !(GetAsyncKeyState(VK_MENU)&0x8000)) - { - if (g_editor.m_hwnd) - SendMessage(g_editor.m_hwnd,WM_COMMAND,ID_QUIT,0); - return 1; - } -#endif - if (g_editor.on_key(m->hwnd, m->message, m->wParam, m->lParam)) - return 1; - } - } - return 0; - } - return 0; -} - - - -#ifdef _WIN32 - -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) -{ - g_hInstance = hInstance; - - SWELLAppMain(SWELLAPP_ONLOAD,0,0); - SWELLAppMain(SWELLAPP_LOADED,0,0); - - for(;;) - { - MSG msg={0,}; - int vvv = GetMessage(&msg,NULL,0,0); - if (!vvv) break; - - if (vvv<0) - { - Sleep(10); - continue; - } - if (!msg.hwnd) - { - DispatchMessage(&msg); - continue; - } - if (SWELLAppMain(SWELLAPP_PROCESSMESSAGE, (INT_PTR) &msg, 0)) continue; - - if (g_editor.m_hwnd && IsDialogMessage(g_editor.m_hwnd,&msg)) continue; - - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - SWELLAppMain(SWELLAPP_DESTROY,0,0); - - ExitProcess(0); - - return 0; -} - -#else - -/************** SWELL stuff ********** */ - -#ifdef __APPLE__ -extern "C" { -#endif - -const char **g_argv; -int g_argc; - -#ifdef __APPLE__ -}; -#endif - - -#ifndef __APPLE__ - -int main(int argc, const char **argv) -{ - g_argc=argc; - g_argv=argv; - SWELL_initargs(&argc,(char***)&argv); - SWELL_Internal_PostMessage_Init(); - SWELL_ExtendedAPI("APPNAME",(void*)"LangPackEdit"); - SWELLAppMain(SWELLAPP_ONLOAD,0,0); - SWELLAppMain(SWELLAPP_LOADED,0,0); - while (!g_quit) { - SWELL_RunMessageLoop(); - Sleep(10); - } - SWELLAppMain(SWELLAPP_DESTROY,0,0); - return 0; -} - -#endif - - -#include "../../swell/swell-dlggen.h" -#include "res.rc_mac_dlg" -#undef BEGIN -#undef END -#include "../../swell/swell-menugen.h" -#include "res.rc_mac_menu" - -#endif diff --git a/oversampling/WDL/localize/langpack_edit/main.m b/oversampling/WDL/localize/langpack_edit/main.m deleted file mode 100644 index 8737033..0000000 --- a/oversampling/WDL/localize/langpack_edit/main.m +++ /dev/null @@ -1,10 +0,0 @@ -#import - -int main(int argc, const char * argv[]) -{ - extern const char **g_argv; - extern int g_argc; - g_argc=argc; - g_argv=argv; - return NSApplicationMain(argc, argv); -} diff --git a/oversampling/WDL/localize/langpack_edit/res.rc b/oversampling/WDL/localize/langpack_edit/res.rc deleted file mode 100644 index 6c5afc0..0000000 --- a/oversampling/WDL/localize/langpack_edit/res.rc +++ /dev/null @@ -1,228 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_ICON1 ICON DISCARDABLE "icon1.ico" - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_DIALOG1 DIALOG DISCARDABLE 0, 0, 600, 400 -STYLE DS_CENTER | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | - WS_SYSMENU | WS_THICKFRAME -CAPTION "LangPackEdit" -MENU IDR_MENU1 -FONT 8, "MS Sans Serif" -BEGIN - LTEXT "Template:",IDC_TEMPLATE_LABEL,3,10,35,8 - EDITTEXT IDC_TEMPLATE,41,8,556,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Pack:",IDC_PACK_LABEL,3,26,35,8 - EDITTEXT IDC_PACK,41,24,556,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "Comments:",IDC_COMMENTS_LABEL,3,40,35,8 - EDITTEXT IDC_COMMENTS,41,40,556,37,ES_MULTILINE | ES_AUTOHSCROLL - LTEXT "Filter:",IDC_FILTERLBL,3,83,35,8,SS_NOTIFY - EDITTEXT IDC_FILTER,41,80,556,14,ES_AUTOHSCROLL - CONTROL "List1",IDC_LIST,"SysListView32",LVS_REPORT | - LVS_SHOWSELALWAYS | LVS_OWNERDATA | LVS_NOSORTHEADER | - WS_BORDER | WS_TABSTOP,3,97,594,300 -END - -IDD_RENAME DIALOG DISCARDABLE 0, 0, 400, 81 -STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Localize: " -FONT 8, "MS Shell Dlg" -BEGIN - LTEXT "Localized string:",IDC_STATIC,7,41,61,8 - EDITTEXT IDC_LOCALIZED_STRING,65,39,328,14,ES_AUTOHSCROLL - DEFPUSHBUTTON "OK",IDOK,118,61,44,14 - PUSHBUTTON "Cancel",IDCANCEL,167,61,44,14 - PUSHBUTTON "Remove Localization",IDC_REMOVE_LOCALIZATION,220,61,84, - 14 - PUSHBUTTON "Set to Template String",IDC_COPY_TEMPLATE,309,61,84,14 - LTEXT "Template string:",IDC_STATIC,7,9,61,8 - EDITTEXT IDC_TEMPLATE_STRING,65,7,328,14,ES_AUTOHSCROLL | - ES_READONLY - LTEXT "[common] string:",IDC_COMMON_LABEL,7,25,61,8 - EDITTEXT IDC_COMMON_STRING,65,23,328,14,ES_AUTOHSCROLL | - ES_READONLY -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDR_CONTEXTMENU MENU DISCARDABLE -BEGIN - POPUP "Context" - BEGIN - MENUITEM "Edit localization\tEnter", IDC_LOCALIZED_STRING - MENUITEM "Edit [common] localization", IDC_COMMON_STRING - MENUITEM "Add dialog scaling item for context", ID_SCALING_ADD - MENUITEM "Set localization to template value if not set (mark as localized)", - IDC_COPY_TEMPLATE - MENUITEM "Remove localization\tDelete", IDC_REMOVE_LOCALIZATION - MENUITEM "Remove localization from items that match template", - IDC_REMOVE_NONLOCALIZATION - END -END - -IDR_MENU1 MENU DISCARDABLE -BEGIN - POPUP "&File" - BEGIN - MENUITEM "Load &Template...\tCtrl+T", IDC_TEMPLATE_LOAD - MENUITEM "&Load Pack...\tCtrl+O", IDC_PACK_LOAD - MENUITEM "&Save Pack\tCtrl+S", IDC_PACK_SAVE - MENUITEM "Save Pack &As...\tCtrl+Alt+S", IDC_PACK_SAVE_AS - MENUITEM SEPARATOR - MENUITEM "&Quit\tCtrl+Q", ID_QUIT - END - POPUP "&Edit" - BEGIN - MENUITEM "Edit localization\tEnter", IDC_LOCALIZED_STRING - MENUITEM "Edit [common] localization", IDC_COMMON_STRING - MENUITEM "Add dialog scaling item for context", ID_SCALING_ADD - MENUITEM "Set localization to template value if not set (mark as localized)", - IDC_COPY_TEMPLATE - MENUITEM "Remove localization\tDelete", IDC_REMOVE_LOCALIZATION - MENUITEM "Remove localization from items that match template", - IDC_REMOVE_NONLOCALIZATION - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_DIALOG1, DIALOG - BEGIN - LEFTMARGIN, 4 - RIGHTMARGIN, 597 - TOPMARGIN, 3 - BOTTOMMARGIN, 258 - END -END -#endif // APSTUDIO_INVOKED - - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,0,0,1 - PRODUCTVERSION 0,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Comments", "\0" - VALUE "CompanyName", "unknown\0" - VALUE "FileDescription", "LangPackEdit\0" - VALUE "FileVersion", "0, 0, 0, 5\0" - VALUE "InternalName", "LangPackEdit\0" - VALUE "LegalCopyright", "Copyright � 2022 and onwards Cockos Inc\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "LangPackEdit.exe\0" - VALUE "PrivateBuild", "\0" - VALUE "ProductName", "LangPackEdit\0" - VALUE "ProductVersion", "0, 0, 0, 5\0" - VALUE "SpecialBuild", "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/oversampling/WDL/localize/langpack_edit/resource.h b/oversampling/WDL/localize/langpack_edit/resource.h deleted file mode 100644 index 13ed185..0000000 --- a/oversampling/WDL/localize/langpack_edit/resource.h +++ /dev/null @@ -1,42 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by res.rc -// -#define IDI_ICON1 101 -#define IDD_DIALOG1 102 -#define IDD_RENAME 103 -#define IDR_MENU1 103 -#define IDR_CONTEXTMENU 104 -#define IDC_LIST 1000 -#define IDC_FILTER 1001 -#define IDC_FILTERLBL 1002 -#define IDC_TEMPLATE 1003 -#define IDC_TEMPLATE_LOAD 1004 -#define IDC_TEMPLATE_LABEL 1005 -#define IDC_PACK 1006 -#define IDC_PACK_LOAD 1007 -#define IDC_PACK_LABEL 1008 -#define IDC_COMMENTS 1009 -#define IDC_COMMENTS_LABEL 1010 -#define IDC_PACK_SAVE 1011 -#define IDC_PACK_SAVE_AS 1012 -#define IDC_LOCALIZED_STRING 1013 -#define IDC_TEMPLATE_STRING 1014 -#define IDC_COMMON_STRING 1015 -#define IDC_COMMON_LABEL 1016 -#define IDC_REMOVE_LOCALIZATION 1017 -#define IDC_COPY_TEMPLATE 1018 -#define ID_SCALING_ADD 1019 -#define IDC_REMOVE_NONLOCALIZATION 1020 -#define ID_QUIT 40000 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 104 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1021 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/oversampling/WDL/localize/localize-import.h b/oversampling/WDL/localize/localize-import.h deleted file mode 100644 index 2a4f287..0000000 --- a/oversampling/WDL/localize/localize-import.h +++ /dev/null @@ -1,83 +0,0 @@ -// used by plug-ins to access imported localization -// usage, in one file: -// #define LOCALIZE_IMPORT_PREFIX "midi_" (should be the directory name with _) -// #include "localize-import.h" -// #include "localize.h" -// import function pointers in initialization -// -// other files can simply import localize.h as normal -// note that if the module might be unloaded, LOCALIZE_FLAG_NOCACHE is essential! -// - -#ifdef _WDL_LOCALIZE_H_ -#error you must include localize-import.h before localize.h, sorry -#endif - -#include -#include "../wdltypes.h" - -// caller must import these 4 function pointers from the running app -static const char *(*importedLocalizeFunc)(const char *str, const char *subctx, int flags); -static void (*importedLocalizeMenu)(const char *rescat, HMENU hMenu, LPCSTR lpMenuName); -static DLGPROC (*importedLocalizePrepareDialog)(const char *rescat, HINSTANCE hInstance, const char *lpTemplate, DLGPROC dlgProc, LPARAM lPAram, void **ptrs, int nptrs); -static void (*importedLocalizeInitializeDialog)(HWND hwnd, const char *d); - -const char *__localizeFunc(const char *str, const char *subctx, int flags) -{ - if (WDL_NORMALLY(importedLocalizeFunc)) return importedLocalizeFunc(str,subctx,flags); - return str; -} - -HMENU __localizeLoadMenu(HINSTANCE hInstance, const char *lpMenuName) -{ - HMENU menu = LoadMenu(hInstance,lpMenuName); - if (menu && WDL_NORMALLY(importedLocalizeMenu)) importedLocalizeMenu(LOCALIZE_IMPORT_PREFIX,menu,lpMenuName); - return menu; -} - -HWND __localizeDialog(HINSTANCE hInstance, const char *lpTemplate, HWND hwndParent, DLGPROC dlgProc, LPARAM lParam, int mode) -{ - void *p[5]; - char tmp[256]; - if (mode == 1) - { - sprintf(tmp,"%.100s%d",LOCALIZE_IMPORT_PREFIX,(int)(INT_PTR)lpTemplate); - p[4] = tmp; - } - else - p[4] = NULL; - - if (WDL_NORMALLY(importedLocalizePrepareDialog)) - { - DLGPROC newDlg = importedLocalizePrepareDialog(LOCALIZE_IMPORT_PREFIX,hInstance,lpTemplate,dlgProc,lParam,p,sizeof(p)/sizeof(p[0])); - if (newDlg) - { - dlgProc = newDlg; - lParam = (LPARAM)(INT_PTR)p; - } - } - switch (mode) - { - case 0: return CreateDialogParam(hInstance,lpTemplate,hwndParent,dlgProc,lParam); - case 1: return (HWND) (INT_PTR)DialogBoxParam(hInstance,lpTemplate,hwndParent,dlgProc,lParam); - } - return 0; -} - -void __localizeInitializeDialog(HWND hwnd, const char *d) -{ - if (WDL_NORMALLY(importedLocalizeInitializeDialog)) importedLocalizeInitializeDialog(hwnd,d); -} - -static WDL_STATICFUNC_UNUSED void localizeKbdSection(KbdSectionInfo *sec, const char *nm) -{ - if (WDL_NORMALLY(importedLocalizeFunc)) - { - int x; - if (sec->action_list) for (x=0;xaction_list_cnt; x++) - { - KbdCmd *p = &sec->action_list[x]; - if (p->text) p->text = __localizeFunc(p->text,nm,2/*LOCALIZE_FLAG_NOCACHE*/); - } - } -} diff --git a/oversampling/WDL/localize/localize-info.txt b/oversampling/WDL/localize/localize-info.txt deleted file mode 100644 index bb272ff..0000000 --- a/oversampling/WDL/localize/localize-info.txt +++ /dev/null @@ -1,83 +0,0 @@ -WDL Localization System -=============================================================================== - -This is a tool for localizing C++ applications. It supports Windows and SWELL-based -GUI applications, or command line only. - - -1. In your code -========================== -The main thing to do is include localize.h from most of your code, and add -localize.cpp to the project (you may want to include it from a wrapper file -in order to hook certain functions). - -At startup your application should call: - -WDL_LoadLanguagePack("/path/to/filename.langpack",NULL); - -When your code has a string that is to be localizable, you do it via this -macro: - - __LOCALIZE("my string","section"); - -Note that both parameters to the macro MUST be literal strings, and be one block -of string (i.e. not using concatenation, i.e. "part1" "part2" etc). - -If you are calling from code that could possibly be in a thread other than the -main thread, or from a module that could be unloaded, use: - - __LOCALIZE_NOCACHE("my string","section"); - -If you would like to have a format specifier in the string, you can use: - - snprintf(buf,sizeof(buf),__LOCALIZE_VERFMT("This has %d items","section"),6); - -The value returned by __LOCALIZE/etc is effectively a const char *, and will -persist, so it is safe to pass whereever and use again. If you are really -performance sensitive, you might want to do: - - static const char *msg; - if (!msg) msg = __LOCALIZE_NOCACHE("whatever","section"); - -This will do the lookup once, and cache the result. - -If you have strings which are present in a table such as: - struct foo bar[]={ - {x,y,z,"string 1"}, - {x,y,z,"string 2"}, - {x,y,z,"string 3"}, - }; - -The best way to handle this is to put comments around the string table, such as: - // !WANT_LOCALIZE_STRINGS_BEGIN:section_name - struct foo bar[]={ - {x,y,z,"string 1"}, - {x,y,z,"string 2"}, - {x,y,z,"string 3"}, - }; - // !WANT_LOCALIZE_STRINGS_END - -Or if other strings exist in that table that are not localized, you can use __LOCALIZE_REG_ONLY(). - -Then, supposing you reference these strings via bar[x].stringptr, you would use: - __localizeFunc(bar[x].stringptr,flags) - (where flags can be 0, or LOCALIZE_FLAG_VERIFY_FMTS or - LOCALIZE_FLAG_NOCACHE or some combination of those, see localize.h) - -There currently a limit of around 8k for localized strings -- if you are -localizing a huge block of text, it might be good to divide it up into -separate strings. - -Finally, for resources, the menus and dialogs are localized automatically via a -wrapper function and some #defines, which are in localize.h - -Dynamic libraries loaded can access the system by using localize-import.h (see comments in that file) - -2. Generating the language pack template -========================== - -To generate a template language pack, compile build_sample_langpack.cpp: - g++ -O -o build_sample_langpack build_sample_langpack.cpp - -Then use: - build_sample_langpack --template *.rc *.cpp > template.langpack diff --git a/oversampling/WDL/localize/localize.cpp b/oversampling/WDL/localize/localize.cpp deleted file mode 100644 index 599f8fb..0000000 --- a/oversampling/WDL/localize/localize.cpp +++ /dev/null @@ -1,1205 +0,0 @@ -// this file may be easier to customize if included directly from other code. Some things that can be defined to hook: -// -// #define WDL_LOCALIZE_HOOK_ALLOW_CACHE (ismainthread()) -// #define WDL_LOCALIZE_HOOK_DLGPROC if (is_modal) return __localDlgProcModalPos; // can return a temporary dlgproc override -// #define WDL_LOCALIZE_HOOK_XLATE(str,subctx,flags,newptr) // can be used to override/tweak translations (newptr str is the original string, newptr is the translated string (or NULL) ) -#ifdef _WIN32 -#include -#else -#include "../swell/swell.h" -#endif - -#ifndef LOCALIZE_NO_DIALOG_MENU_REDEF -#define LOCALIZE_NO_DIALOG_MENU_REDEF -#endif -#include "localize.h" -#include -#include -#include -#include "../assocarray.h" -#include "../ptrlist.h" -#include "../chunkalloc.h" -#include "../fnv64.h" -#include "../win32_utf8.h" -#include "../wdlcstring.h" - - -#define LANGPACK_SCALE_CONSTANT WDL_UINT64_CONST(0x5CA1E00000000000) -static WDL_StringKeyedArray< WDL_AssocArray * > g_translations; -static WDL_AssocArray *g_translations_commonsec; - -static bool isPrintfModifier(char c) -{ - switch (c) - { - case '.': - case '-': - case '+': - case '#': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ' ': - return true; - } - return false; -} - -static const char *next_format(const char *p) -{ - for (;;) - { - switch (p[0]) - { - case 0: return p; - case '%': - if (p[1] != '%') return p; - p++; - WDL_FALLTHROUGH; - default: - p++; - break; - } - } -} - -static bool validateStrs(const char *stock, const char *newstr, int flags) -{ - if (!(flags&LOCALIZE_FLAG_VERIFY_FMTS)) return true; - - for (;;) - { - newstr = next_format(newstr); - if (!newstr[0]) return true; // not enough formats in new string, safe - stock = next_format(stock); - if (!stock[0]) return false; // not enough formats in original string, unsafe - - // compare formats - newstr++; - stock++; - - do - { - while (isPrintfModifier(*newstr)) newstr++; - while (isPrintfModifier(*stock)) stock++; - if (*newstr != *stock) return false; - newstr++; - stock++; - } while (newstr[-1] == '*' || newstr[-1] == 'h' || newstr[-1] == 'l' || newstr[-1] == 'L'); - } - return true; -} - -static char *ChunkAlloc(int len) -{ -#ifdef _DEBUG - static WDL_ChunkAlloc backing(15000); // will free on exit (for debug mode) - return (char*)backing.Alloc(len); -#else - static WDL_ChunkAlloc *backing; - if (!backing) backing = new WDL_ChunkAlloc(15000); - return (char*)backing->Alloc(len); -#endif -} - -#ifdef _DEBUG - bool g_debug_langpack_has_loaded; - - class localizeValidatePtrCacheRec { - public: - localizeValidatePtrCacheRec(const char *subctx, const char *str, const char *ctx) - { - //printf("saving pointers for validation for %s (%s)\n",str,ctx); - m_str_copy=strdup(m_str=str); - m_sub_copy=strdup(m_sub=subctx); - m_ctx=ctx; - } - ~localizeValidatePtrCacheRec() - { - //printf("validating string %s\n",m_str_copy); - WDL_ASSERT(!strcmp(m_sub,m_sub_copy) /* if this triggers, then a caller called __LOCALIZE without NOCACHE on a non-static or unloaded string */ ); - WDL_ASSERT(!strcmp(m_str,m_str_copy) /* if this triggers, then a caller called __LOCALIZE without NOCACHE on a non-static or unloaded string */ ); - } - char *m_sub_copy, *m_str_copy; - const char *m_sub, *m_str, *m_ctx; - }; - static WDL_PtrList_DeleteOnDestroy s_debug_validateptrcache; - #define LANGPACK_DEBUG_SAVE_POINTERS_FOR_VALIDATION(subctx,str,ctx) \ - s_debug_validateptrcache.Add(new localizeValidatePtrCacheRec(subctx,str,ctx)); -#else - #define LANGPACK_DEBUG_SAVE_POINTERS_FOR_VALIDATION(subctx,str,ctx) -#endif - -const char *__localizeFunc(const char *str, const char *subctx, int flags) -{ -#ifdef _DEBUG - WDL_ASSERT(g_debug_langpack_has_loaded != false); -#endif - if (WDL_NOT_NORMALLY(!str || !subctx || !subctx[0])) return str; - if (!g_translations.GetSize()) - { -#ifdef WDL_LOCALIZE_HOOK_XLATE - char *newptr=NULL; - WDL_LOCALIZE_HOOK_XLATE(str,subctx,flags,newptr) - if (newptr) return newptr; -#endif - return str; - } - -#ifdef WDL_LOCALIZE_HOOK_ALLOW_CACHE - const bool cache_lookups = !(flags&LOCALIZE_FLAG_NOCACHE) && WDL_LOCALIZE_HOOK_ALLOW_CACHE; -#else - const bool cache_lookups = !(flags&LOCALIZE_FLAG_NOCACHE); -#endif - -#ifdef BENCHMARK_I8N - static int stats[2]; - static double sumtimes[2]; // [cached] - double startTime=time_precise(); -#endif - - static WDL_PtrKeyedArray< WDL_PtrKeyedArray * > ptrcache; - WDL_PtrKeyedArray *sc = NULL; - - if (cache_lookups) - { - sc = ptrcache.Get((INT_PTR)subctx); - if (sc) - { - const char *ret = sc->Get((INT_PTR)str); - if (ret) - { -#ifdef BENCHMARK_I8N - stats[1]++; - startTime = time_precise()-startTime; - sumtimes[1]+=startTime; - if (!(stats[1]%100)) - { - wdl_log("cached, avg was %fuS\n",sumtimes[1]*10000.0); - sumtimes[1]=0; - } -#endif - - if (ret == (const char *)(INT_PTR)1) return str; - return ret; - } - } - } - - char *newptr = NULL; - - int trycnt; - size_t len = strlen(str)+1; - - if (flags & LOCALIZE_FLAG_DOUBLENULL) - { - // need to test this - for (;;) - { - size_t a = strlen(str+len); - if (!a) break; - len += a+1; - } - len++; - } - else if (flags & LOCALIZE_FLAG_PAIR) - { - len += strlen(str + len) + 1; - } - - WDL_UINT64 hash; - if ((flags & LOCALIZE_FLAG_PAIR) && len == 18 && !memcmp(str,"__LOCALIZE_SCALE\0",18)) - hash = WDL_UINT64_CONST(0x5CA1E00000000000); - else - hash = WDL_FNV64(WDL_FNV64_IV,(const unsigned char *)str,(int)len); - - for (trycnt=0;trycnt<2 && !newptr;trycnt++) - { - WDL_AssocArray *section = trycnt == 1 ? g_translations_commonsec : g_translations.Get(subctx); - - if (section) - { - newptr = section->Get(hash,0); - if (newptr && !validateStrs(str,newptr,flags)) newptr=NULL; - } - } - - #ifdef WDL_LOCALIZE_HOOK_XLATE - WDL_LOCALIZE_HOOK_XLATE(str,subctx,flags,newptr) - #endif - - if (cache_lookups) - { - if (!sc) - { - sc = new WDL_PtrKeyedArray; - ptrcache.Insert((INT_PTR)subctx,sc); - } - sc->Insert((INT_PTR)str,newptr ? newptr : (char*)(INT_PTR)1); // update pointer cache for fast lookup - LANGPACK_DEBUG_SAVE_POINTERS_FOR_VALIDATION(subctx,str,"") - } -#ifdef BENCHMARK_I8N - stats[0]++; - startTime = time_precise()-startTime; - sumtimes[0]+=startTime; - if (!(stats[0]%100)) - { - wdl_log("uncached , avg was %f\n",sumtimes[0]*10000.0); - sumtimes[0]=0; - } -#endif - - return newptr?newptr:str; -} - -static void __localProcMenu(HMENU menu, WDL_AssocArray *s) -{ - int n = GetMenuItemCount(menu); - int x; - char buf[4096]; - for(x=0;xGet(hash,0) : NULL; - if (!newptr && g_translations_commonsec) newptr = g_translations_commonsec->Get(hash,0); - - if (!newptr) - { - #ifdef _WIN32 - char *p =buf; - while (*p && *p != '\t') p++; - lstrcpyn(mod,p,sizeof(mod)); - if (*p) - { - *p++=0; - goto tryagain; - } - #endif - - } - if (newptr) - { - #ifdef _WIN32 - if (mod[0]) - { - lstrcpyn(buf,newptr,3500); - strcat(buf,mod); - newptr=buf; - } - #endif - mii.fMask = MIIM_TYPE; -#ifdef __APPLE__ - mii.fMask |= MIIM_SWELL_DO_NOT_CALC_MODIFIERS; -#endif - mii.dwTypeData = (char*)newptr; - SetMenuItemInfo(menu,x,TRUE,&mii); - } - } - - if (mii.hSubMenu) __localProcMenu(mii.hSubMenu,s); - } - } -} - -void __localizeMenu(const char *rescat, HMENU hMenu, LPCSTR lpMenuName) -{ -#ifdef _DEBUG - WDL_ASSERT(g_debug_langpack_has_loaded != false); -#endif - INT_PTR a = (INT_PTR) lpMenuName; - if (hMenu && a>0&&a<65536) - { - char buf[128]; - sprintf(buf,"%sMENU_%d",rescat?rescat:"",(int)a); - WDL_AssocArray *s = g_translations.Get(buf); - if (s) - { - __localProcMenu(hMenu,s); - } - } -} - -HMENU __localizeLoadMenu(HINSTANCE hInstance, LPCSTR lpMenuName) -{ - HMENU ret = LoadMenu(hInstance,lpMenuName); - if (ret) __localizeMenu(NULL,ret,lpMenuName); - return ret; -} - -struct windowReorgEnt -{ - enum windowReorgEntType - { - WRET_GROUP=0, - WRET_SIZEADJ, - WRET_MISC, // dont analyze for size changes, but move around - - }; - windowReorgEnt(HWND _hwnd, RECT _r, int wc) - { - hwnd=_hwnd; - orig_r=r=_r; - mode=WRET_MISC; - move_amt=0; - wantsizeincrease=0; - scaled_width_change = wc; - } - ~windowReorgEnt() { } - - HWND hwnd; - RECT r,orig_r; - windowReorgEntType mode; - int move_amt; - int wantsizeincrease; - int scaled_width_change; - - static int Sort(const void *_a, const void *_b) - { - const windowReorgEnt *a = (const windowReorgEnt*)_a; - const windowReorgEnt *b = (const windowReorgEnt*)_b; - - if (a->r.left < b->r.left) return -1; - if (a->r.left > b->r.left) return 1; - - if (a->r.top < b->r.top) return -1; - if (a->r.top > b->r.top) return 1; - - return 0; - } - -}; -class windowReorgState -{ -public: - - windowReorgState(HWND _par, float _scx, float _scy) : par(_par), scx(_scx), scy(_scy) - { - RECT cr; - GetClientRect(_par,&cr); - - par_cr = cr; - if (scx != 1.0f) par_cr.right = (int) (par_cr.right * scx + 0.5); - if (scy != 1.0f) par_cr.bottom = (int) (par_cr.bottom * scy + 0.5); - - has_sc = (cr.right != par_cr.right || cr.bottom != par_cr.bottom); - - if (has_sc) - { - RECT wr; - if (GetWindowLong(_par,GWL_STYLE)&WS_CHILD) wr=cr; - else GetWindowRect(_par,&wr); - - SetWindowPos(_par,NULL,0,0, - (par_cr.right - cr.right) + (wr.right-wr.left), - (par_cr.bottom - cr.bottom) + (wr.bottom-wr.top), - SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER); - } - } - ~windowReorgState() { } - - WDL_TypedBuf cws; - WDL_IntKeyedArray columns; // map l|(r<<16) -> maps to size increase - RECT par_cr; - - HWND par; - float scx,scy; - bool has_sc; -}; - -static const char *xlateWindow(HWND hwnd, WDL_AssocArray *s, char *buf, int bufsz, bool prefix_handling) -{ - buf[0]=0; - GetWindowText(hwnd,buf,bufsz); - if (buf[0]) - { - buf[bufsz-1]=0; - WDL_UINT64 hash = WDL_FNV64(WDL_FNV64_IV,(const unsigned char *)buf,(int)strlen(buf)+1); - const char *newptr = s ? s->Get(hash,0) : NULL; - if (!newptr && g_translations_commonsec) newptr = g_translations_commonsec->Get(hash,0); - -#ifdef __APPLE__ - bool filter_prefix = false; - if (!newptr && prefix_handling) - { - extern const char *SWELL_GetRecentPrefixRemoval(const char *p); - const char *p = SWELL_GetRecentPrefixRemoval(buf); - if (p) - { - hash = WDL_FNV64(WDL_FNV64_IV,(const unsigned char *)p,(int)strlen(p)+1); - newptr = s ? s->Get(hash,0) : NULL; - if (!newptr && g_translations_commonsec) newptr = g_translations_commonsec->Get(hash,0); - filter_prefix = true; - } - } -#endif - - if (newptr && strcmp(newptr,buf)) - { -#ifdef __APPLE__ - if (filter_prefix) - { - const char *rd=newptr; - int widx=0; - while (widx < bufsz-1) - { - if (*rd == '&') rd++; - if (!*rd) break; - buf[widx++]=*rd++; - } - buf[widx]=0; - SetWindowText(hwnd,buf); - return newptr; - } -#endif - SetWindowText(hwnd,newptr); - return newptr; - } - } - return NULL; -} - -static BOOL CALLBACK xlateGetRects(HWND hwnd, LPARAM lParam) -{ - windowReorgState *s=(windowReorgState*)lParam; - - if (GetParent(hwnd) != s->par) return TRUE; - - RECT r; - GetWindowRect(hwnd,&r); - ScreenToClient(s->par,(LPPOINT)&r); - ScreenToClient(s->par,((LPPOINT)&r)+1); - int width_change = 0; - - if (s->has_sc) // scaling happens before all of the ripple-code - { - if (r.top > r.bottom) { const int t = r.top; r.top = r.bottom; r.bottom = t; } - - width_change = r.right-r.left; - r.left = (int) (r.left * s->scx + 0.5); - r.top = (int) (r.top * s->scy + 0.5); - r.right = (int) (r.right * s->scx + 0.5); - r.bottom = (int) (r.bottom * s->scy + 0.5); - SetWindowPos(hwnd,NULL, r.left,r.top, r.right-r.left, r.bottom-r.top, SWP_NOACTIVATE|SWP_NOZORDER); - width_change = (r.right-r.left) - width_change; - } - - windowReorgEnt t(hwnd,r,width_change); - -#ifdef _WIN32 - char buf[128]; - buf[0]=0; - GetClassName(hwnd,buf,sizeof(buf)); - if (!strcmp(buf,"Button")) - { - LONG style=GetWindowLong(hwnd,GWL_STYLE); - if (LOWORD(style)==BS_GROUPBOX) t.mode = windowReorgEnt::WRET_GROUP; - else t.mode = windowReorgEnt::WRET_SIZEADJ; - } - else if (!strcmp(buf,"Static")) - { - t.mode = windowReorgEnt::WRET_SIZEADJ; - } -#else - if (SWELL_IsGroupBox(hwnd)) t.mode = windowReorgEnt::WRET_GROUP; - else if (SWELL_IsButton(hwnd)||SWELL_IsStaticText(hwnd)) t.mode = windowReorgEnt::WRET_SIZEADJ; -#endif - - if (t.mode == windowReorgEnt::WRET_GROUP) - { - // first copy is the left side of the group, with hwnd - int a = t.r.right; - t.r.right = t.r.left+4; - t.orig_r=t.r; - s->cws.Add(t); - - // add a second copy, which is the right side but no hwnd - t.r.right = a; - t.r.left = a-4; - t.hwnd=0; - } - t.orig_r=t.r; - s->cws.Add(t); - - return TRUE; -} - -static int rippleControlsRight(HWND hwnd, const RECT *srcR, windowReorgEnt *ent, int ent_cnt, int dSize, int clientw) -{ - // limit first to client rectangle - int space = clientw - 6 - srcR->right; - if (dSize>space) dSize=space; - - while (ent_cnt>0 && dSize>0) - { - // if the two items overlap by more than 1px initially, dont make them ripple (it is assumed they are allowed, maybe one is hidden) -#define LOCALIZE_ISECT_PAIRS(x1,x2,y1,y2) \ - ((x1 >= y1 && x1 < y2) || (x2 >= y1 && x2 < y2) || \ - (y1 >= x1 && y1 < x2) || (y2 >= x1 && y2 < x2)) - if (ent->r.left >= srcR->right-1 && LOCALIZE_ISECT_PAIRS(srcR->top,srcR->bottom,ent->r.top,ent->r.bottom)) - { - space = ent->r.left - srcR->right; - - if (ent->mode == windowReorgEnt::WRET_GROUP) - { - if (dSize>space) dSize=space; - } - else - { - int needAmt = dSize - (space-2 /* border */); - if (needAmt>0) - { - int got = rippleControlsRight(ent->hwnd,&ent->r,ent+1,ent_cnt-1,needAmt,clientw); - dSize -= needAmt - got; - if (ent->move_amt < got) ent->move_amt=got; - } - } - } - - ent_cnt--; - ent++; - } - return dSize; -} - -static void localize_dialog(HWND hwnd, WDL_AssocArray *sec) -{ -#ifdef _DEBUG - WDL_ASSERT(g_debug_langpack_has_loaded != false); -#endif - const char *sc_str = sec->Get(LANGPACK_SCALE_CONSTANT); -/* commented [common] scaling fallback: the langpack author has to set it for each dialog that needs it - if (!sc_str && g_translations_commonsec) - { - sc_str = g_translations_commonsec->Get(LANGPACK_SCALE_CONSTANT); - } -*/ - float scx = 1.0, scy = 1.0; - if (sc_str) - { - while (*sc_str && (*sc_str == ' ' || *sc_str == '\t')) sc_str++; - -#ifdef WDL_HOOK_LOCALIZE_ATOF - float v = (float) WDL_HOOK_LOCALIZE_ATOF(sc_str); -#else - float v = (float) atof(sc_str); -#endif - if (v > 0.1 && v < 8.0) - { - scx=v; - while (*sc_str && *sc_str != ' ' && *sc_str != '\t') sc_str++; - if (*sc_str) - { -#ifdef WDL_HOOK_LOCALIZE_ATOF - v = (float)WDL_HOOK_LOCALIZE_ATOF(sc_str); -#else - v = (float)atof(sc_str); -#endif - if (v > 0.1 && v < 8.0) - scy = v; - } - } - } - - windowReorgState s(hwnd,scx,scy); - - char buf[8192]; - xlateWindow(hwnd,sec,buf,sizeof(buf),false); // translate window title - EnumChildWindows(hwnd,xlateGetRects,(LPARAM)&s); - -#ifdef _WIN32 - HDC hdc=GetDC(hwnd); - HGDIOBJ oldFont=0; - HFONT font = (HFONT)SendMessage(hwnd,WM_GETFONT,0,0); - if (font) oldFont=SelectObject(hdc,font); -#endif - - int x; - const bool do_columns = true; - for(x=0;xhwnd) - { - const char *newText=xlateWindow(rec->hwnd,sec,buf,sizeof(buf), rec->mode != windowReorgEnt::WRET_MISC); - if (newText && rec->mode == windowReorgEnt::WRET_SIZEADJ) - { - RECT r1={0},r2={0}; -#ifdef _WIN32 - DrawText(hdc,buf,-1,&r1,DT_CALCRECT); - DrawText(hdc,newText,-1,&r2,DT_CALCRECT); - r1.right += rec->scaled_width_change; -#else - GetClientRect(rec->hwnd,&r1); - SWELL_GetDesiredControlSize(rec->hwnd,&r2); -#endif - int dSize=r2.right-r1.right; - if (dSize>0) - { - rec->wantsizeincrease = ++dSize; - - if (do_columns) - { - const int v = (rec->r.right<<16) | (rec->r.left&0xffff); - int *diff = s.columns.GetPtr(v); - if (!diff) s.columns.Insert(v,dSize); - else if (dSize > *diff) *diff = dSize; - } - } - } - } - } - - if (do_columns) for(x=0;xhwnd && rec->mode == windowReorgEnt::WRET_SIZEADJ) - { - const int v = (rec->r.right<<16) | (rec->r.left&0xffff); - const int *diff = s.columns.GetPtr(v); - if (diff) rec->wantsizeincrease = *diff; - } - } - - int swSizeInc=0; - - do - { - qsort(s.cws.Get(),s.cws.GetSize(),sizeof(*s.cws.Get()),windowReorgEnt::Sort); - for(x=0;xwantsizeincrease>0) - { - int amt = rippleControlsRight(trec->hwnd,&trec->r,trec+1,s.cws.GetSize() - (x+1),trec->wantsizeincrease,s.par_cr.right); - if (amt>0) - { - trec->wantsizeincrease -= amt; - trec->r.right += amt; - } - int y; - for(y=x+1;ymove_amt); - if (a>0) - { - rec->r.left += a; - rec->r.right += a; - } - rec->move_amt=0; - } - if (!swSizeInc && trec->wantsizeincrease>0) swSizeInc=1; - } - } - - if (swSizeInc++) - { - // flip everything - int w=s.par_cr.right; - for(x=0;xr.left; - int b = w-1-rec->r.right; - rec->r.left = b; - rec->r.right = a; - } - } - } while (swSizeInc == 2); - - - for(x=0;xhwnd) - { - bool wantMove = rec->r.left != rec->orig_r.left; - bool wantSize = (rec->r.right-rec->r.left) != (rec->orig_r.right-rec->orig_r.left); - if (wantMove||wantSize) - { - SetWindowPos(rec->hwnd,NULL,rec->r.left,rec->r.top,rec->r.right-rec->r.left,rec->r.bottom-rec->r.top, - (wantSize?0:SWP_NOSIZE)|(wantMove?0:SWP_NOMOVE)|SWP_NOZORDER|SWP_NOACTIVATE); - } - } - } -#ifdef _WIN32 - if (oldFont) SelectObject(hdc,oldFont); - ReleaseDC(hwnd,hdc); -#endif -} - -void __localizeInitializeDialog(HWND hwnd, const char *desc) -{ - if (!desc || !hwnd || !*desc) return; - WDL_AssocArray *s = g_translations.Get(desc); - if (s) localize_dialog(hwnd,s); -} - -void (*localizePreInitDialogHook)(HWND hwndDlg); - -static WDL_DLGRET __localDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch (uMsg) - { - case WM_INITDIALOG: - { - void **l = (void **)lParam; - - if (localizePreInitDialogHook) - localizePreInitDialogHook(hwnd); - - if (l[2]) - localize_dialog(hwnd,(WDL_AssocArray *)l[2]); - -#ifdef _WIN32 - { - // if not a child window and has a menu set, localize our menu - WDL_AssocArray *s = (WDL_AssocArray *)l[3]; - if (s && !(GetWindowLong(hwnd,GWL_STYLE)&WS_CHILD)) - { - HMENU hmenu = GetMenu(hwnd); - if (hmenu) __localProcMenu(hmenu,s); - } - } -#endif - - DLGPROC newproc = (DLGPROC) l[0]; - SetWindowLongPtr(hwnd,DWLP_DLGPROC,(LRESULT) newproc); - - return newproc(hwnd,uMsg,wParam,(LPARAM)l[1]); - } - } - return 0; -} - -#ifdef _WIN32 -static WORD __getMenuIdFromDlgResource(HINSTANCE hInstance, const char * lpTemplate) -{ - HRSRC h=FindResource(hInstance,lpTemplate,RT_DIALOG); - if (!h) return 0; - DWORD sz = SizeofResource(hInstance, h); - if (sz<30) return 0; - - HGLOBAL hg=LoadResource(hInstance,h); - if (!hg) return 0; - WORD *p = (WORD *)LockResource(hg); - if (!p) return 0; - - if (p[0]!=1 || p[1] != 0xffff) return 0; // not extended dialog template - if (p[13]==0) return 0; - if (p[13]==0xffff) return p[14]; - - //otherwise it is a string, but we dont support(or use) that - return 0; - -} -#endif - -DLGPROC __localizePrepareDialog(const char *rescat, HINSTANCE hInstance, const char *lpTemplate, DLGPROC dlgProc, LPARAM lParam, void **ptrs, int nptrs) -{ - INT_PTR a = (INT_PTR) lpTemplate; - if (WDL_NOT_NORMALLY(nptrs<4)) return NULL; - - WDL_AssocArray *s = NULL, *s2 = NULL; - if (a>0&&a<65536) - { - char buf[128]; - snprintf(buf,sizeof(buf),"%sDLG_%d",rescat?rescat:"",(int)a); - s = g_translations.Get(buf); -#ifdef _WIN32 - int menuid = __getMenuIdFromDlgResource(hInstance,lpTemplate); - if (menuid) - { - snprintf(buf,sizeof(buf),"%sMENU_%d",rescat?rescat:"",menuid); - s2=g_translations.Get(buf); - } -#endif - } - - ptrs[0] = (void*)dlgProc; - ptrs[1] = (void*)(INT_PTR)lParam; - ptrs[2] = s; - ptrs[3] = s2; -#ifdef WDL_LOCALIZE_HOOK_DLGPROC - WDL_LOCALIZE_HOOK_DLGPROC -#endif - return (s||s2||(a>0 && localizePreInitDialogHook)) ? __localDlgProc : NULL; -} - -HWND __localizeDialog(HINSTANCE hInstance, const char *lpTemplate, HWND hwndParent, DLGPROC dlgProc, LPARAM lParam, int mode) -{ - void *p[5]; - char tmp[256]; - if (mode == 1) - { - p[4] = tmp; - snprintf(tmp,sizeof(tmp),"DLG%d",(int)(INT_PTR)lpTemplate); - } - else - p[4] = NULL; - DLGPROC newDlg = __localizePrepareDialog(NULL,hInstance,lpTemplate,dlgProc,lParam,p,sizeof(p)/sizeof(p[0])); - if (newDlg) - { - dlgProc = newDlg; - lParam = (LPARAM)(INT_PTR)p; - } - switch (mode) - { - case 0: return CreateDialogParam(hInstance,lpTemplate,hwndParent,dlgProc,lParam); - case 1: return (HWND) (INT_PTR)DialogBoxParam(hInstance,lpTemplate,hwndParent,dlgProc,lParam); - } - return 0; -} - -static int uint64cmpfunc(WDL_UINT64 *a, WDL_UINT64 *b) -{ - if (*a < *b) return -1; - if (*a > *b) return 1; - return 0; -} - -// call at start of file with format_flag=-1 -// expect possible blank (\r or \n) lines, too, ignore them -// format flag will get set to: 0=utf8, 1=utf16le, 2=utf16be, 3=ansi -void WDL_fgets_as_utf8(char *linebuf, int linebuf_size, FILE *fp, int *format_flag) -{ - linebuf[0]=0; - if (*format_flag>0) - { - int sz=0; - while (sz < linebuf_size-8) - { - int a = fgetc(fp); - int b = *format_flag==3 ? 0 : fgetc(fp); - if (a<0 || b<0) break; - if (*format_flag==2) a = (a<<8)+b; - else a += b<<8; - - - again: - if (a >= 0xD800 && a < 0xDC00) // UTF-16 supplementary planes - { - int aa = fgetc(fp); - int bb = fgetc(fp); - if (aa < 0 || bb < 0) break; - - if (*format_flag==2) aa = (aa<<8)+bb; - else aa += bb<<8; - - if (aa >= 0xDC00 && aa < 0xE000) - { - a = 0x10000 + ((a&0x3FF)<<10) + (aa&0x3FF); - } - else - { - a=aa; - goto again; - } - } - - - if (a < 0x80) linebuf[sz++] = a; - else - { - if (a<0x800) // 11 bits (5+6 bits) - { - linebuf[sz++] = 0xC0 + ((a>>6)&31); - } - else - { - if (a < 0x10000) // 16 bits (4+6+6 bits) - { - linebuf[sz++] = 0xE0 + ((a>>12)&15); // 4 bits - } - else // 21 bits yow - { - linebuf[sz++] = 0xF0 + ((a>>18)&7); // 3 bits - linebuf[sz++] = 0x80 + ((a>>12)&63); // 6 bits - } - linebuf[sz++] = 0x80 + ((a>>6)&63); // 6 bits - } - linebuf[sz++] = 0x80 + (a&63); // 6 bits - } - - if (a == '\n') break; - } - linebuf[sz]=0; - } - else - { - fgets(linebuf,linebuf_size,fp); - } - - if (linebuf[0] && *format_flag<0) - { - unsigned char *p=(unsigned char *)linebuf; - if (p[0] == 0xEF && p[1] == 0xBB && p[2] == 0xBf) - { - *format_flag=0; - memmove(linebuf,linebuf+3,strlen(linebuf+3)+1); // skip UTF-8 BOM - } - else if ((p[0] == 0xFF && p[1] == 0xFE) || (p[0] == 0xFE && p[1] == 0xFF)) - { - fseek(fp,2,SEEK_SET); - *format_flag=p[0] == 0xFE ? 2 : 1; - WDL_fgets_as_utf8(linebuf,linebuf_size,fp,format_flag); - return; - } - else - { - for (;;) - { - const unsigned char *str=(unsigned char *)linebuf; - while (*str) - { - unsigned char c = *str++; - if (c >= 0xC0) - { - if (c <= 0xDF && str[0] >=0x80 && str[0] <= 0xBF) str++; - else if (c <= 0xEF && str[0] >=0x80 && str[0] <= 0xBF && str[1] >=0x80 && str[1] <= 0xBF) str+=2; - else if (c <= 0xF7 && - str[0] >=0x80 && str[0] <= 0xBF && - str[1] >=0x80 && str[1] <= 0xBF && - str[2] >=0x80 && str[2] <= 0xBF) str+=3; - else break; - } - else if (c >= 128) break; - } - if (*str) break; - - linebuf[0]=0; - fgets(linebuf,linebuf_size,fp); - if (!linebuf[0]) break; - } - *format_flag = linebuf[0] ? 3 : 0; // if scanned the whole file without an invalid UTF8 pair, then UTF-8 (0), otherwise ansi (3) - fseek(fp,0,SEEK_SET); - WDL_fgets_as_utf8(linebuf,linebuf_size,fp,format_flag); - return; - } - } -} - -WDL_AssocArray *WDL_GetLangpackSection(const char *sec) -{ - return g_translations.Get(sec); -} - -WDL_AssocArray *WDL_LoadLanguagePackInternal(const char *fn, - WDL_StringKeyedArray< WDL_AssocArray * > *dest, - const char *onlySec_name, - bool include_commented_lines, - bool no_escape_strings, - WDL_StringKeyedArray *extra_metadata - ) -{ -#ifdef _DEBUG - g_debug_langpack_has_loaded = true; -#endif - WDL_AssocArray *rv=NULL; - FILE *fp = fopenUTF8(fn,"r"); - if (!fp) return rv; - - WDL_AssocArray *cursec=NULL; - - int format_flag=-1; - - WDL_TypedBuf procbuf; - char linebuf[16384]; - int ic_lines = 0; - for (;;) - { - WDL_fgets_as_utf8(linebuf,sizeof(linebuf),fp,&format_flag); - if (!linebuf[0]) break; - - char *p=linebuf; - while (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r') p++; - char *lbstart = p; - while (*p) p++; - p--; - while (p >= lbstart && (*p == '\t' || *p == '\n' || *p == '\r')) p--; - p++; - *p=0; - - if (include_commented_lines) - { - if (*lbstart == ';') - { - int x, offs = (lbstart[1] == '^') ? 2 : 1; - for (x = 0; x < 16; x ++) - { - char c = lbstart[offs+x]; - if (c >= 'A' && c <= 'F') { } - else if (c >= '0' && c <= '9') { } - else break; - } - if (x == 16 && lbstart[offs+16] == '=') - lbstart += offs; - } - } - if (!*lbstart || *lbstart == ';' || *lbstart == '#') - { - if (ic_lines >= 0 && extra_metadata) - { - char tmp[128]; - snprintf(tmp,sizeof(tmp),"_initial_comment_%d",ic_lines++); - extra_metadata->Insert(tmp,strdup(linebuf)); - } - continue; - } - - if (*lbstart == '[') - { - ic_lines = -1; - if (cursec) cursec->Resort(); - - lbstart++; - { - char *tmp = lbstart; - while (*tmp && *tmp != ']') tmp++; - *tmp++=0; - if (extra_metadata) - { - while (*tmp == ' ') tmp++; - if (*tmp) - extra_metadata->Insert(lbstart,strdup(tmp)); - } - } - - if (onlySec_name) - { - cursec=NULL; - if (!strcmp(lbstart,onlySec_name)) - { - if (!rv) rv=new WDL_AssocArray(uint64cmpfunc); - cursec=rv; - } - } - else - { - cursec = dest->Get(lbstart); - if (!cursec) - { - cursec = new WDL_AssocArray(uint64cmpfunc); - dest->Insert(lbstart,cursec); - } - } - } - else if (cursec) - { - char *eq = strstr(lbstart,"="); - if (eq) - { - *eq++ = 0; - if (strlen(lbstart) == 16) - { - WDL_UINT64 v=0; - int x; - for (x=0;x<16;x++) - { - int a = lbstart[x]; - if (a>='0' && a<='9') a-='0'; - else if (a>='A' && a<='F') a-='A' - 10; - else break; - - v<<=4; - v+=a; - } - if (x==16) - { - if (strstr(eq,"\\") && !no_escape_strings) - { - procbuf.Resize(0,false); - while (*eq) - { - if (*eq == '\\') - { - eq++; - if (*eq == '\\' || *eq == '\'' || *eq == '"') procbuf.Add(*eq); - else if (*eq == 't'||*eq=='T') procbuf.Add('\t'); - else if (*eq == 'r'||*eq=='R') procbuf.Add('\r'); - else if (*eq == 'n'||*eq=='N') procbuf.Add('\n'); - else if (*eq == '0') procbuf.Add(0); - else procbuf.Add(*eq); - } - else procbuf.Add(*eq); - - eq++; - } - procbuf.Add(0); - procbuf.Add(0); - char *pc = (char *)ChunkAlloc(procbuf.GetSize()); - if (pc) - { - memcpy(pc,procbuf.Get(),procbuf.GetSize()); - cursec->AddUnsorted(v,pc); - } - } - else - { - int eqlen = (int)strlen(eq); - char *pc = (char *)ChunkAlloc(eqlen+2); - if (pc) - { - memcpy(pc,eq,eqlen+1); - pc[eqlen+1]=0; // doublenull terminate to be safe, in case the caller requested LOCALIZE_FLAG_NULLPAIR - cursec->AddUnsorted(v,pc); - } - } - } - } - } - } - } - if (cursec) - cursec->Resort(); - - fclose(fp); - - return rv; -} - -WDL_AssocArray *WDL_LoadLanguagePack(const char *fn, const char *onlySec_name) -{ - WDL_AssocArray *rv = WDL_LoadLanguagePackInternal(fn,&g_translations, onlySec_name,false,false, NULL); - if (!onlySec_name) - g_translations_commonsec = g_translations.Get("common"); - return rv; -} - -void WDL_SetLangpackFallbackEntry(const char *src_sec, WDL_UINT64 src_v, const char *dest_sec, WDL_UINT64 dest_v) -{ - WDL_AssocArray *sec = g_translations.Get(src_sec); - char *v = sec ? sec->Get(src_v) : NULL; - if (!v) return; - sec = g_translations.Get(dest_sec); - if (!sec) - { - sec = new WDL_AssocArray(uint64cmpfunc); - g_translations.Insert(dest_sec,sec); - } - else if (sec->Get(dest_v)) return; - - sec->Insert(dest_v,v); -} - - diff --git a/oversampling/WDL/localize/localize.h b/oversampling/WDL/localize/localize.h deleted file mode 100644 index 75f1335..0000000 --- a/oversampling/WDL/localize/localize.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef _WDL_LOCALIZE_H_ -#define _WDL_LOCALIZE_H_ - -#include "../assocarray.h" - -// normally onlySec_name is NULL and returns NULL (and updates global state) -// if onlySec_name is set, only loads/returns section in question and does not update global state. -WDL_AssocArray *WDL_LoadLanguagePack(const char *buf, const char *onlySec_name); - -WDL_AssocArray *WDL_LoadLanguagePackInternal(const char *buf, - WDL_StringKeyedArray< WDL_AssocArray * > *dest, - const char *onlySec_name, // if set, will not touch dest - bool include_commented_lines, - bool no_escape_strings, - WDL_StringKeyedArray *extra_metadata - ); - -WDL_AssocArray *WDL_GetLangpackSection(const char *sec); - -void WDL_SetLangpackFallbackEntry(const char *src_sec, WDL_UINT64 src_v, const char *dest_sec, WDL_UINT64 dest_v); - -#define LOCALIZE_FLAG_VERIFY_FMTS 1 // verifies translated format-string (%d should match %d, etc) -#define LOCALIZE_FLAG_NOCACHE 2 // must use this if the string passed is not a persistent static string, or if in another thread -#define LOCALIZE_FLAG_PAIR 4 // one \0 in string needed -- this is not doublenull terminated but just a special case -#define LOCALIZE_FLAG_DOUBLENULL 8 // doublenull terminated string - - -#ifdef LOCALIZE_DISABLE -#define __LOCALIZE(str, ctx) str -#define __LOCALIZE_2N(str,ctx) str -#define __LOCALIZE_VERFMT(str, ctx) str -#define __LOCALIZE_NOCACHE(str, ctx) str -#define __LOCALIZE_VERFMT_NOCACHE(str, ctx) str -#define __LOCALIZE_LCACHE(str, ctx, pp) const char *pp = str -#define __LOCALIZE_VERFMT_LCACHE(str, ctx, pp) const char *pp = str -#define LOCALIZE_GET_SCALE_STRING(ctx) ("") -#else -#define __LOCALIZE(str, ctx) __localizeFunc("" str "" , "" ctx "",0) -#define __LOCALIZE_2N(str,ctx) __localizeFunc("" str "" , "" ctx "",LOCALIZE_FLAG_PAIR) -#define __LOCALIZE_VERFMT(str, ctx) __localizeFunc("" str "", "" ctx "",LOCALIZE_FLAG_VERIFY_FMTS) -#define __LOCALIZE_NOCACHE(str, ctx) __localizeFunc("" str "", "" ctx "",LOCALIZE_FLAG_NOCACHE) -#define __LOCALIZE_VERFMT_NOCACHE(str, ctx) __localizeFunc("" str "", "" ctx "",LOCALIZE_FLAG_VERIFY_FMTS|LOCALIZE_FLAG_NOCACHE) -#define __LOCALIZE_LCACHE(str, ctx, pp) static const char *pp; if (!pp) pp = __localizeFunc("" str "", "" ctx "",LOCALIZE_FLAG_NOCACHE) -#define __LOCALIZE_VERFMT_LCACHE(str, ctx, pp) static const char *pp; if (!pp) pp = __localizeFunc("" str "", "" ctx "",LOCALIZE_FLAG_VERIFY_FMTS|LOCALIZE_FLAG_NOCACHE) -#define LOCALIZE_GET_SCALE_STRING(ctx) __localizeFunc("__LOCALIZE_SCALE\0",ctx,LOCALIZE_FLAG_PAIR|LOCALIZE_FLAG_NOCACHE) -#endif - -#define __LOCALIZE_REG_ONLY(str, ctx) str - - -// localize a string -const char *__localizeFunc(const char *str, const char *subctx, int flags); - -// localize a menu; rescat can be NULL, or a prefix -void __localizeMenu(const char *rescat, HMENU hMenu, LPCSTR lpMenuName); - -void __localizeInitializeDialog(HWND hwnd, const char *desc); // only use for certain child windows that we can't control creation of, pass desc of DLG_xyz etc - -// localize a dialog; rescat can be NULL, or a prefix -// if returns non-NULL, use retval as dlgproc and pass ptrs as LPARAM to dialogboxparam -// nptrs should be at least 4 (might increase someday, but this will only ever be used by utilfunc.cpp or localize-import.h) -DLGPROC __localizePrepareDialog(const char *rescat, HINSTANCE hInstance, const char *lpTemplate, DLGPROC dlgProc, LPARAM lParam, void **ptrs, int nptrs); - - -#ifndef LOCALIZE_NO_DIALOG_MENU_REDEF -#undef DialogBox -#undef CreateDialog -#undef DialogBoxParam -#undef CreateDialogParam - -#ifdef _WIN32 - #define DialogBoxParam(a,b,c,d,e) ((INT_PTR)__localizeDialog(a,b,c,d,e,1)) - #define CreateDialogParam(a,b,c,d,e) __localizeDialog(a,b,c,d,e,0) -#else - #define DialogBoxParam(a,b,c,d,e) ((INT_PTR)__localizeDialog(NULL,b,c,d,e,1)) - #define CreateDialogParam(a,b,c,d,e) __localizeDialog(NULL,b,c,d,e,0) -#endif - -#define DialogBox(hinst,lpt,hwndp,dlgproc) DialogBoxParam(hinst,lpt,hwndp,dlgproc,0) -#define CreateDialog(hinst,lpt,hwndp,dlgproc) CreateDialogParam(hinst,lpt,hwndp,dlgproc,0) - - -#undef LoadMenu -#define LoadMenu __localizeLoadMenu -#endif - -HMENU __localizeLoadMenu(HINSTANCE hInstance, const char *lpMenuName); -HWND __localizeDialog(HINSTANCE hInstance, const char * lpTemplate, HWND hwndParent, DLGPROC dlgProc, LPARAM lParam, int mode); - -#define __localizeDialogBoxParam(a,b,c,d,e) ((INT_PTR)__localizeDialog(a,b,c,d,e,1)) -#define __localizeCreateDialogParam(a,b,c,d,e) __localizeDialog(a,b,c,d,e,0) - -extern void (*localizePreInitDialogHook)(HWND hwndDlg); - -#endif diff --git a/oversampling/WDL/localize/merge_langpacks.cpp b/oversampling/WDL/localize/merge_langpacks.cpp deleted file mode 100644 index a870c97..0000000 --- a/oversampling/WDL/localize/merge_langpacks.cpp +++ /dev/null @@ -1,432 +0,0 @@ -#include -#include -#include -#ifndef _WIN32 -#define stricmp strcasecmp -#include -#endif - -#include "../assocarray.h" -#include "../wdlstring.h" -#include "../ptrlist.h" -#include "../wdlcstring.h" - - - - -// call at start of file with format_flag=-1 -// expect possible blank (\r or \n) lines, too, ignore them -static void fgets_as_utf8(char *linebuf, int linebuf_size, FILE *fp, int *format_flag) -{ - // format flag: 0=utf8, 1=utf16le, 2=utf16be, 3=ansi - linebuf[0]=0; - if (*format_flag>0) - { - int sz=0; - while (sz < linebuf_size-8) - { - int a = fgetc(fp); - int b = *format_flag==3 ? 0 : fgetc(fp); - if (a<0 || b<0) break; - if (*format_flag==2) a = (a<<8)+b; - else a += b<<8; - - - again: - if (a >= 0xD800 && a < 0xDC00) // UTF-16 supplementary planes - { - int aa = fgetc(fp); - int bb = fgetc(fp); - if (aa < 0 || bb < 0) break; - - if (*format_flag==2) aa = (aa<<8)+bb; - else aa += bb<<8; - - if (aa >= 0xDC00 && aa < 0xE000) - { - a = 0x10000 + ((a&0x3FF)<<10) + (aa&0x3FF); - } - else - { - a=aa; - goto again; - } - } - - - if (a < 0x80) linebuf[sz++] = a; - else - { - if (a<0x800) // 11 bits (5+6 bits) - { - linebuf[sz++] = 0xC0 + ((a>>6)&31); - } - else - { - if (a < 0x10000) // 16 bits (4+6+6 bits) - { - linebuf[sz++] = 0xE0 + ((a>>12)&15); // 4 bits - } - else // 21 bits yow - { - linebuf[sz++] = 0xF0 + ((a>>18)&7); // 3 bits - linebuf[sz++] = 0x80 + ((a>>12)&63); // 6 bits - } - linebuf[sz++] = 0x80 + ((a>>6)&63); // 6 bits - } - linebuf[sz++] = 0x80 + (a&63); // 6 bits - } - - if (a == '\n') break; - } - linebuf[sz]=0; - } - else - { - fgets(linebuf,linebuf_size,fp); - } - - if (linebuf[0] && *format_flag<0) - { - unsigned char *p=(unsigned char *)linebuf; - if (p[0] == 0xEF && p[1] == 0xBB && p[2] == 0xBf) - { - *format_flag=0; - memmove(linebuf,linebuf+3,strlen(linebuf+3)+1); // skip UTF-8 BOM - } - else if ((p[0] == 0xFF && p[1] == 0xFE) || (p[0] == 0xFE && p[1] == 0xFF)) - { - fseek(fp,2,SEEK_SET); - *format_flag=p[0] == 0xFE ? 2 : 1; - fgets_as_utf8(linebuf,linebuf_size,fp,format_flag); - return; - } - else - { - for (;;) - { - const unsigned char *str=(unsigned char *)linebuf; - while (*str) - { - unsigned char c = *str++; - if (c >= 0xC0) - { - if (c <= 0xDF && str[0] >=0x80 && str[0] <= 0xBF) str++; - else if (c <= 0xEF && str[0] >=0x80 && str[0] <= 0xBF && str[1] >=0x80 && str[1] <= 0xBF) str+=2; - else if (c <= 0xF7 && - str[0] >=0x80 && str[0] <= 0xBF && - str[1] >=0x80 && str[1] <= 0xBF && - str[2] >=0x80 && str[2] <= 0xBF) str+=3; - else break; - } - else if (c >= 128) break; - } - if (*str) break; - - linebuf[0]=0; - fgets(linebuf,linebuf_size,fp); - if (!linebuf[0]) break; - } - *format_flag = linebuf[0] ? 3 : 0; // if scanned the whole file without an invalid UTF8 pair, then UTF-8 (0), otherwise ansi (3) - fseek(fp,0,SEEK_SET); - fgets_as_utf8(linebuf,linebuf_size,fp,format_flag); - return; - } - } -} - - -bool read_ini(const char *fn, WDL_StringKeyedArray< WDL_StringKeyedArray * > *sections, WDL_String *mod_name, int options) -{ - FILE *fp = fopen(fn,"r"); - if (!fp) return false; - - WDL_StringKeyedArray *cursec=NULL; - - bool warn=false; - int char_fmt=-1; - char linebuf[16384]; - int linecnt=0; - for (;;) - { - linebuf[0]=0; - fgets_as_utf8(linebuf,sizeof(linebuf),fp,&char_fmt); - if (!linebuf[0]) break; - if (char_fmt==3 && !warn) - { - fprintf(stderr,"Warning: '%s' was not saved with UTF-8 or UTF-16 encoding, the merged Langpack might contain garbled characters.\n", fn); - warn=true; - } - - char *p=linebuf; - while (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r') p++; - char *lbstart = p; - while (*p) p++; - p--; - while (p >= lbstart) - { - if (options&1) { if (*p == '\n' || *p == '\r') p--; else break; } - else { if (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r') p--; else break; } - } - p++; - *p=0; - - if (!linecnt && !strncmp(lbstart,"#NAME:",6)) - { - mod_name->Set(lbstart+6); - } - - linecnt++; - - if (!*lbstart || *lbstart == '#') continue; - - if (*lbstart == '[') - { - if (cursec) cursec->Resort(); - - lbstart++; - { - char *tmp = lbstart; - while (*tmp && *tmp != ']') tmp++; - *tmp=0; - } - - cursec = sections->Get(lbstart); - if (!cursec) - { - cursec = new WDL_StringKeyedArray(false,WDL_StringKeyedArray::freecharptr); - sections->Insert(lbstart,cursec); - } - } - else if (cursec) - { - char *eq = strstr(lbstart,"="); - if (eq) - { - *eq++ = 0; - cursec->AddUnsorted(lbstart,strdup(eq)); - } - } - } - if (cursec) - cursec->Resort(); - - fclose(fp); - return true; -} - - -char *GotKey(WDL_StringKeyedArray *cursec_modptr, WDL_StringKeyedArray *cursec_hadvals, char *key) // key[19], can be mangled -{ - char *match=NULL; - if (cursec_modptr) - { - int start_idx=2; - match = cursec_modptr->Get(key+start_idx); - if (!match) - { - start_idx=1; - key[1]=';'; - match = cursec_modptr->Get(key+start_idx); - } - if (!match) - { - start_idx=0; - key[0]=';'; - key[1]='^'; - match = cursec_modptr->Get(key+start_idx); - } - if (match) - { - printf("%s=%s\n",key+start_idx,match); - cursec_hadvals->Insert(key+2,true); - } - } - return match; -} - - - - - -int main(int argc, char **argv) -{ - int i; - int options = 0; - for (i=3; i3 && !options)) - { - fprintf(stderr,"Usage: merge_langpacks new_template.txt my_language.txt [options] > new_language.txt\n"); - fprintf(stderr,"Options:\n"); - fprintf(stderr," -p: preserve trailing spaces/tabs\n"); - fprintf(stderr," -c: comment obsolete sections/strings\n"); - return 1; - } - FILE *reffp = fopen(argv[1],"r"); - if (!reffp) - { - fprintf(stderr,"Error reading '%s', invalid template langpack.\n",argv[1]); - return 1; - } - WDL_StringKeyedArray * > mods; - WDL_String mod_name; - if (!read_ini(argv[2],&mods,&mod_name,options)||!mods.GetSize()) - { - fprintf(stderr,"Error reading '%s', invalid langpack.\n",argv[2]); - return 1; - } - - int char_fmt=-1; - - //printf("%c%c%c",0xEF,0xBB,0xBF); // UTF-8 BOM - WDL_String cursec; - WDL_StringKeyedArray *cursec_modptr=NULL; - WDL_StringKeyedArray cursec_hadvals(false); - WDL_PtrList cursec_added; - - bool warn=false; - char key[2+16+1]; - int line_count=0; - for (;;) - { - char buf[16384]; - buf[0]=0; - fgets_as_utf8(buf,sizeof(buf),reffp,&char_fmt); - if (char_fmt==3 && !warn) - { - fprintf(stderr,"Warning: '%s' was not saved with UTF-8 or UTF-16 encoding, the merged Langpack might contain garbled characters.\n", argv[1]); - warn=true; - } - - bool wasZ = !buf[0]; - - // remove any trailing newlines - char *p=buf; - while (*p) p++; - while (p>buf && (p[-1] == '\r'||p[-1] == '\n')) p--; - *p=0; - - // skip any leading space - p=buf; - while (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r') p++; - - line_count++; - if (line_count==1 && mod_name.Get()[0]) - { - printf("#NAME:%s\n",mod_name.Get()); - if (!strncmp(p,"#NAME:",6)) continue; // ignore template #NAME: line, use modded - } - - char *np; - if (wasZ || (p[0] == '[' && (np = strstr(p,"]")) && np > p+1)) - { - if (cursec.Get()[0]) - { - // finish current section - if (cursec_added.GetSize()) - { - printf("######## added in template (section: %s):\n",cursec.Get()); - int x; - for(x=0;xGetSize();x++) - { - const char *nm=NULL; - const char *val= cursec_modptr->Enumerate(x,&nm); - if (!nm || !val) break; - - if (nm[0] == ';') continue; - - if (!cursec_hadvals.Get(nm)) - { - if (!oc++) printf("######## not in template, possibly obsolete (section: %s):\n",cursec.Get()); - printf("%s%s=%s\n", (options&2) ? ";" : "", nm, val); - } - } - if (oc) printf("\n"); - - } - - mods.Delete(cursec.Get()); - cursec_hadvals.DeleteAll(); - cursec_added.Empty(true,free); - cursec_modptr=NULL; - } - - if (wasZ) break; - - printf("%s\n",buf); - cursec.Set(p+1, (int)(np-p-1)); - cursec_modptr = mods.Get(cursec.Get()); - - // if any, preserve the scaling at the top of the section - strcpy(key+2,"5CA1E00000000000"); - GotKey(cursec_modptr, &cursec_hadvals, key); - // done, scaling lines are added by hand (not part of templates) - - continue; - } - - - if (!cursec.Get()[0]) printf("%s\n",buf); - else - { - char *eq = strstr(p,"="); - if (!eq) printf("%s\n",buf); - else - { - if (p[0] == ';' && *++p == '^') p++; - if (eq-p==16) - { - lstrcpyn_safe(key+2, p, 17); - if (!GotKey(cursec_modptr, &cursec_hadvals, key)) - { - cursec_added.Add(strdup(buf)); - } - } - else - { - printf("%s\n",buf); - } - } - } - } - - fclose(reffp); - - int x; - for (x=0;xGetSize();y++) - { - const char *nm=NULL; - const char *v=cursec_modptr->Enumerate(y,&nm); - if (!nm || !v) break; - printf("%s%s=%s\n", (options&2) && nm[0]!=';' ? ";" : "", nm, v); - } - } - - return 0; -} - diff --git a/oversampling/WDL/md5.c b/oversampling/WDL/md5.c deleted file mode 100644 index 5d8d8f1..0000000 --- a/oversampling/WDL/md5.c +++ /dev/null @@ -1,297 +0,0 @@ -/* - * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. - * MD5 Message-Digest Algorithm (RFC 1321). - * - * Homepage: - * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 - * - * Author: - * Alexander Peslyak, better known as Solar Designer - * - * This software was written by Alexander Peslyak in 2001. No copyright is - * claimed, and the software is hereby placed in the public domain. - * In case this attempt to disclaim copyright and place the software in the - * public domain is deemed null and void, then the software is - * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the - * general public under the following terms: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted. - * - * There's ABSOLUTELY NO WARRANTY, express or implied. - * - * (This is a heavily cut-down "BSD license".) - * - * This differs from Colin Plumb's older public domain implementation in that - * no exactly 32-bit integer data type is required (any 32-bit or wider - * unsigned integer data type will do), there's no compile-time endianness - * configuration, and the function prototypes match OpenSSL's. No code from - * Colin Plumb's implementation has been reused; this comment merely compares - * the properties of the two independent implementations. - * - * The primary goals of this implementation are portability and ease of use. - * It is meant to be fast, but not as fast as possible. Some known - * optimizations are not included to reduce source code size and avoid - * compile-time configuration. - * - * Minor additions/changes by Theo Niessink . - */ - -#ifndef HAVE_OPENSSL - -#include - -#include "md5.h" - -/* - * The basic MD5 functions. - * - * F and G are optimized compared to their RFC 1321 definitions for - * architectures that lack an AND-NOT instruction, just like in Colin Plumb's - * implementation. - */ -#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) -#define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y)))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define I(x, y, z) ((y) ^ ((x) | ~(z))) - -/* - * The MD5 transformation for all four rounds. - */ -#define STEP(f, a, b, c, d, x, t, s) \ - (a) += f((b), (c), (d)) + (x) + (t); \ - (a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \ - (a) += (b); - -/* - * SET reads 4 input bytes in little-endian byte order and stores them - * in a properly aligned word in host byte order. - * - * The check for little-endian architectures that tolerate unaligned - * memory accesses is just an optimization. Nothing will break if it - * doesn't work. - */ -#if defined(__i386__) || defined(__x86_64__) || defined(__vax__) -#define SET(n) \ - (*(MD5_u32plus *)&ptr[(n) * 4]) -#define GET(n) \ - SET(n) -#else -#define SET(n) \ - (ctx->block[(n)] = \ - (MD5_u32plus)ptr[(n) * 4] | \ - ((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \ - ((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \ - ((MD5_u32plus)ptr[(n) * 4 + 3] << 24)) -#define GET(n) \ - (ctx->block[(n)]) -#endif - -/* - * This processes one or more 64-byte data blocks, but does NOT update - * the bit counters. There are no alignment requirements. - */ -static const void *body(MD5_CTX *ctx, const void *data, unsigned long size) -{ - const unsigned char *ptr; - MD5_u32plus a, b, c, d; - MD5_u32plus saved_a, saved_b, saved_c, saved_d; - - ptr = (const unsigned char *)data; - - a = ctx->a; - b = ctx->b; - c = ctx->c; - d = ctx->d; - - do { - saved_a = a; - saved_b = b; - saved_c = c; - saved_d = d; - -/* Round 1 */ - STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7) - STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12) - STEP(F, c, d, a, b, SET(2), 0x242070db, 17) - STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22) - STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7) - STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12) - STEP(F, c, d, a, b, SET(6), 0xa8304613, 17) - STEP(F, b, c, d, a, SET(7), 0xfd469501, 22) - STEP(F, a, b, c, d, SET(8), 0x698098d8, 7) - STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12) - STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17) - STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22) - STEP(F, a, b, c, d, SET(12), 0x6b901122, 7) - STEP(F, d, a, b, c, SET(13), 0xfd987193, 12) - STEP(F, c, d, a, b, SET(14), 0xa679438e, 17) - STEP(F, b, c, d, a, SET(15), 0x49b40821, 22) - -/* Round 2 */ - STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5) - STEP(G, d, a, b, c, GET(6), 0xc040b340, 9) - STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14) - STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20) - STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5) - STEP(G, d, a, b, c, GET(10), 0x02441453, 9) - STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14) - STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20) - STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5) - STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9) - STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14) - STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20) - STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5) - STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9) - STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14) - STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20) - -/* Round 3 */ - STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4) - STEP(H, d, a, b, c, GET(8), 0x8771f681, 11) - STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16) - STEP(H, b, c, d, a, GET(14), 0xfde5380c, 23) - STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4) - STEP(H, d, a, b, c, GET(4), 0x4bdecfa9, 11) - STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16) - STEP(H, b, c, d, a, GET(10), 0xbebfbc70, 23) - STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4) - STEP(H, d, a, b, c, GET(0), 0xeaa127fa, 11) - STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16) - STEP(H, b, c, d, a, GET(6), 0x04881d05, 23) - STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4) - STEP(H, d, a, b, c, GET(12), 0xe6db99e5, 11) - STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16) - STEP(H, b, c, d, a, GET(2), 0xc4ac5665, 23) - -/* Round 4 */ - STEP(I, a, b, c, d, GET(0), 0xf4292244, 6) - STEP(I, d, a, b, c, GET(7), 0x432aff97, 10) - STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15) - STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21) - STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6) - STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10) - STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15) - STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21) - STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6) - STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10) - STEP(I, c, d, a, b, GET(6), 0xa3014314, 15) - STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21) - STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6) - STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10) - STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15) - STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21) - - a += saved_a; - b += saved_b; - c += saved_c; - d += saved_d; - - ptr += 64; - } while (size -= 64); - - ctx->a = a; - ctx->b = b; - ctx->c = c; - ctx->d = d; - - return ptr; -} - -void MD5_Init(MD5_CTX *ctx) -{ - ctx->a = 0x67452301; - ctx->b = 0xefcdab89; - ctx->c = 0x98badcfe; - ctx->d = 0x10325476; - - ctx->lo = 0; - ctx->hi = 0; -} - -void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) -{ - MD5_u32plus saved_lo; - unsigned long used, free; - - saved_lo = ctx->lo; - if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) - ctx->hi++; - ctx->hi += size >> 29; - - used = saved_lo & 0x3f; - - if (used) { - free = 64 - used; - - if (size < free) { - memcpy(&ctx->buffer[used], data, size); - return; - } - - memcpy(&ctx->buffer[used], data, free); - data = (unsigned char *)data + free; - size -= free; - body(ctx, ctx->buffer, 64); - } - - if (size >= 64) { - data = body(ctx, data, size & ~(unsigned long)0x3f); - size &= 0x3f; - } - - memcpy(ctx->buffer, data, size); -} - -void MD5_Final(unsigned char *result, MD5_CTX *ctx) -{ - unsigned long used, free; - - used = ctx->lo & 0x3f; - - ctx->buffer[used++] = 0x80; - - free = 64 - used; - - if (free < 8) { - memset(&ctx->buffer[used], 0, free); - body(ctx, ctx->buffer, 64); - used = 0; - free = 64; - } - - memset(&ctx->buffer[used], 0, free - 8); - - ctx->lo <<= 3; - ctx->buffer[56] = ctx->lo; - ctx->buffer[57] = ctx->lo >> 8; - ctx->buffer[58] = ctx->lo >> 16; - ctx->buffer[59] = ctx->lo >> 24; - ctx->buffer[60] = ctx->hi; - ctx->buffer[61] = ctx->hi >> 8; - ctx->buffer[62] = ctx->hi >> 16; - ctx->buffer[63] = ctx->hi >> 24; - - body(ctx, ctx->buffer, 64); - - result[0] = ctx->a; - result[1] = ctx->a >> 8; - result[2] = ctx->a >> 16; - result[3] = ctx->a >> 24; - result[4] = ctx->b; - result[5] = ctx->b >> 8; - result[6] = ctx->b >> 16; - result[7] = ctx->b >> 24; - result[8] = ctx->c; - result[9] = ctx->c >> 8; - result[10] = ctx->c >> 16; - result[11] = ctx->c >> 24; - result[12] = ctx->d; - result[13] = ctx->d >> 8; - result[14] = ctx->d >> 16; - result[15] = ctx->d >> 24; - - memset(ctx, 0, sizeof(*ctx)); -} - -#endif diff --git a/oversampling/WDL/md5.h b/oversampling/WDL/md5.h deleted file mode 100644 index 0c3652e..0000000 --- a/oversampling/WDL/md5.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. - * MD5 Message-Digest Algorithm (RFC 1321). - * - * Homepage: - * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 - * - * Author: - * Alexander Peslyak, better known as Solar Designer - * - * This software was written by Alexander Peslyak in 2001. No copyright is - * claimed, and the software is hereby placed in the public domain. - * In case this attempt to disclaim copyright and place the software in the - * public domain is deemed null and void, then the software is - * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the - * general public under the following terms: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted. - * - * There's ABSOLUTELY NO WARRANTY, express or implied. - * - * See md5.c for more information. - */ - -#ifdef HAVE_OPENSSL -#include -#elif !defined(_MD5_H) -#define _MD5_H - -#define MD5_DIGEST_LENGTH 16 - -#ifdef __cplusplus -extern "C" { -#endif - -/* Any 32-bit or wider unsigned integer data type will do */ -typedef unsigned int MD5_u32plus; - -typedef struct { - MD5_u32plus lo, hi; - MD5_u32plus a, b, c, d; - unsigned char buffer[64]; - MD5_u32plus block[16]; -} MD5_CTX; - -extern void MD5_Init(MD5_CTX *ctx); -extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size); -extern void MD5_Final(unsigned char *result, MD5_CTX *ctx); - -#ifdef __cplusplus -}; -#endif - -#endif diff --git a/oversampling/WDL/mergesort.h b/oversampling/WDL/mergesort.h deleted file mode 100644 index 7a8c862..0000000 --- a/oversampling/WDL/mergesort.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef _WDL_MERGESORT_H_ -#define _WDL_MERGESORT_H_ - -#include "wdltypes.h" - -static void WDL_STATICFUNC_UNUSED WDL_mergesort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *), char *tmpspace) -{ - char *b1,*b2; - size_t n1, n2; - - if (nmemb < 2) return; - - n1 = nmemb / 2; - b1 = (char *) base; - n2 = nmemb - n1; - b2 = b1 + (n1 * size); - - if (nmemb>2) - { - WDL_mergesort(b1, n1, size, compar, tmpspace); - WDL_mergesort(b2, n2, size, compar, tmpspace); - } - - - do - { - if (compar(b1, b2) > 0) // out of order, go to full merge - { - size_t sofar = b1-(char*)base; - memcpy(tmpspace,base,sofar); - memcpy(tmpspace+sofar, b2, size); - b2 += size; - n2--; - - char *writeptr=tmpspace+sofar+size; - while (n1 > 0 && n2 > 0) - { - if (compar(b1, b2) > 0) - { - memcpy(writeptr, b2, size); - b2 += size; - n2--; - } - else - { - memcpy(writeptr, b1, size); - b1 += size; - n1--; - } - writeptr += size; - } - - if (n1 > 0) memcpy(writeptr, b1, n1 * size); - memcpy(base, tmpspace, (nmemb - n2) * size); - - break; - } - - // in order, just advance - b1 += size; - n1--; - } - while (n1 > 0 && n2 > 0); -} - -#endif//_WDL_MERGESORT_H_ diff --git a/oversampling/WDL/metadata.h b/oversampling/WDL/metadata.h deleted file mode 100644 index d8a7815..0000000 --- a/oversampling/WDL/metadata.h +++ /dev/null @@ -1,2241 +0,0 @@ -#ifndef _WDL_METADATA_H_ -#define _WDL_METADATA_H_ - -#include -#include "wdlstring.h" -#include "xmlparse.h" -#include "fileread.h" -#include "filewrite.h" -#include "queue.h" -#include "win32_utf8.h" -#include "wdl_base64.h" -#include "coreaudio_channel_formats.h" - - -const char *EnumMexKeys(int i, const char **desc=NULL) -{ - // TO_DO_IF_METADATA_UPDATE - static const char *s_mexkeys[]= - {"TITLE", "ARTIST", "ALBUM", "TRACKNUMBER", "YEAR", "GENRE", "COMMENT", "DESC", "BPM", "KEY", "DB_CUSTOM"}; - static const char *s_mexdesc[]= - {"Title", "Artist", "Album", "Track", "Date", "Genre", "Comment", "Description", "BPM", "Key", "Media Explorer Tags"}; - - bool ok = i >= 0 && i < sizeof(s_mexkeys)/sizeof(s_mexkeys[0]); - if (desc) *desc = ok ? s_mexdesc[i] : NULL; - return ok ? s_mexkeys[i] : NULL; -} - - -int MetadataToArray(WDL_StringKeyedArray *metadata, WDL_TypedBuf *metadata_arr) -{ - if (!metadata || !metadata_arr) return 0; - - int cnt=0; - for (int i=0; i < metadata->GetSize(); ++i) - { - const char *k, *v=metadata->Enumerate(i, &k); - if (k && v) - { - metadata_arr->Add(k); - metadata_arr->Add(v); - ++cnt; - } - } - metadata_arr->Add(NULL); - return cnt; -} - -int ArrayToMetadata(const char **metadata_arr, WDL_StringKeyedArray *metadata) -{ - if (!metadata_arr || !metadata) return 0; - - int cnt=0; - for (; metadata_arr[0] && metadata_arr[1]; metadata_arr += 2) - { - metadata->AddUnsorted(metadata_arr[0], strdup(metadata_arr[1])); - ++cnt; - } - if (cnt) metadata->Resort(); - return cnt; -} - - -char *tag_strndup(const char *src, int len) -{ - if (!src || !len) return NULL; - int n=0; - while (n < len && src[n]) ++n; - char *dest=(char*)malloc(n+1); - if (!dest) return NULL; - memcpy(dest, src, n); - dest[n]=0; - return dest; -} - -WDL_UINT64 ParseUInt64(const char *val) -{ - WDL_UINT64 i=0; - if (val) - { - const char *p=val; - while (*p) - { - int d=*p-'0'; - if (d < 0 || d > 9) break; - i=(10*i)+d; - ++p; - } - if (*p) i=0; - } - return i; -} - -void InsertMetadataIncrKeyIfNeeded(WDL_StringKeyedArray *metadata, - const char *key, const char *val) -{ - if (!metadata->Exists(key)) - { - metadata->Insert(key, strdup(val)); - } - else - { - for (int i=2; i < 100; ++i) - { - char str[2048]; - snprintf(str,sizeof(str), "%s:%d", key, i); - if (!metadata->Exists(str)) - { - metadata->Insert(str, strdup(val)); - break; - } - } - } -} - -void XMLCompliantAppend(WDL_FastString *str, const char *txt, bool is_value) -{ - if (str && txt) for (;;) - { - char c = *txt++; - switch (c) - { - case 0: return; - case '<': str->Append("<"); break; - case '>': str->Append(">"); break; - case '&': str->Append("&"); break; - case ' ': str->Append(is_value ? " " : "_"); break; - default: str->Append(&c,1); break; - } - } -} - -const char *XMLHasOpenTag(WDL_FastString *str, const char *tag) // tag like "") -{ - // stupid - int taglen=strlen(tag); - const char *open=strstr(str->Get(), tag); - while (open) - { - const char *close=strstr(open+taglen, tag+1); - if (!close || WDL_NOT_NORMALLY(close[-1] != '/')) break; - open=strstr(close+taglen-1, tag); - } - return open; -} - -void UnpackXMLElement(const char *pre, wdl_xml_element *elem, - WDL_StringKeyedArray *metadata) -{ - WDL_FastString key; - if (stricmp(elem->name, "BWFXML")) - { - key.SetFormatted(512, "%s:%s", pre, elem->name); - pre=key.Get(); - } - if (elem->value.Get()[0]) - { - const char *k=key.Get(); - if (!strncmp(k, "IXML:ASWG:", 10)) - { - k += 5; - } - else if (!strncmp(k, "IXML:BEXT:", 10)) - { - // we could rewrite this as follows, but this might overwrite an actual bext chunk so maybe not? - /* - if (!strcmp(k+10, "BWF_DESCRIPTION")) k="BWF:Description"; - else if (!strcmp(k+10, "BWF_ORIGINATOR")) k="BWF:Originator"; - else if (!strcmp(k+10, "BWF_ORIGINATOR_REFERENCE")) k="BWF:OriginatorReference"; - else if (!strcmp(k+10, "BWF_ORIGINATION_DATE")) k="BWF:OriginationDate"; - else if (!strcmp(k+10, "BWF_ORIGINATION_TIME")) k="BWF:OriginationTime"; - else if (!strcmp(k+10, "BWF_TIME_REFERENCE")) k="BWF:TimeReference"; // todo parse lo/hi - else if (!strcmp(k+10, "BWF_VERSION")) k="BWF:Version"; - else if (!strcmp(k+10, "BWF_LOUDNESS_VALUE")) k="BWF:LoudnessValue"; - else if (!strcmp(k+10, "BWF_LOUDNESS_RANGE")) k="BWF:LoudnessRange"; - else if (!strcmp(k+10, "BWF_MAX_TRUE_PEAK_LEVEL")) k="BWF:MaxTruePeakLevel"; - else if (!strcmp(k+10, "BWF_MAX_MOMENTARY_LOUDNESS")) k="BWF:MaxMomentaryLoudness"; - else if (!strcmp(k+10, "BWF_MAX_SHORT_TERM_LOUDNESS")) k="BWF:MaxShortTermLoudness"; - */ - } - InsertMetadataIncrKeyIfNeeded(metadata, k, elem->value.Get()); - } - for (int i=0; i < elem->elements.GetSize(); ++i) - { - wdl_xml_element *elem2=elem->elements.Get(i); - UnpackXMLElement(pre, elem2, metadata); - } -} - -bool UnpackIXMLChunk(const char *buf, int buflen, - WDL_StringKeyedArray *metadata) -{ - if (!buf || !buflen || !metadata) return false; - - while (buflen > 20 && strnicmp(buf, "", 8)) - { - ++buf; - --buflen; - } - if (buflen >= 20) - { - wdl_xml_parser xml(buf, buflen); - if (!xml.parse() && xml.element_root) - { - UnpackXMLElement("IXML", xml.element_root, metadata); - return true; - } - } - - return false; -} - -bool IsXMPMetadata(const char *name, WDL_FastString *key) -{ - if (!name || !name[0] || !key) return false; - - // returns true if this XMP schema is one we know/care about - if (!strnicmp(name, "xmpDM:", 6) && name[6]) - { - key->SetFormatted(512, "XMP:dm/%s", name+6); - return true; - } - if (!strnicmp(name, "dc:", 3) && name[3]) - { - key->SetFormatted(512, "XMP:dc/%s", name+3); - return true; - } - return false; -} - -double UnpackXMPTimestamp(wdl_xml_element *elem) -{ - double tval=-1.0; - int num=0, denom=0; - for (int i=0; i < elem->attributes.GetSize(); ++i) - { - char *attr; - const char *val=elem->attributes.Enumerate(i, &attr); - if (!strcmp(attr, "xmpDM:scale") && val && val[0]) - { - if (sscanf(val, "%d/%d", &num, &denom) != 2) num=denom=0; - } - else if (!strcmp(attr, "xmpDM:value") && val && val[0]) - { - tval=atof(val); - } - } - if (tval >= 0.0 && num > 0 && denom > 0) - { - return tval*(double)num/(double)denom; - } - return -1.0; -} - -const char *GetXMPSubElement(wdl_xml_element *elem, const char *name) -{ - for (int i=0; i < elem->elements.GetSize(); ++i) - { - wdl_xml_element *elem2=elem->elements.Get(i); - if (!strcmp(elem2->name, name)) return elem2->value.Get(); // may be "" - } - return NULL; // element does not exist -} - -bool IsXMPResourceList(wdl_xml_element *elem) -{ - if (!strcmp(elem->name, "rdf:li")) - { - const char *val=elem->get_attribute("rdf:parseType"); - if (val && !strcmp(val, "Resource")) return true; - } - return false; -} - -// keep in sync with metadata.cpp:XMP_MARKER_RESOLUTION -#define XMP_MARKER_RESOLUTION 1000000 - -// todo generic PopulateCuesFromMetadata function metadata => list of REAPERCues - -void UnpackXMPTrack(wdl_xml_element *elem, WDL_StringKeyedArray *metadata) -{ - int num_markers=0; - WDL_FastString key, val; - for (int i=0; i < elem->elements.GetSize(); ++i) - { - wdl_xml_element *elem2=elem->elements.Get(i); - if (!strcmp(elem2->name, "rdf:Bag")) - { - for (int i2=0; i2 < elem2->elements.GetSize(); ++i2) - { - wdl_xml_element *elem3=elem2->elements.Get(i2); - if (IsXMPResourceList(elem3)) - { - const char *track_type=GetXMPSubElement(elem3, "xmpDM:trackType"); - const char *frame_rate=GetXMPSubElement(elem3, "xmpDM:frameRate"); - if (track_type && frame_rate && !strcmp(track_type, "Cue")) - { - double marker_resolution=0; - if (frame_rate[0] == 'f') marker_resolution=atof(frame_rate+1); - // todo parse other resolution types - if (marker_resolution > 0.0) - { - double marker_convert=XMP_MARKER_RESOLUTION/marker_resolution; - for (int i3=0; i3 < elem3->elements.GetSize(); ++i3) - { - wdl_xml_element *elem4=elem3->elements.Get(i3); - if (!strcmp(elem4->name, "xmpDM:markers")) - { - for (int i4=0; i4 < elem4->elements.GetSize(); ++i4) - { - wdl_xml_element *elem5=elem4->elements.Get(i4); - if (!strcmp(elem5->name, "rdf:Seq")) - { - for (int i5=0; i5 < elem5->elements.GetSize(); ++i5) - { - wdl_xml_element *elem6=elem5->elements.Get(i4); - const char *start_time=GetXMPSubElement(elem6, "xmpDM:startTime"); - const char *duration=GetXMPSubElement(elem6, "xmpDM:duration"); - const char *marker_name=GetXMPSubElement(elem6, "xmpDM:name"); - if (start_time) - { - double st=atof(start_time)*marker_convert; - double et = st + (duration ? atof(duration)*marker_convert : 0.0); - key.SetFormatted(512, "XMP:MARK%03d", num_markers++); - val.SetFormatted(512, "%.0f:%.0f:", st, et); - if (marker_name && marker_name[0]) val.Append(marker_name); - else val.AppendFormatted(512, "Marker %d", num_markers); - metadata->Insert(key.Get(), strdup(val.Get())); - } - } - } - } - } - } - } - } - } - } - } - } -} - -void UnpackXMPDescription(const char *curkey, wdl_xml_element *elem, - WDL_StringKeyedArray *metadata) -{ - if (!strcmp(elem->name, "xmpDM:Tracks")) - { - // xmp "tracks" are collections of markers and other related data, - // we can parse the markers (at least ones we wronte) but otherwise - // we can ignore this entire block - UnpackXMPTrack(elem, metadata); - return; - } - - if (!strcmp(elem->name, "xmpDM:relativeTimestamp")) - { - double tval=UnpackXMPTimestamp(elem); - if (tval >= 0.0) - { - char buf[512]; - snprintf(buf, sizeof(buf), "%.0f", floor(tval*1000.0)); - metadata->Insert("XMP:dm/relativeTimestamp", strdup(buf)); - } - return; - } - - WDL_FastString key; - int i; - for (i=0; i < elem->attributes.GetSize(); ++i) - { - char *attr; - const char *val=elem->attributes.Enumerate(i, &attr); - if (IsXMPMetadata(attr, &key) && val && val[0]) - { - metadata->Insert(key.Get(), strdup(val)); - } - } - - if (IsXMPMetadata(elem->name, &key)) curkey=key.Get(); - if (curkey && elem->value.Get()[0]) - { - InsertMetadataIncrKeyIfNeeded(metadata, curkey, elem->value.Get()); - } - - for (i=0; i < elem->elements.GetSize(); ++i) - { - wdl_xml_element *elem2=elem->elements.Get(i); - UnpackXMPDescription(curkey, elem2, metadata); - } -} - -void UnpackXMPElement(wdl_xml_element *elem, WDL_StringKeyedArray *metadata) -{ - if (!strcmp(elem->name, "rdf:Description")) - { - // everything we care about is in this block - UnpackXMPDescription(NULL, elem, metadata); - return; - } - - for (int i=0; i < elem->elements.GetSize(); ++i) - { - wdl_xml_element *elem2=elem->elements.Get(i); - UnpackXMPElement(elem2, metadata); - } -} - -bool UnpackXMPChunk(const char *buf, int buflen, - WDL_StringKeyedArray *metadata) -{ - if (!buf || !buflen || !metadata) return false; - - wdl_xml_parser xmp(buf, buflen); - if (!xmp.parse() && xmp.element_root) - { - UnpackXMPElement(xmp.element_root, metadata); - return true; - } - - return false; -} - - -// metadata is passed as an assocarray of id=>value strings, -// where id has the form "scheme:identifier" -// example "ID3:TIT2", "INFO:IPRD", "VORBIS:ALBUM", etc -// for user-defined metadata, the form is extended to "scheme:identifier:key", -// example "ID3:TXXX:mykey", "VORBIS:USER:mykey", etc -// id passed to this function is just "identifier:key" part -// NOTE: WDL/lameencdec and WDL/vorbisencdec have copies of this, so edit them if this changes -bool ParseUserDefMetadata(const char *id, const char *val, - const char **k, const char **v, int *klen, int *vlen) -{ - const char *sep=strchr(id, ':'); - if (sep) // key encoded in id, version >= 6.12 - { - *k=sep+1; - *klen=strlen(*k); - *v=val; - *vlen=strlen(*v); - return true; - } - - sep=strchr(val, '='); - if (sep) // key encoded in value, version <= 6.11 - { - *k=val; - *klen=sep-val; - *v=sep+1; - *vlen=strlen(*v); - return true; - } - - // no key, version <= 6.11 - *k="User"; - *klen=strlen(*k); - *v=val; - *vlen=strlen(*v); - return false; -} - - -bool HasScheme(const char *scheme, WDL_StringKeyedArray *metadata) -{ - if (!scheme || !scheme[0] || !metadata) return false; - - bool ismatch=false; - int idx=metadata->LowerBound(scheme, &ismatch); - const char *key=NULL; - metadata->Enumerate(idx, &key); - if (key && !strnicmp(key, scheme, strlen(scheme))) return true; - return false; -} - - -WDL_INT64 _ATOI64(const char *str) -{ - bool neg=false; - if (*str == '-') { neg=true; str++; } - WDL_INT64 v=0; - while (*str >= '0' && *str <= '9') - { - v = (v*10) + (WDL_INT64) (neg ? -(*str - '0') : (*str - '0')); - str++; - } - return v; -} - - -int PackIXMLChunk(WDL_HeapBuf *hb, WDL_StringKeyedArray *metadata, int padtolen) -{ - if (!hb || !metadata) return 0; - - if (!HasScheme("IXML", metadata) && - !HasScheme("ASWG", metadata) && - !HasScheme("BWF", metadata)) - { - return 0; - } - - int olen=hb->GetSize(); - - WDL_FastString ixml; - const char *ixml_open=""; - const char *need_close=NULL; - int junklen=0; - - for (int i=0; i < metadata->GetSize(); ++i) - { - const char *key; - const char *val=metadata->Enumerate(i, &key); - if (!key || !key[0] || !val || !val[0]) continue; - - const char *sec = - !strncmp(key, "ASWG:", 5) ? "ASWG" : - !strncmp(key, "BWF:", 4) ? "BWF" : - !strncmp(key, "IXML:USER:", 10) ? "USER" : - !strncmp(key, "IXML:", 5) ? "IXML" : - NULL; - if (!sec) continue; - - key += strlen(sec)+1; - if (!strcmp(sec, "BWF")) - { - if (!strcmp(key, "Description")) key="BWF_DESCRIPTION"; - else if (!strcmp(key, "Originator")) key="BWF_ORIGINATOR"; - else if (!strcmp(key, "OriginatorReference")) key="BWF_ORIGINATOR_REFERENCE"; - else if (!strcmp(key, "OriginationDate")) key="BWF_ORIGINATION_DATE"; - else if (!strcmp(key, "OriginationTime")) key="BWF_ORIGINATION_TIME"; - else if (!strcmp(key, "TimeReference")) key="BWF_TIME_REFERENCE"; - else if (!strcmp(key, "Version")) key="BWF_VERSION"; - else if (!strcmp(key, "LoudnessValue")) key="BWF_LOUDNESS_VALUE"; - else if (!strcmp(key, "LoudnessRange")) key="BWF_LOUDNESS_RANGE"; - else if (!strcmp(key, "MaxTruePeakLevel")) key="BWF_MAX_TRUE_PEAK_LEVEL"; - else if (!strcmp(key, "MaxMomentaryLoudness")) key="BWF_MAX_MOMENTARY_LOUDNESS"; - else if (!strcmp(key, "MaxShortTermLoudness")) key="BWF_MAX_SHORT_TERM_LOUDNESS"; - else continue; - } - - if (!ixml.GetLength()) ixml.Append(ixml_open); - - if (need_close && strcmp(need_close, sec)) - { - ixml.AppendFormatted(512, "", need_close); - need_close=NULL; - } - if (!need_close && strcmp(sec, "IXML")) - { - ixml.AppendFormatted(512, "<%s>", sec); - need_close=sec; - } - - if (!strcmp(key, "BWF_TIME_REFERENCE")) - { - WDL_UINT64 pos=_ATOI64(val); - int hi=pos>>32, lo=(pos&0xFFFFFFFF); - ixml.AppendFormatted(4096, "<%s_HIGH>%d", key, hi, key); - ixml.AppendFormatted(4096, "<%s_LOW>%d", key, lo, key); - continue; - } - - if (!strcmp(sec, "USER")) - { - const char *k, *v; - int klen, vlen; - ParseUserDefMetadata(key, val, &k, &v, &klen, &vlen); - key=k; - val=v; - } - - if (!strncmp(val, "#junk#", 6)) - { - junklen += 11+2*strlen(key)+strlen(val); - continue; - } - - ixml.Append("<"); - XMLCompliantAppend(&ixml, key, false); - ixml.Append(">"); - XMLCompliantAppend(&ixml, val, true); - ixml.Append(""); - } - if (need_close) - { - ixml.AppendFormatted(512, "", need_close); - } - - if (ixml.GetLength()) - { - ixml.Append(""); - int ixmllen=ixml.GetLength(); - int len=ixmllen+1+junklen; - if (len < padtolen) len=padtolen; - if (len&1) ++len; - unsigned char *p=(unsigned char*)hb->Resize(olen+len); - if (p) - { - memcpy(p+olen, ixml.Get(), ixmllen); - memset(p+olen+ixmllen, 0, len-ixmllen); - } - } - - return hb->GetSize()-olen; -} - - -int PackXMPChunk(WDL_HeapBuf *hb, WDL_StringKeyedArray *metadata) -{ - if (!hb || !metadata) return 0; - - if (!HasScheme("XMP", metadata)) return 0; - - int olen=hb->GetSize(); - - static const char *xmp_hdr= - "" - "" - "" - "" - "" - "" - ""; - - WDL_FastString xmp(xmp_hdr); - - for (int pass=0; pass < 2; ++pass) // attributes, then elements - { - if (pass) xmp.Append(">"); - for (int i=0; i < metadata->GetSize(); ++i) - { - const char *key; - const char *val=metadata->Enumerate(i, &key); - if (!key || !key[0] || !val || !val[0]) continue; - - if (!strncmp(key, "XMP:", 4) && key[4]) - { - key += 4; - const char *prefix = // xmp schema - !strncmp(key, "dc/", 3) ? "dc" : - !strncmp(key, "dm/", 3) ? "xmpDM" : NULL; - if (prefix && key[3]) - { - if (!strcmp(key, "dm/markers")) continue; - - if (!strcmp(key, "dc/description") || !strcmp(key, "dc/title")) - { - // elements - if (!pass) continue; - - key += 3; - const char *lang=metadata->Get("XMP:dc/language"); - if (!lang) lang="x-default"; - xmp.AppendFormatted(1024, "<%s:%s>", prefix, key); - xmp.AppendFormatted(1024, "", lang); - xmp.Append(val); - xmp.Append(""); - xmp.AppendFormatted(1024, "", prefix, key); - } - else if (!strcmp(key, "dm/relativeTimestamp")) - { - // element - if (!pass) continue; - - key += 3; - xmp.AppendFormatted(1024, "<%s:%s xmpDM:value=\"%s\" xmpDM:scale=\"1/1000\"/>", - prefix, key, val); - } - else - { - // attributes - if (pass) continue; - - key += 3; - xmp.AppendFormatted(1024, " %s:%s=\"%s\"", prefix, key, val); - } - } - } - } - } - - static const char *track_hdr1= - "" - "" - "" - "Cue" - "f"; - static const char *track_hdr2= - "" - "" - ""; - static const char *track_ftr= - "" - "" - "" - "" - ""; - - char buf[128]; - int cnt=0; - for (int i=0; i < 1000; ++i) - { - snprintf(buf, sizeof(buf), "XMP:MARK%03d", i); - const char *val=metadata->Get(buf); - if (!val || !val[0]) break; - - const char *sep1=strchr(val, ':'); - if (WDL_NOT_NORMALLY(!sep1)) break; - double st=atof(val); - double et=atof(sep1+1); - if (WDL_NOT_NORMALLY(st < 0.0 || et < st)) break; - const char *sep2=strchr(sep1+1, ':'); - const char *name = sep2 ? sep2+1 : ""; // might need to make this xml compliant? - - if (!cnt++) xmp.AppendFormatted(1024, "%s%d%s", track_hdr1, XMP_MARKER_RESOLUTION, track_hdr2); - - xmp.Append(""); - xmp.AppendFormatted(1024, "%.0f", st); - if (et > st) xmp.AppendFormatted(1024, "%.0f", et-st); - if (name[0]) xmp.AppendFormatted(1024, "%s", name); - xmp.Append(""); - } - if (cnt) xmp.Append(track_ftr); - - xmp.Append(xmp_ftr); - - int xmplen=xmp.GetLength(); - int len=xmplen+1; - if (len&1) ++len; - unsigned char *p=(unsigned char*)hb->Resize(olen+len); - if (p) - { - memcpy(p+olen, xmp.Get(), xmplen); - memset(p+olen+xmplen, 0, len-xmplen); - } - - return hb->GetSize()-olen; -} - -int PackVorbisFrame(WDL_HeapBuf *hb, WDL_StringKeyedArray *metadata, bool for_vorbis) -{ - if (!hb || !metadata) return 0; - - // for vorbis, we need an empty frame even if there's no metadata - if (!for_vorbis && !HasScheme("VORBIS", metadata)) return 0; - - int olen=hb->GetSize(); - - const char *vendor="REAPER"; - const int vendorlen=strlen(vendor); - int framelen=4+vendorlen+4+for_vorbis; - - int i, tagcnt=0; - for (i=0; i < metadata->GetSize(); ++i) - { - const char *key; - const char *val=metadata->Enumerate(i, &key); - if (!key || !key[0] || !val || !val[0]) continue; - if (!strncmp(key, "VORBIS:", 7) && key[7]) - { - key += 7; - const char *k=key, *v=val; - int klen=strlen(k), vlen=strlen(v); - if (!strncmp(key, "USER", 4)) - { - ParseUserDefMetadata(key, val, &k, &v, &klen, &vlen); - } - - int taglen=4+klen+1+vlen; - if (framelen+taglen >= 0xFFFFFF) break; - framelen += taglen; - ++tagcnt; - } - } - - unsigned char *buf=(unsigned char*)hb->Resize(olen+framelen)+olen; - if (buf) - { - unsigned char *p=buf; - memcpy(p, &vendorlen, 4); - p += 4; - memcpy(p, vendor, vendorlen); - p += vendorlen; - memcpy(p, &tagcnt, 4); - p += 4; - - for (i=0; i < metadata->GetSize(); ++i) - { - const char *key; - const char *val=metadata->Enumerate(i, &key); - if (!key || !key[0] || !val || !val[0]) continue; - if (!strncmp(key, "VORBIS:", 7) && key[7]) - { - key += 7; - const char *k=key, *v=val; - int klen=strlen(k), vlen=strlen(v); - if (!strncmp(key, "USER", 4)) - { - ParseUserDefMetadata(key, val, &k, &v, &klen, &vlen); - } - - int taglen=klen+1+vlen; - memcpy(p, &taglen, 4); - p += 4; - while (*k) - { - *p++ = (*k >= ' ' && *k <= '}' && *k != '=') ? *k : ' '; - k++; - } - *p++='='; - memcpy(p, v, vlen); - p += vlen; - - if (!--tagcnt) break; - } - } - - if (for_vorbis) *p++=1; // framing bit - - if (WDL_NOT_NORMALLY(p-buf != framelen) || framelen > 0xFFFFFF) - { - hb->Resize(olen); - } - } - - return hb->GetSize()-olen; -} - -bool UnpackVorbisFrame(unsigned char *frame, int framelen, - WDL_StringKeyedArray *metadata) -{ - if (!frame || !framelen || !metadata) return 0; - - char *p=(char*)frame; - - int vendor_len=*(int*)p; - if (4+vendor_len+4 > framelen) return false; - - p += 4+vendor_len; - int tagcnt=*(int*)p; - p += 4; - - WDL_String str; - int pos=4+vendor_len+4; - while (pos < framelen && tagcnt--) - { - int taglen=*(int*)p; - p += 4; - if (pos+taglen > framelen) return false; - str.Set("VORBIS:"); - str.Append(p, taglen); - p += taglen; - const char *sep=strchr(str.Get(), '='); - if (!sep) return false; - *(char*)sep=0; - metadata->Insert(str.Get(), strdup(sep+1)); - } - - return (pos == framelen && tagcnt == 0); -} - - -#define _AddInt32LE(i) \ - *p++=((i)&0xFF); \ - *p++=(((i)>>8)&0xFF); \ - *p++=(((i)>>16)&0xFF); \ - *p++=(((i)>>24)&0xFF); - -#define _GetInt32LE(p) \ - (((p)[0])|((p)[1]<<8)|((p)[2]<<16)|((p)[3]<<24)) - - -int PackApeChunk(WDL_HeapBuf *hb, WDL_StringKeyedArray *metadata) -{ - if (!hb || !metadata) return false; - - if (!HasScheme("APE", metadata)) return false; - - int olen=hb->GetSize(); - - int i, apelen=0, cnt=0; - for (i=0; i < metadata->GetSize(); ++i) - { - const char *key; - const char *val=metadata->Enumerate(i, &key); - if (strlen(key) < 5 || strncmp(key, "APE:", 4) || !val || !val[0]) continue; - key += 4; - if (!apelen) apelen=64; // includes header and footer - if (!strncmp(key, "User Defined", 12)) - { - const char *k, *v; - int klen, vlen; - ParseUserDefMetadata(key, val, &k, &v, &klen, &vlen); - apelen += 8+klen+1+vlen; - } - else - { - apelen += 8+strlen(key)+1+strlen(val); - } - ++cnt; - } - if (!apelen) return false; - - unsigned char *buf=(unsigned char*)hb->Resize(olen+apelen)+olen; - if (buf) - { - unsigned char *p=buf; - memcpy(p, "APETAGEX", 8); - p += 8; - _AddInt32LE(2000); // version - _AddInt32LE(apelen-32); // includes footer but not header - _AddInt32LE(cnt); - _AddInt32LE((1<<31)|(1<<30)|(1<<29)); // tag contains header and footer, this is the header - _AddInt32LE(0); - _AddInt32LE(0); - - for (i=0; i < metadata->GetSize(); ++i) - { - const char *key; - const char *val=metadata->Enumerate(i, &key); - if (strlen(key) < 5 || strncmp(key, "APE:", 4) || !val || !val[0]) continue; - key += 4; - const char *k=key, *v=val; - int klen, vlen; - if (!strncmp(key, "User Defined", 12)) - { - ParseUserDefMetadata(key, val, &k, &v, &klen, &vlen); - } - else - { - klen=strlen(k); - vlen=strlen(v); - } - _AddInt32LE(vlen); - _AddInt32LE(0); - while (klen--) - { - *p = (*k >= 0x20 && *k <= 0x7E ? *k : ' '); - ++p; - ++k; - } - *p++=0; - memcpy(p, v, vlen); - p += vlen; - } - - memcpy(p, "APETAGEX", 8); - p += 8; - _AddInt32LE(2000); // version - _AddInt32LE(apelen-32); // includes footer but not header - _AddInt32LE(cnt); - _AddInt32LE((1<<31)|(1<<30)|(1<<28)); // tag contains header and footer, this is the footer - _AddInt32LE(0); - _AddInt32LE(0); - - if (WDL_NOT_NORMALLY(p-buf != apelen)) hb->Resize(olen); - } - - return hb->GetSize()-olen; -} - - -const char *EnumMetadataSchemeFromFileType(const char *filetype, int idx) -{ - if (!filetype || !filetype[0]) return NULL; - - if (filetype[0] == '.') ++filetype; - if (!stricmp(filetype, "bwf")) filetype="wav"; - else if (!stricmp(filetype, "opus")) filetype="ogg"; - else if (!stricmp(filetype, "aiff")) filetype="aif"; - else if (!stricmp(filetype, "caff")) filetype="caf"; - - static const char *WAV_SCHEMES[]= - { - "BWF", "INFO", "IXML", "ASWG", "XMP", "AXML", "CART", "ID3", - }; - static const char *MP3_SCHEMES[]= - { - "ID3", "APE", "IXML", "ASWG", "XMP", - }; - static const char *FLAC_SCHEMES[]= - { - "VORBIS", "BWF", "IXML", "ASWG", "XMP", - }; - static const char *OGG_SCHEMES[]= - { - "VORBIS", - }; - static const char *WV_SCHEMES[]= - { - "BWF", "APE", - }; - static const char *AIF_SCHEMES[]= - { - "IFF", "XMP", "ID3" - }; - static const char *CAF_SCHEMES[]= - { - "CAFINFO", - }; - static const char *RX2_SCHEMES[]= - { - "REX", - }; - -#define DO_SCHEME_MAP(X) if (!stricmp(filetype, #X)) \ - return idx < sizeof(X##_SCHEMES)/sizeof(X##_SCHEMES[0]) ? X##_SCHEMES[idx] : NULL; - - DO_SCHEME_MAP(WAV); - DO_SCHEME_MAP(MP3); - DO_SCHEME_MAP(FLAC); - DO_SCHEME_MAP(OGG); - DO_SCHEME_MAP(WV); - DO_SCHEME_MAP(AIF); - DO_SCHEME_MAP(CAF); - DO_SCHEME_MAP(RX2); - -#undef DO_SCHEME_MAP - - return NULL; -} - - -bool EnumMetadataKeyFromMexKey(const char *mexkey, int idx, char *key, int keylen) -{ - if (!mexkey || !mexkey[0] || idx < 0 || !key || !keylen) return false; - - // TO_DO_IF_METADATA_UPDATE - // "TITLE", "ARTIST", "ALBUM", "YEAR", "GENRE", "COMMENT", "DESC", "BPM", "KEY", "DB_CUSTOM", "TRACKNUMBER" - - if (!strcmp(mexkey, "DATE")) mexkey="YEAR"; - // callers handle PREFPOS - - // general priority order here: - // BWF - // INFO - // ID3 - // APE - // VORBIS - // CART - // IXML - // ASWG - // XMP - // CAFINFO - // IFF - // REX - - static const char *TITLE_KEYS[]= - { - "INFO:INAM", - "ID3:TIT2", - "APE:Title", - "VORBIS:TITLE", - "CART:Title", - "IXML:PROJECT", - "ASWG:project", - "XMP:dc/title", - "CAFINFO:title", - "IFF:NAME", - "REX:Name", - }; - static const char *ARTIST_KEYS[]= - { - "INFO:IART", - "ID3:TPE1", - "APE:Artist", - "VORBIS:ARTIST", - "CART:Artist", - "XMP:dm/artist", - "CAFINFO:artist", - "IFF:AUTH", - }; - static const char *ALBUM_KEYS[]= - { - "INFO:IALB", - "INFO:IPRD", - "ID3:TALB", - "APE:Album", - "VORBIS:ALBUM", - "XMP:dm/album", - "CAFINFO:album", - }; - static const char *YEAR_KEYS[]= // really DATE - { - "BWF:OriginationDate", - "INFO:ICRD", - "ID3:TYER", - "ID3:TDRC", - "APE:Year", - "APE:Record Date", - "VORBIS:DATE", - "CART:StartDate", - "XMP:dc/date", - "CAFINFO:year", - }; - static const char *GENRE_KEYS[]= - { - "INFO:IGNR", - "ID3:TCON", - "APE:Genre", - "VORBIS:GENRE", - "CART:Category", - "XMP:dm/genre", - "CAFINFO:genre", - }; - static const char *COMMENT_KEYS[]= - { - "INFO:ICMT", - "ID3:COMM", - "APE:Comment", - "VORBIS:COMMENT", - "CART:TagText", - "IXML:NOTE", - "ASWG:notes", - "XMP:dm/logComment", - "CAFINFO:comments", - "CAFINFO:comment", // spec is "comments" but ffmpeg may write "comment" - "REX:FreeText", - }; - static const char *DESC_KEYS[]= - { - "BWF:Description", - "INFO:ISBJ", - "INFO:IKEY", - "ID3:TIT3", - "APE:Subtitle", - "VORBIS:DESCRIPTION", - "XMP:dc/description", - "IFF:ANNO", - }; - static const char *BPM_KEYS[]= - { - "ACID:BPM", - "ID3:TBPM", - "APE:BPM", - "VORBIS:BPM", - "XMP:dm/tempo", - "CAFINFO:tempo", - }; - static const char *KEY_KEYS[]= - { - "ACID:KEY", - "ID3:TKEY", - "APE:Key", - "VORBIS:KEY", - "XMP:dm/key", - "CAFINFO:key signature", - }; - static const char *TRACKNUMBER_KEYS[]= - { - "INFO:TRCK", - "ID3:TRCK", - "APE:Track", - "VORBIS:TRACKNUMBER", - "CART:CutID", - // "IXML:TRACK", - "XMP:dm/trackNumber", - "CAFINFO:track number", - }; - -#define DO_MEXKEY_MAP(K) \ -if (!strcmp(mexkey, #K)) \ -{ \ - if (idx >= sizeof(K##_KEYS)/sizeof(K##_KEYS[0])) return false; \ - lstrcpyn(key, K##_KEYS[idx], keylen); return true; \ -} - - key[0]=0; - DO_MEXKEY_MAP(TITLE); - DO_MEXKEY_MAP(ARTIST); - DO_MEXKEY_MAP(ALBUM); - DO_MEXKEY_MAP(TRACKNUMBER); - DO_MEXKEY_MAP(YEAR); - DO_MEXKEY_MAP(GENRE); - DO_MEXKEY_MAP(COMMENT); - DO_MEXKEY_MAP(DESC); - DO_MEXKEY_MAP(BPM); - DO_MEXKEY_MAP(KEY); - -#undef DO_MEXKEY_MAP - - static const char *DB_CUSTOM_KEYS[]= - { - "ID3:TXXX", - "APE", - "VORBIS", - "IXML:USER", - }; - if (idx >= sizeof(DB_CUSTOM_KEYS)/sizeof(DB_CUSTOM_KEYS[0])) return false; - if (!strcmp(mexkey, "DB_CUSTOM")) mexkey="REAPER"; - snprintf(key, keylen, "%s:%s", DB_CUSTOM_KEYS[idx], mexkey); - return true; -} - -const char *GetMexKeyFromMetadataKey(const char *key) -{ - int i=0; - const char *mexkey; - while ((mexkey=EnumMexKeys(i++))) - { - int j=0; - char tkey[256]; - while (EnumMetadataKeyFromMexKey(mexkey, j++, tkey, sizeof(tkey)) && tkey[0]) - { - if (!strcmp(key, tkey)) return mexkey; - } - } - return NULL; -} - -bool HandleMexMetadataRequest(const char *mexkey, char *buf, int buflen, - WDL_StringKeyedArray *metadata) -{ - if (!mexkey || !mexkey[0] || !buf || !buflen || !metadata) return false; - buf[0]=0; - - buf[0]=0; - int i=0; - char key[256]; - while (EnumMetadataKeyFromMexKey(mexkey, i++, key, sizeof(key)) && key[0]) - { - const char *val=metadata->Get(key); - if (val && val[0]) - { - lstrcpyn(buf, val, buflen); - return true; - } - } - - if (strchr(mexkey, ':')) - { - const char *val=metadata->Get(mexkey); - if (val && val[0]) - { - lstrcpyn(buf, val, buflen); - return true; - } - } - - return false; -} - - -void WriteMetadataPrefPos(double prefpos, int srate, // prefpos <= 0.0 to clear - WDL_StringKeyedArray *metadata) -{ - if (!metadata) return; - - metadata->Delete("BWF:TimeReference"); - metadata->Delete("ID3:TXXX:TIME_REFERENCE"); - metadata->Delete("IXML:BEXT:BWF_TIME_REFERENCE_HIGH"); - metadata->Delete("IXML:BEXT:BWF_TIME_REFERENCE_LOW"); - metadata->Delete("XMP:dm/relativeTimestamp"); - metadata->Delete("VORBIS:TIME_REFERENCE"); - - if (prefpos > 0.0 && srate > 1) - { - char buf[128]; - if (srate > 0.0) - { - snprintf(buf, sizeof(buf), "%.0f", floor(prefpos*(double)srate)); - metadata->Insert("BWF:TimeReference", strdup(buf)); - // BWF:TimeReference causes IXML:BEXT element to be written as well - metadata->Insert("ID3:TXXX:TIME_REFERENCE", strdup(buf)); - metadata->Insert("VORBIS:TIME_REFERENCE", strdup(buf)); - } - snprintf(buf, sizeof(buf), "%.0f", floor(prefpos*1000.0)); - metadata->Insert("XMP:dm/relativeTimestamp", strdup(buf)); - } -} - - -void AddMexMetadata(WDL_StringKeyedArray *mex_metadata, - WDL_StringKeyedArray *metadata, int srate) -{ - if (!mex_metadata || !metadata) return; - - for (int idx=0; idx < mex_metadata->GetSize(); ++idx) - { - const char *mexkey; - const char *val=mex_metadata->Enumerate(idx, &mexkey); - - if (!strcmp(mexkey, "PREFPOS")) - { - WDL_UINT64 ms = val && val[0] ? ParseUInt64(val) : 0; - WriteMetadataPrefPos((double)ms/1000.0, srate, metadata); - // caller may still have to do stuff if prefpos is represented - // in some other way outside the metadata we handle, like wavpack - continue; - } - - int i=0; - char key[256]; - while (EnumMetadataKeyFromMexKey(mexkey, i++, key, sizeof(key)) && key[0]) - { - if (val && val[0]) metadata->Insert(key, strdup(val)); - else metadata->Delete(key); - } - } -} - - -void DumpMetadata(WDL_FastString *str, WDL_StringKeyedArray *metadata) -{ - if (!str || !metadata || !metadata->GetSize()) return; - - char scheme[256]; - scheme[0]=0; - - char buf[2048]; - int j=0; - const char *mexkey, *mexdesc; - while ((mexkey=EnumMexKeys(j++, &mexdesc))) - { - if (HandleMexMetadataRequest(mexkey, buf, sizeof(buf), metadata)) - { - if (!scheme[0]) - { - lstrcpyn(scheme, "mex", sizeof(scheme)); - str->Append("Metadata:\r\n"); - } - str->AppendFormatted(4096, " %s:%s%s\r\n", - mexdesc, strchr(buf, '\n') ? "\r\n" : " ", buf); - } - } - - for (int i=0; i < metadata->GetSize(); ++i) - { - const char *key; - const char *val=metadata->Enumerate(i, &key); - if (!key || !key[0] || !val || !val[0] || !strncmp(val, "[Binary data]", 13)) continue; - - const char *sep=strchr(key, ':'); - if (sep) - { - int slen=wdl_min(sep-key, sizeof(scheme)-1); - if (strncmp(scheme, key, slen)) - { - lstrcpyn(scheme, key, slen+1); - str->AppendFormatted(256, "%s tags:\r\n", scheme); - } - key += slen+1; - } - str->AppendFormatted(4096, " %s:%s%s\r\n", - key, strchr(val, '\n') ? "\r\n" : " ", val); - } - - int unk_cnt=0; - for (int i=0; i < metadata->GetSize(); ++i) - { - const char *key; - const char *val=metadata->Enumerate(i, &key); - if (key && key[0] && val && (!val[0] || !strncmp(val, "[Binary data]", 13))) - { - if (!unk_cnt++) str->Append("Other file sections:\r\n"); - str->AppendFormatted(4096, " %s%s\r\n", key, - !strnicmp(key, "smed", 4) ? - " (proprietary Soundminer metadata)" : ""); - } - } -} - -void CopyMetadata(WDL_StringKeyedArray *src, WDL_StringKeyedArray *dest) -{ - if (!dest || !src) return; - - dest->DeleteAll(false); - for (int i=0; i < src->GetSize(); ++i) - { - const char *key; - const char *val=src->Enumerate(i, &key); - dest->AddUnsorted(key, strdup(val)); - } - dest->Resort(); // safe in case src/dest have diff sort attributes -} - - -bool CopyFileData(WDL_FileRead *fr, WDL_FileWrite *fw, WDL_INT64 len) -{ - while (len) - { - char tmp[32768]; - const int amt = (int) (wdl_min(len,sizeof(tmp))); - const int rd = fr->Read(tmp, amt); - if (rd != amt) return false; - if (fw->Write(tmp, rd) != rd) return false; - len -= rd; - } - return true; -} - - -bool EnumVorbisChapters(WDL_StringKeyedArray *metadata, int idx, - double *pos, const char **name) -{ - if (!metadata) return false; - - int cnt=0; - bool ismatch=false; - const char *prev=NULL; - int i=metadata->LowerBound("VORBIS:CHAPTER", &ismatch); - for (; i < metadata->GetSize(); ++i) - { - const char *key; - const char *val=metadata->Enumerate(i, &key); - if (strncmp(key, "VORBIS:CHAPTER", 14)) return false; - if (!prev || strncmp(key, prev, 17)) - { - prev=key; - if (idx == cnt) - { - if (!key[17] && val && val[0]) - { - // VORBIS:CHAPTER001 => 00:00:00.000 - if (pos) - { - int hh=0, mm=0, ss=0, ms=0; - if (sscanf(val, "%d:%d:%d.%d", &hh, &mm, &ss, &ms) == 4) - { - *pos=(double)hh*3600.0+(double)mm*60.0+(double)ss+(double)ms*0.001; - } - } - if (name) - { - val=metadata->Enumerate(i+1, &key); - if (!strncmp(key, prev, 17) && !strcmp(key+17, "NAME")) - { - // VORBIS:CHAPTER001NAME => chapter name - *name=val; - } - } - return true; - } - return false; - } - ++cnt; - } - } - return false; -} - - -#define _AddSyncSafeInt32(i) \ -*p++=(((i)>>21)&0x7F); \ -*p++=(((i)>>14)&0x7F); \ -*p++=(((i)>>7)&0x7F); \ -*p++=((i)&0x7F); - -#define _AddInt32(i) \ -*p++=(((i)>>24)&0xFF); \ -*p++=(((i)>>16)&0xFF); \ -*p++=(((i)>>8)&0xFF); \ -*p++=((i)&0xFF); - -#define _GetSyncSafeInt32(p) \ -(((p)[0]<<21)|((p)[1]<<14)|((p)[2]<<7)|((p)[3])) - -void WriteSyncSafeInt32(WDL_FileWrite *fw, int i) -{ - unsigned char buf[4]; - unsigned char *p=buf; - _AddSyncSafeInt32(i); - fw->Write(buf, 4); -} - - -#define CTOC_NAME "TOC" // arbitrary name of table of contents element - - -static bool _isnum(const char *v, int pos, int len) -{ - for (int i=pos; i < pos+len; ++i) - { - if (v[i] < '0' || v[i] > '9') return false; - } - return true; -} - -int IsID3TimeVal(const char *v) -{ - if (strlen(v) == 4 && _isnum(v, 0, 4)) return 1; - if (strlen(v) == 5 && _isnum(v, 0, 2) && _isnum(v, 3, 2)) return 2; - return 0; -} - -struct ID3RawTag -{ - char key[8]; // we only use 4 chars + nul - WDL_HeapBuf val; // includes everything after taglen (flags, etc) -}; - -int ReadID3Raw(WDL_FileRead *fr, WDL_PtrList *rawtags) -{ - if (!fr || !fr->IsOpen() || !rawtags) return 0; - - unsigned char buf[16]; - if (fr->Read(buf, 10) != 10) return 0; - if (memcmp(buf, "ID3\x04", 4) && memcmp(buf, "ID3\x03", 4)) return 0; - int id3len=_GetSyncSafeInt32(buf+6); - if (!id3len) return 0; - - int rdlen=0; - WDL_HeapBuf hb; - while (rdlen < id3len) - { - if (fr->Read(buf, 8) != 8) return 0; - if (!buf[0]) return 10+id3len; // padding - if ((buf[0] < 'A' || buf[0] > 'Z') && (buf[0] < '0' || buf[0] > '9')) return 0; // unexpected - - int taglen=_GetSyncSafeInt32(buf+4)+2; // include flags in taglen - - unsigned char *p=(unsigned char*)hb.ResizeOK(taglen); - if (!p || fr->Read(p, taglen) != taglen) return 0; - - ID3RawTag *rawtag=rawtags->Add(new ID3RawTag); - memcpy(rawtag->key, buf, 4); - rawtag->key[4]=0; - rawtag->val=hb; - - rdlen += 8+taglen; - if (rdlen == id3len) return 10+id3len; - } - return 0; -} - -void DeleteID3Raw(WDL_PtrList *rawtags, const char *key) -{ - if (!rawtags || !rawtags->GetSize()) return; - if (strncmp(key, "ID3:", 4)) return; - if (WDL_NOT_NORMALLY(strlen(key) < 8)) return; - - key += 4; - const char *subkey=NULL; - int suboffs=0, sublen=0; - if (key[4]) - { - if (!strncmp(key, "TXXX:", 5)) suboffs=3; - else if (!strncmp(key, "PRIV:", 5)) suboffs=2; - if (!suboffs || !key[5]) return; - subkey=key+5; - sublen=strlen(subkey); - } - - for (int i=0; i < rawtags->GetSize(); ++i) - { - ID3RawTag *rawtag=rawtags->Get(i); - if (!strncmp(key, rawtag->key, 4)) - { - if (subkey && - (rawtag->val.GetSize() < sublen+suboffs || - memcmp((unsigned char*)rawtag->val.Get()+suboffs, subkey, sublen))) - { - continue; // key is like ID3:AAAA:BBBB but rawtag->val does not match *BBBB - } - rawtags->Delete(i--, true); - } - } -} - -int PackID3Chunk(WDL_HeapBuf *hb, WDL_StringKeyedArray *metadata, - bool want_embed_otherschemes, int *ixml_lenwritten, int ixml_padtolen, - WDL_PtrList *rawtags) -{ - if (!hb || !metadata) return false; - - bool want_ixml = want_embed_otherschemes && - (HasScheme("IXML", metadata) || HasScheme("ASWG", metadata) || HasScheme("BWF", metadata)); - bool want_xmp = want_embed_otherschemes && HasScheme("XMP", metadata); - if (!HasScheme("ID3", metadata) && !want_ixml && !want_xmp) return false; - - int olen=hb->GetSize(); - - int id3len=0, chapcnt=0; - WDL_TypedQueue toc; - int i; - for (i=0; i < metadata->GetSize(); ++i) - { - const char *key; - const char *val=metadata->Enumerate(i, &key); - if (strlen(key) < 8 || strncmp(key, "ID3:", 4) || !val) continue; - key += 4; - if (!strncmp(key, "TXXX", 4)) - { - const char *k, *v; - int klen, vlen; - ParseUserDefMetadata(key, val, &k, &v, &klen, &vlen); - id3len += 10+1+klen+1+vlen; - } - else if (!strncmp(key, "TIME", 4)) - { - if (IsID3TimeVal(val)) id3len += 10+1+4; - } - else if (key[0] == 'T' && strlen(key) == 4) - { - id3len += 10+1+strlen(val); - } - else if (!strcmp(key, "COMM") || !strcmp(key, "USLT")) - { - id3len += 10+5+strlen(val); - } - else if (!strncmp(key, "CHAP", 4) && chapcnt < 255) - { - const char *c1=strchr(val, ':'); - const char *c2 = c1 ? strchr(c1+1, ':') : NULL; - if (c1) - { - ++chapcnt; - const char *toc_entry=key; // use "CHAP001", etc as the internal toc entry - const char *chap_name = c2 ? c2+1 : NULL; - toc.Add(toc_entry, strlen(toc_entry)+1); - id3len += 10+strlen(toc_entry)+1+16; - if (chap_name) id3len += 10+1+strlen(chap_name)+1; - } - } - } - if (chapcnt) - { - id3len += 10+strlen(CTOC_NAME)+1+2+toc.GetSize(); - } - - WDL_HeapBuf apic_hdr; - int apic_datalen=0; - const char *apic_fn=metadata->Get("ID3:APIC_FILE"); - if (apic_fn && apic_fn[0]) - { - const char *mime=NULL; - const char *ext=WDL_get_fileext(apic_fn); - if (ext && (!stricmp(ext, ".jpg") || !stricmp(ext, ".jpeg"))) mime="image/jpeg"; - else if (ext && !stricmp(ext, ".png")) mime="image/png"; - if (mime) - { - FILE *fp=fopenUTF8(apic_fn, "rb"); // could stat but let's make sure we can open the file - if (fp) - { - fseek(fp, 0, SEEK_END); - apic_datalen=ftell(fp); - fclose(fp); - } - } - if (apic_datalen) - { - const char *t=metadata->Get("ID3:APIC_TYPE"); - int type=-1; - if (t && t[0] >= '0' && t[0] <= '9') type=atoi(t); - if (type < 0 || type >= 16) type=3; // default "Cover (front)" - - const char *desc=metadata->Get("ID3:APIC_DESC"); - if (!desc) desc=""; - int desclen=wdl_min(strlen(desc), 63); - - int apic_hdrlen=1+strlen(mime)+1+1+desclen+1; - char *p=(char*)apic_hdr.Resize(apic_hdrlen); - if (p) - { - *p++=3; // UTF-8 - memcpy(p, mime, strlen(mime)+1); - p += strlen(mime)+1; - *p++=type; - memcpy(p, desc, desclen); - p += desclen; - *p++=0; - id3len += 10+apic_hdrlen+apic_datalen; - } - } - } - - WDL_HeapBuf ixml; - if (want_ixml) - { - PackIXMLChunk(&ixml, metadata, ixml_padtolen); - if (ixml.GetSize()) - { - if (ixml_lenwritten) *ixml_lenwritten=ixml.GetSize(); - id3len += 10+5+ixml.GetSize(); - } - } - - WDL_HeapBuf xmp; - if (want_xmp) - { - PackXMPChunk(&xmp, metadata); - if (xmp.GetSize()) id3len += 10+4+xmp.GetSize(); - } - - if (rawtags) - { - for (int i=0; i < rawtags->GetSize(); ++i) - { - ID3RawTag *rawtag=rawtags->Get(i); - if (WDL_NORMALLY(rawtag && rawtag->key[0] && rawtag->val.GetSize())) - { - id3len += 8+rawtag->val.GetSize(); - } - } - } - - if (id3len) - { - id3len += 10; - unsigned char *buf=(unsigned char*)hb->Resize(olen+id3len)+olen; - if (buf) - { - chapcnt=0; - unsigned char *p=buf; - memcpy(p,"ID3\x04\x00\x00", 6); - p += 6; - _AddSyncSafeInt32(id3len-10); - for (i=0; i < metadata->GetSize(); ++i) - { - const char *key; - const char *val=metadata->Enumerate(i, &key); - if (strlen(key) < 8 || strncmp(key, "ID3:", 4) || !val) continue; - key += 4; - if (!strncmp(key, "TXXX", 4)) - { - memcpy(p, key, 4); - p += 4; - const char *k, *v; - int klen, vlen; - ParseUserDefMetadata(key, val, &k, &v, &klen, &vlen); - _AddSyncSafeInt32(1+klen+1+vlen); - memcpy(p, "\x00\x00\x03", 3); // UTF-8 - p += 3; - memcpy(p, k, klen); - p += klen; - *p++=0; - memcpy(p, v, vlen); - p += vlen; - } - else if (!strncmp(key, "TIME", 4)) - { - int tv=IsID3TimeVal(val); - if (tv) - { - memcpy(p, key, 4); - p += 4; - _AddSyncSafeInt32(1+4); - memcpy(p, "\x00\x00\x03", 3); // UTF-8 - p += 3; - memcpy(p, val, 2); - if (tv == 1) memcpy(p+2, val+2, 2); - else memcpy(p+2, val+3, 2); - p += 4; - } - } - else if (key[0] == 'T' && strlen(key) == 4) - { - memcpy(p, key, 4); - p += 4; - int len=strlen(val); - _AddSyncSafeInt32(1+len); - memcpy(p, "\x00\x00\x03", 3); // UTF-8 - p += 3; - memcpy(p, val, len); - p += len; - } - else if (!strcmp(key, "COMM") || !strcmp(key, "USLT")) - { - // http://www.loc.gov/standards/iso639-2/php/code_list.php - // most apps ignore this, itunes wants "eng" or something locale-specific - const char *lang=NULL; - if (!strcmp(key, "USLT")) lang=metadata->Get("ID3:LYRIC_LANG"); - if (!lang) lang=metadata->Get("ID3:COMM_LANG"); - if (!lang) lang=metadata->Get("ID3:COMMENT_LANG"); - - memcpy(p, key, 4); - p += 4; - int len=strlen(val); - _AddSyncSafeInt32(5+len); - memcpy(p, "\x00\x00\x03", 3); // UTF-8 - p += 3; - if (lang && strlen(lang) >= 3 && - tolower(*lang) >= 'a' && tolower(*lang) <= 'z') - { - *p++=tolower(*lang++); - *p++=tolower(*lang++); - *p++=tolower(*lang++); - *p++=0; - } - else - { - // some apps write "XXX" for "no particular language" - memcpy(p, "XXX\x00", 4); - p += 4; - } - memcpy(p, val, len); - p += len; - } - else if (!strncmp(key, "CHAP", 4) && chapcnt < 255) - { - const char *c1=strchr(val, ':'); - const char *c2 = c1 ? strchr(c1+1, ':') : NULL; - if (c1) - { - // note, the encoding ignores the chapter number (CHAP001, etc) - - ++chapcnt; - const char *toc_entry=key; // use "CHAP001", etc as the internal toc entry - const char *chap_name = c2 ? c2+1 : NULL; - int st=atoi(val); - int et=atoi(c1+1); - - int framelen=strlen(toc_entry)+1+16; - if (chap_name) framelen += 10+1+strlen(chap_name)+1; - - memcpy(p, "CHAP", 4); - p += 4; - _AddSyncSafeInt32(framelen); - memset(p, 0, 2); - p += 2; - memcpy(p, toc_entry, strlen(toc_entry)+1); - p += strlen(toc_entry)+1; - _AddInt32(st); - _AddInt32(et); - memset(p, 0, 8); - p += 8; - - if (chap_name) - { - int name_framelen=1+strlen(chap_name)+1; - memcpy(p, "TIT2", 4); - p += 4; - _AddSyncSafeInt32(name_framelen); - memcpy(p, "\x00\x00\x03", 3); // UTF-8 - p += 3; - memcpy(p, chap_name, strlen(chap_name)+1); - p += strlen(chap_name)+1; - } - } - } - } - - if (chapcnt) - { - int toc_framelen=strlen(CTOC_NAME)+1+2+toc.GetSize(); - memcpy(p, "CTOC", 4); - p += 4; - _AddSyncSafeInt32(toc_framelen); - memset(p, 0, 2); - p += 2; - memcpy(p, CTOC_NAME, strlen(CTOC_NAME)+1); - p += strlen(CTOC_NAME)+1; - *p++=3; // CTOC flags: &1=top level, &2=ordered - *p++=(chapcnt&0xFF); - memcpy(p, toc.Get(), toc.GetSize()); - p += toc.GetSize(); - } - - if (apic_hdr.GetSize() && apic_datalen) - { - memcpy(p, "APIC", 4); - p += 4; - int len=apic_hdr.GetSize()+apic_datalen; - _AddSyncSafeInt32(len); - memcpy(p, "\x00\x00", 2); - p += 2; - memcpy(p, apic_hdr.Get(), apic_hdr.GetSize()); - p += apic_hdr.GetSize(); - FILE *fp=fopenUTF8(apic_fn, "rb"); - if (WDL_NORMALLY(fp)) - { - fread(p, 1, apic_datalen, fp); - fclose(fp); - } - else // uh oh - { - memset(p, 0, apic_datalen); - } - p += apic_datalen; - } - - if (ixml.GetSize()) - { - memcpy(p, "PRIV", 4); - p += 4; - int len=ixml.GetSize()+5; - _AddSyncSafeInt32(len); - memcpy(p, "\x00\x00", 2); - p += 2; - memcpy(p, "iXML\x00", 5); - p += 5; - memcpy(p, ixml.Get(), ixml.GetSize()); - p += ixml.GetSize(); - } - - if (xmp.GetSize()) - { - memcpy(p, "PRIV", 4); - p += 4; - int len=xmp.GetSize()+4; - _AddSyncSafeInt32(len); - memcpy(p, "\x00\x00", 2); - p += 2; - memcpy(p, "XMP\x00", 4); - p += 4; - memcpy(p, xmp.Get(), xmp.GetSize()); - p += xmp.GetSize(); - } - - if (rawtags) - { - for (int i=0; i < rawtags->GetSize(); ++i) - { - ID3RawTag *rawtag=rawtags->Get(i); - if (WDL_NORMALLY(rawtag && rawtag->key[0] && rawtag->val.GetSize())) - { - memcpy(p, rawtag->key, strlen(rawtag->key)); - p += strlen(rawtag->key); - int vallen=rawtag->val.GetSize(); // includes flags - _AddSyncSafeInt32(vallen-2); - memcpy(p, rawtag->val.Get(), vallen); - p += vallen; - } - } - } - - if (WDL_NOT_NORMALLY(p-buf != id3len)) hb->Resize(olen); - } - } - - return hb->GetSize()-olen; -} - -double ReadMetadataPrefPos(WDL_StringKeyedArray *metadata, double srate) -{ - if (!metadata) return -1.0; - - const char *v=metadata->Get("BWF:TimeReference"); - if (!v || !v[0]) v=metadata->Get("ID3:TXXX:TIME_REFERENCE"); - if (!v || !v[0]) v=metadata->Get("VORBIS:TIME_REFERENCE"); - if (v && v[0] && srate > 0.0) - { - WDL_UINT64 i=ParseUInt64(v); - return (double)i/srate; - } - - v=metadata->Get("IXML:BEXT:BWF_TIME_REFERENCE_LOW"); - if (v && v[0] && srate > 0.0) - { - WDL_UINT64 ipos=atoi(v); - v=metadata->Get("IXML:BEXT:BWF_TIME_REFERENCE_HIGH"); - if (v && v[0]) ipos |= ((WDL_UINT64)atoi(v))<<32; - return (double)ipos/srate; - } - - v=metadata->Get("XMP:dm/relativeTimestamp"); - if (v && v[0]) - { - WDL_UINT64 i=ParseUInt64(v); - return (double)i/1000.0; - } - - return -1.0; -} - - -// nch 0 means channel count agnostic -// nch -1 means high order ambisonic, nch must? be an integer squared, layout tag must be or'd with the number of channels -struct ChanLayout { const char *fmts; int nch; const char *desc; int chan_layout, chan_mask; }; -static const ChanLayout CHAN_LAYOUTS[]= -{ - // using Ls/Rs for left side/right side - // using Lb/Rb for left back/right back - - { "cw", 2, "L R", - kAudioChannelLayoutTag_UseChannelBitmap, - kAudioChannelBit_Left | kAudioChannelBit_Right }, - - { "cw", 3, "L R C", - kAudioChannelLayoutTag_UseChannelBitmap, - kAudioChannelBit_Left | kAudioChannelBit_Right | kAudioChannelBit_Center }, - - { "cw", 4, "L R Lb Rb", - kAudioChannelLayoutTag_UseChannelBitmap, - kAudioChannelBit_Left | kAudioChannelBit_Right | - kAudioChannelBit_LeftSurround | kAudioChannelBit_RightSurround }, - - { "cw", 5, "L R C Lb Rb", - kAudioChannelLayoutTag_UseChannelBitmap, - kAudioChannelBit_Left | kAudioChannelBit_Right | kAudioChannelBit_Center | - kAudioChannelBit_LeftSurround | kAudioChannelBit_RightSurround }, - - { "cw", 6, "L R C LFE Lb Rb", - kAudioChannelLayoutTag_UseChannelBitmap, - kAudioChannelBit_Left | kAudioChannelBit_Right | kAudioChannelBit_Center | - kAudioChannelBit_LFEScreen | - kAudioChannelBit_LeftSurround | kAudioChannelBit_RightSurround }, - - { "cw", 6, "L R Lb Rb Ls Rs", - kAudioChannelLayoutTag_UseChannelBitmap, - kAudioChannelBit_Left | kAudioChannelBit_Right | - kAudioChannelBit_LeftSurround | kAudioChannelBit_RightSurround | - kAudioChannelBit_LeftSurroundDirect | kAudioChannelBit_RightSurroundDirect }, - - { "cw", 8, "L R C LFE Lb Rb Ls Rs", - kAudioChannelLayoutTag_UseChannelBitmap, - kAudioChannelBit_Left | kAudioChannelBit_Right | kAudioChannelBit_Center | - kAudioChannelBit_LFEScreen | - kAudioChannelBit_LeftSurround | kAudioChannelBit_RightSurround | - kAudioChannelBit_LeftSurroundDirect | kAudioChannelBit_RightSurroundDirect }, - - { "c", 2, "Mid-Side", kAudioChannelLayoutTag_MidSide, 0 }, - { "c", 2, "Binaural", kAudioChannelLayoutTag_Binaural, 0 }, - { "c", 4, "Ambisonic B-Format - W X Y Z", kAudioChannelLayoutTag_Ambisonic_B_Format, 0 }, - - { "c", 6, "MPEG 5.1A - L R C LFE Lb Rb", kAudioChannelLayoutTag_MPEG_5_1_A, 0 }, - { "c", 6, "MPEG 5.1B - L R Lb Rb C LFE", kAudioChannelLayoutTag_MPEG_5_1_B, 0 }, - { "c", 6, "MPEG 5.1C - L C R Lb Rb LFE", kAudioChannelLayoutTag_MPEG_5_1_C, 0 }, - { "c", 6, "MPEG 5.1D - C L R Lb Rb LFE", kAudioChannelLayoutTag_MPEG_5_1_D, 0 }, - - { "c", 8, "MPEG 7.1A - L R C LFE Lb Rb Lc Rc", kAudioChannelLayoutTag_MPEG_7_1_A, 0 }, - { "c", 8, "MPEG 7.1B - C Lc Rc L R Lb Rb LFE", kAudioChannelLayoutTag_MPEG_7_1_B, 0 }, - { "c", 8, "MPEG 7.1C (SMPTE 7.1) - L R C LFE Ls Rs Lb Rb", kAudioChannelLayoutTag_MPEG_7_1_C, 0 }, - - { "c", 6, "ITU 3.2.1 - L R C LFE Lb Rb", kAudioChannelLayoutTag_ITU_3_2_1, 0 }, - { "c", 8, "ITU 3.4.1 - L R C LFE Lb Rb Rls Rrs", kAudioChannelLayoutTag_ITU_3_4_1, 0 }, - - { "c", -1, "HO Ambisonic SN3D", kAudioChannelLayoutTag_HOA_ACN_SN3D, 0 }, - { "c", -1, "HO Ambisonic N3D", kAudioChannelLayoutTag_HOA_ACN_N3D, 0 }, - - { "c", 8, "Atmos 5.1.2 - L R C LFE Lb Rb Ltm Rtm", kAudioChannelLayoutTag_Atmos_5_1_2, 0 }, - { "c", 12, "Atmos 7.1.4 - L R C LFE Lb Rb Rls Rrs Ltf Rtf Ltr Rtr", kAudioChannelLayoutTag_Atmos_7_1_4, 0 }, - { "c", 16, "Atmos 9.1.6 - L R C LFE Lb Rb Rls Rrs Lw Rw Ltf Rtf Ltm Rtm Ltr Rtr", kAudioChannelLayoutTag_Atmos_9_1_6, 0 }, -}; - -#define LAYOUT_MASK_VALID(layout, mask) \ - (((layout) == kAudioChannelLayoutTag_UseChannelBitmap) == ((mask) != 0)) - - -const char *EnumSupportedChannelLayouts(int idx, char fmt) -{ - int n=0; - for (int i=0; i < sizeof(CHAN_LAYOUTS)/sizeof(CHAN_LAYOUTS[0]); ++i) - { - WDL_ASSERT(LAYOUT_MASK_VALID(CHAN_LAYOUTS[i].chan_layout, CHAN_LAYOUTS[i].chan_mask)); - - if ((!fmt || strchr(CHAN_LAYOUTS[i].fmts, fmt)) && idx == n++) - { - return CHAN_LAYOUTS[i].desc; - } - } - return NULL; -} - - -const char *GetChannelLayoutDesc(int chan_layout, int chan_mask) -{ - if (!LAYOUT_MASK_VALID(chan_layout, chan_mask)) return NULL; - - bool is_match=false; - for (int i=0; i < sizeof(CHAN_LAYOUTS)/sizeof(CHAN_LAYOUTS[0]); ++i) - { - if (CHAN_LAYOUTS[i].chan_mask != 0) - { - if (CHAN_LAYOUTS[i].chan_mask == chan_mask) is_match=true; - } - else if (CHAN_LAYOUTS[i].nch == -1) - { - // high order ambisonic layout tags are OR'd with the actual number of channels - if ((CHAN_LAYOUTS[i].chan_layout&0xFFFF0000) == (chan_layout&0xFFFF0000)) is_match=true; - } - else - { - if (CHAN_LAYOUTS[i].chan_layout == chan_layout) is_match=true; - } - if (is_match) - { - return CHAN_LAYOUTS[i].desc; - } - } - return NULL; -} - -bool GetChannelLayoutFromDesc(const char *desc, int *chan_layout, int *chan_mask, int *nch) -{ - if (!desc || !desc[0]) return false; - for (int i=0; i < sizeof(CHAN_LAYOUTS)/sizeof(CHAN_LAYOUTS[0]); ++i) - { - if (!strcmp(desc, CHAN_LAYOUTS[i].desc)) - { - if (chan_layout) *chan_layout=CHAN_LAYOUTS[i].chan_layout; - if (chan_mask) *chan_mask=CHAN_LAYOUTS[i].chan_mask; - if (nch) *nch=CHAN_LAYOUTS[i].nch; - return true; - } - } - return false; -} - - -bool PackFlacPicBase64(WDL_StringKeyedArray *metadata, - int img_w, int img_h, int bpp, WDL_HeapBuf *hb) -{ - if (!metadata || !hb || img_w <= 0 || img_h <= 0) return false; - - const char *picfn=metadata->Get("FLACPIC:APIC_FILE"); - const char *pictype=metadata->Get("FLACPIC:APIC_TYPE"); - const char *picdesc=metadata->Get("FLACPIC:APIC_DESC"); - - if (!picfn || !picfn[0]) return false; - if (!pictype) pictype="3"; - if (!picdesc) picdesc=""; - - const char *mime=NULL; - const char *ext=WDL_get_fileext(picfn); - if (ext && (!stricmp(ext, ".jpg") || !stricmp(ext, ".jpeg"))) mime="image/jpeg"; - else if (ext && !stricmp(ext, ".png")) mime="image/png"; - if (!mime) return false; - - WDL_FileRead fr(picfn); - if (!fr.IsOpen()) return false; - - WDL_INT64 datalen64=fr.GetSize(); - if (datalen64 < 1 || datalen64 >= (1<<30)) - { - return false; - } - int datalen = (int)datalen64; - int r8 = (datalen&7) ? 8-(datalen&7) : 0; - - // see opusfile src/info.c opus_picture_tag_parse_impl - // for what we are apparently encoding - - int mimelen=strlen(mime); - int desclen=strlen(picdesc); - - int binlen = - 4+ // pictype - 4+mimelen+ - 4+desclen+ - 4+4+4+4+ // w, h, depth, colors - 4+datalen+r8; - - WDL_HeapBuf hb_bin; - unsigned char *p=(unsigned char*)hb_bin.ResizeOK(binlen); - if (!p) - { - return false; - } - unsigned char *op=p; - - int t=atoi(pictype); - _AddInt32(t); - _AddInt32(mimelen); - memcpy(p, mime, mimelen); - p += mimelen; - _AddInt32(desclen); - memcpy(p, picdesc, desclen); - p += desclen; - _AddInt32(img_w); - _AddInt32(img_h); - _AddInt32(bpp); - _AddInt32(0); - _AddInt32(datalen+r8); - - fr.Read(p, datalen); - p += datalen; - - memset(p, 0, r8); - p += r8; - - if (WDL_NORMALLY(p-op == binlen)) - { - int base64len=binlen*4/3; - if (base64len&3) base64len += 4-(base64len&3); - ++base64len; // nul terminated return - - int osz=hb->GetSize(); - char *pout=(char*)hb->ResizeOK(osz+base64len); - if (pout) - { - wdl_base64encode(op, pout, binlen); - return true; - } - } - - return false; -} - -bool ExportMetadataImageToTmpFile(const char *srcfn, const char *infostr, - WDL_FastString *imgdesc, WDL_FastString *imgtype, WDL_FastString *imgfn) -{ - if (!srcfn || !srcfn[0] || !infostr || !infostr[0] || !imgfn) return false; - - WDL_HeapBuf tmp; - int tmplen=strlen(infostr); - if (!tmp.ResizeOK(tmplen+1)) return false; - memcpy(tmp.Get(), infostr, tmplen+1); - - const char *ext=NULL, *mime=NULL, *desc=NULL, *type=NULL, *offs=NULL, *len=NULL; - char *p=(char*)tmp.Get(); - for (int i=0; i < tmplen; ++i) - { - if (!strncmp(p+i, "ext:", 4)) { if (i) p[i-1]=0; i += 4; ext=p+i; } - else if (!strncmp(p+i, "mime:", 5)) { if (i) p[i-1]=0; i += 5; mime=p+i; } - else if (!strncmp(p+i, "desc:", 5)) { if (i) p[i-1]=0; i += 5; desc=p+i; } - else if (!strncmp(p+i, "type:", 5)) { if (i) p[i-1]=0; i += 5; type=p+i; } - else if (!strncmp(p+i, "offset:", 7)) { if (i) p[i-1]=0; i += 7; offs=p+i; } - else if (!strncmp(p+i, "length:", 7)) { if (i) p[i-1]=0; i += 7; len=p+i; } - } - - WDL_INT64 ioffs = offs ? (WDL_INT64)atof(offs) : 0; - int ilen = len ? atoi(len) : 0; - - bool ok=false; - if ((ext || mime) && ioffs > 0 && ilen > 0) - { - WDL_FileRead fr(srcfn); - if (fr.IsOpen() && fr.GetSize() >= ioffs+ilen) - { - fr.SetPosition(ioffs); - - char tmppath[2048]; - tmppath[0]=0; - GetTempPath(sizeof(tmppath), tmppath); - imgfn->Set(tmppath); - imgfn->Append(WDL_get_filepart(srcfn)); - imgfn->Append("."); - if (ext) imgfn->Append(ext); - else if (mime && !strncmp(mime, "image/", 6)) imgfn->Append(mime+6); - - WDL_FileWrite fw(imgfn->Get()); - if (fw.IsOpen() && CopyFileData(&fr, &fw, ilen)) - { - if (desc && imgdesc) imgdesc->Set(desc); - if (type && imgtype) imgtype->Set(type); - ok=true; - } - } - } - - return ok; -} - - - -#endif // _METADATA_H_ diff --git a/oversampling/WDL/mp3write.h b/oversampling/WDL/mp3write.h deleted file mode 100644 index 8add096..0000000 --- a/oversampling/WDL/mp3write.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - WDL - mp3write.h - Copyright (C) 2005 Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - -*/ - -/* - - This file provides a simple class for writing MP3 files (using lameencdec.h) - -*/ - - -#ifndef _MP3WRITE_H_ -#define _MP3WRITE_H_ - - -#include -#include "lameencdec.h" - -class mp3Writer -{ - public: - // appending doesnt check sample types - mp3Writer() - { - m_enc=0; - m_fp=0; - m_srate=0; - m_nch=0; - } - - mp3Writer(char *filename, int nch, int srate, int bitrate, int allow_append=1) - { - m_enc=0; - m_fp=0; - m_srate=0; - m_nch=0; - Open(filename,nch,srate,bitrate,allow_append); - - } - - int Open(char *filename, int nch, int srate, int bitrate, int allow_append=1) - { - m_fp=0; - if (allow_append) - { - m_fp=fopen(filename,"r+b"); - if (m_fp) - { - fseek(m_fp,0,SEEK_END); - } - } - if (!m_fp) - { - m_fp=fopen(filename,"wb"); - } - m_nch=nch>1?2:1; - m_srate=srate; - m_enc = new LameEncoder(srate,nch,bitrate); - if (m_enc->Status()) - { - delete m_enc; - m_enc=0; - } - return m_fp && m_enc; - } - - ~mp3Writer() - { - if (m_fp) - { - if (m_enc) - { - m_enc->Encode(NULL,0); - if (m_enc->outqueue.Available()) - { - fwrite(m_enc->outqueue.Get(),1,m_enc->outqueue.GetSize(),m_fp); - fflush(m_fp); - m_enc->outqueue.Advance(m_enc->outqueue.GetSize()); - m_enc->outqueue.Compact(); - } - } - - fclose(m_fp); - m_fp=0; - } - if (m_enc) - { - delete m_enc; - m_enc=0; - } - } - - int Status() { return m_enc && m_fp; } - - void WriteFloats(float *samples, int nsamples) - { - if (!m_fp || !m_enc) return; - - m_enc->Encode(samples,nsamples/m_nch); - if (m_enc->outqueue.Available()) - { - fwrite(m_enc->outqueue.Get(),1,m_enc->outqueue.GetSize(),m_fp); - fflush(m_fp); - m_enc->outqueue.Advance(m_enc->outqueue.GetSize()); - m_enc->outqueue.Compact(); - } - - } - - int get_nch() { return m_nch; } - int get_srate() { return m_srate; } - - private: - FILE *m_fp; - int m_nch,m_srate; - LameEncoder *m_enc; -}; - - -#endif//_MP3WRITE_H_ \ No newline at end of file diff --git a/oversampling/WDL/mutex.h b/oversampling/WDL/mutex.h deleted file mode 100644 index a83c24f..0000000 --- a/oversampling/WDL/mutex.h +++ /dev/null @@ -1,237 +0,0 @@ -/* - WDL - mutex.h - Copyright (C) 2005 and later, Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - -*/ - -/* - - - This file provides a simple class that abstracts a mutex or critical section object. - On Windows it uses CRITICAL_SECTION, on everything else it uses pthread's mutex library. - It simulates the Critical Section behavior on non-Windows, as well (meaning a thread can - safely Enter the mutex multiple times, provided it Leaves the same number of times) - -*/ - -#ifndef _WDL_MUTEX_H_ -#define _WDL_MUTEX_H_ - -#ifdef _WIN32 -#include -#else - -#include -// define this if you wish to use carbon critical sections on OS X -// #define WDL_MAC_USE_CARBON_CRITSEC - -#ifdef WDL_MAC_USE_CARBON_CRITSEC -#include -#else -#include -#endif - -#endif - -#include "wdltypes.h" -#include "wdlatomic.h" - -#ifdef _DEBUG -#include -#endif - -class WDL_Mutex { - public: - WDL_Mutex() - { -#ifdef _WIN32 - InitializeCriticalSection(&m_cs); -#elif defined( WDL_MAC_USE_CARBON_CRITSEC) - MPCreateCriticalRegion(&m_cr); -#elif defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER) && !defined(__linux__) - const pthread_mutex_t tmp = PTHREAD_RECURSIVE_MUTEX_INITIALIZER; - m_mutex = tmp; -#else - pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE); -#ifdef __linux__ - // todo: macos too? - pthread_mutexattr_setprotocol(&attr,PTHREAD_PRIO_INHERIT); -#endif - pthread_mutex_init(&m_mutex,&attr); - pthread_mutexattr_destroy(&attr); -#endif - } - ~WDL_Mutex() - { -#ifdef _WIN32 - DeleteCriticalSection(&m_cs); -#elif defined(WDL_MAC_USE_CARBON_CRITSEC) - MPDeleteCriticalRegion(m_cr); -#else - pthread_mutex_destroy(&m_mutex); -#endif - } - - void Enter() - { -#ifdef _WIN32 - EnterCriticalSection(&m_cs); -#elif defined(WDL_MAC_USE_CARBON_CRITSEC) - MPEnterCriticalRegion(m_cr,kDurationForever); -#else - pthread_mutex_lock(&m_mutex); -#endif - } - - void Leave() - { -#ifdef _WIN32 - LeaveCriticalSection(&m_cs); -#elif defined(WDL_MAC_USE_CARBON_CRITSEC) - MPExitCriticalRegion(m_cr); -#else - pthread_mutex_unlock(&m_mutex); -#endif - } - - private: -#ifdef _WIN32 - CRITICAL_SECTION m_cs; -#elif defined(WDL_MAC_USE_CARBON_CRITSEC) - MPCriticalRegionID m_cr; -#else - pthread_mutex_t m_mutex; -#endif - - // prevent callers from copying mutexes accidentally - WDL_Mutex(const WDL_Mutex &cp) - { -#ifdef _DEBUG - assert(sizeof(WDL_Mutex) == 0); -#endif - } - WDL_Mutex &operator=(const WDL_Mutex &cp) - { -#ifdef _DEBUG - assert(sizeof(WDL_Mutex) == 0); -#endif - return *this; - } - -} WDL_FIXALIGN; - -class WDL_MutexLock { -public: - WDL_MutexLock(WDL_Mutex *m) : m_m(m) { if (m) m->Enter(); } - ~WDL_MutexLock() { if (m_m) m_m->Leave(); } - - // the caller modifies this, make sure it unlocks the mutex first and locks the new mutex! - WDL_Mutex *m_m; -} WDL_FIXALIGN; - -class WDL_SharedMutex -{ - public: - WDL_SharedMutex() { m_sharedcnt=0; } - ~WDL_SharedMutex() { } - - void LockExclusive() // note: the calling thread must NOT have any shared locks, or deadlock WILL occur - { - m_mutex.Enter(); -#ifdef _WIN32 - while (m_sharedcnt>0) Sleep(1); -#else - while (m_sharedcnt>0) usleep(100); -#endif - } - void UnlockExclusive() { m_mutex.Leave(); } - - void LockShared() - { - m_mutex.Enter(); - wdl_atomic_incr(&m_sharedcnt); - m_mutex.Leave(); - } - void UnlockShared() - { - wdl_atomic_decr(&m_sharedcnt); - } - - void SharedToExclusive() // assumes a SINGLE shared lock by this thread! - { - m_mutex.Enter(); -#ifdef _WIN32 - while (m_sharedcnt>1) Sleep(1); -#else - while (m_sharedcnt>1) usleep(100); -#endif - UnlockShared(); - } - - void ExclusiveToShared() // assumes exclusive locked returns with shared locked - { - // already have exclusive lock - wdl_atomic_incr(&m_sharedcnt); - m_mutex.Leave(); - } - - private: - WDL_Mutex m_mutex; - volatile int m_sharedcnt; - - // prevent callers from copying accidentally - WDL_SharedMutex(const WDL_SharedMutex &cp) - { - #ifdef _DEBUG - assert(sizeof(WDL_SharedMutex) == 0); - #endif - } - WDL_SharedMutex &operator=(const WDL_SharedMutex &cp) - { - #ifdef _DEBUG - assert(sizeof(WDL_SharedMutex) == 0); - #endif - return *this; - } - - -} WDL_FIXALIGN; - - - -class WDL_MutexLockShared { - public: - WDL_MutexLockShared(WDL_SharedMutex *m) : m_m(m) { if (m) m->LockShared(); } - ~WDL_MutexLockShared() { if (m_m) m_m->UnlockShared(); } - private: - WDL_SharedMutex *m_m; -} WDL_FIXALIGN; - -class WDL_MutexLockExclusive { - public: - WDL_MutexLockExclusive(WDL_SharedMutex *m) : m_m(m) { if (m) m->LockExclusive(); } - ~WDL_MutexLockExclusive() { if (m_m) m_m->UnlockExclusive(); } - private: - WDL_SharedMutex *m_m; -} WDL_FIXALIGN; - - -#endif diff --git a/oversampling/WDL/pcmfmtcvt.h b/oversampling/WDL/pcmfmtcvt.h deleted file mode 100644 index b621830..0000000 --- a/oversampling/WDL/pcmfmtcvt.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - WDL - pcmfmtcvt.h - Copyright (C) 2005 and later, Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - -*/ - -#ifndef _PCMFMTCVT_H_ -#define _PCMFMTCVT_H_ - - -#include "wdltypes.h" -#include - -#ifndef PCMFMTCVT_DBL_TYPE -#define PCMFMTCVT_DBL_TYPE double -#endif - -#define INT16_TO_float INT16_TO_double -#define float_TO_INT16 double_TO_INT16 -#define float_to_i32 double_to_i32 -#define float_to_i24 double_to_i24 -#define i24_to_float i24_to_double -#define i32_to_float i32_to_double - -#define pcmToFloats pcmToDoubles -#define floatsToPcm doublesToPcm - - -template static void INT16_TO_double(T &out, int in) -{ - out = (T) (in/32768.0); -} -template static void double_TO_INT16(T &out, double in) -{ - in *= 32768.0; - if (in <= -32768.0) out = -32768; - else if (in >= 32767.0) out = 32767; - else out = (T) floor(in + 0.5); -} - -template static void i32_to_double(int i32, T *p) -{ - *p = i32 * (1.0 / 2147483648.0); -} - -template static void i24_to_double(const unsigned char *i24, T *p) -{ - // little endian - int val=(i24[0]) | (i24[1]<<8) | (i24[2]<<16); - if (val&0x800000) val|=0xFF000000; - *p = (T) (((double) val) * (1.0 / 8388608.0)); -} - -template static void double_to_i32(const T *vv, int *i32) -{ - const double v = *vv * 2147483648.0; - if (v <= -2147483648.0) *i32 = 0x80000000; - else if (v >= 2147483647.0) *i32 = 0x7FFFFFFF; - else *i32 = (int) floor(v + 0.5); -} - -static WDL_STATICFUNC_UNUSED int double_to_int_24(const double vv) -{ - const double v = vv * 8388608.0; - if (v <= -8388608.0) return -0x800000; - if (v >= 8388607.0) return 0x7fffff; - return (int) floor(v + 0.5); -} - -static WDL_STATICFUNC_UNUSED int double_to_int_x(const double vv, int bits) -{ - const double sc = (double) (1<<(bits-1)); - const double v = vv * sc; - if (v <= -sc) return -(1<<(bits-1)); - if (v >= sc-1.0) return (1<<(bits-1))-1; - return (int) floor(v + 0.5); -} - -template static void double_to_i24(const T *vv, unsigned char *i24) -{ - const int i = double_to_int_24(*vv); - i24[0]=i&0xff; - i24[1]=(i>>8)&0xff; - i24[2]=(i>>16)&0xff; -} - -template static void pcmToDoubles(void *src, int items, int bps, int src_spacing, T *dest, int dest_spacing, int byteadvancefor24=0) -{ - if (bps == 32) - { - int *i1=(int *)src; - while (items--) - { - i32_to_double(*i1,dest); - i1+=src_spacing; - dest+=dest_spacing; - } - } - else if (bps == 24) - { - unsigned char *i1=(unsigned char *)src; - int adv=3*src_spacing+byteadvancefor24; - while (items--) - { - i24_to_double(i1,dest); - dest+=dest_spacing; - i1+=adv; - } - } - else if (bps == 16) - { - short *i1=(short *)src; - while (items--) - { - INT16_TO_double(*dest,*i1); - i1+=src_spacing; - dest+=dest_spacing; - } - } -} - -template static void doublesToPcm(const T *src, int src_spacing, int items, void *dest, int bps, int dest_spacing, int byteadvancefor24=0) -{ - if (bps==32) - { - int *o1=(int*)dest; - while (items--) - { - double_to_i32(src,o1); - src+=src_spacing; - o1+=dest_spacing; - } - } - else if (bps == 24) - { - unsigned char *o1=(unsigned char*)dest; - int adv=dest_spacing*3+byteadvancefor24; - while (items--) - { - double_to_i24(src,o1); - src+=src_spacing; - o1+=adv; - } - } - else if (bps==16) - { - short *o1=(short*)dest; - while (items--) - { - double_TO_INT16(*o1,*src); - src+=src_spacing; - o1+=dest_spacing; - } - } -} - -#endif //_PCMFMTCVT_H_ diff --git a/oversampling/WDL/plush2/pl_cam.cpp b/oversampling/WDL/plush2/pl_cam.cpp deleted file mode 100644 index 22e5f38..0000000 --- a/oversampling/WDL/plush2/pl_cam.cpp +++ /dev/null @@ -1,762 +0,0 @@ -/****************************************************************************** -Plush Version 1.2 -cam.c -Camera and Rendering -Copyright (c) 1996-2000, Justin Frankel -******************************************************************************/ - -#include "plush.h" - - -#include "../lice/lice_extended.h" - -#include "../mergesort.h" - -#define MACRO_plMatrixApply(m,x,y,z,outx,outy,outz) \ - ( outx ) = ( x )*( m )[0] + ( y )*( m )[1] + ( z )*( m )[2] + ( m )[3];\ - ( outy ) = ( x )*( m )[4] + ( y )*( m )[5] + ( z )*( m )[6] + ( m )[7];\ - ( outz ) = ( x )*( m )[8] + ( y )*( m )[9] + ( z )*( m )[10] + ( m )[11] - -#define MACRO_plDotProduct(x1,y1,z1,x2,y2,z2) \ - ((( x1 )*( x2 ))+(( y1 )*( y2 ))+(( z1 )*( z2 ))) - -#define MACRO_plNormalizeVector(x,y,z) { \ - double length; \ - length = ( x )*( x )+( y )*( y )+( z )*( z ); \ - if (length > 0.0000000001) { \ - double __l = 1.0/sqrt(length); \ - ( x ) *= __l; \ - ( y ) *= __l; \ - ( z ) *= __l; \ - } \ -} - - -static void _FindNormal(double x2, double x3,double y2, double y3, - double zv, double *res) { - res[0] = zv*(y2-y3); - res[1] = zv*(x3-x2); - res[2] = x2*y3 - y2*x3; -} - - -void pl_Cam::SetTarget(pl_Float x, pl_Float y, pl_Float z) { - double dx, dy, dz; - dx = x - X; - dy = y - Y; - dz = z - Z; - Roll = 0; - if (dz > 0.0001f) { - Pan = (pl_Float) (-atan(dx/dz)*(180.0/PL_PI)); - dz /= cos(Pan*(PL_PI/180.0)); - Pitch = (pl_Float) (atan(dy/dz)*(180.0/PL_PI)); - } else if (dz < -0.0001f) { - Pan = (pl_Float) (180.0-atan(dx/dz)*(180.0/PL_PI)); - dz /= cos((Pan-180.0f)*(PL_PI/180.0)); - Pitch = (pl_Float) (-atan(dy/dz)*(180.0/PL_PI)); - } else { - Pan = 90.0f; - Pitch = (pl_Float) (atan2(dy,-dx) * (180.0 / PL_PI)); - Roll = -90.0f; - } - GenMatrix = true; -} - -void pl_Cam::RecalcFrustum(int fbw, int fbh) -{ - const int cx = (CenterX*m_lastFBScaling)/256 + fbw/2; - const int cy = (CenterY*m_lastFBScaling)/256 + fbh/2; - m_lastCX = cx; - m_lastCY = cy; - - m_adj_asp = 1.0 / AspectRatio; - m_fovfactor = CalcFOVFactor(fbw); - memset(m_clipPlanes,0,sizeof(m_clipPlanes)); - - /* Back */ - m_clipPlanes[0][2] = -1.0; - m_clipPlanes[0][3] = -ClipBack; - - /* Left */ - m_clipPlanes[1][3] = 0.00000001; - if (cx == 0) m_clipPlanes[1][0] = 1.0; - else - { - _FindNormal(-100,-100, - 100, -100, - m_fovfactor*100.0/cx, - m_clipPlanes[1]); - if (cx < 0) - { - m_clipPlanes[1][0] = -m_clipPlanes[1][0]; - m_clipPlanes[1][1] = -m_clipPlanes[1][1]; - m_clipPlanes[1][2] = -m_clipPlanes[1][2]; - } - } - - /* Right */ - m_clipPlanes[2][3] = 0.00000001; - if (fbw == cx) m_clipPlanes[2][0] = -1.0; - else - { - _FindNormal(100,100, - -100, 100, - m_fovfactor*100.0/(fbw-cx), - m_clipPlanes[2]); - if (cx > fbw) - { - m_clipPlanes[2][0] = -m_clipPlanes[2][0]; - m_clipPlanes[2][1] = -m_clipPlanes[2][1]; - m_clipPlanes[2][2] = -m_clipPlanes[2][2]; - } - } - - /* Top */ - m_clipPlanes[3][3] = 0.00000001; - if (cy == 0) m_clipPlanes[3][1] = 1.0; - else - { - _FindNormal(100, -100, - 100, 100, - m_fovfactor*m_adj_asp*-100.0/(cy), - m_clipPlanes[3]); - if (cy < 0) - { - m_clipPlanes[3][0] = -m_clipPlanes[3][0]; - m_clipPlanes[3][1] = -m_clipPlanes[3][1]; - m_clipPlanes[3][2] = -m_clipPlanes[3][2]; - } - } - - /* Bottom */ - m_clipPlanes[4][3] = 0.00000001; - if (cy == fbh) m_clipPlanes[4][1] = -1.0; - else - { - _FindNormal(-100, 100, - -100, -100, - m_fovfactor*m_adj_asp*100.0/(cy-fbh), - m_clipPlanes[4]); - if (cy > fbh) - { - m_clipPlanes[4][0] = -m_clipPlanes[4][0]; - m_clipPlanes[4][1] = -m_clipPlanes[4][1]; - m_clipPlanes[4][2] = -m_clipPlanes[4][2]; - } - } - -} - - - /* Returns: 0 if nothing gets in, 1 or 2 if pout1 & pout2 get in */ -pl_uInt pl_Cam::_ClipToPlane(pl_uInt numVerts, pl_Float *plane) -{ - pl_uInt i, nextvert, curin, nextin; - double curdot, nextdot, scale; - pl_uInt invert, outvert; - invert = 0; - outvert = 0; - curdot = m_cl[0].newVertices[0].xformedx*plane[0] + - m_cl[0].newVertices[0].xformedy*plane[1] + - m_cl[0].newVertices[0].xformedz*plane[2]; - curin = (curdot >= plane[3]); - - for (i=0 ; i < numVerts; i++) { - nextvert = (i + 1) % numVerts; - if (curin) { - memcpy(&m_cl[1].ShadeInfos[outvert][0],&m_cl[0].ShadeInfos[invert][0],3*sizeof(pl_Float)); - int a; - for(a=0;a= plane[3]); - if (curin != nextin) { - scale = (plane[3] - curdot) / (nextdot - curdot); - m_cl[1].newVertices[outvert].xformedx = (pl_Float) (m_cl[0].newVertices[invert].xformedx + - (m_cl[0].newVertices[nextvert].xformedx - m_cl[0].newVertices[invert].xformedx) - * scale); - m_cl[1].newVertices[outvert].xformedy = (pl_Float) (m_cl[0].newVertices[invert].xformedy + - (m_cl[0].newVertices[nextvert].xformedy - m_cl[0].newVertices[invert].xformedy) - * scale); - m_cl[1].newVertices[outvert].xformedz = (pl_Float) (m_cl[0].newVertices[invert].xformedz + - (m_cl[0].newVertices[nextvert].xformedz - m_cl[0].newVertices[invert].xformedz) - * scale); - - m_cl[1].ShadeInfos[outvert][0] = m_cl[0].ShadeInfos[invert][0] + (m_cl[0].ShadeInfos[nextvert][0] - m_cl[0].ShadeInfos[invert][0]) * scale; - m_cl[1].ShadeInfos[outvert][1] = m_cl[0].ShadeInfos[invert][1] + (m_cl[0].ShadeInfos[nextvert][1] - m_cl[0].ShadeInfos[invert][1]) * scale; - m_cl[1].ShadeInfos[outvert][2] = m_cl[0].ShadeInfos[invert][2] + (m_cl[0].ShadeInfos[nextvert][2] - m_cl[0].ShadeInfos[invert][2]) * scale; - - int a; - for(a=0;a= 0 && xtmp < m_lastFBWidth && ytmp >= 0 && ytmp < m_lastFBHeight; -} - - -void pl_Cam::ClipRenderFace(pl_Face *face, pl_Obj *obj) { - const int cx = m_lastCX, cy = m_lastCY; - - { - pl_Vertex *vlist=obj->Vertices.Get(); - int a; - for (a = 0; a < 3; a ++) { - m_cl[0].newVertices[a] = vlist[face->VertexIndices[a]]; - - memcpy(&m_cl[0].ShadeInfos[a][0],&face->Shades[a][0],3*sizeof(pl_Float)); - int b; - for(b=0;bMappingU[b][a]; - m_cl[0].MappingV[b][a] = face->MappingV[b][a]; - } - } - } - - pl_uInt numVerts = 3; - { - int a = (m_clipPlanes[0][3] < 0.0 ? 0 : 1); - while (a < PL_NUM_CLIP_PLANES && numVerts > 2) - { - numVerts = _ClipToPlane(numVerts, m_clipPlanes[a]); - memcpy(&m_cl[0],&m_cl[1],sizeof(m_cl[0])); - a++; - } - } - if (numVerts > 2) { - pl_Face newface; - memcpy(&newface,face,sizeof(pl_Face)); - int k; - for (k = 2; k < (int)numVerts; k ++) { - int a; - for (a = 0; a < 3; a ++) { - int w; - if (a == 0) w = 0; - else w = a+(k-2); ; - pl_Vertex *thisv=m_cl[0].newVertices+w; - newface.Shades[a][0] = m_cl[0].ShadeInfos[w][0]; - newface.Shades[a][1] = m_cl[0].ShadeInfos[w][1]; - newface.Shades[a][2] = m_cl[0].ShadeInfos[w][2]; - int b; - for(b=0;bxformedz; - double ytmp = m_fovfactor * newface.Scrz[a]; - double xtmp = ytmp*thisv->xformedx; - ytmp *= thisv->xformedy*m_adj_asp; - newface.Scrx[a] = xtmp+cx; - newface.Scry[a] = ytmp+cy; - } - RenderTrisOut++; - - // quick approx of triangle area - RenderPixelsOut += 0.5*fabs( - (newface.Scrx[1] - newface.Scrx[0]) * - (newface.Scry[2] - newface.Scry[0]) - - (newface.Scrx[2] - newface.Scrx[0]) * - (newface.Scry[1] - newface.Scry[0]) ); - - PutFace(&newface); - } - } -} - -pl_sInt pl_Cam::ClipNeeded(pl_Face *face, pl_Obj *obj) { - const int fbw=m_fBuffer.m_w, fbh=m_fBuffer.m_h; - const int cx = m_lastCX, cy = m_lastCY; - double dr,dl,db,dt; - double f; - dr = (fbw-cx); - dl = (-cx); - db = (fbh-cy); - dt = (-cy); - f = m_fovfactor*m_adj_asp; - pl_Vertex *vlist=obj->Vertices.Get(); - pl_Vertex *v0=vlist+face->VertexIndices[0]; - pl_Vertex *v1=vlist+face->VertexIndices[1]; - pl_Vertex *v2=vlist+face->VertexIndices[2]; - - return ((ClipBack <= 0.0 || - v0->xformedz <= ClipBack || - v1->xformedz <= ClipBack || - v2->xformedz <= ClipBack) && - (v0->xformedz >= 0 || - v1->xformedz >= 0 || - v2->xformedz >= 0) && - (v0->xformedx*m_fovfactor<=dr*v0->xformedz || - v1->xformedx*m_fovfactor<=dr*v1->xformedz || - v2->xformedx*m_fovfactor<=dr*v2->xformedz) && - (v0->xformedx*m_fovfactor>=dl*v0->xformedz || - v1->xformedx*m_fovfactor>=dl*v1->xformedz || - v2->xformedx*m_fovfactor>=dl*v2->xformedz) && - (v0->xformedy*f<=db*v0->xformedz || - v1->xformedy*f<=db*v1->xformedz || - v2->xformedy*f<=db*v2->xformedz) && - (v0->xformedy*f>=dt*v0->xformedz || - v1->xformedy*f>=dt*v1->xformedz || - v2->xformedy*f>=dt*v2->xformedz)); -} - - - - - - -void pl_Cam::Begin(LICE_IBitmap *fb, bool want_zbclear, pl_ZBuffer zbclear) { - if (WDL_NOT_NORMALLY(m_fBuffer.m_buf) || WDL_NOT_NORMALLY(!fb)) return; - - m_lastFBWidth=fb->getWidth(); - m_lastFBHeight=fb->getHeight(); - m_lastFBScaling = (int)fb->Extended(LICE_EXT_GET_SCALING,NULL); - if (m_lastFBScaling==0 || WDL_NOT_NORMALLY(m_lastFBScaling > 1024)) m_lastFBScaling=256; - - m_fBuffer.m_buf = fb->getBits(); - m_fBuffer.m_span = fb->getRowSpan(); - m_fBuffer.m_w = fb->getWidth() * m_lastFBScaling / 256; - m_fBuffer.m_h = fb->getHeight() * m_lastFBScaling / 256; - m_fBuffer.m_flipped = fb->isFlipped(); - - if (WantZBuffer) - { - int zbsz=m_fBuffer.m_w*m_fBuffer.m_h; - pl_ZBuffer *zb=zBuffer.ResizeOK(zbsz); - if (!zb) zBuffer.Resize(0); - else if (want_zbclear) - { - if (!zbclear) memset(zb,0,zbsz*sizeof(pl_ZBuffer)); - else - { - int i=zbsz; - while(i--) *zb++=zbclear; - } - } - } - else zBuffer.Resize(0); - pl_Float tempMatrix[16]; - _numlights = 0; - _numfaces = _numfaces_sorted = 0; - if (GenMatrix) - { - plMatrixRotate(CamMatrix,2,-Pan); - plMatrixRotate(tempMatrix,1,-Pitch); - plMatrixMultiply(CamMatrix,tempMatrix); - plMatrixRotate(tempMatrix,3,-Roll); - plMatrixMultiply(CamMatrix,tempMatrix); - } - - RecalcFrustum(m_fBuffer.m_w, m_fBuffer.m_h); - - RenderTrisIn=RenderTrisCulled=RenderTrisOut=0; - RenderPixelsOut=0.0; - -} - -void pl_Cam::RenderLight(pl_Light *light) { - if (!light||WDL_NOT_NORMALLY(!m_fBuffer.m_buf)) return; - - pl_Float *pl, xp, yp, zp; - if (light->Type == PL_LIGHT_NONE) return; - if (_lights.GetSize()<=_numlights) _lights.Resize(_numlights+1); - pl = _lights.Get()[_numlights].l; - if (light->Type == PL_LIGHT_VECTOR) { - xp = light->Xp; - yp = light->Yp; - zp = light->Zp; - MACRO_plMatrixApply(CamMatrix,xp,yp,zp,pl[0],pl[1],pl[2]); - } else if (light->Type & PL_LIGHT_POINT) { - xp = light->Xp-X; - yp = light->Yp-Y; - zp = light->Zp-Z; - MACRO_plMatrixApply(CamMatrix,xp,yp,zp,pl[0],pl[1],pl[2]); - } - _lights.Get()[_numlights++].light = light; -} - -void pl_Cam::RenderObject(pl_Obj *obj, const pl_Float *bmatrix, const pl_Float *bnmatrix) { - if (!obj||WDL_NOT_NORMALLY(!m_fBuffer.m_buf)) return; - - pl_Float oMatrix[16], nMatrix[16], tempMatrix[16]; - - if (obj->GenMatrix) { - plMatrixRotate(nMatrix,1,obj->Xa); - plMatrixRotate(tempMatrix,2,obj->Ya); - plMatrixMultiply(nMatrix,tempMatrix); - plMatrixRotate(tempMatrix,3,obj->Za); - plMatrixMultiply(nMatrix,tempMatrix); - memcpy(obj->RotMatrix,nMatrix,sizeof(pl_Float)*16); - - memcpy(oMatrix,nMatrix,sizeof(pl_Float)*16); - plMatrixTranslate(tempMatrix, obj->Xp, obj->Yp, obj->Zp); - plMatrixMultiply(oMatrix,tempMatrix); - memcpy(obj->Matrix,oMatrix,sizeof(pl_Float)*16); - } else { - memcpy(oMatrix,obj->Matrix,sizeof(pl_Float)*16); - memcpy(nMatrix,obj->RotMatrix,sizeof(pl_Float)*16); - } - - if (bnmatrix) plMatrixMultiply(nMatrix,bnmatrix); - if (bmatrix) plMatrixMultiply(oMatrix,bmatrix); - - { - int i; - for (i = 0; i < obj->Children.GetSize(); i ++) - if (obj->Children.Get(i)) RenderObject(obj->Children.Get(i),oMatrix,nMatrix); - } - if (!obj->Faces.GetSize() || !obj->Vertices.GetSize()) return; - - plMatrixTranslate(tempMatrix, -X, -Y, -Z); - plMatrixMultiply(oMatrix,tempMatrix); - plMatrixMultiply(oMatrix,CamMatrix); - plMatrixMultiply(nMatrix,CamMatrix); - - { - pl_Vertex *vertex = obj->Vertices.Get(); - int i = obj->Vertices.GetSize(); - - while (i--) - { - MACRO_plMatrixApply(oMatrix,vertex->x,vertex->y,vertex->z, - vertex->xformedx, vertex->xformedy, vertex->xformedz); - MACRO_plMatrixApply(nMatrix,vertex->nx,vertex->ny,vertex->nz, - vertex->xformednx,vertex->xformedny,vertex->xformednz); - vertex++; - } - } - - if (_faces.GetSize() < _numfaces + obj->Faces.GetSize()) _faces.Resize(_numfaces + obj->Faces.GetSize()); - - - _faceInfo *facelistout = _faces.Get() + _numfaces; - - pl_Face *face = obj->Faces.Get(); - int facecnt = obj->Faces.GetSize(); - - RenderTrisIn += facecnt; - _numfaces += facecnt; - pl_Vertex *vlist = obj->Vertices.Get(); - - while (facecnt--) - { - double nx,ny,nz; - pl_Mat *mat=face->Material; - if (mat->BackfaceCull || (mat->Lightable && !mat->Smoothing)) - { - MACRO_plMatrixApply(nMatrix,face->nx,face->ny,face->nz,nx,ny,nz); - } - pl_Vertex *v0=vlist+face->VertexIndices[0]; - pl_Vertex *v1=vlist+face->VertexIndices[1]; - pl_Vertex *v2=vlist+face->VertexIndices[2]; - - if (!mat->BackfaceCull || (MACRO_plDotProduct(nx,ny,nz, v0->xformedx, v0->xformedy, v0->xformedz) < 0.0000001)) { - if (ClipNeeded(face,obj)) { - if (!mat->Smoothing && (mat->Lightable||mat->FadeDist)) { - pl_Float val[3]; - memcpy(val,face->sLighting,3*sizeof(pl_Float)); - if (mat->Lightable) { - _lightInfo *inf = _lights.Get(); - int i=_numlights; - while (i--) - { - pl_Light *light = inf->light; - double lightsc=0.0; - if (light->Type & PL_LIGHT_POINT_ANGLE) { - double nx2 = inf->l[0] - v0->xformedx; - double ny2 = inf->l[1] - v0->xformedy; - double nz2 = inf->l[2] - v0->xformedz; - MACRO_plNormalizeVector(nx2,ny2,nz2); - lightsc = MACRO_plDotProduct(nx,ny,nz,nx2,ny2,nz2); - } - if (light->Type & PL_LIGHT_POINT_DISTANCE) { - double nx2 = inf->l[0] - v0->xformedx; - double ny2 = inf->l[1] - v0->xformedy; - double nz2 = inf->l[2] - v0->xformedz; - if (light->Type & PL_LIGHT_POINT_ANGLE) { - nx2 = (1.0 - 0.5*((nx2*nx2+ny2*ny2+nz2*nz2)/ - light->HalfDistSquared)); - lightsc *= plMax(0,plMin(1.0,nx2)); - } else { - lightsc = (1.0 - 0.5*((nx2*nx2+ny2*ny2+nz2*nz2)/ - light->HalfDistSquared)); - lightsc = plMax(0,plMin(1.0,lightsc)); - } - } - if (light->Type == PL_LIGHT_VECTOR) - lightsc = MACRO_plDotProduct(nx,ny,nz,inf->l[0],inf->l[1],inf->l[2]); - - if (lightsc>0.0) - { - val[0] += light->Intensity[0]*lightsc; - val[1] += light->Intensity[1]*lightsc; - val[2] += light->Intensity[2]*lightsc; - } - else if (mat->BackfaceIllumination) - { - val[0] -= light->Intensity[0]*lightsc*mat->BackfaceIllumination; - val[1] -= light->Intensity[1]*lightsc*mat->BackfaceIllumination; - val[2] -= light->Intensity[2]*lightsc*mat->BackfaceIllumination; - } - inf++; - } /* End of light loop */ - } /* End of flat shading if */ - - if (mat->FadeDist) - { - double lightsc = 1.0 - (v0->xformedz+v1->xformedz+v2->xformedz) / (mat->FadeDist*3.0); - if (lightsc<0.0) lightsc=0.0; - else if (lightsc>1.0)lightsc=1.0; - if (mat->Lightable) - { - val[0] *= lightsc; - val[1] *= lightsc; - val[2] *= lightsc; - } - else - { - val[0]+=lightsc; - val[1]+=lightsc; - val[2]+=lightsc; - } - } - face->Shades[0][0]=mat->Ambient[0] + mat->Diffuse[0]*val[0]; - face->Shades[0][1]=mat->Ambient[1] + mat->Diffuse[1]*val[1]; - face->Shades[0][2]=mat->Ambient[2] + mat->Diffuse[2]*val[2]; - } - else memcpy(face->Shades,mat->Ambient,sizeof(mat->Ambient)); // flat shading - - if ((mat->Texture && mat->TexMapIdx<0)||(mat->Texture2 && mat->Tex2MapIdx<0)) { - face->MappingU[PLUSH_MAX_MAPCOORDS-1][0] = 0.5 + (v0->xformednx); - face->MappingV[PLUSH_MAX_MAPCOORDS-1][0] = 0.5 - (v0->xformedny); - face->MappingU[PLUSH_MAX_MAPCOORDS-1][1] = 0.5 + (v1->xformednx); - face->MappingV[PLUSH_MAX_MAPCOORDS-1][1] = 0.5 - (v1->xformedny); - face->MappingU[PLUSH_MAX_MAPCOORDS-1][2] = 0.5 + (v2->xformednx); - face->MappingV[PLUSH_MAX_MAPCOORDS-1][2] = 0.5 - (v2->xformedny); - } - - if (mat->Smoothing && (mat->Lightable || mat->FadeDist)) - { - int a; - for (a = 0; a < 3; a ++) { - pl_Float val[3]; - memcpy(val,face->vsLighting[a],sizeof(val)); - pl_Vertex *thisvert = obj->Vertices.Get()+face->VertexIndices[a]; - - if (mat->Lightable) - { - int i=_numlights; - _lightInfo *inf = _lights.Get(); - while (i--) - { - double lightsc = 0.0; - pl_Light *light = inf->light; - if (light->Type & PL_LIGHT_POINT_ANGLE) { - double nx2 = inf->l[0] - thisvert->xformedx; - double ny2 = inf->l[1] - thisvert->xformedy; - double nz2 = inf->l[2] - thisvert->xformedz; - MACRO_plNormalizeVector(nx2,ny2,nz2); - lightsc = MACRO_plDotProduct(thisvert->xformednx, - thisvert->xformedny, - thisvert->xformednz, - nx2,ny2,nz2); - } - if (light->Type & PL_LIGHT_POINT_DISTANCE) { - double nx2 = inf->l[0] - thisvert->xformedx; - double ny2 = inf->l[1] - thisvert->xformedy; - double nz2 = inf->l[2] - thisvert->xformedz; - if (light->Type & PL_LIGHT_POINT_ANGLE) { - double t= (1.0 - 0.5*((nx2*nx2+ny2*ny2+nz2*nz2)/light->HalfDistSquared)); - lightsc *= plMax(0,plMin(1.0,t)); - } else { - lightsc = (1.0 - 0.5*((nx2*nx2+ny2*ny2+nz2*nz2)/light->HalfDistSquared)); - lightsc = plMax(0,plMin(1.0,lightsc)); - } - } - - if (light->Type == PL_LIGHT_VECTOR) - lightsc = MACRO_plDotProduct(thisvert->xformednx, - thisvert->xformedny, - thisvert->xformednz, - inf->l[0],inf->l[1],inf->l[2]); - if (lightsc > 0.0) - { - val[0] += lightsc * light->Intensity[0]; - val[1] += lightsc * light->Intensity[1]; - val[2] += lightsc * light->Intensity[2]; - } - else if (mat->BackfaceIllumination) - { - val[0] -= lightsc * light->Intensity[0]*mat->BackfaceIllumination; - val[1] -= lightsc * light->Intensity[1]*mat->BackfaceIllumination; - val[2] -= lightsc * light->Intensity[2]*mat->BackfaceIllumination; - } - inf++; - } /* End of light loop */ - } /* End of gouraud shading if */ - if (mat->FadeDist) - { - double lightsc = 1.0-thisvert->xformedz/mat->FadeDist; - if (lightsc<0.0) lightsc=0.0; - else if (lightsc>1.0)lightsc=1.0; - if (mat->Lightable) - { - val[0] *= lightsc; - val[1] *= lightsc; - val[2] *= lightsc; - } - else - { - val[0] += lightsc; - val[1] += lightsc; - val[2] += lightsc; - } - } - face->Shades[a][0] = mat->Ambient[0] + mat->Diffuse[0]*val[0]; - face->Shades[a][1] = mat->Ambient[1] + mat->Diffuse[1]*val[1]; - face->Shades[a][2] = mat->Ambient[2] + mat->Diffuse[2]*val[2]; - } /* End of vertex loop for */ - } /* End of gouraud shading mask if */ - else // flat modes, shade all vertices - { - memcpy(&face->Shades[1][0],&face->Shades[0][0],sizeof(pl_Float)*3); - memcpy(&face->Shades[2][0],&face->Shades[0][0],sizeof(pl_Float)*3); - } - - facelistout->zd = v0->xformedz+v1->xformedz+v2->xformedz; - facelistout->obj=obj; - facelistout->face = face; - facelistout++; - - - RenderTrisCulled++; - - } /* Is it in our area Check */ - } /* Backface Check */ - face++; - } - _numfaces = facelistout-_faces.Get(); -} -void pl_Cam::SortToCurrent() -{ - if (Sort && _numfaces > _numfaces_sorted+1) - { - WDL_mergesort(_faces.Get()+_numfaces_sorted, - _numfaces-_numfaces_sorted,sizeof(_faceInfo), - Sort > 0 ? sortFwdFunc : sortRevFunc, - (char*)_sort_tmpspace.Resize((_numfaces-_numfaces_sorted)*sizeof(_faceInfo),false)); - } - _numfaces_sorted=_numfaces; -} - -int pl_Cam::sortRevFunc(const void *a, const void *b) -{ - _faceInfo *aa = (_faceInfo*)a; - _faceInfo *bb = (_faceInfo*)b; - - if (aa->zd < bb->zd) return -1; - if (aa->zd > bb->zd) return 1; - return 0; -} - -int pl_Cam::sortFwdFunc(const void *a, const void *b) -{ - _faceInfo *aa = (_faceInfo*)a; - _faceInfo *bb = (_faceInfo*)b; - - if (aa->zd < bb->zd) return 1; - if (aa->zd > bb->zd) return -1; - return 0; -} - -void pl_Cam::End() { - if (WDL_NOT_NORMALLY(!m_fBuffer.m_buf)) return; - - SortToCurrent(); - - _faceInfo *f = _faces.Get(); - int n=_numfaces; - while (n-->0) - { - if (f->face->Material) - { - ClipRenderFace(f->face,f->obj); - } - f++; - } - - m_fBuffer.m_buf = NULL; - _numfaces=0; - _numlights = 0; -} - - - - -void pl_Light::Set(pl_uChar mode, pl_Float x, pl_Float y, pl_Float z, pl_Float intensity_r, pl_Float intensity_g, pl_Float intensity_b, pl_Float halfDist) { - pl_Float m[16], m2[16]; - Type = mode; - Intensity[0] = intensity_r; - Intensity[1] = intensity_g; - Intensity[2] = intensity_b; - HalfDistSquared = halfDist*halfDist; - switch (mode) { - case PL_LIGHT_VECTOR: - plMatrixRotate(m,1,x); - plMatrixRotate(m2,2,y); - plMatrixMultiply(m,m2); - plMatrixRotate(m2,3,z); - plMatrixMultiply(m,m2); - plMatrixApply(m,0.0,0.0,-1.0,&Xp, &Yp, &Zp); - break; - case PL_LIGHT_POINT_ANGLE: - case PL_LIGHT_POINT_DISTANCE: - case PL_LIGHT_POINT: - Xp = x; - Yp = y; - Zp = z; - break; - } -} diff --git a/oversampling/WDL/plush2/pl_make.cpp b/oversampling/WDL/plush2/pl_make.cpp deleted file mode 100644 index 0f59b28..0000000 --- a/oversampling/WDL/plush2/pl_make.cpp +++ /dev/null @@ -1,537 +0,0 @@ -/****************************************************************************** -Plush Version 1.2 -make.c -Object Primitives -Copyright (c) 1996-2000, Justin Frankel -******************************************************************************* - Notes: - Most of these routines are highly unoptimized. - They could all use some work, such as more capable divisions (Box is - most notable), etc... The mapping coordinates are all set up nicely, - though. -******************************************************************************/ - -#include "plush.h" - -pl_Obj *plMakeTorus(pl_Float r1, pl_Float r2, pl_uInt divrot, pl_uInt divrad, - pl_Mat *m) { - pl_Obj *o; - pl_Vertex *v; - pl_Face *f; - pl_uInt x, y; - double ravg, rt, a, da, al, dal; - pl_Float U,V,dU,dV; - if (divrot < 3) divrot = 3; - if (divrad < 3) divrad = 3; - ravg = (r1+r2)*0.5; - rt = (r2-r1)*0.5; - o = new pl_Obj(divrad*divrot,divrad*divrot*2); - if (!o) return 0; - v = o->Vertices.Get(); - a = 0.0; - da = 2*PL_PI/divrot; - for (y = 0; y < divrot; y ++) { - al = 0.0; - dal = 2*PL_PI/divrad; - for (x = 0; x < divrad; x ++) { - v->x = (pl_Float) (cos((double) a)*(ravg + cos((double) al)*rt)); - v->z = (pl_Float) (sin((double) a)*(ravg + cos((double) al)*rt)); - v->y = (pl_Float) (sin((double) al)*rt); - v++; - al += dal; - } - a += da; - } - v = o->Vertices.Get(); - f = o->Faces.Get(); - dV = 1.0/divrad; - dU = 1.0/divrot; - U = 0; - for (y = 0; y < divrot; y ++) { - V = -0.5; - for (x = 0; x < divrad; x ++) { - f->VertexIndices[0] = v+x+y*divrad - o->Vertices.Get(); - f->MappingU[0][0] = U; - f->MappingV[0][0] = V; - f->VertexIndices[1] = v+(x+1==divrad?0:x+1)+y*divrad - o->Vertices.Get(); - f->MappingU[0][1] = U; - f->MappingV[0][1] = V+dV; - f->VertexIndices[2] = v+x+(y+1==divrot?0:(y+1)*divrad) - o->Vertices.Get(); - f->MappingU[0][2] = U+dU; - f->MappingV[0][2] = V; - f->Material = m; - f++; - f->VertexIndices[0] = v+x+(y+1==divrot?0:(y+1)*divrad) - o->Vertices.Get(); - f->MappingU[0][0] = U+dU; - f->MappingV[0][0] = V; - f->VertexIndices[1] = v+(x+1==divrad?0:x+1)+y*divrad - o->Vertices.Get(); - f->MappingU[0][1] = U; - f->MappingV[0][1] = V+dV; - f->VertexIndices[2] = v+(x+1==divrad?0:x+1)+(y+1==divrot?0:(y+1)*divrad) - o->Vertices.Get(); - f->MappingU[0][2] = U+dU; - f->MappingV[0][2] = V+dV; - f->Material = m; - f++; - V += dV; - } - U += dU; - } - o->CalculateNormals(); - return (o); -} - -pl_Obj *plMakeSphere(pl_Float r, pl_uInt divr, pl_uInt divh, pl_Mat *m) { - pl_Obj *o; - pl_Vertex *v; - pl_Face *f; - pl_uInt x, y; - double a, da, yp, ya, yda, yf; - pl_Float U,V,dU,dV; - if (divh < 3) divh = 3; - if (divr < 3) divr = 3; - o = new pl_Obj(2+(divh-2)*(divr),2*divr+(divh-3)*divr*2); - if (!o) return 0; - v = o->Vertices.Get(); - v->x = v->z = 0.0; v->y = r; v++; - v->x = v->z = 0.0; v->y = -r; v++; - ya = 0.0; - yda = PL_PI/(divh-1); - da = (PL_PI*2.0)/divr; - for (y = 0; y < divh - 2; y ++) { - ya += yda; - yp = cos((double) ya)*r; - yf = sin((double) ya)*r; - a = 0.0; - for (x = 0; x < divr; x ++) { - v->y = (pl_Float) yp; - v->x = (pl_Float) (cos((double) a)*yf); - v->z = (pl_Float) (sin((double) a)*yf); - v++; - a += da; - } - } - f = o->Faces.Get(); - v = o->Vertices.Get() + 2; - a = 0.0; - U = 0; - dU = 1.0/divr; - dV = V = 1.0/divh; - for (x = 0; x < divr; x ++) { - f->VertexIndices[0] = 0; - f->VertexIndices[1] = v + (x+1==divr ? 0 : x+1) - o->Vertices.Get(); - f->VertexIndices[2] = v + x - o->Vertices.Get(); - f->MappingU[0][0] = U; - f->MappingV[0][0] = 0; - f->MappingU[0][1] = U+dU; - f->MappingV[0][1] = V; - f->MappingU[0][2] = U; - f->MappingV[0][2] = V; - f->Material = m; - f++; - U += dU; - } - da = 1.0/(divr+1); - v = o->Vertices.Get() + 2; - for (x = 0; x < (divh-3); x ++) { - U = 0; - for (y = 0; y < divr; y ++) { - f->VertexIndices[0] = v+y - o->Vertices.Get(); - f->VertexIndices[1] = v+divr+(y+1==divr?0:y+1) - o->Vertices.Get(); - f->VertexIndices[2] = v+y+divr - o->Vertices.Get(); - f->MappingU[0][0] = U; - f->MappingV[0][0] = V; - f->MappingU[0][1] = U+dU; - f->MappingV[0][1] = V+dV; - f->MappingU[0][2] = U; - f->MappingV[0][2] = V+dV; - f->Material = m; f++; - f->VertexIndices[0] = v+y - o->Vertices.Get(); - f->VertexIndices[1] = v+(y+1==divr?0:y+1) - o->Vertices.Get(); - f->VertexIndices[2] = v+(y+1==divr?0:y+1)+divr - o->Vertices.Get(); - f->MappingU[0][0] = U; - f->MappingV[0][0] = V; - f->MappingU[0][1] = U+dU; - f->MappingV[0][1] = V; - f->MappingU[0][2] = U+dU; - f->MappingV[0][2] = V+dV; - f->Material = m; f++; - U += dU; - } - V += dV; - v += divr; - } - v = o->Vertices.Get() + o->Vertices.GetSize() - divr; - U = 0; - for (x = 0; x < divr; x ++) { - f->VertexIndices[0] = 1; - f->VertexIndices[1] = v + x - o->Vertices.Get(); - f->VertexIndices[2] = v + (x+1==divr ? 0 : x+1) - o->Vertices.Get(); - f->MappingU[0][0] = U; - f->MappingV[0][0] = 1.0; - f->MappingU[0][1] = U; - f->MappingV[0][1] = V; - f->MappingU[0][2] = U+dU; - f->MappingV[0][2] = V; - f->Material = m; - f++; - U += dU; - } - o->CalculateNormals(); - return (o); -} - -pl_Obj *plMakeDisc(pl_Float r, pl_uInt divr, pl_Mat *m) -{ - pl_Obj *o; - pl_Vertex *v; - pl_Face *f; - pl_uInt32 i; - double a, da; - - o=new pl_Obj(divr, divr); - if (!o) return NULL; - - a = 0.0; - da = (2.0*PL_PI)/divr; - v = o->Vertices.Get(); - for (i = 0; i < divr; i ++) - { - v->y = 0.0; - v->x = (pl_Float) (r*cos((double) a)); - v->z = (pl_Float)(r*sin(a)); - v->xformedx = (0.5 + (0.5*cos((double) a))); // temp - v->xformedy = (0.5 + (0.5*sin((double) a))); // use xf - v++; - a += da; - } - - v = o->Vertices.Get(); - f = o->Faces.Get(); - for (i = 0; i < divr; i ++) - { - f->VertexIndices[0] = i == divr-1 ? 0 : i + 1; - f->VertexIndices[1] = i; - f->VertexIndices[2] = 0; - f->MappingU[0][0] = v[(i==divr-1?0:i+1)].xformedx; - f->MappingV[0][0] = v[(i==divr-1?0:i+1)].xformedy; - f->MappingU[0][1] = v[i].xformedx; - f->MappingV[0][1] = v[i].xformedy; - f->MappingU[0][2] = f->MappingV[0][2] = 0.5; - f->Material = m; - f++; - } - - f->VertexIndices[0] = 0; - f->VertexIndices[1] = 2; - f->VertexIndices[2] = 1; - f->MappingU[0][0] = v[0].xformedx; - f->MappingV[0][0] = v[0].xformedy; - f->MappingU[0][1] = v[1].xformedx; - f->MappingV[0][1] = v[1].xformedy; - f->MappingU[0][2] = v[2].xformedx; - f->MappingV[0][2] = v[2].xformedy; - - f->Material = m; - - o->CalculateNormals(); - return o; -} - -pl_Obj *plMakeCylinder(pl_Float r, pl_Float h, pl_uInt divr, pl_Bool captop, - pl_Bool capbottom, pl_Mat *m) { - pl_Obj *o; - pl_Vertex *v, *topverts, *bottomverts, *topcapvert=0, *bottomcapvert=0; - pl_Face *f; - pl_uInt32 i; - double a, da; - if (divr < 3) divr = 3; - o = new pl_Obj(divr*2+((divr==3)?0:(captop?1:0)+(capbottom?1:0)), - divr*2+(divr==3 ? (captop ? 1 : 0) + (capbottom ? 1 : 0) : - (captop ? divr : 0) + (capbottom ? divr : 0))); - if (!o) return 0; - a = 0.0; - da = (2.0*PL_PI)/divr; - v = o->Vertices.Get(); - topverts = v; - for (i = 0; i < divr; i ++) { - v->y = h/2.0f; - v->x = (pl_Float) (r*cos((double) a)); - v->z = (pl_Float)(r*sin(a)); - v->xformedx = (0.5 + (0.5*cos((double) a))); // temp - v->xformedy = (0.5 + (0.5*sin((double) a))); // use xf - v++; - a += da; - } - bottomverts = v; - a = 0.0; - for (i = 0; i < divr; i ++) { - v->y = -h/2.0f; - v->x = (pl_Float) (r*cos((double) a)); - v->z = (pl_Float) (r*sin(a)); - v->xformedx = (0.5 + (0.5*cos((double) a))); - v->xformedy = (0.5 + (0.5*sin((double) a))); - v++; a += da; - } - if (captop && divr != 3) { - topcapvert = v; - v->y = h / 2.0f; - v->x = v->z = 0.0f; - v++; - } - if (capbottom && divr != 3) { - bottomcapvert = v; - v->y = -h / 2.0f; - v->x = v->z = 0.0f; - v++; - } - f = o->Faces.Get(); - for (i = 0; i < divr; i ++) { - f->VertexIndices[0] = bottomverts + i - o->Vertices.Get(); - f->VertexIndices[1] = topverts + i - o->Vertices.Get(); - f->VertexIndices[2] = bottomverts + (i == divr-1 ? 0 : i+1) - o->Vertices.Get(); - f->MappingV[0][0] = f->MappingV[0][2] = 1.0; f->MappingV[0][1] = 0; - f->MappingU[0][0] = f->MappingU[0][1] = i/(double)divr; - f->MappingU[0][2] = ((i+1))/(double)divr; - f->Material = m; f++; - f->VertexIndices[0] = bottomverts + (i == divr-1 ? 0 : i+1) - o->Vertices.Get(); - f->VertexIndices[1] = topverts + i - o->Vertices.Get(); - f->VertexIndices[2] = topverts + (i == divr-1 ? 0 : i+1) - o->Vertices.Get(); - f->MappingV[0][1] = f->MappingV[0][2] = 0; f->MappingV[0][0] = 1.0; - f->MappingU[0][0] = f->MappingU[0][2] = ((i+1))/(double)divr; - f->MappingU[0][1] = (i)/(double)divr; - f->Material = m; f++; - } - if (captop) { - if (divr == 3) { - f->VertexIndices[0] = topverts + 0 - o->Vertices.Get(); - f->VertexIndices[1] = topverts + 2 - o->Vertices.Get(); - f->VertexIndices[2] = topverts + 1 - o->Vertices.Get(); - f->MappingU[0][0] = topverts[0].xformedx; - f->MappingV[0][0] = topverts[0].xformedy; - f->MappingU[0][1] = topverts[1].xformedx; - f->MappingV[0][1] = topverts[1].xformedy; - f->MappingU[0][2] = topverts[2].xformedx; - f->MappingV[0][2] = topverts[2].xformedy; - f->Material = m; f++; - } else { - for (i = 0; i < divr; i ++) { - f->VertexIndices[0] = topverts + (i == divr-1 ? 0 : i + 1) - o->Vertices.Get(); - f->VertexIndices[1] = topverts + i - o->Vertices.Get(); - f->VertexIndices[2] = topcapvert - o->Vertices.Get(); - f->MappingU[0][0] = topverts[(i==divr-1?0:i+1)].xformedx; - f->MappingV[0][0] = topverts[(i==divr-1?0:i+1)].xformedy; - f->MappingU[0][1] = topverts[i].xformedx; - f->MappingV[0][1] = topverts[i].xformedy; - f->MappingU[0][2] = f->MappingV[0][2] = 0.5; - f->Material = m; f++; - } - } - } - if (capbottom) { - if (divr == 3) { - f->VertexIndices[0] = bottomverts + 0 - o->Vertices.Get(); - f->VertexIndices[1] = bottomverts + 1 - o->Vertices.Get(); - f->VertexIndices[2] = bottomverts + 2 - o->Vertices.Get(); - f->MappingU[0][0] = bottomverts[0].xformedx; - f->MappingV[0][0] = bottomverts[0].xformedy; - f->MappingU[0][1] = bottomverts[1].xformedx; - f->MappingV[0][1] = bottomverts[1].xformedy; - f->MappingU[0][2] = bottomverts[2].xformedx; - f->MappingV[0][2] = bottomverts[2].xformedy; - f->Material = m; f++; - } else { - for (i = 0; i < divr; i ++) { - f->VertexIndices[0] = bottomverts + i - o->Vertices.Get(); - f->VertexIndices[1] = bottomverts + (i == divr-1 ? 0 : i + 1) - o->Vertices.Get(); - f->VertexIndices[2] = bottomcapvert - o->Vertices.Get(); - f->MappingU[0][0] = bottomverts[i].xformedx; - f->MappingV[0][0] = bottomverts[i].xformedy; - f->MappingU[0][1] = bottomverts[(i==divr-1?0:i+1)].xformedx; - f->MappingV[0][1] = bottomverts[(i==divr-1?0:i+1)].xformedy; - f->MappingU[0][2] = f->MappingV[0][2] = 0.5; - f->Material = m; f++; - } - } - } - o->CalculateNormals(); - return (o); -} - -pl_Obj *plMakeCone(pl_Float r, pl_Float h, pl_uInt div, - pl_Bool cap, pl_Mat *m) { - pl_Obj *o; - pl_Vertex *v; - pl_Face *f; - pl_uInt32 i; - double a, da; - if (div < 3) div = 3; - o = new pl_Obj(div + (div == 3 ? 1 : (cap ? 2 : 1)), - div + (div == 3 ? 1 : (cap ? div : 0))); - if (!o) return 0; - v = o->Vertices.Get(); - v->x = v->z = 0; v->y = h/2; - v->xformedx = 0.5; - v->xformedy = 0.5; - v++; - a = 0.0; - da = (2.0*PL_PI)/div; - for (i = 1; i <= div; i ++) { - v->y = h/-2.0f; - v->x = (pl_Float) (r*cos((double) a)); - v->z = (pl_Float) (r*sin((double) a)); - v->xformedx = (0.5 + (cos((double) a)*0.5)); - v->xformedy = (0.5 + (sin((double) a)*0.5)); - a += da; - v++; - } - if (cap && div != 3) { - v->y = h / -2.0f; - v->x = v->z = 0.0f; - v->xformedx = 0.5; - v->xformedy = 0.5; - v++; - } - f = o->Faces.Get(); - for (i = 1; i <= div; i ++) { - f->VertexIndices[0] = 0; - f->VertexIndices[1] = o->Vertices.Get() + (i == div ? 1 : i + 1) - o->Vertices.Get(); - f->VertexIndices[2] = o->Vertices.Get() + i - o->Vertices.Get(); - f->MappingU[0][0] = o->Vertices.Get()[0].xformedx; - f->MappingV[0][0] = o->Vertices.Get()[0].xformedy; - f->MappingU[0][1] = o->Vertices.Get()[(i==div?1:i+1)].xformedx; - f->MappingV[0][1] = o->Vertices.Get()[(i==div?1:i+1)].xformedy; - f->MappingU[0][2] = o->Vertices.Get()[i].xformedx; - f->MappingV[0][2] = o->Vertices.Get()[i].xformedy; - f->Material = m; - f++; - } - if (cap) { - if (div == 3) { - f->VertexIndices[0] = 1; - f->VertexIndices[1] = 2; - f->VertexIndices[2] = 3; - f->MappingU[0][0] = o->Vertices.Get()[1].xformedx; - f->MappingV[0][0] = o->Vertices.Get()[1].xformedy; - f->MappingU[0][1] = o->Vertices.Get()[2].xformedx; - f->MappingV[0][1] = o->Vertices.Get()[2].xformedy; - f->MappingU[0][2] = o->Vertices.Get()[3].xformedx; - f->MappingV[0][2] = o->Vertices.Get()[3].xformedy; - f->Material = m; - f++; - } else { - for (i = 1; i <= div; i ++) { - f->VertexIndices[0] = div + 1; - f->VertexIndices[1] = i; - f->VertexIndices[2] = (i==div ? 1 : i+1); - f->MappingU[0][0] = o->Vertices.Get()[div+1].xformedx; - f->MappingV[0][0] = o->Vertices.Get()[div+1].xformedy; - f->MappingU[0][1] = o->Vertices.Get()[i].xformedx; - f->MappingV[0][1] = o->Vertices.Get()[i].xformedy; - f->MappingU[0][2] = o->Vertices.Get()[i==div?1:i+1].xformedx; - f->MappingV[0][2] = o->Vertices.Get()[i==div?1:i+1].xformedy; - f->Material = m; - f++; - } - } - } - o->CalculateNormals(); - return (o); -} - -static pl_uChar verts[6*6] = { - 0,4,1, 1,4,5, 0,1,2, 3,2,1, 2,3,6, 3,7,6, - 6,7,4, 4,7,5, 1,7,3, 7,1,5, 2,6,0, 4,0,6 -}; -static pl_uChar map[24*2*3] = { - 1,0, 1,1, 0,0, 0,0, 1,1, 0,1, - 0,0, 1,0, 0,1, 1,1, 0,1, 1,0, - 0,0, 1,0, 0,1, 1,0, 1,1, 0,1, - 0,0, 1,0, 0,1, 0,1, 1,0, 1,1, - 1,0, 0,1, 0,0, 0,1, 1,0, 1,1, - 1,0, 1,1, 0,0, 0,1, 0,0, 1,1 -}; - - -pl_Obj *plMakeBox(pl_Float w, pl_Float d, pl_Float h, pl_Mat *m) { - pl_uChar *mm = map; - pl_uChar *vv = verts; - pl_Obj *o; - pl_Vertex *v; - pl_Face *f; - pl_uInt x; - o = new pl_Obj(8,12); - if (!o) return 0; - v = o->Vertices.Get(); - v->x = -w/2; v->y = h/2; v->z = d/2; v++; - v->x = w/2; v->y = h/2; v->z = d/2; v++; - v->x = -w/2; v->y = h/2; v->z = -d/2; v++; - v->x = w/2; v->y = h/2; v->z = -d/2; v++; - v->x = -w/2; v->y = -h/2; v->z = d/2; v++; - v->x = w/2; v->y = -h/2; v->z = d/2; v++; - v->x = -w/2; v->y = -h/2; v->z = -d/2; v++; - v->x = w/2; v->y = -h/2; v->z = -d/2; v++; - f = o->Faces.Get(); - for (x = 0; x < 12; x ++) { - f->VertexIndices[0] = *vv++; - f->VertexIndices[1] = *vv++; - f->VertexIndices[2] = *vv++; - f->MappingU[0][0] = (pl_Float) *mm++; - f->MappingV[0][0] = (pl_Float) *mm++; - f->MappingU[0][1] = (pl_Float) *mm++; - f->MappingV[0][1] = (pl_Float) *mm++; - f->MappingU[0][2] = (pl_Float) *mm++; - f->MappingV[0][2] = (pl_Float) *mm++; - f->Material = m; - f++; - } - - o->CalculateNormals(); - return (o); -} - -pl_Obj *plMakePlane(pl_Float w, pl_Float d, pl_uInt res, pl_Mat *m) { - pl_Obj *o; - pl_Vertex *v; - pl_Face *f; - pl_uInt x, y; - o = new pl_Obj((res+1)*(res+1),res*res*2); - if (!o) return 0; - v = o->Vertices.Get(); - for (y = 0; y <= res; y ++) { - for (x = 0; x <= res; x ++) { - v->y = 0; - v->x = ((x*w)/res) - w/2; - v->z = ((y*d)/res) - d/2; - v++; - } - } - f = o->Faces.Get(); - for (y = 0; y < res; y ++) { - for (x = 0; x < res; x ++) { - f->VertexIndices[0] = x+(y*(res+1)); - f->MappingU[0][0] = (x)/(double)res; - f->MappingV[0][0] = (y)/(double)res; - f->VertexIndices[2] = x+1+(y*(res+1)); - f->MappingU[0][2] = ((x+1))/(double)res; - f->MappingV[0][2] = (y)/(double)res; - f->VertexIndices[1] = x+((y+1)*(res+1)); - f->MappingU[0][1] = (x)/(double)res; - f->MappingV[0][1] = ((y+1))/(double)res; - f->Material = m; - f++; - f->VertexIndices[0] = x+((y+1)*(res+1)); - f->MappingU[0][0] = (x)/(double)res; - f->MappingV[0][0] = ((y+1))/(double)res; - f->VertexIndices[2] = x+1+(y*(res+1)); - f->MappingU[0][2] = ((x+1))/(double)res; - f->MappingV[0][2] = (y)/(double)res; - f->VertexIndices[1] = x+1+((y+1)*(res+1)); - f->MappingU[0][1] = ((x+1))/(double)res; - f->MappingV[0][1] = ((y+1))/(double)res; - f->Material = m; - f++; - } - } - o->CalculateNormals(); - return (o); -} diff --git a/oversampling/WDL/plush2/pl_math.cpp b/oversampling/WDL/plush2/pl_math.cpp deleted file mode 100644 index f338a90..0000000 --- a/oversampling/WDL/plush2/pl_math.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/****************************************************************************** -Plush Version 1.2 -math.c -Math and Matrix Control -Copyright (c) 1996-2000, Justin Frankel -******************************************************************************/ - -#include "plush.h" - -void plMatrixRotate(pl_Float matrix[], pl_uChar m, pl_Float Deg) { - pl_uChar m1, m2; - double c,s; - double d= Deg * PL_PI / 180.0; - memset(matrix,0,sizeof(pl_Float)*16); - matrix[((m-1)<<2)+m-1] = matrix[15] = 1.0; - m1 = (m % 3); - m2 = ((m1+1) % 3); - c = cos(d); s = sin(d); - matrix[(m1<<2)+m1]=(pl_Float)c; matrix[(m1<<2)+m2]=(pl_Float)s; - matrix[(m2<<2)+m2]=(pl_Float)c; matrix[(m2<<2)+m1]=(pl_Float)-s; -} - -void plMatrixTranslate(pl_Float m[], pl_Float x, pl_Float y, pl_Float z) { - memset(m,0,sizeof(pl_Float)*16); - m[0] = m[4+1] = m[8+2] = m[12+3] = 1.0; - m[0+3] = x; m[4+3] = y; m[8+3] = z; -} - -void plMatrixMultiply(pl_Float *dest, const pl_Float src[]) { - pl_Float temp[16]; - pl_uInt i; - memcpy(temp,dest,sizeof(pl_Float)*16); - for (i = 0; i < 16; i += 4) { - *dest++ = src[i+0]*temp[(0<<2)+0]+src[i+1]*temp[(1<<2)+0]+ - src[i+2]*temp[(2<<2)+0]+src[i+3]*temp[(3<<2)+0]; - *dest++ = src[i+0]*temp[(0<<2)+1]+src[i+1]*temp[(1<<2)+1]+ - src[i+2]*temp[(2<<2)+1]+src[i+3]*temp[(3<<2)+1]; - *dest++ = src[i+0]*temp[(0<<2)+2]+src[i+1]*temp[(1<<2)+2]+ - src[i+2]*temp[(2<<2)+2]+src[i+3]*temp[(3<<2)+2]; - *dest++ = src[i+0]*temp[(0<<2)+3]+src[i+1]*temp[(1<<2)+3]+ - src[i+2]*temp[(2<<2)+3]+src[i+3]*temp[(3<<2)+3]; - } -} - -void plMatrixApply(pl_Float *m, pl_Float x, pl_Float y, pl_Float z, - pl_Float *outx, pl_Float *outy, pl_Float *outz) { - *outx = x*m[0] + y*m[1] + z*m[2] + m[3]; - *outy = x*m[4] + y*m[5] + z*m[6] + m[7]; - *outz = x*m[8] + y*m[9] + z*m[10] + m[11]; -} - -pl_Float plDotProduct(pl_Float x1, pl_Float y1, pl_Float z1, - pl_Float x2, pl_Float y2, pl_Float z2) { - return ((x1*x2)+(y1*y2)+(z1*z2)); -} - -void plNormalizeVector(pl_Float *x, pl_Float *y, pl_Float *z) { - double length; - length = (*x)*(*x)+(*y)*(*y)+(*z)*(*z); - if (length > 0.0000000001) { - pl_Float t = (pl_Float)sqrt(length); - *x /= t; - *y /= t; - *z /= t; - } else *x = *y = *z = 0.0; -} - diff --git a/oversampling/WDL/plush2/pl_obj.cpp b/oversampling/WDL/plush2/pl_obj.cpp deleted file mode 100644 index 1bfa98c..0000000 --- a/oversampling/WDL/plush2/pl_obj.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/****************************************************************************** -Plush Version 1.2 -obj.c -Object control -Copyright (c) 1996-2000, Justin Frankel -******************************************************************************/ - -#include "plush.h" - -void pl_Obj::Scale(pl_Float s) { - int i = Vertices.GetSize(); - pl_Vertex *v = Vertices.Get(); - while (i--) { - v->x *= s; v->y *= s; v->z *= s; v++; - } - for (i = 0; i < Children.GetSize(); i ++) - if (Children.Get(i)) Children.Get(i)->Scale(s); -} - -void pl_Obj::Stretch(pl_Float x, pl_Float y, pl_Float z) { - int i = Vertices.GetSize(); - pl_Vertex *v = Vertices.Get(); - while (i--) { - v->x *= x; v->y *= y; v->z *= z; v++; - } - for (i = 0; i < Children.GetSize(); i ++) - if (Children.Get(i)) Children.Get(i)->Stretch(x,y,z); -} - -void pl_Obj::Translate(pl_Float x, pl_Float y, pl_Float z) { - int i = Vertices.GetSize(); - pl_Vertex *v = Vertices.Get(); - while (i--) { - v->x += x; v->y += y; v->z += z; v++; - } - for (i = 0; i < Children.GetSize(); i ++) - if (Children.Get(i)) Children.Get(i)->Translate(x,y,z); -} - -void pl_Obj::FlipNormals() { - int i = Vertices.GetSize(); - pl_Vertex *v = Vertices.Get(); - pl_Face *f = Faces.Get(); - while (i--) { - v->nx = - v->nx; v->ny = - v->ny; v->nz = - v->nz; v++; - } - i = Faces.GetSize(); - while (i--) { - f->nx = - f->nx; f->ny = - f->ny; f->nz = - f->nz; - f++; - } - for (i = 0; i < Children.GetSize(); i ++) - if (Children.Get(i)) Children.Get(i)->FlipNormals(); -} - - -pl_Obj *pl_Obj::Clone() { - int i; - pl_Obj *out; - if (!(out = new pl_Obj(Vertices.GetSize(),Faces.GetSize()))) return 0; - for (i = 0; i < Children.GetSize(); i ++) - out->Children.Add(Children.Get(i) ? Children.Get(i)->Clone() : NULL); - - out->Xa = Xa; out->Ya = Ya; out->Za = Za; - out->Xp = Xp; out->Yp = Yp; out->Zp = Zp; - out->GenMatrix = GenMatrix; - memcpy(out->Matrix,Matrix,sizeof(Matrix)); - memcpy(out->Vertices.Get(), Vertices.Get(), sizeof(pl_Vertex) * Vertices.GetSize()); - memcpy(out->Faces.Get(),Faces.Get(),sizeof(pl_Face) * Faces.GetSize()); - return out; -} - -void pl_Obj::SetMaterial(pl_Mat *m, pl_Bool th) { - pl_sInt32 i = Faces.GetSize(); - pl_Face *f = Faces.Get(); - while (i--) (f++)->Material = m; - if (th) for (i = 0; i < Children.GetSize(); i++) - if (Children.Get(i)) Children.Get(i)->SetMaterial(m,true); -} - -void pl_Obj::CalculateNormals() { - int i; - pl_Vertex *v = Vertices.Get(); - pl_Face *f = Faces.Get(); - double x1, x2, y1, y2, z1, z2; - i = Vertices.GetSize(); - while (i--) { - v->nx = 0.0; v->ny = 0.0; v->nz = 0.0; - v++; - } - i = Faces.GetSize(); - while (i--) { - pl_Vertex *vp=Vertices.Get(); - pl_Vertex *fVertices[3] = { - vp+f->VertexIndices[0], - vp+f->VertexIndices[1], - vp+f->VertexIndices[2], - }; - x1 = fVertices[0]->x-fVertices[1]->x; - x2 = fVertices[0]->x-fVertices[2]->x; - y1 = fVertices[0]->y-fVertices[1]->y; - y2 = fVertices[0]->y-fVertices[2]->y; - z1 = fVertices[0]->z-fVertices[1]->z; - z2 = fVertices[0]->z-fVertices[2]->z; - f->nx = (pl_Float) (y1*z2 - z1*y2); - f->ny = (pl_Float) (z1*x2 - x1*z2); - f->nz = (pl_Float) (x1*y2 - y1*x2); - plNormalizeVector(&f->nx, &f->ny, &f->nz); - fVertices[0]->nx += f->nx; - fVertices[0]->ny += f->ny; - fVertices[0]->nz += f->nz; - fVertices[1]->nx += f->nx; - fVertices[1]->ny += f->ny; - fVertices[1]->nz += f->nz; - fVertices[2]->nx += f->nx; - fVertices[2]->ny += f->ny; - fVertices[2]->nz += f->nz; - f++; - } - v = Vertices.Get(); - i = Vertices.GetSize(); - do { - plNormalizeVector(&v->nx, &v->ny, &v->nz); - v++; - } while (--i); - - for (i = 0; i < Children.GetSize(); i ++) - if (Children.Get(i)) Children.Get(i)->CalculateNormals(); -} diff --git a/oversampling/WDL/plush2/pl_pf_tex.h b/oversampling/WDL/plush2/pl_pf_tex.h deleted file mode 100644 index bf08d25..0000000 --- a/oversampling/WDL/plush2/pl_pf_tex.h +++ /dev/null @@ -1,446 +0,0 @@ - -static void -#ifdef PL_PF_MULTITEX -PLMTexTri -#else -PLTexTri -#endif -(LICE_pixel *gmem, int swidth, pl_Face *TriFace, pl_ZBuffer *zbuf, int zfb_width, bool zb_update, - int solidalpha, int solidcomb, LICE_IBitmap *tex, pl_Float *texscales, int texalpha, int texcomb, int texmap -#ifdef PL_PF_MULTITEX - , LICE_IBitmap *tex2, int tex2alpha, int tex2comb, int texmap2 -#endif - - ) -{ - pl_sInt32 C1[3], C3[3], C2[3], dC2[3]={0}, dCL[3]={0},dC1[3]={0}, dX2=0, dX1=0; - pl_Float dZ2=0, dZL=0,dZ1=0; - - PUTFACE_SORT(); - - - solidcomb&=LICE_BLIT_MODE_MASK; - if (solidcomb == 0 && solidalpha == 256) solidcomb=-1; - else if (solidalpha==0) solidcomb=-2; // ignore - int solidalpha2=(256-solidalpha)*256; - - - pl_Float dU2=0,dV2=0,dUL=0,dVL=0; - pl_Float dU1=0, dV1=0; - bool bilinear = (texcomb&LICE_BLIT_FILTER_MASK)==LICE_BLIT_FILTER_BILINEAR; - texcomb&=LICE_BLIT_MODE_MASK|LICE_BLIT_USE_ALPHA; - if (texcomb==LICE_BLIT_MODE_COPY && texalpha==256) texcomb=-1; - else if (texalpha==0) texcomb=-2; - int texalpha2=(256-texalpha); - - int tex_rowspan=0; - LICE_pixel *texture=NULL; - int tex_w=16,tex_h=16; - -#if defined(PLUSH_NO_SOLIDGOURAUD) || defined(PLUSH_NO_TEXTURE) - if (tex) -#endif - { - texture=tex->getBits(); - tex_rowspan = tex->getRowSpan(); - if (tex->isFlipped()) - { - texture += tex_rowspan*(tex->getHeight()-1); - tex_rowspan=-tex_rowspan; - } - tex_w=tex->getWidth(); - tex_h=tex->getHeight(); - tex_rowspan *= 4; - } - pl_sInt32 MappingU_Max=tex_w<<16, MappingV_Max=tex_h<<16; - texscales[0]*=MappingU_Max; - texscales[1]*=MappingV_Max; - tex_w *= 4; - -#ifdef PL_PF_MULTITEX - - pl_Float dU2_2=0,dV2_2=0,dUL_2=0,dVL_2=0; - pl_Float dU1_2=0, dV1_2=0; - int tex_w_2=16,tex_h_2=16; - bool bilinear2 = (tex2comb&LICE_BLIT_FILTER_MASK)==LICE_BLIT_FILTER_BILINEAR; - tex2comb&=LICE_BLIT_MODE_MASK|LICE_BLIT_USE_ALPHA; - if (tex2comb==LICE_BLIT_MODE_COPY && tex2alpha==256) tex2comb=-1; - else if (tex2alpha==0) tex2comb=-2; - int tex2alpha2=(256-tex2alpha); - LICE_pixel *texture_2=NULL; - int tex_rowspan_2 = 0; - pl_sInt32 MappingU_Max_2, MappingV_Max_2; - -#ifdef PLUSH_NO_TEXTURE - if (tex2) -#endif - { - tex_w_2=tex2->getWidth(); - tex_h_2=tex2->getHeight(); - texture_2=tex2->getBits(); - tex_rowspan_2 = tex2->getRowSpan(); - if (tex2->isFlipped()) - { - texture_2 += tex_rowspan_2*(tex2->getHeight()-1); - tex_rowspan_2=-tex_rowspan_2; - } - tex_rowspan_2 *= 4; - } - MappingU_Max_2=tex_w_2<<16; - MappingV_Max_2=tex_h_2<<16; - texscales[2]*=MappingU_Max_2; - texscales[3]*=MappingV_Max_2; - tex_w_2 *= 4; -#endif - - - pl_uChar nm = TriFace->Material->PerspectiveCorrect; - pl_uChar nmb = 0; while (nm) { nmb++; nm >>= 1; } - nmb = plMin(6,nmb); - nm = 1<Scrz[i0]; - pl_Float Z2 = TriFace->Scrz[i1]; - pl_Float Z3 = TriFace->Scrz[i2]; - - pl_Float MappingU1=TriFace->MappingU[texmap][i0]*texscales[0]*Z1; - pl_Float MappingV1=TriFace->MappingV[texmap][i0]*texscales[1]*Z1; - pl_Float MappingU2=TriFace->MappingU[texmap][i1]*texscales[0]*Z2; - pl_Float MappingV2=TriFace->MappingV[texmap][i1]*texscales[1]*Z2; - pl_Float MappingU3=TriFace->MappingU[texmap][i2]*texscales[0]*Z3; - pl_Float MappingV3=TriFace->MappingV[texmap][i2]*texscales[1]*Z3; - -#ifdef PL_PF_MULTITEX - pl_Float MappingU1_2=TriFace->MappingU[texmap2][i0]*texscales[2]*Z1; - pl_Float MappingV1_2=TriFace->MappingV[texmap2][i0]*texscales[3]*Z1; - pl_Float MappingU2_2=TriFace->MappingU[texmap2][i1]*texscales[2]*Z2; - pl_Float MappingV2_2=TriFace->MappingV[texmap2][i1]*texscales[3]*Z2; - pl_Float MappingU3_2=TriFace->MappingU[texmap2][i2]*texscales[2]*Z3; - pl_Float MappingV3_2=TriFace->MappingV[texmap2][i2]*texscales[3]*Z3; -#endif - - int a; - for(a=0;a<3;a++) - { - C1[a] = (pl_sInt32) (TriFace->Shades[i0][a]*(1<<24)); - C2[a] = (pl_sInt32) (TriFace->Shades[i1][a]*(1<<24)); - C3[a] = (pl_sInt32) (TriFace->Shades[i2][a]*(1<<24)); - } - - pl_Float U1, U2; - U1 = U2 = MappingU1; - pl_Float V1,V2; - V1 = V2 = MappingV1; -#ifdef PL_PF_MULTITEX - pl_Float U1_2, U2_2; - U1_2 = U2_2 = MappingU1_2; - pl_Float V1_2, V2_2; - V1_2 = V2_2 = MappingV1_2; -#endif - - pl_sInt32 X2,X1; - X2 = X1 = Scrx[i0]; - pl_sInt32 Y0 = Scry[i0]; - pl_sInt32 Y1 = Scry[i1]; - pl_sInt32 Y2 = Scry[i2]; - - - { - pl_sInt32 dY = Y2-Y0; - if (dY) { - dX2 = (Scrx[i2] - X1) / dY; - - pl_Float v = 1.0/dY; - for(a=0;a<3;a++) dC2[a] = (pl_sInt32) ((C3[a] - C1[a]) * v); - dZ2 = (Z3 - Z1) * v; - dU2 = (MappingU3 - U1) * v; - dV2 = (MappingV3 - V1) * v; - #ifdef PL_PF_MULTITEX - dU2_2 = (MappingU3_2 - U1_2) * v; - dV2_2 = (MappingV3_2 - V1_2) * v; - #endif - } - dY = Y1-Y0; - if (dY) { - dX1 = (Scrx[i1] - X1) / dY; - pl_Float v=1.0/dY; - dZ1 = (Z2 - Z1) * v; - for(a=0;a<3;a++) dC1[a] = (pl_sInt32) ((C2[a] - C1[a]) * v); - dU1 = (MappingU2 - U1) * v; - dV1 = (MappingV2 - V1) * v; - #ifdef PL_PF_MULTITEX - dU1_2 = (MappingU2_2 - U1_2) * v; - dV1_2 = (MappingV2_2 - V1_2) * v; - #endif - if (dX2 < dX1) { - SWAP(dX1,dX2,pl_sInt32); - SWAP(dU1,dU2,pl_Float); - SWAP(dV1,dV2,pl_Float); - #ifdef PL_PF_MULTITEX - SWAP(dU1_2,dU2_2,pl_Float); - SWAP(dV1_2,dV2_2,pl_Float); - #endif - SWAP(dZ1,dZ2,pl_Float); - for(a=0;a<3;a++) - SWAP(dC1[a],dC2[a],pl_sInt32); - stat = 2; - } else stat = 1; - Z2 = Z1; - C2[0] = C1[0]; - C2[1] = C1[1]; - C2[2] = C1[2]; - - } else { - if (Scrx[i1] > X1) { - X2 = Scrx[i1]; - U2 = MappingU2; - V2 = MappingV2; - #ifdef PL_PF_MULTITEX - U2_2 = MappingU2_2; - V2_2 = MappingV2_2; - #endif - stat = 2|4; - } else { - X1 = Scrx[i1]; - SWAP(Z1,Z2,pl_Float) - for(a=0;a<3;a++) SWAP(C1[a],C2[a],pl_sInt32); - U1 = MappingU2; - V1 = MappingV2; - #ifdef PL_PF_MULTITEX - U1_2 = MappingU2_2; - V1_2 = MappingV2_2; - #endif - stat = 1|8; - } - } - pl_sInt32 tmp = (dX1-dX2)*dY; - if (tmp) { - pl_Float v=(1<>XPOS_BITS; - pl_sInt32 Xlen = ((X2+(1<<(XPOS_BITS-1)))>>XPOS_BITS) - XL1; - if (Xlen > 0) { - pl_sInt32 iUL, iVL, idUL, idVL, iULnext, iVLnext; - pl_Float UL = U1; - pl_Float VL = V1; -#ifdef PL_PF_MULTITEX - pl_sInt32 iUL_2, iVL_2, idUL_2, idVL_2, iULnext_2, iVLnext_2; - pl_Float UL_2 = U1_2; - pl_Float VL_2 = V1_2; -#endif - pl_sInt32 CL[3] = {C1[0],C1[1], C1[2]}; - pl_Float pZL,ZL; - pl_Float t = 1.0f / (pZL = ZL = Z1); - gmem += XL1; - zbuf += XL1; - - XL1 += Xlen; // update to new line end pos so we can adjust gmem/zbuf later - iULnext = ((pl_sInt32) (UL*t)); - iVLnext = ((pl_sInt32) (VL*t)); -#ifdef PL_PF_MULTITEX - iULnext_2 = ((pl_sInt32) (UL_2*t)); - iVLnext_2 = ((pl_sInt32) (VL_2*t)); -#endif - do { - UL += dUL; - VL += dVL; - iUL = iULnext; - iVL = iVLnext; - pZL += pdZL; - t = 1.0f/pZL; - iULnext = ((pl_sInt32) (UL*t)); - iVLnext = ((pl_sInt32) (VL*t)); - idUL = (iULnext - iUL)>>nmb; - idVL = (iVLnext - iVL)>>nmb; - if (idUL>MappingU_Max) idUL=MappingU_Max; - else if (idUL<-MappingU_Max) idUL=-MappingU_Max; - if (idVL>MappingV_Max) idVL=MappingV_Max; - else if (idVL<-MappingV_Max) idVL=-MappingV_Max; - - // todo: this is slow as shit, should we force textures to be powers of two? hehe - if (iUL<0) do iUL+=MappingU_Max; while (iUL<0); - else while (iUL >= MappingU_Max) iUL-=MappingU_Max; - if (iVL<0) do iVL+=MappingV_Max; while (iVL<0); - else while (iVL >= MappingV_Max) iVL-=MappingV_Max; - -#ifdef PL_PF_MULTITEX - UL_2 += dUL_2; - VL_2 += dVL_2; - iUL_2 = iULnext_2; - iVL_2 = iVLnext_2; - iULnext_2 = ((pl_sInt32) (UL_2*t)); - iVLnext_2 = ((pl_sInt32) (VL_2*t)); - idUL_2 = (iULnext_2 - iUL_2)>>nmb; - idVL_2 = (iVLnext_2 - iVL_2)>>nmb; - if (idUL_2>MappingU_Max_2) idUL_2=MappingU_Max_2; - else if (idUL_2<-MappingU_Max_2) idUL_2=-MappingU_Max_2; - if (idVL_2>MappingV_Max_2) idVL_2=MappingV_Max_2; - else if (idVL_2<-MappingV_Max_2) idVL_2=-MappingV_Max_2; - - // todo: this is slow as shit, should we force textures to be powers of two? hehe - if (iUL_2<0) do iUL_2+=MappingU_Max_2; while (iUL_2<0); - else while (iUL_2 >= MappingU_Max_2) iUL_2-=MappingU_Max_2; - if (iVL_2<0) do iVL_2+=MappingV_Max_2; while (iVL_2<0); - else while (iVL_2 >= MappingV_Max_2) iVL_2-=MappingV_Max_2; - -#endif - - pl_uInt n = nm; - Xlen -= n; - if (Xlen < 0) n += Xlen; - if (zfb_width) do { - if (*zbuf < ZL) { - if (zb_update) *zbuf = (pl_ZBuffer) ZL; - - #ifdef PL_PF_MULTITEX - TextureMakePixel2((LICE_pixel_chan *)gmem,solidcomb,solidalpha,solidalpha2,CL, bilinear, - iUL,iVL,tex_w,tex_h,texture,tex_rowspan,texcomb,texalpha,texalpha2, - bilinear2, iUL_2,iVL_2, - tex_w_2,tex_h_2, - texture_2,tex_rowspan_2,tex2comb,tex2alpha,tex2alpha2); - #else - TextureMakePixel((LICE_pixel_chan *)gmem,solidcomb,solidalpha,solidalpha2,CL, bilinear, iUL,iVL, - tex_w,tex_h, - texture,tex_rowspan,texcomb,texalpha,texalpha2); - #endif - - } - zbuf++; - gmem++; - ZL += dZL; - CL[0] += dCL[0]; - CL[1] += dCL[1]; - CL[2] += dCL[2]; - iUL += idUL; - iVL += idVL; - - if (iUL<0) iUL+=MappingU_Max; - else if (iUL >= MappingU_Max) iUL -= MappingU_Max; - if (iVL<0) iVL+=MappingV_Max; - else if (iVL >= MappingV_Max) iVL -= MappingV_Max; -#ifdef PL_PF_MULTITEX - iUL_2 += idUL_2; - iVL_2 += idVL_2; - - if (iUL_2<0) iUL_2+=MappingU_Max_2; - else if (iUL_2 >= MappingU_Max_2) iUL_2 -= MappingU_Max_2; - if (iVL_2<0) iVL_2+=MappingV_Max_2; - else if (iVL_2 >= MappingV_Max_2) iVL_2 -= MappingV_Max_2; -#endif - } while (--n); - else do { - - #ifdef PL_PF_MULTITEX - TextureMakePixel2((LICE_pixel_chan *)gmem,solidcomb,solidalpha,solidalpha2,CL, bilinear, - iUL,iVL,tex_w,tex_h,texture,tex_rowspan,texcomb,texalpha,texalpha2, - bilinear2, iUL_2,iVL_2, - tex_w_2,tex_h_2, - texture_2,tex_rowspan_2,tex2comb,tex2alpha,tex2alpha2); - #else - TextureMakePixel((LICE_pixel_chan *)gmem,solidcomb,solidalpha,solidalpha2,CL, bilinear, iUL,iVL, - tex_w,tex_h, - texture,tex_rowspan,texcomb,texalpha,texalpha2); - #endif - - - gmem++; - CL[0] += dCL[0]; - CL[1] += dCL[1]; - CL[2] += dCL[2]; - iUL += idUL; - iVL += idVL; - - if (iUL<0) iUL+=MappingU_Max; - else if (iUL >= MappingU_Max) iUL -= MappingU_Max; - if (iVL<0) iVL+=MappingV_Max; - else if (iVL >= MappingV_Max) iVL -= MappingV_Max; - -#ifdef PL_PF_MULTITEX - iUL_2 += idUL_2; - iVL_2 += idVL_2; - - if (iUL_2<0) iUL_2+=MappingU_Max_2; - else if (iUL_2 >= MappingU_Max_2) iUL_2 -= MappingU_Max_2; - if (iVL_2<0) iVL_2+=MappingV_Max_2; - else if (iVL_2 >= MappingV_Max_2) iVL_2 -= MappingV_Max_2; -#endif - - } while (--n); - } while (Xlen > 0); - gmem += swidth-XL1; - zbuf += zfb_width-XL1; - } else { // xlen <=0 ,no drawing - gmem += swidth; - zbuf += zfb_width; - } - Z1 += dZ1; - U1 += dU1; - V1 += dV1; -#ifdef PL_PF_MULTITEX - U1_2 += dU1_2; - V1_2 += dV1_2; -#endif - X1 += dX1; - X2 += dX2; - C1[0] += dC1[0]; - C1[1] += dC1[1]; - C1[2] += dC1[2]; - } -} - - - diff --git a/oversampling/WDL/plush2/pl_putface.cpp b/oversampling/WDL/plush2/pl_putface.cpp deleted file mode 100644 index 8a83de5..0000000 --- a/oversampling/WDL/plush2/pl_putface.cpp +++ /dev/null @@ -1,713 +0,0 @@ -#include "plush.h" -#include "../lice/lice_combine.h" - -//#define PLUSH_NO_SOLIDFLAT // make non-texturemapped flat shading optimized engine -//#define PLUSH_NO_SOLIDGOURAUD // disable non-texturemapped gouraud optimized engine -//#define PLUSH_NO_TEXTURE // disable single-texture optimized engine -//#define PLUSH_NO_MULTITEXTURE // disable multitexture (this can do any of em) -#define XPOS_BITS 19 // allows 2^13 max screen width, or 8192px - -#define SWAP(a,b,t) { t ____tmp=(a); (a)=(b); (b)=____tmp; } - -#define PUTFACE_SORT() \ - int i0 = 0; int i1 = 1; int i2 = 2; int stat; \ - if (TriFace->Scry[0] > TriFace->Scry[1]) { i0 = 1; i1 = 0; } \ - if (TriFace->Scry[i0] > TriFace->Scry[2]) { SWAP(i0,i2,int); } \ - if (TriFace->Scry[i1] > TriFace->Scry[i2]) { SWAP(i1,i2,int); } \ - int Scrx[3] = {(int)(TriFace->Scrx[0]*(1<Scrx[1]*(1<Scrx[2]*(1<Scry[0]+0.5), (int) (TriFace->Scry[1]+0.5), (int) (TriFace->Scry[2]+0.5)}; \ - -#define DO_STAT_XDELTAS \ - if (stat & 1) { \ - dX1 = (Scrx[i2]-(X1 = Scrx[i1]))/dY; \ - if (stat & 8) dX2 = (Scrx[i2]-(X2 = Scrx[i0]))/dY; \ - } \ - else if (stat & 2) { \ - dX2 = (Scrx[i2]-(X2 = Scrx[i1]))/dY; \ - if (stat & 4) dX1 = (Scrx[i2]-(X1 = Scrx[i0]))/dY; \ - } - - -static inline void OverlayBlend(int &red, int &green, int &blue, int &alpha, int r, int g, int b, int a, int usea) -{ - int da=(256-usea)*128; - int srcr = r*usea+da, srcg = g*usea+da, srcb = b*usea+da, srca = usea*a + da; - red = ( red*( (red*(32768-srcr))/256 + srcr ) )/32768; - green = ( green*( (green*(32768-srcg))/256 + srcg ) )/32768; - blue = ( blue*( (blue*(32768-srcb))/256 + srcb ) )/32768; - alpha = ( alpha*( (alpha*(32768-srca))/256 + srca ) )/32768; -} - -static inline void MulBlend(int &red, int &green, int &blue, int &alpha, int r, int g, int b, int a, int ta) -{ - int ta2=(256-ta)*256; - red = (r*ta*red + red*ta2)/65536; - green = (g*ta*green + green*ta2)/65536; - blue = (b*ta*blue + blue*ta2)/65536; - alpha = (a*ta*alpha + alpha*ta2)/65536; -} - - -static inline void AdjustHSV(int &red, int &green, int &blue, int r, int g, int b, int texalpha) -{ - int h,s,v; - __LICE_RGB2HSV(red,green,blue,&h,&s,&v); - h+=(((r+r/2) - 192) * texalpha)/256; - if (h<0)h+=384; - else if (h>=384) h-=384; - s+=((g-128)*texalpha)/256; - if (s&~0xff) - { - if (s<0)s=0; - else s=255; - } - v+=((b-128)*texalpha)/256; - if (v&~0xff) - { - if (v<0)v=0; - else v=255; - } - __LICE_HSV2RGB(h,s,v,&red,&green,&blue); -} - -static inline void DodgeBlend(int &red, int &green, int &blue, int &alpha, int r, int g, int b, int a, int ta) -{ - int src_r = 256-r*ta/256; - int src_g = 256-g*ta/256; - int src_b = 256-b*ta/256; - int src_a = 256-(a*ta)/256; - - red = src_r > 1 ? 256*red / src_r : 256*red; - green = src_g > 1 ? 256*green / src_g : 256*green; - blue = src_b > 1 ? 256*blue / src_b : 256*blue; - alpha = src_a > 1 ? 256*alpha / src_a : 256*alpha; -} - - -static void inline DoTextureCombine(int texcomb, int r, int g, int b, int a, int &red, int &green, int &blue, int &alpha, int texalpha, int texalpha2) -{ - switch (texcomb) - { - case LICE_BLIT_MODE_COPY: - red = (r*texalpha + red*texalpha2) >> 8; - green = (g*texalpha + green*texalpha2) >> 8; - blue = (b*texalpha + blue*texalpha2) >> 8; - alpha = (a*texalpha + alpha*texalpha2) >> 8; - break; - case LICE_BLIT_MODE_ADD: - red += (r*texalpha) >> 8; - green += (g*texalpha) >> 8; - blue += (b*texalpha) >> 8; - alpha += (a*texalpha) >> 8; - break; - case LICE_BLIT_MODE_MUL: - MulBlend(red,green,blue,alpha,r,g,b,a,texalpha); - break; - case LICE_BLIT_MODE_DODGE: - DodgeBlend(red,green,blue,alpha,r,g,b,a,texalpha); - - break; - case LICE_BLIT_MODE_OVERLAY: - OverlayBlend(red,green,blue,alpha,r,g,b,a, texalpha); - break; - case LICE_BLIT_MODE_HSVADJ: - AdjustHSV(red,green,blue,r,g,b,texalpha); - break; - case LICE_BLIT_MODE_COPY|LICE_BLIT_USE_ALPHA: - { - int ta=(texalpha*(a+1)); - int ta2=(65536-ta); - red = (r*ta + red*ta2) >> 16; - green = (g*ta + green*ta2) >> 16; - blue = (b*ta + blue*ta2) >> 16; - alpha = (a*ta + alpha*ta2) >> 16; - } - break; - case LICE_BLIT_MODE_ADD|LICE_BLIT_USE_ALPHA: - { - int ta=(texalpha*(a+1)); - red += (r*ta) >> 16; - green += (g*ta) >> 16; - blue += (b*ta) >> 16; - alpha += (a*ta) >> 16; - } - break; - case LICE_BLIT_MODE_DODGE|LICE_BLIT_USE_ALPHA: - { - int ta=(texalpha*(a+1))/256; - DodgeBlend(red,green,blue,alpha,r,g,b,a,ta); - } - break; - case LICE_BLIT_MODE_MUL|LICE_BLIT_USE_ALPHA: - MulBlend(red,green,blue,alpha,r,g,b,a,(texalpha*(a+1))/256); - break; - case LICE_BLIT_MODE_OVERLAY|LICE_BLIT_USE_ALPHA: - OverlayBlend(red,green,blue,alpha,r,g,b,a, (texalpha*(a+1))/256); - break; - case LICE_BLIT_MODE_HSVADJ|LICE_BLIT_USE_ALPHA: - AdjustHSV(red,green,blue,r,g,b,(texalpha*(a+1))/256); - break; - case -2: - break; - default: - red=r; green=g; blue=b; alpha=a; - break; - } -} - - -static void inline TextureMakePixelSolidCombine(int &red, int &green, int &blue, int &alpha, - pl_sInt32 *CL, int solidcomb, int solidalpha, - int solidalpha2, - LICE_pixel_chan *gmemptr) -{ - - switch (solidcomb) - { - case LICE_BLIT_MODE_COPY: - red = ((CL[0]>>8)*solidalpha + gmemptr[LICE_PIXEL_R]*solidalpha2)>>16; - green = ((CL[1]>>8)*solidalpha + gmemptr[LICE_PIXEL_G]*solidalpha2)>>16; - blue = ((CL[2]>>8)*solidalpha + gmemptr[LICE_PIXEL_B]*solidalpha2)>>16; - alpha = solidalpha; - break; - case LICE_BLIT_MODE_ADD: - red = gmemptr[LICE_PIXEL_R] + (((CL[0]>>8)*solidalpha)>>16); - green = gmemptr[LICE_PIXEL_G] + (((CL[1]>>8)*solidalpha)>>16); - blue = gmemptr[LICE_PIXEL_B] + (((CL[2]>>8)*solidalpha)>>16); - alpha = gmemptr[LICE_PIXEL_A] + solidalpha; - break; - case LICE_BLIT_MODE_DODGE: - red=gmemptr[LICE_PIXEL_R]; - green=gmemptr[LICE_PIXEL_G]; - blue=gmemptr[LICE_PIXEL_B]; - alpha=gmemptr[LICE_PIXEL_A]; - DodgeBlend(red,green,blue,alpha,CL[0]>>16,CL[1]>>16,CL[2]>>16,solidalpha,solidalpha); - break; - case LICE_BLIT_MODE_MUL: - red=gmemptr[LICE_PIXEL_R]; - green=gmemptr[LICE_PIXEL_G]; - blue=gmemptr[LICE_PIXEL_B]; - alpha=gmemptr[LICE_PIXEL_A]; - MulBlend(red,green,blue,alpha,CL[0]>>16,CL[1]>>16,CL[2]>>16,solidalpha,solidalpha); - break; - case LICE_BLIT_MODE_OVERLAY: - red=gmemptr[LICE_PIXEL_R]; - green=gmemptr[LICE_PIXEL_G]; - blue=gmemptr[LICE_PIXEL_B]; - alpha=gmemptr[LICE_PIXEL_A]; - OverlayBlend(red,green,blue,alpha,CL[0]>>16,CL[1]>>16,CL[2]>>16,solidalpha, solidalpha); - break; - case LICE_BLIT_MODE_HSVADJ: - red=gmemptr[LICE_PIXEL_R]; - green=gmemptr[LICE_PIXEL_G]; - blue=gmemptr[LICE_PIXEL_B]; - alpha=gmemptr[LICE_PIXEL_A]; - AdjustHSV(red,green,blue,CL[0]>>16,CL[1]>>16,CL[2]>>16,solidalpha); - break; - case -2: - red=gmemptr[LICE_PIXEL_R]; - green=gmemptr[LICE_PIXEL_G]; - blue=gmemptr[LICE_PIXEL_B]; - alpha=gmemptr[LICE_PIXEL_A]; - break; - default: - red=CL[0]>>16; - green=CL[1]>>16; - blue=CL[2]>>16; - alpha=solidalpha; - break; - } -} - - -static void inline TextureMakePixel2(LICE_pixel_chan *gmemptr, - int solidcomb, int solidalpha, int solidalpha2, - pl_sInt32 *CL, - bool bilinear, - pl_sInt32 iUL, pl_sInt32 iVL, - pl_sInt32 texwidth, pl_sInt32 texheight, - LICE_pixel *texture, int tex_rowspan, - int texcomb, - int texalpha, - int texalpha2, - bool bilinear2, - pl_sInt32 iUL_2, pl_sInt32 iVL_2, - pl_sInt32 texwidth_2, pl_sInt32 texheight_2, - LICE_pixel *texture2, int tex_rowspan_2, - int tex2comb, - int tex2alpha, - int tex2alpha2) -{ - - int red,green,blue,alpha; - - TextureMakePixelSolidCombine(red,green,blue,alpha,CL,solidcomb,solidalpha,solidalpha2,gmemptr); - - int r,g,b,a; - -#if defined(PLUSH_NO_TEXTURE) - if (texture) -#endif - { - const int xpos=(iUL>>14)&~3; - const int ypos=iVL>>16; - const LICE_pixel_chan *rd = ((LICE_pixel_chan*)texture) + xpos+ypos*tex_rowspan; - - if (bilinear) - { - __LICE_BilinearFilterI_2(&r,&g,&b,&a,rd, - ypos < texheight - 1 ? rd+tex_rowspan : ((LICE_pixel_chan *)texture)+xpos, - xpos < texwidth - 4 ? 4 : 4-texwidth, - iUL&65535,iVL&65535); - } - else - { - r=rd[LICE_PIXEL_R]; g=rd[LICE_PIXEL_G]; b=rd[LICE_PIXEL_B]; a=rd[LICE_PIXEL_A]; - } - - DoTextureCombine(texcomb, r,g,b,a, red,green,blue,alpha,texalpha,texalpha2); - } - -#ifdef PLUSH_NO_TEXTURE - if (texture2) -#endif - { - const int xpos=(iUL_2>>14)&~3; - const int ypos=iVL_2>>16; - const LICE_pixel_chan *rd = ((LICE_pixel_chan*)texture2) + xpos+ypos*tex_rowspan_2; - - if (bilinear2) - { - __LICE_BilinearFilterI_2(&r,&g,&b,&a,rd, - ypos < texheight_2 - 1 ? rd+tex_rowspan_2 : ((LICE_pixel_chan *)texture2)+xpos, - xpos < texwidth_2 - 4 ? 4 : 4-texwidth_2, - iUL_2&65535,iVL_2&65535); - } - else - { - r=rd[LICE_PIXEL_R]; g=rd[LICE_PIXEL_G]; b=rd[LICE_PIXEL_B]; a=rd[LICE_PIXEL_A]; - } - - DoTextureCombine(tex2comb, r,g,b,a, red,green,blue,alpha,tex2alpha,tex2alpha2); - } - - _LICE_MakePixelClamp(gmemptr, red,green,blue,alpha); -} - -static void inline TextureMakePixel(LICE_pixel_chan *gmemptr, - int solidcomb, int solidalpha, int solidalpha2, - pl_sInt32 *CL, - bool bilinear, - pl_sInt32 iUL, pl_sInt32 iVL, - pl_sInt32 texwidth, pl_sInt32 texheight, - LICE_pixel *texture, int tex_rowspan, - int texcomb, - int texalpha, - int texalpha2) -{ - - int red,green,blue,alpha; - - if ( -#ifdef PLUSH_NO_SOLIDGOURAUD - !texture|| -#endif - texcomb!=-1) - TextureMakePixelSolidCombine(red,green,blue,alpha,CL,solidcomb,solidalpha,solidalpha2,gmemptr); - - - -#ifdef PLUSH_NO_SOLIDGOURAUD - if (texture) -#endif - { - int r,g,b,a; - const int xpos=(iUL>>14)&~3; - const int ypos=iVL>>16; - const LICE_pixel_chan *rd = ((LICE_pixel_chan*)texture) + xpos+ypos*tex_rowspan; - - if (bilinear) - { - - __LICE_BilinearFilterI_2(&r,&g,&b,&a,rd, - ypos < texheight - 1 ? rd+tex_rowspan : ((LICE_pixel_chan *)texture)+xpos, - xpos < texwidth - 4 ? 4 : 4-texwidth, - iUL&65535,iVL&65535); - } - else - { - r=rd[LICE_PIXEL_R]; g=rd[LICE_PIXEL_G]; b=rd[LICE_PIXEL_B]; a=rd[LICE_PIXEL_A]; - } - - DoTextureCombine(texcomb, r,g,b,a, red,green,blue,alpha,texalpha,texalpha2); - } - - _LICE_MakePixelClamp(gmemptr, red,green,blue,alpha); -} - - - -#ifndef PLUSH_NO_TEXTURE -#include "pl_pf_tex.h" -#endif - -#ifndef PLUSH_NO_MULTITEXTURE -#define PL_PF_MULTITEX -#include "pl_pf_tex.h" -#endif - - - - -template class PLSolidPutFace -{ - public: -#ifndef PLUSH_NO_SOLIDGOURAUD - static void SolidGouraud(LICE_pixel *gmem, int swidth, pl_Face *TriFace, int alpha, pl_ZBuffer *zbuf, int zfb_width, bool zb_update) - { - pl_Float dZL=0, dZ1=0, dZ2=0; - pl_sInt32 dX1=0, dX2=0, C1[3], C2[3], dC1[3]={0}, dC2[3]={0}, dCL[3]={0}, C3[3]; - - PUTFACE_SORT(); - - - int a; - for(a=0;a<3;a++) - { - C1[a] = (pl_sInt32) (TriFace->Shades[i0][a]*(1<<24)); - C2[a] = (pl_sInt32) (TriFace->Shades[i1][a]*(1<<24)); - C3[a] = (pl_sInt32) (TriFace->Shades[i2][a]*(1<<24)); - } - pl_sInt32 X2,X1; - X2 = X1 = Scrx[i0]; - pl_Float Z1 = TriFace->Scrz[i0]; - pl_Float Z2 = TriFace->Scrz[i1]; - pl_Float Z3 = TriFace->Scrz[i2]; - - pl_sInt32 Y0 = Scry[i0]; - pl_sInt32 Y1 = Scry[i1]; - pl_sInt32 Y2 = Scry[i2]; - - { - pl_sInt32 dY = Y2 - Y0; - if (dY) { - dX2 = (Scrx[i2] - X1) / dY; - for(a=0;a<3;a++) dC2[a] = (C3[a] - C1[a]) / dY; - dZ2 = (Z3 - Z1) / dY; - } - dY = Y1 - Y0; - if (dY) { - dX1 = (Scrx[i1] - X1) / dY; - for(a=0;a<3;a++) - dC1[a] = (C2[a] - C1[a]) / dY; - dZ1 = (Z2 - Z1) / dY; - if (dX2 < dX1) { - SWAP(dX2,dX1,pl_sInt32); - for(a=0;a<3;a++) SWAP(dC1[a],dC2[a],pl_sInt32); - SWAP(dZ1,dZ2,pl_Float); - stat = 2; - } else stat = 1; - Z2 = Z1; - C2[0] = C1[0]; - C2[1] = C1[1]; - C2[2] = C1[2]; - } else { - if (Scrx[i1] > X1) { - X2 = Scrx[i1]; - stat = 2|4; - } else { - for(a=0;a<3;a++) SWAP(C1[a],C2[a],pl_sInt32); - SWAP(Z1,Z2,pl_Float); - X1 = Scrx[i1]; - stat = 1|8; - } - } - - pl_sInt32 tmp = (dX1-dX2)*dY; - if (tmp) { - double v=(1<>XPOS_BITS; - pl_sInt32 XL2 = ((X2+(1<<(XPOS_BITS-1)))>>XPOS_BITS) - XL1; - if (XL2 > 0) { - gmem += XL1; - XL1 += XL2; - pl_sInt32 CL[3] = {C1[0],C1[1],C1[2]}; - if (zbuf) - { - pl_Float ZL = Z1; - zbuf += XL1-XL2; - do { - if (*zbuf < ZL) { - if (zb_update) *zbuf = (pl_ZBuffer) ZL; - - Comb::doPix((LICE_pixel_chan *)gmem,CL[0]>>16,CL[1]>>16,CL[2]>>16,255,alpha); - } - gmem++; - zbuf++; - ZL += dZL; - CL[0] += dCL[0]; - CL[1] += dCL[1]; - CL[2] += dCL[2]; - } while (--XL2); - zbuf -= XL1; - } - else do { - Comb::doPix((LICE_pixel_chan *)gmem,CL[0]>>16,CL[1]>>16,CL[2]>>16,255,alpha); - gmem++; - CL[0] += dCL[0]; - CL[1] += dCL[1]; - CL[2] += dCL[2]; - } while (--XL2); - gmem -= XL1; - } - gmem += swidth; - zbuf += zfb_width; - X1 += dX1; - X2 += dX2; - C1[0] += dC1[0]; - C1[1] += dC1[1]; - C1[2] += dC1[2]; - Z1 += dZ1; - Y0++; - } - } -#endif - -#ifndef PLUSH_NO_SOLIDFLAT - static void Solid(LICE_pixel *gmem, int swidth, pl_Face *TriFace, int alpha, pl_ZBuffer *zbuf, int zfb_width, bool zb_update) - { - pl_sInt32 dX1=0, dX2=0; - pl_Float dZL=0, dZ1=0, dZ2=0; - - PUTFACE_SORT(); - - int col0 = (int) (TriFace->Shades[0][0]*255.0); - int col1 = (int) (TriFace->Shades[0][1]*255.0); - int col2 = (int) (TriFace->Shades[0][2]*255.0); - - pl_sInt32 X1,X2; - X2 = X1 = Scrx[i0]; - pl_sInt32 Y0 = Scry[i0]; - pl_sInt32 Y1 = Scry[i1]; - pl_sInt32 Y2 = Scry[i2]; - - pl_Float Z1 = TriFace->Scrz[i0]; - pl_Float Z2 = TriFace->Scrz[i1]; - pl_Float Z3 = TriFace->Scrz[i2]; - - { - pl_sInt32 dY = Y2-Y0; - if (dY) { - dX2 = (Scrx[i2] - X1) / dY; - dZ2 = (Z3 - Z1) / dY; - } - dY = Y1-Y0; - if (dY) { - dX1 = (Scrx[i1] - X1) / dY; - dZ1 = (Z2 - Z1) / dY; - if (dX2 < dX1) { - SWAP(dX1,dX2,pl_sInt32); - SWAP(dZ1,dZ2,pl_Float); - stat = 2; - } else stat = 1; - Z2 = Z1; - } else { - if (Scrx[i1] > X1) { - X2 = Scrx[i1]; - stat = 2|4; - } else { - X1 = Scrx[i1]; - SWAP(Z1,Z2,pl_Float); - stat = 1|8; - } - } - - if (zbuf) - { - pl_sInt32 tmp=(dX1-dX2)*dY; - if (tmp) dZL = ((dZ1-dZ2)*dY)*(double)(1<>XPOS_BITS; - pl_sInt32 XL2 = ((X2+(1<<(XPOS_BITS-1)))>>XPOS_BITS) - XL1; - if (XL2 > 0) { - gmem += XL1; - XL1 += XL2; - if (zbuf) - { - pl_Float ZL = Z1; - zbuf += XL1-XL2; - do { - if (*zbuf < ZL) { - if (zb_update) *zbuf = (pl_ZBuffer) ZL; - Comb::doPix((LICE_pixel_chan *)gmem,col0,col1,col2,255,alpha); - } - gmem++; - zbuf++; - ZL += dZL; - } while (--XL2); - zbuf -= XL1; - } - else - { - do { - Comb::doPix((LICE_pixel_chan *)gmem,col0,col1,col2,255,alpha); - gmem++; - } while (--XL2); - } - gmem -= XL1; - - } - gmem += swidth; - zbuf += zfb_width; - Z1 += dZ1; - X1 += dX1; - X2 += dX2; - Y0++; - } - } -#endif -}; - -void pl_Cam::PutFace(pl_Face *TriFace) -{ - LICE_pixel *gmem = m_fBuffer.m_buf; - if (WDL_NOT_NORMALLY(!gmem)) return; - - int zfb_width = 0; - int zBufferable = TriFace->Material->zBufferable; - pl_ZBuffer *zb = NULL; - if (zBufferable && - zBuffer.GetSize() && - WDL_NORMALLY(zBuffer.GetSize() >= m_fBuffer.m_w*m_fBuffer.m_h) - ) - { - zfb_width = m_fBuffer.m_w; - zb = zBuffer.Get(); - } - - int swidth = m_fBuffer.m_span; - if (m_fBuffer.m_flipped) - { - gmem += swidth*(m_fBuffer.m_h-1); - swidth=-swidth; - } - - pl_Mat *mat=TriFace->Material; - -#ifndef PLUSH_NO_MULTITEXTURE - - #ifndef PLUSH_NO_TEXTURE - if (mat->Texture&&mat->Texture2) - #else - #ifndef PLUSH_NO_SOLIDGOURAUD - if (mat->Texture||mat->Texture2) - #endif - #endif - { - pl_Float texsc[4]; - memcpy(texsc,mat->TexScaling,sizeof(mat->TexScaling)); - memcpy(texsc+2,mat->Tex2Scaling,sizeof(mat->Tex2Scaling)); - int tidx = mat->TexMapIdx; - if (tidx<0 || tidx>=PLUSH_MAX_MAPCOORDS)tidx=PLUSH_MAX_MAPCOORDS-1; - int tidx2 = mat->Tex2MapIdx; - if (tidx2<0 || tidx2>=PLUSH_MAX_MAPCOORDS)tidx2=PLUSH_MAX_MAPCOORDS-1; - - PLMTexTri(gmem,swidth,TriFace,zb,zfb_width,zBufferable!=2,(int) (mat->SolidOpacity*256.0),mat->SolidCombineMode, - mat->Texture,texsc,(int) (mat->TexOpacity*256.0),mat->TexCombineMode,tidx, - mat->Texture2,(int) (mat->Tex2Opacity*256.0),mat->Tex2CombineMode,tidx2 - ); - return; - } -#endif - - -#ifndef PLUSH_NO_TEXTURE - #ifndef PLUSH_NO_SOLIDGOURAUD - if (mat->Texture||mat->Texture2) - #endif - { - LICE_IBitmap *tex=mat->Texture ? mat->Texture : mat->Texture2; - int talpha = (int) (mat->Texture ? mat->TexOpacity*256.0 : mat->Tex2Opacity*256.0); - int tcomb = (int) (mat->Texture ? mat->TexCombineMode : mat->Tex2CombineMode); - int tidx = (mat->Texture ? mat->TexMapIdx: mat->Tex2MapIdx); - if (tidx<0 || tidx>=PLUSH_MAX_MAPCOORDS)tidx=PLUSH_MAX_MAPCOORDS-1; - pl_Float texsc[2]; - memcpy(texsc,mat->Texture ? mat->TexScaling : mat->Tex2Scaling,sizeof(texsc)); - PLTexTri(gmem,swidth,TriFace,zb,zfb_width,zBufferable!=2,(int) (mat->SolidOpacity*256.0),mat->SolidCombineMode,tex,texsc,talpha,tcomb,tidx); - return; - } -#endif - - int alpha=(int) (mat->SolidOpacity*256.0); - if (!alpha) return; - -#ifndef PLUSH_NO_SOLIDGOURAUD -#ifndef PLUSH_NO_SOLIDFLAT - if (mat->Smoothing) -#endif - { - #define __LICE__ACTION(comb) PLSolidPutFace::SolidGouraud(gmem,swidth,TriFace,alpha,zb,zfb_width, zBufferable!=2); - __LICE_ACTION_CONSTANTALPHA(mat->SolidCombineMode,alpha,true); - #undef __LICE__ACTION - return; - } -#endif - -#ifndef PLUSH_NO_SOLIDFLAT - - #define __LICE__ACTION(comb) PLSolidPutFace::Solid(gmem,swidth,TriFace,alpha,zb,zfb_width, zBufferable!=2); - __LICE_ACTION_CONSTANTALPHA(mat->SolidCombineMode,alpha,true); - #undef __LICE__ACTION - -#endif // PLUSH_NO_SOLIDFLAT -} - - diff --git a/oversampling/WDL/plush2/pl_read_3ds.cpp b/oversampling/WDL/plush2/pl_read_3ds.cpp deleted file mode 100644 index 9e29ea5..0000000 --- a/oversampling/WDL/plush2/pl_read_3ds.cpp +++ /dev/null @@ -1,347 +0,0 @@ -/****************************************************************************** -Plush Version 1.2 -read_3ds.c -3DS Object Reader -Copyright (c) 1996-2000, Justin Frankel -******************************************************************************/ - -#include "plush.h" - -typedef struct -{ - pl_uInt16 id; - void (*func)(pl_uChar *ptr, pl_uInt32 p); -} _pl_3DSChunk; - -static pl_Obj *obj; -static pl_Obj *bobj; -static pl_Obj *lobj; -static pl_sInt16 currentobj; -static pl_Mat *_m; - -static pl_Float _pl3DSReadFloat(pl_uChar **ptr); -static pl_uInt32 _pl3DSReadDWord(pl_uChar **ptr); -static pl_uInt16 _pl3DSReadWord(pl_uChar **ptr); -static void _pl3DSChunkReader(pl_uChar *ptr, int len); -static void _pl3DSRGBFReader(pl_uChar *f, pl_uInt32 p); -static void _pl3DSRGBBReader(pl_uChar *f, pl_uInt32 p); -static int _pl3DSASCIIZReader(pl_uChar *ptr, pl_uInt32 p, char *as); -static void _pl3DSObjBlockReader(pl_uChar *ptr, pl_uInt32 p); -static void _pl3DSTriMeshReader(pl_uChar *f, pl_uInt32 p); -static void _pl3DSVertListReader(pl_uChar *f, pl_uInt32 p); -static void _pl3DSFaceListReader(pl_uChar *f, pl_uInt32 p); -static void _pl3DSFaceMatReader(pl_uChar *f, pl_uInt32 p); -static void MapListReader(pl_uChar *f, pl_uInt32 p); -static pl_sInt16 _pl3DSFindChunk(pl_uInt16 id); - -static _pl_3DSChunk _pl3DSChunkNames[] = { - {0x4D4D,NULL}, /* Main */ - {0x3D3D,NULL}, /* Object Mesh */ - {0x4000,_pl3DSObjBlockReader}, - {0x4100,_pl3DSTriMeshReader}, - {0x4110,_pl3DSVertListReader}, - {0x4120,_pl3DSFaceListReader}, - {0x4130,_pl3DSFaceMatReader}, - {0x4140,MapListReader}, - {0xAFFF,NULL}, /* Material */ - {0xA010,NULL}, /* Ambient */ - {0xA020,NULL}, /* Diff */ - {0xA030,NULL}, /* Specular */ - {0xA200,NULL}, /* Texture */ - {0x0010,_pl3DSRGBFReader}, - {0x0011,_pl3DSRGBBReader}, -}; - -pl_Obj *plRead3DSObjFromFile(char *fn, pl_Mat *m) -{ - FILE *f = fopen(fn, "rb"); - if (!f) return 0; - fseek(f, 0, 2); - pl_uInt32 p = ftell(f); - rewind(f); - - WDL_HeapBuf buf; - buf.Resize(p); - int s = fread(buf.Get(), 1, p, f); - fclose(f); - - if(!s) return 0; - - return plRead3DSObj(buf.Get(), s, m); -} - -pl_Obj *plRead3DSObjFromResource(HINSTANCE hInst, int resid, pl_Mat *m) -{ -#ifdef _WIN32 - HRSRC hResource = FindResource(hInst, MAKEINTRESOURCE(resid), "3DS"); - if(!hResource) return NULL; - - DWORD imageSize = SizeofResource(hInst, hResource); - if(imageSize < 6) return NULL; - - HGLOBAL res = LoadResource(hInst, hResource); - const void* pResourceData = LockResource(res); - if(!pResourceData) return NULL; - - unsigned char *data = (unsigned char *)pResourceData; - - pl_Obj *o = plRead3DSObj(data, imageSize, m); - - DeleteObject(res); - - return o; -#else - return 0; -#endif -} - -pl_Obj *plRead3DSObj(void *ptr, int size, pl_Mat *m) -{ - _m = m; - obj = bobj = lobj = 0; - currentobj = 0; - - _pl3DSChunkReader((pl_uChar *)ptr, size); - - return bobj; -} - -static pl_Float _pl3DSReadFloat(pl_uChar **ptr) { - pl_uInt32 *i; - pl_IEEEFloat32 c; - i = (pl_uInt32 *) &c; - *i = _pl3DSReadDWord(ptr); - return ((pl_Float) c); -} - -static pl_uInt32 _pl3DSReadDWord(pl_uChar **ptr) -{ - pl_uInt32 r; - pl_uChar *p = *ptr; - r = *p++; - r |= (*p++)<<8; - r |= (*p++)<<16; - r |= (*p++)<<24; - *ptr += 4; - return r; -} - -static pl_uInt16 _pl3DSReadWord(pl_uChar **ptr) -{ - pl_uInt16 r; - pl_uChar *p = *ptr; - r = *p++; - r |= (*p++)<<8; - *ptr += 2; - return r; -} - -static void _pl3DSRGBFReader(pl_uChar *f, pl_uInt32 p) -{ - pl_Float c[3]; - if(p < 3*4) return; - c[0] = _pl3DSReadFloat(&f); - c[1] = _pl3DSReadFloat(&f); - c[2] = _pl3DSReadFloat(&f); -} - -static void _pl3DSRGBBReader(pl_uChar *f, pl_uInt32 p) -{ - unsigned char c[3]; - if(p < 3) return; - memcpy(c, f, sizeof(c)); -} - -static int _pl3DSASCIIZReader(pl_uChar *ptr, pl_uInt32 p, char *as) -{ - int l = 0; - while (*ptr && p>0) - { - if(as) *as++ = *ptr; - ptr++; - l++; - p--; - } - if(as) *as = 0; - return l+1; -} - -static void _pl3DSObjBlockReader(pl_uChar *ptr, pl_uInt32 p) -{ - int l = _pl3DSASCIIZReader(ptr, p, 0); - ptr += l; - p -= l; - _pl3DSChunkReader(ptr, p); -} - -static void _pl3DSTriMeshReader(pl_uChar *ptr, pl_uInt32 p) -{ - pl_uInt32 i; - pl_Face *face; - obj = new pl_Obj; - _pl3DSChunkReader(ptr, p); - i = obj->Faces.GetSize(); - face = obj->Faces.Get(); - while (i--) - { - pl_Vertex *vp=obj->Vertices.Get(); - pl_Vertex *fVertices[3] = { - vp+face->VertexIndices[0], - vp+face->VertexIndices[1], - vp+face->VertexIndices[2], - }; - face->MappingU[0][0] = fVertices[0]->xformedx; - face->MappingV[0][0] = fVertices[0]->xformedy; - face->MappingU[0][1] = fVertices[1]->xformedx; - face->MappingV[0][1] = fVertices[1]->xformedy; - face->MappingU[0][2] = fVertices[2]->xformedx; - face->MappingV[0][2] = fVertices[2]->xformedy; - face++; - } - obj->CalculateNormals(); - if (currentobj == 0) - { - currentobj = 1; - lobj = bobj = obj; - } - else - { - lobj->Children.Add(obj); - lobj = obj; - } -} - -static void _pl3DSVertListReader(pl_uChar *f, pl_uInt32 p) -{ - pl_uInt16 nv; - pl_Vertex *v; - int len = (int)p; - nv = _pl3DSReadWord(&f); - len -= 2; - if(len <= 0) return; - obj->Vertices.Resize(nv); - v = obj->Vertices.Get(); - while (nv--) - { - memset(v,0,sizeof(pl_Vertex)); - v->x = _pl3DSReadFloat(&f); - v->y = _pl3DSReadFloat(&f); - v->z = _pl3DSReadFloat(&f); - len -= 3*4; - if(len < 0) return; - v++; - } -} - -static void _pl3DSFaceListReader(pl_uChar *f, pl_uInt32 p) -{ - pl_uInt16 nv; - pl_uInt16 c[3]; - pl_uInt16 flags; - pl_Face *face; - int len = (int)p; - - nv = _pl3DSReadWord(&f); - len -= 2; - if(len <= 0) return; - obj->Faces.Resize(nv); - face = obj->Faces.Get(); - while (nv--) - { - memset(face,0,sizeof(pl_Face)); - c[0] = _pl3DSReadWord(&f); - c[1] = _pl3DSReadWord(&f); - c[2] = _pl3DSReadWord(&f); - flags = _pl3DSReadWord(&f); - len -= 4*2; - if(len < 0) return; - - face->VertexIndices[0] = (c[0]&0x0000FFFF); - face->VertexIndices[1] = (c[1]&0x0000FFFF); - face->VertexIndices[2] = (c[2]&0x0000FFFF); - face->Material = _m; - face++; - } - if(len) _pl3DSChunkReader(f, len); -} - -static void _pl3DSFaceMatReader(pl_uChar *ptr, pl_uInt32 p) -{ - pl_uInt16 n, nf; - - int l = _pl3DSASCIIZReader(ptr, p, 0); - ptr += l; - p -= l; - - n = _pl3DSReadWord(&ptr); - while (n--) - { - nf = _pl3DSReadWord(&ptr); - } -} - -static void MapListReader(pl_uChar *f, pl_uInt32 p) -{ - pl_uInt16 nv; - pl_Float c[2]; - pl_Vertex *v; - int len = (int) p; - nv = _pl3DSReadWord(&f); - len -= 2; - v = obj->Vertices.Get(); - if (nv == obj->Vertices.GetSize()) while (nv--) - { - c[0] = _pl3DSReadFloat(&f); - c[1] = _pl3DSReadFloat(&f); - len -= 2*4; - if (len < 0) return; - v->xformedx = c[0]; - v->xformedy = c[1]; - v++; - } -} - -static pl_sInt16 _pl3DSFindChunk(pl_uInt16 id) -{ - pl_sInt16 i; - for (i = 0; i < sizeof(_pl3DSChunkNames)/sizeof(_pl3DSChunkNames[0]); i++) - if (id == _pl3DSChunkNames[i].id) return i; - return -1; -} - -static void _pl3DSChunkReader(pl_uChar *ptr, int len) -{ - pl_uInt32 hlen; - pl_uInt16 hid; - pl_sInt16 n; - - while (len > 0) - { - hid = _pl3DSReadWord(&ptr); - len -= 2; - if(len <= 0) return; - hlen = _pl3DSReadDWord(&ptr); - len -= 4; - if(len <= 0) return; - if (hlen == 0) return; - hlen -= 6; - n = _pl3DSFindChunk(hid); - if (n < 0) - { - ptr += hlen; - len -= hlen; - } - else - { - pl_uChar *p = ptr; - if (_pl3DSChunkNames[n].func != NULL) - _pl3DSChunkNames[n].func(p, hlen); - else - _pl3DSChunkReader(p, hlen); - - ptr += hlen; - len -= hlen; - } - } -} - diff --git a/oversampling/WDL/plush2/pl_read_cob.cpp b/oversampling/WDL/plush2/pl_read_cob.cpp deleted file mode 100644 index 20d7e93..0000000 --- a/oversampling/WDL/plush2/pl_read_cob.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/****************************************************************************** -Plush Version 1.2 -read_cob.c -ASCII COB Object Reader -Copyright (c) 1996-2000, Justin Frankel -******************************************************************************/ - -#include "plush.h" - -#define PL_COB_MAX_LINELENGTH 1024 - -pl_Obj *plReadCOBObj(char *fn, pl_Mat *mat) { - FILE *fp = fopen(fn,"rt"); - int p1,m1,p2,m2,p3,m3; - char temp_string[PL_COB_MAX_LINELENGTH]; - float TransMatrix[4][4]; - pl_Obj *obj; - pl_sInt32 x,i2; - int numVertices, numMappingVertices, numFaces, i; - pl_Float *MappingVertices = 0; - if (!fp) return 0; - - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - if (memcmp("Caligari",temp_string,8)) { fclose(fp); return 0; } - - do { - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - } while (!feof(fp) && memcmp("Transform",temp_string,9)); - if (feof(fp)) { fclose(fp); return 0; } - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - sscanf(temp_string,"%f %f %f %f", - &TransMatrix[0][0],&TransMatrix[0][1],&TransMatrix[0][2],&TransMatrix[0][3]); - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - sscanf(temp_string,"%f %f %f %f", - &TransMatrix[1][0],&TransMatrix[1][1],&TransMatrix[1][2],&TransMatrix[1][3]); - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - sscanf(temp_string,"%f %f %f %f", - &TransMatrix[2][0],&TransMatrix[2][1],&TransMatrix[2][2],&TransMatrix[2][3]); - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - sscanf(temp_string,"%f %f %f %f", - &TransMatrix[3][0],&TransMatrix[3][1],&TransMatrix[3][2],&TransMatrix[3][3]); - - do { - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - } while (!feof(fp) && memcmp("World Vertices",temp_string,12)); - if (feof(fp) || sscanf(temp_string,"World Vertices %d",&numVertices) != 1) - { fclose(fp); return 0; } - - rewind(fp); - do { - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - } while (!feof(fp) && memcmp("Texture Vertices",temp_string,16)); - if (feof(fp) || - sscanf(temp_string,"Texture Vertices %d",&numMappingVertices) != 1) { - fclose(fp); return 0; - } - - rewind(fp); - do { - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - } while (!feof(fp) && memcmp("Faces",temp_string,5)); - if (feof(fp) || sscanf(temp_string,"Faces %d",&numFaces) != 1) { - fclose(fp); return 0; - } - for (x = numFaces; x; x--) { - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - if (feof(fp) || sscanf(temp_string+4," verts %d",&i) != 1 || i < 3) { - fclose(fp); - return 0; - } - numFaces += i-3; - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - } - obj = new pl_Obj(numVertices,numFaces); - if (!obj) { fclose(fp); return 0; } - rewind(fp); - do { - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - } while (!feof(fp) && memcmp("World Vertices",temp_string,12)); - if (feof(fp)) { delete obj; fclose(fp); return 0; } - for (x = 0; x < numVertices; x ++) { - float xp, yp, zp; - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - if (feof(fp) || - sscanf(temp_string,"%f %f %f", &xp, &yp, &zp) != 3) { - delete obj; fclose(fp); return 0; - } - obj->Vertices.Get()[x].x = (TransMatrix[0][0]*xp+TransMatrix[0][1]*yp+ - TransMatrix[0][2]*zp+TransMatrix[0][3]); - obj->Vertices.Get()[x].y = (TransMatrix[1][0]*xp+TransMatrix[1][1]*yp+ - TransMatrix[1][2]*zp+TransMatrix[1][3]); - obj->Vertices.Get()[x].z = (TransMatrix[2][0]*xp+TransMatrix[2][1]*yp+ - TransMatrix[2][2]*zp+TransMatrix[2][3]); - } - rewind(fp); - do { - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - } while (!feof(fp) && memcmp("Texture Vertices",temp_string,16)); - if (!feof(fp)) { - MappingVertices = (pl_Float *) - malloc(sizeof(pl_Float ) * numMappingVertices * 2); - if (MappingVertices) { - for (x = 0; x < numMappingVertices; x ++) { - float p1, p2; - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - if (feof(fp) || sscanf(temp_string,"%f %f", &p1, &p2) != 2) { - free(MappingVertices); delete obj; fclose(fp); return 0; - } - MappingVertices[x*2] = p1; - MappingVertices[x*2+1] = p2; - } - } - } - rewind(fp); - do { - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - } while (!feof(fp) && memcmp("Faces",temp_string,5)); - if (feof(fp)) { - if (MappingVertices) free(MappingVertices); - delete obj; fclose(fp); return 0; - } - for (x = 0; x < numFaces; x ++) { - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - sscanf(temp_string+4," verts %d",&i); - fgets(temp_string,PL_COB_MAX_LINELENGTH,fp); - if (i == 3) { - if (feof(fp) || sscanf(temp_string,"<%d,%d> <%d,%d> <%d,%d>", - &p3,&m3,&p2,&m2,&p1,&m1) != 6) { - if (MappingVertices) free(MappingVertices); - delete obj; fclose(fp); return 0; - } - obj->Faces.Get()[x].VertexIndices[0] = p1; - obj->Faces.Get()[x].VertexIndices[1] = p2; - obj->Faces.Get()[x].VertexIndices[2] = p3; - if (MappingVertices) { - obj->Faces.Get()[x].MappingU[0][0] = MappingVertices[m1*2]; - obj->Faces.Get()[x].MappingV[0][0] = MappingVertices[m1*2+1]; - obj->Faces.Get()[x].MappingU[0][1] = MappingVertices[m2*2]; - obj->Faces.Get()[x].MappingV[0][1] = MappingVertices[m2*2+1]; - obj->Faces.Get()[x].MappingU[0][2] = MappingVertices[m3*2]; - obj->Faces.Get()[x].MappingV[0][2] = MappingVertices[m3*2+1]; - } - obj->Faces.Get()[x].Material = mat; - } else { - int p[16],m[16]; - if (feof(fp)) { - if (MappingVertices) free(MappingVertices); - delete obj; fclose(fp); return 0; - } - sscanf(temp_string, - "<%d,%d> <%d,%d> <%d,%d> <%d,%d> " - "<%d,%d> <%d,%d> <%d,%d> <%d,%d> " - "<%d,%d> <%d,%d> <%d,%d> <%d,%d> " - "<%d,%d> <%d,%d> <%d,%d> <%d,%d> ", - p+0,m+0,p+1,m+1,p+2,m+2,p+3,m+3, - p+4,m+4,p+5,m+5,p+6,m+6,p+7,m+7, - p+8,m+8,p+9,m+9,p+10,m+10,p+11,m+11, - p+12,m+12,p+13,m+13,p+14,m+14,p+15,m+15); - for (i2 = 1; i2 < (i-1); i2 ++) { - obj->Faces.Get()[x].VertexIndices[0] = p[0]; - obj->Faces.Get()[x].VertexIndices[1] = p[i2+1]; - obj->Faces.Get()[x].VertexIndices[2] = p[i2]; - if (MappingVertices) { - obj->Faces.Get()[x].MappingU[0][0] = MappingVertices[m[0]*2]; - obj->Faces.Get()[x].MappingV[0][0] = MappingVertices[m[0]*2+1]; - obj->Faces.Get()[x].MappingU[0][1] = MappingVertices[m[i2+1]*2]; - obj->Faces.Get()[x].MappingV[0][1] = MappingVertices[m[i2+1]*2+1]; - obj->Faces.Get()[x].MappingU[0][2] = MappingVertices[m[i2]*2]; - obj->Faces.Get()[x].MappingV[0][2] = MappingVertices[m[i2]*2+1]; - } - obj->Faces.Get()[x].Material = mat; - x++; - } - x--; - } - } - if (MappingVertices) free(MappingVertices); - obj->CalculateNormals(); - fclose(fp); - return obj; -} diff --git a/oversampling/WDL/plush2/pl_read_jaw.cpp b/oversampling/WDL/plush2/pl_read_jaw.cpp deleted file mode 100644 index a894721..0000000 --- a/oversampling/WDL/plush2/pl_read_jaw.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/****************************************************************************** -Plush Version 1.2 -read_jaw.c -Jaw3D Object Reader -Copyright (c) 1996-2000, Justin Frankel -******************************************************************************* - Notes on .JAW files: - This is a file format created by Jawed Karim for Jaw3D - (http://jaw3d.home.ml.org). - -- updated 11/6/00 - www.jawed.com - It is very simple, and lets one easily create ones own models using only - a text editor. The format is pretty simple: - The first line must be "Light: (x,y,z)" where x,y, and z are the x y and - z components of the lightsource vector (I think ;) - A series of lines, numbered 0 to n, in the format of - "i: x y z", where i is the vertex number (which should be listed in - order, and x y and z are the coordinates of that vertex. - A series of lines, having the format "tri a, b, c" where a b and c are - the vertices that the face uses. It is unclear at this time which - way the vertices are listed (ccw or cw), so just make em consistent - and you can always use plFlipObjectNormals() on the loaded object. - That is it! (I told ya it was simple). -******************************************************************************/ - -#include "plush.h" - -pl_Obj *plReadJAWObj(char *filename, pl_Mat *m) { - FILE *jawfile; - pl_Obj *obj; - pl_uInt32 i; - pl_sInt crap; - char line[256]; - pl_uInt32 total_points = 0, total_polys = 0; - if ((jawfile = fopen(filename, "r")) == NULL) return 0; - fgets(line, 256, jawfile); /* Ignores lightsource info */ - while (fgets(line, 256, jawfile) != NULL) - if (strstr(line, ":") != NULL) total_points++; - - rewind(jawfile); fgets(line, 256, jawfile); - while (fgets(line, 256, jawfile) != NULL) - if (strstr(line, "tri") != NULL) total_polys++; - - rewind(jawfile); fgets(line, 256, jawfile); - obj = new pl_Obj(total_points,total_polys); - - i = 0; - while (fgets(line, 256, jawfile) != NULL) if (strstr(line, ":") != NULL) { - float x, y, z; - sscanf(line, "%d: %f %f %f",&crap,&x,&y,&z); - obj->Vertices.Get()[i].x = (pl_Float) x; - obj->Vertices.Get()[i].y = (pl_Float) y; - obj->Vertices.Get()[i].z = (pl_Float) z; - i++; - } - rewind(jawfile); fgets(line, 256, jawfile); - i = 0; - while (fgets(line, 256, jawfile) != NULL) if (strstr(line, "tri") != NULL) { - pl_uInt32 a,b,c; - sscanf(line, "tri %ld, %ld, %ld", &a, &b, &c); - obj->Faces.Get()[i].VertexIndices[0] = a; - obj->Faces.Get()[i].VertexIndices[1] = c; - obj->Faces.Get()[i].VertexIndices[2] = b; - obj->Faces.Get()[i].Material = m; - i++; - } - fclose(jawfile); - obj->CalculateNormals(); - return obj; -} diff --git a/oversampling/WDL/plush2/pl_spline.cpp b/oversampling/WDL/plush2/pl_spline.cpp deleted file mode 100644 index 78791e9..0000000 --- a/oversampling/WDL/plush2/pl_spline.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/****************************************************************************** -Plush Version 1.2 -spline.c -n-th Dimensional Spline Interpolator -Copyright (c) 1996-2000, Justin Frankel -******************************************************************************/ - -#include "plush.h" - -void pl_Spline::GetPoint(pl_Float frame, pl_Float *out) { - pl_sInt32 i, i_1, i0, i1, i2; - pl_Float time1,time2,time3; - pl_Float t1,t2,t3,t4,u1,u2,u3,u4,v1,v2,v3; - pl_Float a,b,c,d; - - int numKeys=keys.GetSize(); - pl_Float *keyptrs = keys.Get(); - - a = (1-tens)*(1+cont)*(1+bias); - b = (1-tens)*(1-cont)*(1-bias); - c = (1-tens)*(1-cont)*(1+bias); - d = (1-tens)*(1+cont)*(1-bias); - v1 = t1 = -a / 2.0; u1 = a; - u2 = (-6-2*a+2*b+c)/2.0; v2 = (a-b)/2.0; t2 = (4+a-b-c) / 2.0; - t3 = (-4+b+c-d) / 2.0; - u3 = (6-2*b-c+d)/2.0; - v3 = b/2.0; - t4 = d/2.0; u4 = -t4; - - i0 = (pl_uInt) frame; - i_1 = i0 - 1; - while (i_1 < 0) i_1 += numKeys; - i1 = i0 + 1; - while (i1 >= numKeys) i1 -= numKeys; - i2 = i0 + 2; - while (i2 >= numKeys) i2 -= numKeys; - time1 = frame - (pl_Float) ((pl_uInt) frame); - time2 = time1*time1; - time3 = time2*time1; - i0 *= keyWidth; - i1 *= keyWidth; - i2 *= keyWidth; - i_1 *= keyWidth; - for (i = 0; i < keyWidth; i ++) { - a = t1*keyptrs[i+i_1]+t2*keyptrs[i+i0]+t3*keyptrs[i+i1]+t4*keyptrs[i+i2]; - b = u1*keyptrs[i+i_1]+u2*keyptrs[i+i0]+u3*keyptrs[i+i1]+u4*keyptrs[i+i2]; - c = v1*keyptrs[i+i_1]+v2*keyptrs[i+i0]+v3*keyptrs[i+i1]; - *out++ = a*time3 + b*time2 + c*time1 + keyptrs[i+i0]; - } -} diff --git a/oversampling/WDL/plush2/plush.h b/oversampling/WDL/plush2/plush.h deleted file mode 100644 index 0fea6f8..0000000 --- a/oversampling/WDL/plush2/plush.h +++ /dev/null @@ -1,607 +0,0 @@ -/****************************************************************************** - plush.h - PLUSH 3D VERSION 2.0 MAIN HEADER - Copyright (c) 1996-2000 Justin Frankel - Copyright (c) 1998-2000 Nullsoft, Inc. - Copyright (c) 2008 Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - -******************************************************************************/ - -#ifndef _PLUSH_H_ -#define _PLUSH_H_ - -#include -#include -#include -#include - -#include "../lice/lice.h" // using LICE for images -#include "../ptrlist.h" -#include "../wdltypes.h" - -typedef float pl_ZBuffer; /* z-buffer type (must be float) */ -typedef double pl_Float; /* General floating point */ -typedef float pl_IEEEFloat32; /* IEEE 32 bit floating point */ -typedef signed int pl_sInt32; /* signed 32 bit integer */ -typedef unsigned int pl_uInt32; /* unsigned 32 bit integer */ -typedef signed short int pl_sInt16; /* signed 16 bit integer */ -typedef unsigned short int pl_uInt16; /* unsigned 16 bit integer */ -typedef signed int pl_sInt; /* signed optimal integer */ -typedef unsigned int pl_uInt; /* unsigned optimal integer */ -typedef bool pl_Bool; /* boolean */ -typedef unsigned char pl_uChar; /* unsigned 8 bit integer */ -typedef signed char pl_sChar; /* signed 8 bit integer */ - - - -/* pi! */ -#define PL_PI 3.141592653589793238 - -/* Utility min() and max() functions */ -#define plMin(x,y) (( ( x ) > ( y ) ? ( y ) : ( x ))) -#define plMax(x,y) (( ( x ) < ( y ) ? ( y ) : ( x ))) - - - -/* -** Light modes. Used with plLight.Type or plLightSet(). -** Note that PL_LIGHT_POINT_ANGLE assumes no falloff and uses the angle between -** the light and the point, PL_LIGHT_POINT_DISTANCE has falloff with proportion -** to distance**2 (see plLightSet() for setting it), PL_LIGHT_POINT does both. -*/ -#define PL_LIGHT_NONE (0x0) -#define PL_LIGHT_VECTOR (0x1) -#define PL_LIGHT_POINT (0x2|0x4) -#define PL_LIGHT_POINT_DISTANCE (0x2) -#define PL_LIGHT_POINT_ANGLE (0x4) - - -#define PLUSH_MAX_MAPCOORDS 3 // 2 + envmap slot - - -class pl_Mat -{ -public: - pl_Mat() - { - memset(Ambient,0,sizeof(Ambient)); - Diffuse[0]=Diffuse[1]=Diffuse[2]=1.0; - SolidOpacity=1.0; - SolidCombineMode= LICE_BLIT_MODE_COPY; - - Texture=NULL; - TexCombineMode = LICE_BLIT_MODE_ADD; //LICE_BLIT_USE_SOURCE_ALPHA? - TexOpacity=1.0; - TexScaling[0]=TexScaling[1]=1.0; - TexMapIdx=0; - - Texture2=NULL; - Tex2CombineMode = LICE_BLIT_MODE_ADD; - Tex2Opacity=1.0; - Tex2Scaling[0]=Tex2Scaling[1]=1.0; - Tex2MapIdx=-1; - - FadeDist=0.0; - Smoothing=Lightable=true; - zBufferable=1; - PerspectiveCorrect=16; - BackfaceCull=true; - BackfaceIllumination=0.0; - - cachedTexture=cachedTexture2=0; - cachesInvalid=true; - } - - ~pl_Mat() - { - delete cachedTexture; - delete cachedTexture2; - } - - - pl_Bool Smoothing; // smoothing of lighting - pl_Bool Lightable; // affected by lights - pl_uChar zBufferable; /* Can this material be Z-buffered? 2=yes, but does not update Z buffer */ - pl_uChar PerspectiveCorrect; /* Correct texture perspective every n pixels */ - - pl_Float FadeDist WDL_FIXALIGN; /* For distance fading, distance at which intensity is 0. set to 0.0 for no distance shading */ - - pl_Bool BackfaceCull; /* Are backfacing polys drawn? */ - pl_Float BackfaceIllumination WDL_FIXALIGN; /* Illuminated by lights behind them, and by how much of a factor? */ - - // colors - pl_Float Ambient[3]; /* RGB of surface (0-1 is a good range) */ - pl_Float Diffuse[3]; /* RGB of diffuse (0-1 is a good range) */ - pl_Float SolidOpacity; - int SolidCombineMode; /* LICE combine mode for first pass (color), default should be replace (or add-black for transparent) */ - - // textures - LICE_IBitmap *Texture; /* Texture map (not owned by Material but a reference)*/ - pl_Float TexScaling[2] WDL_FIXALIGN; /* Texture map scaling */ - pl_Float TexOpacity; - int TexCombineMode; /* Texture combine mode (generally should be additive) */ - int TexMapIdx; // -1 for env - - LICE_IBitmap *Texture2; - pl_Float Tex2Scaling[2] WDL_FIXALIGN; - pl_Float Tex2Opacity; - int Tex2CombineMode; - int Tex2MapIdx; // -1 for env - - - void InvalidateTextureCaches() { cachesInvalid=true; } // call this if you change Texture or Texture2 after rendering - -private: - bool cachesInvalid; - LICE_IBitmap *cachedTexture,*cachedTexture2; // these may need to be LICE_GL_MemBitmaps etc - -} WDL_FIXALIGN; - - -struct pl_Vertex { - pl_Float x, y, z; /* Vertex coordinate (objectspace) */ - pl_Float nx, ny, nz; /* Unit vertex normal (objectspace) */ - - pl_Float xformedx, xformedy, xformedz; /* Transformed vertex coordinate (cameraspace) */ - pl_Float xformednx, xformedny, xformednz; /* Transformed unit vertex normal (cameraspace) */ -}; - -struct pl_Face { - pl_Mat *Material; /* Material of triangle */ - int VertexIndices[3]; /* Vertices of triangle */ - - pl_Float nx WDL_FIXALIGN; - pl_Float ny; - pl_Float nz; /* Normal of triangle (object space) */ - - pl_Float MappingU[PLUSH_MAX_MAPCOORDS][3], MappingV[PLUSH_MAX_MAPCOORDS][3]; /* Texture mapping coordinates */ - - pl_Float sLighting[3]; /* Face static lighting. Should usually be 0.0 */ - pl_Float vsLighting[3][3]; /* Vertex static lighting. Should usually be 0.0 */ - - - // calculated: - pl_Float Shades[3][3]; /* colors (first 3 used for flat, all for Gouraud) */ - pl_Float Scrx[3], Scry[3]; /* Projected screen coordinates */ - pl_Float Scrz[3]; /* Projected 1/Z coordinates */ - -}; - - -class pl_Obj { -public: - pl_Obj(int nv=0, int nf=0) - { - if (nv) memset(Vertices.Resize(nv),0,nv*sizeof(pl_Vertex)); - if (nf) memset(Faces.Resize(nf),0,nf*sizeof(pl_Face)); - - GenMatrix=true; - Xp=Yp=Zp=Xa=Ya=Za=0.0; - } - ~pl_Obj() { Children.Empty(true); } - - pl_Obj *Clone(); - void Scale(pl_Float sc); - void Stretch(pl_Float x, pl_Float y, pl_Float z); // scales but preserves normals - void Translate(pl_Float x, pl_Float y, pl_Float z); - void FlipNormals(); - - void SetMaterial(pl_Mat *m, pl_Bool recurse=true); - void CalculateNormals(); - - - pl_Float Xp, Yp, Zp, Xa, Ya, Za; /* Position and rotation of object: - Note: rotations are around X then Y then Z. Measured in degrees */ - pl_Float Matrix[16]; /* Transformation matrix */ - pl_Float RotMatrix[16]; /* Rotation-only, for normals */ - - WDL_TypedBuf Vertices; - WDL_TypedBuf Faces; - WDL_PtrList Children; - - pl_Bool GenMatrix; /* Generate Matrix from X-Z* if set */ -}; - - -class pl_Spline { -public: - pl_Spline() { cont=1.0; bias=0.3; tens=0.3; keyWidth=1; } - ~pl_Spline () { } - void GetPoint(pl_Float frame, pl_Float *out); - WDL_TypedBuf keys; /* Key data, keyWidth*numKeys */ - pl_sInt keyWidth; /* Number of floats per key */ - - pl_Float cont WDL_FIXALIGN; /* Continuity. Should be -1.0 -> 1.0 */ - pl_Float bias; /* Bias. -1.0 -> 1.0 */ - pl_Float tens; /* Tension. -1.0 -> 1.0 */ -}; - - -class pl_Light { -public: - pl_Light() { Type = PL_LIGHT_VECTOR; Xp=Yp=0.0; Zp=1.0; Intensity[0]=Intensity[1]=Intensity[2]=1.0; } - ~pl_Light() { } - -/* - Set() sets up a light: - mode: the mode of the light (PL_LIGHT_*) - x,y,z: either the position of the light (PL_LIGHT_POINT*) or the angle - in degrees of the light (PL_LIGHT_VECTOR) - intensity: the intensity of the light (0.0-1.0) - halfDist: the distance at which PL_LIGHT_POINT_DISTANCE is 1/2 intensity -*/ - void Set(pl_uChar mode, pl_Float x, pl_Float y, pl_Float z, pl_Float intensity_r, pl_Float intensity_g, pl_Float intensity_b, pl_Float halfDist); - - - // privatestuff - pl_uChar Type; /* Type of light: PL_LIGHT_* */ - pl_Float Xp WDL_FIXALIGN; - pl_Float Yp, Zp; /* If Type=PL_LIGHT_POINT*, - this is Position (PL_LIGHT_POINT_*), - otherwise if PL_LIGHT_VECTOR, - Unit vector */ - pl_Float Intensity[3]; /* Intensity. 0.0 is off, 1.0 is full */ - pl_Float HalfDistSquared; /* Distance squared at which - PL_LIGHT_POINT_DISTANCE is 50% */ -}; - - -class pl_Cam { -public: - pl_Cam() : m_fBuffer(NULL,0,0,0,false) - { - m_lastFBScaling=256; - m_lastFBWidth=m_lastFBHeight=0; - Fov=90.0; - AspectRatio=1.0; - Sort=1; - ClipBack=-1.0; - CenterX=CenterY=0; - X=Y=Z=0.0; - WantZBuffer=false; - Pitch=Pan=Roll=0.0; - GenMatrix = true; - } - ~pl_Cam() - { - } - - - void SetTarget(pl_Float x, pl_Float y, pl_Float z); - - pl_Float Pitch, Pan, Roll; /* Camera angle in degrees in worldspace */ - pl_Float Fov; /* FOV in degrees valid range is 1-179 */ - pl_Float AspectRatio; /* Aspect ratio (usually 1.0) */ - - pl_Float ClipBack WDL_FIXALIGN; /* Far clipping ( < 0.0 is none) */ - pl_Float X, Y, Z; /* Camera position in worldspace */ - - pl_Float CamMatrix[16]; /* should be rotation-only. translation will mess with the normals */ - - pl_sChar Sort; /* Sort polygons, -1 f-t-b, 1 b-t-f, 0 no */ - pl_sInt CenterX, CenterY; /* Offset center of screen from actual center by this much... */ - - pl_Bool WantZBuffer; - pl_Bool GenMatrix; /* if set, generates CamMatrix from Pan/Pitch/Roll in Begin() */ - - void Begin(LICE_IBitmap *fb, bool want_zbclear=true, pl_ZBuffer zbclear=0.0); - void RenderLight(pl_Light *light); - void RenderObject(pl_Obj *obj, const pl_Float *bmatrix=NULL, const pl_Float *bnmatrix=NULL); - void SortToCurrent(); // sorts all faces added since Begin() or last SortToCurrent() call. useful for if you use zbuffering with transparent objects (draw them last) - - // returns true if onscreen x/y/z are world coordinates - bool ProjectCoordinate(pl_Float x, pl_Float y, pl_Float z, pl_Float *screen_x, pl_Float *screen_y, pl_Float *dist); // outputs can be NULL if not needed - - LICE_IBitmap *GetFrameBuffer() { return m_fBuffer.m_buf ? &m_fBuffer : NULL; } - WDL_TypedBuf zBuffer; /* Z Buffer (validate size before using)*/ - - void End(); - - int RenderTrisIn; - int RenderTrisCulled; - int RenderTrisOut; - - double RenderPixelsOut WDL_FIXALIGN; - - void PutFace(pl_Face *TriFace); - -protected: - LICE_WrapperBitmap m_fBuffer; - pl_uInt m_lastFBWidth, m_lastFBHeight; // unscaled sizes when compared to m_fBuffer - pl_uInt m_lastFBScaling; - pl_sInt m_lastCX, m_lastCY; // calculated as w/2+CenterX/2 etc - - // internal use - void ClipRenderFace(pl_Face *face, pl_Obj *obj); - int ClipNeeded(pl_Face *face, pl_Obj *obj); // 0=no draw, 1=drawing (possibly splitting) necessary - void RecalcFrustum(int fbw, int fbh); - double CalcFOVFactor(double fbw) const - { - return fbw/tan(plMin(plMax(Fov,1.0),179.0)*(PL_PI/360.0)); - } - - - #define PL_NUM_CLIP_PLANES 5 - - struct _clipInfo - { - pl_Vertex newVertices[8]; - pl_Float ShadeInfos[8][3]; - pl_Float MappingU[PLUSH_MAX_MAPCOORDS][8]; - pl_Float MappingV[PLUSH_MAX_MAPCOORDS][8]; - }; - - _clipInfo m_cl[2] WDL_FIXALIGN; - pl_Float m_clipPlanes[PL_NUM_CLIP_PLANES][4]; - pl_Float m_fovfactor, m_adj_asp; // recalculated - - /* Returns: 0 if nothing gets in, 1 or 2 if pout1 & pout2 get in */ - pl_uInt _ClipToPlane(pl_uInt numVerts, pl_Float *plane); - - - struct _faceInfo { - pl_Float zd; - pl_Face *face; - pl_Obj *obj; - } WDL_FIXALIGN; - - struct _lightInfo { - pl_Float l[3]; - pl_Light *light; - } WDL_FIXALIGN; - - static int sortRevFunc(const void *a, const void *b); - static int sortFwdFunc(const void *a, const void *b); - - int _numfaces,_numfaces_sorted; - WDL_TypedBuf<_faceInfo> _faces; - - int _numlights; - WDL_TypedBuf<_lightInfo> _lights; - - void _RenderObj(pl_Obj *, pl_Float *, pl_Float *); - - WDL_HeapBuf _sort_tmpspace; - -}; - - - - -/****************************************************************************** -** Object Primitives Code (pl_make.cpp) -******************************************************************************/ - -/* - plMakePlane() makes a plane centered at the origin facing up the y axis. - Parameters: - w: width of the plane (along the x axis) - d: depth of the plane (along the z axis) - res: resolution of plane, i.e. subdivisions - m: material to use - Returns: - pointer to object created. -*/ -pl_Obj *plMakePlane(pl_Float w, pl_Float d, pl_uInt res, pl_Mat *m); - -/* - plMakeBox() makes a box centered at the origin - Parameters: - w: width of the box (x axis) - d: depth of the box (z axis) - h: height of the box (y axis) - Returns: - pointer to object created. -*/ -pl_Obj *plMakeBox(pl_Float w, pl_Float d, pl_Float h, pl_Mat *m); - -/* - plMakeDisc() makes a disc centered at the origin - Parameters: - r: radius of the disc (x-z axis) - divr: division of of disc (around the circle) (>=3) - m: material to use - Returns: - pointer to object created. - */ -pl_Obj *plMakeDisc(pl_Float r, pl_uInt divr, pl_Mat *m); - -/* - plMakeCone() makes a cone centered at the origin - Parameters: - r: radius of the cone (x-z axis) - h: height of the cone (y axis) - div: division of cone (>=3) - cap: close the big end? - m: material to use - Returns: - pointer to object created. -*/ -pl_Obj *plMakeCone(pl_Float r, pl_Float h, pl_uInt div, pl_Bool cap, pl_Mat *m); - -/* - plMakeCylinder() makes a cylinder centered at the origin - Parameters: - r: radius of the cylinder (x-z axis) - h: height of the cylinder (y axis) - divr: division of of cylinder (around the circle) (>=3) - captop: close the top - capbottom: close the bottom - m: material to use - Returns: - pointer to object created. -*/ -pl_Obj *plMakeCylinder(pl_Float r, pl_Float h, pl_uInt divr, pl_Bool captop, - pl_Bool capbottom, pl_Mat *m); - -/* - plMakeSphere() makes a sphere centered at the origin. - Parameters: - r: radius of the sphere - divr: division of the sphere (around the y axis) (>=3) - divh: division of the sphere (around the x,z axis) (>=3) - m: material to use - Returns: - pointer to object created. -*/ -pl_Obj *plMakeSphere(pl_Float r, pl_uInt divr, pl_uInt divh, pl_Mat *m); - -/* - plMakeTorus() makes a torus centered at the origin - Parameters: - r1: inner radius of the torus - r2: outer radius of the torus - divrot: division of the torus (around the y axis) (>=3) - divrad: division of the radius of the torus (x>=3) - m: material to use - Returns: - pointer to object created. -*/ -pl_Obj *plMakeTorus(pl_Float r1, pl_Float r2, pl_uInt divrot, - pl_uInt divrad, pl_Mat *m); - - -/****************************************************************************** -** File Readers (pl_read_*.cpp) -******************************************************************************/ - -/* - plRead3DSObj() reads a 3DS object - Parameters: - fn: filename of object to read - m: material to assign it - Returns: - pointer to object - Notes: - This reader organizes multiple objects like so: - 1) the first object is returned - 2) the second object is the first's first child - 3) the third object is the second's first child - 4) etc -*/ -pl_Obj *plRead3DSObj(void *ptr, int size, pl_Mat *m); -pl_Obj *plRead3DSObjFromFile(char *fn, pl_Mat *m); -pl_Obj *plRead3DSObjFromResource(HINSTANCE hInst, int resid, pl_Mat *m); - -/* - plReadCOBObj() reads an ascii .COB object - Parameters: - fn: filename of object to read - mat: material to assign it - Returns: - pointer to object - Notes: - This is Caligari's ASCII object format. - This reader doesn't handle multiple objects. It just reads the first one. - Polygons with lots of sides are not always tesselated correctly. Just - use the "Tesselate" button from within truespace to improve the results. -*/ -pl_Obj *plReadCOBObj(char *fn, pl_Mat *mat); - -/* - plReadJAWObj() reads a .JAW object. - Parameters: - fn: filename of object to read - m: material to assign it - Returns: - pointer to object - Notes: - For information on the .JAW format, please see the jaw3D homepage, - http://www.tc.umn.edu/nlhome/g346/kari0022/jaw3d/ -*/ -pl_Obj *plReadJAWObj(char *fn, pl_Mat *m); - - - -/****************************************************************************** -** Math Code (pl_math.cpp) -******************************************************************************/ - -/* - plMatrixRotate() generates a rotation matrix - Parameters: - matrix: an array of 16 pl_Floats that is a 4x4 matrix - m: the axis to rotate around, 1=X, 2=Y, 3=Z. - Deg: the angle in degrees to rotate - Returns: - nothing -*/ -void plMatrixRotate(pl_Float matrix[], pl_uChar m, pl_Float Deg); - -/* - plMatrixTranslate() generates a translation matrix - Parameters: - m: the matrix (see plMatrixRotate for more info) - x,y,z: the translation coordinates - Returns: - nothing -*/ -void plMatrixTranslate(pl_Float m[], pl_Float x, pl_Float y, pl_Float z); - -/* - plMatrixMultiply() multiplies two matrices - Parameters: - dest: destination matrix will be multipled by src - src: source matrix - Returns: - nothing - Notes: - this is the same as dest = dest*src (since the order *does* matter); -*/ -void plMatrixMultiply(pl_Float *dest, const pl_Float src[]); - -/* - plMatrixApply() applies a matrix. - Parameters: - m: matrix to apply - x,y,z: input coordinate - outx,outy,outz: pointers to output coords. - Returns: - nothing - Notes: - applies the matrix to the 3d point to produce the transformed 3d point -*/ -void plMatrixApply(pl_Float *m, pl_Float x, pl_Float y, pl_Float z, - pl_Float *outx, pl_Float *outy, pl_Float *outz); - -/* - plNormalizeVector() makes a vector a unit vector - Parameters: - x,y,z: pointers to the vector - Returns: - nothing -*/ -void plNormalizeVector(pl_Float *x, pl_Float *y, pl_Float *z); - -/* - plDotProduct() returns the dot product of two vectors - Parameters: - x1,y1,z1: the first vector - x2,y2,z2: the second vector - Returns: - the dot product of the two vectors -*/ -pl_Float plDotProduct(pl_Float x1, pl_Float y1, pl_Float z1, - pl_Float x2, pl_Float y2, pl_Float z2); - - - - -#endif /* !_PLUSH_H_ */ diff --git a/oversampling/WDL/poollist.h b/oversampling/WDL/poollist.h deleted file mode 100644 index a53a640..0000000 --- a/oversampling/WDL/poollist.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - WDL - poollist.h - Copyright (C) 2006 and later, Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - - - This file defines a template class for hosting lists of referenced count, string-identified objects. - - We mostly use it with WDL_ResourcePool, but any class like this can use it: - - - class SomeClass - { - public: - SomeClass(char *identstr) { WDL_POOLLIST_identstr=identstr; WDL_POOLLIST_refcnt=0; } - ~SomeClass() {} // do NOT free or delete WDL_POOLLIST_identstr - - - void Clear() {} // will be called if ReleasePool(x,false) is called and refcnt gets to 0 - int WDL_POOLLIST_refcnt; - char *WDL_POOLLIST_identstr; - }; - - - -*/ - - - -#ifndef _WDL_POOLLIST_H_ -#define _WDL_POOLLIST_H_ - -#include - -#include "mutex.h" - -template class WDL_PoolList_NoFreeOnDestroy -{ -public: - - WDL_PoolList_NoFreeOnDestroy() - { - } - ~WDL_PoolList_NoFreeOnDestroy() - { - } - - DATATYPE *Get(const char *filename, bool createIfExists=true) - { - WDL_MutexLock lock(&mutex); - - DATATYPE *t = Find(filename,false); - if (t) - { - t->WDL_POOLLIST_refcnt++; - return t; - } - if (!createIfExists) return NULL; - - t = new DATATYPE(strdup(filename)); - t->WDL_POOLLIST_refcnt=1; - - int x; - for(x=0;xWDL_POOLLIST_identstr,filename)>0) break; - - pool.Insert(x,t); - - return t; - } - - DATATYPE *Find(const char *filename, bool lockMutex=true) // not threadsafe - { - if (lockMutex) mutex.Enter(); - DATATYPE **_tmp=NULL; - if (pool.GetSize()) - { - DATATYPE tmp((char *)filename),*t=&tmp; - _tmp = (DATATYPE**)bsearch(&t,pool.GetList(),pool.GetSize(),sizeof(void *),_sortfunc); - } - if (lockMutex) mutex.Leave(); - return _tmp ? *_tmp : NULL; - } - - int ReleaseByName(const char *filename, bool isFull=true) - { - WDL_MutexLock lock(&mutex); - return Release(Find(filename,false),isFull); - } - - int Release(DATATYPE *tp, bool isFull=true) - { - if (!tp) return -1; - WDL_MutexLock lock(&mutex); - - int refcnt; - if (!(refcnt=--tp->WDL_POOLLIST_refcnt)) - { - if (!isFull) - { - tp->Clear(); - } - else - { - int x; - for (x = 0; x < pool.GetSize() && pool.Get(x) != tp; x ++); - if (xWDL_POOLLIST_identstr); - delete tp; - } - // remove from list - } - return refcnt; - } - - void RemoveAll() - { - int x; - for (x = 0; x < pool.GetSize(); x ++) - { - DATATYPE *p = pool.Get(x); - free(p->WDL_POOLLIST_identstr); - delete p; - } - pool.Empty(); - } - - WDL_Mutex mutex; - WDL_PtrList< DATATYPE > pool; - -private: - - static int _sortfunc(const void *a, const void *b) - { - DATATYPE *ta = *(DATATYPE **)a; - DATATYPE *tb = *(DATATYPE **)b; - - return stricmp(ta->WDL_POOLLIST_identstr,tb->WDL_POOLLIST_identstr); - } -}; - -template class WDL_PoolList : public WDL_PoolList_NoFreeOnDestroy -{ -public: - WDL_PoolList() { } - ~WDL_PoolList() { WDL_PoolList_NoFreeOnDestroy::RemoveAll(); } - - -}; - -#endif diff --git a/oversampling/WDL/projectcontext.cpp b/oversampling/WDL/projectcontext.cpp deleted file mode 100644 index 9fde493..0000000 --- a/oversampling/WDL/projectcontext.cpp +++ /dev/null @@ -1,1320 +0,0 @@ -#ifdef _WIN32 -#include -#else -#include -#include -#include -#endif -#include -#include -#include - -#include "projectcontext.h" - -#include "fileread.h" -#include "filewrite.h" -#include "heapbuf.h" -#include "wdlstring.h" -#include "wdlcstring.h" -#include "fastqueue.h" -#include "lineparse.h" - - -//#define WDL_MEMPROJECTCONTEXT_USE_ZLIB 1 - -#ifdef WDL_MEMPROJECTCONTEXT_USE_ZLIB - -#define WDL_MEMPROJECTCONTEXT_ZLIB_CHUNKSIZE 65536 -#include "zlib/zlib.h" - -#endif - -#include "denormal.h" - - -char *projectcontext_fastDoubleToString(double value, char *bufOut, int prec_digits) -{ - value = denormal_filter_double2(value); - - if (value<0.0) - { - value=-value; - *bufOut++ = '-'; - } - - if (value < 1e-20) - { - *bufOut++ = '0'; - *bufOut = 0; - return bufOut; - } - - if (value > 2147483647.0) - { - if (value >= 1.0e40) sprintf(bufOut, "%e", value); - else sprintf(bufOut, "%.*f", wdl_min(prec_digits,8), value); - while (*bufOut) bufOut++; - return bufOut; - } - - unsigned int value_i, frac, frac2; - int prec_digits2 = 0; - - if (prec_digits>0) - { - static const unsigned int scales[9] = - { - 10, - 100, - 1000, - 10000, - 100000, - 1000000, - 10000000, - 100000000, - 1000000000 - }; - - value_i = (unsigned int)value; - const int value_digits = - value_i >= 10000 ? ( - value_i >= 1000000 ? - (value_i >= 100000000 ? - (value_i >= 1000000000 ? 10 : 9) : - (value_i >= 10000000 ? 8 : 7)) : - (value_i >= 100000 ? 6 : 5) - ) - : - ( - value_i >= 100 ? - (value_i >= 1000 ? 4 : 3) : - (value_i >= 10 ? 2 : 1) - ); - - // double precision is limited to about 17 decimal digits of meaningful values - if (prec_digits + value_digits > 17) prec_digits = 17-value_digits; - - if (prec_digits > 9) - { - prec_digits2 = prec_digits - 9; - prec_digits = 9; - if (prec_digits2 > 9) prec_digits2 = 9; - } - - const unsigned int prec_scale = scales[prec_digits-1]; - const double dfrac = (value - value_i) * prec_scale; - if (prec_digits2 > 0) - { - const unsigned int prec_scale2 = scales[prec_digits2-1]; - frac = (unsigned int) dfrac; - - double dfrac2 = (dfrac - frac) * prec_scale2; - frac2 = (unsigned int) (dfrac2 + 0.5); - - const int prec_scale2_small = wdl_min(prec_scale2/1024,10); - - if (frac2 <= prec_scale2_small) frac2=0; - else if (frac2 >= prec_scale2 - prec_scale2_small - 1) frac2=prec_scale2; - - if (frac2 >= prec_scale2) - { - frac2 -= prec_scale2; - frac++; - } - } - else - { - frac = (unsigned int) (dfrac + 0.5); - frac2 = 0; - const int prec_scale_small = wdl_min(prec_scale/1024,10); - if (frac <= prec_scale_small) frac=0; - else if (frac>=prec_scale-prec_scale_small - 1) frac=prec_scale; - } - - if (frac >= prec_scale) // round up to next integer - { - frac -= prec_scale; - value_i++; - } - } - else // round to int - { - value_i = (unsigned int)(value+0.5); - frac2 = frac = 0; - } - - char digs[32]; - - if (value_i) - { - int tmp=value_i; - int x = 0; - do { - const int a = (tmp%10); - tmp/=10; - digs[x++]='0' + a; - } while (tmp); - - while (x>0) *bufOut++ = digs[--x]; - } - else - { - *bufOut++ = '0'; - } - - - if (frac || frac2) - { - int x = 0; - int tmp=frac; - int dleft = prec_digits; - *bufOut++='.'; - - if (frac) do - { - const int a = (tmp%10); - tmp /= 10; - if (x || a || frac2) digs[x++] = '0'+a; - } while (dleft-- > 0 && tmp); - - while (dleft-->0) *bufOut++ = '0'; - while (x>0) *bufOut++ = digs[--x]; - // x is 0 - - if (frac2) - { - tmp=frac2; - dleft = prec_digits2; - do - { - const int a = (tmp%10); - tmp /= 10; - if (x || a) digs[x++] = '0'+a; - } while (dleft-- > 0 && tmp); - - while (dleft-->0) *bufOut++ = '0'; - while (x>0) *bufOut++ = digs[--x]; - } - } - - *bufOut = 0; - return bufOut; -} - -int ProjectContextFormatString(char *outbuf, size_t outbuf_size, const char *fmt, va_list va) -{ - int wroffs=0; - - while (*fmt && outbuf_size > 1) - { - char c = *fmt++; - if (c != '%') - { - outbuf[wroffs++] = c != '\n' ? c : ' '; - outbuf_size--; - continue; - } - - if (*fmt == '%') - { - outbuf[wroffs++] = '%'; - outbuf_size--; - fmt++; - continue; - } - - - const char *ofmt = fmt-1; - bool want_abort=false; - - int has_prec=0; - int prec=0; - if (*fmt == '.') - { - has_prec=1; - fmt++; - while (*fmt >= '0' && *fmt <= '9') prec = prec*10 + (*fmt++-'0'); - if (*fmt != 'f' || prec < 0 || prec>20) - { - want_abort=true; - } - } - else if (*fmt == '0') - { - has_prec=2; - fmt++; - while (*fmt >= '0' && *fmt <= '9') prec = prec*10 + (*fmt++-'0'); - if (*fmt != 'x' && *fmt != 'X' && *fmt != 'd' && *fmt != 'u') - { - want_abort=true; - } - } - - c = *fmt++; - if (!want_abort) switch (c) - { - case '@': - case 'p': - case 's': - { - const char *str=va_arg(va,const char *); - bool prefer_quoteless = true; - if (c == 'p' && *fmt == '~') // %p~ to bias towards "string" (legacy) - { - prefer_quoteless = false; - fmt++; - } - const char qc = outbuf_size >= 3 && c != 's' ? getConfigStringQuoteChar(str, prefer_quoteless) : ' '; - - if (qc != ' ') - { - outbuf[wroffs++] = qc ? qc : '`'; - outbuf_size-=2; // will add trailing quote below - } - - if (str) while (outbuf_size > 1 && *str) - { - char v = *str++; - if (!qc && v == '`') v = '\''; - outbuf[wroffs++] = v != '\n' && v != '\r' ? v : ' '; - outbuf_size--; - } - - if (qc != ' ') - { - outbuf[wroffs++] = qc ? qc : '`'; - // outbuf_size already decreased above - } - } - break; - case 'c': - { - int v = (va_arg(va,int)) & 0xff; - outbuf[wroffs++] = v != '\n' ? v : ' '; - outbuf_size--; - } - break; - case 'd': - { - int v = va_arg(va,int); - if (v<0) - { - outbuf[wroffs++] = '-'; - outbuf_size--; - v=-v; // this won't handle -2147483648 right, todo special case? - } - - char tab[32]; - int x=0; - do - { - tab[x++] = v%10; - v/=10; - } - while (v); - if (has_prec == 2) while (x= 0 && outbuf_size>1) - { - outbuf[wroffs++] = '0' + tab[x]; - outbuf_size--; - } - } - break; - case 'u': - { - unsigned int v = va_arg(va,unsigned int); - - char tab[32]; - int x=0; - do - { - tab[x++] = v%10; - v/=10; - } - while (v); - if (has_prec == 2) while (x= 0 && outbuf_size>1) - { - outbuf[wroffs++] = '0' + tab[x]; - outbuf_size--; - } - } - break; - case 'x': - case 'X': - { - const char base = (c - 'x') + 'a'; - unsigned int v = va_arg(va,unsigned int); - - char tab[32]; - int x=0; - do - { - tab[x++] = v&0xf; - v>>=4; - } - while (v); - - if (has_prec == 2) while (x= 0 && outbuf_size>1) - { - if (tab[x] < 10) - outbuf[wroffs++] = '0' + tab[x]; - else - outbuf[wroffs++] = base + tab[x] - 10; - - outbuf_size--; - } - } - break; - case 'f': - { - double v = va_arg(va,double); - if (outbuf_size<64) - { - char tmp[64]; - projectcontext_fastDoubleToString(v,tmp,has_prec?prec:6); - const char *str = tmp; - while (outbuf_size > 1 && *str) - { - outbuf[wroffs++] = *str++; - outbuf_size--; - } - } - else - { - const char *p=projectcontext_fastDoubleToString(v,outbuf+wroffs,has_prec?prec:6); - int amt = (int) (p-(outbuf+wroffs)); - wroffs += amt; - outbuf_size-=amt; - } - } - break; - default: - want_abort=true; - break; - } - if (want_abort) - { - fmt=ofmt; - break; - } - } - - outbuf += wroffs; - outbuf[0] = 0; - if (outbuf_size<2||!*fmt) - return wroffs; - -#if defined(_WIN32) && defined(_MSC_VER) - // _vsnprintf() does not always null terminate (see below) - _vsnprintf(outbuf,outbuf_size,fmt,va); -#else - // vsnprintf() on non-win32, always null terminates - vsnprintf(outbuf,outbuf_size,fmt,va); -#endif - - int l; - outbuf_size--; - for (l = 0; l < outbuf_size && outbuf[l]; l ++) if (outbuf[l] == '\n') outbuf[l] = ' '; - -#if defined(_WIN32) && defined(_MSC_VER) - // nul terminate for _vsnprintf() - outbuf[l]=0; -#endif - - return wroffs+l; -} - - - -class ProjectStateContext_Mem : public ProjectStateContext -{ -public: - - ProjectStateContext_Mem(WDL_HeapBuf *hb, int rwflags) - { - m_rwflags=rwflags; - m_heapbuf=hb; - m_pos=0; - m_tmpflag=0; -#ifdef WDL_MEMPROJECTCONTEXT_USE_ZLIB - memset(&m_compstream,0,sizeof(m_compstream)); - m_usecomp=0; -#endif - } - - virtual ~ProjectStateContext_Mem() - { - #ifdef WDL_MEMPROJECTCONTEXT_USE_ZLIB - if (m_usecomp==1) - { - FlushComp(true); - deflateEnd(&m_compstream); - } - else if (m_usecomp==2) - { - inflateEnd(&m_compstream); - } - #endif - }; - - virtual void WDL_VARARG_WARN(printf,2,3) AddLine(const char *fmt, ...); - virtual int GetLine(char *buf, int buflen); // returns -1 on eof - - virtual WDL_INT64 GetOutputSize() { return m_heapbuf ? m_heapbuf->GetSize() : 0; } - - virtual int GetTempFlag() { return m_tmpflag; } - virtual void SetTempFlag(int flag) { m_tmpflag=flag; } - - int m_pos; - WDL_HeapBuf *m_heapbuf; - int m_tmpflag; - int m_rwflags; - -#ifdef WDL_MEMPROJECTCONTEXT_USE_ZLIB - int DecompressData() - { - if (m_pos >= m_heapbuf->GetSize()) return 1; - - m_compstream.next_in = (unsigned char *)m_heapbuf->Get() + m_pos; - m_compstream.avail_in = m_heapbuf->GetSize()-m_pos; - m_compstream.total_in = 0; - - int outchunk = 65536; - m_compstream.next_out = (unsigned char *)m_compdatabuf.Add(NULL,outchunk); - m_compstream.avail_out = outchunk; - m_compstream.total_out = 0; - - int e = inflate(&m_compstream,Z_NO_FLUSH); - - m_pos += m_compstream.total_in; - m_compdatabuf.Add(NULL,m_compstream.total_out - outchunk); // rewind - - return e != Z_OK; - } - - void FlushComp(bool eof) - { - while (m_compdatabuf.Available()>=WDL_MEMPROJECTCONTEXT_ZLIB_CHUNKSIZE || eof) - { - if (!m_heapbuf->GetSize()) m_heapbuf->SetGranul(256*1024); - m_compstream.next_in = (unsigned char *)m_compdatabuf.Get(); - m_compstream.avail_in = m_compdatabuf.Available(); - m_compstream.total_in = 0; - - int osz = m_heapbuf->GetSize(); - - int newsz=osz + wdl_max(m_compstream.avail_in,8192) + 256; - m_compstream.next_out = (unsigned char *)m_heapbuf->Resize(newsz, false) + osz; - if (m_heapbuf->GetSize()!=newsz) return; // ERROR - m_compstream.avail_out = newsz-osz; - m_compstream.total_out=0; - - deflate(&m_compstream,eof?Z_SYNC_FLUSH:Z_NO_FLUSH); - - m_heapbuf->Resize(osz+m_compstream.total_out,false); - m_compdatabuf.Advance(m_compstream.total_in); - if (m_compstream.avail_out) break; // no need to process anymore - - } - m_compdatabuf.Compact(); - } - - // these will be used for either decompression or compression, fear - int m_usecomp; // 0=?, -1 = fail, 1=yes - WDL_Queue m_compdatabuf; - z_stream m_compstream; -#endif - -}; - -// returns length, modifies ptr to point to tmp if newline needed to be filtered -static int filter_newline_buf(const char **ptr, char *tmp, int tmpsz) -{ - const char *use_buf = *ptr; - if (!use_buf) return -1; - - int l; - for (l=0; use_buf[l] && use_buf[l] != '\n'; l++); - - if (!use_buf[l]) return l; - - lstrcpyn_safe(tmp,use_buf,tmpsz); - *ptr=tmp; - - if (l >= tmpsz) return tmpsz-1; - - for (;tmp[l]; l++) if (tmp[l] == '\n') tmp[l] = ' '; // replace any newlines with spaces - return l; -} - - -void ProjectStateContext_Mem::AddLine(const char *fmt, ...) -{ - if (!m_heapbuf || !(m_rwflags&2)) return; - - char tmp[8192]; - - const char *use_buf; - int l; - - va_list va; - va_start(va,fmt); - - if (fmt && fmt[0] == '%' && (fmt[1] == 's' || fmt[1] == 'S') && !fmt[2]) - { - use_buf = va_arg(va,const char *); - l = filter_newline_buf(&use_buf,tmp,(int)sizeof(tmp)) + 1; - } - else - { - l = ProjectContextFormatString(tmp,sizeof(tmp),fmt, va) + 1; - use_buf = tmp; - } - va_end(va); - - if (l < 1) return; - - -#ifdef WDL_MEMPROJECTCONTEXT_USE_ZLIB - if (!m_usecomp) - { - if (deflateInit(&m_compstream,WDL_MEMPROJECTCONTEXT_USE_ZLIB)==Z_OK) m_usecomp=1; - else m_usecomp=-1; - } - - if (m_usecomp==1) - { - m_compdatabuf.Add(use_buf,(int)l); - FlushComp(false); - return; - } -#endif - - - const int sz=m_heapbuf->GetSize(); - if (!sz && m_heapbuf->GetGranul() < 256*1024) - { - m_heapbuf->SetGranul(256*1024); - } - - char *p = (char *)m_heapbuf->ResizeOK(sz+l); - if (!p) - { - // ERROR, resize to 0 and return - m_heapbuf->Resize(0); - m_heapbuf=0; - return; - } - memcpy(p+sz,use_buf,l); -} - -int ProjectStateContext_Mem::GetLine(char *buf, int buflen) // returns -1 on eof -{ - if (!m_heapbuf || !(m_rwflags&1)) return -1; - - buf[0]=0; - - -#ifdef WDL_MEMPROJECTCONTEXT_USE_ZLIB - if (!m_usecomp) - { - unsigned char hdr[]={0x78,0x01}; - if (m_heapbuf->GetSize()>2 && !memcmp(hdr,m_heapbuf->Get(),4) && inflateInit(&m_compstream)==Z_OK) m_usecomp=2; - else m_usecomp=-1; - } - if (m_usecomp==2) - { - int x=0; - for (;;) - { - const char *p = (const char*) m_compdatabuf.Get(); - for (x = 0; x < m_compdatabuf.Available() && p[x] && p[x] != '\r' && p[x] != '\n'; x ++); - while (x >= m_compdatabuf.Available()) - { - int err = DecompressData(); - p = (const char *)m_compdatabuf.Get(); - for (; x < m_compdatabuf.Available() && p[x] && p[x] != '\r' && p[x] != '\n'; x ++); - - if (err) break; - } - - if (x||!m_compdatabuf.Available()) break; - - m_compdatabuf.Advance(1); // skip over nul or newline char - } - - if (!x) return -1; - - if (buflen > 0 && buf) - { - int l = wdl_min(buflen-1,x); - memcpy(buf,m_compdatabuf.Get(),l); - buf[l]=0; - } - - m_compdatabuf.Advance(x+1); - m_compdatabuf.Compact(); - return 0; - } -#endif - - - int avail = m_heapbuf->GetSize() - m_pos; - const char *p=(const char *)m_heapbuf->Get() + m_pos; - while (avail > 0 && (p[0] =='\r'||p[0]=='\n'||!p[0]||p[0] == ' ' || p[0] == '\t')) - { - p++; - m_pos++; - avail--; - } - if (avail <= 0) return -1; - - int x; - for (x = 0; x < avail && p[x] && p[x] != '\n'; x ++); - m_pos += x+1; - - if (buflen > 0&&buf) - { - int l = buflen-1; - if (l>x) l=x; - memcpy(buf,p,l); - if (l>0 && buf[l-1]=='\r') l--; - buf[l]=0; - } - return 0; -} - -class ProjectStateContext_File : public ProjectStateContext -{ -public: - - ProjectStateContext_File(WDL_FileRead *rd, WDL_FileWrite *wr) - { - m_rd=rd; - m_wr=wr; - m_indent=0; - m_bytesOut=0; - m_errcnt=false; - m_tmpflag=0; - _rdbuf_pos = _rdbuf_valid = 0; - } - virtual ~ProjectStateContext_File(){ delete m_rd; delete m_wr; }; - - virtual void WDL_VARARG_WARN(printf,2,3) AddLine(const char *fmt, ...); - virtual int GetLine(char *buf, int buflen); // returns -1 on eof - - virtual WDL_INT64 GetOutputSize() { return m_bytesOut; } - - virtual int GetTempFlag() { return m_tmpflag; } - virtual void SetTempFlag(int flag) { m_tmpflag=flag; } - - bool HasError() { return m_errcnt; } - - WDL_INT64 m_bytesOut WDL_FIXALIGN; - - WDL_FileRead *m_rd; - WDL_FileWrite *m_wr; - - char rdbuf[4096]; - int _rdbuf_pos, _rdbuf_valid; - - int m_indent; - int m_tmpflag; - bool m_errcnt; - -}; - -int ProjectStateContext_File::GetLine(char *buf, int buflen) -{ - if (!m_rd||buflen<3) return -1; - - char * const buf_orig=buf; - int rdpos = _rdbuf_pos; - int rdvalid = _rdbuf_valid; - buflen -= 2; - - for (;;) - { - while (rdpos < rdvalid) - { - char c=rdbuf[rdpos++]; - switch (c) - { - case ' ': case '\r': case '\n': case '\t': break; - default: - *buf++=c; - - do - { - int mxl = rdvalid - rdpos; - if (mxl > buflen) mxl=buflen; - while (mxl-->0) - { - char c2 = rdbuf[rdpos++]; - if (c2=='\n') goto finished; - - *buf++ = c2; - buflen--; - } - if (rdpos>=rdvalid) - { - rdpos = 0; - rdvalid = m_rd->Read(rdbuf, sizeof(rdbuf)); - if (rdvalid<1) break; - } - } - while (buflen > 0); - - finished: - _rdbuf_pos=rdpos; - _rdbuf_valid=rdvalid; - - if (buf > buf_orig && buf[-1] == '\r') buf--; - *buf=0; - return 0; - } - } - - rdpos = 0; - rdvalid = m_rd->Read(rdbuf, sizeof(rdbuf)); - if (rdvalid<1) - { - buf[0]=0; - return -1; - } - } -} - -void ProjectStateContext_File::AddLine(const char *fmt, ...) -{ - if (m_wr && !m_errcnt) - { - int err=0; - - char tmp[8192]; - const char *use_buf; - va_list va; - va_start(va,fmt); - int l; - - if (fmt && fmt[0] == '%' && (fmt[1] == 's' || fmt[1] == 'S') && !fmt[2]) - { - // special case "%s" passed, directly use it - use_buf = va_arg(va,const char *); - l = filter_newline_buf(&use_buf,tmp,(int)sizeof(tmp)); - } - else - { - l = ProjectContextFormatString(tmp,sizeof(tmp),fmt, va); - use_buf = tmp; - } - - va_end(va); - if (l < 0) return; - - - int a=m_indent; - if (use_buf[0] == '<') m_indent+=2; - else if (use_buf[0] == '>') a=(m_indent-=2); - - if (a>0) - { - m_bytesOut+=a; - char tb[128]; - memset(tb,' ',a < (int)sizeof(tb) ? a : (int)sizeof(tb)); - while (a>0) - { - const int tl = a < (int)sizeof(tb) ? a : (int)sizeof(tb); - a-=tl; - m_wr->Write(tb,tl); - } - } - - err |= m_wr->Write(use_buf,l) != l; - err |= m_wr->Write("\r\n",2) != 2; - m_bytesOut += 2 + l; - - if (err) m_errcnt=true; - } -} - - - -ProjectStateContext *ProjectCreateFileRead(const char *fn) -{ - WDL_FileRead *rd = new WDL_FileRead(fn,0,65536,1); - if (!rd || !rd->IsOpen()) - { - delete rd; - return NULL; - } - return new ProjectStateContext_File(rd,NULL); -} -ProjectStateContext *ProjectCreateFileWrite(const char *fn) -{ - WDL_FileWrite *wr = new WDL_FileWrite(fn); - if (!wr || !wr->IsOpen()) - { - delete wr; - return NULL; - } - return new ProjectStateContext_File(NULL,wr); -} - - -ProjectStateContext *ProjectCreateMemCtx(WDL_HeapBuf *hb) -{ - return new ProjectStateContext_Mem(hb,3); -} - -ProjectStateContext *ProjectCreateMemCtx_Read(const WDL_HeapBuf *hb) -{ - return new ProjectStateContext_Mem((WDL_HeapBuf *)hb,1); -} -ProjectStateContext *ProjectCreateMemCtx_Write(WDL_HeapBuf *hb) -{ - return new ProjectStateContext_Mem(hb,2); -} - - - - -class ProjectStateContext_FastQueue : public ProjectStateContext -{ -public: - - ProjectStateContext_FastQueue(WDL_FastQueue *fq) - { - m_fq = fq; - m_tmpflag=0; - } - - virtual ~ProjectStateContext_FastQueue() - { - }; - - virtual void WDL_VARARG_WARN(printf,2,3) AddLine(const char *fmt, ...); - virtual int GetLine(char *buf, int buflen) { return -1; }//unsup - - virtual WDL_INT64 GetOutputSize() { return m_fq ? m_fq->Available() : 0; } - - virtual int GetTempFlag() { return m_tmpflag; } - virtual void SetTempFlag(int flag) { m_tmpflag=flag; } - - WDL_FastQueue *m_fq; - int m_tmpflag; - - -}; - -void ProjectStateContext_FastQueue::AddLine(const char *fmt, ...) -{ - if (!m_fq) return; - - va_list va; - va_start(va,fmt); - - char tmp[8192]; - if (fmt && fmt[0] == '%' && (fmt[1] == 's' || fmt[1] == 'S') && !fmt[2]) - { - const char *use_buf = va_arg(va,const char *); - const int l = filter_newline_buf(&use_buf,tmp,(int)sizeof(tmp)); - if (use_buf) m_fq->Add(use_buf, l + 1); - } - else - { - const int l = ProjectContextFormatString(tmp,sizeof(tmp),fmt, va); - if (l>0) m_fq->Add(tmp, l+1); - } - va_end(va); -} - - - - - - - -ProjectStateContext *ProjectCreateMemWriteFastQueue(WDL_FastQueue *fq) // only write! -{ - return new ProjectStateContext_FastQueue(fq); -} - -bool ProjectContext_GetNextLine(ProjectStateContext *ctx, LineParser *lpOut) -{ - for (;;) - { - char linebuf[4096]; - if (ctx->GetLine(linebuf,sizeof(linebuf))) - { - lpOut->parse(""); - return false; - } - - if (lpOut->parse(linebuf)||lpOut->getnumtokens()<=0) continue; - - return true; // success! - - } -} - - -bool ProjectContext_EatCurrentBlock(ProjectStateContext *ctx, ProjectStateContext *ctxOut) -{ - int child_count=1; - if (ctx) for (;;) - { - char linebuf[4096]; - if (ctx->GetLine(linebuf,sizeof(linebuf))) break; - const char *sp = linebuf; - while (*sp == ' ' || *sp == '\t') sp++; - - const char *p = sp; - if (*p == '\'' || *p == '"' || *p == '`') p++; // skip a quote if any - if (p[0] == '>') if (--child_count < 1) return true; - - if (ctxOut) ctxOut->AddLine("%s",sp); - - if (p[0] == '<') child_count++; - } - - return false; -} - - -#include "wdl_base64.h" - -int cfg_decode_binary(ProjectStateContext *ctx, WDL_HeapBuf *hb) // 0 on success, doesnt clear hb -{ - int child_count=1; - for (;;) - { - char linebuf[4096]; - if (ctx->GetLine(linebuf,sizeof(linebuf))) break; - - const char *p = linebuf; - while (*p == ' ' || *p == '\t') p++; - if (*p == '\'' || *p == '"' || *p == '`') p++; // skip a quote if any - - if (p[0] == '<') child_count++; - else if (p[0] == '>') { if (child_count-- == 1) return 0; } - else if (child_count == 1 && p[0]) - { - unsigned char buf[3200]; - const int buf_l=wdl_base64decode(p,buf,sizeof(buf)); - if (buf_l) - { - const int os=hb->GetSize(); - char *dest = (char*)hb->ResizeOK(os+buf_l); - if (dest) memcpy(dest+os,buf,buf_l); - } - } - } - return -1; -} - -void cfg_encode_binary(ProjectStateContext *ctx, const void *ptr, int len) -{ - if (!ctx || len < 1) return; - - const unsigned char *p=(const unsigned char *)ptr; - if (len > 128 && len < (1<<30)) - { - // we could (probably should) use dynamic_cast<> here, but as we span modules this - // raises all kinds of questions (especially with VC having the option to disable RTTI). - // for now, we assume that the first void * in an object is the vtable pointer. with - // testing, of course. - WDL_FastQueue *fq = NULL; - WDL_HeapBuf *hb = NULL; -#ifndef WDL_MEMPROJECTCONTEXT_USE_ZLIB - static const ProjectStateContext_Mem hb_def(NULL,0); -#endif - static const ProjectStateContext_FastQueue fq_def(NULL); - if (*(void **)ctx == *(void **)&fq_def) - { - fq=((ProjectStateContext_FastQueue*)ctx)->m_fq; - } -#ifndef WDL_MEMPROJECTCONTEXT_USE_ZLIB - else if (*(void **)ctx == *(void **)&hb_def) - { - hb=((ProjectStateContext_Mem*)ctx)->m_heapbuf; - } -#endif - - if (fq||hb) - { - const int linelen8 = 280/8; - - const int enc_len = ((len+2)/3)*4; // every 3 characters end up as 4 - const int lines = (enc_len + linelen8*8 - 1) / (linelen8*8); - - char *wr = NULL; - if (fq) - { - wr = (char*)fq->Add(WDL_FASTQUEUE_ADD_NOZEROBUF,enc_len + lines); - } - else if (hb) - { - const int oldsz=hb->GetSize(); - wr=(char*)hb->ResizeOK(oldsz + enc_len + lines,false); - if (wr) wr+=oldsz; - } - - if (wr) - { - #ifdef _DEBUG - char * const wr_end=wr + enc_len + lines; - #endif - - int lpos = 0; - - while (len >= 6) - { - const int accum = (p[0] << 16) + (p[1] << 8) + p[2]; - const int accum2 = (p[3] << 16) + (p[4] << 8) + p[5]; - wr[0] = wdl_base64_alphabet[(accum >> 18) & 0x3F]; - wr[1] = wdl_base64_alphabet[(accum >> 12) & 0x3F]; - wr[2] = wdl_base64_alphabet[(accum >> 6) & 0x3F]; - wr[3] = wdl_base64_alphabet[accum & 0x3F]; - wr[4] = wdl_base64_alphabet[(accum2 >> 18) & 0x3F]; - wr[5] = wdl_base64_alphabet[(accum2 >> 12) & 0x3F]; - wr[6] = wdl_base64_alphabet[(accum2 >> 6) & 0x3F]; - wr[7] = wdl_base64_alphabet[accum2 & 0x3F]; - wr+=8; - p+=6; - len-=6; - - if (++lpos >= linelen8) { *wr++= 0; lpos=0; } - } - - if (len >= 3) - { - const int accum = (p[0] << 16) + (p[1] << 8) + p[2]; - wr[0] = wdl_base64_alphabet[(accum >> 18) & 0x3F]; - wr[1] = wdl_base64_alphabet[(accum >> 12) & 0x3F]; - wr[2] = wdl_base64_alphabet[(accum >> 6) & 0x3F]; - wr[3] = wdl_base64_alphabet[accum & 0x3F]; - wr+=4; - p+=3; - len-=3; - lpos+=3; - } - - if (len>0) - { - lpos += len; - if (len == 2) - { - const int accum = (p[0] << 8) | p[1]; - wr[0] = wdl_base64_alphabet[(accum >> 10) & 0x3F]; - wr[1] = wdl_base64_alphabet[(accum >> 4) & 0x3F]; - wr[2] = wdl_base64_alphabet[(accum & 0xF)<<2]; - } - else - { - const int accum = p[0]; - wr[0] = wdl_base64_alphabet[(accum >> 2) & 0x3F]; - wr[1] = wdl_base64_alphabet[(accum & 0x3)<<4]; - wr[2] = '='; - } - wr[3] = '='; - wr+=4; - } - if (lpos>0) *wr++=0; - - #ifdef _DEBUG - if (wr != wr_end) wdl_log("cfg_encode_binary: block mode size mismatch %d!\n", (int)(wr-wr_end)); - #endif - return; - } - } - } - - do - { - char buf[256]; - int thiss=len; - if (thiss > 96) thiss=96; - wdl_base64encode(p,buf,thiss); - - ctx->AddLine("%s",buf); - p+=thiss; - len-=thiss; - } - while (len>0); - -} - - -int cfg_decode_textblock(ProjectStateContext *ctx, WDL_FastString *str) // 0 on success, appends to str -{ - int child_count=1; - bool did_firstline=!!str->Get()[0]; - for (;;) - { - char linebuf[4096]; - if (ctx->GetLine(linebuf,sizeof(linebuf))) break; - - const char *p = linebuf; - while (*p == ' ' || *p == '\t') p++; - if (*p == '\'' || *p == '"' || *p == '`') p++; // skip a quote if any - - if (!p[0]) continue; - else if (p[0] == '<') child_count++; - else if (p[0] == '>') { if (child_count-- == 1) return 0; } - else if (child_count == 1) - { - const char *prefix = did_firstline ? "\r\n" : ""; - // lines can have a prefix immediately before | to specify the line ending of the previous line - switch (p[0]) - { - case 'c': prefix=""; p++; break; - case 'n': prefix="\n"; p++; break; - case 'r': prefix="\r"; p++; break; - case 'R': prefix="\n\r"; p++; break; - } - - if (p[0] == '|') - { - if (*prefix) str->Append(prefix); - str->Append(++p); - did_firstline=true; - } - } - } - return -1; - -} - -void cfg_encode_textblock(ProjectStateContext *ctx, const char *txt) // splits long lines -{ - while (*txt) - { - int l = 0; - while (txt[l] && l < 4000 && txt[l] != '\r' && txt[l] != '\n') l++; - ctx->AddLine("|%.*s",l,txt); - txt += l; - if (*txt == '\r') - { - if (*++txt== '\n') txt++; - } - else if (*txt == '\n') - { - if (*++txt == '\r') txt++; - } - } -} - -void cfg_encode_textblock2(ProjectStateContext *ctx, const char *txt) // preserves long lines, line endings -{ - char prefix = ' '; - while (*txt) - { - int l = 0; - while (txt[l] && l < 2000 && txt[l] != '\r' && txt[l] != '\n') l++; - ctx->AddLine("%c|%.*s",prefix,l,txt); - txt += l; - if (*txt == '\r') - { - prefix = 'r'; - if (*++txt== '\n') - { - txt++; - prefix = ' '; - } - } - else if (*txt == '\n') - { - prefix = 'n'; - if (*++txt == '\r') - { - txt++; - prefix = 'R'; - } - } - else if (*txt) prefix = 'c'; - else break; - - if (!*txt) - ctx->AddLine("%c|",prefix); - } -} - -char getConfigStringQuoteChar(const char *p, bool prefer_quoteless) -{ - if (!p || !*p) return '"'; - - char fc = *p; - int flags=0; - while (*p && flags!=15) - { - char c=*p++; - if (c=='"') flags|=1; - else if (c=='\'') flags|=2; - else if (c=='`') flags|=4; - else if (c == ' ' || c == '\t' || c == '\n' || c == '\r') flags |= 8; - } - if (prefer_quoteless || flags == 7) - { - if (!(flags & 8) && fc != '"' && fc != '\'' && fc != '`' && fc != '#' && fc != ';') return ' '; - } - - if (!(flags & 1)) return '"'; - if (!(flags & 2)) return '\''; - if (!(flags & 4)) return '`'; - return 0; -} - -bool configStringWantsBlockEncoding(const char *in) // returns true if over 1k long, has newlines, or contains all quote chars -{ - int maxl = 1024, flags = 0; - while (--maxl) - { - switch (*in++) - { - case 0: return false; - case '\n': return true; - case '"': if ((flags|=1)==7) return true; break; - case '`': if ((flags|=2)==7) return true; break; - case '\'': if ((flags|=4)==7) return true; break; - } - } - return true; -} - -void makeEscapedConfigString(const char *in, WDL_FastString *out) -{ - char c; - if (!in || !*in) out->Set("\"\""); - else if ((c = getConfigStringQuoteChar(in))) - { - if (c == ' ') - { - out->Set(in); - } - else - { - out->Set(&c,1); - out->Append(in); - out->Append(&c,1); - } - } - else // ick, change ` into ' - { - out->Set("`"); - out->Append(in); - out->Append("`"); - char *p=(char *)out->Get()+1; - while (*p && p[1]) - { - if (*p == '`') *p='\''; - else if (*p == '\r' || *p == '\n') *p=' '; - p++; - } - } -} diff --git a/oversampling/WDL/projectcontext.h b/oversampling/WDL/projectcontext.h deleted file mode 100644 index ee1400e..0000000 --- a/oversampling/WDL/projectcontext.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef _PROJECTCONTEXT_H_ -#define _PROJECTCONTEXT_H_ - -#include "wdltypes.h" - -class WDL_FastString; -class WDL_HeapBuf; -class WDL_FastQueue; - -#ifndef _REAPER_PLUGIN_PROJECTSTATECONTEXT_DEFINED_ -#define _WDL_PROJECTSTATECONTEXT_DEFINED_ - -class ProjectStateContext // this is also defined in reaper_plugin.h (keep them identical, thx) -{ -public: - virtual ~ProjectStateContext(){}; - - virtual void WDL_VARARG_WARN(printf,2,3) AddLine(const char *fmt, ...) = 0; - virtual int GetLine(char *buf, int buflen)=0; // returns -1 on eof - - virtual WDL_INT64 GetOutputSize()=0; - - virtual int GetTempFlag()=0; - virtual void SetTempFlag(int flag)=0; -}; - -#endif - -ProjectStateContext *ProjectCreateFileRead(const char *fn); -ProjectStateContext *ProjectCreateFileWrite(const char *fn); -ProjectStateContext *ProjectCreateMemCtx(WDL_HeapBuf *hb); // read or write (ugh, deprecated), be sure to delete it before accessing hb -ProjectStateContext *ProjectCreateMemCtx_Read(const WDL_HeapBuf *hb); // read only -ProjectStateContext *ProjectCreateMemCtx_Write(WDL_HeapBuf *hb); // write only, be sure to delete it before accessing hb -ProjectStateContext *ProjectCreateMemWriteFastQueue(WDL_FastQueue *fq); // only write! no need to do anything at all before accessing (can clear/reuse as necessary) - - -// helper functions -class LineParser; -bool ProjectContext_EatCurrentBlock(ProjectStateContext *ctx, - ProjectStateContext *ctxOut=NULL); // returns TRUE if got valid >, otherwise it means eof... - // writes to ctxOut if specified, will not write final > - -bool ProjectContext_GetNextLine(ProjectStateContext *ctx, LineParser *lpOut); // true if lpOut is valid - -char *projectcontext_fastDoubleToString(double value, char *bufOut, int prec_digits); // returns pointer to end of encoded string. prec_digits 0..18. -int ProjectContextFormatString(char *outbuf, size_t outbuf_size, const char *fmt, va_list va); // returns bytes used - -int cfg_decode_binary(ProjectStateContext *ctx, WDL_HeapBuf *hb); // 0 on success, doesnt clear hb -void cfg_encode_binary(ProjectStateContext *ctx, const void *ptr, int len); - -int cfg_decode_textblock(ProjectStateContext *ctx, WDL_FastString *str); // 0 on success, appends to str -void cfg_encode_textblock(ProjectStateContext *ctx, const char *text); // long lines get split by newlines -void cfg_encode_textblock2(ProjectStateContext *ctx, const char *text); // preserves newlines/long lines/etc (requires recent cfg_decode_textblock()) - -char getConfigStringQuoteChar(const char *in, bool prefer_quoteless=true); // returns 0 if no quote char available! -bool configStringWantsBlockEncoding(const char *in); // returns true if over 1k long, has newlines, or contains all quote chars -void makeEscapedConfigString(const char *in, WDL_FastString *out); - - -class ProjectStateContext_GenericRead : public ProjectStateContext -{ - protected: - const char *m_ptr; - const char *m_endptr; - int m_tmpflag; - - public: - ProjectStateContext_GenericRead(const void *buf, int sz) : m_tmpflag(0) - { - m_ptr = (const char *)buf; - m_endptr = m_ptr ? m_ptr+sz : NULL; - } - virtual ~ProjectStateContext_GenericRead() {} - - virtual void WDL_VARARG_WARN(printf,2,3) AddLine(const char *fmt, ...) { } - virtual int GetLine(char *buf, int buflen) // returns -1 on eof - { - const char *p = m_ptr; - const char *ep = m_endptr; - - while (p < ep && (!*p || *p == '\t' || *p == '\r' || *p == '\n' || *p == ' ')) p++; - if (p >= ep) - { - m_ptr=p; - return -1; - } - - if (buflen > 0) - { - while (--buflen > 0 && *p) *buf++ = *p++; - *buf=0; - } - - while (*p) p++; - m_ptr=p+1; // skip NUL - - return 0; - } - virtual int GetTempFlag() { return m_tmpflag; } - virtual void SetTempFlag(int flag) { m_tmpflag=flag; } - virtual WDL_INT64 GetOutputSize() { return 0; } -}; - - -#endif//_PROJECTCONTEXT_H_ diff --git a/oversampling/WDL/prvhash/prvhash_core.h b/oversampling/WDL/prvhash/prvhash_core.h deleted file mode 100644 index 873335f..0000000 --- a/oversampling/WDL/prvhash/prvhash_core.h +++ /dev/null @@ -1,168 +0,0 @@ -/** - * prvhash_core.h version 3.3 - * - * The inclusion file for the "prvhash_core64", "prvhash_core32", - * "prvhash_core16", "prvhash_core8", "prvhash_core4", "prvhash_core2" PRVHASH - * core functions for various state variable sizes. - * - * Description is available at https://github.com/avaneev/prvhash - * - * License - * - * Copyright (c) 2020-2021 Aleksey Vaneev - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#ifndef PRVHASH_CORE_INCLUDED -#define PRVHASH_CORE_INCLUDED - -#include - -/** - * This function runs a single PRVHASH random number generation round. This - * function can be used both as a hash generator and as a general-purpose - * random number generator. In the latter case, it is advisable to initially - * run this function 5 times before using its random output, to neutralize any - * possible oddities of "Seed"'s and "lcg"'s initial values. - * - * To generate hashes, the "lcg" variable should be XORed with entropy input - * prior to calling this function. - * - * @param[in,out] Seed0 The current "Seed" value. Can be initialized to any - * value. - * @param[in,out] lcg0 The current "lcg" value. Can be initialized to any - * value. - * @param[in,out] Hash0 Current hash word in a hash word array. - * @return Current random value. - */ - -inline uint64_t prvhash_core64( uint64_t* const Seed0, uint64_t* const lcg0, - uint64_t* const Hash0 ) -{ - uint64_t Seed = *Seed0; uint64_t lcg = *lcg0; uint64_t Hash = *Hash0; - - const uint64_t plcg = lcg; - const uint64_t mx = Seed * ( lcg - ~lcg ); - const uint64_t rs = mx >> 32 | mx << 32; - lcg += ~mx; - Hash += rs; - Seed = Hash ^ plcg; - const uint64_t out = lcg ^ rs; - - *Seed0 = Seed; *lcg0 = lcg; *Hash0 = Hash; - - return( out ); -} - -inline uint32_t prvhash_core32( uint32_t* const Seed0, uint32_t* const lcg0, - uint32_t* const Hash0 ) -{ - uint32_t Seed = *Seed0; uint32_t lcg = *lcg0; uint32_t Hash = *Hash0; - - const uint32_t plcg = lcg; - const uint32_t mx = Seed * ( lcg - ~lcg ); - const uint32_t rs = mx >> 16 | mx << 16; - lcg += ~mx; - Hash += rs; - Seed = Hash ^ plcg; - const uint32_t out = lcg ^ rs; - - *Seed0 = Seed; *lcg0 = lcg; *Hash0 = Hash; - - return( out ); -} - -inline uint16_t prvhash_core16( uint16_t* const Seed0, uint16_t* const lcg0, - uint16_t* const Hash0 ) -{ - uint16_t Seed = *Seed0; uint16_t lcg = *lcg0; uint16_t Hash = *Hash0; - - const uint16_t plcg = lcg; - const uint16_t mx = (uint16_t) ( Seed * ( lcg - ~lcg )); - const uint16_t rs = (uint16_t) ( mx >> 8 | mx << 8 ); - lcg += (uint16_t) ~mx; - Hash += rs; - Seed = (uint16_t) ( Hash ^ plcg ); - const uint16_t out = (uint16_t) ( lcg ^ rs ); - - *Seed0 = Seed; *lcg0 = lcg; *Hash0 = Hash; - - return( out ); -} - -inline uint8_t prvhash_core8( uint8_t* const Seed0, uint8_t* const lcg0, - uint8_t* const Hash0 ) -{ - uint8_t Seed = *Seed0; uint8_t lcg = *lcg0; uint8_t Hash = *Hash0; - - const uint8_t plcg = lcg; - const uint8_t mx = (uint8_t) ( Seed * ( lcg - ~lcg )); - const uint8_t rs = (uint8_t) ( mx >> 4 | mx << 4 ); - lcg += (uint8_t) ~mx; - Hash += rs; - Seed = (uint8_t) ( Hash ^ plcg ); - const uint8_t out = (uint8_t) ( lcg ^ rs ); - - *Seed0 = Seed; *lcg0 = lcg; *Hash0 = Hash; - - return( out ); -} - -inline uint8_t prvhash_core4( uint8_t* const Seed0, uint8_t* const lcg0, - uint8_t* const Hash0 ) -{ - uint8_t Seed = *Seed0; uint8_t lcg = *lcg0; uint8_t Hash = *Hash0; - - const uint8_t plcg = lcg; - const uint8_t mx = (uint8_t) (( Seed * ( lcg - ~lcg )) & 15 ); - const uint8_t rs = (uint8_t) (( mx >> 2 | mx << 2 ) & 15 ); - lcg += (uint8_t) ~mx; - lcg &= 15; - Hash += rs; - Hash &= 15; - Seed = (uint8_t) ( Hash ^ plcg ); - const uint8_t out = (uint8_t) ( lcg ^ rs ); - - *Seed0 = Seed; *lcg0 = lcg; *Hash0 = Hash; - - return( out ); -} - -inline uint8_t prvhash_core2( uint8_t* const Seed0, uint8_t* const lcg0, - uint8_t* const Hash0 ) -{ - uint8_t Seed = *Seed0; uint8_t lcg = *lcg0; uint8_t Hash = *Hash0; - - const uint8_t plcg = lcg; - const uint8_t mx = (uint8_t) (( Seed * ( lcg - ~lcg )) & 3 ); - const uint8_t rs = (uint8_t) (( mx >> 1 | mx << 1 ) & 3 ); - lcg += (uint8_t) ~mx; - lcg &= 3; - Hash += rs; - Hash &= 3; - Seed = (uint8_t) ( Hash ^ plcg ); - const uint8_t out = (uint8_t) ( lcg ^ rs ); - - *Seed0 = Seed; *lcg0 = lcg; *Hash0 = Hash; - - return( out ); -} - -#endif // PRVHASH_CORE_INCLUDED diff --git a/oversampling/WDL/ptrlist.h b/oversampling/WDL/ptrlist.h deleted file mode 100644 index eec7a98..0000000 --- a/oversampling/WDL/ptrlist.h +++ /dev/null @@ -1,273 +0,0 @@ -/* - WDL - ptrlist.h - Copyright (C) 2005 and later, Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - -*/ - -/* - - This file provides a simple templated class for a list of pointers. By default this list - doesn't free any of the pointers, but you can call Empty(true) or Delete(x,true) to delete the pointer, - or you can use Empty(true,free) etc to call free (or any other function). - - Note: on certain compilers, instantiating with WDL_PtrList bla; will give a warning, since - the template will create code for "delete (void *)x;" which isn't technically valid. Oh well. - -*/ - -#ifndef _WDL_PTRLIST_H_ -#define _WDL_PTRLIST_H_ - -#include "heapbuf.h" - -template class WDL_PtrList -{ - public: - explicit WDL_PtrList(int defgran=4096) : m_hb(defgran WDL_HEAPBUF_TRACEPARM("WDL_PtrList")) - { - } - - ~WDL_PtrList() - { - } - - PTRTYPE **GetList() const { return (PTRTYPE**)m_hb.Get(); } - PTRTYPE *Get(INT_PTR index) const - { - PTRTYPE **list = (PTRTYPE**)m_hb.Get(); - if (list && (UINT_PTR)index < (UINT_PTR)(m_hb.GetSize()/sizeof(PTRTYPE *))) return list[index]; - return NULL; - } - - int GetSize(void) const { return m_hb.GetSize()/(unsigned int)sizeof(PTRTYPE *); } - - int Find(const PTRTYPE *p) const - { - if (p) - { - PTRTYPE **list=(PTRTYPE **)m_hb.Get(); - int x; - const int n = GetSize(); - for (x = 0; x < n; x ++) if (list[x] == p) return x; - } - return -1; - } - int FindR(const PTRTYPE *p) const - { - if (p) - { - PTRTYPE **list=(PTRTYPE **)m_hb.Get(); - int x = GetSize(); - while (--x >= 0) if (list[x] == p) return x; - } - return -1; - } - - PTRTYPE *Add(PTRTYPE *item) - { - const int s=GetSize(); - PTRTYPE **list=(PTRTYPE **)m_hb.ResizeOK((s+1)*(unsigned int)sizeof(PTRTYPE*),false); - if (list) - { - list[s]=item; - return item; - } - return NULL; - } - - PTRTYPE *Set(int index, PTRTYPE *item) - { - PTRTYPE **list=(PTRTYPE **)m_hb.Get(); - if (list && index >= 0 && index < GetSize()) return list[index]=item; - return NULL; - } - - PTRTYPE *Insert(int index, PTRTYPE *item) - { - int s=GetSize(); - PTRTYPE **list = (PTRTYPE **)m_hb.ResizeOK((s+1)*(unsigned int)sizeof(PTRTYPE*),false); - - if (!list) return item; - - if (index<0) index=0; - - int x; - for (x = s; x > index; x --) list[x]=list[x-1]; - return (list[x] = item); - } - int FindSorted(const PTRTYPE *p, int (*compar)(const PTRTYPE **a, const PTRTYPE **b)) const - { - bool m; - int i = LowerBound(p,&m,compar); - return m ? i : -1; - } - PTRTYPE *InsertSorted(PTRTYPE *item, int (*compar)(const PTRTYPE **a, const PTRTYPE **b)) - { - bool m; - return Insert(LowerBound(item,&m,compar),item); - } - - void Delete(int index) - { - PTRTYPE **list=GetList(); - int size=GetSize(); - if (list && index >= 0 && index < size) - { - if (index < --size) memmove(list+index,list+index+1,(unsigned int)sizeof(PTRTYPE *)*(size-index)); - m_hb.Resize(size * (unsigned int)sizeof(PTRTYPE*),false); - } - } - void Delete(int index, bool wantDelete, void (*delfunc)(void *)=NULL) - { - PTRTYPE **list=GetList(); - int size=GetSize(); - if (list && index >= 0 && index < size) - { - if (wantDelete) - { - if (delfunc) delfunc(Get(index)); - else delete Get(index); - } - if (index < --size) memmove(list+index,list+index+1,(unsigned int)sizeof(PTRTYPE *)*(size-index)); - m_hb.Resize(size * (unsigned int)sizeof(PTRTYPE*),false); - } - } - void Delete(int index, void (*delfunc)(PTRTYPE *)) - { - PTRTYPE **list=GetList(); - int size=GetSize(); - if (list && index >= 0 && index < size) - { - if (delfunc) delfunc(Get(index)); - if (index < --size) memmove(list+index,list+index+1,(unsigned int)sizeof(PTRTYPE *)*(size-index)); - m_hb.Resize(size * (unsigned int)sizeof(PTRTYPE*),false); - } - } - void DeletePtr(const PTRTYPE *p) { Delete(Find(p)); } - void DeletePtr(const PTRTYPE *p, bool wantDelete, void (*delfunc)(void *)=NULL) { Delete(Find(p),wantDelete,delfunc); } - void DeletePtr(const PTRTYPE *p, void (*delfunc)(PTRTYPE *)) { Delete(Find(p),delfunc); } - - void Empty() - { - m_hb.Resize(0,false); - } - void Empty(bool wantDelete, void (*delfunc)(void *)=NULL) - { - if (wantDelete) - { - int x; - for (x = GetSize()-1; x >= 0; x --) - { - PTRTYPE* p = Get(x); - if (p) - { - if (delfunc) delfunc(p); - else delete p; - } - m_hb.Resize(x*(unsigned int)sizeof(PTRTYPE *),false); - } - } - m_hb.Resize(0,false); - } - void Empty(void (*delfunc)(PTRTYPE *)) - { - int x; - for (x = GetSize()-1; x >= 0; x --) - { - PTRTYPE* p = Get(x); - if (delfunc && p) delfunc(p); - m_hb.Resize(x*(unsigned int)sizeof(PTRTYPE *),false); - } - } - void EmptySafe(bool wantDelete=false,void (*delfunc)(void *)=NULL) - { - if (!wantDelete) Empty(); - else - { - WDL_PtrList tmp; - int x; - for(x=0;x 0) a = b+1; - else if (cmp < 0) c = b; - else - { - *ismatch = true; - return b; - } - } - *ismatch = false; - return a; - } - - void Compact() { m_hb.Resize(m_hb.GetSize(),true); } - - - int DeleteBatch(bool (*proc)(PTRTYPE *p, void *ctx), void *ctx=NULL) // proc returns true to remove item. returns number removed - { - const int sz = GetSize(); - int cnt=0; - PTRTYPE **rd = GetList(), **wr = rd; - for (int x = 0; x < sz; x ++) - { - if (!proc(*rd,ctx)) - { - if (rd != wr) *wr=*rd; - wr++; - cnt++; - } - rd++; - } - if (cnt < sz) m_hb.Resize(cnt * sizeof(PTRTYPE*),false); - return sz - cnt; - } - - private: - WDL_HeapBuf m_hb; - -}; - - -template class WDL_PtrList_DeleteOnDestroy : public WDL_PtrList -{ -public: - explicit WDL_PtrList_DeleteOnDestroy(void (*delfunc)(void *)=NULL, int defgran=4096) : WDL_PtrList(defgran), m_delfunc(delfunc) { } - ~WDL_PtrList_DeleteOnDestroy() - { - WDL_PtrList::EmptySafe(true,m_delfunc); - } -private: - void (*m_delfunc)(void *); -}; - -#endif - diff --git a/oversampling/WDL/ptrlist_indexed.h b/oversampling/WDL/ptrlist_indexed.h deleted file mode 100644 index 1ef8727..0000000 --- a/oversampling/WDL/ptrlist_indexed.h +++ /dev/null @@ -1,142 +0,0 @@ -#ifndef _WDL_PTRLIST_INDEXED_H_ -#define _WDL_PTRLIST_INDEXED_H_ - -#include "assocarray.h" -#include "ptrlist.h" - -template class WDL_IndexedPtrList { - public: - WDL_IndexedPtrList() { } - ~WDL_IndexedPtrList() { } - - int GetSize() const { - // do not _checkState(), GetSize() may be called while unlocked for estimation purposes - return m_list.GetSize(); - } - T * const *GetList() const { _checkState(); return m_list.GetList(); } - T *Get(INT_PTR idx) const { _checkState(); return m_list.Get(idx); } - int Find(const T *p) const - { - _checkState(); - if (!p) return -1; - const int *ret = m_index.GetPtr((INT_PTR)p); - return ret ? *ret : -1; - } - void Empty() { _checkState(); m_list.Empty(); m_index.DeleteAll(); } - void Empty(bool wantDelete, void (*delfunc)(void*)=NULL) { _checkState(); m_list.Empty(wantDelete,delfunc); m_index.DeleteAll(); } - void EmptySafe(bool wantDelete=false,void (*delfunc)(void *)=NULL) - { - _checkState(); - m_index.DeleteAll(); - m_list.EmptySafe(wantDelete,delfunc); - m_index.DeleteAll(); - } - void Delete(int idx, bool wantDelete=false, void (*delfunc)(void *)=NULL) - { - _checkState(); - T *item = m_list.Get(idx); - m_list.Delete(idx,wantDelete,delfunc); - if (item) - { - m_index.Delete((INT_PTR)item); - const int indexsz = m_index.GetSize(); - WDL_ASSERT(m_list.GetSize() == indexsz); - if (idx < indexsz) - { - for (int x=0;x idx) (*val)--; - } - } - } - } - } - void DeletePtr(const T *p) { Delete(Find(p)); } - void DeletePtr(const T *p, bool wantDelete, void (*delfunc)(void *)=NULL) { Delete(Find(p),wantDelete,delfunc); } - void Add(T *p) - { - _checkState(); - WDL_ASSERT(Find(p) < 0); - if (WDL_NORMALLY(p)) - { - const int sz = m_list.GetSize(); - m_list.Add(p); - m_index.Insert((INT_PTR)p,sz); - } - } - void RebuildIndex() - { - m_index.DeleteAll(); - for (int x = 0; x < m_list.GetSize(); x ++) - { - m_index.AddUnsorted((INT_PTR)m_list.Get(x),x); - } - m_index.Resort(); - _checkState(); - } - void Swap(int index1, int index2) - { - _checkState(); - if (index1 != index2 && - WDL_NORMALLY(index1>=0) && - WDL_NORMALLY(index1=0) && - WDL_NORMALLY(index2= listsz) { Add(p); return; } - - const int indexsz = m_index.GetSize(); - WDL_ASSERT(listsz==indexsz); - - for (int x=0;x= index) (*val)++; - WDL_ASSERT(*val != index); - } - } - m_list.Insert(index,p); - m_index.Insert((INT_PTR)p,index); - } - - WDL_PtrList m_list; - WDL_PtrKeyedArray m_index; - - WDL_IndexedPtrList &operator=(const WDL_IndexedPtrList &cp) - { - m_list = cp.m_list; - RebuildIndex(); - return *this; - } - - void _checkState() const - { -#ifdef _DEBUG - const int idxsz = m_index.GetSize(), listsz = m_list.GetSize(); - WDL_ASSERT(idxsz == listsz); -#endif - } -}; - -#endif diff --git a/oversampling/WDL/queue.h b/oversampling/WDL/queue.h deleted file mode 100644 index 0e8ca89..0000000 --- a/oversampling/WDL/queue.h +++ /dev/null @@ -1,270 +0,0 @@ -/* - WDL - queue.h - Copyright (C) 2005 and later, Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - -*/ - -/* - - This file provides a simple class for a FIFO queue of bytes. It uses a simple buffer, - so should not generally be used for large quantities of data (it can advance the queue - pointer, but Compact() needs to be called regularly to keep memory usage down, and when - it is called, there's a memcpy() penalty for the remaining data. oh well, is what it is). - - You may also wish to look at fastqueue.h or circbuf.h if these limitations aren't acceptable. - -*/ - -#ifndef _WDL_QUEUE_H_ -#define _WDL_QUEUE_H_ - -#include "heapbuf.h" - - -class WDL_Queue -{ -public: - WDL_Queue() : m_hb(4096 WDL_HEAPBUF_TRACEPARM("WDL_Queue")), m_pos(0) { } - WDL_Queue(int hbgran) : m_hb(hbgran WDL_HEAPBUF_TRACEPARM("WDL_Queue")), m_pos(0) { } - ~WDL_Queue() { } - - template void* AddT(T* buf) - { - return Add(buf, sizeof(T)); - } - - void *Add(const void *buf, int len) - { - int olen=m_hb.GetSize(); - if (m_pos >= olen) m_pos=olen=0; // if queue is empty then autoreset it - - char *newbuf=(char *)m_hb.ResizeOK(olen+len,false); - if (newbuf) - { - newbuf += olen; - if (buf) memcpy(newbuf,buf,len); - } - return newbuf; - } - - template T* GetT(T* val=0) - { - T* p = (T*) Get(sizeof(T)); - if (val && p) *val = *p; - return p; - } - - void* Get(int size) - { - void* p = Get(); - if (p) Advance(size); - return p; - } - - void *Get() const - { - if (m_pos >= 0 && m_pos < m_hb.GetSize()) return (char *)m_hb.Get()+m_pos; - return NULL; - } - - void* Rewind() - { - m_pos = 0; - return m_hb.Get(); - } - - int GetSize() const - { - return m_hb.GetSize()-m_pos; - } - int Available() const { return GetSize(); } - - void Clear() - { - m_pos=0; - m_hb.Resize(0,false); - } - - void Advance(int bytecnt) - { - m_pos+=bytecnt; - if (m_pos<0)m_pos=0; - else if (m_pos > m_hb.GetSize()) m_pos=m_hb.GetSize(); - } - - void Compact(bool allocdown=false, bool force=false) - { - int olen=m_hb.GetSize(); - if (m_pos > (force ? 0 : olen/2)) - { - olen -= m_pos; - if (olen > 0) - { - char *a=(char*)m_hb.Get(); - memmove(a,a+m_pos,olen); - } - else - { - olen = 0; - } - m_hb.Resize(olen,allocdown); - m_pos=0; - } - } - - void SetGranul(int granul) { m_hb.SetGranul(granul); } - - - - - // endian-management stuff - - static void WDL_Queue__bswap_buffer(void *buf, int len) // poorly named! only bswaps on BE, deprecated, use wdl_memcpy_le() - { - wdl_memcpy_le(buf,buf,1,len); - } - - // older API of static functions (that ended up warning a bit anyway) -#define WDL_Queue__AddToLE(q, v) (q)->AddToLE(v) -#define WDL_Queue__AddDataToLE(q,d,ds,us) (q)->AddDataToLE(d,ds,us) -#define WDL_Queue__GetTFromLE(q,v) (q)->GetTFromLE(v) -#define WDL_Queue__GetDataFromLE(q,ds,us) (q)->GetDataFromLE(ds,us) - - template void AddToLE(T *val) - { - void *w = Add(NULL, sizeof(T)); - if (WDL_NORMALLY(w != NULL) && val != NULL) - wdl_memcpy_le(w, val, 1, sizeof(T)); - } - void AddDataToLE(const void *data, int datasize, int unitsize) - { - char *w = (char *)Add(NULL,datasize); - if (WDL_NOT_NORMALLY(w == NULL)) return; - - if (WDL_NOT_NORMALLY(unitsize<1)) unitsize=1; - WDL_ASSERT((datasize % unitsize) == 0); - if (data) wdl_memcpy_le(w,data,datasize/unitsize,unitsize); - } - - - // NOTE: these thrash the contents of the queue if on BE systems, do not use if you - // will rewind etc. better to use Get() and wdl_memcpy_le(). - template T *GetTFromLE(T* val=0) - { - T *p = GetT(val); - if (p) - { - wdl_memcpy_le(p,p,1,sizeof(T)); - if (val) *val = *p; - } - return p; - } - - void *GetDataFromLE(int datasize, int unitsize) - { - void *data=Get(datasize); - WDL_ASSERT((datasize % unitsize) == 0); - if (data && WDL_NORMALLY(unitsize>0)) wdl_memcpy_le(data,data,datasize/unitsize,unitsize); - return data; - } - - -private: - WDL_HeapBuf m_hb; - int m_pos; -public: - int __pad; // keep 8 byte aligned -}; - -template class WDL_TypedQueue -{ -public: - WDL_TypedQueue() : m_hb(4096 WDL_HEAPBUF_TRACEPARM("WDL_TypedQueue")), m_pos(0) { } - ~WDL_TypedQueue() { } - - T *Add(const T *buf, int len) - { - int olen=m_hb.GetSize(); - if (m_pos >= olen) olen=m_pos=0; - len *= (int)sizeof(T); - - char *newbuf=(char*)m_hb.ResizeOK(olen+len,false); - if (newbuf) - { - newbuf += olen; - if (buf) memcpy(newbuf,buf,len); - } - return (T*) newbuf; - } - - T *Get() const - { - if (m_pos >= 0 && m_pos < m_hb.GetSize()) return (T*)((char *)m_hb.Get()+m_pos); - return NULL; - } - - int GetSize() const - { - return m_pos < m_hb.GetSize() ? (m_hb.GetSize()-m_pos)/sizeof(T) : 0; - } - int Available() const { return GetSize(); } - - void Clear() - { - m_pos=0; - m_hb.Resize(0,false); - } - - void Advance(int cnt) - { - m_pos+=cnt*(int)sizeof(T); - if (m_pos<0)m_pos=0; - else if (m_pos > m_hb.GetSize()) m_pos=m_hb.GetSize(); - } - - void Compact(bool allocdown=false, bool force=false) - { - int olen=m_hb.GetSize(); - if (m_pos >= (force ? 0 : olen/2)) - { - olen -= m_pos; - if (olen > 0) - { - char *a=(char*)m_hb.Get(); - memmove(a,a+m_pos,olen); - } - else - { - olen = 0; - } - m_hb.Resize(olen,allocdown); - m_pos=0; - } - } - - void SetGranul(int granul) { m_hb.SetGranul(granul); } - -private: - WDL_HeapBuf m_hb; - int m_pos; -public: - int __pad; // keep 8 byte aligned -}; - -#endif diff --git a/oversampling/WDL/resample.cpp b/oversampling/WDL/resample.cpp deleted file mode 100644 index 96b981f..0000000 --- a/oversampling/WDL/resample.cpp +++ /dev/null @@ -1,1670 +0,0 @@ -/* - WDL - resample.cpp - Copyright (C) 2010 and later Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - You may also distribute this software under the LGPL v2 or later. - -*/ - -#include "resample.h" -#include - -#include "denormal.h" - -#if !defined(WDL_RESAMPLE_NO_SSE) && !defined(WDL_RESAMPLE_USE_SSE) - #if defined(__SSE2__) || _M_IX86_FP >= 2 || (defined(_M_X64) && (_MSC_VER > 1400 || __INTEL_COMPILER > 0)) - #define WDL_RESAMPLE_USE_SSE - #endif -#endif - -#ifdef WDL_RESAMPLE_USE_SSE - #include -#endif - -#ifndef PI -#define PI 3.1415926535897932384626433832795 -#endif - -class WDL_Resampler::WDL_Resampler_Filter // pre/post filter -{ -public: - WDL_Resampler_Filter() : m_fpos(-1.0), m_filtsz(0), m_state(-1) { } - - void Reset() - { - memset(m_hist.Get(),0,m_hist.GetSize() * sizeof(double)); - m_state = -1; - } - - void setParms(double fpos, double fpos2, double Q, int hist_sz, int nch) - { - if (fpos < 1.0) - { - // if initial filter state is close to nyquist, fade-in - // (in case this resampler was newly activated on varispeed media) - if (m_state == -1 && fpos >= 0.97) m_state=0; - fpos *= fpos2; - } - else - { - fpos = 1.0; - } - - m_filtsz = hist_sz; - hist_sz *= 4 * nch; - if (m_hist.GetSize() != hist_sz) - { - const int oldsz = m_hist.GetSize(); - double *p = m_hist.Resize(hist_sz,false); - if (m_hist.GetSize() > oldsz) - memset(p+oldsz,0,(m_hist.GetSize() - oldsz)*sizeof(double)); - } - - if (fabs(fpos-m_fpos)<0.000001) return; - m_fpos=fpos; - - const double pos = (fpos == 1.0 ? fpos2 : fpos) * PI; - const double cpos=cos(pos); - const double spos=sin(pos); - const double alpha=spos/(2.0*Q); - const double sc=1.0/( 1 + alpha); - m_b1 = (1-cpos) * sc; - m_b2 = m_b0 = m_b1*0.5; - m_a1 = -2 * cpos * sc; - m_a2 = (1-alpha)*sc; - } - - void ApplyIIR(WDL_ResampleSample *out1, int ns, int span, double *hsave) - { - double b0=m_b0,b1=m_b1,b2=m_b2,a1=m_a1,a2=m_a2; - double hist[4]; - memcpy(hist,hsave, sizeof(hist)); - while (ns--) - { - double in=*out1; - double out = (double) ( in*b0 + hist[0]*b1 + hist[1]*b2 - hist[2]*a1 - hist[3]*a2); - hist[1]=hist[0]; hist[0]=in; - hist[3]=hist[2]; *out1 = hist[2]=denormal_filter_double(out); - - out1+=span; - } - memcpy(hsave, hist, sizeof(hist)); - } - void ApplyIIRFade(WDL_ResampleSample *out1, int ns, int span, double *hsave, double v0, double dv) - { - double b0=m_b0,b1=m_b1,b2=m_b2,a1=m_a1,a2=m_a2; - double hist[4]; - memcpy(hist,hsave, sizeof(hist)); - while (ns--) - { - double in=*out1; - double out = (double) ( in*b0 + hist[0]*b1 + hist[1]*b2 - hist[2]*a1 - hist[3]*a2); - hist[1]=hist[0]; hist[0]=in; - hist[3]=hist[2]; - *out1 = (hist[2] = denormal_filter_double(out)) * v0 + in * (1.0-v0); - v0 += dv; - out1+=span; - } - memcpy(hsave, hist, sizeof(hist)); - } - - void ApplyBuffer(WDL_ResampleSample *buf, int ns, int nch) - { - double *hist = m_hist.Get(); - const int nf = m_filtsz; - if (m_state == 0) - { - if (m_fpos >= 1.0) return; - m_state = 1; - for (int x=0; x < nch; x ++) for (int a = 0; a < nf; a ++, hist+=4) ApplyIIRFade(buf+x,ns,nch,hist,0.0,1.0/ns); - } - else if (m_fpos >= 1.0) - { - if (m_state > 0) - for (int x=0; x < nch; x ++) for (int a = 0; a < nf; a ++, hist+=4) ApplyIIRFade(buf+x,ns,nch,hist,1.0,-1.0/ns); - m_state = 0; - } - else - { - m_state = 1; - for (int x=0; x < nch; x ++) for (int a = 0; a < nf; a ++, hist+=4) ApplyIIR(buf+x,ns,nch,hist); - } - } - -private: - double m_fpos; - double m_a1,m_a2; - double m_b0,m_b1,m_b2; - - WDL_TypedBuf m_hist; - - int m_filtsz; - int m_state; -}; - - -template static void inline SincSample(T1 *outptr, const T1 *inptr, double fracpos, int nch, const T2 *filter, int filtsz, int oversize) -{ - fracpos *= oversize; - const int ifpos=(int)fracpos; - filter += (oversize-ifpos) * filtsz; - fracpos -= ifpos; - - int x; - for (x = 0; x < nch; x ++) - { - double sum=0.0,sum2=0.0; - const T2 *fptr2=filter; - const T2 *fptr=fptr2 - filtsz; - const T1 *iptr=inptr+x; - int i=filtsz/2; - while (i--) - { - sum += fptr[0]*iptr[0]; - sum2 += fptr2[0]*iptr[0]; - sum += fptr[1]*iptr[nch]; - sum2 += fptr2[1]*iptr[nch]; - iptr+=nch*2; - fptr+=2; - fptr2+=2; - } - outptr[x]=sum*fracpos + sum2*(1.0-fracpos); - } - -} - -template static void inline SincSampleN(T1 *outptr, const T1 *inptr, double fracpos, int nch, const T2 *filter, int filtsz, int oversize) -{ - const int ifpos=(int)(fracpos*oversize+0.5); - filter += (oversize-ifpos) * filtsz; - - int x; - for (x = 0; x < nch; x ++) - { - double sum2=0.0; - const T2 *fptr2=filter; - const T1 *iptr=inptr+x; - int i=filtsz/2; - while (i--) - { - sum2 += fptr2[0]*iptr[0]; - sum2 += fptr2[1]*iptr[nch]; - iptr+=nch*2; - fptr2+=2; - } - outptr[x]=sum2; - } - -} - -template static void inline SincSample1(T1 *outptr, const T1 *inptr, double fracpos, const T2 *filter, int filtsz, int oversize) -{ - fracpos *= oversize; - const int ifpos=(int)fracpos; - fracpos -= ifpos; - - double sum=0.0,sum2=0.0; - const T2 *fptr2=filter + (oversize-ifpos) * filtsz; - const T2 *fptr=fptr2 - filtsz; - const T1 *iptr=inptr; - int i=filtsz/2; - while (i--) - { - sum += fptr[0]*iptr[0]; - sum2 += fptr2[0]*iptr[0]; - sum += fptr[1]*iptr[1]; - sum2 += fptr2[1]*iptr[1]; - iptr+=2; - fptr+=2; - fptr2+=2; - } - outptr[0]=sum*fracpos+sum2*(1.0-fracpos); -} - -template static void inline SincSample1N(T1 *outptr, const T1 *inptr, double fracpos, const T2 *filter, int filtsz, int oversize) -{ - const int ifpos=(int)(fracpos*oversize+0.5); - - double sum2=0.0; - const T2 *fptr2=filter + (oversize-ifpos) * filtsz; - const T1 *iptr=inptr; - int i=filtsz/2; - while (i--) - { - sum2 += fptr2[0]*iptr[0]; - sum2 += fptr2[1]*iptr[1]; - iptr+=2; - fptr2+=2; - } - outptr[0]=sum2; -} - -template static void inline SincSample2(T1 *outptr, const T1 *inptr, double fracpos, const T2 *filter, int filtsz, int oversize) -{ - fracpos *= oversize; - const int ifpos=(int)fracpos; - fracpos -= ifpos; - - const T2 *fptr2=filter + (oversize-ifpos) * filtsz; - const T2 *fptr=fptr2 - filtsz; - - double sum=0.0; - double sum2=0.0; - double sumb=0.0; - double sum2b=0.0; - const T1 *iptr=inptr; - int i=filtsz/2; - while (i--) - { - sum += fptr[0]*iptr[0]; - sum2 += fptr[0]*iptr[1]; - sumb += fptr2[0]*iptr[0]; - sum2b += fptr2[0]*iptr[1]; - sum += fptr[1]*iptr[2]; - sum2 += fptr[1]*iptr[3]; - sumb += fptr2[1]*iptr[2]; - sum2b += fptr2[1]*iptr[3]; - iptr+=4; - fptr+=2; - fptr2+=2; - } - outptr[0]=sum*fracpos + sumb*(1.0-fracpos); - outptr[1]=sum2*fracpos + sum2b*(1.0-fracpos); - -} - -template static void inline SincSample2N(T1 *outptr, const T1 *inptr, double fracpos, const T2 *filter, int filtsz, int oversize) -{ - const int ifpos=(int)(fracpos*oversize+0.5); - - const T2 *fptr2=filter + (oversize-ifpos) * filtsz; - - double sumb=0.0; - double sum2b=0.0; - const T1 *iptr=inptr; - int i=filtsz/2; - while (i--) - { - sumb += fptr2[0]*iptr[0]; - sum2b += fptr2[0]*iptr[1]; - sumb += fptr2[1]*iptr[2]; - sum2b += fptr2[1]*iptr[3]; - iptr+=4; - fptr2+=2; - } - outptr[0]=sumb; - outptr[1]=sum2b; -} - - -#ifdef WDL_RESAMPLE_USE_SSE - -static void inline SincSample(double *outptr, const double *inptr, double fracpos, int nch, const float *filter, int filtsz, int oversize) -{ - fracpos *= oversize; - const int ifpos=(int)fracpos; - filter += (oversize-ifpos) * filtsz; - fracpos -= ifpos; - - int x; - for (x = 0; x < nch; x ++) - { - double sum, sum2; - const float *fptr2=filter; - const float *fptr=fptr2 - filtsz; - const double *iptr=inptr+x; - int i=filtsz/2; - - __m128d xmm0 = _mm_setzero_pd(); - __m128d xmm1 = _mm_setzero_pd(); - __m128d xmm2, xmm3; - - while (i--) - { - xmm2 = _mm_set_pd(iptr[nch], iptr[0]); - - xmm3 = _mm_load_sd((double *)fptr); - xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm3); - - xmm3 = _mm_load_sd((double *)fptr2); - xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm1 = _mm_add_pd(xmm1, xmm3); - - iptr+=nch*2; - fptr+=2; - fptr2+=2; - } - - xmm2 = xmm0; - xmm0 = _mm_unpackhi_pd(xmm0, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm2); - _mm_store_sd(&sum, xmm0); - - xmm3 = xmm1; - xmm1 = _mm_unpackhi_pd(xmm1, xmm3); - xmm1 = _mm_add_pd(xmm1, xmm3); - _mm_store_sd(&sum2, xmm1); - - outptr[x]=sum*fracpos + sum2*(1.0-fracpos); - } - -} - -static void inline SincSampleN(double *outptr, const double *inptr, double fracpos, int nch, const float *filter, int filtsz, int oversize) -{ - const int ifpos=(int)(fracpos*oversize+0.5); - filter += (oversize-ifpos) * filtsz; - - int x; - for (x = 0; x < nch; x ++) - { - double sum2; - const float *fptr2=filter; - const double *iptr=inptr+x; - int i=filtsz/2; - - __m128d xmm0 = _mm_setzero_pd(); - __m128d xmm1 = _mm_setzero_pd(); - __m128d xmm2, xmm3; - - while (i >= 2) - { - xmm2 = _mm_set_pd(iptr[nch], iptr[0]); - - xmm3 = _mm_load_sd((double *)fptr2); - xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm3); - - xmm2 = _mm_set_pd(iptr[nch*3], iptr[nch*2]); - - xmm3 = _mm_load_sd((double *)fptr2 + 1); - xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm1 = _mm_add_pd(xmm1, xmm3); - - iptr+=nch*4; - fptr2+=4; - i-=2; - } - - if (i) - { - xmm2 = _mm_set_pd(iptr[nch], iptr[0]); - - xmm3 = _mm_load_sd((double *)fptr2); - xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm3); - } - - xmm1 = _mm_add_pd(xmm1, xmm0); - - xmm3 = xmm1; - xmm1 = _mm_unpackhi_pd(xmm1, xmm3); - xmm1 = _mm_add_pd(xmm1, xmm3); - _mm_store_sd(&sum2, xmm1); - - outptr[x]=sum2; - } - -} - -static void inline SincSample1(double *outptr, const double *inptr, double fracpos, const float *filter, int filtsz, int oversize) -{ - fracpos *= oversize; - const int ifpos=(int)fracpos; - fracpos -= ifpos; - - double sum, sum2; - const float *fptr2=filter + (oversize-ifpos) * filtsz; - const float *fptr=fptr2 - filtsz; - const double *iptr=inptr; - int i=filtsz/2; - - __m128d xmm0 = _mm_setzero_pd(); - __m128d xmm1 = _mm_setzero_pd(); - __m128d xmm2, xmm3; - - while (i >= 2) - { - xmm2 = _mm_loadu_pd(iptr); - - xmm3 = _mm_cvtps_pd(_mm_load_ps(fptr)); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm3); - - xmm3 = _mm_cvtps_pd(_mm_load_ps(fptr2)); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm1 = _mm_add_pd(xmm1, xmm3); - - xmm2 = _mm_loadu_pd(iptr+2); - - xmm3 = _mm_load_sd((double *)fptr + 1); - xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm3); - - xmm3 = _mm_load_sd((double *)fptr2 + 1); - xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm1 = _mm_add_pd(xmm1, xmm3); - - iptr+=4; - fptr+=4; - fptr2+=4; - i-=2; - } - - if (i) - { - xmm2 = _mm_loadu_pd(iptr); - - xmm3 = _mm_load_sd((double *)fptr); - xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm3); - - xmm3 = _mm_load_sd((double *)fptr2); - xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm1 = _mm_add_pd(xmm1, xmm3); - } - - xmm2 = xmm0; - xmm0 = _mm_unpackhi_pd(xmm0, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm2); - _mm_store_sd(&sum, xmm0); - - xmm3 = xmm1; - xmm1 = _mm_unpackhi_pd(xmm1, xmm3); - xmm1 = _mm_add_pd(xmm1, xmm3); - _mm_store_sd(&sum2, xmm1); - - outptr[0]=sum*fracpos+sum2*(1.0-fracpos); -} - -static void inline SincSample1N(double *outptr, const double *inptr, double fracpos, const float *filter, int filtsz, int oversize) -{ - const int ifpos=(int)(fracpos*oversize+0.5); - - double sum2; - const float *fptr2=filter + (oversize-ifpos) * filtsz; - const double *iptr=inptr; - int i=filtsz/2; - - __m128d xmm0 = _mm_setzero_pd(); - __m128d xmm1 = _mm_setzero_pd(); - __m128d xmm2, xmm3; - - while (i >= 2) - { - xmm2 = _mm_loadu_pd(iptr); - - xmm3 = _mm_cvtps_pd(_mm_load_ps(fptr2)); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm3); - - xmm2 = _mm_loadu_pd(iptr+2); - - xmm3 = _mm_load_sd((double *)fptr2 + 1); - xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm1 = _mm_add_pd(xmm1, xmm3); - - iptr+=4; - fptr2+=4; - i-=2; - } - - if (i) - { - xmm2 = _mm_loadu_pd(iptr); - - xmm3 = _mm_load_sd((double *)fptr2); - xmm3 = _mm_cvtps_pd(_mm_castpd_ps(xmm3)); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm3); - } - - xmm1 = _mm_add_pd(xmm1, xmm0); - - xmm3 = xmm1; - xmm1 = _mm_unpackhi_pd(xmm1, xmm3); - xmm1 = _mm_add_pd(xmm1, xmm3); - _mm_store_sd(&sum2, xmm1); - - outptr[0]=sum2; -} - -static void inline SincSample2(double *outptr, const double *inptr, double fracpos, const float *filter, int filtsz, int oversize) -{ - fracpos *= oversize; - const int ifpos=(int)fracpos; - fracpos -= ifpos; - - const float *fptr2=filter + (oversize-ifpos) * filtsz; - const float *fptr=fptr2 - filtsz; - - double sum, sum2, sumb, sum2b; - const double *iptr=inptr; - int i=filtsz/2; - - __m128d xmm0 = _mm_setzero_pd(); - __m128d xmm1 = _mm_setzero_pd(); - __m128d xmm2, xmm3; - __m128 xmm4; - - while (i--) - { - xmm2 = _mm_loadu_pd(iptr); - - xmm4 = _mm_set1_ps(fptr[0]); - xmm3 = _mm_cvtps_pd(xmm4); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm3); - - xmm4 = _mm_set1_ps(fptr2[0]); - xmm3 = _mm_cvtps_pd(xmm4); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm1 = _mm_add_pd(xmm1, xmm3); - - xmm2 = _mm_loadu_pd(iptr+2); - - xmm4 = _mm_set1_ps(fptr[1]); - xmm3 = _mm_cvtps_pd(xmm4); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm3); - - xmm4 = _mm_set1_ps(fptr2[1]); - xmm3 = _mm_cvtps_pd(xmm4); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm1 = _mm_add_pd(xmm1, xmm3); - - iptr+=4; - fptr+=2; - fptr2+=2; - } - - xmm2 = xmm0; - _mm_store_sd(&sum, xmm0); - xmm2 = _mm_unpackhi_pd(xmm2, xmm0); - _mm_store_sd(&sum2, xmm2); - - xmm3 = xmm1; - _mm_store_sd(&sumb, xmm1); - xmm3 = _mm_unpackhi_pd(xmm3, xmm1); - _mm_store_sd(&sum2b, xmm3); - - outptr[0]=sum*fracpos + sumb*(1.0-fracpos); - outptr[1]=sum2*fracpos + sum2b*(1.0-fracpos); -} - -static void inline SincSample2N(double *outptr, const double *inptr, double fracpos, const float *filter, int filtsz, int oversize) -{ - const int ifpos=(int)(fracpos*oversize+0.5); - - const float *fptr2=filter + (oversize-ifpos) * filtsz; - - double sumb, sum2b; - const double *iptr=inptr; - int i=filtsz/2; - - __m128d xmm0 = _mm_setzero_pd(); - __m128d xmm1 = _mm_setzero_pd(); - __m128d xmm2, xmm3; - __m128 xmm4; - - while (i--) - { - xmm2 = _mm_loadu_pd(iptr); - - xmm4 = _mm_set1_ps(fptr2[0]); - xmm3 = _mm_cvtps_pd(xmm4); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm3); - - xmm2 = _mm_loadu_pd(iptr+2); - - xmm4 = _mm_set1_ps(fptr2[1]); - xmm3 = _mm_cvtps_pd(xmm4); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm1 = _mm_add_pd(xmm1, xmm3); - - iptr+=4; - fptr2+=2; - } - - xmm1 = _mm_add_pd(xmm1, xmm0); - - xmm3 = xmm1; - _mm_store_sd(&sumb, xmm1); - xmm3 = _mm_unpackhi_pd(xmm3, xmm1); - _mm_store_sd(&sum2b, xmm3); - - outptr[0]=sumb; - outptr[1]=sum2b; -} - - -static void inline SincSample(double *outptr, const double *inptr, double fracpos, int nch, const double *filter, int filtsz, int oversize) -{ - fracpos *= oversize; - const int ifpos=(int)fracpos; - filter += (oversize-ifpos) * filtsz; - fracpos -= ifpos; - - int x; - for (x = 0; x < nch; x ++) - { - double sum, sum2; - const double *fptr2=filter; - const double *fptr=fptr2 - filtsz; - const double *iptr=inptr+x; - int i=filtsz/2; - - __m128d xmm0 = _mm_setzero_pd(); - __m128d xmm1 = _mm_setzero_pd(); - __m128d xmm2 = _mm_setzero_pd(); - __m128d xmm3 = _mm_setzero_pd(); - __m128d xmm4, xmm5; - - while (i >= 2) - { - xmm4 = _mm_set_pd(iptr[nch], iptr[0]); - - xmm5 = _mm_load_pd(fptr); - xmm5 = _mm_mul_pd(xmm5, xmm4); - xmm0 = _mm_add_pd(xmm0, xmm5); - - xmm5 = _mm_load_pd(fptr2); - xmm5 = _mm_mul_pd(xmm5, xmm4); - xmm1 = _mm_add_pd(xmm1, xmm5); - - xmm4 = _mm_set_pd(iptr[nch*3], iptr[nch*2]); - - xmm5 = _mm_load_pd(fptr+2); - xmm5 = _mm_mul_pd(xmm5, xmm4); - xmm2 = _mm_add_pd(xmm2, xmm5); - - xmm5 = _mm_load_pd(fptr2+2); - xmm5 = _mm_mul_pd(xmm5, xmm4); - xmm3 = _mm_add_pd(xmm3, xmm5); - - iptr+=nch*4; - fptr+=4; - fptr2+=4; - i-=2; - } - - if (i) - { - xmm4 = _mm_set_pd(iptr[nch], iptr[0]); - - xmm5 = _mm_load_pd(fptr); - xmm5 = _mm_mul_pd(xmm5, xmm4); - xmm0 = _mm_add_pd(xmm0, xmm5); - - xmm5 = _mm_load_pd(fptr2); - xmm5 = _mm_mul_pd(xmm5, xmm4); - xmm1 = _mm_add_pd(xmm1, xmm5); - } - - xmm0 = _mm_add_pd(xmm0, xmm2); - xmm1 = _mm_add_pd(xmm1, xmm3); - - xmm2 = xmm0; - xmm0 = _mm_unpackhi_pd(xmm0, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm2); - _mm_store_sd(&sum, xmm0); - - xmm3 = xmm1; - xmm1 = _mm_unpackhi_pd(xmm1, xmm3); - xmm1 = _mm_add_pd(xmm1, xmm3); - _mm_store_sd(&sum2, xmm1); - - outptr[x]=sum*fracpos + sum2*(1.0-fracpos); - } - -} - -static void inline SincSampleN(double *outptr, const double *inptr, double fracpos, int nch, const double *filter, int filtsz, int oversize) -{ - const int ifpos=(int)(fracpos*oversize+0.5); - filter += (oversize-ifpos) * filtsz; - - int x; - for (x = 0; x < nch; x ++) - { - double sum2; - const double *fptr2=filter; - const double *iptr=inptr+x; - int i=filtsz/2; - - __m128d xmm0 = _mm_setzero_pd(); - __m128d xmm1 = _mm_setzero_pd(); - __m128d xmm2, xmm3; - - while (i >= 2) - { - xmm2 = _mm_set_pd(iptr[nch], iptr[0]); - - xmm3 = _mm_load_pd(fptr2); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm3); - - xmm2 = _mm_set_pd(iptr[nch*3], iptr[nch*2]); - - xmm3 = _mm_load_pd(fptr2+2); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm1 = _mm_add_pd(xmm1, xmm3); - - iptr+=nch*4; - fptr2+=4; - i-=2; - } - - if (i) - { - xmm2 = _mm_set_pd(iptr[nch], iptr[0]); - - xmm3 = _mm_load_pd(fptr2); - xmm3 = _mm_mul_pd(xmm3, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm3); - } - - xmm1 = _mm_add_pd(xmm1, xmm0); - - xmm3 = xmm1; - xmm1 = _mm_unpackhi_pd(xmm1, xmm3); - xmm1 = _mm_add_pd(xmm1, xmm3); - _mm_store_sd(&sum2, xmm1); - - outptr[x]=sum2; - } - -} - -static void inline SincSample1(double *outptr, const double *inptr, double fracpos, const double *filter, int filtsz, int oversize) -{ - fracpos *= oversize; - const int ifpos=(int)fracpos; - fracpos -= ifpos; - - double sum, sum2; - const double *fptr2=filter + (oversize-ifpos) * filtsz; - const double *fptr=fptr2 - filtsz; - const double *iptr=inptr; - int i=filtsz/2; - - __m128d xmm0 = _mm_setzero_pd(); - __m128d xmm1 = _mm_setzero_pd(); - __m128d xmm2 = _mm_setzero_pd(); - __m128d xmm3 = _mm_setzero_pd(); - __m128d xmm4, xmm5; - - while (i >= 2) - { - xmm4 = _mm_loadu_pd(iptr); - - xmm5 = _mm_load_pd(fptr); - xmm5 = _mm_mul_pd(xmm5, xmm4); - xmm0 = _mm_add_pd(xmm0, xmm5); - - xmm5 = _mm_load_pd(fptr2); - xmm5 = _mm_mul_pd(xmm5, xmm4); - xmm1 = _mm_add_pd(xmm1, xmm5); - - xmm4 = _mm_loadu_pd(iptr+2); - - xmm5 = _mm_load_pd(fptr+2); - xmm5 = _mm_mul_pd(xmm5, xmm4); - xmm2 = _mm_add_pd(xmm2, xmm5); - - xmm5 = _mm_load_pd(fptr2+2); - xmm5 = _mm_mul_pd(xmm5, xmm4); - xmm3 = _mm_add_pd(xmm3, xmm5); - - iptr+=4; - fptr+=4; - fptr2+=4; - i-=2; - } - - if (i) - { - xmm4 = _mm_loadu_pd(iptr); - - xmm5 = _mm_load_pd(fptr); - xmm5 = _mm_mul_pd(xmm5, xmm4); - xmm0 = _mm_add_pd(xmm0, xmm5); - - xmm5 = _mm_load_pd(fptr2); - xmm5 = _mm_mul_pd(xmm5, xmm4); - xmm1 = _mm_add_pd(xmm1, xmm5); - } - - xmm0 = _mm_add_pd(xmm0, xmm2); - xmm1 = _mm_add_pd(xmm1, xmm3); - - xmm2 = xmm0; - xmm0 = _mm_unpackhi_pd(xmm0, xmm2); - xmm0 = _mm_add_pd(xmm0, xmm2); - _mm_store_sd(&sum, xmm0); - - xmm3 = xmm1; - xmm1 = _mm_unpackhi_pd(xmm1, xmm3); - xmm1 = _mm_add_pd(xmm1, xmm3); - _mm_store_sd(&sum2, xmm1); - - outptr[0]=sum*fracpos+sum2*(1.0-fracpos); -} - -static void inline SincSample1N(double *outptr, const double *inptr, double fracpos, const double *filter, int filtsz, int oversize) -{ - const int ifpos=(int)(fracpos*oversize+0.5); - - double sum2; - const double *fptr2=filter + (oversize-ifpos) * filtsz; - const double *iptr=inptr; - int i=filtsz/2; - - __m128d xmm0 = _mm_setzero_pd(); - __m128d xmm1 = _mm_setzero_pd(); - __m128d xmm2; - - while (i >= 2) - { - xmm2 = _mm_loadu_pd(iptr); - xmm2 = _mm_mul_pd(xmm2, _mm_load_pd(fptr2)); - xmm0 = _mm_add_pd(xmm0, xmm2); - - xmm2 = _mm_loadu_pd(iptr+2); - xmm2 = _mm_mul_pd(xmm2, _mm_load_pd(fptr2+2)); - xmm1 = _mm_add_pd(xmm1, xmm2); - - iptr+=4; - fptr2+=4; - i-=2; - } - - if (i) - { - xmm2 = _mm_loadu_pd(iptr); - xmm2 = _mm_mul_pd(xmm2, _mm_load_pd(fptr2)); - xmm0 = _mm_add_pd(xmm0, xmm2); - } - - xmm1 = _mm_add_pd(xmm1, xmm0); - - xmm2 = xmm1; - xmm1 = _mm_unpackhi_pd(xmm1, xmm2); - xmm1 = _mm_add_pd(xmm1, xmm2); - _mm_store_sd(&sum2, xmm1); - - outptr[0]=sum2; -} - -static void inline SincSample2(double *outptr, const double *inptr, double fracpos, const double *filter, int filtsz, int oversize) -{ - fracpos *= oversize; - const int ifpos=(int)fracpos; - fracpos -= ifpos; - - const double *fptr2=filter + (oversize-ifpos) * filtsz; - const double *fptr=fptr2 - filtsz; - - double sum, sum2, sumb, sum2b; - const double *iptr=inptr; - int i=filtsz/2; - - __m128d xmm0 = _mm_setzero_pd(); - __m128d xmm1 = _mm_setzero_pd(); - __m128d xmm2 = _mm_setzero_pd(); - __m128d xmm3 = _mm_setzero_pd(); - __m128d xmm4, xmm5, xmm6, xmm7; - - while (i--) - { - xmm4 = _mm_load_pd(fptr); - xmm5 = _mm_load_pd(fptr2); - - xmm6 = _mm_loadu_pd(iptr); - - xmm7 = xmm4; - xmm7 = _mm_unpacklo_pd(xmm7, xmm4); - xmm7 = _mm_mul_pd(xmm7, xmm6); - xmm0 = _mm_add_pd(xmm0, xmm7); - - xmm7 = xmm5; - xmm7 = _mm_unpacklo_pd(xmm7, xmm5); - xmm7 = _mm_mul_pd(xmm7, xmm6); - xmm1 = _mm_add_pd(xmm1, xmm7); - - xmm6 = _mm_loadu_pd(iptr+2); - - xmm4 = _mm_unpackhi_pd(xmm4, xmm4); - xmm4 = _mm_mul_pd(xmm4, xmm6); - xmm2 = _mm_add_pd(xmm2, xmm4); - - xmm5 = _mm_unpackhi_pd(xmm5, xmm5); - xmm5 = _mm_mul_pd(xmm5, xmm6); - xmm3 = _mm_add_pd(xmm3, xmm5); - - iptr+=4; - fptr+=2; - fptr2+=2; - } - - xmm0 = _mm_add_pd(xmm0, xmm2); - xmm1 = _mm_add_pd(xmm1, xmm3); - - xmm2 = xmm0; - _mm_store_sd(&sum, xmm0); - xmm2 = _mm_unpackhi_pd(xmm2, xmm0); - _mm_store_sd(&sum2, xmm2); - - xmm3 = xmm1; - _mm_store_sd(&sumb, xmm1); - xmm3 = _mm_unpackhi_pd(xmm3, xmm1); - _mm_store_sd(&sum2b, xmm3); - - outptr[0]=sum*fracpos + sumb*(1.0-fracpos); - outptr[1]=sum2*fracpos + sum2b*(1.0-fracpos); -} - -static void inline SincSample2N(double *outptr, const double *inptr, double fracpos, const double *filter, int filtsz, int oversize) -{ - const int ifpos=(int)(fracpos*oversize+0.5); - - const double *fptr2=filter + (oversize-ifpos) * filtsz; - - double sumb, sum2b; - const double *iptr=inptr; - int i=filtsz/2; - - __m128d xmm0 = _mm_setzero_pd(); - __m128d xmm1 = _mm_setzero_pd(); - __m128d xmm2 = _mm_setzero_pd(); - __m128d xmm3 = _mm_setzero_pd(); - __m128d xmm4, xmm5, xmm6; - - while (i >= 2) - { - xmm4 = _mm_load_pd(fptr2); - xmm5 = xmm4; - - xmm6 = _mm_loadu_pd(iptr); - xmm4 = _mm_unpacklo_pd(xmm4, xmm5); - xmm6 = _mm_mul_pd(xmm6, xmm4); - xmm0 = _mm_add_pd(xmm0, xmm6); - - xmm6 = _mm_loadu_pd(iptr+2); - xmm5 = _mm_unpackhi_pd(xmm5, xmm5); - xmm6 = _mm_mul_pd(xmm6, xmm5); - xmm1 = _mm_add_pd(xmm1, xmm6); - - xmm4 = _mm_load_pd(fptr2+2); - xmm5 = xmm4; - - xmm6 = _mm_loadu_pd(iptr+4); - xmm4 = _mm_unpacklo_pd(xmm4, xmm5); - xmm6 = _mm_mul_pd(xmm6, xmm4); - xmm2 = _mm_add_pd(xmm2, xmm6); - - xmm6 = _mm_loadu_pd(iptr+6); - xmm5 = _mm_unpackhi_pd(xmm5, xmm5); - xmm6 = _mm_mul_pd(xmm6, xmm5); - xmm3 = _mm_add_pd(xmm3, xmm6); - - iptr+=8; - fptr2+=4; - i-=2; - } - - if (i) - { - xmm4 = _mm_load_pd(fptr2); - xmm5 = xmm4; - - xmm6 = _mm_loadu_pd(iptr); - xmm4 = _mm_unpacklo_pd(xmm4, xmm5); - xmm6 = _mm_mul_pd(xmm6, xmm4); - xmm0 = _mm_add_pd(xmm0, xmm6); - - xmm6 = _mm_loadu_pd(iptr+2); - xmm5 = _mm_unpackhi_pd(xmm5, xmm5); - xmm6 = _mm_mul_pd(xmm6, xmm5); - xmm1 = _mm_add_pd(xmm1, xmm6); - } - - xmm0 = _mm_add_pd(xmm0, xmm2); - xmm1 = _mm_add_pd(xmm1, xmm3); - - xmm1 = _mm_add_pd(xmm1, xmm0); - - xmm3 = xmm1; - _mm_store_sd(&sumb, xmm1); - xmm3 = _mm_unpackhi_pd(xmm3, xmm1); - _mm_store_sd(&sum2b, xmm3); - - outptr[0]=sumb; - outptr[1]=sum2b; -} - -#endif // WDL_RESAMPLE_USE_SSE - - -WDL_Resampler::WDL_Resampler() -{ - m_sinc_ideal_calced = -1; - m_filterq=0.707f; - m_filterpos=0.693f; // .792 ? - - m_sincoversize=0; - m_lp_oversize=1; - m_sincsize=0; - m_prepost_filtercnt = 1; - m_interp=true; - m_feedmode=false; - - m_filter_coeffs_size=0; - m_sratein=44100.0; - m_srateout=44100.0; - m_ratio=1.0; - m_filter_ratio=-1.0; - m_pre_filter = NULL; - m_post_filter = NULL; - - Reset(); -} - -WDL_Resampler::~WDL_Resampler() -{ - delete m_pre_filter; - delete m_post_filter; -} - -void WDL_Resampler::Reset(double fracpos) -{ - m_last_requested=0; - m_filtlatency=0; - m_fracpos=fracpos; - m_samples_in_rsinbuf=0; - m_rsinbuf_nch=0; - if (m_sinc_ideal_calced == -2) m_sinc_ideal_calced = -1; - if (m_pre_filter) m_pre_filter->Reset(); - if (m_post_filter) m_post_filter->Reset(); -} - -void WDL_Resampler::SetMode(bool interp, int filtercnt, bool sinc, int sinc_size, int sinc_interpsize) -{ - m_sincsize = sinc && sinc_size>= 4 ? sinc_size > 8192 ? 8192 : (sinc_size&~1) : 0; - m_sincoversize = m_sincsize ? (sinc_interpsize<= 1 ? 1 : sinc_interpsize>=8192 ? 8192 : sinc_interpsize) : 1; - - m_prepost_filtercnt = m_sincsize ? 0 : wdl_max(filtercnt,0); - m_interp=interp && !m_sincsize; - - if (!m_sincsize) - { - m_filter_coeffs.Resize(0); - m_filter_coeffs_size=0; - } - if (!m_prepost_filtercnt) - { - delete m_pre_filter; - m_pre_filter=NULL; - delete m_post_filter; - m_post_filter=NULL; - } -} - -void WDL_Resampler::SetRates(double rate_in, double rate_out) -{ - if (rate_in<1.0) rate_in=1.0; - if (rate_out<1.0) rate_out=1.0; - if (rate_in != m_sratein || rate_out != m_srateout) - { - m_sratein=rate_in; - m_srateout=rate_out; - m_ratio=m_sratein / m_srateout; - m_sinc_ideal_calced = -1; - } -} - -const WDL_SincFilterSample *WDL_Resampler::BuildLowPass(double filtpos, bool *isIdeal) // only called in sinc modes -{ - const int wantsize=m_sincsize; - int wantinterp=m_sincoversize; - - int ideal_interp = 0; - if (wantinterp) - { - if (m_sinc_ideal_calced == -1) - { - if (m_ratio < 1.0) - { - const double drat = m_srateout/m_sratein; - const int irat = (int) (drat + 0.5); - if (irat > 1 && irat==drat) ideal_interp=irat; - } - else - { - const int irat = (int) (m_ratio + 0.5); - if (m_ratio == irat) ideal_interp=1; // eg 96k to 48k, only need one table - } - - if (!ideal_interp) - { - // if whole integer rates, calculate GCD - const int in1 = (int)m_sratein, out1 = (int)m_srateout; - if (out1 > 0 && in1 > 0 && m_sratein == (double)in1 && m_srateout == (double)out1) - { - // don't bother finding the GCD if it's lower than is useful - int min_cd = out1 / (2*wantinterp); - if (min_cd < 1) min_cd = 1; - - int n1 = out1, n2=in1; - while (n2 >= min_cd) - { - const int tmp = n1; - n1 = n2; - n2 = tmp % n2; - } - if (!n2) - ideal_interp = out1 / n1; - } - } - if (ideal_interp > 0 && m_fracpos != 0.0) - { - // should maybe see if m_fracpos maps losslessly to ideal_interp - ideal_interp = -2; - } - m_sinc_ideal_calced = ideal_interp; - } - else - ideal_interp = m_sinc_ideal_calced; - - if (ideal_interp > 0 && ideal_interp <= wantinterp*2) // use ideal filter for reduced cpu use even if it means more memory - { - wantinterp = ideal_interp; - } - } - - *isIdeal = ideal_interp == wantinterp; - if (m_filter_ratio!=filtpos || - m_filter_coeffs_size != wantsize || - m_lp_oversize != wantinterp) - { - m_lp_oversize = wantinterp; - m_filter_ratio=filtpos; - - // build lowpass filter - const int allocsize = wantsize*(m_lp_oversize+1); - const int alignedsize = allocsize + 16/sizeof(WDL_SincFilterSample) - 1; - if (m_filter_coeffs.ResizeOK(alignedsize)) - { - WDL_SincFilterSample *cfout=m_filter_coeffs.GetAligned(16); - m_filter_coeffs_size=wantsize; - - const double dwindowpos = 2.0 * PI/(double)wantsize; - const double dsincpos = PI * filtpos; // filtpos is outrate/inrate, i.e. 0.5 is going to half rate - const int hwantsize=wantsize/2, hwantinterp=wantinterp/2; - - double filtpower=0.0; - WDL_SincFilterSample *ptrout = cfout; - int slice; - for (slice=0;slice<=hwantinterp;slice++) - { - const double frac = slice / (double)wantinterp; - const int center_x = slice == 0 ? hwantsize : -1; - - const int n = ((slice < hwantinterp) | (wantinterp & 1)) ? wantsize : hwantsize; - int x; - for (x=0;x= 0; ++x, --y) cfout[x] = cfout[y]; - } - else m_filter_coeffs_size=0; - - } - return m_filter_coeffs_size > 0 ? m_filter_coeffs.GetAligned(16) : NULL; -} - -double WDL_Resampler::GetCurrentLatency() -{ - double v=((double)m_samples_in_rsinbuf-m_filtlatency)/m_sratein; - - if (v<0.0)v=0.0; - return v; -} - -static void wdl_rs_reinterleave_buffer(WDL_ResampleSample *rdptr, int in_nch, int out_nch, int len) -{ - if (len < 1 || !rdptr) return; - - int x=len-1; - WDL_ResampleSample *wrptr = rdptr; - if (out_nch < in_nch) - { - const int sz1=out_nch*sizeof(WDL_ResampleSample); - while (x--) - { - rdptr += in_nch; - wrptr += out_nch; - memmove(wrptr,rdptr,sz1); - } - } - else if (out_nch > in_nch) - { - const int sz1=in_nch*sizeof(WDL_ResampleSample); - const int sz2=(out_nch-in_nch)*sizeof(WDL_ResampleSample); - rdptr += in_nch*x; - wrptr += out_nch*x; - while(x--) - { - memmove(wrptr,rdptr,sz1); - memset(wrptr+in_nch,0,sz2); - - rdptr-=in_nch; - wrptr-=out_nch; - } - memset(wrptr+in_nch,0,sz2); // last iteration doesnt need memcpy (but does need clear) - } -} - -int WDL_Resampler::ResamplePrepare(int out_samples, int nch, WDL_ResampleSample **inbuffer) -{ - if (nch < 1) return 0; - - if (m_prepost_filtercnt > 0) - { - if (!m_pre_filter) m_pre_filter = new WDL_Resampler_Filter; - m_pre_filter->setParms(1.0/m_ratio,m_filterpos,m_filterq, m_prepost_filtercnt,nch); - if (!m_post_filter) m_post_filter = new WDL_Resampler_Filter; - m_post_filter->setParms(m_ratio,m_filterpos,m_filterq, m_prepost_filtercnt,nch); - } - - int fsize=0; - if (m_sincsize>1) fsize = m_sincsize; - - int hfs=fsize/2; - if (hfs>1 && m_samples_in_rsinbuf0) - { - WDL_ResampleSample *p = m_rsinbuf.Resize(m_samples_in_rsinbuf*nch,false); - memset(p,0,sizeof(WDL_ResampleSample)*m_rsinbuf.GetSize()); - } - } - - int sreq = 0; - - if (!m_feedmode) sreq = (int)(m_ratio * out_samples) + 4 + fsize - m_samples_in_rsinbuf; - else sreq = out_samples; - - if (sreq<0)sreq=0; - - // if decreasing channel count, reinterleave before realloc - if (nch < m_rsinbuf_nch && m_rsinbuf_nch > 0 && m_samples_in_rsinbuf) - wdl_rs_reinterleave_buffer(m_rsinbuf.Get(), m_rsinbuf_nch, nch, m_samples_in_rsinbuf); - -again: - m_rsinbuf.Resize((m_samples_in_rsinbuf+sreq)*nch,false); - - int sz = m_rsinbuf.GetSize()/(nch?nch:1) - m_samples_in_rsinbuf; - if (sz!=sreq) - { - if (sreq>4 && !sz) - { - sreq/=2; - goto again; // try again with half the size - } - // todo: notify of error? - sreq=sz; - } - - // if increasing channel count, reinterleave after realloc - if (m_rsinbuf_nch < nch && m_rsinbuf_nch > 0 && m_samples_in_rsinbuf) - wdl_rs_reinterleave_buffer(m_rsinbuf.Get(), m_rsinbuf_nch, nch, m_samples_in_rsinbuf); - - m_rsinbuf_nch = nch; - - *inbuffer = m_rsinbuf.Get() + m_samples_in_rsinbuf*nch; - - m_last_requested=sreq; - return sreq; -} - - - -int WDL_Resampler::ResampleOut(WDL_ResampleSample *out, int nsamples_in, int nsamples_out, int nch) -{ - if (nch < 1) return 0; -#ifdef WDL_DENORMAL_WANTS_SCOPED_FTZ - WDL_denormal_ftz_scope ftz_force; -#endif - - if (m_pre_filter && nsamples_in > 0) // filter input - { - m_pre_filter->ApplyBuffer(m_rsinbuf.Get() + m_samples_in_rsinbuf*nch,nsamples_in,nch); - } - - // prevent the caller from corrupting the internal state - m_samples_in_rsinbuf += nsamples_in < m_last_requested ? nsamples_in : m_last_requested; - - int rsinbuf_availtemp = m_samples_in_rsinbuf; - - if (nsamples_in < m_last_requested) // flush out to ensure we can deliver - { - int fsize=(m_last_requested-nsamples_in)*2 + m_sincsize*2; - - int alloc_size=(m_samples_in_rsinbuf+fsize)*nch; - WDL_ResampleSample *zb=m_rsinbuf.Resize(alloc_size,false); - if (m_rsinbuf.GetSize()==alloc_size) - { - memset(zb+m_samples_in_rsinbuf*nch,0,fsize*nch*sizeof(WDL_ResampleSample)); - rsinbuf_availtemp = m_samples_in_rsinbuf+fsize; - } - } - - int ret=0; - double srcpos=m_fracpos; - double drspos = m_ratio; - WDL_ResampleSample *localin = m_rsinbuf.Get(); - - WDL_ResampleSample *outptr=out; - - int ns=nsamples_out; - - int outlatadj=0; - - bool isideal = false; - if (m_sincsize) // sinc interpolating - { - const WDL_SincFilterSample *filter; - if (m_ratio > 1.0) filter=BuildLowPass(1.0 / (m_ratio*1.03), &isideal); - else filter=BuildLowPass(1.0, &isideal); - - const int oversize = m_lp_oversize; - int filtsz=m_filter_coeffs_size; - int filtlen = rsinbuf_availtemp - filtsz; - outlatadj=filtsz/2-1; - - if (WDL_NOT_NORMALLY(!filter)) {} - else if (nch == 1) - { - if (isideal) - while (ns--) - { - int ipos = (int)srcpos; - - if (ipos >= filtlen-1) break; // quit decoding, not enough input samples - - SincSample1N(outptr,localin + ipos,srcpos-ipos,filter,filtsz,oversize); - outptr ++; - srcpos+=drspos; - ret++; - } - else - while (ns--) - { - int ipos = (int)srcpos; - - if (ipos >= filtlen-1) break; // quit decoding, not enough input samples - - SincSample1(outptr,localin + ipos,srcpos-ipos,filter,filtsz,oversize); - outptr ++; - srcpos+=drspos; - ret++; - } - } - else if (nch==2) - { - if (isideal) - while (ns--) - { - int ipos = (int)srcpos; - - if (ipos >= filtlen-1) break; // quit decoding, not enough input samples - - SincSample2N(outptr,localin + ipos*2,srcpos-ipos,filter,filtsz,oversize); - outptr+=2; - srcpos+=drspos; - ret++; - } - else - while (ns--) - { - int ipos = (int)srcpos; - - if (ipos >= filtlen-1) break; // quit decoding, not enough input samples - - SincSample2(outptr,localin + ipos*2,srcpos-ipos,filter,filtsz,oversize); - outptr+=2; - srcpos+=drspos; - ret++; - } - } - else - { - if (isideal) - while (ns--) - { - int ipos = (int)srcpos; - - if (ipos >= filtlen-1) break; // quit decoding, not enough input samples - - SincSampleN(outptr,localin + ipos*nch,srcpos-ipos,nch,filter,filtsz,oversize); - outptr += nch; - srcpos+=drspos; - ret++; - } - else - while (ns--) - { - int ipos = (int)srcpos; - - if (ipos >= filtlen-1) break; // quit decoding, not enough input samples - - SincSample(outptr,localin + ipos*nch,srcpos-ipos,nch,filter,filtsz,oversize); - outptr += nch; - srcpos+=drspos; - ret++; - } - } - } - else if (!m_interp) // point sampling - { - if (nch == 1) - { - while (ns--) - { - int ipos = (int)srcpos; - if (ipos >= rsinbuf_availtemp) break; // quit decoding, not enough input samples - - *outptr++ = localin[ipos]; - srcpos+=drspos; - ret++; - } - } - else if (nch == 2) - { - while (ns--) - { - int ipos = (int)srcpos; - if (ipos >= rsinbuf_availtemp) break; // quit decoding, not enough input samples - - ipos+=ipos; - - outptr[0] = localin[ipos]; - outptr[1] = localin[ipos+1]; - outptr+=2; - srcpos+=drspos; - ret++; - } - } - else - while (ns--) - { - int ipos = (int)srcpos; - if (ipos >= rsinbuf_availtemp) break; // quit decoding, not enough input samples - - memcpy(outptr,localin + ipos*nch,nch*sizeof(WDL_ResampleSample)); - outptr += nch; - srcpos+=drspos; - ret++; - } - } - else // linear interpolation - { - if (nch == 1) - { - while (ns--) - { - int ipos = (int)srcpos; - double fracpos=srcpos-ipos; - - if (ipos >= rsinbuf_availtemp-1) - { - break; // quit decoding, not enough input samples - } - - double ifracpos=1.0-fracpos; - WDL_ResampleSample *inptr = localin + ipos; - *outptr++ = inptr[0]*(ifracpos) + inptr[1]*(fracpos); - srcpos+=drspos; - ret++; - } - } - else if (nch == 2) - { - while (ns--) - { - int ipos = (int)srcpos; - double fracpos=srcpos-ipos; - - if (ipos >= rsinbuf_availtemp-1) - { - break; // quit decoding, not enough input samples - } - - double ifracpos=1.0-fracpos; - WDL_ResampleSample *inptr = localin + ipos*2; - outptr[0] = inptr[0]*(ifracpos) + inptr[2]*(fracpos); - outptr[1] = inptr[1]*(ifracpos) + inptr[3]*(fracpos); - outptr += 2; - srcpos+=drspos; - ret++; - } - } - else - { - while (ns--) - { - int ipos = (int)srcpos; - double fracpos=srcpos-ipos; - - if (ipos >= rsinbuf_availtemp-1) - { - break; // quit decoding, not enough input samples - } - - double ifracpos=1.0-fracpos; - int ch=nch; - WDL_ResampleSample *inptr = localin + ipos*nch; - while (ch--) - { - *outptr++ = inptr[0]*(ifracpos) + inptr[nch]*(fracpos); - inptr++; - } - srcpos+=drspos; - ret++; - } - } - } - - - if (ret > 0 && m_post_filter) // filter output - { - m_post_filter->ApplyBuffer(out,ret,nch); - } - - if (ret>0 && rsinbuf_availtemp>m_samples_in_rsinbuf) // we had to pad!! - { - // check for the case where rsinbuf_availtemp>m_samples_in_rsinbuf, decrease ret down to actual valid samples - double adj=(srcpos-m_samples_in_rsinbuf + outlatadj) / drspos; - if (adj>0) - { - ret -= (int) (adj + 0.5); - if (ret<0)ret=0; - } - } - - int isrcpos=(int)srcpos; - if (isrcpos > m_samples_in_rsinbuf) isrcpos=m_samples_in_rsinbuf; - m_fracpos = srcpos - isrcpos; - - if (m_sincsize && isideal) - m_fracpos = floor(m_lp_oversize*m_fracpos + 0.5)/m_lp_oversize; - - m_samples_in_rsinbuf -= isrcpos; - if (m_samples_in_rsinbuf <= 0) m_samples_in_rsinbuf=0; - else - memmove(localin, localin + isrcpos*nch,m_samples_in_rsinbuf*sizeof(WDL_ResampleSample)*nch); - - - return ret; -} diff --git a/oversampling/WDL/resample.h b/oversampling/WDL/resample.h deleted file mode 100644 index 09e22ba..0000000 --- a/oversampling/WDL/resample.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - WDL - resample.h - Copyright (C) 2010 and later Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - You may also distribute this software under the LGPL v2 or later. - -*/ - -#ifndef _WDL_RESAMPLE_H_ -#define _WDL_RESAMPLE_H_ - -#include -#include -#include "wdltypes.h" -#include "heapbuf.h" - -// default to floats for sinc filter ceofficients -#ifdef WDL_RESAMPLE_FULL_SINC_PRECISION -typedef double WDL_SincFilterSample; -#else -typedef float WDL_SincFilterSample; -#endif - -// default to doubles for audio samples -#ifdef WDL_RESAMPLE_TYPE -typedef WDL_RESAMPLE_TYPE WDL_ResampleSample; -#else -typedef double WDL_ResampleSample; -#endif - - -class WDL_Resampler -{ -public: - WDL_Resampler(); - ~WDL_Resampler(); - // if sinc set, it overrides interp or filtercnt - void SetMode(bool interp, int filtercnt, bool sinc, int sinc_size=64, int sinc_interpsize=32); - - void SetFilterParms(float filterpos=0.693, float filterq=0.707) { m_filterpos=filterpos; m_filterq=filterq; } // used for filtercnt>0 but not sinc - void SetFeedMode(bool wantInputDriven) { m_feedmode=wantInputDriven; } // if true, that means the first parameter to ResamplePrepare will specify however much input you have, not how much you want - - void Reset(double fracpos=0.0); - void SetRates(double rate_in, double rate_out); - - double GetCurrentLatency(); // amount of input that has been received but not yet converted to output, in seconds - - // req_samples is output samples desired if !wantInputDriven, or if wantInputDriven is input samples that we have - // returns number of samples desired (put these into *inbuffer) - // note that it is safe to call ResamplePrepare without calling ResampleOut (the next call of ResamplePrepare will function as normal) - int ResamplePrepare(int req_samples, int nch, WDL_ResampleSample **inbuffer); - - - // if numsamples_in < the value return by ResamplePrepare(), then it will be flushed to produce all remaining valid samples - // do NOT call with nsamples_in greater than the value returned from resamplerprpare()! the extra samples will be ignored. - // returns number of samples successfully outputted to out - int ResampleOut(WDL_ResampleSample *out, int nsamples_in, int nsamples_out, int nch); - - - -private: - const WDL_SincFilterSample *BuildLowPass(double filtpos, bool *isIdeal); - - double m_sratein WDL_FIXALIGN; - double m_srateout; - double m_fracpos; - double m_ratio; - double m_filter_ratio; - float m_filterq, m_filterpos; - WDL_TypedBuf m_rsinbuf; - WDL_TypedBuf m_filter_coeffs; - - class WDL_Resampler_Filter; - WDL_Resampler_Filter *m_pre_filter, *m_post_filter; - int m_prepost_filtercnt; - - int m_filter_coeffs_size; - int m_last_requested; - int m_filtlatency; - int m_samples_in_rsinbuf; - int m_rsinbuf_nch; - int m_lp_oversize; - int m_sinc_ideal_calced; // -1=not yet calced - - int m_sincsize; - int m_sincoversize; - bool m_interp; - bool m_feedmode; - -}; - - - -#endif diff --git a/oversampling/WDL/rng.cpp b/oversampling/WDL/rng.cpp deleted file mode 100644 index e02dc2e..0000000 --- a/oversampling/WDL/rng.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - WDL - rng.cpp - Copyright (C) 2005 and later, Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - -*/ - -/* - - This file provides the implementation of a decent random number generator, - that internally uses a 256-bit state, and SHA-1 to iterate. - -*/ - -#ifdef _WIN32 -#include -#else -#include -#include -#include -#endif - - -#include "rng.h" -#include "sha.h" - -static unsigned char state[32]; - -void WDL_RNG_addentropy(void *buf, int buflen) -{ - WDL_SHA1 tmp; - tmp.add(state,sizeof(state)); - tmp.result(state); - tmp.reset(); - tmp.add((unsigned char *)buf,buflen); - tmp.result(state+sizeof(state) - WDL_SHA1SIZE); -} - -static void rngcycle() -{ - int i; - for (i = 0; i < (int)sizeof(state) && state[i]++; i++); -} - -int WDL_RNG_int32() -{ - WDL_SHA1 tmp; - tmp.add(state,sizeof(state)); - rngcycle(); - union { - char buf[WDL_SHA1SIZE]; - int a; - } b; - tmp.result(b.buf); - return b.a; - -} - - -void WDL_RNG_bytes(void *buf, int buflen) -{ - char *b=(char *)buf; - while (buflen > 0) - { - char tb[WDL_SHA1SIZE]; - WDL_SHA1 tmp; - tmp.add(state,sizeof(state)); - rngcycle(); - - tmp.result(tb); - const int l=buflen < WDL_SHA1SIZE ? buflen : WDL_SHA1SIZE; - memcpy(b,tb,l); - buflen-=l; - b+=l; - } -} - diff --git a/oversampling/WDL/rng.h b/oversampling/WDL/rng.h deleted file mode 100644 index 85fb21c..0000000 --- a/oversampling/WDL/rng.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - WDL - rng.h - Copyright (C) 2005 and later, Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - -*/ - -/* - - This header provides the interface to a decent random number generator, - that internally uses a 256-bit state, and SHA-1 to iterate. We wouldn't consider - this RNG to be cryptographically secure, but it may be decent. - -*/ - -#ifndef _WDL_RNG_H_ -#define _WDL_RNG_H_ - - -void WDL_RNG_addentropy(void *buf, int buflen); // add entropy to the RNG - -int WDL_RNG_int32(); // get a random integer -void WDL_RNG_bytes(void *buf, int buflen); // get a random string of bytes - - -#endif - diff --git a/oversampling/WDL/rpool.h b/oversampling/WDL/rpool.h deleted file mode 100644 index 52f7380..0000000 --- a/oversampling/WDL/rpool.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - WDL - rpool.h - Copyright (C) 2006 and later, Cockos Incorporated - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - - This file defines a template for a class that stores a list of objects, and allows the caller - to periodically get an object, do something with it, and add it back into the pool. - - When the caller does this, it can set ownership of the object, and an expiration for that ownership. - - - The PTYPE1 and PTYPE2entries for the template are there to store additional information (for use with poollist.h) - - - This is pretty esoteric. But we use it for some things. - -*/ - - -#ifndef _WDL_RPOOL_H_ -#define _WDL_RPOOL_H_ - -// resource pool (time based) - -#include "ptrlist.h" -#include "mutex.h" - -class WDL_ResourcePool_ResInfo // include in class RTYPE as WDL_ResourcePool_ResInfo m_rpoolinfo; -{ -public: - WDL_ResourcePool_ResInfo(){ m_owneduntil=0; m_ownerptr=0; next=0; } - ~WDL_ResourcePool_ResInfo() {} - - unsigned int m_owneduntil; - void *m_ownerptr; - - void *next; -} WDL_FIXALIGN; - - -template class WDL_ResourcePool -{ - public: - WDL_ResourcePool(char *identstr) - { - WDL_POOLLIST_refcnt=0; - WDL_POOLLIST_identstr=identstr; - m_rlist=NULL; - extraInfo=0; - m_hadres=false; - } - ~WDL_ResourcePool() - { - while (m_rlist) - { - RTYPE *tp=m_rlist; - m_rlist=(RTYPE *)m_rlist->m_rpoolinfo.next; - delete tp; - } - delete extraInfo; - } - void Clear() - { - m_mutex.Enter(); - while (m_rlist) - { - RTYPE *tp=m_rlist; - m_rlist=(RTYPE *)m_rlist->m_rpoolinfo.next; - delete tp; - } - m_hadres=false; - m_mutex.Leave(); - } - bool HasResources() - { - return m_hadres; - } - - void AddResource(RTYPE *item, void *own, unsigned int until) - { - item->m_rpoolinfo.m_ownerptr = own; - item->m_rpoolinfo.m_owneduntil = until; - - m_mutex.Enter(); - item->m_rpoolinfo.next = m_rlist; - m_rlist = item; - m_hadres=true; - m_mutex.Leave(); - } - - void ReleaseResources(void *own) - { - m_mutex.Enter(); - RTYPE *ent=m_rlist; - while (ent) - { - if (ent->m_rpoolinfo.m_ownerptr == own) - { - ent->m_rpoolinfo.m_ownerptr = 0; - ent->m_rpoolinfo.m_owneduntil=0; - } - ent=(RTYPE *)ent->m_rpoolinfo.next; - } - m_mutex.Leave(); - } - - RTYPE *GetResource(void *own, unsigned int now, int flags=0) // flags&1 to only match owner (not look at owneduntil). flags&2 to ignore owneduntil and always take from others (greedy) - { - m_mutex.Enter(); - RTYPE *ent=m_rlist, *lastent=NULL, *bestent=NULL, *bestlastent=NULL; - bool bestnoown=false; - while (ent) - { - if (ent->m_rpoolinfo.m_ownerptr == own) - { - if (lastent) lastent->m_rpoolinfo.next = ent->m_rpoolinfo.next; - else m_rlist = (RTYPE *)ent->m_rpoolinfo.next; - m_mutex.Leave(); - return ent; - } - - if (!bestnoown) - { - if (!ent->m_rpoolinfo.m_ownerptr || - (flags & 2) || - (!(flags & 1) && (now - (ent->m_rpoolinfo.m_owneduntil+1)) <= 0x7FFFFFFF)) - { - bestent=ent; - bestlastent=lastent; - if (!ent->m_rpoolinfo.m_ownerptr || !ent->m_rpoolinfo.m_owneduntil) bestnoown=true; - } - } - lastent=ent; - ent=(RTYPE *)ent->m_rpoolinfo.next; - } - - if (bestent) - { - if (bestlastent) bestlastent->m_rpoolinfo.next = bestent->m_rpoolinfo.next; - else m_rlist = (RTYPE *)bestent->m_rpoolinfo.next; - } - - m_mutex.Leave(); - return bestent; - } - - int WDL_POOLLIST_refcnt; - char *WDL_POOLLIST_identstr; - bool m_hadres; - - EXTRAINFOTYPE *extraInfo; - - RTYPE *PeekList() - { - return m_rlist; - } - void LockList() - { - m_mutex.Enter(); - } - void UnlockList() - { - m_mutex.Leave(); - } - -private: - - WDL_Mutex m_mutex; - RTYPE *m_rlist; - -} WDL_FIXALIGN; - - - -#endif diff --git a/oversampling/WDL/sc_bounce/index.html b/oversampling/WDL/sc_bounce/index.html deleted file mode 100644 index 3fd2c20..0000000 --- a/oversampling/WDL/sc_bounce/index.html +++ /dev/null @@ -1,50 +0,0 @@ - - -stream - - - -
...loading...
-
-